/* -*- 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 .
*/
// reset the RequestHandler of the used Outliner to the handler of the document
::Outliner* pOutliner = mpView->GetTextEditOutliner();
if (pOutliner)
pOutliner->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(mrDoc.GetStyleSheetPool()));
}
}
/************************************************************************* |* |* Execute functionality of this class: |* |* #71422: Start the functionality of this class in this method |* and not in the ctor. |* If you construct an object of this class and you put the |* address of this object to pFuActual you've got a problem, |* because some methods inside DoExecute use the pFuActual-Pointer. |* If the code inside DoExecute is executed inside the ctor, |* the value of pFuActual is not right. And the value will not |* be right until the ctor finished !!! |*
\************************************************************************/ void FuText::DoExecute( SfxRequest& )
{
mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBarShell(
ToolBarManager::ToolBarGroup::Function,
ToolbarId::Draw_Text_Toolbox_Sd);
// handle URL also during the text editing if (rMEvt.GetClicks() == 1 && rMEvt.IsLeft() && rMEvt.IsMod1())
{
OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
if (mxTextObj.get().is() && pOLV && pOLV->GetFieldUnderMousePointer())
{ const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer(); if (pFieldItem)
{ const SvxFieldData* pField = pFieldItem->GetField();
if (eHit == SdrHitKind::TextEdit)
{ // hit text -> SdrView handles event if (mpView->MouseButtonDown(rMEvt, mpWindow->GetOutDev())) returntrue;
}
if (rMEvt.GetClicks() == 1)
{ if (mpView->IsTextEdit() && eHit != SdrHitKind::MarkedObject && eHit != SdrHitKind::Handle)
{ // finish text input if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
{ /* Bugfix from MBA: during a double click onto the unused? area in text mode, we get with the second click eHit = SdrHitKind::TextEditObj since it goes to the TextObject which was created with the first click. But this is removed by SdrEndTextEdit since it is empty. But it is still in the mark list. The call MarkObj further below accesses then the dead object. As a simple fix, we determine eHit after
SdrEndTextEdit again, this returns then SdrHitKind::NONE. */
mxTextObj = nullptr;
eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
}
if (rMEvt.IsMod1())
{ // open in new frame
pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
{ &aStrItem, &aBrowseItem, &aReferer });
} else
{ // open in current frame
SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
pFrame->GetDispatcher()->ExecuteList(SID_OPENDOC,
SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
{ &aStrItem, &aFrameItem, &aBrowseItem, &aReferer });
}
}
} else
{ // drag object or handle
// #i78748# // do the EndTextEdit first, it will delete the handles and force a // recreation. This will make aVEvt.mpHdl to point to a deleted handle, // thus it is necessary to reset it and to get it again.
// #i112855# // cl: I'm not sure why we checked here also for mxTextObj->GetOutlinerParaObject // this caused SdrEndTextEdit() to be called also when not in text editing and // this does not make sense and caused troubles. (see issue 112855)
if(aVEvt.mpHdl)
{ // force new handle identification, the pointer will be dead here // since SdrEndTextEdit has reset (deleted) the handles.
aVEvt.mpHdl = nullptr;
mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
}
}
if (!aVEvt.mpHdl)
{ if( eHit == SdrHitKind::UnmarkedObject )
{ if ( !rMEvt.IsShift() )
mpView->UnmarkAll();
// Set defaults for vertical click-n'drag text object, pool defaults are: // SdrTextVertAdjustItem: SDRTEXTVERTADJUST_TOP // SdrTextHorzAdjustItem: SDRTEXTHORZADJUST_BLOCK // Analog to that:
aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK));
aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
if (bJustEndedEdit)
{
bJustEndedEdit = false;
FuPoor::cancel();
} if ((rMEvt.GetClicks() != 2) &&
!rMEvt.IsShift() && !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsRight() &&
std::abs(aPnt.X() - aMDPos.X()) < nDrgLog &&
std::abs(aPnt.Y() - aMDPos.Y()) < nDrgLog)
{ /************************************************************* * From text mode, you don't want to rotate immediately.
**************************************************************/
SdrPageView* pPV;
SdrObject* pObj = mpView->PickObj(aMDPos, mpView->getHitTolLog(), pPV, SdrSearchOptions::ALSOONMASTER | SdrSearchOptions::BEFOREMARK); if (pObj && pPV->IsObjMarkable(pObj))
{
mpView->UnmarkAllObj();
mpView->MarkObj(pObj,pPV); return bReturn;
}
}
} elseif( mpView && mpView->IsCreateObj() && rMEvt.IsLeft())
{ // object was created
rtl::Reference<SdrTextObj> pTextObj = DynCastSdrTextObj( mpView->GetCreateObj() );
mxTextObj = pTextObj.get();
if( pTextObj )
{ //AW outliner needs to be set to vertical when there is no // outliner object up to now; also it needs to be set back to not // vertical when there was a vertical one used last time.
OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject();
SdrOutliner& rOutl(pTextObj->getSdrModelFromSdrObject().GetDrawOutliner(GetTextObj())); bool bVertical((pOPO && pOPO->IsEffectivelyVertical())
|| nSlotId == SID_ATTR_CHAR_VERTICAL
|| nSlotId == SID_TEXT_FITTOSIZE_VERTICAL);
rOutl.SetVertical(bVertical);
// Before ImpSetAttributesForNewTextObject the vertical writing mode // needs to be set at the object. This is done here at the OutlinerParaObject // directly to not mirror the layout text items involved. These items will be set // from ImpSetAttributesForNewTextObject and below.
OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
if (!mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
{ // it was not possible to create text object
mxTextObj = nullptr;
pTextObj = nullptr;
} elseif (nSlotId == SID_TEXT_FITTOSIZE)
{
ImpSetAttributesFitToSize(GetTextObj());
if(nSlotId == SID_ATTR_CHAR_VERTICAL)
{ // Here, all items which need to be different from pool default need to be set // again on the newly created text object. // Since this is a simple click text object, it is first created, then SetVertical() // is used, then ImpSetAttributesForNewTextObject is called and then the object is // deleted again since not the minimum drag distance was travelled. Then, a new // click text object is created and thus all that stuff needs to be set again here.
// Before using the new object the vertical writing mode // needs to be set. This is done here at the OutlinerParaObject // directly to not mirror the layout text items involved. These items will be set // below.
OutlinerParaObject* pPara = GetTextObj()->GetOutlinerParaObject();
// Analog to the else case below, for vertical simple click texts // one of the default set items from ImpSetAttributesForNewTextObject // needs to be adapted to non-block mode. const SfxItemSet& rSet = mpView->GetDefaultAttr();
SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue();
if(SvxFrameDirection::Horizontal_RL_TB == eDirection || SvxFrameDirection::Vertical_RL_TB == eDirection)
{
aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM));
} else
{
aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
}
} else
{ // This is for Format/Page settings. Since this also leads // to the object defaults to be changed, i think this code can be // removed. CL. wanted to take a look before adding this.
// Look in the object defaults if left-to-right is wanted. If // yes, set text anchoring to right to let the box grow to left. const SfxItemSet& rSet = mpView->GetDefaultAttr();
SvxFrameDirection eDirection = rSet.Get(EE_PARA_WRITINGDIR).GetValue();
if(mxTextObj.get().is())
{ // maybe object is deleted, test if it's equal to the selected object const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
SdrObject* pSelectedObj = nullptr;
if (mpDocSh->IsReadOnly())
{
bOK = !EditEngine::DoesKeyChangeText(aKEvt);
} if( aKeyCode.GetCode() == KEY_PAGEUP || aKeyCode.GetCode() == KEY_PAGEDOWN )
{
bOK = false; // default handling in base class
}
if (bOK && mpView->KeyInput(aKEvt, mpWindow) )
{
bReturn = true;
// #i89661# it's no longer necessary to make it so big here, it's fine tuned // for text objects in SdrMarkView::CheckSingleSdrObjectHit
mpView->SetHitTolerancePixel( 2 * HITPIX );
if (eHit == SdrHitKind::TextEdit)
{ // hit text if (nSdrObjKind == SdrObjKind::Text ||
nSdrObjKind == SdrObjKind::TitleText ||
nSdrObjKind == SdrObjKind::OutlineText ||
nSdrObjKind == SdrObjKind::Table ||
nSlotId == SID_TEXTEDIT ||
!bQuickDrag)
{
pOLV->MouseButtonDown(rMEvt);
pOLV->MouseMove(rMEvt);
pOLV->MouseButtonUp(rMEvt);
}
if (mrViewShell.GetFrameView()->IsQuickEdit() && bQuickDrag && GetTextObj()->GetOutlinerParaObject())
{
pOLV->MouseButtonDown(rMEvt);
}
} else
{ // Move cursor to end of text if (pOLV != nullptr)
pOLV->SetSelection(ESelection::AtEnd());
}
} else
{
mpView->RestoreDefaultText( mxTextObj.get().get() );
}
}
}
}
} else
{
mxTextObj = nullptr;
}
}
/** * Text entry is started, if necessary delete the default text.
*/ void FuText::DeleteDefaultText()
{ if ( !(mxTextObj.get().is() && mxTextObj.get()->IsEmptyPresObj()) ) return;
// test for type before using
&& SID_TEXTEDIT == nSlotId
&& SfxItemState::SET == pArgs->GetItemState(SID_TEXTEDIT)
&& pArgs->Get(SID_TEXTEDIT).GetValue() == 2)
{ // selection with double click -> do not allow QuickDrag
bQuickDrag = false;
}
SetInEditMode(aMEvt, bQuickDrag);
}
void FuText::DoubleClick(const MouseEvent& )
{ // Nothing to do
}
/** Removed the insertion of default text and putting a new text object directly into edit mode.
*/
rtl::Reference<SdrObject> FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
rtl::Reference<SdrObject> pObj( SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier(),
nullptr) );
// Put text object into edit mode.
SdrPageView* pPV = mpView->GetSdrPageView();
mpView->SdrBeginTextEdit(pText, pPV);
} else
{
OSL_FAIL("Object is NO text object");
}
}
return pObj;
}
/** is called when the current function should be aborted. <p> This is used when a function gets a KEY_ESCAPE but can also be called directly.
@returns true if an active function was aborted
*/ bool FuText::cancel()
{ if ( mpView->IsTextEdit() )
{ if(mpView->SdrEndTextEdit() == SdrEndTextEditKind::Deleted)
mxTextObj = nullptr;
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.