1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <config_features.h>
22 #include <sal/config.h>
24 #include <hintids.hxx>
25 #include <svl/languageoptions.hxx>
26 #include <sfx2/linkmgr.hxx>
27 #include <sfx2/htmlmode.hxx>
28 #include <svx/imapdlg.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/viewfrm.hxx>
31 #include <sfx2/request.hxx>
32 #include <svl/whiter.hxx>
33 #include <svl/visitem.hxx>
34 #include <editeng/langitem.hxx>
35 #include <svx/clipfmtitem.hxx>
36 #include <svx/contdlg.hxx>
37 #include <vcl/graph.hxx>
38 #include <vcl/inputctx.hxx>
39 #include <svl/slstitm.hxx>
40 #include <svl/ptitem.hxx>
41 #include <svl/stritem.hxx>
42 #include <editeng/colritem.hxx>
43 #include <editeng/fhgtitem.hxx>
44 #include <editeng/fontitem.hxx>
45 #include <editeng/shaditem.hxx>
46 #include <editeng/boxitem.hxx>
47 #include <editeng/brushitem.hxx>
48 #include <editeng/opaqitem.hxx>
49 #include <editeng/sizeitem.hxx>
50 #include <svx/flagsdef.hxx>
51 #include <editeng/scripttypeitem.hxx>
52 #include <sfx2/objface.hxx>
54 #include <fmthdft.hxx>
55 #include <fmtclds.hxx>
59 #include <swmodule.hxx>
64 #include <viewopt.hxx>
65 #include <fontcfg.hxx>
66 #include <fmtsrnd.hxx>
69 #include <tablemgr.hxx>
71 #include <swdtflvr.hxx>
72 #include <pagedesc.hxx>
75 #include <tblafmt.hxx>
78 #include <strings.hrc>
79 #include <unotxdoc.hxx>
81 #include <IDocumentSettingAccess.hxx>
82 #include <IDocumentUndoRedo.hxx>
83 #include <swabstdlg.hxx>
85 #include <svx/fmshell.hxx>
86 #include <SwRewriter.hxx>
87 #include <svx/galleryitem.hxx>
88 #include <svx/devtools/DevelopmentToolChildWindow.hxx>
89 #include <com/sun/star/gallery/GalleryItemType.hpp>
92 #include <svx/unobrushitemhelper.hxx>
93 #include <comphelper/scopeguard.hxx>
94 #include <comphelper/lok.hxx>
96 #include <svx/svxdlg.hxx>
98 #include <shellres.hxx>
99 #include <UndoTable.hxx>
101 FlyMode
SwBaseShell::eFrameMode
= FLY_DRAG_END
;
103 // These variables keep the state of Gallery (slot SID_GALLERY_BG_BRUSH)
104 // detected by GetGalleryState() for the subsequent ExecuteGallery() call.
106 static sal_uInt8 nParagraphPos
;
107 static sal_uInt8 nGraphicPos
;
108 static sal_uInt8 nOlePos
;
109 static sal_uInt8 nFramePos
;
110 static sal_uInt8 nTablePos
;
111 static sal_uInt8 nTableRowPos
;
112 static sal_uInt8 nTableCellPos
;
113 static sal_uInt8 nPagePos
;
114 static sal_uInt8 nHeaderPos
;
115 static sal_uInt8 nFooterPos
;
117 #define ShellClass_SwBaseShell
118 #include <sfx2/msg.hxx>
119 #include <swslots.hxx>
121 #include <AccessibilityCheck.hxx>
122 #include <svx/AccessibilityCheckDialog.hxx>
126 SvxContourDlg
* GetContourDlg(SwView
const &rView
)
128 SfxChildWindow
*pWnd
= rView
.GetViewFrame()->GetChildWindow(SvxContourDlgChildWindow::GetChildWindowId());
129 return pWnd
? static_cast<SvxContourDlg
*>(pWnd
->GetController().get()) : nullptr;
132 SvxIMapDlg
* GetIMapDlg(SwView
const &rView
)
134 SfxChildWindow
* pWnd
= rView
.GetViewFrame()->GetChildWindow(SvxIMapDlgChildWindow::GetChildWindowId());
135 return pWnd
? static_cast<SvxIMapDlg
*>(pWnd
->GetController().get()) : nullptr;
139 using namespace ::com::sun::star
;
140 using namespace ::com::sun::star::uno
;
141 using namespace ::com::sun::star::frame
;
142 using namespace ::com::sun::star::lang
;
144 SFX_IMPL_SUPERCLASS_INTERFACE(SwBaseShell
, SfxShell
)
146 void SwBaseShell::InitInterface_Impl()
148 GetStaticInterface()->RegisterChildWindow(SvxIMapDlgChildWindow::GetChildWindowId());
149 GetStaticInterface()->RegisterChildWindow(SvxContourDlgChildWindow::GetChildWindowId());
150 GetStaticInterface()->RegisterChildWindow(DevelopmentToolChildWindow::GetChildWindowId());
153 static void lcl_UpdateIMapDlg( SwWrtShell
& rSh
)
155 Graphic
aGrf( rSh
.GetIMapGraphic() );
156 GraphicType nGrfType
= aGrf
.GetType();
157 void* pEditObj
= GraphicType::NONE
!= nGrfType
&& GraphicType::Default
!= nGrfType
158 ? rSh
.GetIMapInventor() : nullptr;
159 std::unique_ptr
<TargetList
> pList(new TargetList
);
160 SfxFrame::GetDefaultTargetList(*pList
);
162 SfxItemSet
aSet( rSh
.GetAttrPool(), svl::Items
<RES_URL
, RES_URL
>{} );
163 rSh
.GetFlyFrameAttr( aSet
);
164 const SwFormatURL
&rURL
= aSet
.Get( RES_URL
);
165 SvxIMapDlgChildWindow::UpdateIMapDlg(
166 aGrf
, rURL
.GetMap(), pList
.get(), pEditObj
);
169 static bool lcl_UpdateContourDlg( SwWrtShell
&rSh
, SelectionType nSel
)
171 Graphic
aGraf( rSh
.GetIMapGraphic() );
172 GraphicType nGrfType
= aGraf
.GetType();
173 bool bRet
= GraphicType::NONE
!= nGrfType
&& GraphicType::Default
!= nGrfType
;
177 if ( nSel
& SelectionType::Graphic
)
178 rSh
.GetGrfNms( &aGrfName
, nullptr );
180 SvxContourDlg
*pDlg
= GetContourDlg(rSh
.GetView());
183 pDlg
->Update(aGraf
, !aGrfName
.isEmpty(),
184 rSh
.GetGraphicPolygon(), rSh
.GetIMapInventor());
190 void SwBaseShell::ExecDelete(SfxRequest
&rReq
)
192 SwWrtShell
&rSh
= GetShell();
193 SwEditWin
& rTmpEditWin
= GetView().GetEditWin();
194 switch(rReq
.GetSlot())
205 bool bLeft
= rSh
.Left( CRSR_SKIP_CHARS
, true, 1, false );
211 // JP 15.07.96: If it no longer goes forward, cancel
212 // the numbering. For example at the beginning
213 // of a doc, frame, table or an area.
220 [[fallthrough
]]; // otherwise call DelLeft
221 case FN_SHIFT_BACKSPACE
:
225 OSL_FAIL("wrong Dispatcher");
230 //#i42732# - notify the edit window that from now on we do not use the input language
231 rTmpEditWin
.SetUseInputLanguage( false );
234 void SwBaseShell::ExecClpbrd(SfxRequest
&rReq
)
236 // Attention: At risk of suicide!
237 // After paste, paste special the shell can be destroy.
239 SwWrtShell
&rSh
= GetShell();
240 sal_uInt16 nId
= rReq
.GetSlot();
241 bool bIgnore
= false;
242 PasteTableType ePasteTable
= PasteTableType::PASTE_DEFAULT
;
248 rView
.GetEditWin().FlushInBuffer();
249 if ( rSh
.HasSelection() )
251 rtl::Reference
<SwTransferable
> pTransfer
= new SwTransferable( rSh
);
253 if ( nId
== SID_CUT
&& FlyProtectFlags::NONE
== rSh
.IsSelObjProtected(FlyProtectFlags::Content
|FlyProtectFlags::Parent
) )
257 const bool bLockedView
= rSh
.IsViewLocked();
258 rSh
.LockView( true ); //lock visible section
260 rSh
.LockView( bLockedView
);
266 case FN_PASTE_NESTED_TABLE
:
267 case FN_TABLE_PASTE_ROW_BEFORE
:
268 case FN_TABLE_PASTE_COL_BEFORE
:
271 case FN_PASTE_NESTED_TABLE
:
272 ePasteTable
= PasteTableType::PASTE_TABLE
;
274 case FN_TABLE_PASTE_ROW_BEFORE
:
275 ePasteTable
= PasteTableType::PASTE_ROW
;
277 case FN_TABLE_PASTE_COL_BEFORE
:
278 ePasteTable
= PasteTableType::PASTE_COLUMN
;
286 TransferableDataHelper
aDataHelper(
287 TransferableDataHelper::CreateFromSystemClipboard( &rSh
.GetView().GetEditWin() ) );
288 if( aDataHelper
.GetXTransferable().is()
289 && SwTransferable::IsPaste( rSh
, aDataHelper
) )
291 // Temporary variables, because the shell could already be
292 // destroyed after the paste.
293 SwView
* pView
= &rView
;
295 RndStdIds nAnchorType
= RndStdIds::FLY_AT_PARA
;
296 const SfxUInt16Item
* pAnchorType
= rReq
.GetArg
<SfxUInt16Item
>(FN_PARAM_1
);
298 nAnchorType
= static_cast<RndStdIds
>(pAnchorType
->GetValue());
299 bool bIgnoreComments
= false;
300 const SfxBoolItem
* pIgnoreComments
= rReq
.GetArg
<SfxBoolItem
>(FN_PARAM_2
);
302 bIgnoreComments
= pIgnoreComments
->GetValue();
303 SwTransferable::Paste(rSh
, aDataHelper
, nAnchorType
, bIgnoreComments
, ePasteTable
);
305 if( rSh
.IsFrameSelected() || rSh
.IsObjSelected() )
306 rSh
.EnterSelFrameMode();
307 pView
->AttrChangedNotify(nullptr);
314 case SID_CLIPBOARD_FORMAT_ITEMS
:
316 const SfxItemSet
* pArgs
= rReq
.GetArgs();
317 const SfxPoolItem
* pFormat
;
318 if( pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( nId
, false, &pFormat
) )
320 TransferableDataHelper
aDataHelper(
321 TransferableDataHelper::CreateFromSystemClipboard(
322 &rSh
.GetView().GetEditWin()) );
323 if( aDataHelper
.GetXTransferable().is()
324 /*&& SwTransferable::IsPaste( rSh, aDataHelper )*/ )
326 // Temporary variables, because the shell could already be
327 // destroyed after the paste.
328 SwView
* pView
= &rView
;
330 SwTransferable::PasteFormat( rSh
, aDataHelper
,
331 static_cast<SotClipboardFormatId
>(static_cast<const SfxUInt32Item
*>(pFormat
)->GetValue()) );
333 //Done() has to be called before the shell has been removed
336 if( rSh
.IsFrameSelected() || rSh
.IsObjSelected())
337 rSh
.EnterSelFrameMode();
338 pView
->AttrChangedNotify(nullptr);
344 case SID_PASTE_UNFORMATTED
:
346 TransferableDataHelper
aDataHelper(
347 TransferableDataHelper::CreateFromSystemClipboard( &rSh
.GetView().GetEditWin()) );
348 if( aDataHelper
.GetXTransferable().is()
349 && SwTransferable::IsPaste( rSh
, aDataHelper
) )
351 // Temporary variables, because the shell could already be
352 // destroyed after the paste.
353 SwView
* pView
= &rView
;
356 if(SwTransferable::PasteUnformatted( rSh
, aDataHelper
))
358 SfxViewFrame
* pViewFrame
= pView
->GetViewFrame();
359 uno::Reference
< frame::XDispatchRecorder
> xRecorder
=
360 pViewFrame
->GetBindings().GetRecorder();
362 SfxRequest
aReq( pViewFrame
, SID_CLIPBOARD_FORMAT_ITEMS
);
363 aReq
.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS
, static_cast<sal_uInt32
>(SotClipboardFormatId::STRING
) ) );
368 if (rSh
.IsFrameSelected() || rSh
.IsObjSelected())
369 rSh
.EnterSelFrameMode();
370 pView
->AttrChangedNotify(nullptr);
377 case SID_PASTE_SPECIAL
:
379 std::shared_ptr
<TransferableDataHelper
> aDataHelper
=
380 std::make_shared
<TransferableDataHelper
>(TransferableDataHelper::CreateFromSystemClipboard( &rSh
.GetView().GetEditWin()));
382 if( aDataHelper
->GetXTransferable().is()
383 && SwTransferable::IsPaste( rSh
, *aDataHelper
)
384 && !rSh
.CursorInsideInputField() )
389 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
390 VclPtr
<SfxAbstractPasteDialog
> pDlg(pFact
->CreatePasteDialog( rReq
.GetFrameWeld() ));
392 // Prepare the dialog
393 SwTransferable::PrePasteSpecial(rSh
, *aDataHelper
, pDlg
);
394 pDlg
->PreGetFormat(*aDataHelper
);
397 pDlg
->StartExecuteAsync([aDataHelper
, pDlg
, &rSh
, this](sal_Int32 nResult
){
398 if (nResult
== RET_OK
)
400 // Temporary variables, because the shell could already be
401 // destroyed after the paste.
402 SwView
* pView
= &rView
;
404 SotClipboardFormatId nFormatId
= pDlg
->GetFormatOnly();
406 if( nFormatId
!= SotClipboardFormatId::NONE
)
407 bRet
= SwTransferable::PasteFormat( rSh
, *aDataHelper
, nFormatId
);
411 SfxViewFrame
* pViewFrame
= pView
->GetViewFrame();
412 uno::Reference
< frame::XDispatchRecorder
> xRecorder
=
413 pViewFrame
->GetBindings().GetRecorder();
415 SfxRequest
aReq( pViewFrame
, SID_CLIPBOARD_FORMAT_ITEMS
);
416 aReq
.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS
, static_cast<sal_uInt32
>(nFormatId
) ) );
421 if (rSh
.IsFrameSelected() || rSh
.IsObjSelected())
422 rSh
.EnterSelFrameMode();
423 pView
->AttrChangedNotify(nullptr);
436 OSL_FAIL("wrong Dispatcher");
445 void SwBaseShell::StateClpbrd(SfxItemSet
&rSet
)
447 SwWrtShell
&rSh
= GetShell();
448 SfxWhichIter
aIter(rSet
);
450 const bool bCopy
= rSh
.HasSelection();
452 sal_uInt16 nWhich
= aIter
.FirstWhich();
459 if( FlyProtectFlags::NONE
!= rSh
.IsSelObjProtected(FlyProtectFlags::Content
|FlyProtectFlags::Parent
) )
461 rSet
.DisableItem( nWhich
);
466 if( !bCopy
|| GetObjectShell()->isContentExtractionLocked())
467 rSet
.DisableItem( nWhich
);
470 case FN_PASTE_NESTED_TABLE
:
471 case FN_TABLE_PASTE_ROW_BEFORE
:
472 case FN_TABLE_PASTE_COL_BEFORE
:
473 if( !rSh
.IsCursorInTable()
474 || !GetView().IsPasteSpecialAllowed()
475 || rSh
.CursorInsideInputField()
476 // disable if not a native Writer table and not a spreadsheet format
477 || !GetView().IsPasteSpreadsheet(rSh
.GetTableCopied()) )
479 rSet
.DisableItem( nWhich
);
484 if( !GetView().IsPasteAllowed() )
486 rSet
.DisableItem( nWhich
);
490 case SID_PASTE_SPECIAL
:
491 if( !GetView().IsPasteSpecialAllowed()
492 || rSh
.CursorInsideInputField() )
494 rSet
.DisableItem( nWhich
);
498 case SID_PASTE_UNFORMATTED
:
499 if( !GetView().IsPasteSpecialAllowed() )
501 rSet
.DisableItem( nWhich
);
505 case SID_CLIPBOARD_FORMAT_ITEMS
:
507 TransferableDataHelper
aDataHelper(
508 TransferableDataHelper::CreateFromSystemClipboard(
509 &rSh
.GetView().GetEditWin()) );
511 SvxClipboardFormatItem
aFormatItem( nWhich
);
512 SwTransferable::FillClipFormatItem( rSh
, aDataHelper
, aFormatItem
);
513 rSet
.Put( aFormatItem
);
517 nWhich
= aIter
.NextWhich();
523 void SwBaseShell::ExecUndo(SfxRequest
&rReq
)
525 SwWrtShell
&rWrtShell
= GetShell();
527 SwUndoId
nUndoId(SwUndoId::EMPTY
);
528 sal_uInt16 nId
= rReq
.GetSlot(), nCnt
= 1;
529 const SfxItemSet
* pArgs
= rReq
.GetArgs();
530 const SfxPoolItem
* pItem
;
531 if( pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( nId
, false, &pItem
))
532 nCnt
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
534 // Repair mode: allow undo/redo of all undo actions, even if access would
535 // be limited based on the view shell ID.
536 bool bRepair
= false;
537 if (pArgs
&& pArgs
->GetItemState(SID_REPAIRPACKAGE
, false, &pItem
) == SfxItemState::SET
)
538 bRepair
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
540 // #i106349#: save pointer: undo/redo may delete the shell, i.e., this!
541 SfxViewFrame
*const pViewFrame( GetView().GetViewFrame() );
543 IDocumentUndoRedo
& rUndoRedo
= rWrtShell
.GetIDocumentUndoRedo();
544 bool bWasRepair
= rUndoRedo
.DoesRepair();
545 rUndoRedo
.DoRepair(bRepair
);
546 comphelper::ScopeGuard
aGuard([&rUndoRedo
, bWasRepair
]()
548 rUndoRedo
.DoRepair(bWasRepair
);
554 if (rUndoRedo
.GetLastUndoInfo(nullptr, &nUndoId
, &rWrtShell
.GetView()))
556 for (SwViewShell
& rShell
: rWrtShell
.GetRingContainer())
558 rWrtShell
.Do( SwWrtShell::UNDO
, nCnt
);
559 for (SwViewShell
& rShell
: rWrtShell
.GetRingContainer())
560 rShell
.UnlockPaint();
565 if (rUndoRedo
.GetFirstRedoInfo(nullptr, &nUndoId
, &rWrtShell
.GetView()))
567 for (SwViewShell
& rShell
: rWrtShell
.GetRingContainer())
569 rWrtShell
.Do( SwWrtShell::REDO
, nCnt
);
570 for (SwViewShell
& rShell
: rWrtShell
.GetRingContainer())
571 rShell
.UnlockPaint();
576 rWrtShell
.Do( SwWrtShell::REPEAT
);
579 OSL_FAIL("wrong Dispatcher");
582 if (nUndoId
== SwUndoId::CONFLICT
)
584 rReq
.SetReturnValue( SfxUInt32Item(nId
, static_cast<sal_uInt32
>(SID_REPAIRPACKAGE
)) );
586 else if (nUndoId
== SwUndoId::INSFMTATTR
)
588 rWrtShell
.GetDoc()->GetDocShell()->GetStyleSheetPool()->Broadcast(SfxHint(SfxHintId::StyleSheetModified
));
591 if (pViewFrame
) { pViewFrame
->GetBindings().InvalidateAll(false); }
596 void SwBaseShell::StateUndo(SfxItemSet
&rSet
)
598 SwUndoId
nUndoId(SwUndoId::EMPTY
);
599 SwWrtShell
&rSh
= GetShell();
600 SfxWhichIter
aIter(rSet
);
601 sal_uInt16 nWhich
= aIter
.FirstWhich();
608 if (rSh
.GetLastUndoInfo(nullptr, &nUndoId
, &rSh
.GetView()))
610 rSet
.Put( SfxStringItem(nWhich
,
611 rSh
.GetDoString(SwWrtShell::UNDO
)));
613 else if (nUndoId
== SwUndoId::CONFLICT
)
615 rSet
.Put( SfxUInt32Item(nWhich
, static_cast<sal_uInt32
>(SID_REPAIRPACKAGE
)) );
618 rSet
.DisableItem(nWhich
);
624 if (rSh
.GetFirstRedoInfo(nullptr, &nUndoId
, &rSh
.GetView()))
626 rSet
.Put(SfxStringItem(nWhich
,
627 rSh
.GetDoString(SwWrtShell::REDO
)));
629 else if (nUndoId
== SwUndoId::CONFLICT
)
631 rSet
.Put( SfxInt32Item(nWhich
, static_cast<sal_uInt32
>(SID_REPAIRPACKAGE
)) );
634 rSet
.DisableItem(nWhich
);
638 { // Repeat is only possible if no REDO is possible - UI-Restriction
639 if ((!rSh
.GetFirstRedoInfo(nullptr, nullptr)) &&
640 !rSh
.IsSelFrameMode() &&
641 (SwUndoId::EMPTY
!= rSh
.GetRepeatInfo(nullptr)))
643 rSet
.Put(SfxStringItem(nWhich
, rSh
.GetRepeatString()));
646 rSet
.DisableItem(nWhich
);
650 case SID_GETUNDOSTRINGS
:
651 if (rSh
.GetLastUndoInfo(nullptr, nullptr))
653 SfxStringListItem
aStrLst( nWhich
);
654 rSh
.GetDoStrings( SwWrtShell::UNDO
, aStrLst
);
658 rSet
.DisableItem( nWhich
);
661 case SID_GETREDOSTRINGS
:
662 if (rSh
.GetFirstRedoInfo(nullptr, nullptr))
664 SfxStringListItem
aStrLst( nWhich
);
665 rSh
.GetDoStrings( SwWrtShell::REDO
, aStrLst
);
669 rSet
.DisableItem( nWhich
);
672 nWhich
= aIter
.NextWhich();
676 // Evaluate respectively dispatching the slot Id
678 void SwBaseShell::Execute(SfxRequest
&rReq
)
680 const SfxPoolItem
*pItem
;
681 SwWrtShell
&rSh
= GetShell();
682 const SfxItemSet
* pArgs
= rReq
.GetArgs();
685 sal_uInt16 nSlot
= rReq
.GetSlot();
690 Reference
< XModel
> xModel
= GetView().GetDocShell()->GetModel();
691 auto pDoc
= comphelper::getUnoTunnelImplementation
<SwXTextDocument
>(xModel
);
692 pDoc
->NotifyRefreshListeners();
696 case FN_UPDATE_FIELDS
:
699 rSh
.EndAllTableBoxEdit();
700 rSh
.SwViewShell::UpdateFields(true);
702 if( rSh
.IsCursorInTable() )
704 if( !rSh
.IsTableComplexForChart() )
705 SwTableFUNC( &rSh
).UpdateChart();
706 rSh
.ClearTableBoxContent();
707 rSh
.SaveTableBoxContent();
711 case FN_UPDATE_CHARTS
:
713 SwWait
aWait( *rView
.GetDocShell(), true );
714 rSh
.UpdateAllCharts();
720 comphelper::EmbeddedObjectContainer
& rEmbeddedObjectContainer
721 = GetObjectShell()->getEmbeddedObjectContainer();
722 rEmbeddedObjectContainer
.setUserAllowsLinkUpdate(true);
724 SwView
& rTempView
= GetView();
726 if( !rSh
.GetLinkManager().GetLinks().empty() )
728 rSh
.StartAllAction();
729 rSh
.GetLinkManager().UpdateAllLinks( false, true, nullptr );
732 SfxDispatcher
&rDis
= *rTempView
.GetViewFrame()->GetDispatcher();
733 rDis
.Execute( FN_UPDATE_FIELDS
);
734 rDis
.Execute( FN_UPDATE_TOX
);
735 rDis
.Execute( FN_UPDATE_CHARTS
);
740 case FN_UPDATE_INPUTFIELDS
:
741 rSh
.UpdateInputFields();
744 case FN_PREV_BOOKMARK
:
745 rReq
.SetReturnValue(SfxBoolItem( nSlot
, rSh
.GoPrevBookmark()));
747 case FN_NEXT_BOOKMARK
:
748 rReq
.SetReturnValue(SfxBoolItem( nSlot
, rSh
.GoNextBookmark()));
751 case FN_GOTO_NEXT_MARK
:
752 case FN_GOTO_PREV_MARK
:
754 SwFieldMgr aFieldMgr
;
755 SwFieldType
* pFieldType
= aFieldMgr
.GetFieldType(SwFieldIds::JumpEdit
);
759 if (rSh
.IsSelFrameMode())
762 rSh
.LeaveSelFrameMode();
767 SwMvContext
aMvContext(&rSh
);
768 if (rSh
.IsCursorPtAtEnd())
773 bool bRet
= rSh
.MoveFieldType( pFieldType
, nSlot
== FN_GOTO_NEXT_MARK
);
774 SwField
* pCurField
= bRet
? rSh
.GetCurField() : nullptr;
776 rSh
.ClickToField(*pCurField
);
777 rReq
.SetReturnValue(SfxBoolItem( nSlot
, bRet
));
782 case FN_START_DOC_DIRECT
:
783 case FN_END_DOC_DIRECT
:
785 if (rSh
.IsSelFrameMode())
788 rSh
.LeaveSelFrameMode();
791 nSlot
== FN_START_DOC_DIRECT
?
792 rSh
.SttEndDoc(true) :
793 rSh
.SttEndDoc(false);
796 case FN_GOTO_PREV_OBJ
:
797 case FN_GOTO_NEXT_OBJ
:
799 bool bSuccess
= rSh
.GotoObj( nSlot
== FN_GOTO_NEXT_OBJ
);
800 rReq
.SetReturnValue(SfxBoolItem(nSlot
, bSuccess
));
801 if (bSuccess
&& !rSh
.IsSelFrameMode())
804 rSh
.EnterSelFrameMode();
805 GetView().AttrChangedNotify(nullptr);
809 case SID_GALLERY_FORMATS
:
811 const SvxGalleryItem
* pGalleryItem
= SfxItemSet::GetItem
<SvxGalleryItem
>(pArgs
, SID_GALLERY_FORMATS
, false);
815 const SelectionType nSelType
= rSh
.GetSelectionType();
816 sal_Int8
nGalleryItemType( pGalleryItem
->GetType() );
818 if ( (!rSh
.IsSelFrameMode() || nSelType
& SelectionType::Graphic
) &&
819 nGalleryItemType
== css::gallery::GalleryItemType::GRAPHIC
)
821 SwWait
aWait( *rView
.GetDocShell(), true );
823 OUString aGrfName
, aFltName
;
824 const Graphic
aGrf( pGalleryItem
->GetGraphic() );
826 if ( nSelType
& SelectionType::Graphic
)
827 rSh
.ReRead( aGrfName
, aFltName
, &aGrf
);
829 rSh
.Insert( aGrfName
, aFltName
, aGrf
);
831 GetView().GetEditWin().GrabFocus();
833 else if(!rSh
.IsSelFrameMode() &&
834 nGalleryItemType
== css::gallery::GalleryItemType::MEDIA
)
836 const SfxStringItem
aMediaURLItem( SID_INSERT_AVMEDIA
, pGalleryItem
->GetURL() );
837 GetView().GetViewFrame()->GetDispatcher()->ExecuteList(
838 SID_INSERT_AVMEDIA
, SfxCallMode::SYNCHRON
,
843 case FN_PAGE_STYLE_SET_COLS
:
847 // Determine the current PageDescriptor and fill the set with that.
848 const size_t nCurIdx
= rSh
.GetCurPageDesc();
849 SwPageDesc
aPageDesc(rSh
.GetPageDesc(nCurIdx
));
851 SwFrameFormat
&rFormat
= aPageDesc
.GetMaster();
853 SwFormatCol aFormatCol
= rFormat
.GetCol();
856 if(SfxItemState::SET
== pArgs
->GetItemState(nSlot
))
857 nCount
= static_cast<const SfxUInt16Item
&>(pArgs
->Get(nSlot
)).GetValue();
859 nCount
= pArgs
->Get(SID_ATTR_COLUMNS
).GetValue();
860 sal_uInt16 nGutterWidth
= DEF_GUTTER_WIDTH
;
862 aFormatCol
.Init(nCount
? nCount
: 1, nGutterWidth
, USHRT_MAX
);
863 aFormatCol
.SetWishWidth(USHRT_MAX
);
864 aFormatCol
.SetGutterWidth(nGutterWidth
, USHRT_MAX
);
866 rFormat
.SetFormatAttr(aFormatCol
);
868 rSh
.ChgPageDesc(nCurIdx
, aPageDesc
);
871 GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG
);
874 case FN_CONVERT_TABLE_TO_TEXT
:
875 case FN_CONVERT_TEXT_TO_TABLE
:
876 case FN_CONVERT_TEXT_TABLE
:
878 sal_Unicode cDelim
= 0;
879 bool bToTable
= false;
880 if( nSlot
== FN_CONVERT_TEXT_TO_TABLE
||
881 ( nSlot
== FN_CONVERT_TEXT_TABLE
&& nullptr == rSh
.GetTableFormat() ))
883 SwInsertTableOptions
aInsTableOpts( SwInsertTableFlags::All
, 1 );
884 SwTableAutoFormat
const* pTAFormat
= nullptr;
885 std::unique_ptr
<SwTableAutoFormatTable
> pAutoFormatTable
;
886 bool bDeleteFormat
= true;
887 if(pArgs
&& SfxItemState::SET
== pArgs
->GetItemState( FN_PARAM_1
, true, &pItem
))
889 aInsTableOpts
.mnInsMode
= SwInsertTableFlags::NONE
;
891 OUString sDelim
= static_cast< const SfxStringItem
* >(pItem
)->GetValue();
892 if(!sDelim
.isEmpty())
895 if(SfxItemState::SET
== pArgs
->GetItemState( FN_PARAM_2
, true, &pItem
))
897 OUString sAutoFormat
= static_cast< const SfxStringItem
* >(pItem
)->GetValue();
899 pAutoFormatTable
.reset(new SwTableAutoFormatTable
);
900 pAutoFormatTable
->Load();
902 for( sal_uInt16 i
= 0, nCount
= pAutoFormatTable
->size(); i
< nCount
; i
++ )
904 SwTableAutoFormat
const*const pFormat
= &(*pAutoFormatTable
)[ i
];
905 if( pFormat
->GetName() == sAutoFormat
)
908 bDeleteFormat
= false;
914 if(SfxItemState::SET
== pArgs
->GetItemState( FN_PARAM_3
, true, &pItem
) &&
915 static_cast< const SfxBoolItem
* >(pItem
)->GetValue())
916 aInsTableOpts
.mnInsMode
|= SwInsertTableFlags::Headline
;
918 if(SfxItemState::SET
== pArgs
->GetItemState( FN_PARAM_4
, true, &pItem
))
919 aInsTableOpts
.mnRowsToRepeat
=
920 static_cast<sal_uInt16
>(static_cast< const SfxInt16Item
* >(pItem
)->GetValue());
922 if(SfxItemState::SET
== pArgs
->GetItemState( FN_PARAM_5
, true, &pItem
) &&
923 static_cast< const SfxBoolItem
* >(pItem
)->GetValue())
924 aInsTableOpts
.mnInsMode
|= SwInsertTableFlags::DefaultBorder
;
926 if(SfxItemState::SET
== pArgs
->GetItemState( FN_PARAM_6
, true, &pItem
) &&
927 !static_cast< const SfxBoolItem
* >(pItem
)->GetValue() )
928 aInsTableOpts
.mnInsMode
|= SwInsertTableFlags::SplitLayout
;
932 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
933 ScopedVclPtr
<AbstractSwConvertTableDlg
> pDlg(pFact
->CreateSwConvertTableDlg(GetView(), bToTable
));
934 if( RET_OK
== pDlg
->Execute() )
936 pDlg
->GetValues( cDelim
, aInsTableOpts
, pTAFormat
);
944 SwView
& rSaveView
= rView
;
945 bool bInserted
= false;
947 SfxViewFrame
* pViewFrame
= GetView().GetViewFrame();
948 if( SfxRequest::HasMacroRecorder(pViewFrame
) )
950 SfxRequest
aReq( pViewFrame
, nSlot
);
951 aReq
.AppendItem( SfxStringItem( FN_PARAM_1
, OUString(cDelim
) ));
955 aReq
.AppendItem( SfxStringItem( FN_PARAM_2
, pTAFormat
->GetName()));
956 aReq
.AppendItem( SfxBoolItem ( FN_PARAM_3
, bool(aInsTableOpts
.mnInsMode
& SwInsertTableFlags::Headline
)));
957 aReq
.AppendItem( SfxInt16Item( FN_PARAM_4
, static_cast<short>(aInsTableOpts
.mnRowsToRepeat
) ));
958 aReq
.AppendItem( SfxBoolItem ( FN_PARAM_5
, bool(aInsTableOpts
.mnInsMode
& SwInsertTableFlags::DefaultBorder
) ));
959 aReq
.AppendItem( SfxBoolItem ( FN_PARAM_6
, !(aInsTableOpts
.mnInsMode
& SwInsertTableFlags::SplitLayout
)));
965 rSh
.TableToText( cDelim
);
968 bInserted
= rSh
.TextToTable( aInsTableOpts
, cDelim
, pTAFormat
);
973 rSaveView
.AutoCaption( TABLE_CAP
);
979 case SID_STYLE_WATERCAN
:
980 case SID_STYLE_UPDATE_BY_EXAMPLE
:
981 case SID_STYLE_NEW_BY_EXAMPLE
:
982 case SID_STYLE_APPLY
:
984 ShellMode eMode
= GetView().GetShellMode();
985 if ( ShellMode::Draw
!= eMode
&&
986 ShellMode::DrawForm
!= eMode
&&
987 ShellMode::DrawText
!= eMode
&&
988 ShellMode::Bezier
!= eMode
)
991 if ( SID_STYLE_WATERCAN
== nSlot
)
993 const bool bLockedView
= rSh
.IsViewLocked();
994 rSh
.LockView( true ); //lock visible section
996 GetView().GetDocShell()->ExecStyleSheet(rReq
);
998 rSh
.LockView( bLockedView
);
1001 // Will be recorded from the DocShell
1002 GetView().GetDocShell()->ExecStyleSheet(rReq
);
1006 case SID_CLASSIFICATION_APPLY
:
1008 GetView().GetDocShell()->Execute(rReq
);
1011 case SID_CLASSIFICATION_DIALOG
:
1013 GetView().GetDocShell()->Execute(rReq
);
1016 case SID_PARAGRAPH_SIGN_CLASSIFY_DLG
:
1018 GetView().GetDocShell()->Execute(rReq
);
1023 GetView().GetDocShell()->Execute(rReq
);
1027 GetView().ExecuteSlot(rReq
);
1031 sal_uInt16 nId
= SvxIMapDlgChildWindow::GetChildWindowId();
1033 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
1034 pVFrame
->ToggleChildWindow( nId
);
1035 pVFrame
->GetBindings().Invalidate( SID_IMAP
);
1037 if ( pVFrame
->HasChildWindow( nId
) && rSh
.IsFrameSelected() )
1038 lcl_UpdateIMapDlg( rSh
);
1043 SvxIMapDlg
* pDlg
= GetIMapDlg(GetView());
1045 // Check, if the allocation is useful or allowed at all.
1046 if ( rSh
.IsFrameSelected() &&
1047 pDlg
->GetEditingObject() == rSh
.GetIMapInventor() )
1049 SfxItemSet
aSet( rSh
.GetAttrPool(), svl::Items
<RES_URL
, RES_URL
>{} );
1050 rSh
.GetFlyFrameAttr( aSet
);
1051 SwFormatURL
aURL( aSet
.Get( RES_URL
) );
1052 aURL
.SetMap( &pDlg
->GetImageMap() );
1054 rSh
.SetFlyFrameAttr( aSet
);
1058 case SID_CONTOUR_DLG
:
1060 sal_uInt16 nId
= SvxContourDlgChildWindow::GetChildWindowId();
1062 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
1063 pVFrame
->ToggleChildWindow( nId
);
1064 pVFrame
->GetBindings().Invalidate( SID_CONTOUR_DLG
);
1066 SelectionType nSel
= rSh
.GetSelectionType();
1067 if ( pVFrame
->HasChildWindow( nId
) &&
1068 (nSel
& (SelectionType::Graphic
|SelectionType::Ole
)) )
1070 lcl_UpdateContourDlg( rSh
, nSel
);
1074 case SID_CONTOUR_EXEC
:
1076 SvxContourDlg
*pDlg
= GetContourDlg(GetView());
1077 // Check, if the allocation is useful or allowed at all.
1078 SelectionType nSel
= rSh
.GetSelectionType();
1079 if ( nSel
& (SelectionType::Graphic
|SelectionType::Ole
) )
1081 if (pDlg
&& pDlg
->GetEditingObject() == rSh
.GetIMapInventor())
1084 SfxItemSet
aSet( rSh
.GetAttrPool(), svl::Items
<RES_SURROUND
, RES_SURROUND
>{});
1085 rSh
.GetFlyFrameAttr( aSet
);
1086 SwFormatSurround
aSur( aSet
.Get( RES_SURROUND
) );
1087 if ( !aSur
.IsContour() )
1089 aSur
.SetContour( true );
1090 if ( aSur
.GetSurround() == css::text::WrapTextMode_NONE
)
1091 aSur
.SetSurround( css::text::WrapTextMode_PARALLEL
);
1093 rSh
.SetFlyFrameAttr( aSet
);
1095 const tools::PolyPolygon
aPoly( pDlg
->GetPolyPolygon() );
1096 rSh
.SetGraphicPolygon( &aPoly
);
1097 if ( pDlg
->IsGraphicChanged() )
1098 rSh
.ReRead( OUString(), OUString(), &pDlg
->GetGraphic());
1104 case FN_FRAME_TO_ANCHOR
:
1106 rSh
.GotoFlyAnchor();
1111 case FN_TOOL_ANCHOR_PAGE
:
1112 case FN_TOOL_ANCHOR_PARAGRAPH
:
1113 case FN_TOOL_ANCHOR_CHAR
:
1114 case FN_TOOL_ANCHOR_AT_CHAR
:
1115 case FN_TOOL_ANCHOR_FRAME
:
1117 RndStdIds eSet
= nSlot
== FN_TOOL_ANCHOR_PAGE
1118 ? RndStdIds::FLY_AT_PAGE
1119 : nSlot
== FN_TOOL_ANCHOR_PARAGRAPH
1120 ? RndStdIds::FLY_AT_PARA
1121 : nSlot
== FN_TOOL_ANCHOR_FRAME
1122 ? RndStdIds::FLY_AT_FLY
1123 : nSlot
== FN_TOOL_ANCHOR_CHAR
1124 ? RndStdIds::FLY_AS_CHAR
1125 : RndStdIds::FLY_AT_CHAR
;
1127 if (rSh
.IsObjSelected())
1128 rSh
.ChgAnchor(eSet
);
1129 else if (rSh
.IsFrameSelected())
1131 SwFormatAnchor
aAnc(eSet
, rSh
.GetPhyPageNum());
1132 SfxItemSet
aSet(SwFEShell::makeItemSetFromFormatAnchor(GetPool(), aAnc
));
1133 rSh
.SetFlyFrameAttr(aSet
);
1135 // if new anchor is 'as char' and it is a Math object and the usual
1136 // pre-conditions are met then align the formula to the baseline of the text
1137 const uno::Reference
< embed::XEmbeddedObject
> xObj( rSh
.GetOleRef() );
1138 const bool bDoMathBaselineAlignment
= xObj
.is() && SotExchange::IsMath( xObj
->getClassID() )
1139 && RndStdIds::FLY_AS_CHAR
== eSet
&& rSh
.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT
);
1140 if (bDoMathBaselineAlignment
)
1141 rSh
.AlignFormulaToBaseline( xObj
);
1143 sal_uInt16 nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
1146 SfxItemSet
aSet(GetPool(), svl::Items
<RES_SURROUND
, RES_HORI_ORIENT
>{});
1147 rSh
.GetFlyFrameAttr(aSet
);
1149 const SwFormatSurround
& rSurround
= aSet
.Get(RES_SURROUND
);
1150 const SwFormatVertOrient
& rVert
= aSet
.Get(RES_VERT_ORIENT
);
1151 const SwFormatHoriOrient
& rHori
= aSet
.Get(RES_HORI_ORIENT
);
1152 sal_Int16 eVOrient
= rVert
.GetVertOrient();
1153 sal_Int16 eHOrient
= rHori
.GetHoriOrient();
1154 css::text::WrapTextMode eSurround
= rSurround
.GetSurround();
1158 case RndStdIds::FLY_AT_FLY
:
1159 case RndStdIds::FLY_AT_PAGE
:
1160 //Wrap through, left or from left, top, from top
1161 if(eSurround
!= css::text::WrapTextMode_THROUGH
)
1162 aSet
.Put(SwFormatSurround(css::text::WrapTextMode_THROUGH
));
1164 if( eVOrient
!= text::VertOrientation::TOP
&& eVOrient
!= text::VertOrientation::NONE
)
1165 aSet
.Put(SwFormatVertOrient(0, text::VertOrientation::TOP
));
1167 if (eHOrient
!= text::HoriOrientation::NONE
&& eHOrient
!= text::HoriOrientation::LEFT
)
1168 aSet
.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT
));
1171 case RndStdIds::FLY_AT_PARA
:
1172 // left, from left, right, top, no wrap, wrap left and right
1173 if (eSurround
!= css::text::WrapTextMode_LEFT
&& eSurround
!= css::text::WrapTextMode_RIGHT
)
1174 aSet
.Put(SwFormatSurround(css::text::WrapTextMode_LEFT
));
1176 if( eVOrient
!= text::VertOrientation::TOP
)
1177 aSet
.Put(SwFormatVertOrient(0, text::VertOrientation::TOP
));
1179 if (eHOrient
!= text::HoriOrientation::NONE
&& eHOrient
!= text::HoriOrientation::LEFT
&& eHOrient
!= text::HoriOrientation::RIGHT
)
1180 aSet
.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT
));
1183 case RndStdIds::FLY_AT_CHAR
:
1184 // left, from left, right, top, wrap through
1185 if(eSurround
!= css::text::WrapTextMode_THROUGH
)
1186 aSet
.Put(SwFormatSurround(css::text::WrapTextMode_THROUGH
));
1188 if( eVOrient
!= text::VertOrientation::TOP
)
1189 aSet
.Put(SwFormatVertOrient(0, text::VertOrientation::TOP
));
1191 if (eHOrient
!= text::HoriOrientation::NONE
&& eHOrient
!= text::HoriOrientation::LEFT
&& eHOrient
!= text::HoriOrientation::RIGHT
)
1192 aSet
.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT
));
1200 rSh
.SetFlyFrameAttr( aSet
);
1204 GetView().GetViewFrame()->GetBindings().Invalidate( SID_ANCHOR_MENU
);
1208 case FN_FRAME_NOWRAP
:
1210 case FN_FRAME_WRAP_IDEAL
:
1211 case FN_FRAME_WRAPTHRU
:
1212 case FN_FRAME_WRAPTHRU_TRANSP
:
1213 case FN_FRAME_WRAPTHRU_TOGGLE
:
1214 case FN_FRAME_WRAP_CONTOUR
:
1215 case FN_WRAP_ANCHOR_ONLY
:
1216 case FN_FRAME_WRAP_LEFT
:
1217 case FN_FRAME_WRAP_RIGHT
:
1218 SetWrapMode( nSlot
);
1221 case FN_UPDATE_ALL_LINKS
:
1223 if( !rSh
.GetLinkManager().GetLinks().empty() )
1226 rSh
.StartAllAction();
1227 rSh
.GetLinkManager().UpdateAllLinks( false, false, nullptr );
1233 case FN_XFORMS_DESIGN_MODE
:
1234 if (pArgs
&& pArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
1236 if (const SfxBoolItem
* pBoolItem
= dynamic_cast<const SfxBoolItem
*>(pItem
))
1238 bool bDesignMode
= pBoolItem
->GetValue();
1240 // set from design mode
1241 OSL_ENSURE( GetView().GetFormShell() != nullptr, "form shell?" );
1242 SfxRequest
aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE
);
1243 aReq
.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE
, bDesignMode
) );
1244 GetView().GetFormShell()->Execute( aReq
);
1247 // also set suitable view options
1248 SwViewOption aViewOption
= *rSh
.GetViewOptions();
1249 aViewOption
.SetFormView( ! bDesignMode
);
1250 rSh
.ApplyViewOptions( aViewOption
);
1260 if(!bMore
|| !pArgs
)
1264 pArgs
->GetItemState(GetPool().GetWhich(nSlot
), false, &pItem
);
1270 case SID_ATTR_BRUSH
:
1271 case SID_ATTR_BORDER_SHADOW
:
1274 rSh
.StartAllAction();
1275 // Tabele cell(s) selected?
1276 if ( rSh
.IsTableMode() )
1278 SwFrameFormat
*pFormat
= rSh
.GetTableFormat();
1279 pFormat
->SetFormatAttr( *pItem
);
1281 else if ( rSh
.IsFrameSelected() )
1283 // Set border attributes via Frame-Manager.
1284 SwFlyFrameAttrMgr
aMgr( false, &rSh
, Frmmgr_Type::NONE
, nullptr );
1285 aMgr
.SetAttrSet( *pArgs
);
1286 aMgr
.UpdateFlyFrame();
1290 rSh
.SetAttrSet( *pArgs
);
1295 case FN_PAGE_STYLE_SET_LR_MARGIN
:
1296 case FN_PAGE_STYLE_SET_UL_MARGIN
:
1297 case FN_PAGE_STYLE_SET_NUMBER_FORMAT
:
1298 case FN_PAGE_STYLE_SET_PAPER_SIZE
:
1299 case FN_PAGE_STYLE_SET_PAPER_BIN
:
1301 OSL_FAIL("not implemented");
1305 case SID_ATTR_BORDER_OUTER
:
1307 // Tabele cell(s) selected?
1308 if ( rSh
.IsTableMode() )
1310 // Set border attributes Get/SetTabBorders()
1311 rSh
.SetTabBorders(*pArgs
);
1313 else if ( rSh
.IsFrameSelected() )
1315 // Set border attributes via Frame-Manager.
1316 SwFlyFrameAttrMgr
aMgr( false, &rSh
, Frmmgr_Type::NONE
, nullptr );
1317 aMgr
.SetAttrSet(*pArgs
);
1318 aMgr
.UpdateFlyFrame();
1322 // Set border attributes via shell quite normally.
1323 rSh
.SetAttrItem( *pItem
);
1328 OSL_FAIL("wrong Dispatcher");
1332 // Here the state for SID_IMAP / SID_CONTOUR will be handled
1333 // until the swapping of the graphic is finished.
1335 IMPL_LINK_NOARG(SwBaseShell
, GraphicArrivedHdl
, SwCursorShell
&, void)
1337 SwWrtShell
&rSh
= GetShell();
1338 if (CNT_GRF
!= rSh
.SwEditShell::GetCntType())
1340 GraphicType
const nGrfType(rSh
.GetGraphicType());
1341 if (GraphicType::NONE
== nGrfType
|| aGrfUpdateSlots
.empty())
1344 bool bProtect
= FlyProtectFlags::NONE
!= rSh
.IsSelObjProtected(FlyProtectFlags::Content
|FlyProtectFlags::Parent
);
1345 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
1346 for( const auto nSlot
: aGrfUpdateSlots
)
1348 bool bSetState
= false;
1349 bool bState
= false;
1355 sal_uInt16 nId
= SvxIMapDlgChildWindow::GetChildWindowId();
1356 SfxChildWindow
*pChildWindow
= pVFrame
->HasChildWindow(nId
) ?
1357 pVFrame
->GetChildWindow(nId
) : nullptr;
1358 SvxIMapDlg
*pDlg
= pChildWindow
?
1359 static_cast<SvxIMapDlg
*>(pChildWindow
->GetController().get()) : nullptr;
1361 if( pDlg
&& ( SID_IMAP_EXEC
== nSlot
||
1362 ( SID_IMAP
== nSlot
&& !bProtect
)) &&
1363 pDlg
->GetEditingObject() != rSh
.GetIMapInventor())
1364 lcl_UpdateIMapDlg( rSh
);
1366 if( !bProtect
&& SID_IMAP
== nSlot
)
1369 bState
= nullptr != pDlg
;
1374 case SID_CONTOUR_DLG
:
1377 sal_uInt16 nId
= SvxContourDlgChildWindow::GetChildWindowId();
1378 SfxChildWindow
*pChildWindow
= pVFrame
->HasChildWindow(nId
) ?
1379 pVFrame
->GetChildWindow(nId
) : nullptr;
1380 SvxIMapDlg
*pDlg
= pChildWindow
?
1381 static_cast<SvxIMapDlg
*>(pChildWindow
->GetController().get()) : nullptr;
1382 if( pDlg
&& pDlg
->GetEditingObject() !=
1383 rSh
.GetIMapInventor() )
1384 lcl_UpdateContourDlg( rSh
, SelectionType::Graphic
);
1387 bState
= nullptr != pDlg
;
1391 case FN_FRAME_WRAP_CONTOUR
:
1394 SfxItemSet
aSet(GetPool(), svl::Items
<RES_SURROUND
, RES_SURROUND
>{});
1395 rSh
.GetFlyFrameAttr(aSet
);
1396 const SwFormatSurround
& rWrap
= aSet
.Get(RES_SURROUND
);
1398 bState
= rWrap
.IsContour();
1403 case SID_GRFFILTER_INVERT
:
1404 case SID_GRFFILTER_SMOOTH
:
1405 case SID_GRFFILTER_SHARPEN
:
1406 case SID_GRFFILTER_REMOVENOISE
:
1407 case SID_GRFFILTER_SOBEL
:
1408 case SID_GRFFILTER_MOSAIC
:
1409 case SID_GRFFILTER_EMBOSS
:
1410 case SID_GRFFILTER_POSTER
:
1411 case SID_GRFFILTER_POPART
:
1412 case SID_GRFFILTER_SEPIA
:
1413 case SID_GRFFILTER_SOLARIZE
:
1414 bSetState
= bState
= GraphicType::Bitmap
== nGrfType
;
1420 SfxBoolItem
aBool( nSlot
, bState
);
1422 pGetStateSet
->Put( aBool
);
1424 pVFrame
->GetBindings().SetState( aBool
);
1427 aGrfUpdateSlots
.clear();
1430 void SwBaseShell::GetState( SfxItemSet
&rSet
)
1432 SwWrtShell
&rSh
= GetShell();
1433 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
1434 SfxWhichIter
aIter( rSet
);
1435 sal_uInt16 nWhich
= aIter
.FirstWhich();
1436 pGetStateSet
= &rSet
;
1441 case SID_GALLERY_FORMATS
:
1442 if ( rSh
.IsObjSelected() ||
1443 (rSh
.IsSelFrameMode() &&
1444 !(rSh
.GetSelectionType() & SelectionType::Graphic
)) )
1445 rSet
.DisableItem( nWhich
);
1447 case SID_GALLERY_ENABLE_ADDCOPY
:
1448 // #108230# allow copy from gallery in Writer AND Writer/Web!
1449 rSet
.Put( SfxBoolItem( SID_GALLERY_ENABLE_ADDCOPY
, true ) );
1451 case FN_EDIT_REGION
:
1452 if( !rSh
.IsAnySectionInDoc() )
1453 rSet
.DisableItem(nWhich
);
1456 case FN_EDIT_CURRENT_REGION
:
1457 //tdf#112808 if cursor is in an index, don't show the edit section.
1458 if( !rSh
.GetCurrSection() ||
1459 (rSh
.GetCurrSection()->GetType() != SectionType::Content
&&
1460 rSh
.GetCurrSection()->GetType() != SectionType::FileLink
))
1462 rSet
.DisableItem(nWhich
);
1466 case FN_INSERT_REGION
:
1467 if( rSh
.CursorInsideInputField()
1468 || rSh
.IsSelFrameMode()
1469 || !rSh
.IsInsRegionAvailable() )
1471 rSet
.DisableItem( nWhich
);
1475 case FN_CONVERT_TABLE_TO_TEXT
:
1477 FrameTypeFlags eFrameType
= rSh
.GetFrameType(nullptr,true);
1478 if( (eFrameType
& FrameTypeFlags::FOOTNOTE
) ||
1479 !rSh
.GetTableFormat() )
1480 rSet
.DisableItem( nWhich
);
1483 case FN_CONVERT_TEXT_TO_TABLE
:
1485 FrameTypeFlags eFrameType
= rSh
.GetFrameType(nullptr,true);
1486 if( (eFrameType
& FrameTypeFlags::FOOTNOTE
) ||
1487 !rSh
.IsTextToTableAvailable() )
1488 rSet
.DisableItem( nWhich
);
1491 case FN_CONVERT_TEXT_TABLE
:
1493 FrameTypeFlags eFrameType
= rSh
.GetFrameType(nullptr,true);
1494 if( (eFrameType
& FrameTypeFlags::FOOTNOTE
) ||
1495 (!rSh
.GetTableFormat() && !rSh
.IsTextToTableAvailable() ) )
1496 rSet
.DisableItem( nWhich
);
1501 SfxItemSet
aSet( rSh
.GetAttrPool(),
1502 svl::Items
<RES_SHADOW
, RES_SHADOW
>{} );
1504 // Table cell(s) selected?
1505 if ( rSh
.IsTableMode() )
1507 SwFrameFormat
*pFormat
= rSh
.GetTableFormat();
1508 aSet
.Put(pFormat
->GetFormatAttr( nWhich
));
1510 else if( rSh
.IsFrameSelected() )
1512 SwFlyFrameAttrMgr
aMgr( false, &rSh
, Frmmgr_Type::NONE
, nullptr );
1513 aSet
.Put( aMgr
.GetAttrSet() );
1516 rSh
.GetCurAttr( aSet
);
1518 const SvxShadowItem
& rShItem
= static_cast<const SvxShadowItem
&>(aSet
.Get(nWhich
));
1525 // Improve efficiency:
1526 // If selected object is protected, item has to disabled.
1527 const bool bProtect
= FlyProtectFlags::NONE
!= rSh
.IsSelObjProtected(FlyProtectFlags::Content
|FlyProtectFlags::Parent
);
1530 rSet
.DisableItem( nWhich
);
1534 const sal_uInt16 nId
= SvxIMapDlgChildWindow::GetChildWindowId();
1535 const bool bHas
= pVFrame
->HasChildWindow( nId
);
1536 const bool bFrameSel
= rSh
.IsFrameSelected();
1537 const bool bIsGraphicSelection
=
1538 rSh
.GetSelectionType() == SelectionType::Graphic
;
1541 // Avoid unnecessary loading of selected graphic.
1542 // The graphic is only needed, if the dialog is open.
1543 // If the swapping of the graphic is finished, the status
1544 // must be determined asynchronously, until this the slot
1545 // will be disabled.
1546 if ( bHas
&& bIsGraphicSelection
&& rSh
.IsLinkedGrfSwapOut() )
1548 if( AddGrfUpdateSlot( nWhich
))
1549 rSh
.GetGraphic(false); // start the loading
1555 ( bIsGraphicSelection
&&
1556 rSh
.GetGraphicType() == GraphicType::NONE
) ) )
1558 rSet
.DisableItem( nWhich
);
1562 SfxBoolItem
aBool(nWhich
, bHas
);
1563 if ( bHas
&& bFrameSel
)
1564 lcl_UpdateIMapDlg( rSh
);
1573 bool bDisable
= false;
1574 if( !rSh
.IsFrameSelected())
1576 sal_uInt16 nId
= SvxIMapDlgChildWindow::GetChildWindowId();
1577 if(!bDisable
&& pVFrame
->HasChildWindow( nId
))
1579 if(rSh
.GetSelectionType() == SelectionType::Graphic
1580 && rSh
.IsLinkedGrfSwapOut())
1582 if( AddGrfUpdateSlot( nWhich
))
1583 rSh
.GetGraphic(false); // start the loading
1587 SvxIMapDlg
*pDlg
= GetIMapDlg(GetView());
1588 if (pDlg
&& pDlg
->GetEditingObject() != rSh
.GetIMapInventor())
1589 lcl_UpdateIMapDlg( rSh
);
1592 rSet
.Put(SfxBoolItem(nWhich
, bDisable
));
1598 if ( ( rSh
.HasReadonlySel() && !rSh
.CursorInsideInputField() )
1599 || rSh
.IsSelObjProtected( FlyProtectFlags::Content
|FlyProtectFlags::Parent
) != FlyProtectFlags::NONE
)
1601 rSet
.DisableItem( nWhich
);
1605 case SID_CONTOUR_DLG
:
1607 bool bParentCntProt
= FlyProtectFlags::NONE
!= rSh
.IsSelObjProtected(FlyProtectFlags::Content
|FlyProtectFlags::Parent
);
1609 if( bParentCntProt
|| 0 != (HTMLMODE_ON
& ::GetHtmlMode(
1610 GetView().GetDocShell() )) )
1611 rSet
.DisableItem( nWhich
);
1614 sal_uInt16 nId
= SvxContourDlgChildWindow::GetChildWindowId();
1615 bool bHas
= GetView().GetViewFrame()->HasChildWindow( nId
);
1616 SelectionType nSel
= rSh
.GetSelectionType();
1617 bool bOk(nSel
& (SelectionType::Graphic
|SelectionType::Ole
));
1619 bool bDisable
= false;
1623 // Avoid unnecessary loading of selected graphic.
1624 // The graphic is only needed, if the dialog is open.
1625 // If the swapping of the graphic is finished, the status
1626 // must be determined asynchronously, until this the slot
1627 // will be disabled.
1628 else if ( bHas
&& (nSel
& SelectionType::Graphic
) &&
1629 rSh
.IsLinkedGrfSwapOut() )
1631 if( AddGrfUpdateSlot( nWhich
))
1632 rSh
.GetGraphic(false); // start the loading
1636 else if( bHas
&& bOk
)
1637 bDisable
= !lcl_UpdateContourDlg( rSh
, nSel
);
1641 // apply fix #i59688# only for selected graphics
1642 if ( nSel
& SelectionType::Graphic
)
1643 bDisable
= GraphicType::NONE
== rSh
.GetGraphicType();
1645 bDisable
= GraphicType::NONE
== rSh
.GetIMapGraphic().GetType();
1649 rSet
.DisableItem( nWhich
);
1651 rSet
.Put( SfxBoolItem(nWhich
, bHas
) );
1655 case SID_CONTOUR_EXEC
:
1657 bool bDisable
= false;
1658 SelectionType nSel
= rSh
.GetSelectionType();
1659 if( !(nSel
& (SelectionType::Graphic
|SelectionType::Ole
)) )
1661 sal_uInt16 nId
= SvxContourDlgChildWindow::GetChildWindowId();
1662 if( !bDisable
&& GetView().GetViewFrame()->HasChildWindow( nId
))
1664 SvxContourDlg
*pDlg
= GetContourDlg(GetView());
1665 if (pDlg
&& pDlg
->GetEditingObject() != rSh
.GetIMapInventor())
1668 rSet
.Put(SfxBoolItem(nWhich
, bDisable
));
1672 case SID_ANCHOR_MENU
:
1673 case FN_TOOL_ANCHOR_PAGE
:
1674 case FN_TOOL_ANCHOR_PARAGRAPH
:
1675 case FN_TOOL_ANCHOR_CHAR
:
1676 case FN_TOOL_ANCHOR_AT_CHAR
:
1677 case FN_TOOL_ANCHOR_FRAME
:
1679 bool bObj
= 0 != rSh
.IsObjSelected();
1680 bool bParentCntProt
= rSh
.IsSelObjProtected( FlyProtectFlags::Content
|FlyProtectFlags::Parent
) != FlyProtectFlags::NONE
;
1682 if( !bParentCntProt
&& (bObj
|| rSh
.IsFrameSelected()))
1684 SfxItemSet
aSet(GetPool(), svl::Items
<RES_ANCHOR
, RES_ANCHOR
>{});
1686 rSh
.GetObjAttr(aSet
);
1688 rSh
.GetFlyFrameAttr(aSet
);
1689 RndStdIds eSet
= aSet
.Get(RES_ANCHOR
).GetAnchorId();
1691 ((nWhich
== FN_TOOL_ANCHOR_PAGE
) &&
1692 (eSet
== RndStdIds::FLY_AT_PAGE
))
1693 || ((nWhich
== FN_TOOL_ANCHOR_PARAGRAPH
) &&
1694 (eSet
== RndStdIds::FLY_AT_PARA
))
1695 || ((nWhich
== FN_TOOL_ANCHOR_FRAME
) &&
1696 (eSet
== RndStdIds::FLY_AT_FLY
))
1697 || ((nWhich
== FN_TOOL_ANCHOR_AT_CHAR
) &&
1698 (eSet
== RndStdIds::FLY_AT_CHAR
))
1699 || ((nWhich
== FN_TOOL_ANCHOR_CHAR
) &&
1700 (eSet
== RndStdIds::FLY_AS_CHAR
));
1702 if( nWhich
== FN_TOOL_ANCHOR_FRAME
&& !rSh
.IsFlyInFly() )
1703 rSet
.DisableItem(nWhich
);
1704 else if(nWhich
!= SID_ANCHOR_MENU
)
1705 rSet
.Put(SfxBoolItem(nWhich
, bSet
));
1707 if (comphelper::LibreOfficeKit::isActive())
1709 if (nWhich
== FN_TOOL_ANCHOR_PAGE
|| nWhich
== FN_TOOL_ANCHOR_PARAGRAPH
1710 || nWhich
== FN_TOOL_ANCHOR_FRAME
)
1712 rSet
.DisableItem(nWhich
);
1717 rSet
.DisableItem( nWhich
);
1720 case FN_FRAME_NOWRAP
:
1722 case FN_FRAME_WRAP_IDEAL
:
1723 case FN_FRAME_WRAPTHRU
:
1724 case FN_FRAME_WRAPTHRU_TRANSP
:
1725 case FN_FRAME_WRAPTHRU_TOGGLE
:
1726 case FN_FRAME_WRAP_CONTOUR
:
1727 case FN_WRAP_ANCHOR_ONLY
:
1728 case FN_FRAME_WRAP_LEFT
:
1729 case FN_FRAME_WRAP_RIGHT
:
1731 bool bObj
= 0 != rSh
.IsObjSelected();
1732 bool bParentCntProt
= rSh
.IsSelObjProtected( FlyProtectFlags::Content
|FlyProtectFlags::Parent
) != FlyProtectFlags::NONE
;
1734 if( !bParentCntProt
&& (bObj
|| rSh
.IsFrameSelected()))
1736 SfxItemSet
aSet(GetPool(), svl::Items
<RES_OPAQUE
, RES_ANCHOR
>{});
1737 RndStdIds nAnchorType
;
1740 rSh
.GetObjAttr(aSet
);
1741 nAnchorType
= rSh
.GetAnchorId();
1745 rSh
.GetFlyFrameAttr(aSet
);
1746 nAnchorType
= aSet
.Get(RES_ANCHOR
).GetAnchorId();
1748 const SwFormatSurround
& rWrap
= aSet
.Get(RES_SURROUND
);
1750 const SvxOpaqueItem
& rOpaque
= aSet
.Get(RES_OPAQUE
);
1751 bool bOpaque
= rOpaque
.GetValue();
1752 css::text::WrapTextMode nSurround
= rWrap
.GetSurround();
1756 (nAnchorType
== RndStdIds::UNKNOWN
) || (nAnchorType
== RndStdIds::FLY_AS_CHAR
);
1757 const bool bHtmlMode
=
1758 0 != ::GetHtmlMode(GetView().GetDocShell());
1762 case FN_FRAME_NOWRAP
:
1764 ( (nAnchorType
!= RndStdIds::FLY_AT_PARA
)
1765 && (nAnchorType
!= RndStdIds::FLY_AT_CHAR
)
1766 && (nAnchorType
!= RndStdIds::FLY_AT_PAGE
));
1767 bSet
= nSurround
== css::text::WrapTextMode_NONE
;
1770 bDisable
|= bHtmlMode
;
1771 bSet
= nSurround
== css::text::WrapTextMode_PARALLEL
;
1773 case FN_FRAME_WRAP_IDEAL
:
1774 bDisable
|= bHtmlMode
;
1775 bSet
= nSurround
== css::text::WrapTextMode_DYNAMIC
;
1777 case FN_FRAME_WRAPTHRU
:
1778 bDisable
|= (bHtmlMode
||
1779 ( (nAnchorType
!= RndStdIds::FLY_AT_PARA
)
1780 && (nAnchorType
!= RndStdIds::FLY_AT_CHAR
)
1781 && (nAnchorType
!= RndStdIds::FLY_AT_PAGE
)));
1783 bSet
= nSurround
== css::text::WrapTextMode_THROUGH
&& rSh
.GetLayerId();
1785 bSet
= nSurround
== css::text::WrapTextMode_THROUGH
&& bOpaque
;
1787 case FN_FRAME_WRAPTHRU_TRANSP
:
1788 case FN_FRAME_WRAPTHRU_TOGGLE
:
1789 bDisable
|= bHtmlMode
;
1791 bSet
= nSurround
== css::text::WrapTextMode_THROUGH
&& !rSh
.GetLayerId();
1793 bSet
= nSurround
== css::text::WrapTextMode_THROUGH
&& !bOpaque
;
1795 case FN_FRAME_WRAP_CONTOUR
:
1796 bDisable
|= bHtmlMode
;
1797 //no contour available whenn no wrap or wrap through is set
1798 bDisable
|= (nSurround
== css::text::WrapTextMode_NONE
|| nSurround
== css::text::WrapTextMode_THROUGH
);
1801 SelectionType nSel
= rSh
.GetSelectionType();
1802 if( (nSel
& SelectionType::Graphic
) &&
1803 rSh
.IsLinkedGrfSwapOut())
1805 if( AddGrfUpdateSlot( nWhich
))
1806 rSh
.GetGraphic(false); // start the loading
1808 else if( rSh
.IsFrameSelected() )
1810 // #i102253# applied patch from OD (see task)
1812 nSel
& SelectionType::Frame
||
1813 GraphicType::NONE
== rSh
.GetIMapGraphic().GetType();
1816 bSet
= !bDisable
&& rWrap
.IsContour();
1819 case FN_WRAP_ANCHOR_ONLY
:
1820 bDisable
|= (bHtmlMode
||
1821 (nAnchorType
!= RndStdIds::FLY_AT_PARA
));
1822 bSet
= rWrap
.IsAnchorOnly();
1824 case FN_FRAME_WRAP_LEFT
:
1825 bSet
= nSurround
== css::text::WrapTextMode_LEFT
;
1827 case FN_FRAME_WRAP_RIGHT
:
1828 bSet
= nSurround
== css::text::WrapTextMode_RIGHT
;
1833 rSet
.DisableItem(nWhich
);
1835 rSet
.Put(SfxBoolItem(nWhich
, bSet
));
1838 rSet
.DisableItem(nWhich
);
1841 case FN_UPDATE_CHARTS
:
1842 if( !rSh
.HasCharts() )
1843 rSet
.DisableItem( nWhich
);
1845 case FN_UPDATE_ALL_LINKS
:
1846 if ( rSh
.GetLinkManager().GetLinks().empty() )
1847 rSet
.DisableItem(nWhich
);
1849 case FN_XFORMS_DESIGN_MODE
:
1850 // enable if in XForms document
1851 if( rSh
.GetDoc()->isXForms() )
1853 // determine current state from view options
1854 bool bValue
= ! rSh
.GetViewOptions()->IsFormView();
1855 rSet
.Put( SfxBoolItem( nWhich
, bValue
) );
1858 rSet
.Put( SfxVisibilityItem( nWhich
, false ) );
1861 nWhich
= aIter
.NextWhich();
1863 pGetStateSet
= nullptr;
1866 // Disable the slots with this status method
1868 void SwBaseShell::StateDisableItems( SfxItemSet
&rSet
)
1870 SfxWhichIter
aIter(rSet
);
1871 sal_uInt16 nWhich
= aIter
.FirstWhich();
1875 rSet
.DisableItem( nWhich
);
1876 nWhich
= aIter
.NextWhich();
1880 // Disable the slots with this status method
1882 void SwBaseShell::StateStyle( SfxItemSet
&rSet
)
1884 bool bParentCntProt
= GetShell().IsSelObjProtected( FlyProtectFlags::Content
|FlyProtectFlags::Parent
) != FlyProtectFlags::NONE
;
1885 ShellMode eMode
= GetView().GetShellMode();
1887 if ( bParentCntProt
||
1888 ShellMode::Draw
== eMode
||
1889 ShellMode::DrawForm
== eMode
||
1890 ShellMode::DrawText
== eMode
||
1891 ShellMode::Bezier
== eMode
)
1893 SfxWhichIter
aIter( rSet
);
1894 sal_uInt16 nWhich
= aIter
.FirstWhich();
1897 rSet
.DisableItem( nWhich
);
1898 nWhich
= aIter
.NextWhich();
1902 GetView().GetDocShell()->StateStyleSheet(rSet
, &GetShell());
1905 void SwBaseShell::SetWrapMode( sal_uInt16 nSlot
)
1907 SwWrtShell
&rSh
= GetShell();
1908 bool bObj
= 0 != rSh
.IsObjSelected();
1909 if( !bObj
&& !rSh
.IsFrameSelected())
1912 SfxItemSet
aSet(GetPool(), svl::Items
<RES_OPAQUE
, RES_SURROUND
>{});
1914 rSh
.GetObjAttr(aSet
);
1916 rSh
.GetFlyFrameAttr(aSet
);
1917 SwFormatSurround
aWrap( aSet
.Get(RES_SURROUND
) );
1918 css::text::WrapTextMode
nOldSurround(aWrap
.GetSurround());
1919 css::text::WrapTextMode nSurround
= css::text::WrapTextMode_PARALLEL
;
1923 case FN_FRAME_NOWRAP
:
1924 nSurround
= css::text::WrapTextMode_NONE
;
1925 if (aWrap
.IsContour())
1926 aWrap
.SetContour(false);
1928 case FN_FRAME_WRAP_IDEAL
:
1929 nSurround
= css::text::WrapTextMode_DYNAMIC
;
1931 case FN_WRAP_ANCHOR_ONLY
:
1932 aWrap
.SetAnchorOnly(!aWrap
.IsAnchorOnly());
1934 // keep previous wrapping
1936 // switch to wrap css::text::WrapTextMode_PARALLEL, if previous wrap is css::text::WrapTextMode_NONE
1937 if ( nOldSurround
!= css::text::WrapTextMode_NONE
)
1939 nSurround
= nOldSurround
;
1942 case FN_FRAME_WRAP_CONTOUR
:
1943 aWrap
.SetContour(!aWrap
.IsContour());
1944 // Contour is meaningless in no-wrap or wrap-through context. Otherwise keep existing wrap.
1945 if ( !aWrap
.IsContour() ||
1946 ( nOldSurround
!= css::text::WrapTextMode_NONE
&&
1947 nOldSurround
!= css::text::WrapTextMode_THROUGH
) )
1949 nSurround
= nOldSurround
;
1952 case FN_FRAME_WRAPTHRU_TRANSP
:
1953 case FN_FRAME_WRAPTHRU_TOGGLE
:
1954 if (aWrap
.IsContour())
1955 aWrap
.SetContour(false);
1957 case FN_FRAME_WRAPTHRU
:
1958 nSurround
= css::text::WrapTextMode_THROUGH
;
1961 case FN_FRAME_WRAP_LEFT
:
1962 nSurround
= css::text::WrapTextMode_LEFT
;
1965 case FN_FRAME_WRAP_RIGHT
:
1966 nSurround
= css::text::WrapTextMode_RIGHT
;
1972 aWrap
.SetSurround(nSurround
);
1974 if (nSlot
!= FN_FRAME_WRAP_CONTOUR
)
1976 // Defaulting the contour wrap on draw objects.
1977 if (bObj
&& nOldSurround
!= nSurround
&&
1978 (nOldSurround
== css::text::WrapTextMode_NONE
|| nOldSurround
== css::text::WrapTextMode_THROUGH
))
1980 aWrap
.SetContour(true);
1986 bool bOpaque
= nSlot
!= FN_FRAME_WRAPTHRU_TRANSP
&& nSlot
!= FN_FRAME_WRAPTHRU_TOGGLE
;
1987 if( nSlot
== FN_FRAME_WRAPTHRU_TOGGLE
)
1990 bOpaque
= !rSh
.GetLayerId();
1993 const SvxOpaqueItem
& aOpaque( aSet
.Get(RES_OPAQUE
) );
1994 bOpaque
= !aOpaque
.GetValue();
1997 aSet
.Put(SvxOpaqueItem(RES_OPAQUE
, bOpaque
));
2001 rSh
.SetObjAttr(aSet
);
2003 rSh
.SelectionToHeaven();
2005 rSh
.SelectionToHell();
2008 rSh
.SetFlyFrameAttr(aSet
);
2012 //Force update of the status line
2014 void SwBaseShell::SetFrameMode(FlyMode eMode
, SwWrtShell
*pSh
)
2017 SfxBindings
&rBnd
= pSh
->GetView().GetViewFrame()->GetBindings();
2019 if( eMode
== FLY_DRAG
|| pSh
->IsFrameSelected() || pSh
->IsObjSelected() )
2021 const SfxPointItem
aTmp1( SID_ATTR_POSITION
, pSh
->GetAnchorObjDiff());
2022 const SvxSizeItem
aTmp2( SID_ATTR_SIZE
, pSh
->GetObjSize());
2023 rBnd
.SetState( aTmp1
);
2024 rBnd
.SetState( aTmp2
);
2026 else if( eMode
== FLY_DRAG_END
)
2028 static sal_uInt16 aInval
[] =
2030 SID_ATTR_POSITION
, SID_ATTR_SIZE
, 0
2032 rBnd
.Invalidate(aInval
);
2036 SwBaseShell::SwBaseShell(SwView
& rVw
) :
2039 pGetStateSet(nullptr)
2041 SwWrtShell
& rWrtSh
= rView
.GetWrtShell();
2043 SetPool(&rWrtSh
.GetAttrPool());
2045 rWrtSh
.SetGrfArrivedLnk( LINK( this, SwBaseShell
, GraphicArrivedHdl
));
2048 SwBaseShell::~SwBaseShell()
2050 if( rView
.GetCurShell() == this )
2051 rView
.ResetSubShell();
2053 Link
<SwCursorShell
&,void> aTmp( LINK( this, SwBaseShell
, GraphicArrivedHdl
));
2054 if( aTmp
== rView
.GetWrtShell().GetGrfArrivedLnk() )
2055 rView
.GetWrtShell().SetGrfArrivedLnk( Link
<SwCursorShell
&,void>() );
2058 void SwBaseShell::ExecTextCtrl( SfxRequest
& rReq
)
2060 const SfxItemSet
*pArgs
= rReq
.GetArgs();
2064 SwWrtShell
&rSh
= GetShell();
2065 std::unique_ptr
<SvxScriptSetItem
> pSSetItem
;
2066 sal_uInt16 nSlot
= rReq
.GetSlot();
2067 SfxItemPool
& rPool
= rSh
.GetAttrPool();
2068 sal_uInt16 nWhich
= rPool
.GetWhich( nSlot
);
2069 SvtScriptType nScripts
= SvtScriptType::LATIN
| SvtScriptType::ASIAN
| SvtScriptType::COMPLEX
;
2070 SfxItemSet
aHeightSet( GetPool(), svl::Items
<RES_CHRATR_FONTSIZE
, RES_CHRATR_FONTSIZE
,
2071 RES_CHRATR_CJK_FONTSIZE
, RES_CHRATR_CJK_FONTSIZE
,
2072 RES_CHRATR_CTL_FONTSIZE
, RES_CHRATR_CTL_FONTSIZE
>{});
2076 case SID_ATTR_CHAR_FONT
:
2078 nScripts
= rSh
.GetScriptType();
2079 // #i42732# input language should be preferred over
2080 // current cursor position to detect script type
2081 if(!rSh
.HasSelection())
2083 LanguageType nInputLang
= GetView().GetEditWin().GetInputLanguage();
2084 if(nInputLang
!= LANGUAGE_DONTKNOW
&& nInputLang
!= LANGUAGE_SYSTEM
)
2085 nScripts
= SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang
);
2089 case SID_ATTR_CHAR_POSTURE
:
2090 case SID_ATTR_CHAR_WEIGHT
:
2092 pSSetItem
.reset(new SvxScriptSetItem( nSlot
, rPool
));
2093 pSSetItem
->PutItemForScriptType( nScripts
, pArgs
->Get( nWhich
));
2094 pArgs
= &pSSetItem
->GetItemSet();
2097 case SID_ATTR_CHAR_FONTHEIGHT
:
2099 if(rSh
.HasSelection())
2101 pSSetItem
.reset(new SvxScriptSetItem( nSlot
, rPool
));
2102 pSSetItem
->PutItemForScriptType( nScripts
, pArgs
->Get( nWhich
));
2103 pArgs
= &pSSetItem
->GetItemSet();
2107 nScripts
= rSh
.GetScriptType();
2108 LanguageType nInputLang
= GetView().GetEditWin().GetInputLanguage();
2109 if(nInputLang
!= LANGUAGE_DONTKNOW
&& nInputLang
!= LANGUAGE_SYSTEM
)
2110 nScripts
= SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang
);
2111 sal_uInt32 nHeight
= static_cast< const SvxFontHeightItem
& >(pArgs
->Get( nWhich
)).GetHeight();
2112 SwStdFontConfig
* pStdFont
= SW_MOD()->GetStdFontConfig();
2114 SfxItemSet
aLangSet( GetPool(), svl::Items
<RES_CHRATR_LANGUAGE
, RES_CHRATR_LANGUAGE
,
2115 RES_CHRATR_CJK_LANGUAGE
, RES_CHRATR_CJK_LANGUAGE
,
2116 RES_CHRATR_CTL_LANGUAGE
, RES_CHRATR_CTL_LANGUAGE
>{});
2117 rSh
.GetCurAttr( aLangSet
);
2119 sal_Int32 nWesternSize
=
2120 pStdFont
->GetFontHeight(FONT_STANDARD
, FONT_GROUP_DEFAULT
,
2121 aLangSet
.Get( RES_CHRATR_LANGUAGE
).GetLanguage());
2122 sal_Int32 nCJKSize
=
2123 pStdFont
->GetFontHeight(FONT_STANDARD
, FONT_GROUP_CJK
,
2124 aLangSet
.Get( RES_CHRATR_CJK_LANGUAGE
).GetLanguage());
2125 sal_Int32 nCTLSize
=
2126 pStdFont
->GetFontHeight(FONT_STANDARD
, FONT_GROUP_CTL
,
2127 aLangSet
.Get( RES_CHRATR_CTL_LANGUAGE
).GetLanguage());
2131 case SvtScriptType::LATIN
:
2132 nCJKSize
= nHeight
* nCJKSize
/ nWesternSize
;
2133 nCTLSize
= nHeight
* nCTLSize
/ nWesternSize
;
2134 nWesternSize
= static_cast<sal_Int32
>(nHeight
);
2136 case SvtScriptType::ASIAN
:
2137 nCTLSize
= nHeight
* nCTLSize
/ nCJKSize
;
2138 nWesternSize
= nHeight
* nWesternSize
/ nCJKSize
;
2139 nCJKSize
= static_cast<sal_Int32
>(nHeight
);
2141 case SvtScriptType::COMPLEX
:
2142 nCJKSize
= nHeight
* nCJKSize
/ nCTLSize
;
2143 nWesternSize
= nHeight
* nWesternSize
/ nCTLSize
;
2144 nCTLSize
= static_cast<sal_Int32
>(nHeight
);
2148 aHeightSet
.Put( SvxFontHeightItem( static_cast<sal_uInt32
>(nWesternSize
), 100, RES_CHRATR_FONTSIZE
));
2149 aHeightSet
.Put( SvxFontHeightItem( static_cast<sal_uInt32
>(nCJKSize
), 100, RES_CHRATR_CJK_FONTSIZE
));
2150 aHeightSet
.Put( SvxFontHeightItem( static_cast<sal_uInt32
>(nCTLSize
), 100, RES_CHRATR_CTL_FONTSIZE
));
2151 pArgs
= &aHeightSet
;
2160 if ( !isCHRATR(nWhich
) ||
2161 ( rSh
.HasSelection() && rSh
.IsSelFullPara() ) )
2163 SwTextFormatColl
* pColl
= rSh
.GetCurTextFormatColl();
2164 if ( pColl
&& pColl
->IsAutoUpdateFormat() )
2166 rSh
.AutoUpdatePara( pColl
, *pArgs
);
2173 rSh
.SetAttrSet( *pArgs
);
2178 GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG
);
2182 void SwBaseShell::GetTextCtrlState( SfxItemSet
& rSet
)
2184 SwWrtShell
&rSh
= GetShell();
2185 rSh
.GetCurAttr( rSet
);
2188 void SwBaseShell::GetTextFontCtrlState( SfxItemSet
& rSet
)
2190 SwWrtShell
&rSh
= GetShell();
2192 std::unique_ptr
<SfxItemSet
> pFntCoreSet
;
2193 SvtScriptType nScriptType
= SvtScriptType::LATIN
;
2194 SfxWhichIter
aIter( rSet
);
2195 sal_uInt16 nWhich
= aIter
.FirstWhich();
2200 case RES_CHRATR_FONT
:
2201 case RES_CHRATR_FONTSIZE
:
2202 case RES_CHRATR_WEIGHT
:
2203 case RES_CHRATR_POSTURE
:
2207 pFntCoreSet
.reset(new SfxItemSet( *rSet
.GetPool(),
2208 svl::Items
<RES_CHRATR_BEGIN
, RES_CHRATR_END
-1>{} ));
2209 rSh
.GetCurAttr( *pFntCoreSet
);
2210 nScriptType
= rSh
.GetScriptType();
2211 // #i42732# input language should be preferred over
2212 // current cursor position to detect script type
2213 SwEditWin
& rEditWin
= GetView().GetEditWin();
2214 if( rEditWin
.IsUseInputLanguage() )
2216 if(!rSh
.HasSelection() && (
2217 nWhich
== RES_CHRATR_FONT
||
2218 nWhich
== RES_CHRATR_FONTSIZE
))
2220 LanguageType nInputLang
= rEditWin
.GetInputLanguage();
2221 if(nInputLang
!= LANGUAGE_DONTKNOW
&& nInputLang
!= LANGUAGE_SYSTEM
)
2222 nScriptType
= SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang
);
2226 SfxItemPool
& rPool
= *rSet
.GetPool();
2227 SvxScriptSetItem
aSetItem( rPool
.GetSlotId( nWhich
), rPool
);
2228 aSetItem
.GetItemSet().Put( *pFntCoreSet
, false );
2229 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScriptType
);
2232 rSet
.Put( pI
->CloneSetWhich(nWhich
) );
2235 rSet
.InvalidateItem( nWhich
);
2236 // Set input context of the SwEditWin according to the selected font and script type
2237 if(RES_CHRATR_FONT
== nWhich
)
2240 if (const SvxFontItem
* pFontItem
= dynamic_cast<const SvxFontItem
*>(pI
))
2242 aFont
.SetFamilyName(pFontItem
->GetFamilyName());
2243 aFont
.SetStyleName(pFontItem
->GetStyleName());
2244 aFont
.SetFamily(pFontItem
->GetFamily());
2245 aFont
.SetPitch(pFontItem
->GetPitch());
2246 aFont
.SetCharSet(pFontItem
->GetCharSet());
2249 bool bVertical
= rSh
.IsInVerticalText();
2250 aFont
.SetOrientation(Degree10(bVertical
? 2700 : 0));
2251 aFont
.SetVertical(bVertical
);
2252 GetView().GetEditWin().SetInputContext( InputContext( aFont
, InputContextFlags::Text
|
2253 InputContextFlags::ExtText
) );
2261 rSh
.GetCurAttr( rSet
);
2265 nWhich
= aIter
.NextWhich();
2269 void SwBaseShell::GetBckColState(SfxItemSet
&rSet
)
2271 SwWrtShell
&rSh
= GetShell();
2272 SfxWhichIter
aIter(rSet
);
2273 sal_uInt16
nWhich(aIter
.FirstWhich());
2274 SelectionType
nSelType(rSh
.GetSelectionType());
2275 std::unique_ptr
<SvxBrushItem
> aBrushItem(std::make_unique
<SvxBrushItem
>(RES_BACKGROUND
));
2277 if( nWhich
== SID_TABLE_CELL_BACKGROUND_COLOR
)
2279 rSh
.GetBoxBackground( aBrushItem
);
2283 // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set
2284 SfxItemSet
aCoreSet(GetPool(), svl::Items
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
>{});
2286 aCoreSet
.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2288 if(nSelType
& SelectionType::Graphic
|| SelectionType::Frame
& nSelType
)
2290 rSh
.GetFlyFrameAttr(aCoreSet
);
2294 rSh
.GetCurAttr(aCoreSet
);
2297 aBrushItem
= getSvxBrushItemFromSourceSet(aCoreSet
, RES_BACKGROUND
);
2304 case SID_BACKGROUND_COLOR
:
2305 case SID_TABLE_CELL_BACKGROUND_COLOR
:
2307 SvxColorItem
aColorItem(aBrushItem
->GetColor(), nWhich
);
2308 rSet
.Put(aColorItem
);
2311 case SID_ATTR_BRUSH
:
2312 case RES_BACKGROUND
:
2314 // if this was intended to have a independent copy of the Item to be set
2315 // this is not needed due to the ItemSet/Pool cloning Items which get set anyways.
2316 // Keeping code as reference - it may have had other reasons I do notz see (?!?)
2317 // std::unique_ptr<SfxPoolItem> pNewItem(aBrushItem.CloneSetWhich(GetPool().GetWhich(nWhich)));
2318 rSet
.Put(*aBrushItem
);
2323 nWhich
= aIter
.NextWhich();
2327 void SwBaseShell::ExecBckCol(SfxRequest
& rReq
)
2329 SwWrtShell
&rSh
= GetShell();
2330 SelectionType
nSelType(rSh
.GetSelectionType());
2331 const SfxItemSet
* pArgs
= rReq
.GetArgs();
2332 sal_uInt16
nSlot(rReq
.GetSlot());
2334 if (!pArgs
&& nSlot
!= SID_BACKGROUND_COLOR
&& nSlot
!= SID_TABLE_CELL_BACKGROUND_COLOR
)
2339 std::unique_ptr
<SvxBrushItem
> aBrushItem(std::make_unique
<SvxBrushItem
>(RES_BACKGROUND
));
2341 if ( nSlot
== SID_TABLE_CELL_BACKGROUND_COLOR
)
2343 rSh
.GetBoxBackground( aBrushItem
);
2347 // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set
2348 SfxItemSet
aCoreSet(GetPool(), svl::Items
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
>{});
2350 aCoreSet
.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2352 if((SelectionType::Frame
& nSelType
) || (SelectionType::Graphic
& nSelType
))
2354 rSh
.GetFlyFrameAttr(aCoreSet
);
2358 rSh
.GetCurAttr(aCoreSet
);
2361 aBrushItem
= getSvxBrushItemFromSourceSet(aCoreSet
, RES_BACKGROUND
);
2366 case SID_BACKGROUND_COLOR
:
2367 case SID_TABLE_CELL_BACKGROUND_COLOR
:
2369 const SfxPoolItem
* pColorStringItem
= nullptr;
2370 bool bIsTransparent
= false;
2372 aBrushItem
->SetGraphicPos(GPOS_NONE
);
2374 sal_uInt16 nSlotId
= (nSlot
== SID_BACKGROUND_COLOR
) ? SID_BACKGROUND_COLOR
: SID_TABLE_CELL_BACKGROUND_COLOR
;
2375 if (pArgs
&& SfxItemState::SET
== pArgs
->GetItemState(SID_ATTR_COLOR_STR
, false, &pColorStringItem
))
2377 OUString sColor
= static_cast<const SfxStringItem
*>(pColorStringItem
)->GetValue();
2378 if (sColor
== "transparent")
2380 bIsTransparent
= true;
2384 Color
aColor(ColorTransparency
, sColor
.toInt32(16));
2386 aBrushItem
->SetColor(aColor
);
2388 SvxColorItem
aNewColorItem(nSlotId
);
2389 aNewColorItem
.SetValue(aColor
);
2391 GetView().GetViewFrame()->GetBindings().SetState(aNewColorItem
);
2396 const SvxColorItem
& rNewColorItem
= static_cast<const SvxColorItem
&>(pArgs
->Get(nSlotId
));
2397 const Color
& rNewColor
= rNewColorItem
.GetValue();
2398 aBrushItem
->SetColor(rNewColor
);
2399 GetView().GetViewFrame()->GetBindings().SetState(rNewColorItem
);
2403 bIsTransparent
= true;
2408 aBrushItem
->SetColor(COL_TRANSPARENT
);
2409 rReq
.AppendItem(SvxColorItem(COL_TRANSPARENT
,nSlot
));
2414 case SID_ATTR_BRUSH
:
2415 case RES_BACKGROUND
:
2417 assert(pArgs
&& "only SID_BACKGROUND_COLOR can have !pArgs, checked at entry");
2418 aBrushItem
.reset(static_cast<SvxBrushItem
*>(pArgs
->Get(GetPool().GetWhich(nSlot
)).Clone()));
2424 OSL_FAIL("unknown message in ExecuteAttr!" );
2429 if ( nSlot
== SID_TABLE_CELL_BACKGROUND_COLOR
)
2431 rSh
.SetBoxBackground( *aBrushItem
);
2435 // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set
2436 SfxItemSet
aCoreSet(GetPool(), svl::Items
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
>{});
2438 aCoreSet
.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet());
2439 setSvxBrushItemAsFillAttributesToTargetSet(*aBrushItem
, aCoreSet
);
2441 if((SelectionType::Frame
& nSelType
) || (SelectionType::Graphic
& nSelType
))
2443 // Template autoupdate
2444 SwFrameFormat
* pFormat
= rSh
.GetSelectedFrameFormat();
2446 if(pFormat
&& pFormat
->IsAutoUpdateFormat())
2448 rSh
.AutoUpdateFrame(pFormat
, aCoreSet
);
2452 rSh
.SetFlyFrameAttr(aCoreSet
);
2457 SwTextFormatColl
* pColl
= rSh
.GetCurTextFormatColl();
2459 if(pColl
&& pColl
->IsAutoUpdateFormat())
2461 rSh
.AutoUpdatePara(pColl
, aCoreSet
);
2465 rSh
.SetAttrSet(aCoreSet
);
2473 void SwBaseShell::GetBorderState(SfxItemSet
&rSet
)
2475 SwWrtShell
&rSh
= GetShell();
2476 // Tabele cell(s) selected?
2477 bool bPrepare
= true;
2478 bool bTableMode
= rSh
.IsTableMode();
2481 SfxItemSet
aCoreSet( GetPool(),
2482 svl::Items
<RES_BOX
, RES_BOX
,
2483 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
>{} );
2484 SvxBoxInfoItem
aBoxInfo( SID_ATTR_BORDER_INNER
);
2485 aCoreSet
.Put( aBoxInfo
);
2486 rSh
.GetTabBorders( aCoreSet
);
2487 rSet
.Put( aCoreSet
);
2489 else if ( rSh
.IsFrameSelected() )
2491 SwFlyFrameAttrMgr
aMgr( false, &rSh
, Frmmgr_Type::NONE
, nullptr );
2492 rSet
.Put( aMgr
.GetAttrSet() );
2496 // Get border attributes via shell quite normal
2497 rSh
.GetCurAttr( rSet
);
2499 ::PrepareBoxInfo( rSet
, rSh
);
2500 // Switch the border toolbox controller mode
2501 rSet
.Put( SfxBoolItem( SID_BORDER_REDUCED_MODE
, !bTableMode
));
2504 void SwBaseShell::ExecDlg(SfxRequest
&rReq
)
2506 SwWrtShell
&rSh
= GetShell();
2507 weld::Window
* pMDI
= GetView().GetFrameWeld();
2508 // So that from the basic no dialogues for the background views are called:
2509 bool bBackground
= (&GetView() != GetActiveView());
2510 const SfxPoolItem
* pItem
= nullptr;
2511 const SfxItemSet
* pArgs
= rReq
.GetArgs();
2513 sal_uInt16 nSlot
= rReq
.GetSlot();
2514 const SfxItemSet
* pOutSet
= nullptr;
2517 pArgs
->GetItemState( GetPool().GetWhich(nSlot
), false, &pItem
);
2521 case FN_FORMAT_TITLEPAGE_DLG
:
2523 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
2524 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateTitlePageDlg(pMDI
));
2525 VclAbstractDialog::AsyncContext aContext
;
2526 aContext
.maEndDialogFn
= [](sal_Int32
){};
2527 pDlg
->StartExecuteAsync(aContext
);
2530 case FN_FORMAT_PAGE_DLG
:
2531 case FN_FORMAT_PAGE_COLUMN_DLG
:
2532 case FN_FORMAT_PAGE_SETTING_DLG
:
2536 const size_t nCurIdx
= rSh
.GetCurPageDesc();
2537 const SwPageDesc
& rPageDesc
= rSh
.GetPageDesc( nCurIdx
);
2538 // Temporary view, because the shell does not need to be valid after the dialog
2539 // for example disable header
2540 SwView
& rTempView
= GetView();
2545 case FN_FORMAT_PAGE_COLUMN_DLG
:
2546 sPageId
= "columns";
2548 case FN_FORMAT_PAGE_SETTING_DLG
:
2551 case FN_FORMAT_PAGE_DLG
:
2553 sPageId
= OUStringToOString(static_cast<const SfxStringItem
*>(pItem
)->GetValue(), RTL_TEXTENCODING_UTF8
);
2556 rTempView
.GetDocShell()->FormatPage(rPageDesc
.GetName(), sPageId
, rSh
, &rReq
);
2557 rTempView
.InvalidateRulerPos();
2559 bDone
= true; // FormatPage() takes care of calling Done()
2563 case FN_FORMAT_BORDER_DLG
:
2565 SfxItemSet
aSet( rSh
.GetAttrPool(),
2566 svl::Items
<RES_BOX
, RES_SHADOW
,
2567 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
>{} );
2568 ScopedVclPtr
<SfxAbstractDialog
> pDlg
;
2569 // Table cell(s) selected?
2570 if ( rSh
.IsTableMode() )
2572 // Set border attributes Get/SetTabBorders()
2573 ::PrepareBoxInfo( aSet
, rSh
);
2574 rSh
.GetTabBorders( aSet
);
2575 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
2576 pDlg
.disposeAndReset(pFact
->CreateSwBorderDlg(pMDI
, aSet
, SwBorderModes::TABLE
));
2577 if ( pDlg
->Execute() == RET_OK
)
2579 rSh
.SetTabBorders( *pDlg
->GetOutputItemSet() );
2580 pOutSet
= pDlg
->GetOutputItemSet();
2583 else if ( rSh
.IsFrameSelected() )
2585 // Set border attributes via Frame-Manager
2586 SwFlyFrameAttrMgr
aMgr( false, &rSh
, Frmmgr_Type::NONE
, nullptr );
2587 aSet
.Put( aMgr
.GetAttrSet() );
2589 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
2590 pDlg
.disposeAndReset(pFact
->CreateSwBorderDlg(pMDI
, aSet
, SwBorderModes::FRAME
));
2591 if ( pDlg
->Execute() == RET_OK
)
2593 aMgr
.SetAttrSet( *pDlg
->GetOutputItemSet() );
2594 aMgr
.UpdateFlyFrame();
2595 pOutSet
= pDlg
->GetOutputItemSet();
2600 // Set border attributes via Shell quite normal
2601 rSh
.GetCurAttr( aSet
);
2602 ::PrepareBoxInfo( aSet
, rSh
);
2604 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
2605 pDlg
.disposeAndReset(pFact
->CreateSwBorderDlg(pMDI
, aSet
, SwBorderModes::PARA
));
2606 if ( pDlg
->Execute() == RET_OK
)
2608 rSh
.SetAttrSet( *pDlg
->GetOutputItemSet() );
2609 pOutSet
= pDlg
->GetOutputItemSet();
2614 rReq
.Done(*pOutSet
);
2619 case FN_FORMAT_BACKGROUND_DLG
:
2621 SfxItemSet
aSet( rSh
.GetAttrPool(),
2622 svl::Items
<RES_BACKGROUND
, RES_BACKGROUND
,
2623 XATTR_FILL_FIRST
, XATTR_FILL_LAST
>{} );
2625 ScopedVclPtr
<SfxAbstractDialog
> pDlg
;
2626 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
2628 // Table cell(s) selected?
2629 if ( rSh
.IsTableMode() )
2631 // Get background attributes of the table and put it in the set
2632 std::unique_ptr
<SvxBrushItem
> aBrush
;
2633 rSh
.GetBoxBackground( aBrush
);
2634 pDlg
.disposeAndReset(pFact
->CreateSwBackgroundDialog(pMDI
, aSet
));
2635 aSet
.Put( *aBrush
);
2636 if ( pDlg
->Execute() == RET_OK
)
2639 rSh
.SetBoxBackground( pDlg
->GetOutputItemSet()->Get( RES_BACKGROUND
) );
2640 pOutSet
= pDlg
->GetOutputItemSet();
2643 else if ( rSh
.IsFrameSelected() )
2646 rSh
.GetFlyFrameAttr( aSet
);
2648 pDlg
.disposeAndReset(pFact
->CreateSwBackgroundDialog(pMDI
, aSet
));
2649 if ( pDlg
->Execute() == RET_OK
)
2651 rSh
.SetFlyFrameAttr(const_cast<SfxItemSet
&>(*pDlg
->GetOutputItemSet()) );
2652 pOutSet
= pDlg
->GetOutputItemSet();
2657 // Set border attributes Umrandungsattribute with the shell quite normal.
2658 rSh
.GetCurAttr( aSet
);
2660 pDlg
.disposeAndReset(pFact
->CreateSwBackgroundDialog(pMDI
, aSet
));
2661 if ( pDlg
->Execute() == RET_OK
)
2663 rSh
.SetAttrSet( *pDlg
->GetOutputItemSet() );
2664 pOutSet
= pDlg
->GetOutputItemSet();
2669 rReq
.Done(*pOutSet
);
2674 case SID_ACCESSIBILITY_CHECK
:
2676 sw::AccessibilityCheck
aCheck(rSh
.GetDoc());
2678 svx::AccessibilityCheckDialog
aDialog(pMDI
, aCheck
.getIssueCollection());
2682 default:OSL_FAIL("wrong Dispatcher (basesh.cxx)");
2688 SwWrtShell
& SwBaseShell::GetShell()
2690 return rView
.GetWrtShell();
2693 SwWrtShell
* SwBaseShell::GetShellPtr()
2695 return rView
.GetWrtShellPtr();
2698 static void EndUndo(SwWrtShell
& rSh
)
2700 SwRewriter aRewriter
;
2702 if (rSh
.GetTableFormat())
2704 aRewriter
.AddRule(UndoArg1
, SwResId(STR_START_QUOTE
));
2705 aRewriter
.AddRule(UndoArg2
, rSh
.GetTableFormat()->GetName());
2706 aRewriter
.AddRule(UndoArg3
, SwResId(STR_END_QUOTE
));
2709 rSh
.EndUndo(SwUndoId::INSTABLE
, &aRewriter
); // If possible change the Shell
2712 static void InsertTableImpl(SwWrtShell
& rSh
,
2714 const OUString
& aTableName
,
2717 SwInsertTableOptions aInsTableOpts
,
2718 const OUString
& aAutoName
,
2719 const std::unique_ptr
<SwTableAutoFormat
>& pTAFormat
)
2721 rSh
.StartUndo(SwUndoId::INSTABLE
);
2723 rSh
.StartAllAction();
2724 if( rSh
.HasSelection() )
2727 rSh
.InsertTable( aInsTableOpts
, nRows
, nCols
, pTAFormat
.get() );
2728 rSh
.MoveTable( GotoPrevTable
, fnTableStart
);
2730 if( !aTableName
.isEmpty() && !rSh
.GetTableStyle( aTableName
) )
2731 rSh
.GetTableFormat()->SetName( aTableName
);
2733 if( pTAFormat
!= nullptr && !aAutoName
.isEmpty()
2734 && aAutoName
!= SwViewShell::GetShellRes()->aStrNone
)
2736 SwTableNode
* pTableNode
= const_cast<SwTableNode
*>( rSh
.IsCursorInTable() );
2739 pTableNode
->GetTable().SetTableStyleName( aAutoName
);
2740 SwUndoTableAutoFormat
* pUndo
= new SwUndoTableAutoFormat( *pTableNode
, *pTAFormat
);
2742 rSh
.GetIDocumentUndoRedo().AppendUndo( std::unique_ptr
<SwUndo
>(pUndo
) );
2747 rTempView
.AutoCaption(TABLE_CAP
);
2750 void SwBaseShell::InsertTable( SfxRequest
& _rRequest
)
2752 const SfxItemSet
* pArgs
= _rRequest
.GetArgs();
2753 SwWrtShell
& rSh
= GetShell();
2755 if ( rSh
.GetFrameType( nullptr, true ) & FrameTypeFlags::FOOTNOTE
)
2758 SwView
&rTempView
= GetView(); // Because GetView() does not work after the shell exchange
2759 bool bHTMLMode
= 0 != (::GetHtmlMode(rTempView
.GetDocShell())&HTMLMODE_ON
);
2760 bool bCallEndUndo
= false;
2762 if( !pArgs
&& rSh
.IsSelection() && !rSh
.IsInClickToEdit() &&
2763 !rSh
.IsTableMode() )
2765 const SwModuleOptions
* pModOpt
= SW_MOD()->GetModuleConfig();
2766 SwInsertTableOptions aInsTableOpts
= pModOpt
->GetInsTableFlags(bHTMLMode
);
2768 rSh
.StartUndo(SwUndoId::INSTABLE
);
2769 bCallEndUndo
= true;
2771 bool bInserted
= rSh
.TextToTable( aInsTableOpts
, '\t' );
2774 rTempView
.AutoCaption(TABLE_CAP
);
2779 sal_uInt16 nColsIn
= 0;
2780 sal_uInt16 nRowsIn
= 0;
2781 SwInsertTableOptions
aInsTableOptsIn( SwInsertTableFlags::All
, 1 );
2782 OUString aTableNameIn
;
2783 OUString aAutoNameIn
;
2784 std::unique_ptr
<SwTableAutoFormat
> pTAFormatIn
;
2786 if( pArgs
&& pArgs
->Count() >= 2 )
2788 const SfxStringItem
* pName
= _rRequest
.GetArg
<SfxStringItem
>(FN_INSERT_TABLE
);
2789 const SfxUInt16Item
* pCols
= _rRequest
.GetArg
<SfxUInt16Item
>(SID_ATTR_TABLE_COLUMN
);
2790 const SfxUInt16Item
* pRows
= _rRequest
.GetArg
<SfxUInt16Item
>(SID_ATTR_TABLE_ROW
);
2791 const SfxInt32Item
* pFlags
= _rRequest
.GetArg
<SfxInt32Item
>(FN_PARAM_1
);
2792 const SfxStringItem
* pAuto
= _rRequest
.GetArg
<SfxStringItem
>(FN_PARAM_2
);
2795 aTableNameIn
= pName
->GetValue();
2797 nColsIn
= pCols
->GetValue();
2799 nRowsIn
= pRows
->GetValue();
2802 aAutoNameIn
= pAuto
->GetValue();
2803 if ( !aAutoNameIn
.isEmpty() )
2805 SwTableAutoFormatTable aTableTable
;
2807 for ( size_t n
=0; n
<aTableTable
.size(); n
++ )
2809 if ( aTableTable
[n
].GetName() == aAutoNameIn
)
2811 pTAFormatIn
.reset(new SwTableAutoFormat( aTableTable
[n
] ));
2819 aInsTableOptsIn
.mnInsMode
= static_cast<SwInsertTableFlags
>(pFlags
->GetValue());
2822 const SwModuleOptions
* pModOpt
= SW_MOD()->GetModuleConfig();
2823 aInsTableOptsIn
= pModOpt
->GetInsTableFlags(bHTMLMode
);
2827 if( !nColsIn
|| !nRowsIn
)
2829 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
2830 std::shared_ptr
<AbstractInsTableDlg
> pAbstractDialog(pFact
->CreateInsTableDlg(rTempView
));
2831 std::shared_ptr
<weld::DialogController
> pDialogController(pAbstractDialog
->getDialogController());
2833 weld::DialogController::runAsync(pDialogController
,
2834 [pAbstractDialog
, &rSh
, &rTempView
, aTableNameIn
, nRowsIn
, nColsIn
, aInsTableOptsIn
, aAutoNameIn
] (sal_Int32 nResult
) {
2835 if( RET_OK
== nResult
)
2837 sal_uInt16 nCols
= nColsIn
;
2838 sal_uInt16 nRows
= nRowsIn
;
2839 SwInsertTableOptions aInsTableOpts
= aInsTableOptsIn
;
2840 OUString aTableName
= aTableNameIn
;
2841 OUString aAutoName
= aAutoNameIn
;
2842 std::unique_ptr
<SwTableAutoFormat
> pTAFormat
;
2844 pAbstractDialog
->GetValues( aTableName
, nRows
, nCols
, aInsTableOpts
, aAutoName
, pTAFormat
);
2846 if( nCols
&& nRows
)
2848 InsertTableImpl( rSh
, rTempView
, aTableName
, nRows
, nCols
, aInsTableOpts
, aAutoName
, pTAFormat
);
2857 // record before shell change
2858 _rRequest
.AppendItem( SfxStringItem( FN_INSERT_TABLE
, aTableNameIn
) );
2859 if ( !aAutoNameIn
.isEmpty() )
2860 _rRequest
.AppendItem( SfxStringItem( FN_PARAM_2
, aAutoNameIn
) );
2861 _rRequest
.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN
, nColsIn
) );
2862 _rRequest
.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW
, nRowsIn
) );
2863 _rRequest
.AppendItem( SfxInt32Item( FN_PARAM_1
, static_cast<sal_Int32
>(aInsTableOptsIn
.mnInsMode
) ) );
2866 InsertTableImpl( rSh
, rTempView
, aTableNameIn
, nRowsIn
, nColsIn
, aInsTableOptsIn
, aAutoNameIn
, pTAFormatIn
);
2868 bCallEndUndo
= true;
2876 void SwBaseShell::GetGalleryState( SfxItemSet
&rSet
)
2878 SwWrtShell
&rSh
= GetShell();
2879 SfxWhichIter
aIter( rSet
);
2880 sal_uInt16 nWhich
= aIter
.FirstWhich();
2883 case SID_GALLERY_BG_BRUSH
:
2885 SelectionType nSel
= rSh
.GetSelectionType();
2886 SfxStringListItem
aLst( nWhich
);
2887 std::vector
<OUString
> &rLst
= aLst
.GetList();
2888 nParagraphPos
= nGraphicPos
= nOlePos
= nFramePos
= nTablePos
=
2889 nTableRowPos
= nTableCellPos
= nPagePos
=
2890 nHeaderPos
= nFooterPos
= 0;
2892 rLst
.push_back( SwResId( STR_SWBG_PAGE
) );
2894 sal_uInt16 nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
2895 bool bHtmlMode
= 0 != (nHtmlMode
& HTMLMODE_ON
);
2897 if ( (!bHtmlMode
|| (nHtmlMode
& HTMLMODE_FULL_STYLES
)) &&
2898 (nSel
& SelectionType::Text
) )
2900 rLst
.push_back( SwResId( STR_SWBG_PARAGRAPH
) );
2901 nParagraphPos
= nPos
++;
2903 if ( (!bHtmlMode
|| (nHtmlMode
& HTMLMODE_SOME_STYLES
)) &&
2904 nSel
& (SelectionType::Table
|SelectionType::TableCell
) )
2906 rLst
.push_back( SwResId( STR_SWBG_TABLE
) );
2911 rLst
.push_back( SwResId( STR_SWBG_TABLE_ROW
) );
2912 nTableRowPos
= nPos
++;
2915 rLst
.push_back( SwResId( STR_SWBG_TABLE_CELL
) );
2916 nTableCellPos
= nPos
++;
2920 if ( nSel
& SelectionType::Frame
)
2922 rLst
.push_back( SwResId( STR_SWBG_FRAME
) );
2925 if ( nSel
& SelectionType::Graphic
)
2927 rLst
.push_back( SwResId( STR_SWBG_GRAPHIC
) );
2928 nGraphicPos
= nPos
++;
2930 if ( nSel
& SelectionType::Ole
)
2932 rLst
.push_back( SwResId( STR_SWBG_OLE
) );
2935 const FrameTypeFlags nType
= rSh
.GetFrameType(nullptr,true);
2936 if ( nType
& FrameTypeFlags::HEADER
)
2938 rLst
.push_back( SwResId( STR_SWBG_HEADER
) );
2939 nHeaderPos
= nPos
++;
2941 if ( nType
& FrameTypeFlags::FOOTER
)
2943 rLst
.push_back( SwResId( STR_SWBG_FOOTER
) );
2948 rSet
.DisableItem( nWhich
);
2956 void SwBaseShell::ExecuteGallery(SfxRequest
&rReq
)
2958 SwWrtShell
&rSh
= GetShell();
2960 const SfxItemSet
* pArgs
= rReq
.GetArgs();
2961 sal_uInt16 nSlot
= rReq
.GetSlot();
2964 case SID_GALLERY_BG_BRUSH
:
2969 SelectionType nSel
= rSh
.GetSelectionType();
2970 if ( nSel
& SelectionType::DrawObjectEditMode
)
2973 const SfxUInt16Item
* pPos
= rReq
.GetArg
<SfxUInt16Item
>(SID_GALLERY_BG_POS
);
2974 const SvxBrushItem
* pBrush
= rReq
.GetArg
<SvxBrushItem
>(SID_GALLERY_BG_BRUSH
);
2975 if ( !pPos
|| !pBrush
)
2978 sal_uInt8 nPos
= pPos
->GetValue();
2981 SvxBrushItem
aBrush( *pBrush
);
2982 aBrush
.SetWhich( RES_BACKGROUND
);
2983 if ( nPos
== nParagraphPos
)
2984 rSh
.SetAttrItem( aBrush
);
2985 else if ( nPos
== nTablePos
)
2986 rSh
.SetTabBackground( aBrush
);
2987 else if ( nPos
== nTableRowPos
)
2988 rSh
.SetRowBackground( aBrush
);
2989 else if ( nPos
== nTableCellPos
)
2990 rSh
.SetBoxBackground( aBrush
);
2991 else if ( nPos
== nFramePos
|| nPos
== nGraphicPos
|| nPos
== nOlePos
)
2993 SfxItemSet
aCoreSet(GetPool(), svl::Items
<RES_BACKGROUND
, RES_BACKGROUND
>{});
2994 aCoreSet
.Put( aBrush
);
2995 rSh
.SetFlyFrameAttr( aCoreSet
);
2997 else if ( nPos
== nPagePos
|| nPos
== nHeaderPos
|| nPos
== nFooterPos
)
2999 sal_uInt16 nDesc
= rSh
.GetCurPageDesc();
3000 SwPageDesc
aDesc( rSh
.GetPageDesc( nDesc
) );
3001 if ( nPos
== nPagePos
)
3002 aDesc
.GetMaster().SetFormatAttr( aBrush
);
3003 else if ( nPos
== nHeaderPos
)
3005 SwFormatHeader
aHead( aDesc
.GetMaster().GetHeader() );
3006 aHead
.GetHeaderFormat()->SetFormatAttr( aBrush
);
3007 aDesc
.GetMaster().SetFormatAttr( aHead
);
3009 else if ( nPos
== nFooterPos
)
3011 SwFormatFooter
aFoot( aDesc
.GetMaster().GetFooter() );
3012 aFoot
.GetFooterFormat()->SetFormatAttr( aBrush
);
3013 aDesc
.GetMaster().SetFormatAttr( aFoot
);
3015 rSh
.ChgPageDesc( nDesc
, aDesc
);
3024 void SwBaseShell::ExecField( SfxRequest
const & rReq
)
3026 sal_uInt16 nSlot
= rReq
.GetSlot();
3029 #if HAVE_FEATURE_DBCONNECTIVITY
3030 case FN_CHANGE_DBFIELD
:
3032 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
3033 ScopedVclPtr
<VclAbstractDialog
> pDlg(pFact
->CreateSwChangeDBDlg(GetView()));
3039 OSL_FAIL("wrong dispatcher");
3043 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */