/* -*- 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 .
*/
void SwBaseShell::ExecDelete(SfxRequest &rReq)
{
SwWrtShell &rSh = GetShell();
SwEditWin& rTmpEditWin = GetView().GetEditWin(); switch(rReq.GetSlot())
{ case SID_DELETE: if (rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton())
{ // Disallow if the cursor is at the end of a paragraph and the document model // node at this position is an outline node with folded content or the next node // is an outline node with folded content. if (rSh.IsEndPara())
{
SwNodeIndex aIdx(rSh.GetCursor()->GetPointNode()); if (aIdx.GetNode().IsTextNode())
{ if (!aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible()) break;
++aIdx; if (aIdx.GetNode().IsTextNode())
{ if (!aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible()) break;
}
}
}
}
rSh.DelRight(); break;
case FN_BACKSPACE: if (rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton())
{ // Disallow if the cursor is at the start of a paragraph and the document model // node at this position is an outline node with folded content or the previous // node is a content node without a layout frame. if (rSh.IsSttPara())
{
SwNodeIndex aIdx(rSh.GetCursor()->GetPointNode()); if (aIdx.GetNode().IsTextNode())
{ if (!aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible()) break;
--aIdx; if (aIdx.GetNode().IsContentNode() &&
!aIdx.GetNode().GetContentNode()->getLayoutFrame(rSh.GetLayout())) break;
}
}
} if( rSh.IsNoNum() )
{
rSh.SttCursorMove(); bool bLeft = rSh.Left( SwCursorSkipMode::Chars, true, 1, false ); if( bLeft )
{
rSh.DelLeft();
} else // JP 15.07.96: If it no longer goes forward, cancel // the numbering. For example at the beginning // of a doc, frame, table or an area.
rSh.DelNumRules();
switch( nId )
{ case SID_CUT: case SID_COPY:
m_rView.GetEditWin().FlushInBuffer(); if ( rSh.HasSelection() )
{
rtl::Reference<SwTransferable> pTransfer = new SwTransferable( rSh );
case FN_PASTE_NESTED_TABLE: case FN_TABLE_PASTE_ROW_BEFORE: case FN_TABLE_PASTE_COL_BEFORE: switch ( nId )
{ case FN_PASTE_NESTED_TABLE:
ePasteTable = PasteTableType::PASTE_TABLE; break; case FN_TABLE_PASTE_ROW_BEFORE:
ePasteTable = PasteTableType::PASTE_ROW; break; case FN_TABLE_PASTE_COL_BEFORE:
ePasteTable = PasteTableType::PASTE_COLUMN; break; default:
;
}
[[fallthrough]]; case SID_PASTE:
{
TransferableDataHelper aDataHelper(
TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin() ) ); if( aDataHelper.GetXTransferable().is()
&& SwTransferable::IsPaste( rSh, aDataHelper ) )
{ // Temporary variables, because the shell could already be // destroyed after the paste.
SwView* pView = &m_rView;
//Done() has to be called before the shell has been removed
rReq.Done();
bIgnore = true; if( rSh.IsFrameSelected() || rSh.GetSelectedObjCount())
rSh.EnterSelFrameMode();
pView->AttrChangedNotify(nullptr);
// Fold pasted outlines that have outline content visible attribute false
MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc());
}
}
} break;
case SID_PASTE_UNFORMATTED:
{
TransferableDataHelper aDataHelper(
TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()) ); if( aDataHelper.GetXTransferable().is()
&& SwTransferable::IsPaste( rSh, aDataHelper ) )
{ // Temporary variables, because the shell could already be // destroyed after the paste.
SwView* pView = &m_rView;
rReq.Ignore();
bIgnore = true; if(SwTransferable::PasteUnformatted( rSh, aDataHelper ))
{
SfxViewFrame& rViewFrame = pView->GetViewFrame();
uno::Reference< frame::XDispatchRecorder > xRecorder =
rViewFrame.GetBindings().GetRecorder(); if(xRecorder.is()) {
SfxRequest aReq(rViewFrame, SID_CLIPBOARD_FORMAT_ITEMS);
aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(SotClipboardFormatId::STRING) ) );
aReq.Done();
}
}
if (rSh.IsFrameSelected() || rSh.GetSelectedObjCount())
rSh.EnterSelFrameMode();
pView->AttrChangedNotify(nullptr);
// Fold pasted outlines that have outline content visible attribute false
MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc());
} else return;
} break;
case SID_PASTE_SPECIAL:
{
std::shared_ptr<const TransferableDataHelper> aDataHelper =
std::make_shared<TransferableDataHelper>(TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()));
case FN_PASTE_NESTED_TABLE: case FN_TABLE_PASTE_ROW_BEFORE: case FN_TABLE_PASTE_COL_BEFORE: if( !rSh.IsCursorInTable()
|| !GetView().IsPasteSpecialAllowed()
|| rSh.CursorInsideInputField() // disable if not a native Writer table and not a spreadsheet format
|| !GetView().IsPasteSpreadsheet(rSh.GetTableCopied()) )
{
rSet.DisableItem( nWhich );
} break;
// Repair mode: allow undo/redo of all undo actions, even if access would // be limited based on the view shell ID. bool bRepair = false; const SfxBoolItem* pRepairItem; if (pArgs && (pRepairItem = pArgs->GetItemIfSet(SID_REPAIRPACKAGE, false)))
bRepair = pRepairItem->GetValue();
// #i106349#: save pointer: undo/redo may delete the shell, i.e., this!
SfxViewFrame& rViewFrame( GetView().GetViewFrame() );
switch( nId )
{ case SID_UNDO: if (rUndoRedo.GetLastUndoInfo(nullptr, &nUndoId, &rWrtShell.GetView()))
{ for (SwViewShell& rShell : rWrtShell.GetRingContainer())
rShell.LockPaint(LockPaintReason::Undo);
sal_uInt16 nUndoOffset = 0; if (comphelper::LibreOfficeKit::isActive() && !bRepair && nCnt == 1)
{
sw::UndoManager& rManager = rWrtShell.GetDoc()->GetUndoManager(); const SfxUndoAction* pAction = rManager.GetUndoAction();
SwView& rView = rWrtShell.GetView();
ViewShellId nViewShellId = rView.GetViewShellId();
sal_uInt16 nOffset = 0; if (pAction->GetViewShellId() != nViewShellId
&& rManager.IsViewUndoActionIndependent(&rView, nOffset))
{ // Execute the undo with an offset: don't undo the top action, but an // earlier one, since it's independent and that belongs to our view.
nUndoOffset += nOffset;
}
}
namespace
{ /// Searches for the specified field type and field name prefix and update the matching fields to /// have the provided new name and content. bool UpdateFieldContents(const SfxRequest& rReq, SwWrtShell& rWrtSh)
{ const SfxStringItem* pTypeName = rReq.GetArg<SfxStringItem>(FN_PARAM_1); if (!pTypeName || pTypeName->GetValue() != "SetRef")
{ // This is implemented so far only for reference marks. returnfalse;
}
sal_uInt16 nFieldIndex = 0; for (auto& pIntermediateRefMark : aRefMarks)
{ auto pRefMark = const_cast<SwFormatRefMark*>(pIntermediateRefMark); if (!pRefMark->GetRefName().toString().startsWith(rNamePrefix))
{ continue;
}
auto pTextRefMark = const_cast<SwTextRefMark*>(pRefMark->GetTextRefMark()); if (bNeverExpand)
{
pTextRefMark->SetDontExpand(true);
pTextRefMark->SetLockExpandFlag(true);
pTextRefMark->SetDontExpandStartAttr(true);
}
if (nFieldIndex >= aFields.getLength())
{ // earlier we used to break here // but now we need to set expand flags for each refmark continue;
}
comphelper::SequenceAsHashMap aMap(aFields[nFieldIndex++]);
pRefMark->GetRefName() = SwMarkName(aMap[u"Name"_ustr].get<OUString>());
/// Searches for the specified field type and field name prefix under cursor and update the matching /// field to have the provided new name and content. void UpdateFieldContent(const SfxRequest& rReq, SwWrtShell& rWrtSh)
{ const SfxStringItem* pTypeName = rReq.GetArg<SfxStringItem>(FN_PARAM_1); if (!pTypeName || pTypeName->GetValue() != "SetRef")
{ // This is implemented so far only for reference marks. return;
}
sal_uInt16 nSlot = rReq.GetSlot(); switch(nSlot)
{ case FN_REPAGINATE:
{
Reference < XModel > xModel = GetView().GetDocShell()->GetModel(); auto pDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(xModel);
pDoc->NotifyRefreshListeners();
rSh.CalcLayout();
} break; case FN_UPDATE_FIELDS:
{ if (UpdateFieldContents(rReq, rSh))
{ // Parameters indicated that the name / content of fields has to be updated to // the provided values, don't do an actual fields update. break;
}
rSh.LockView( bLockedView );
} else // Will be recorded from the DocShell
GetView().GetDocShell()->ExecStyleSheet(rReq);
}
} break; case SID_CLASSIFICATION_APPLY:
{
GetView().GetDocShell()->Execute(rReq);
} break; case SID_CLASSIFICATION_DIALOG:
{
GetView().GetDocShell()->Execute(rReq);
} break; case SID_PARAGRAPH_SIGN_CLASSIFY_DLG:
{
GetView().GetDocShell()->Execute(rReq);
} break; case SID_WATERMARK:
{
GetView().GetDocShell()->Execute(rReq);
} break; case FN_ESCAPE:
GetView().ExecuteSlot(rReq); break; case SID_IMAP:
{
sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
SfxViewFrame& rVFrame = GetView().GetViewFrame();
rVFrame.ToggleChildWindow( nId );
rVFrame.GetBindings().Invalidate( SID_IMAP );
if ( rVFrame.HasChildWindow( nId ) && rSh.IsFrameSelected() )
lcl_UpdateIMapDlg( rSh );
} break; case SID_IMAP_EXEC:
{
SvxIMapDlg* pDlg = GetIMapDlg(GetView());
// Check, if the allocation is useful or allowed at all. if ( rSh.IsFrameSelected() &&
pDlg->GetEditingObject() == rSh.GetIMapInventor() )
{
SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_URL, RES_URL>(rSh.GetAttrPool()));
rSh.GetFlyFrameAttr( aSet );
SwFormatURL aURL( aSet.Get( RES_URL ) );
aURL.SetMap( &pDlg->GetImageMap() );
aSet.Put( aURL );
rSh.SetFlyFrameAttr( aSet );
}
} break; case FN_SET_TRACKED_CHANGES_IN_TEXT: case FN_SET_TRACKED_DELETIONS_IN_MARGIN: case FN_SET_TRACKED_INSERTIONS_IN_MARGIN:
{
SwViewOption aViewOption = *rSh.GetViewOptions(); bool bAllInText = FN_SET_TRACKED_CHANGES_IN_TEXT == nSlot;
aViewOption.SetShowChangesInMargin( !bAllInText ); if ( !bAllInText )
aViewOption.SetShowChangesInMargin2( FN_SET_TRACKED_INSERTIONS_IN_MARGIN == nSlot );
rSh.ApplyViewOptions( aViewOption );
// tdf#140982 restore annotation ranges stored in temporary bookmarks // (only remove temporary bookmarks during file saving to avoid possible // conflict with lazy deletion of the bookmarks of the moved tracked deletions) if ( bAllInText || FN_SET_TRACKED_INSERTIONS_IN_MARGIN == nSlot )
rSh.GetDoc()->getIDocumentMarkAccess()->restoreAnnotationMarks(false);
} break; case SID_CONTOUR_DLG:
{
sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
SfxViewFrame& rVFrame = GetView().GetViewFrame();
rVFrame.ToggleChildWindow( nId );
rVFrame.GetBindings().Invalidate( SID_CONTOUR_DLG );
SelectionType nSel = rSh.GetSelectionType(); if ( rVFrame.HasChildWindow( nId ) &&
(nSel & (SelectionType::Graphic|SelectionType::Ole)) )
{
lcl_UpdateContourDlg( rSh, nSel );
}
} break; case SID_CONTOUR_EXEC:
{
SvxContourDlg *pDlg = GetContourDlg(GetView()); // Check, if the allocation is useful or allowed at all.
SelectionType nSel = rSh.GetSelectionType(); if ( nSel & (SelectionType::Graphic|SelectionType::Ole) )
{ if (pDlg && pDlg->GetEditingObject() == rSh.GetIMapInventor())
{
rSh.StartAction();
SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_SURROUND, RES_SURROUND>(rSh.GetAttrPool()));
rSh.GetFlyFrameAttr( aSet );
SwFormatSurround aSur( aSet.Get( RES_SURROUND ) ); if ( !aSur.IsContour() )
{
aSur.SetContour( true ); if ( aSur.GetSurround() == css::text::WrapTextMode_NONE )
aSur.SetSurround( css::text::WrapTextMode_PARALLEL );
aSet.Put( aSur );
rSh.SetFlyFrameAttr( aSet );
} const tools::PolyPolygon aPoly( pDlg->GetPolyPolygon() );
rSh.SetGraphicPolygon( &aPoly ); if ( pDlg->IsGraphicChanged() )
rSh.ReRead( OUString(), OUString(), &pDlg->GetGraphic());
rSh.EndAction();
}
}
} break; case FN_FRAME_TO_ANCHOR:
{
rSh.GotoFlyAnchor();
rSh.EnterStdMode();
rSh.CallChgLnk();
} break; case FN_TOOL_ANCHOR_PAGE: case FN_TOOL_ANCHOR_PARAGRAPH: case FN_TOOL_ANCHOR_CHAR: case FN_TOOL_ANCHOR_AT_CHAR: case FN_TOOL_ANCHOR_FRAME:
{
RndStdIds eSet = nSlot == FN_TOOL_ANCHOR_PAGE
? RndStdIds::FLY_AT_PAGE
: nSlot == FN_TOOL_ANCHOR_PARAGRAPH
? RndStdIds::FLY_AT_PARA
: nSlot == FN_TOOL_ANCHOR_FRAME
? RndStdIds::FLY_AT_FLY
: nSlot == FN_TOOL_ANCHOR_CHAR
? RndStdIds::FLY_AS_CHAR
: RndStdIds::FLY_AT_CHAR;
rSh.StartUndo(); if (rSh.GetSelectedObjCount())
rSh.ChgAnchor(eSet); elseif (rSh.IsFrameSelected())
{
SwFormatAnchor aAnc(eSet, eSet == RndStdIds::FLY_AT_PAGE ? rSh.GetPhyPageNum() : 0);
SfxItemSet aSet(SwFEShell::makeItemSetFromFormatAnchor(GetPool(), aAnc));
rSh.SetFlyFrameAttr(aSet);
} // if new anchor is 'as char' and it is a Math object and the usual // pre-conditions are met then align the formula to the baseline of the text const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() ); constbool bDoMathBaselineAlignment = xObj.is() && SotExchange::IsMath( xObj->getClassID() )
&& RndStdIds::FLY_AS_CHAR == eSet && rSh.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ); if (bDoMathBaselineAlignment)
rSh.AlignFormulaToBaseline( xObj );
switch( eSet )
{ case RndStdIds::FLY_AT_FLY: case RndStdIds::FLY_AT_PAGE: //Wrap through, left or from left, top, from top if(eSurround != css::text::WrapTextMode_THROUGH)
aSet.Put(SwFormatSurround(css::text::WrapTextMode_THROUGH));
case RndStdIds::FLY_AT_PARA: // left, from left, right, top, no wrap, wrap left and right if (eSurround != css::text::WrapTextMode_LEFT && eSurround != css::text::WrapTextMode_RIGHT)
aSet.Put(SwFormatSurround(css::text::WrapTextMode_LEFT));
case RndStdIds::FLY_AT_CHAR: // left, from left, right, top, wrap through if(eSurround != css::text::WrapTextMode_THROUGH)
aSet.Put(SwFormatSurround(css::text::WrapTextMode_THROUGH));
case FN_FRAME_NOWRAP: case FN_FRAME_WRAP: case FN_FRAME_WRAP_IDEAL: case FN_FRAME_WRAPTHRU: case FN_FRAME_WRAPTHRU_TRANSP: case FN_FRAME_WRAPTHRU_TOGGLE: case FN_FRAME_WRAP_CONTOUR: case FN_WRAP_ANCHOR_ONLY: case FN_FRAME_WRAP_LEFT: case FN_FRAME_WRAP_RIGHT:
SetWrapMode( nSlot ); break;
case FN_UPDATE_ALL_LINKS:
{ if( !rSh.GetLinkManager().GetLinks().empty() )
{
rSh.EnterStdMode();
rSh.StartAllAction();
SfxMedium * medium = nullptr; if (autoconst sh = rSh.GetDoc()->GetDocShell()) {
medium = sh->GetMedium();
}
rSh.GetLinkManager().UpdateAllLinks( false, false, nullptr, medium == nullptr ? OUString() : medium->GetName() );
rSh.EndAllAction();
}
} break;
case FN_XFORMS_DESIGN_MODE: if (pArgs && pArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET)
{ if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem))
{ bool bDesignMode = pBoolItem->GetValue();
case SID_GRFFILTER: case SID_GRFFILTER_INVERT: case SID_GRFFILTER_SMOOTH: case SID_GRFFILTER_SHARPEN: case SID_GRFFILTER_REMOVENOISE: case SID_GRFFILTER_SOBEL: case SID_GRFFILTER_MOSAIC: case SID_GRFFILTER_EMBOSS: case SID_GRFFILTER_POSTER:
--> --------------------
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.