summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells/basesh.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase/shells/basesh.cxx')
-rw-r--r--sw/source/uibase/shells/basesh.cxx684
1 files changed, 463 insertions, 221 deletions
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 5942e7cc7340..cf36bcd7e076 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -18,10 +18,12 @@
*/
#include <config_features.h>
+#include <config_fuzzers.h>
#include <sal/config.h>
#include <hintids.hxx>
+#include <comphelper/servicehelper.hxx>
#include <svl/languageoptions.hxx>
#include <sfx2/linkmgr.hxx>
#include <sfx2/htmlmode.hxx>
@@ -78,30 +80,43 @@
#include <strings.hrc>
#include <unotxdoc.hxx>
#include <doc.hxx>
+#include <drawdoc.hxx>
#include <IDocumentSettingAccess.hxx>
+#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <ThemeColorChanger.hxx>
#include <swabstdlg.hxx>
#include <modcfg.hxx>
#include <svx/fmshell.hxx>
#include <SwRewriter.hxx>
+#include <GraphicSizeCheck.hxx>
#include <svx/galleryitem.hxx>
#include <sfx2/devtools/DevelopmentToolChildWindow.hxx>
#include <com/sun/star/gallery/GalleryItemType.hpp>
+#include <com/sun/star/beans/PropertyValues.hpp>
#include <memory>
+
#include <svx/unobrushitemhelper.hxx>
+#include <svx/dialog/ThemeDialog.hxx>
#include <comphelper/scopeguard.hxx>
#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <osl/diagnose.h>
#include <svx/svxdlg.hxx>
+#include <comphelper/sequenceashashmap.hxx>
#include <shellres.hxx>
#include <UndoTable.hxx>
#include <ndtxt.hxx>
+#include <UndoManager.hxx>
+#include <fmtrfmrk.hxx>
+#include <txtrfmrk.hxx>
+#include <translatehelper.hxx>
-FlyMode SwBaseShell::eFrameMode = FLY_DRAG_END;
+FlyMode SwBaseShell::s_eFrameMode = FLY_DRAG_END;
// These variables keep the state of Gallery (slot SID_GALLERY_BG_BRUSH)
// detected by GetGalleryState() for the subsequent ExecuteGallery() call.
@@ -122,19 +137,18 @@ static sal_uInt8 nFooterPos;
#include <swslots.hxx>
#include <AccessibilityCheck.hxx>
-#include <svx/AccessibilityCheckDialog.hxx>
namespace
{
SvxContourDlg* GetContourDlg(SwView const &rView)
{
- SfxChildWindow *pWnd = rView.GetViewFrame()->GetChildWindow(SvxContourDlgChildWindow::GetChildWindowId());
+ SfxChildWindow *pWnd = rView.GetViewFrame().GetChildWindow(SvxContourDlgChildWindow::GetChildWindowId());
return pWnd ? static_cast<SvxContourDlg*>(pWnd->GetController().get()) : nullptr;
}
SvxIMapDlg* GetIMapDlg(SwView const &rView)
{
- SfxChildWindow* pWnd = rView.GetViewFrame()->GetChildWindow(SvxIMapDlgChildWindow::GetChildWindowId());
+ SfxChildWindow* pWnd = rView.GetViewFrame().GetChildWindow(SvxIMapDlgChildWindow::GetChildWindowId());
return pWnd ? static_cast<SvxIMapDlg*>(pWnd->GetController().get()) : nullptr;
}
}
@@ -142,7 +156,6 @@ namespace
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::frame;
-using namespace ::com::sun::star::lang;
SFX_IMPL_SUPERCLASS_INTERFACE(SwBaseShell, SfxShell)
@@ -159,14 +172,14 @@ static void lcl_UpdateIMapDlg( SwWrtShell& rSh )
GraphicType nGrfType = aGrf.GetType();
void* pEditObj = GraphicType::NONE != nGrfType && GraphicType::Default != nGrfType
? rSh.GetIMapInventor() : nullptr;
- std::unique_ptr<TargetList> pList(new TargetList);
- SfxFrame::GetDefaultTargetList(*pList);
+ TargetList aList;
+ SfxFrame::GetDefaultTargetList(aList);
- SfxItemSet aSet( rSh.GetAttrPool(), svl::Items<RES_URL, RES_URL>{} );
+ SfxItemSetFixed<RES_URL, RES_URL> aSet( rSh.GetAttrPool() );
rSh.GetFlyFrameAttr( aSet );
const SwFormatURL &rURL = aSet.Get( RES_URL );
SvxIMapDlgChildWindow::UpdateIMapDlg(
- aGrf, rURL.GetMap(), pList.get(), pEditObj );
+ aGrf, rURL.GetMap(), &aList, pEditObj );
}
static bool lcl_UpdateContourDlg( SwWrtShell &rSh, SelectionType nSel )
@@ -199,25 +212,26 @@ void SwBaseShell::ExecDelete(SfxRequest &rReq)
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()->GetNode());
- // disallow if this is am outline node having folded content
- bool bVisible = true;
- aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible);
- if (!bVisible)
- return;
- // disallow if the next text node is an outline node having folded content
- ++aIdx;
- SwNodeType aNodeType;
- while ((aNodeType = aIdx.GetNode().GetNodeType()) != SwNodeType::Text)
- ++aIdx;
+ SwNodeIndex aIdx(rSh.GetCursor()->GetPointNode());
if (aIdx.GetNode().IsTextNode())
{
- bVisible = true;
+ bool bVisible = true;
aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible);
if (!bVisible)
- return;
+ break;
+ ++aIdx;
+ if (aIdx.GetNode().IsTextNode())
+ {
+ bVisible = true;
+ aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible);
+ if (!bVisible)
+ break;
+ }
}
}
}
@@ -227,27 +241,29 @@ void SwBaseShell::ExecDelete(SfxRequest &rReq)
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()->GetNode());
- // disallow if this is a folded outline node
- bool bVisible = true;
- aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible);
- if (!bVisible)
- return;
- // disallow if previous text node does not have a layout frame
- --aIdx;
- SwNodeType aNodeType;
- while ((aNodeType = aIdx.GetNode().GetNodeType()) != SwNodeType::Text)
+ SwNodeIndex aIdx(rSh.GetCursor()->GetPointNode());
+ if (aIdx.GetNode().IsTextNode())
+ {
+ bool bVisible = true;
+ aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible(bVisible);
+ if (!bVisible)
+ break;
--aIdx;
- if (aIdx.GetNode().IsContentNode() && !aIdx.GetNode().GetContentNode()->getLayoutFrame(nullptr))
- return;
+ if (aIdx.GetNode().IsContentNode() &&
+ !aIdx.GetNode().GetContentNode()->getLayoutFrame(rSh.GetLayout()))
+ break;
+ }
}
}
if( rSh.IsNoNum() )
{
rSh.SttCursorMove();
- bool bLeft = rSh.Left( CRSR_SKIP_CHARS, true, 1, false );
+ bool bLeft = rSh.Left( SwCursorSkipMode::Chars, true, 1, false );
if( bLeft )
{
rSh.DelLeft();
@@ -278,8 +294,6 @@ void SwBaseShell::ExecDelete(SfxRequest &rReq)
void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
{
- MakeAllOutlineContentTemporarilyVisible a(GetShell().GetDoc());
-
// Attention: At risk of suicide!
// After paste, paste special the shell can be destroy.
@@ -292,7 +306,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
{
case SID_CUT:
case SID_COPY:
- rView.GetEditWin().FlushInBuffer();
+ m_rView.GetEditWin().FlushInBuffer();
if ( rSh.HasSelection() )
{
rtl::Reference<SwTransferable> pTransfer = new SwTransferable( rSh );
@@ -337,7 +351,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
{
// Temporary variables, because the shell could already be
// destroyed after the paste.
- SwView* pView = &rView;
+ SwView* pView = &m_rView;
RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA;
const SfxUInt16Item* pAnchorType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
@@ -352,6 +366,9 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
if( rSh.IsFrameSelected() || rSh.IsObjSelected() )
rSh.EnterSelFrameMode();
pView->AttrChangedNotify(nullptr);
+
+ // Fold pasted outlines that have outline content visible attribute false
+ MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc());
}
else
return;
@@ -372,7 +389,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
{
// Temporary variables, because the shell could already be
// destroyed after the paste.
- SwView* pView = &rView;
+ SwView* pView = &m_rView;
SwTransferable::PasteFormat( rSh, aDataHelper,
static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pFormat)->GetValue()) );
@@ -383,6 +400,9 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
if( rSh.IsFrameSelected() || rSh.IsObjSelected())
rSh.EnterSelFrameMode();
pView->AttrChangedNotify(nullptr);
+
+ // Fold pasted outlines that have outline content visible attribute false
+ MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc());
}
}
}
@@ -397,16 +417,16 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
{
// Temporary variables, because the shell could already be
// destroyed after the paste.
- SwView* pView = &rView;
+ SwView* pView = &m_rView;
rReq.Ignore();
bIgnore = true;
if(SwTransferable::PasteUnformatted( rSh, aDataHelper ))
{
- SfxViewFrame* pViewFrame = pView->GetViewFrame();
+ SfxViewFrame& rViewFrame = pView->GetViewFrame();
uno::Reference< frame::XDispatchRecorder > xRecorder =
- pViewFrame->GetBindings().GetRecorder();
+ rViewFrame.GetBindings().GetRecorder();
if(xRecorder.is()) {
- SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
+ SfxRequest aReq(rViewFrame, SID_CLIPBOARD_FORMAT_ITEMS);
aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(SotClipboardFormatId::STRING) ) );
aReq.Done();
}
@@ -415,6 +435,9 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
if (rSh.IsFrameSelected() || rSh.IsObjSelected())
rSh.EnterSelFrameMode();
pView->AttrChangedNotify(nullptr);
+
+ // Fold pasted outlines that have outline content visible attribute false
+ MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc());
}
else
return;
@@ -423,7 +446,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
case SID_PASTE_SPECIAL:
{
- std::shared_ptr<TransferableDataHelper> aDataHelper =
+ std::shared_ptr<const TransferableDataHelper> aDataHelper =
std::make_shared<TransferableDataHelper>(TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()));
if( aDataHelper->GetXTransferable().is()
@@ -441,38 +464,43 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq)
pDlg->PreGetFormat(*aDataHelper);
- pDlg->StartExecuteAsync([aDataHelper, pDlg, &rSh, this](sal_Int32 nResult){
- if (nResult == RET_OK)
- {
- // Temporary variables, because the shell could already be
- // destroyed after the paste.
- SwView* pView = &rView;
- bool bRet = false;
- SotClipboardFormatId nFormatId = pDlg->GetFormatOnly();
+ pDlg->StartExecuteAsync(
+ [aDataHelper, pDlg, &rSh, this](sal_Int32 nResult)
+ {
+ if (nResult == RET_OK)
+ {
+ // Temporary variables, because the shell could already be
+ // destroyed after the paste.
+ SwView* pView = &m_rView;
+ bool bRet = false;
+ SotClipboardFormatId nFormatId = pDlg->GetFormatOnly();
- if( nFormatId != SotClipboardFormatId::NONE )
- bRet = SwTransferable::PasteFormat( rSh, *aDataHelper, nFormatId );
+ if( nFormatId != SotClipboardFormatId::NONE )
+ bRet = SwTransferable::PasteFormat( rSh, *aDataHelper, nFormatId );
- if (bRet)
- {
- SfxViewFrame* pViewFrame = pView->GetViewFrame();
- uno::Reference< frame::XDispatchRecorder > xRecorder =
- pViewFrame->GetBindings().GetRecorder();
- if(xRecorder.is()) {
- SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS );
- aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(nFormatId) ) );
- aReq.Done();
- }
- }
+ if (bRet)
+ {
+ 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>(nFormatId) ) );
+ aReq.Done();
+ }
+ }
- if (rSh.IsFrameSelected() || rSh.IsObjSelected())
- rSh.EnterSelFrameMode();
- pView->AttrChangedNotify(nullptr);
- }
+ if (rSh.IsFrameSelected() || rSh.IsObjSelected())
+ rSh.EnterSelFrameMode();
+ pView->AttrChangedNotify(nullptr);
- pDlg->disposeOnce();
+ // Fold pasted outlines that have outline content visible attribute false
+ MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc());
+ }
- });
+ pDlg->disposeOnce();
+ }
+ );
}
else
return;
@@ -555,7 +583,7 @@ void SwBaseShell::StateClpbrd(SfxItemSet &rSet)
TransferableDataHelper::CreateFromSystemClipboard(
&rSh.GetView().GetEditWin()) );
- SvxClipboardFormatItem aFormatItem( nWhich );
+ SvxClipboardFormatItem aFormatItem( SID_CLIPBOARD_FORMAT_ITEMS );
SwTransferable::FillClipFormatItem( rSh, aDataHelper, aFormatItem );
rSet.Put( aFormatItem );
}
@@ -569,7 +597,7 @@ void SwBaseShell::StateClpbrd(SfxItemSet &rSet)
void SwBaseShell::ExecUndo(SfxRequest &rReq)
{
- MakeAllOutlineContentTemporarilyVisible a(GetShell().GetDoc());
+ MakeAllOutlineContentTemporarilyVisible a(GetShell().GetDoc(), true);
SwWrtShell &rWrtShell = GetShell();
@@ -583,11 +611,12 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
// Repair mode: allow undo/redo of all undo actions, even if access would
// be limited based on the view shell ID.
bool bRepair = false;
- if (pArgs && pArgs->GetItemState(SID_REPAIRPACKAGE, false, &pItem) == SfxItemState::SET)
- bRepair = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ 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 *const pViewFrame( GetView().GetViewFrame() );
+ SfxViewFrame& rViewFrame( GetView().GetViewFrame() );
IDocumentUndoRedo& rUndoRedo = rWrtShell.GetIDocumentUndoRedo();
bool bWasRepair = rUndoRedo.DoesRepair();
@@ -603,8 +632,27 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
if (rUndoRedo.GetLastUndoInfo(nullptr, &nUndoId, &rWrtShell.GetView()))
{
for (SwViewShell& rShell : rWrtShell.GetRingContainer())
- rShell.LockPaint();
- rWrtShell.Do( SwWrtShell::UNDO, nCnt );
+ 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;
+ }
+ }
+
+ rWrtShell.Do(SwWrtShell::UNDO, nCnt, nUndoOffset);
+
for (SwViewShell& rShell : rWrtShell.GetRingContainer())
rShell.UnlockPaint();
@@ -620,7 +668,7 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
if (rUndoRedo.GetFirstRedoInfo(nullptr, &nUndoId, &rWrtShell.GetView()))
{
for (SwViewShell& rShell : rWrtShell.GetRingContainer())
- rShell.LockPaint();
+ rShell.LockPaint(LockPaintReason::Redo);
rWrtShell.Do( SwWrtShell::REDO, nCnt );
for (SwViewShell& rShell : rWrtShell.GetRingContainer())
rShell.UnlockPaint();
@@ -638,12 +686,8 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq)
{
rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)) );
}
- else if (nUndoId == SwUndoId::INSFMTATTR)
- {
- rWrtShell.GetDoc()->GetDocShell()->GetStyleSheetPool()->Broadcast(SfxHint(SfxHintId::StyleSheetModified));
- }
- if (pViewFrame) { pViewFrame->GetBindings().InvalidateAll(false); }
+ rViewFrame.GetBindings().InvalidateAll(false);
}
// State of undo
@@ -728,6 +772,141 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet)
}
}
+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(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 false;
+ }
+
+ const SfxStringItem* pNamePrefix = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
+ if (!pNamePrefix)
+ {
+ return false;
+ }
+ const OUString& rNamePrefix = pNamePrefix->GetValue();
+
+ const SfxUnoAnyItem* pFields = rReq.GetArg<SfxUnoAnyItem>(FN_PARAM_3);
+ if (!pFields)
+ {
+ return false;
+ }
+ uno::Sequence<beans::PropertyValues> aFields;
+ pFields->GetValue() >>= aFields;
+
+ SwDoc* pDoc = rWrtSh.GetDoc();
+ pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_FIELDS, nullptr);
+ rWrtSh.StartAction();
+
+ std::vector<const SwFormatRefMark*> aRefMarks;
+
+ for (sal_uInt16 i = 0; i < pDoc->GetRefMarks(); ++i)
+ {
+ aRefMarks.push_back(pDoc->GetRefMark(i));
+ }
+
+ std::sort(aRefMarks.begin(), aRefMarks.end(),
+ [](const SwFormatRefMark* pMark1, const SwFormatRefMark* pMark2) -> bool {
+ const SwTextRefMark* pTextRefMark1 = pMark1->GetTextRefMark();
+ const SwTextRefMark* pTextRefMark2 = pMark2->GetTextRefMark();
+ SwPosition aPos1(pTextRefMark1->GetTextNode(), pTextRefMark1->GetStart());
+ SwPosition aPos2(pTextRefMark2->GetTextNode(), pTextRefMark2->GetStart());
+ return aPos1 < aPos2;
+ });
+
+ sal_uInt16 nFieldIndex = 0;
+ for (auto& pIntermediateRefMark : aRefMarks)
+ {
+ auto pRefMark = const_cast<SwFormatRefMark*>(pIntermediateRefMark);
+ if (!pRefMark->GetRefName().startsWith(rNamePrefix))
+ {
+ continue;
+ }
+
+ if (nFieldIndex >= aFields.getLength())
+ {
+ break;
+ }
+ comphelper::SequenceAsHashMap aMap(aFields[nFieldIndex++]);
+ pRefMark->GetRefName() = aMap["Name"].get<OUString>();
+
+ auto pTextRefMark = const_cast<SwTextRefMark*>(pRefMark->GetTextRefMark());
+ pTextRefMark->UpdateFieldContent(pDoc, rWrtSh, aMap["Content"].get<OUString>());
+ }
+
+ rWrtSh.EndAction();
+ pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_FIELDS, nullptr);
+ return true;
+}
+
+/// 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(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;
+ }
+
+ const SfxStringItem* pNamePrefix = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
+ if (!pNamePrefix)
+ {
+ return;
+ }
+ const OUString& rNamePrefix = pNamePrefix->GetValue();
+
+ const SfxUnoAnyItem* pField = rReq.GetArg<SfxUnoAnyItem>(FN_PARAM_3);
+ if (!pField)
+ {
+ return;
+ }
+ uno::Sequence<beans::PropertyValue> aField;
+ pField->GetValue() >>= aField;
+
+ SwPosition& rCursor = *rWrtSh.GetCursor()->GetPoint();
+ SwTextNode* pTextNode = rCursor.GetNode().GetTextNode();
+ std::vector<SwTextAttr*> aAttrs
+ = pTextNode->GetTextAttrsAt(rCursor.GetContentIndex(), RES_TXTATR_REFMARK);
+ if (aAttrs.empty())
+ {
+ return;
+ }
+
+ auto& rRefmark = const_cast<SwFormatRefMark&>(aAttrs[0]->GetRefMark());
+ if (!rRefmark.GetRefName().startsWith(rNamePrefix))
+ {
+ return;
+ }
+
+ SwDoc* pDoc = rWrtSh.GetDoc();
+ SwRewriter aRewriter;
+ aRewriter.AddRule(UndoArg1, rRefmark.GetRefName());
+ pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_FIELD, &aRewriter);
+ rWrtSh.StartAction();
+ comphelper::ScopeGuard g(
+ [&rWrtSh, &aRewriter]
+ {
+ rWrtSh.EndAction();
+ rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_FIELD, &aRewriter);
+ });
+
+ comphelper::SequenceAsHashMap aMap(aField);
+ rRefmark.GetRefName() = aMap["Name"].get<OUString>();
+
+ OUString aContent = aMap["Content"].get<OUString>();
+ auto pTextRefMark = const_cast<SwTextRefMark*>(rRefmark.GetTextRefMark());
+ pTextRefMark->UpdateFieldContent(pDoc, rWrtSh, aContent);
+}
+}
+
// Evaluate respectively dispatching the slot Id
void SwBaseShell::Execute(SfxRequest &rReq)
@@ -743,13 +922,20 @@ void SwBaseShell::Execute(SfxRequest &rReq)
case FN_REPAGINATE:
{
Reference < XModel > xModel = GetView().GetDocShell()->GetModel();
- auto pDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xModel);
+ 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.UpdateDocStat();
rSh.EndAllTableBoxEdit();
rSh.SwViewShell::UpdateFields(true);
@@ -763,9 +949,14 @@ void SwBaseShell::Execute(SfxRequest &rReq)
}
}
break;
+ case FN_UPDATE_FIELD:
+ {
+ UpdateFieldContent(rReq, rSh);
+ }
+ break;
case FN_UPDATE_CHARTS:
{
- SwWait aWait( *rView.GetDocShell(), true );
+ SwWait aWait( *m_rView.GetDocShell(), true );
rSh.UpdateAllCharts();
}
break;
@@ -784,11 +975,12 @@ void SwBaseShell::Execute(SfxRequest &rReq)
rSh.GetLinkManager().UpdateAllLinks( false, true, nullptr );
rSh.EndAllAction();
}
- SfxDispatcher &rDis = *rTempView.GetViewFrame()->GetDispatcher();
+ SfxDispatcher &rDis = *rTempView.GetViewFrame().GetDispatcher();
rDis.Execute( FN_UPDATE_FIELDS );
rDis.Execute( FN_UPDATE_TOX );
rDis.Execute( FN_UPDATE_CHARTS );
rSh.Reformat();
+ rSh.UpdateOleObjectPreviews();
}
break;
@@ -873,7 +1065,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
if ( (!rSh.IsSelFrameMode() || nSelType & SelectionType::Graphic) &&
nGalleryItemType == css::gallery::GalleryItemType::GRAPHIC )
{
- SwWait aWait( *rView.GetDocShell(), true );
+ SwWait aWait( *m_rView.GetDocShell(), true );
OUString aGrfName, aFltName;
const Graphic aGrf( pGalleryItem->GetGraphic() );
@@ -881,7 +1073,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
if ( nSelType & SelectionType::Graphic )
rSh.ReRead( aGrfName, aFltName, &aGrf );
else
- rSh.Insert( aGrfName, aFltName, aGrf );
+ rSh.InsertGraphic( aGrfName, aFltName, aGrf );
GetView().GetEditWin().GrabFocus();
}
@@ -889,7 +1081,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
nGalleryItemType == css::gallery::GalleryItemType::MEDIA )
{
const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() );
- GetView().GetViewFrame()->GetDispatcher()->ExecuteList(
+ GetView().GetViewFrame().GetDispatcher()->ExecuteList(
SID_INSERT_AVMEDIA, SfxCallMode::SYNCHRON,
{ &aMediaURLItem });
}
@@ -923,7 +1115,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
rSh.ChgPageDesc(nCurIdx, aPageDesc);
}
else
- GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG);
+ GetView().GetViewFrame().GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG);
}
break;
case FN_CONVERT_TABLE_TO_TEXT:
@@ -972,7 +1164,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
// RepeatHeaderLines
if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_4, true, &pItem))
aInsTableOpts.mnRowsToRepeat =
- static_cast<sal_uInt16>(static_cast< const SfxInt16Item* >(pItem)->GetValue());
+ o3tl::narrowing<sal_uInt16>(static_cast< const SfxInt16Item* >(pItem)->GetValue());
//WithBorder
if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_5, true, &pItem) &&
static_cast< const SfxBoolItem* >(pItem)->GetValue())
@@ -996,13 +1188,13 @@ void SwBaseShell::Execute(SfxRequest &rReq)
if( cDelim )
{
//Shell change!
- SwView& rSaveView = rView;
+ SwView& rSaveView = m_rView;
bool bInserted = false;
//recording:
- SfxViewFrame* pViewFrame = GetView().GetViewFrame();
- if( SfxRequest::HasMacroRecorder(pViewFrame) )
+ SfxViewFrame& rViewFrame = GetView().GetViewFrame();
+ if (SfxRequest::HasMacroRecorder(rViewFrame))
{
- SfxRequest aReq( pViewFrame, nSlot);
+ SfxRequest aReq(rViewFrame, nSlot);
aReq.AppendItem( SfxStringItem( FN_PARAM_1, OUString(cDelim) ));
if(bToTable)
{
@@ -1085,11 +1277,11 @@ void SwBaseShell::Execute(SfxRequest &rReq)
{
sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
- SfxViewFrame* pVFrame = GetView().GetViewFrame();
- pVFrame->ToggleChildWindow( nId );
- pVFrame->GetBindings().Invalidate( SID_IMAP );
+ SfxViewFrame& rVFrame = GetView().GetViewFrame();
+ rVFrame.ToggleChildWindow( nId );
+ rVFrame.GetBindings().Invalidate( SID_IMAP );
- if ( pVFrame->HasChildWindow( nId ) && rSh.IsFrameSelected() )
+ if ( rVFrame.HasChildWindow( nId ) && rSh.IsFrameSelected() )
lcl_UpdateIMapDlg( rSh );
}
break;
@@ -1101,7 +1293,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
if ( rSh.IsFrameSelected() &&
pDlg->GetEditingObject() == rSh.GetIMapInventor() )
{
- SfxItemSet aSet( rSh.GetAttrPool(), svl::Items<RES_URL, RES_URL>{} );
+ SfxItemSetFixed<RES_URL, RES_URL> aSet( rSh.GetAttrPool() );
rSh.GetFlyFrameAttr( aSet );
SwFormatURL aURL( aSet.Get( RES_URL ) );
aURL.SetMap( &pDlg->GetImageMap() );
@@ -1132,12 +1324,12 @@ void SwBaseShell::Execute(SfxRequest &rReq)
{
sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
- SfxViewFrame* pVFrame = GetView().GetViewFrame();
- pVFrame->ToggleChildWindow( nId );
- pVFrame->GetBindings().Invalidate( SID_CONTOUR_DLG );
+ SfxViewFrame& rVFrame = GetView().GetViewFrame();
+ rVFrame.ToggleChildWindow( nId );
+ rVFrame.GetBindings().Invalidate( SID_CONTOUR_DLG );
SelectionType nSel = rSh.GetSelectionType();
- if ( pVFrame->HasChildWindow( nId ) &&
+ if ( rVFrame.HasChildWindow( nId ) &&
(nSel & (SelectionType::Graphic|SelectionType::Ole)) )
{
lcl_UpdateContourDlg( rSh, nSel );
@@ -1154,7 +1346,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
if (pDlg && pDlg->GetEditingObject() == rSh.GetIMapInventor())
{
rSh.StartAction();
- SfxItemSet aSet( rSh.GetAttrPool(), svl::Items<RES_SURROUND, RES_SURROUND>{});
+ SfxItemSetFixed<RES_SURROUND, RES_SURROUND> aSet( rSh.GetAttrPool() );
rSh.GetFlyFrameAttr( aSet );
SwFormatSurround aSur( aSet.Get( RES_SURROUND ) );
if ( !aSur.IsContour() )
@@ -1201,7 +1393,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
rSh.ChgAnchor(eSet);
else if (rSh.IsFrameSelected())
{
- SwFormatAnchor aAnc(eSet, rSh.GetPhyPageNum());
+ SwFormatAnchor aAnc(eSet, eSet == RndStdIds::FLY_AT_PAGE ? rSh.GetPhyPageNum() : 0);
SfxItemSet aSet(SwFEShell::makeItemSetFromFormatAnchor(GetPool(), aAnc));
rSh.SetFlyFrameAttr(aSet);
}
@@ -1216,7 +1408,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
if( nHtmlMode )
{
- SfxItemSet aSet(GetPool(), svl::Items<RES_SURROUND, RES_HORI_ORIENT>{});
+ SfxItemSetFixed<RES_SURROUND, RES_HORI_ORIENT> aSet(GetPool());
rSh.GetFlyFrameAttr(aSet);
const SwFormatSurround& rSurround = aSet.Get(RES_SURROUND);
@@ -1274,7 +1466,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
}
rSh.EndUndo();
- GetView().GetViewFrame()->GetBindings().Invalidate( SID_ANCHOR_MENU );
+ GetView().GetViewFrame().GetBindings().Invalidate( SID_ANCHOR_MENU );
}
break;
@@ -1312,7 +1504,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
// set from design mode
OSL_ENSURE( GetView().GetFormShell() != nullptr, "form shell?" );
- SfxRequest aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE );
+ SfxRequest aReq(GetView().GetViewFrame(), SID_FM_DESIGN_MODE);
aReq.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE, bDesignMode ) );
GetView().GetFormShell()->Execute( aReq );
aReq.Done();
@@ -1334,7 +1526,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
return;
pItem = nullptr;
- pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
+ pArgs->GetItemState(GetPool().GetWhichIDFromSlotID(nSlot), false, &pItem);
if(!pItem)
return;
@@ -1345,7 +1537,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
case RES_SHADOW:
{
rSh.StartAllAction();
- // Tabele cell(s) selected?
+ // Table cell(s) selected?
if ( rSh.IsTableMode() )
{
SwFrameFormat *pFormat = rSh.GetTableFormat();
@@ -1377,7 +1569,7 @@ void SwBaseShell::Execute(SfxRequest &rReq)
case SID_ATTR_BORDER_OUTER:
{
- // Tabele cell(s) selected?
+ // Table cell(s) selected?
if ( rSh.IsTableMode() )
{
// Set border attributes Get/SetTabBorders()
@@ -1411,12 +1603,12 @@ IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void)
if (CNT_GRF != rSh.SwEditShell::GetCntType())
return;
GraphicType const nGrfType(rSh.GetGraphicType());
- if (GraphicType::NONE == nGrfType || aGrfUpdateSlots.empty())
+ if (GraphicType::NONE == nGrfType || m_aGrfUpdateSlots.empty())
return;
bool bProtect = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent);
- SfxViewFrame* pVFrame = GetView().GetViewFrame();
- for( const auto nSlot : aGrfUpdateSlots )
+ SfxViewFrame& rVFrame = GetView().GetViewFrame();
+ for( const auto nSlot : m_aGrfUpdateSlots )
{
bool bSetState = false;
bool bState = false;
@@ -1426,8 +1618,8 @@ IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void)
case SID_IMAP_EXEC:
{
sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
- SfxChildWindow *pChildWindow = pVFrame->HasChildWindow(nId) ?
- pVFrame->GetChildWindow(nId) : nullptr;
+ SfxChildWindow *pChildWindow = rVFrame.HasChildWindow(nId) ?
+ rVFrame.GetChildWindow(nId) : nullptr;
SvxIMapDlg *pDlg = pChildWindow ?
static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr;
@@ -1448,8 +1640,8 @@ IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void)
if( !bProtect )
{
sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
- SfxChildWindow *pChildWindow = pVFrame->HasChildWindow(nId) ?
- pVFrame->GetChildWindow(nId) : nullptr;
+ SfxChildWindow *pChildWindow = rVFrame.HasChildWindow(nId) ?
+ rVFrame.GetChildWindow(nId) : nullptr;
SvxIMapDlg *pDlg = pChildWindow ?
static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr;
if( pDlg && pDlg->GetEditingObject() !=
@@ -1464,7 +1656,7 @@ IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void)
case FN_FRAME_WRAP_CONTOUR:
if( !bProtect )
{
- SfxItemSet aSet(GetPool(), svl::Items<RES_SURROUND, RES_SURROUND>{});
+ SfxItemSetFixed<RES_SURROUND, RES_SURROUND> aSet(GetPool());
rSh.GetFlyFrameAttr(aSet);
const SwFormatSurround& rWrap = aSet.Get(RES_SURROUND);
bSetState = true;
@@ -1491,22 +1683,22 @@ IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void)
if( bSetState )
{
SfxBoolItem aBool( nSlot, bState );
- if( pGetStateSet )
- pGetStateSet->Put( aBool );
+ if( m_pGetStateSet )
+ m_pGetStateSet->Put( aBool );
else
- pVFrame->GetBindings().SetState( aBool );
+ rVFrame.GetBindings().SetState( aBool );
}
}
- aGrfUpdateSlots.clear();
+ m_aGrfUpdateSlots.clear();
}
void SwBaseShell::GetState( SfxItemSet &rSet )
{
SwWrtShell &rSh = GetShell();
- SfxViewFrame* pVFrame = GetView().GetViewFrame();
+ SfxViewFrame& rVFrame = GetView().GetViewFrame();
SfxWhichIter aIter( rSet );
sal_uInt16 nWhich = aIter.FirstWhich();
- pGetStateSet = &rSet;
+ m_pGetStateSet = &rSet;
while ( nWhich )
{
switch ( nWhich )
@@ -1571,8 +1763,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
break;
case RES_SHADOW:
{
- SfxItemSet aSet( rSh.GetAttrPool(),
- svl::Items<RES_SHADOW, RES_SHADOW>{} );
+ SfxItemSetFixed<RES_SHADOW, RES_SHADOW> aSet( rSh.GetAttrPool());
// Table cell(s) selected?
if ( rSh.IsTableMode() )
@@ -1605,7 +1796,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
else
{
const sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
- const bool bHas = pVFrame->HasChildWindow( nId );
+ const bool bHas = rVFrame.HasChildWindow( nId );
const bool bFrameSel = rSh.IsFrameSelected();
const bool bIsGraphicSelection =
rSh.GetSelectionType() == SelectionType::Graphic;
@@ -1647,7 +1838,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
if( !rSh.IsFrameSelected())
bDisable = true;
sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
- if(!bDisable && pVFrame->HasChildWindow( nId ))
+ if(!bDisable && rVFrame.HasChildWindow( nId ))
{
if(rSh.GetSelectionType() == SelectionType::Graphic
&& rSh.IsLinkedGrfSwapOut())
@@ -1685,7 +1876,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
else
{
sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
- bool bHas = GetView().GetViewFrame()->HasChildWindow( nId );
+ bool bHas = GetView().GetViewFrame().HasChildWindow( nId );
SelectionType nSel = rSh.GetSelectionType();
bool bOk(nSel & (SelectionType::Graphic|SelectionType::Ole));
@@ -1732,7 +1923,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
if( !(nSel & (SelectionType::Graphic|SelectionType::Ole)) )
bDisable = true;
sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId();
- if( !bDisable && GetView().GetViewFrame()->HasChildWindow( nId ))
+ if( !bDisable && GetView().GetViewFrame().HasChildWindow( nId ))
{
SvxContourDlg *pDlg = GetContourDlg(GetView());
if (pDlg && pDlg->GetEditingObject() != rSh.GetIMapInventor())
@@ -1754,7 +1945,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
if( !bParentCntProt && (bObj || rSh.IsFrameSelected()))
{
- SfxItemSet aSet(GetPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{});
+ SfxItemSetFixed<RES_ANCHOR, RES_ANCHOR> aSet(GetPool());
if(bObj)
rSh.GetObjAttr(aSet);
else
@@ -1779,8 +1970,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
if (comphelper::LibreOfficeKit::isActive())
{
- if (nWhich == FN_TOOL_ANCHOR_PAGE || nWhich == FN_TOOL_ANCHOR_PARAGRAPH
- || nWhich == FN_TOOL_ANCHOR_FRAME)
+ if (nWhich == FN_TOOL_ANCHOR_PAGE || nWhich == FN_TOOL_ANCHOR_FRAME)
{
rSet.DisableItem(nWhich);
}
@@ -1806,7 +1996,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
if( !bParentCntProt && (bObj || rSh.IsFrameSelected()))
{
- SfxItemSet aSet(GetPool(), svl::Items<RES_OPAQUE, RES_ANCHOR>{});
+ SfxItemSetFixed<RES_OPAQUE, RES_ANCHOR> aSet(GetPool());
RndStdIds nAnchorType;
if(bObj)
{
@@ -1867,7 +2057,7 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
break;
case FN_FRAME_WRAP_CONTOUR:
bDisable |= bHtmlMode;
- //no contour available whenn no wrap or wrap through is set
+ //no contour available when no wrap or wrap through is set
bDisable |= (nSurround == css::text::WrapTextMode_NONE || nSurround == css::text::WrapTextMode_THROUGH);
if( !bDisable )
{
@@ -1930,10 +2120,36 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
else
rSet.Put( SfxVisibilityItem( nWhich, false ) );
break;
+ case SID_GRAPHIC_SIZE_CHECK:
+ {
+ sal_Int32 nDPI = rSh.GetDoc()->getIDocumentSettingAccess().getImagePreferredDPI();
+ if (nDPI <= 0)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ case SID_THEME_DIALOG:
+ {
+ bool bDisable = true;
+ auto* pDocument = rSh.GetDoc();
+ auto* pDocumentShell = pDocument->GetDocShell();
+ if (pDocumentShell)
+ {
+ SdrModel* pModel = pDocument->getIDocumentDrawModelAccess().GetDrawModel();
+ if (pModel)
+ {
+ auto const& pTheme = pModel->getTheme();
+ if (pTheme)
+ bDisable = false;
+ }
+ }
+ if (bDisable)
+ rSet.DisableItem(nWhich);
+ }
+ break;
}
nWhich = aIter.NextWhich();
}
- pGetStateSet = nullptr;
+ m_pGetStateSet = nullptr;
}
// Disable the slots with this status method
@@ -1982,7 +2198,7 @@ void SwBaseShell::SetWrapMode( sal_uInt16 nSlot )
if( !bObj && !rSh.IsFrameSelected())
return;
- SfxItemSet aSet(GetPool(), svl::Items<RES_OPAQUE, RES_SURROUND>{});
+ SfxItemSetFixed<RES_OPAQUE, RES_SURROUND> aSet(GetPool());
if(bObj)
rSh.GetObjAttr(aSet);
else
@@ -2086,8 +2302,8 @@ void SwBaseShell::SetWrapMode( sal_uInt16 nSlot )
void SwBaseShell::SetFrameMode(FlyMode eMode, SwWrtShell *pSh )
{
- eFrameMode = eMode;
- SfxBindings &rBnd = pSh->GetView().GetViewFrame()->GetBindings();
+ s_eFrameMode = eMode;
+ SfxBindings &rBnd = pSh->GetView().GetViewFrame().GetBindings();
if( eMode == FLY_DRAG || pSh->IsFrameSelected() || pSh->IsObjSelected() )
{
@@ -2108,10 +2324,10 @@ void SwBaseShell::SetFrameMode(FlyMode eMode, SwWrtShell *pSh )
SwBaseShell::SwBaseShell(SwView& rVw) :
SfxShell( &rVw ),
- rView(rVw),
- pGetStateSet(nullptr)
+ m_rView(rVw),
+ m_pGetStateSet(nullptr)
{
- SwWrtShell& rWrtSh = rView.GetWrtShell();
+ SwWrtShell& rWrtSh = m_rView.GetWrtShell();
SetPool(&rWrtSh.GetAttrPool());
SetName("Base");
@@ -2120,29 +2336,30 @@ SwBaseShell::SwBaseShell(SwView& rVw) :
SwBaseShell::~SwBaseShell()
{
- if( rView.GetCurShell() == this )
- rView.ResetSubShell();
+ if( m_rView.GetCurShell() == this )
+ m_rView.ResetSubShell();
Link<SwCursorShell&,void> aTmp( LINK( this, SwBaseShell, GraphicArrivedHdl));
- if( aTmp == rView.GetWrtShell().GetGrfArrivedLnk() )
- rView.GetWrtShell().SetGrfArrivedLnk( Link<SwCursorShell&,void>() );
+ if( aTmp == m_rView.GetWrtShell().GetGrfArrivedLnk() )
+ m_rView.GetWrtShell().SetGrfArrivedLnk( Link<SwCursorShell&,void>() );
}
void SwBaseShell::ExecTextCtrl( SfxRequest& rReq )
{
const SfxItemSet *pArgs = rReq.GetArgs();
+ const sal_uInt16 nSlot = rReq.GetSlot();
if( pArgs)
{
SwWrtShell &rSh = GetShell();
std::unique_ptr<SvxScriptSetItem> pSSetItem;
- sal_uInt16 nSlot = rReq.GetSlot();
SfxItemPool& rPool = rSh.GetAttrPool();
- sal_uInt16 nWhich = rPool.GetWhich( nSlot );
+ sal_uInt16 nWhich = rPool.GetWhichIDFromSlotID( nSlot );
SvtScriptType nScripts = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
- SfxItemSet aHeightSet( GetPool(), svl::Items<RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE,
- RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_FONTSIZE,
- RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_FONTSIZE>{});
+ SfxItemSetFixed<RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE,
+ RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_FONTSIZE,
+ RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_FONTSIZE>
+ aHeightSet( GetPool() );
switch( nSlot )
{
@@ -2184,9 +2401,10 @@ void SwBaseShell::ExecTextCtrl( SfxRequest& rReq )
sal_uInt32 nHeight = static_cast< const SvxFontHeightItem& >(pArgs->Get( nWhich )).GetHeight();
SwStdFontConfig* pStdFont = SW_MOD()->GetStdFontConfig();
- SfxItemSet aLangSet( GetPool(), svl::Items<RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
- RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
- RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE>{});
+ SfxItemSetFixed<RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
+ RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
+ RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE>
+ aLangSet( GetPool() );
rSh.GetCurAttr( aLangSet );
sal_Int32 nWesternSize =
@@ -2234,7 +2452,7 @@ void SwBaseShell::ExecTextCtrl( SfxRequest& rReq )
( rSh.HasSelection() && rSh.IsSelFullPara() ) )
{
SwTextFormatColl * pColl = rSh.GetCurTextFormatColl();
- if ( pColl && pColl->IsAutoUpdateFormat() )
+ if ( pColl && pColl->IsAutoUpdateOnDirectFormat() )
{
rSh.AutoUpdatePara( pColl, *pArgs );
bAuto = true;
@@ -2248,7 +2466,14 @@ void SwBaseShell::ExecTextCtrl( SfxRequest& rReq )
}
}
else
- GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG );
+ {
+ if (nSlot == SID_ATTR_CHAR_KERNING)
+ GetView().GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG_POSITION);
+ else if (nSlot == SID_ATTR_CHAR_COLOR)
+ GetView().GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG_EFFECT);
+ else
+ GetView().GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG);
+ }
rReq.Done();
}
@@ -2262,7 +2487,7 @@ void SwBaseShell::GetTextFontCtrlState( SfxItemSet& rSet )
{
SwWrtShell &rSh = GetShell();
bool bFirst = true;
- std::unique_ptr<SfxItemSet> pFntCoreSet;
+ std::optional<SfxItemSet> pFntCoreSet;
SvtScriptType nScriptType = SvtScriptType::LATIN;
SfxWhichIter aIter( rSet );
sal_uInt16 nWhich = aIter.FirstWhich();
@@ -2277,8 +2502,8 @@ void SwBaseShell::GetTextFontCtrlState( SfxItemSet& rSet )
{
if( !pFntCoreSet )
{
- pFntCoreSet.reset(new SfxItemSet( *rSet.GetPool(),
- svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{} ));
+ pFntCoreSet.emplace( *rSet.GetPool(),
+ svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1> );
rSh.GetCurAttr( *pFntCoreSet );
nScriptType = rSh.GetScriptType();
// #i42732# input language should be preferred over
@@ -2354,7 +2579,7 @@ void SwBaseShell::GetBckColState(SfxItemSet &rSet)
else
{
// Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set
- SfxItemSet aCoreSet(GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
+ SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> aCoreSet(GetPool());
aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet());
@@ -2377,7 +2602,7 @@ void SwBaseShell::GetBckColState(SfxItemSet &rSet)
case SID_BACKGROUND_COLOR:
case SID_TABLE_CELL_BACKGROUND_COLOR:
{
- SvxColorItem aColorItem(aBrushItem->GetColor(), nWhich);
+ SvxColorItem aColorItem(aBrushItem->GetColor(), aBrushItem->getComplexColor(), nWhich);
rSet.Put(aColorItem);
break;
}
@@ -2418,7 +2643,7 @@ void SwBaseShell::ExecBckCol(SfxRequest& rReq)
else
{
// Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set
- SfxItemSet aCoreSet(GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
+ SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> aCoreSet(GetPool());
aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet());
@@ -2439,37 +2664,17 @@ void SwBaseShell::ExecBckCol(SfxRequest& rReq)
case SID_BACKGROUND_COLOR:
case SID_TABLE_CELL_BACKGROUND_COLOR:
{
- const SfxPoolItem* pColorStringItem = nullptr;
bool bIsTransparent = false;
aBrushItem->SetGraphicPos(GPOS_NONE);
sal_uInt16 nSlotId = (nSlot == SID_BACKGROUND_COLOR) ? SID_BACKGROUND_COLOR : SID_TABLE_CELL_BACKGROUND_COLOR;
- if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem))
- {
- OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue();
- if (sColor == "transparent")
- {
- bIsTransparent = true;
- }
- else
- {
- Color aColor(ColorTransparency, sColor.toInt32(16));
-
- aBrushItem->SetColor(aColor);
-
- SvxColorItem aNewColorItem(nSlotId);
- aNewColorItem.SetValue(aColor);
-
- GetView().GetViewFrame()->GetBindings().SetState(aNewColorItem);
- }
- }
- else if (pArgs)
+ if (pArgs)
{
const SvxColorItem& rNewColorItem = static_cast<const SvxColorItem&>(pArgs->Get(nSlotId));
- const Color& rNewColor = rNewColorItem.GetValue();
- aBrushItem->SetColor(rNewColor);
- GetView().GetViewFrame()->GetBindings().SetState(rNewColorItem);
+ aBrushItem->SetColor(rNewColorItem.GetValue());
+ aBrushItem->setComplexColor(rNewColorItem.getComplexColor());
+ GetView().GetViewFrame().GetBindings().SetState(rNewColorItem);
}
else
{
@@ -2488,7 +2693,7 @@ void SwBaseShell::ExecBckCol(SfxRequest& rReq)
case RES_BACKGROUND:
{
assert(pArgs && "only SID_BACKGROUND_COLOR can have !pArgs, checked at entry");
- aBrushItem.reset(static_cast<SvxBrushItem*>(pArgs->Get(GetPool().GetWhich(nSlot)).Clone()));
+ aBrushItem.reset(static_cast<SvxBrushItem*>(pArgs->Get(GetPool().GetWhichIDFromSlotID(nSlot)).Clone()));
break;
}
default:
@@ -2506,7 +2711,7 @@ void SwBaseShell::ExecBckCol(SfxRequest& rReq)
else
{
// Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set
- SfxItemSet aCoreSet(GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
+ SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> aCoreSet(GetPool());
aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet());
setSvxBrushItemAsFillAttributesToTargetSet(*aBrushItem, aCoreSet);
@@ -2516,7 +2721,7 @@ void SwBaseShell::ExecBckCol(SfxRequest& rReq)
// Template autoupdate
SwFrameFormat* pFormat = rSh.GetSelectedFrameFormat();
- if(pFormat && pFormat->IsAutoUpdateFormat())
+ if(pFormat && pFormat->IsAutoUpdateOnDirectFormat())
{
rSh.AutoUpdateFrame(pFormat, aCoreSet);
}
@@ -2529,7 +2734,7 @@ void SwBaseShell::ExecBckCol(SfxRequest& rReq)
{
SwTextFormatColl* pColl = rSh.GetCurTextFormatColl();
- if(pColl && pColl->IsAutoUpdateFormat())
+ if(pColl && pColl->IsAutoUpdateOnDirectFormat())
{
rSh.AutoUpdatePara(pColl, aCoreSet);
}
@@ -2546,14 +2751,13 @@ void SwBaseShell::ExecBckCol(SfxRequest& rReq)
void SwBaseShell::GetBorderState(SfxItemSet &rSet)
{
SwWrtShell &rSh = GetShell();
- // Tabele cell(s) selected?
+ // Table cell(s) selected?
bool bPrepare = true;
bool bTableMode = rSh.IsTableMode();
if ( bTableMode )
{
- SfxItemSet aCoreSet( GetPool(),
- svl::Items<RES_BOX, RES_BOX,
- SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{} );
+ SfxItemSetFixed<RES_BOX, RES_BOX,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER> aCoreSet( GetPool() );
SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
aCoreSet.Put( aBoxInfo );
rSh.GetTabBorders( aCoreSet );
@@ -2587,7 +2791,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
const SfxItemSet* pOutSet = nullptr;
bool bDone = false;
if(pArgs)
- pArgs->GetItemState( GetPool().GetWhich(nSlot), false, &pItem );
+ pArgs->GetItemState( GetPool().GetWhichIDFromSlotID(nSlot), false, &pItem );
switch ( nSlot )
{
@@ -2603,6 +2807,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
case FN_FORMAT_PAGE_DLG:
case FN_FORMAT_PAGE_COLUMN_DLG:
case FN_FORMAT_PAGE_SETTING_DLG:
+ case FN_FORMAT_PAGE_AREA_DLG:
{
if( !bBackground )
{
@@ -2612,7 +2817,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
// for example disable header
SwView& rTempView = GetView();
- OString sPageId;
+ OUString sPageId;
switch (nSlot)
{
case FN_FORMAT_PAGE_COLUMN_DLG:
@@ -2621,12 +2826,15 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
case FN_FORMAT_PAGE_SETTING_DLG:
sPageId = "page";
break;
+ case FN_FORMAT_PAGE_AREA_DLG:
+ sPageId = "area";
+ break;
case FN_FORMAT_PAGE_DLG:
if (pItem)
- sPageId = OUStringToOString(static_cast<const SfxStringItem*>(pItem)->GetValue(), RTL_TEXTENCODING_UTF8);
+ sPageId = static_cast<const SfxStringItem*>(pItem)->GetValue();
break;
}
- rTempView.GetDocShell()->FormatPage(rPageDesc.GetName(), sPageId, rSh, &rReq);
+ rTempView.GetDocShell()->FormatPage(rReq.GetFrameWeld(), rPageDesc.GetName(), sPageId, rSh, &rReq);
rTempView.InvalidateRulerPos();
bDone = true; // FormatPage() takes care of calling Done()
@@ -2635,9 +2843,8 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
break;
case FN_FORMAT_BORDER_DLG:
{
- SfxItemSet aSet( rSh.GetAttrPool(),
- svl::Items<RES_BOX , RES_SHADOW,
- SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{} );
+ SfxItemSetFixed<RES_BOX , RES_SHADOW,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER> aSet( rSh.GetAttrPool() );
ScopedVclPtr<SfxAbstractDialog> pDlg;
// Table cell(s) selected?
if ( rSh.IsTableMode() )
@@ -2691,9 +2898,8 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
break;
case FN_FORMAT_BACKGROUND_DLG:
{
- SfxItemSet aSet( rSh.GetAttrPool(),
- svl::Items<RES_BACKGROUND, RES_BACKGROUND,
- XATTR_FILL_FIRST, XATTR_FILL_LAST>{} );
+ SfxItemSetFixed<RES_BACKGROUND, RES_BACKGROUND,
+ XATTR_FILL_FIRST, XATTR_FILL_LAST> aSet( rSh.GetAttrPool() );
ScopedVclPtr<SfxAbstractDialog> pDlg;
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
@@ -2702,10 +2908,11 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
if ( rSh.IsTableMode() )
{
// Get background attributes of the table and put it in the set
- std::unique_ptr<SvxBrushItem> aBrush;
+ // tdf#144843 calling GetBoxBackground *requires* an incarnation to be handed over
+ std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
rSh.GetBoxBackground( aBrush );
pDlg.disposeAndReset(pFact->CreateSwBackgroundDialog(pMDI, aSet));
- aSet.Put( *aBrush );
+ aSet.Put( std::move(aBrush) );
if ( pDlg->Execute() == RET_OK )
{
@@ -2744,14 +2951,42 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
}
}
break;
- case SID_ACCESSIBILITY_CHECK:
+
+ case SID_GRAPHIC_SIZE_CHECK:
{
- sw::AccessibilityCheck aCheck(rSh.GetDoc());
- aCheck.check();
- svx::AccessibilityCheckDialog aDialog(pMDI, aCheck.getIssueCollection());
+ sw::GraphicSizeCheckGUIResult aResult(rSh.GetDoc());
+ svx::GenericCheckDialog aDialog(pMDI, aResult);
aDialog.run();
}
break;
+
+ case SID_THEME_DIALOG:
+ {
+ auto* pDocument = rSh.GetDoc();
+ auto* pDocumentShell = pDocument->GetDocShell();
+ if (pDocumentShell)
+ {
+ SdrModel* pModel = pDocument->getIDocumentDrawModelAccess().GetDrawModel();
+ auto const& pTheme = pModel->getTheme();
+ if (pTheme)
+ {
+ std::shared_ptr<svx::IThemeColorChanger> xChanger(new sw::ThemeColorChanger(pDocumentShell));
+ auto pDialog = std::make_shared<svx::ThemeDialog>(pMDI, pTheme.get());
+ weld::DialogController::runAsync(pDialog, [pDialog, xChanger=std::move(xChanger)](sal_uInt32 nResult) {
+ if (RET_OK != nResult)
+ return;
+
+ auto pColorSet = pDialog->getCurrentColorSet();
+ if (pColorSet)
+ {
+ xChanger->apply(pColorSet);
+ }
+ });
+ }
+ }
+ }
+ break;
+
default:OSL_FAIL("wrong Dispatcher (basesh.cxx)");
}
if(!bDone)
@@ -2760,12 +2995,12 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
SwWrtShell& SwBaseShell::GetShell()
{
- return rView.GetWrtShell();
+ return m_rView.GetWrtShell();
}
SwWrtShell* SwBaseShell::GetShellPtr()
{
- return rView.GetWrtShellPtr();
+ return m_rView.GetWrtShellPtr();
}
static void EndUndo(SwWrtShell& rSh)
@@ -2801,7 +3036,7 @@ static void InsertTableImpl(SwWrtShell& rSh,
rSh.MoveTable( GotoPrevTable, fnTableStart );
if( !aTableName.isEmpty() && !rSh.GetTableStyle( aTableName ) )
- rSh.GetTableFormat()->SetName( aTableName );
+ rSh.GetTableFormat()->SetFormatName( aTableName );
if( pTAFormat != nullptr && !aAutoName.isEmpty()
&& aAutoName != SwViewShell::GetShellRes()->aStrNone )
@@ -3063,7 +3298,7 @@ void SwBaseShell::ExecuteGallery(SfxRequest &rReq)
rSh.SetBoxBackground( aBrush );
else if ( nPos == nFramePos || nPos == nGraphicPos || nPos == nOlePos )
{
- SfxItemSet aCoreSet(GetPool(), svl::Items<RES_BACKGROUND, RES_BACKGROUND>{});
+ SfxItemSetFixed<RES_BACKGROUND, RES_BACKGROUND> aCoreSet(GetPool());
aCoreSet.Put( aBrush );
rSh.SetFlyFrameAttr( aCoreSet );
}
@@ -3099,12 +3334,19 @@ void SwBaseShell::ExecField( SfxRequest const & rReq )
sal_uInt16 nSlot = rReq.GetSlot();
switch( nSlot )
{
-#if HAVE_FEATURE_DBCONNECTIVITY
+#if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS
case FN_CHANGE_DBFIELD:
{
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
- ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwChangeDBDlg(GetView()));
- pDlg->Execute();
+ VclPtr<AbstractChangeDbDialog> pDlg(pFact->CreateSwChangeDBDlg(GetView()));
+ pDlg->StartExecuteAsync(
+ [pDlg] (sal_Int32 nResult)->void
+ {
+ if (nResult == RET_OK)
+ pDlg->UpdateFields();
+ pDlg->disposeOnce();
+ }
+ );
}
break;
#endif