/src/libreoffice/sw/source/uibase/shells/basesh.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <config_features.h> |
21 | | #include <config_fuzzers.h> |
22 | | |
23 | | #include <sal/config.h> |
24 | | |
25 | | #include <hintids.hxx> |
26 | | #include <comphelper/servicehelper.hxx> |
27 | | #include <svl/languageoptions.hxx> |
28 | | #include <sfx2/docfile.hxx> |
29 | | #include <sfx2/linkmgr.hxx> |
30 | | #include <sfx2/htmlmode.hxx> |
31 | | #include <svx/imapdlg.hxx> |
32 | | #include <sfx2/dispatch.hxx> |
33 | | #include <sfx2/viewfrm.hxx> |
34 | | #include <sfx2/request.hxx> |
35 | | #include <svl/whiter.hxx> |
36 | | #include <svl/visitem.hxx> |
37 | | #include <editeng/langitem.hxx> |
38 | | #include <svx/clipfmtitem.hxx> |
39 | | #include <svx/contdlg.hxx> |
40 | | #include <vcl/graph.hxx> |
41 | | #include <vcl/inputctx.hxx> |
42 | | #include <svl/slstitm.hxx> |
43 | | #include <svl/ptitem.hxx> |
44 | | #include <svl/stritem.hxx> |
45 | | #include <editeng/colritem.hxx> |
46 | | #include <editeng/fhgtitem.hxx> |
47 | | #include <editeng/fontitem.hxx> |
48 | | #include <editeng/shaditem.hxx> |
49 | | #include <editeng/boxitem.hxx> |
50 | | #include <editeng/brushitem.hxx> |
51 | | #include <editeng/opaqitem.hxx> |
52 | | #include <editeng/sizeitem.hxx> |
53 | | #include <editeng/protitem.hxx> |
54 | | #include <svx/flagsdef.hxx> |
55 | | #include <editeng/scriptsetitem.hxx> |
56 | | #include <sfx2/objface.hxx> |
57 | | #include <fmturl.hxx> |
58 | | #include <fmthdft.hxx> |
59 | | #include <fmtclds.hxx> |
60 | | #include <docsh.hxx> |
61 | | #include <wrtsh.hxx> |
62 | | #include <view.hxx> |
63 | | #include <swmodule.hxx> |
64 | | #include <swundo.hxx> |
65 | | #include <fldbas.hxx> |
66 | | #include <uitool.hxx> |
67 | | #include <basesh.hxx> |
68 | | #include <viewopt.hxx> |
69 | | #include <fontcfg.hxx> |
70 | | #include <fmtsrnd.hxx> |
71 | | #include <fldmgr.hxx> |
72 | | #include <frmmgr.hxx> |
73 | | #include <tablemgr.hxx> |
74 | | #include <mdiexp.hxx> |
75 | | #include <swdtflvr.hxx> |
76 | | #include <pagedesc.hxx> |
77 | | #include <fmtcol.hxx> |
78 | | #include <edtwin.hxx> |
79 | | #include <tblafmt.hxx> |
80 | | #include <swwait.hxx> |
81 | | #include <cmdid.h> |
82 | | #include <strings.hrc> |
83 | | #include <unotxdoc.hxx> |
84 | | #include <doc.hxx> |
85 | | #include <drawdoc.hxx> |
86 | | #include <IDocumentSettingAccess.hxx> |
87 | | #include <IDocumentDrawModelAccess.hxx> |
88 | | #include <IDocumentUndoRedo.hxx> |
89 | | #include <ThemeColorChanger.hxx> |
90 | | #include <swabstdlg.hxx> |
91 | | #include <modcfg.hxx> |
92 | | #include <svx/fmshell.hxx> |
93 | | #include <SwRewriter.hxx> |
94 | | #include <GraphicSizeCheck.hxx> |
95 | | #include <svx/galleryitem.hxx> |
96 | | #include <sfx2/devtools/DevelopmentToolChildWindow.hxx> |
97 | | #include <com/sun/star/gallery/GalleryItemType.hpp> |
98 | | #include <com/sun/star/beans/PropertyValues.hpp> |
99 | | #include <memory> |
100 | | |
101 | | |
102 | | #include <svx/unobrushitemhelper.hxx> |
103 | | #include <svx/dialog/ThemeDialog.hxx> |
104 | | #include <comphelper/scopeguard.hxx> |
105 | | #include <comphelper/lok.hxx> |
106 | | #include <LibreOfficeKit/LibreOfficeKitEnums.h> |
107 | | #include <osl/diagnose.h> |
108 | | |
109 | | #include <svx/svxdlg.hxx> |
110 | | #include <comphelper/sequenceashashmap.hxx> |
111 | | |
112 | | #include <shellres.hxx> |
113 | | #include <UndoTable.hxx> |
114 | | |
115 | | #include <ndtxt.hxx> |
116 | | #include <UndoManager.hxx> |
117 | | #include <fmtrfmrk.hxx> |
118 | | #include <txtrfmrk.hxx> |
119 | | #include <translatehelper.hxx> |
120 | | #include <rootfrm.hxx> |
121 | | |
122 | | FlyMode SwBaseShell::s_eFrameMode = FLY_DRAG_END; |
123 | | |
124 | | // These variables keep the state of Gallery (slot SID_GALLERY_BG_BRUSH) |
125 | | // detected by GetGalleryState() for the subsequent ExecuteGallery() call. |
126 | | |
127 | | static sal_uInt8 nParagraphPos; |
128 | | static sal_uInt8 nGraphicPos; |
129 | | static sal_uInt8 nOlePos; |
130 | | static sal_uInt8 nFramePos; |
131 | | static sal_uInt8 nTablePos; |
132 | | static sal_uInt8 nTableRowPos; |
133 | | static sal_uInt8 nTableCellPos; |
134 | | static sal_uInt8 nPagePos; |
135 | | static sal_uInt8 nHeaderPos; |
136 | | static sal_uInt8 nFooterPos; |
137 | | |
138 | | #define ShellClass_SwBaseShell |
139 | | #include <sfx2/msg.hxx> |
140 | | #include <swslots.hxx> |
141 | | |
142 | | #include <AccessibilityCheck.hxx> |
143 | | |
144 | | namespace |
145 | | { |
146 | | SvxContourDlg* GetContourDlg(SwView const &rView) |
147 | 0 | { |
148 | 0 | SfxChildWindow *pWnd = rView.GetViewFrame().GetChildWindow(SvxContourDlgChildWindow::GetChildWindowId()); |
149 | 0 | return pWnd ? static_cast<SvxContourDlg*>(pWnd->GetController().get()) : nullptr; |
150 | 0 | } |
151 | | |
152 | | SvxIMapDlg* GetIMapDlg(SwView const &rView) |
153 | 0 | { |
154 | 0 | SfxChildWindow* pWnd = rView.GetViewFrame().GetChildWindow(SvxIMapDlgChildWindow::GetChildWindowId()); |
155 | 0 | return pWnd ? static_cast<SvxIMapDlg*>(pWnd->GetController().get()) : nullptr; |
156 | 0 | } |
157 | | } |
158 | | |
159 | | using namespace ::com::sun::star; |
160 | | using namespace ::com::sun::star::uno; |
161 | | using namespace ::com::sun::star::frame; |
162 | | |
163 | | SFX_IMPL_SUPERCLASS_INTERFACE(SwBaseShell, SfxShell) |
164 | | |
165 | | void SwBaseShell::InitInterface_Impl() |
166 | 9 | { |
167 | 9 | GetStaticInterface()->RegisterChildWindow(SvxIMapDlgChildWindow::GetChildWindowId()); |
168 | 9 | GetStaticInterface()->RegisterChildWindow(SvxContourDlgChildWindow::GetChildWindowId()); |
169 | 9 | GetStaticInterface()->RegisterChildWindow(DevelopmentToolChildWindow::GetChildWindowId()); |
170 | 9 | } |
171 | | |
172 | | static void lcl_UpdateIMapDlg( SwWrtShell& rSh ) |
173 | 0 | { |
174 | 0 | Graphic aGrf( rSh.GetIMapGraphic() ); |
175 | 0 | GraphicType nGrfType = aGrf.GetType(); |
176 | 0 | void* pEditObj = GraphicType::NONE != nGrfType && GraphicType::Default != nGrfType |
177 | 0 | ? rSh.GetIMapInventor() : nullptr; |
178 | 0 | TargetList aList; |
179 | 0 | SfxFrame::GetDefaultTargetList(aList); |
180 | |
|
181 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_URL, RES_URL>(rSh.GetAttrPool())); |
182 | 0 | rSh.GetFlyFrameAttr( aSet ); |
183 | 0 | const SwFormatURL &rURL = aSet.Get( RES_URL ); |
184 | 0 | SvxIMapDlgChildWindow::UpdateIMapDlg( |
185 | 0 | aGrf, rURL.GetMap(), &aList, pEditObj ); |
186 | 0 | } |
187 | | |
188 | | static bool lcl_UpdateContourDlg( SwWrtShell &rSh, SelectionType nSel ) |
189 | 0 | { |
190 | 0 | Graphic aGraf( rSh.GetIMapGraphic() ); |
191 | 0 | GraphicType nGrfType = aGraf.GetType(); |
192 | 0 | bool bRet = GraphicType::NONE != nGrfType && GraphicType::Default != nGrfType; |
193 | 0 | if( bRet ) |
194 | 0 | { |
195 | 0 | OUString aGrfName; |
196 | 0 | if ( nSel & SelectionType::Graphic ) |
197 | 0 | rSh.GetGrfNms( &aGrfName, nullptr ); |
198 | |
|
199 | 0 | SvxContourDlg *pDlg = GetContourDlg(rSh.GetView()); |
200 | 0 | if (pDlg) |
201 | 0 | { |
202 | 0 | pDlg->Update(aGraf, !aGrfName.isEmpty(), |
203 | 0 | rSh.GetGraphicPolygon(), rSh.GetIMapInventor()); |
204 | 0 | } |
205 | 0 | } |
206 | 0 | return bRet; |
207 | 0 | } |
208 | | |
209 | | void SwBaseShell::ExecDelete(SfxRequest &rReq) |
210 | 0 | { |
211 | 0 | SwWrtShell &rSh = GetShell(); |
212 | 0 | SwEditWin& rTmpEditWin = GetView().GetEditWin(); |
213 | 0 | switch(rReq.GetSlot()) |
214 | 0 | { |
215 | 0 | case SID_DELETE: |
216 | 0 | if (rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton()) |
217 | 0 | { |
218 | | // Disallow if the cursor is at the end of a paragraph and the document model |
219 | | // node at this position is an outline node with folded content or the next node |
220 | | // is an outline node with folded content. |
221 | 0 | if (rSh.IsEndPara()) |
222 | 0 | { |
223 | 0 | SwNodeIndex aIdx(rSh.GetCursor()->GetPointNode()); |
224 | 0 | if (aIdx.GetNode().IsTextNode()) |
225 | 0 | { |
226 | 0 | if (!aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible()) |
227 | 0 | break; |
228 | 0 | ++aIdx; |
229 | 0 | if (aIdx.GetNode().IsTextNode()) |
230 | 0 | { |
231 | 0 | if (!aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible()) |
232 | 0 | break; |
233 | 0 | } |
234 | 0 | } |
235 | 0 | } |
236 | 0 | } |
237 | 0 | rSh.DelRight(); |
238 | 0 | break; |
239 | | |
240 | 0 | case FN_BACKSPACE: |
241 | 0 | if (rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton()) |
242 | 0 | { |
243 | | // Disallow if the cursor is at the start of a paragraph and the document model |
244 | | // node at this position is an outline node with folded content or the previous |
245 | | // node is a content node without a layout frame. |
246 | 0 | if (rSh.IsSttPara()) |
247 | 0 | { |
248 | 0 | SwNodeIndex aIdx(rSh.GetCursor()->GetPointNode()); |
249 | 0 | if (aIdx.GetNode().IsTextNode()) |
250 | 0 | { |
251 | 0 | if (!aIdx.GetNode().GetTextNode()->GetAttrOutlineContentVisible()) |
252 | 0 | break; |
253 | 0 | --aIdx; |
254 | 0 | if (aIdx.GetNode().IsContentNode() && |
255 | 0 | !aIdx.GetNode().GetContentNode()->getLayoutFrame(rSh.GetLayout())) |
256 | 0 | break; |
257 | 0 | } |
258 | 0 | } |
259 | 0 | } |
260 | 0 | if( rSh.IsNoNum() ) |
261 | 0 | { |
262 | 0 | rSh.SttCursorMove(); |
263 | 0 | bool bLeft = rSh.Left( SwCursorSkipMode::Chars, true, 1, false ); |
264 | 0 | if( bLeft ) |
265 | 0 | { |
266 | 0 | rSh.DelLeft(); |
267 | 0 | } |
268 | 0 | else |
269 | | // JP 15.07.96: If it no longer goes forward, cancel |
270 | | // the numbering. For example at the beginning |
271 | | // of a doc, frame, table or an area. |
272 | 0 | rSh.DelNumRules(); |
273 | |
|
274 | 0 | rSh.EndCursorMove(); |
275 | 0 | break; |
276 | 0 | } |
277 | | |
278 | 0 | [[fallthrough]]; // otherwise call DelLeft |
279 | 0 | case FN_SHIFT_BACKSPACE: |
280 | 0 | rSh.DelLeft(); |
281 | 0 | break; |
282 | 0 | default: |
283 | 0 | OSL_FAIL("wrong Dispatcher"); |
284 | 0 | return; |
285 | 0 | } |
286 | 0 | rReq.Done(); |
287 | | |
288 | | //#i42732# - notify the edit window that from now on we do not use the input language |
289 | 0 | rTmpEditWin.SetUseInputLanguage( false ); |
290 | | |
291 | | // Test Fieldmark when empty reset the Placeholders |
292 | 0 | const IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); |
293 | 0 | for (SwPaM &rPaM : rSh.GetCursor()->GetRingContainer()) |
294 | 0 | { |
295 | 0 | const SwPosition* sp = rPaM.Start(); |
296 | | // Legacy text/combo/checkbox: never return read-only when inside these form fields. |
297 | 0 | sw::mark::Fieldmark* pA = pMarksAccess->getInnerFieldmarkFor(*sp); |
298 | 0 | if (pA != nullptr) |
299 | 0 | { |
300 | 0 | if ((IDocumentMarkAccess::GetType(*pA) == IDocumentMarkAccess::MarkType::TEXT_FIELDMARK) && |
301 | 0 | (pA->GetContent().getLength() == 0) |
302 | 0 | ) |
303 | 0 | { |
304 | 0 | pA->ReplaceContent(vEnSpaces); |
305 | 0 | rSh.GotoFieldmark(pA); |
306 | 0 | } |
307 | 0 | } |
308 | 0 | } |
309 | 0 | } |
310 | | |
311 | | void SwBaseShell::ExecClpbrd(SfxRequest &rReq) |
312 | 0 | { |
313 | | // Attention: At risk of suicide! |
314 | | // After paste, paste special the shell can be destroy. |
315 | |
|
316 | 0 | SwWrtShell &rSh = GetShell(); |
317 | 0 | sal_uInt16 nId = rReq.GetSlot(); |
318 | 0 | bool bIgnore = false; |
319 | 0 | PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT; |
320 | |
|
321 | 0 | switch( nId ) |
322 | 0 | { |
323 | 0 | case SID_CUT: |
324 | 0 | case SID_COPY: |
325 | 0 | m_rView.GetEditWin().FlushInBuffer(); |
326 | 0 | if ( rSh.HasSelection() ) |
327 | 0 | { |
328 | 0 | rtl::Reference<SwTransferable> pTransfer = new SwTransferable( rSh ); |
329 | |
|
330 | 0 | if ( nId == SID_CUT && FlyProtectFlags::NONE == rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent) ) |
331 | 0 | pTransfer->Cut(); |
332 | 0 | else |
333 | 0 | { |
334 | 0 | const bool bLockedView = rSh.IsViewLocked(); |
335 | 0 | rSh.LockView( true ); //lock visible section |
336 | 0 | pTransfer->Copy(); |
337 | 0 | rSh.LockView( bLockedView ); |
338 | 0 | } |
339 | 0 | break; |
340 | 0 | } |
341 | 0 | return; |
342 | | |
343 | 0 | case FN_PASTE_NESTED_TABLE: |
344 | 0 | case FN_TABLE_PASTE_ROW_BEFORE: |
345 | 0 | case FN_TABLE_PASTE_COL_BEFORE: |
346 | 0 | switch ( nId ) |
347 | 0 | { |
348 | 0 | case FN_PASTE_NESTED_TABLE: |
349 | 0 | ePasteTable = PasteTableType::PASTE_TABLE; |
350 | 0 | break; |
351 | 0 | case FN_TABLE_PASTE_ROW_BEFORE: |
352 | 0 | ePasteTable = PasteTableType::PASTE_ROW; |
353 | 0 | break; |
354 | 0 | case FN_TABLE_PASTE_COL_BEFORE: |
355 | 0 | ePasteTable = PasteTableType::PASTE_COLUMN; |
356 | 0 | break; |
357 | 0 | default: |
358 | 0 | ; |
359 | 0 | } |
360 | 0 | [[fallthrough]]; |
361 | 0 | case SID_PASTE: |
362 | 0 | { |
363 | 0 | TransferableDataHelper aDataHelper( |
364 | 0 | TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin() ) ); |
365 | 0 | if( aDataHelper.GetXTransferable().is() |
366 | 0 | && SwTransferable::IsPaste( rSh, aDataHelper ) ) |
367 | 0 | { |
368 | | // Temporary variables, because the shell could already be |
369 | | // destroyed after the paste. |
370 | 0 | SwView* pView = &m_rView; |
371 | |
|
372 | 0 | RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA; |
373 | 0 | const SfxUInt16Item* pAnchorType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1); |
374 | 0 | if (pAnchorType) |
375 | 0 | nAnchorType = static_cast<RndStdIds>(pAnchorType->GetValue()); |
376 | 0 | bool bIgnoreComments = false; |
377 | 0 | const SfxBoolItem* pIgnoreComments = rReq.GetArg<SfxBoolItem>(FN_PARAM_2); |
378 | 0 | if (pIgnoreComments) |
379 | 0 | bIgnoreComments = pIgnoreComments->GetValue(); |
380 | 0 | SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments, ePasteTable, true); |
381 | |
|
382 | 0 | if( rSh.IsFrameSelected() || rSh.GetSelectedObjCount() ) |
383 | 0 | rSh.EnterSelFrameMode(); |
384 | 0 | pView->AttrChangedNotify(nullptr); |
385 | | |
386 | | // Fold pasted outlines that have outline content visible attribute false |
387 | 0 | MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc()); |
388 | 0 | } |
389 | 0 | else |
390 | 0 | return; |
391 | 0 | } |
392 | 0 | break; |
393 | | |
394 | 0 | case SID_CLIPBOARD_FORMAT_ITEMS: |
395 | 0 | { |
396 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
397 | 0 | const SfxPoolItem* pFormat; |
398 | 0 | if( pArgs && SfxItemState::SET == pArgs->GetItemState( nId, false, &pFormat ) ) |
399 | 0 | { |
400 | 0 | TransferableDataHelper aDataHelper( |
401 | 0 | TransferableDataHelper::CreateFromSystemClipboard( |
402 | 0 | &rSh.GetView().GetEditWin()) ); |
403 | 0 | if( aDataHelper.GetXTransferable().is() |
404 | 0 | /*&& SwTransferable::IsPaste( rSh, aDataHelper )*/ ) |
405 | 0 | { |
406 | | // Temporary variables, because the shell could already be |
407 | | // destroyed after the paste. |
408 | 0 | SwView* pView = &m_rView; |
409 | |
|
410 | 0 | SwTransferable::PasteFormat( rSh, aDataHelper, |
411 | 0 | static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pFormat)->GetValue()) ); |
412 | | |
413 | | //Done() has to be called before the shell has been removed |
414 | 0 | rReq.Done(); |
415 | 0 | bIgnore = true; |
416 | 0 | if( rSh.IsFrameSelected() || rSh.GetSelectedObjCount()) |
417 | 0 | rSh.EnterSelFrameMode(); |
418 | 0 | pView->AttrChangedNotify(nullptr); |
419 | | |
420 | | // Fold pasted outlines that have outline content visible attribute false |
421 | 0 | MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc()); |
422 | 0 | } |
423 | 0 | } |
424 | 0 | } |
425 | 0 | break; |
426 | | |
427 | 0 | case SID_PASTE_UNFORMATTED: |
428 | 0 | { |
429 | 0 | TransferableDataHelper aDataHelper( |
430 | 0 | TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()) ); |
431 | 0 | if( aDataHelper.GetXTransferable().is() |
432 | 0 | && SwTransferable::IsPaste( rSh, aDataHelper ) ) |
433 | 0 | { |
434 | | // Temporary variables, because the shell could already be |
435 | | // destroyed after the paste. |
436 | 0 | SwView* pView = &m_rView; |
437 | 0 | rReq.Ignore(); |
438 | 0 | bIgnore = true; |
439 | 0 | if(SwTransferable::PasteUnformatted( rSh, aDataHelper )) |
440 | 0 | { |
441 | 0 | SfxViewFrame& rViewFrame = pView->GetViewFrame(); |
442 | 0 | uno::Reference< frame::XDispatchRecorder > xRecorder = |
443 | 0 | rViewFrame.GetBindings().GetRecorder(); |
444 | 0 | if(xRecorder.is()) { |
445 | 0 | SfxRequest aReq(rViewFrame, SID_CLIPBOARD_FORMAT_ITEMS); |
446 | 0 | aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(SotClipboardFormatId::STRING) ) ); |
447 | 0 | aReq.Done(); |
448 | 0 | } |
449 | 0 | } |
450 | |
|
451 | 0 | if (rSh.IsFrameSelected() || rSh.GetSelectedObjCount()) |
452 | 0 | rSh.EnterSelFrameMode(); |
453 | 0 | pView->AttrChangedNotify(nullptr); |
454 | | |
455 | | // Fold pasted outlines that have outline content visible attribute false |
456 | 0 | MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc()); |
457 | 0 | } |
458 | 0 | else |
459 | 0 | return; |
460 | 0 | } |
461 | 0 | break; |
462 | | |
463 | 0 | case SID_PASTE_SPECIAL: |
464 | 0 | { |
465 | 0 | std::shared_ptr<const TransferableDataHelper> aDataHelper = |
466 | 0 | std::make_shared<TransferableDataHelper>(TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin())); |
467 | |
|
468 | 0 | if( aDataHelper->GetXTransferable().is() |
469 | 0 | && SwTransferable::IsPaste( rSh, *aDataHelper ) |
470 | 0 | && !rSh.CursorInsideInputField() ) |
471 | 0 | { |
472 | 0 | rReq.Ignore(); |
473 | 0 | bIgnore = true; |
474 | |
|
475 | 0 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
476 | 0 | VclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( rReq.GetFrameWeld() )); |
477 | | |
478 | | // Prepare the dialog |
479 | 0 | SwTransferable::PrePasteSpecial(rSh, *aDataHelper, pDlg); |
480 | 0 | pDlg->PreGetFormat(*aDataHelper); |
481 | | |
482 | |
|
483 | 0 | pDlg->StartExecuteAsync( |
484 | 0 | [aDataHelper=std::move(aDataHelper), pDlg, &rSh, this](sal_Int32 nResult) |
485 | 0 | { |
486 | 0 | if (nResult == RET_OK) |
487 | 0 | { |
488 | | // Temporary variables, because the shell could already be |
489 | | // destroyed after the paste. |
490 | 0 | SwView* pView = &m_rView; |
491 | 0 | bool bRet = false; |
492 | 0 | SotClipboardFormatId nFormatId = pDlg->GetFormatOnly(); |
493 | |
|
494 | 0 | if( nFormatId != SotClipboardFormatId::NONE ) |
495 | 0 | bRet = SwTransferable::PasteFormat( rSh, *aDataHelper, nFormatId ); |
496 | |
|
497 | 0 | if (bRet) |
498 | 0 | { |
499 | 0 | SfxViewFrame& rViewFrame = pView->GetViewFrame(); |
500 | 0 | uno::Reference< frame::XDispatchRecorder > xRecorder = |
501 | 0 | rViewFrame.GetBindings().GetRecorder(); |
502 | 0 | if(xRecorder.is()) { |
503 | 0 | SfxRequest aReq(rViewFrame, SID_CLIPBOARD_FORMAT_ITEMS); |
504 | 0 | aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS, static_cast<sal_uInt32>(nFormatId) ) ); |
505 | 0 | aReq.Done(); |
506 | 0 | } |
507 | 0 | } |
508 | |
|
509 | 0 | if (rSh.IsFrameSelected() || rSh.GetSelectedObjCount()) |
510 | 0 | rSh.EnterSelFrameMode(); |
511 | 0 | pView->AttrChangedNotify(nullptr); |
512 | | |
513 | | // Fold pasted outlines that have outline content visible attribute false |
514 | 0 | MakeAllOutlineContentTemporarilyVisible a(rSh.GetDoc()); |
515 | 0 | } |
516 | |
|
517 | 0 | pDlg->disposeOnce(); |
518 | 0 | } |
519 | 0 | ); |
520 | 0 | } |
521 | 0 | else |
522 | 0 | return; |
523 | 0 | } |
524 | 0 | break; |
525 | | |
526 | 0 | default: |
527 | 0 | OSL_FAIL("wrong Dispatcher"); |
528 | 0 | return; |
529 | 0 | } |
530 | 0 | if(!bIgnore) |
531 | 0 | rReq.Done(); |
532 | 0 | } |
533 | | |
534 | | // ClipBoard state |
535 | | |
536 | | void SwBaseShell::StateClpbrd(SfxItemSet &rSet) |
537 | 0 | { |
538 | 0 | SwWrtShell &rSh = GetShell(); |
539 | 0 | SfxWhichIter aIter(rSet); |
540 | |
|
541 | 0 | const bool bCopy = rSh.HasSelection(); |
542 | |
|
543 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
544 | |
|
545 | 0 | while(nWhich) |
546 | 0 | { |
547 | 0 | switch(nWhich) |
548 | 0 | { |
549 | 0 | case SID_CUT: |
550 | 0 | if( FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent ) ) |
551 | 0 | { |
552 | 0 | rSet.DisableItem( nWhich ); |
553 | 0 | break; |
554 | 0 | } |
555 | 0 | [[fallthrough]]; |
556 | 0 | case SID_COPY: |
557 | 0 | if( !bCopy || GetObjectShell()->isContentExtractionLocked()) |
558 | 0 | rSet.DisableItem( nWhich ); |
559 | 0 | break; |
560 | | |
561 | 0 | case FN_PASTE_NESTED_TABLE: |
562 | 0 | case FN_TABLE_PASTE_ROW_BEFORE: |
563 | 0 | case FN_TABLE_PASTE_COL_BEFORE: |
564 | 0 | if( !rSh.IsCursorInTable() |
565 | 0 | || !GetView().IsPasteSpecialAllowed() |
566 | 0 | || rSh.CursorInsideInputField() |
567 | | // disable if not a native Writer table and not a spreadsheet format |
568 | 0 | || !GetView().IsPasteSpreadsheet(rSh.GetTableCopied()) ) |
569 | 0 | { |
570 | 0 | rSet.DisableItem( nWhich ); |
571 | 0 | } |
572 | 0 | break; |
573 | | |
574 | 0 | case SID_PASTE: |
575 | 0 | if( !GetView().IsPasteAllowed() ) |
576 | 0 | { |
577 | 0 | rSet.DisableItem( nWhich ); |
578 | 0 | } |
579 | 0 | break; |
580 | | |
581 | 0 | case SID_PASTE_SPECIAL: |
582 | 0 | if( !GetView().IsPasteSpecialAllowed() |
583 | 0 | || rSh.CursorInsideInputField() ) |
584 | 0 | { |
585 | 0 | rSet.DisableItem( nWhich ); |
586 | 0 | } |
587 | 0 | break; |
588 | | |
589 | 0 | case SID_PASTE_UNFORMATTED: |
590 | 0 | if( !GetView().IsPasteSpecialAllowed() ) |
591 | 0 | { |
592 | 0 | rSet.DisableItem( nWhich ); |
593 | 0 | } |
594 | 0 | break; |
595 | | |
596 | 0 | case SID_CLIPBOARD_FORMAT_ITEMS: |
597 | 0 | { |
598 | 0 | TransferableDataHelper aDataHelper( |
599 | 0 | TransferableDataHelper::CreateFromSystemClipboard( |
600 | 0 | &rSh.GetView().GetEditWin()) ); |
601 | |
|
602 | 0 | SvxClipboardFormatItem aFormatItem( SID_CLIPBOARD_FORMAT_ITEMS ); |
603 | 0 | SwTransferable::FillClipFormatItem( rSh, aDataHelper, aFormatItem ); |
604 | 0 | rSet.Put( aFormatItem ); |
605 | 0 | } |
606 | 0 | break; |
607 | 0 | } |
608 | 0 | nWhich = aIter.NextWhich(); |
609 | 0 | } |
610 | 0 | } |
611 | | |
612 | | // Perform undo |
613 | | |
614 | | void SwBaseShell::ExecUndo(SfxRequest &rReq) |
615 | 0 | { |
616 | 0 | MakeAllOutlineContentTemporarilyVisible a(GetShell().GetDoc(), true); |
617 | |
|
618 | 0 | SwWrtShell &rWrtShell = GetShell(); |
619 | |
|
620 | 0 | SwUndoId nUndoId(SwUndoId::EMPTY); |
621 | 0 | sal_uInt16 nId = rReq.GetSlot(), nCnt = 1; |
622 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
623 | 0 | const SfxPoolItem* pItem; |
624 | 0 | if( pArgs && SfxItemState::SET == pArgs->GetItemState( nId, false, &pItem )) |
625 | 0 | nCnt = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); |
626 | | |
627 | | // Repair mode: allow undo/redo of all undo actions, even if access would |
628 | | // be limited based on the view shell ID. |
629 | 0 | bool bRepair = false; |
630 | 0 | const SfxBoolItem* pRepairItem; |
631 | 0 | if (pArgs && (pRepairItem = pArgs->GetItemIfSet(SID_REPAIRPACKAGE, false))) |
632 | 0 | bRepair = pRepairItem->GetValue(); |
633 | | |
634 | | // #i106349#: save pointer: undo/redo may delete the shell, i.e., this! |
635 | 0 | SfxViewFrame& rViewFrame( GetView().GetViewFrame() ); |
636 | |
|
637 | 0 | IDocumentUndoRedo& rUndoRedo = rWrtShell.GetIDocumentUndoRedo(); |
638 | 0 | bool bWasRepair = rUndoRedo.DoesRepair(); |
639 | 0 | rUndoRedo.DoRepair(bRepair); |
640 | 0 | comphelper::ScopeGuard aGuard([&rUndoRedo, bWasRepair]() |
641 | 0 | { |
642 | 0 | rUndoRedo.DoRepair(bWasRepair); |
643 | 0 | }); |
644 | |
|
645 | 0 | switch( nId ) |
646 | 0 | { |
647 | 0 | case SID_UNDO: |
648 | 0 | if (rUndoRedo.GetLastUndoInfo(nullptr, &nUndoId, &rWrtShell.GetView())) |
649 | 0 | { |
650 | 0 | for (SwViewShell& rShell : rWrtShell.GetRingContainer()) |
651 | 0 | rShell.LockPaint(LockPaintReason::Undo); |
652 | |
|
653 | 0 | sal_uInt16 nUndoOffset = 0; |
654 | 0 | if (comphelper::LibreOfficeKit::isActive() && !bRepair && nCnt == 1) |
655 | 0 | { |
656 | 0 | sw::UndoManager& rManager = rWrtShell.GetDoc()->GetUndoManager(); |
657 | 0 | const SfxUndoAction* pAction = rManager.GetUndoAction(); |
658 | 0 | SwView& rView = rWrtShell.GetView(); |
659 | 0 | ViewShellId nViewShellId = rView.GetViewShellId(); |
660 | 0 | sal_uInt16 nOffset = 0; |
661 | 0 | if (pAction->GetViewShellId() != nViewShellId |
662 | 0 | && rManager.IsViewUndoActionIndependent(&rView, nOffset)) |
663 | 0 | { |
664 | | // Execute the undo with an offset: don't undo the top action, but an |
665 | | // earlier one, since it's independent and that belongs to our view. |
666 | 0 | nUndoOffset += nOffset; |
667 | 0 | } |
668 | 0 | } |
669 | |
|
670 | 0 | rWrtShell.Do(SwWrtShell::UNDO, nCnt, nUndoOffset); |
671 | |
|
672 | 0 | for (SwViewShell& rShell : rWrtShell.GetRingContainer()) |
673 | 0 | rShell.UnlockPaint(); |
674 | 0 | } |
675 | 0 | break; |
676 | | |
677 | 0 | case SID_REDO: |
678 | 0 | if (rUndoRedo.GetFirstRedoInfo(nullptr, &nUndoId, &rWrtShell.GetView())) |
679 | 0 | { |
680 | 0 | for (SwViewShell& rShell : rWrtShell.GetRingContainer()) |
681 | 0 | rShell.LockPaint(LockPaintReason::Redo); |
682 | 0 | rWrtShell.Do( SwWrtShell::REDO, nCnt ); |
683 | 0 | for (SwViewShell& rShell : rWrtShell.GetRingContainer()) |
684 | 0 | rShell.UnlockPaint(); |
685 | 0 | } |
686 | 0 | break; |
687 | | |
688 | 0 | case SID_REPEAT: |
689 | 0 | rWrtShell.Do( SwWrtShell::REPEAT ); |
690 | 0 | break; |
691 | 0 | default: |
692 | 0 | OSL_FAIL("wrong Dispatcher"); |
693 | 0 | } |
694 | | |
695 | 0 | if (nUndoId == SwUndoId::CONFLICT) |
696 | 0 | { |
697 | 0 | rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)) ); |
698 | 0 | } |
699 | |
|
700 | 0 | rViewFrame.GetBindings().InvalidateAll(false); |
701 | 0 | } |
702 | | |
703 | | // State of undo |
704 | | |
705 | | void SwBaseShell::StateUndo(SfxItemSet &rSet) |
706 | 0 | { |
707 | 0 | SwUndoId nUndoId(SwUndoId::EMPTY); |
708 | 0 | SwWrtShell &rSh = GetShell(); |
709 | 0 | SfxWhichIter aIter(rSet); |
710 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
711 | 0 | while(nWhich) |
712 | 0 | { |
713 | 0 | switch(nWhich) |
714 | 0 | { |
715 | 0 | case SID_UNDO: |
716 | 0 | { |
717 | 0 | if (rSh.GetLastUndoInfo(nullptr, &nUndoId, &rSh.GetView())) |
718 | 0 | { |
719 | 0 | rSet.Put( SfxStringItem(nWhich, |
720 | 0 | rSh.GetDoString(SwWrtShell::UNDO))); |
721 | 0 | } |
722 | 0 | else if (nUndoId == SwUndoId::CONFLICT) |
723 | 0 | { |
724 | 0 | rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)) ); |
725 | 0 | } |
726 | 0 | else |
727 | 0 | rSet.DisableItem(nWhich); |
728 | |
|
729 | 0 | break; |
730 | 0 | } |
731 | 0 | case SID_REDO: |
732 | 0 | { |
733 | 0 | if (rSh.GetFirstRedoInfo(nullptr, &nUndoId, &rSh.GetView())) |
734 | 0 | { |
735 | 0 | rSet.Put(SfxStringItem(nWhich, |
736 | 0 | rSh.GetDoString(SwWrtShell::REDO))); |
737 | 0 | } |
738 | 0 | else if (nUndoId == SwUndoId::CONFLICT) |
739 | 0 | { |
740 | 0 | rSet.Put( SfxInt32Item(nWhich, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)) ); |
741 | 0 | } |
742 | 0 | else |
743 | 0 | rSet.DisableItem(nWhich); |
744 | 0 | break; |
745 | 0 | } |
746 | 0 | case SID_REPEAT: |
747 | 0 | { // Repeat is only possible if no REDO is possible - UI-Restriction |
748 | 0 | if ((!rSh.GetFirstRedoInfo(nullptr, nullptr)) && |
749 | 0 | !rSh.IsSelFrameMode() && |
750 | 0 | (SwUndoId::EMPTY != rSh.GetRepeatInfo(nullptr))) |
751 | 0 | { |
752 | 0 | rSet.Put(SfxStringItem(nWhich, rSh.GetRepeatString())); |
753 | 0 | } |
754 | 0 | else |
755 | 0 | rSet.DisableItem(nWhich); |
756 | 0 | break; |
757 | 0 | } |
758 | | |
759 | 0 | case SID_GETUNDOSTRINGS: |
760 | 0 | if (rSh.GetLastUndoInfo(nullptr, nullptr)) |
761 | 0 | { |
762 | 0 | SfxStringListItem aStrLst( nWhich ); |
763 | 0 | rSh.GetDoStrings( SwWrtShell::UNDO, aStrLst ); |
764 | 0 | rSet.Put( aStrLst ); |
765 | 0 | } |
766 | 0 | else |
767 | 0 | rSet.DisableItem( nWhich ); |
768 | 0 | break; |
769 | | |
770 | 0 | case SID_GETREDOSTRINGS: |
771 | 0 | if (rSh.GetFirstRedoInfo(nullptr, nullptr)) |
772 | 0 | { |
773 | 0 | SfxStringListItem aStrLst( nWhich ); |
774 | 0 | rSh.GetDoStrings( SwWrtShell::REDO, aStrLst ); |
775 | 0 | rSet.Put( aStrLst ); |
776 | 0 | } |
777 | 0 | else |
778 | 0 | rSet.DisableItem( nWhich ); |
779 | 0 | break; |
780 | 0 | } |
781 | 0 | nWhich = aIter.NextWhich(); |
782 | 0 | } |
783 | 0 | } |
784 | | |
785 | | namespace |
786 | | { |
787 | | /// Searches for the specified field type and field name prefix and update the matching fields to |
788 | | /// have the provided new name and content. |
789 | | bool UpdateFieldContents(const SfxRequest& rReq, SwWrtShell& rWrtSh) |
790 | 0 | { |
791 | 0 | const SfxStringItem* pTypeName = rReq.GetArg<SfxStringItem>(FN_PARAM_1); |
792 | 0 | if (!pTypeName || pTypeName->GetValue() != "SetRef") |
793 | 0 | { |
794 | | // This is implemented so far only for reference marks. |
795 | 0 | return false; |
796 | 0 | } |
797 | | |
798 | 0 | const SfxStringItem* pNamePrefix = rReq.GetArg<SfxStringItem>(FN_PARAM_2); |
799 | 0 | if (!pNamePrefix) |
800 | 0 | { |
801 | 0 | return false; |
802 | 0 | } |
803 | 0 | const OUString& rNamePrefix = pNamePrefix->GetValue(); |
804 | |
|
805 | 0 | const SfxUnoAnyItem* pFields = rReq.GetArg<SfxUnoAnyItem>(FN_PARAM_3); |
806 | 0 | if (!pFields) |
807 | 0 | { |
808 | 0 | return false; |
809 | 0 | } |
810 | | |
811 | 0 | bool bNeverExpand = false; |
812 | 0 | const SfxBoolItem* pNeverExpand = rReq.GetArg<SfxBoolItem>(FN_PARAM_6); |
813 | 0 | if (pNeverExpand) |
814 | 0 | { |
815 | 0 | bNeverExpand = pNeverExpand->GetValue(); |
816 | 0 | } |
817 | 0 | uno::Sequence<beans::PropertyValues> aFields; |
818 | 0 | pFields->GetValue() >>= aFields; |
819 | |
|
820 | 0 | SwDoc* pDoc = rWrtSh.GetDoc(); |
821 | 0 | pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_FIELDS, nullptr); |
822 | 0 | rWrtSh.StartAction(); |
823 | |
|
824 | 0 | std::vector<const SwFormatRefMark*> aRefMarks; |
825 | 0 | pDoc->GetRefMarks(aRefMarks); |
826 | |
|
827 | 0 | std::sort(aRefMarks.begin(), aRefMarks.end(), |
828 | 0 | [](const SwFormatRefMark* pMark1, const SwFormatRefMark* pMark2) -> bool { |
829 | 0 | const SwTextRefMark* pTextRefMark1 = pMark1->GetTextRefMark(); |
830 | 0 | const SwTextRefMark* pTextRefMark2 = pMark2->GetTextRefMark(); |
831 | 0 | SwPosition aPos1(pTextRefMark1->GetTextNode(), pTextRefMark1->GetStart()); |
832 | 0 | SwPosition aPos2(pTextRefMark2->GetTextNode(), pTextRefMark2->GetStart()); |
833 | 0 | return aPos1 < aPos2; |
834 | 0 | }); |
835 | |
|
836 | 0 | sal_uInt16 nFieldIndex = 0; |
837 | 0 | for (auto& pIntermediateRefMark : aRefMarks) |
838 | 0 | { |
839 | 0 | auto pRefMark = const_cast<SwFormatRefMark*>(pIntermediateRefMark); |
840 | 0 | if (!pRefMark->GetRefName().toString().startsWith(rNamePrefix)) |
841 | 0 | { |
842 | 0 | continue; |
843 | 0 | } |
844 | | |
845 | 0 | auto pTextRefMark = const_cast<SwTextRefMark*>(pRefMark->GetTextRefMark()); |
846 | 0 | if (bNeverExpand) |
847 | 0 | { |
848 | 0 | pTextRefMark->SetDontExpand(true); |
849 | 0 | pTextRefMark->SetLockExpandFlag(true); |
850 | 0 | pTextRefMark->SetDontExpandStartAttr(true); |
851 | 0 | } |
852 | |
|
853 | 0 | if (nFieldIndex >= aFields.getLength()) |
854 | 0 | { |
855 | | // earlier we used to break here |
856 | | // but now we need to set expand flags for each refmark |
857 | 0 | continue; |
858 | 0 | } |
859 | 0 | comphelper::SequenceAsHashMap aMap(aFields[nFieldIndex++]); |
860 | 0 | pRefMark->GetRefName() = SwMarkName(aMap[u"Name"_ustr].get<OUString>()); |
861 | |
|
862 | 0 | pTextRefMark->UpdateFieldContent(pDoc, rWrtSh, aMap[u"Content"_ustr].get<OUString>()); |
863 | 0 | } |
864 | |
|
865 | 0 | rWrtSh.EndAction(); |
866 | 0 | pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_FIELDS, nullptr); |
867 | 0 | return true; |
868 | 0 | } |
869 | | |
870 | | /// Searches for the specified field type and field name prefix under cursor and update the matching |
871 | | /// field to have the provided new name and content. |
872 | | void UpdateFieldContent(const SfxRequest& rReq, SwWrtShell& rWrtSh) |
873 | 0 | { |
874 | 0 | const SfxStringItem* pTypeName = rReq.GetArg<SfxStringItem>(FN_PARAM_1); |
875 | 0 | if (!pTypeName || pTypeName->GetValue() != "SetRef") |
876 | 0 | { |
877 | | // This is implemented so far only for reference marks. |
878 | 0 | return; |
879 | 0 | } |
880 | | |
881 | 0 | const SfxStringItem* pNamePrefix = rReq.GetArg<SfxStringItem>(FN_PARAM_2); |
882 | 0 | if (!pNamePrefix) |
883 | 0 | { |
884 | 0 | return; |
885 | 0 | } |
886 | 0 | const OUString& rNamePrefix = pNamePrefix->GetValue(); |
887 | |
|
888 | 0 | const SfxUnoAnyItem* pField = rReq.GetArg<SfxUnoAnyItem>(FN_PARAM_3); |
889 | 0 | if (!pField) |
890 | 0 | { |
891 | 0 | return; |
892 | 0 | } |
893 | 0 | uno::Sequence<beans::PropertyValue> aField; |
894 | 0 | pField->GetValue() >>= aField; |
895 | |
|
896 | 0 | SwPosition& rCursor = *rWrtSh.GetCursor()->GetPoint(); |
897 | 0 | SwTextNode* pTextNode = rCursor.GetNode().GetTextNode(); |
898 | 0 | std::vector<SwTextAttr*> aAttrs |
899 | 0 | = pTextNode->GetTextAttrsAt(rCursor.GetContentIndex(), RES_TXTATR_REFMARK); |
900 | 0 | if (aAttrs.empty()) |
901 | 0 | { |
902 | 0 | return; |
903 | 0 | } |
904 | | |
905 | 0 | auto& rRefmark = const_cast<SwFormatRefMark&>(aAttrs[0]->GetRefMark()); |
906 | 0 | if (!rRefmark.GetRefName().toString().startsWith(rNamePrefix)) |
907 | 0 | { |
908 | 0 | return; |
909 | 0 | } |
910 | | |
911 | 0 | SwDoc* pDoc = rWrtSh.GetDoc(); |
912 | 0 | SwRewriter aRewriter; |
913 | 0 | aRewriter.AddRule(UndoArg1, rRefmark.GetRefName()); |
914 | 0 | pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::UPDATE_FIELD, &aRewriter); |
915 | 0 | rWrtSh.StartAction(); |
916 | 0 | comphelper::ScopeGuard g( |
917 | 0 | [&rWrtSh, &aRewriter] |
918 | 0 | { |
919 | 0 | rWrtSh.EndAction(); |
920 | 0 | rWrtSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::UPDATE_FIELD, &aRewriter); |
921 | 0 | }); |
922 | |
|
923 | 0 | comphelper::SequenceAsHashMap aMap(aField); |
924 | 0 | rRefmark.GetRefName() = SwMarkName(aMap[u"Name"_ustr].get<OUString>()); |
925 | |
|
926 | 0 | OUString aContent = aMap[u"Content"_ustr].get<OUString>(); |
927 | 0 | auto pTextRefMark = const_cast<SwTextRefMark*>(rRefmark.GetTextRefMark()); |
928 | 0 | pTextRefMark->UpdateFieldContent(pDoc, rWrtSh, aContent); |
929 | 0 | } |
930 | | } |
931 | | |
932 | | // Evaluate respectively dispatching the slot Id |
933 | | |
934 | | void SwBaseShell::Execute(SfxRequest &rReq) |
935 | 0 | { |
936 | 0 | const SfxPoolItem *pItem; |
937 | 0 | SwWrtShell &rSh = GetShell(); |
938 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
939 | 0 | bool bMore = false; |
940 | |
|
941 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
942 | 0 | switch(nSlot) |
943 | 0 | { |
944 | 0 | case FN_REPAGINATE: |
945 | 0 | { |
946 | 0 | Reference < XModel > xModel = GetView().GetDocShell()->GetModel(); |
947 | 0 | auto pDoc = comphelper::getFromUnoTunnel<SwXTextDocument>(xModel); |
948 | 0 | pDoc->NotifyRefreshListeners(); |
949 | 0 | rSh.CalcLayout(); |
950 | 0 | } |
951 | 0 | break; |
952 | 0 | case FN_UPDATE_FIELDS: |
953 | 0 | { |
954 | 0 | if (UpdateFieldContents(rReq, rSh)) |
955 | 0 | { |
956 | | // Parameters indicated that the name / content of fields has to be updated to |
957 | | // the provided values, don't do an actual fields update. |
958 | 0 | break; |
959 | 0 | } |
960 | | |
961 | 0 | rSh.UpdateDocStat(); |
962 | 0 | rSh.EndAllTableBoxEdit(); |
963 | 0 | rSh.SwViewShell::UpdateFields(true); |
964 | |
|
965 | 0 | if( rSh.IsCursorInTable() ) |
966 | 0 | { |
967 | 0 | if( !rSh.IsTableComplexForChart() ) |
968 | 0 | SwTableFUNC( &rSh ).UpdateChart(); |
969 | 0 | rSh.ClearTableBoxContent(); |
970 | 0 | rSh.SaveTableBoxContent(); |
971 | 0 | } |
972 | 0 | } |
973 | 0 | break; |
974 | 0 | case FN_UPDATE_FIELD: |
975 | 0 | { |
976 | 0 | UpdateFieldContent(rReq, rSh); |
977 | 0 | } |
978 | 0 | break; |
979 | 0 | case FN_UPDATE_CHARTS: |
980 | 0 | { |
981 | 0 | SwWait aWait( *m_rView.GetDocShell(), true ); |
982 | 0 | rSh.UpdateAllCharts(); |
983 | 0 | } |
984 | 0 | break; |
985 | | |
986 | 0 | case FN_UPDATE_ALL: |
987 | 0 | { |
988 | 0 | comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer |
989 | 0 | = GetObjectShell()->getEmbeddedObjectContainer(); |
990 | 0 | rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true); |
991 | |
|
992 | 0 | SwView& rTempView = GetView(); |
993 | 0 | rSh.EnterStdMode(); |
994 | 0 | if( !rSh.GetLinkManager().GetLinks().empty() ) |
995 | 0 | { |
996 | 0 | rSh.StartAllAction(); |
997 | 0 | SfxMedium * medium = nullptr; |
998 | 0 | if (auto const sh = rSh.GetDoc()->GetDocShell()) { |
999 | 0 | medium = sh->GetMedium(); |
1000 | 0 | } |
1001 | 0 | rSh.GetLinkManager().UpdateAllLinks( |
1002 | 0 | false, true, nullptr, medium == nullptr ? OUString() : medium->GetName() ); |
1003 | 0 | rSh.EndAllAction(); |
1004 | 0 | } |
1005 | 0 | SfxDispatcher &rDis = *rTempView.GetViewFrame().GetDispatcher(); |
1006 | 0 | rDis.Execute( FN_UPDATE_FIELDS ); |
1007 | 0 | rDis.Execute( FN_UPDATE_TOX ); |
1008 | 0 | rDis.Execute( FN_UPDATE_CHARTS ); |
1009 | 0 | rSh.Reformat(); |
1010 | 0 | rSh.UpdateOleObjectPreviews(); |
1011 | 0 | } |
1012 | 0 | break; |
1013 | | |
1014 | 0 | case FN_UPDATE_INPUTFIELDS: |
1015 | 0 | rSh.UpdateInputFields(); |
1016 | 0 | break; |
1017 | | |
1018 | 0 | case FN_PREV_BOOKMARK: |
1019 | 0 | rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoPrevBookmark())); |
1020 | 0 | break; |
1021 | 0 | case FN_NEXT_BOOKMARK: |
1022 | 0 | rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoNextBookmark())); |
1023 | 0 | break; |
1024 | | |
1025 | 0 | case FN_GOTO_NEXT_MARK: |
1026 | 0 | case FN_GOTO_PREV_MARK: |
1027 | 0 | { |
1028 | 0 | SwFieldMgr aFieldMgr; |
1029 | 0 | SwFieldType* pFieldType = aFieldMgr.GetFieldType(SwFieldIds::JumpEdit); |
1030 | |
|
1031 | 0 | if (pFieldType) |
1032 | 0 | { |
1033 | 0 | if (rSh.IsSelFrameMode()) |
1034 | 0 | { |
1035 | 0 | rSh.UnSelectFrame(); |
1036 | 0 | rSh.LeaveSelFrameMode(); |
1037 | 0 | } |
1038 | |
|
1039 | 0 | if (rSh.HasMark()) |
1040 | 0 | { |
1041 | 0 | SwMvContext aMvContext(&rSh); |
1042 | 0 | if (rSh.IsCursorPtAtEnd()) |
1043 | 0 | rSh.SwapPam(); |
1044 | 0 | rSh.ClearMark(); |
1045 | 0 | rSh.EndSelect(); |
1046 | 0 | } |
1047 | 0 | bool bRet = rSh.MoveFieldType( pFieldType, nSlot == FN_GOTO_NEXT_MARK ); |
1048 | 0 | SwField* pCurField = bRet ? rSh.GetCurField() : nullptr; |
1049 | 0 | if (pCurField) |
1050 | 0 | rSh.ClickToField(*pCurField, /*bExecHyperlinks=*/false); |
1051 | 0 | rReq.SetReturnValue(SfxBoolItem( nSlot, bRet)); |
1052 | 0 | } |
1053 | 0 | } |
1054 | 0 | break; |
1055 | | |
1056 | 0 | case FN_START_DOC_DIRECT: |
1057 | 0 | case FN_END_DOC_DIRECT: |
1058 | 0 | { |
1059 | 0 | if (rSh.IsSelFrameMode()) |
1060 | 0 | { |
1061 | 0 | rSh.UnSelectFrame(); |
1062 | 0 | rSh.LeaveSelFrameMode(); |
1063 | 0 | } |
1064 | 0 | rSh.EnterStdMode(); |
1065 | 0 | nSlot == FN_START_DOC_DIRECT ? |
1066 | 0 | rSh.SttEndDoc(true) : |
1067 | 0 | rSh.SttEndDoc(false); |
1068 | 0 | } |
1069 | 0 | break; |
1070 | 0 | case FN_GOTO_PREV_OBJ: |
1071 | 0 | case FN_GOTO_NEXT_OBJ: |
1072 | 0 | { |
1073 | 0 | bool bSuccess = rSh.GotoObj( nSlot == FN_GOTO_NEXT_OBJ ); |
1074 | 0 | rReq.SetReturnValue(SfxBoolItem(nSlot, bSuccess)); |
1075 | 0 | if (bSuccess && !rSh.IsSelFrameMode()) |
1076 | 0 | { |
1077 | 0 | rSh.HideCursor(); |
1078 | 0 | rSh.EnterSelFrameMode(); |
1079 | 0 | GetView().AttrChangedNotify(nullptr); |
1080 | 0 | } |
1081 | 0 | } |
1082 | 0 | break; |
1083 | 0 | case SID_GALLERY_FORMATS: |
1084 | 0 | { |
1085 | 0 | const SvxGalleryItem* pGalleryItem = SfxItemSet::GetItem<SvxGalleryItem>(pArgs, SID_GALLERY_FORMATS, false); |
1086 | 0 | if ( !pGalleryItem ) |
1087 | 0 | break; |
1088 | | |
1089 | 0 | const SelectionType nSelType = rSh.GetSelectionType(); |
1090 | 0 | sal_Int8 nGalleryItemType( pGalleryItem->GetType() ); |
1091 | |
|
1092 | 0 | if ( (!rSh.IsSelFrameMode() || nSelType & SelectionType::Graphic) && |
1093 | 0 | nGalleryItemType == css::gallery::GalleryItemType::GRAPHIC ) |
1094 | 0 | { |
1095 | 0 | SwWait aWait( *m_rView.GetDocShell(), true ); |
1096 | |
|
1097 | 0 | OUString aGrfName, aFltName; |
1098 | 0 | const Graphic aGrf( pGalleryItem->GetGraphic() ); |
1099 | |
|
1100 | 0 | if ( nSelType & SelectionType::Graphic ) |
1101 | 0 | rSh.ReRead( aGrfName, aFltName, &aGrf ); |
1102 | 0 | else |
1103 | 0 | rSh.InsertGraphic( aGrfName, aFltName, aGrf ); |
1104 | |
|
1105 | 0 | GetView().GetEditWin().GrabFocus(); |
1106 | 0 | } |
1107 | 0 | else if(!rSh.IsSelFrameMode() && |
1108 | 0 | nGalleryItemType == css::gallery::GalleryItemType::MEDIA ) |
1109 | 0 | { |
1110 | 0 | const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGalleryItem->GetURL() ); |
1111 | 0 | GetView().GetViewFrame().GetDispatcher()->ExecuteList( |
1112 | 0 | SID_INSERT_AVMEDIA, SfxCallMode::SYNCHRON, |
1113 | 0 | { &aMediaURLItem }); |
1114 | 0 | } |
1115 | 0 | } |
1116 | 0 | break; |
1117 | 0 | case FN_PAGE_STYLE_SET_COLS: |
1118 | 0 | { |
1119 | 0 | if (pArgs) |
1120 | 0 | { |
1121 | | // Determine the current PageDescriptor and fill the set with that. |
1122 | 0 | const size_t nCurIdx = rSh.GetCurPageDesc(); |
1123 | 0 | SwPageDesc aPageDesc(rSh.GetPageDesc(nCurIdx)); |
1124 | |
|
1125 | 0 | SwFrameFormat &rFormat = aPageDesc.GetMaster(); |
1126 | |
|
1127 | 0 | SwFormatCol aFormatCol = rFormat.GetCol(); |
1128 | |
|
1129 | 0 | sal_uInt16 nCount; |
1130 | 0 | if(SfxItemState::SET == pArgs->GetItemState(nSlot)) |
1131 | 0 | nCount = static_cast<const SfxUInt16Item &>(pArgs->Get(nSlot)).GetValue(); |
1132 | 0 | else |
1133 | 0 | nCount = pArgs->Get(SID_ATTR_COLUMNS).GetValue(); |
1134 | 0 | sal_uInt16 nGutterWidth = DEF_GUTTER_WIDTH; |
1135 | |
|
1136 | 0 | aFormatCol.Init(nCount ? nCount : 1, nGutterWidth, USHRT_MAX); |
1137 | 0 | aFormatCol.SetWishWidth(USHRT_MAX); |
1138 | 0 | aFormatCol.SetGutterWidth(nGutterWidth, USHRT_MAX); |
1139 | |
|
1140 | 0 | rFormat.SetFormatAttr(aFormatCol); |
1141 | |
|
1142 | 0 | rSh.ChgPageDesc(nCurIdx, aPageDesc); |
1143 | 0 | } |
1144 | 0 | else |
1145 | 0 | GetView().GetViewFrame().GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG); |
1146 | 0 | } |
1147 | 0 | break; |
1148 | 0 | case FN_CONVERT_TABLE_TO_TEXT: |
1149 | 0 | case FN_CONVERT_TEXT_TO_TABLE: |
1150 | 0 | case FN_CONVERT_TEXT_TABLE: |
1151 | 0 | { |
1152 | 0 | sal_Unicode cDelim = 0; |
1153 | 0 | bool bToTable = false; |
1154 | 0 | if( nSlot == FN_CONVERT_TEXT_TO_TABLE || |
1155 | 0 | ( nSlot == FN_CONVERT_TEXT_TABLE && nullptr == rSh.GetTableFormat() )) |
1156 | 0 | bToTable = true; |
1157 | 0 | SwInsertTableOptions aInsTableOpts( SwInsertTableFlags::All, 1 ); |
1158 | 0 | SwTableAutoFormat const* pTAFormat = nullptr; |
1159 | 0 | std::unique_ptr<SwTableAutoFormatTable> pAutoFormatTable; |
1160 | 0 | bool bDeleteFormat = true; |
1161 | 0 | if(pArgs && SfxItemState::SET == pArgs->GetItemState( FN_PARAM_1, true, &pItem)) |
1162 | 0 | { |
1163 | 0 | aInsTableOpts.mnInsMode = SwInsertTableFlags::NONE; |
1164 | | // Delimiter |
1165 | 0 | OUString sDelim = static_cast< const SfxStringItem* >(pItem)->GetValue(); |
1166 | 0 | if(!sDelim.isEmpty()) |
1167 | 0 | cDelim = sDelim[0]; |
1168 | | // AutoFormat |
1169 | 0 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_2, true, &pItem)) |
1170 | 0 | { |
1171 | 0 | OUString sAutoFormat = static_cast< const SfxStringItem* >(pItem)->GetValue(); |
1172 | |
|
1173 | 0 | pAutoFormatTable.reset(new SwTableAutoFormatTable(SwModule::get()->GetAutoFormatTable())); |
1174 | |
|
1175 | 0 | for( sal_uInt16 i = 0, nCount = pAutoFormatTable->size(); i < nCount; i++ ) |
1176 | 0 | { |
1177 | 0 | SwTableAutoFormat const*const pFormat = &(*pAutoFormatTable)[ i ]; |
1178 | 0 | if( pFormat->GetName() == sAutoFormat ) |
1179 | 0 | { |
1180 | 0 | pTAFormat = pFormat; |
1181 | 0 | bDeleteFormat = false; |
1182 | 0 | break; |
1183 | 0 | } |
1184 | 0 | } |
1185 | 0 | } |
1186 | | //WithHeader |
1187 | 0 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_3, true, &pItem) && |
1188 | 0 | static_cast< const SfxBoolItem* >(pItem)->GetValue()) |
1189 | 0 | aInsTableOpts.mnInsMode |= SwInsertTableFlags::Headline; |
1190 | | // RepeatHeaderLines |
1191 | 0 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_4, true, &pItem)) |
1192 | 0 | aInsTableOpts.mnRowsToRepeat = |
1193 | 0 | o3tl::narrowing<sal_uInt16>(static_cast< const SfxInt16Item* >(pItem)->GetValue()); |
1194 | | //WithBorder |
1195 | 0 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_5, true, &pItem) && |
1196 | 0 | static_cast< const SfxBoolItem* >(pItem)->GetValue()) |
1197 | 0 | aInsTableOpts.mnInsMode |= SwInsertTableFlags::DefaultBorder; |
1198 | | //DontSplitTable |
1199 | 0 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_6, true, &pItem) && |
1200 | 0 | !static_cast< const SfxBoolItem* >(pItem)->GetValue() ) |
1201 | 0 | aInsTableOpts.mnInsMode |= SwInsertTableFlags::SplitLayout; |
1202 | 0 | } |
1203 | 0 | else |
1204 | 0 | { |
1205 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
1206 | 0 | ScopedVclPtr<AbstractSwConvertTableDlg> pDlg(pFact->CreateSwConvertTableDlg(GetView(), bToTable)); |
1207 | 0 | if( RET_OK == pDlg->Execute() ) |
1208 | 0 | { |
1209 | 0 | pDlg->GetValues( cDelim, aInsTableOpts, pTAFormat ); |
1210 | |
|
1211 | 0 | } |
1212 | 0 | } |
1213 | |
|
1214 | 0 | if( cDelim ) |
1215 | 0 | { |
1216 | | //Shell change! |
1217 | 0 | SwView& rSaveView = m_rView; |
1218 | 0 | bool bInserted = false; |
1219 | | //recording: |
1220 | 0 | SfxViewFrame& rViewFrame = GetView().GetViewFrame(); |
1221 | 0 | if (SfxRequest::HasMacroRecorder(rViewFrame)) |
1222 | 0 | { |
1223 | 0 | SfxRequest aReq(rViewFrame, nSlot); |
1224 | 0 | aReq.AppendItem( SfxStringItem( FN_PARAM_1, OUString(cDelim) )); |
1225 | 0 | if(bToTable) |
1226 | 0 | { |
1227 | 0 | if(pTAFormat) |
1228 | 0 | aReq.AppendItem( SfxStringItem( FN_PARAM_2, pTAFormat->GetName().toString())); |
1229 | 0 | aReq.AppendItem( SfxBoolItem ( FN_PARAM_3, bool(aInsTableOpts.mnInsMode & SwInsertTableFlags::Headline))); |
1230 | 0 | aReq.AppendItem( SfxInt16Item( FN_PARAM_4, static_cast<short>(aInsTableOpts.mnRowsToRepeat) )); |
1231 | 0 | aReq.AppendItem( SfxBoolItem ( FN_PARAM_5, bool(aInsTableOpts.mnInsMode & SwInsertTableFlags::DefaultBorder) )); |
1232 | 0 | aReq.AppendItem( SfxBoolItem ( FN_PARAM_6, !(aInsTableOpts.mnInsMode & SwInsertTableFlags::SplitLayout))); |
1233 | 0 | } |
1234 | 0 | aReq.Done(); |
1235 | 0 | } |
1236 | |
|
1237 | 0 | if( !bToTable ) |
1238 | 0 | rSh.TableToText( cDelim ); |
1239 | 0 | else |
1240 | 0 | { |
1241 | 0 | bInserted = rSh.TextToTable( aInsTableOpts, cDelim, pTAFormat ); |
1242 | 0 | } |
1243 | 0 | rSh.EnterStdMode(); |
1244 | |
|
1245 | 0 | if( bInserted ) |
1246 | 0 | rSaveView.AutoCaption( TABLE_CAP ); |
1247 | 0 | } |
1248 | 0 | if(bDeleteFormat) |
1249 | 0 | delete pTAFormat; |
1250 | 0 | } |
1251 | 0 | break; |
1252 | 0 | case SID_STYLE_WATERCAN: |
1253 | 0 | case SID_STYLE_UPDATE_BY_EXAMPLE: |
1254 | 0 | case SID_STYLE_NEW_BY_EXAMPLE: |
1255 | 0 | case SID_STYLE_APPLY: |
1256 | 0 | { |
1257 | 0 | ShellMode eMode = GetView().GetShellMode(); |
1258 | 0 | if ( ShellMode::Draw != eMode && |
1259 | 0 | ShellMode::DrawForm != eMode && |
1260 | 0 | ShellMode::DrawText != eMode && |
1261 | 0 | ShellMode::Bezier != eMode ) |
1262 | 0 | { |
1263 | | // oj #107754# |
1264 | 0 | if ( SID_STYLE_WATERCAN == nSlot ) |
1265 | 0 | { |
1266 | 0 | const bool bLockedView = rSh.IsViewLocked(); |
1267 | 0 | rSh.LockView( true ); //lock visible section |
1268 | |
|
1269 | 0 | GetView().GetDocShell()->ExecStyleSheet(rReq); |
1270 | |
|
1271 | 0 | rSh.LockView( bLockedView ); |
1272 | 0 | } |
1273 | 0 | else |
1274 | | // Will be recorded from the DocShell |
1275 | 0 | GetView().GetDocShell()->ExecStyleSheet(rReq); |
1276 | 0 | } |
1277 | 0 | } |
1278 | 0 | break; |
1279 | 0 | case SID_CLASSIFICATION_APPLY: |
1280 | 0 | { |
1281 | 0 | GetView().GetDocShell()->Execute(rReq); |
1282 | 0 | } |
1283 | 0 | break; |
1284 | 0 | case SID_CLASSIFICATION_DIALOG: |
1285 | 0 | { |
1286 | 0 | GetView().GetDocShell()->Execute(rReq); |
1287 | 0 | } |
1288 | 0 | break; |
1289 | 0 | case SID_PARAGRAPH_SIGN_CLASSIFY_DLG: |
1290 | 0 | { |
1291 | 0 | GetView().GetDocShell()->Execute(rReq); |
1292 | 0 | } |
1293 | 0 | break; |
1294 | 0 | case SID_WATERMARK: |
1295 | 0 | { |
1296 | 0 | GetView().GetDocShell()->Execute(rReq); |
1297 | 0 | } |
1298 | 0 | break; |
1299 | 0 | case FN_ESCAPE: |
1300 | 0 | GetView().ExecuteSlot(rReq); |
1301 | 0 | break; |
1302 | 0 | case SID_IMAP: |
1303 | 0 | { |
1304 | 0 | sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); |
1305 | |
|
1306 | 0 | SfxViewFrame& rVFrame = GetView().GetViewFrame(); |
1307 | 0 | rVFrame.ToggleChildWindow( nId ); |
1308 | 0 | rVFrame.GetBindings().Invalidate( SID_IMAP ); |
1309 | |
|
1310 | 0 | if ( rVFrame.HasChildWindow( nId ) && rSh.IsFrameSelected() ) |
1311 | 0 | lcl_UpdateIMapDlg( rSh ); |
1312 | 0 | } |
1313 | 0 | break; |
1314 | 0 | case SID_IMAP_EXEC: |
1315 | 0 | { |
1316 | 0 | SvxIMapDlg* pDlg = GetIMapDlg(GetView()); |
1317 | | |
1318 | | // Check, if the allocation is useful or allowed at all. |
1319 | 0 | if ( rSh.IsFrameSelected() && |
1320 | 0 | pDlg->GetEditingObject() == rSh.GetIMapInventor() ) |
1321 | 0 | { |
1322 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_URL, RES_URL>(rSh.GetAttrPool())); |
1323 | 0 | rSh.GetFlyFrameAttr( aSet ); |
1324 | 0 | SwFormatURL aURL( aSet.Get( RES_URL ) ); |
1325 | 0 | aURL.SetMap( &pDlg->GetImageMap() ); |
1326 | 0 | aSet.Put( aURL ); |
1327 | 0 | rSh.SetFlyFrameAttr( aSet ); |
1328 | 0 | } |
1329 | 0 | } |
1330 | 0 | break; |
1331 | 0 | case FN_SET_TRACKED_CHANGES_IN_TEXT: |
1332 | 0 | case FN_SET_TRACKED_DELETIONS_IN_MARGIN: |
1333 | 0 | case FN_SET_TRACKED_INSERTIONS_IN_MARGIN: |
1334 | 0 | { |
1335 | 0 | SwViewOption aViewOption = *rSh.GetViewOptions(); |
1336 | 0 | bool bAllInText = FN_SET_TRACKED_CHANGES_IN_TEXT == nSlot; |
1337 | 0 | aViewOption.SetShowChangesInMargin( !bAllInText ); |
1338 | 0 | if ( !bAllInText ) |
1339 | 0 | aViewOption.SetShowChangesInMargin2( FN_SET_TRACKED_INSERTIONS_IN_MARGIN == nSlot ); |
1340 | 0 | rSh.ApplyViewOptions( aViewOption ); |
1341 | | |
1342 | | // tdf#140982 restore annotation ranges stored in temporary bookmarks |
1343 | | // (only remove temporary bookmarks during file saving to avoid possible |
1344 | | // conflict with lazy deletion of the bookmarks of the moved tracked deletions) |
1345 | 0 | if ( bAllInText || FN_SET_TRACKED_INSERTIONS_IN_MARGIN == nSlot ) |
1346 | 0 | rSh.GetDoc()->getIDocumentMarkAccess()->restoreAnnotationMarks(false); |
1347 | 0 | } |
1348 | 0 | break; |
1349 | 0 | case SID_CONTOUR_DLG: |
1350 | 0 | { |
1351 | 0 | sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); |
1352 | |
|
1353 | 0 | SfxViewFrame& rVFrame = GetView().GetViewFrame(); |
1354 | 0 | rVFrame.ToggleChildWindow( nId ); |
1355 | 0 | rVFrame.GetBindings().Invalidate( SID_CONTOUR_DLG ); |
1356 | |
|
1357 | 0 | SelectionType nSel = rSh.GetSelectionType(); |
1358 | 0 | if ( rVFrame.HasChildWindow( nId ) && |
1359 | 0 | (nSel & (SelectionType::Graphic|SelectionType::Ole)) ) |
1360 | 0 | { |
1361 | 0 | lcl_UpdateContourDlg( rSh, nSel ); |
1362 | 0 | } |
1363 | 0 | } |
1364 | 0 | break; |
1365 | 0 | case SID_CONTOUR_EXEC: |
1366 | 0 | { |
1367 | 0 | SvxContourDlg *pDlg = GetContourDlg(GetView()); |
1368 | | // Check, if the allocation is useful or allowed at all. |
1369 | 0 | SelectionType nSel = rSh.GetSelectionType(); |
1370 | 0 | if ( nSel & (SelectionType::Graphic|SelectionType::Ole) ) |
1371 | 0 | { |
1372 | 0 | if (pDlg && pDlg->GetEditingObject() == rSh.GetIMapInventor()) |
1373 | 0 | { |
1374 | 0 | rSh.StartAction(); |
1375 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_SURROUND, RES_SURROUND>(rSh.GetAttrPool())); |
1376 | 0 | rSh.GetFlyFrameAttr( aSet ); |
1377 | 0 | SwFormatSurround aSur( aSet.Get( RES_SURROUND ) ); |
1378 | 0 | if ( !aSur.IsContour() ) |
1379 | 0 | { |
1380 | 0 | aSur.SetContour( true ); |
1381 | 0 | if ( aSur.GetSurround() == css::text::WrapTextMode_NONE ) |
1382 | 0 | aSur.SetSurround( css::text::WrapTextMode_PARALLEL ); |
1383 | 0 | aSet.Put( aSur ); |
1384 | 0 | rSh.SetFlyFrameAttr( aSet ); |
1385 | 0 | } |
1386 | 0 | const tools::PolyPolygon aPoly( pDlg->GetPolyPolygon() ); |
1387 | 0 | rSh.SetGraphicPolygon( &aPoly ); |
1388 | 0 | if ( pDlg->IsGraphicChanged() ) |
1389 | 0 | rSh.ReRead( OUString(), OUString(), &pDlg->GetGraphic()); |
1390 | 0 | rSh.EndAction(); |
1391 | 0 | } |
1392 | 0 | } |
1393 | 0 | } |
1394 | 0 | break; |
1395 | 0 | case FN_FRAME_TO_ANCHOR: |
1396 | 0 | { |
1397 | 0 | rSh.GotoFlyAnchor(); |
1398 | 0 | rSh.EnterStdMode(); |
1399 | 0 | rSh.CallChgLnk(); |
1400 | 0 | } |
1401 | 0 | break; |
1402 | 0 | case FN_TOOL_ANCHOR_PAGE: |
1403 | 0 | case FN_TOOL_ANCHOR_PARAGRAPH: |
1404 | 0 | case FN_TOOL_ANCHOR_CHAR: |
1405 | 0 | case FN_TOOL_ANCHOR_AT_CHAR: |
1406 | 0 | case FN_TOOL_ANCHOR_FRAME: |
1407 | 0 | { |
1408 | 0 | RndStdIds eSet = nSlot == FN_TOOL_ANCHOR_PAGE |
1409 | 0 | ? RndStdIds::FLY_AT_PAGE |
1410 | 0 | : nSlot == FN_TOOL_ANCHOR_PARAGRAPH |
1411 | 0 | ? RndStdIds::FLY_AT_PARA |
1412 | 0 | : nSlot == FN_TOOL_ANCHOR_FRAME |
1413 | 0 | ? RndStdIds::FLY_AT_FLY |
1414 | 0 | : nSlot == FN_TOOL_ANCHOR_CHAR |
1415 | 0 | ? RndStdIds::FLY_AS_CHAR |
1416 | 0 | : RndStdIds::FLY_AT_CHAR; |
1417 | 0 | rSh.StartUndo(); |
1418 | 0 | if (rSh.GetSelectedObjCount()) |
1419 | 0 | rSh.ChgAnchor(eSet); |
1420 | 0 | else if (rSh.IsFrameSelected()) |
1421 | 0 | { |
1422 | 0 | SwFormatAnchor aAnc(eSet, eSet == RndStdIds::FLY_AT_PAGE ? rSh.GetPhyPageNum() : 0); |
1423 | 0 | SfxItemSet aSet(SwFEShell::makeItemSetFromFormatAnchor(GetPool(), aAnc)); |
1424 | 0 | rSh.SetFlyFrameAttr(aSet); |
1425 | 0 | } |
1426 | | // if new anchor is 'as char' and it is a Math object and the usual |
1427 | | // pre-conditions are met then align the formula to the baseline of the text |
1428 | 0 | const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() ); |
1429 | 0 | const bool bDoMathBaselineAlignment = xObj.is() && SotExchange::IsMath( xObj->getClassID() ) |
1430 | 0 | && RndStdIds::FLY_AS_CHAR == eSet && rSh.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ); |
1431 | 0 | if (bDoMathBaselineAlignment) |
1432 | 0 | rSh.AlignFormulaToBaseline( xObj ); |
1433 | |
|
1434 | 0 | sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); |
1435 | 0 | if( nHtmlMode ) |
1436 | 0 | { |
1437 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_SURROUND, RES_HORI_ORIENT>(GetPool())); |
1438 | 0 | rSh.GetFlyFrameAttr(aSet); |
1439 | |
|
1440 | 0 | const SwFormatSurround& rSurround = aSet.Get(RES_SURROUND); |
1441 | 0 | const SwFormatVertOrient& rVert = aSet.Get(RES_VERT_ORIENT); |
1442 | 0 | const SwFormatHoriOrient& rHori = aSet.Get(RES_HORI_ORIENT); |
1443 | 0 | sal_Int16 eVOrient = rVert.GetVertOrient(); |
1444 | 0 | sal_Int16 eHOrient = rHori.GetHoriOrient(); |
1445 | 0 | css::text::WrapTextMode eSurround = rSurround.GetSurround(); |
1446 | |
|
1447 | 0 | switch( eSet ) |
1448 | 0 | { |
1449 | 0 | case RndStdIds::FLY_AT_FLY: |
1450 | 0 | case RndStdIds::FLY_AT_PAGE: |
1451 | | //Wrap through, left or from left, top, from top |
1452 | 0 | if(eSurround != css::text::WrapTextMode_THROUGH) |
1453 | 0 | aSet.Put(SwFormatSurround(css::text::WrapTextMode_THROUGH)); |
1454 | |
|
1455 | 0 | if( eVOrient != text::VertOrientation::TOP && eVOrient != text::VertOrientation::NONE) |
1456 | 0 | aSet.Put(SwFormatVertOrient(0, text::VertOrientation::TOP)); |
1457 | |
|
1458 | 0 | if (eHOrient != text::HoriOrientation::NONE && eHOrient != text::HoriOrientation::LEFT) |
1459 | 0 | aSet.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT)); |
1460 | 0 | break; |
1461 | | |
1462 | 0 | case RndStdIds::FLY_AT_PARA: |
1463 | | // left, from left, right, top, no wrap, wrap left and right |
1464 | 0 | if (eSurround != css::text::WrapTextMode_LEFT && eSurround != css::text::WrapTextMode_RIGHT) |
1465 | 0 | aSet.Put(SwFormatSurround(css::text::WrapTextMode_LEFT)); |
1466 | |
|
1467 | 0 | if( eVOrient != text::VertOrientation::TOP) |
1468 | 0 | aSet.Put(SwFormatVertOrient(0, text::VertOrientation::TOP)); |
1469 | |
|
1470 | 0 | if (eHOrient != text::HoriOrientation::NONE && eHOrient != text::HoriOrientation::LEFT && eHOrient != text::HoriOrientation::RIGHT) |
1471 | 0 | aSet.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT)); |
1472 | 0 | break; |
1473 | | |
1474 | 0 | case RndStdIds::FLY_AT_CHAR: |
1475 | | // left, from left, right, top, wrap through |
1476 | 0 | if(eSurround != css::text::WrapTextMode_THROUGH) |
1477 | 0 | aSet.Put(SwFormatSurround(css::text::WrapTextMode_THROUGH)); |
1478 | |
|
1479 | 0 | if( eVOrient != text::VertOrientation::TOP) |
1480 | 0 | aSet.Put(SwFormatVertOrient(0, text::VertOrientation::TOP)); |
1481 | |
|
1482 | 0 | if (eHOrient != text::HoriOrientation::NONE && eHOrient != text::HoriOrientation::LEFT && eHOrient != text::HoriOrientation::RIGHT) |
1483 | 0 | aSet.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT)); |
1484 | 0 | break; |
1485 | | |
1486 | 0 | default: |
1487 | 0 | ; |
1488 | 0 | } |
1489 | | |
1490 | 0 | if( aSet.Count() ) |
1491 | 0 | rSh.SetFlyFrameAttr( aSet ); |
1492 | 0 | } |
1493 | 0 | rSh.EndUndo(); |
1494 | |
|
1495 | 0 | GetView().GetViewFrame().GetBindings().Invalidate( SID_ANCHOR_MENU ); |
1496 | 0 | } |
1497 | 0 | break; |
1498 | | |
1499 | 0 | case FN_FRAME_NOWRAP: |
1500 | 0 | case FN_FRAME_WRAP: |
1501 | 0 | case FN_FRAME_WRAP_IDEAL: |
1502 | 0 | case FN_FRAME_WRAPTHRU: |
1503 | 0 | case FN_FRAME_WRAPTHRU_TRANSP: |
1504 | 0 | case FN_FRAME_WRAPTHRU_TOGGLE: |
1505 | 0 | case FN_FRAME_WRAP_CONTOUR: |
1506 | 0 | case FN_WRAP_ANCHOR_ONLY: |
1507 | 0 | case FN_FRAME_WRAP_LEFT: |
1508 | 0 | case FN_FRAME_WRAP_RIGHT: |
1509 | 0 | SetWrapMode( nSlot ); |
1510 | 0 | break; |
1511 | | |
1512 | 0 | case FN_UPDATE_ALL_LINKS: |
1513 | 0 | { |
1514 | 0 | if( !rSh.GetLinkManager().GetLinks().empty() ) |
1515 | 0 | { |
1516 | 0 | rSh.EnterStdMode(); |
1517 | 0 | rSh.StartAllAction(); |
1518 | 0 | SfxMedium * medium = nullptr; |
1519 | 0 | if (auto const sh = rSh.GetDoc()->GetDocShell()) { |
1520 | 0 | medium = sh->GetMedium(); |
1521 | 0 | } |
1522 | 0 | rSh.GetLinkManager().UpdateAllLinks( |
1523 | 0 | false, false, nullptr, medium == nullptr ? OUString() : medium->GetName() ); |
1524 | 0 | rSh.EndAllAction(); |
1525 | 0 | } |
1526 | 0 | } |
1527 | 0 | break; |
1528 | | |
1529 | 0 | case SID_PROTECTSIZE: |
1530 | 0 | case SID_PROTECTPOS: |
1531 | 0 | { |
1532 | 0 | const bool bIsProtected |
1533 | 0 | = rSh.IsSelObjProtected(nSlot == SID_PROTECTSIZE ? FlyProtectFlags::Size |
1534 | 0 | : FlyProtectFlags::Pos) |
1535 | 0 | != FlyProtectFlags::NONE; |
1536 | |
|
1537 | 0 | SfxItemSet aSet( GetPool(), aFrameFormatSetRange ); |
1538 | 0 | rSh.GetFlyFrameAttr( aSet ); |
1539 | |
|
1540 | 0 | SvxProtectItem rProt = aSet.Get( RES_PROTECT ); |
1541 | 0 | if (nSlot == SID_PROTECTSIZE) |
1542 | 0 | rProt.SetSizeProtect(!bIsProtected); |
1543 | 0 | else |
1544 | 0 | rProt.SetPosProtect(!bIsProtected); |
1545 | 0 | aSet.Put( rProt ); |
1546 | |
|
1547 | 0 | rSh.SetFlyFrameAttr( aSet ); |
1548 | 0 | } |
1549 | 0 | break; |
1550 | | |
1551 | 0 | default: |
1552 | 0 | bMore = true; |
1553 | 0 | } |
1554 | | |
1555 | | |
1556 | 0 | if(!bMore || !pArgs) |
1557 | 0 | return; |
1558 | | |
1559 | 0 | pItem = nullptr; |
1560 | 0 | pArgs->GetItemState(GetPool().GetWhichIDFromSlotID(nSlot), false, &pItem); |
1561 | 0 | if(!pItem) |
1562 | 0 | return; |
1563 | | |
1564 | 0 | switch(nSlot) |
1565 | 0 | { |
1566 | 0 | case SID_ATTR_BRUSH: |
1567 | 0 | case SID_ATTR_BORDER_SHADOW: |
1568 | 0 | case RES_SHADOW: |
1569 | 0 | { |
1570 | 0 | rSh.StartAllAction(); |
1571 | | // Table cell(s) selected? |
1572 | 0 | if ( rSh.IsTableMode() ) |
1573 | 0 | { |
1574 | 0 | SwFrameFormat *pFormat = rSh.GetTableFormat(); |
1575 | 0 | pFormat->SetFormatAttr( *pItem ); |
1576 | 0 | } |
1577 | 0 | else if ( rSh.IsFrameSelected() ) |
1578 | 0 | { |
1579 | | // Set border attributes via Frame-Manager. |
1580 | 0 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); |
1581 | 0 | aMgr.SetAttrSet( *pArgs ); |
1582 | 0 | aMgr.UpdateFlyFrame(); |
1583 | 0 | } |
1584 | 0 | else |
1585 | 0 | { |
1586 | 0 | rSh.SetAttrSet( *pArgs ); |
1587 | 0 | } |
1588 | 0 | rSh.EndAllAction(); |
1589 | 0 | } |
1590 | 0 | break; |
1591 | 0 | case FN_PAGE_STYLE_SET_LR_MARGIN: |
1592 | 0 | case FN_PAGE_STYLE_SET_UL_MARGIN: |
1593 | 0 | case FN_PAGE_STYLE_SET_NUMBER_FORMAT: |
1594 | 0 | case FN_PAGE_STYLE_SET_PAPER_SIZE: |
1595 | 0 | case FN_PAGE_STYLE_SET_PAPER_BIN: |
1596 | 0 | { |
1597 | 0 | OSL_FAIL("not implemented"); |
1598 | 0 | } |
1599 | 0 | break; |
1600 | | |
1601 | 0 | case SID_ATTR_BORDER_OUTER: |
1602 | 0 | { |
1603 | | // Table cell(s) selected? |
1604 | 0 | if ( rSh.IsTableMode() ) |
1605 | 0 | { |
1606 | | // Set border attributes Get/SetTabBorders() |
1607 | 0 | rSh.SetTabBorders(*pArgs); |
1608 | 0 | } |
1609 | 0 | else if ( rSh.IsFrameSelected() ) |
1610 | 0 | { |
1611 | | // Set border attributes via Frame-Manager. |
1612 | 0 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); |
1613 | 0 | aMgr.SetAttrSet(*pArgs); |
1614 | 0 | aMgr.UpdateFlyFrame(); |
1615 | 0 | } |
1616 | 0 | else |
1617 | 0 | { |
1618 | | // Set border attributes via shell quite normally. |
1619 | 0 | rSh.SetAttrItem( *pItem ); |
1620 | 0 | } |
1621 | 0 | } |
1622 | 0 | break; |
1623 | 0 | default: |
1624 | 0 | OSL_FAIL("wrong Dispatcher"); |
1625 | 0 | } |
1626 | 0 | } |
1627 | | |
1628 | | // Here the state for SID_IMAP / SID_CONTOUR will be handled |
1629 | | // until the swapping of the graphic is finished. |
1630 | | |
1631 | | IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void) |
1632 | 0 | { |
1633 | 0 | SwWrtShell &rSh = GetShell(); |
1634 | 0 | if (CNT_GRF != rSh.SwEditShell::GetCntType()) |
1635 | 0 | return; |
1636 | 0 | GraphicType const nGrfType(rSh.GetGraphicType()); |
1637 | 0 | if (GraphicType::NONE == nGrfType || m_aGrfUpdateSlots.empty()) |
1638 | 0 | return; |
1639 | | |
1640 | 0 | bool bProtect = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent); |
1641 | 0 | SfxViewFrame& rVFrame = GetView().GetViewFrame(); |
1642 | 0 | for( const auto nSlot : m_aGrfUpdateSlots ) |
1643 | 0 | { |
1644 | 0 | bool bSetState = false; |
1645 | 0 | bool bState = false; |
1646 | 0 | switch( nSlot ) |
1647 | 0 | { |
1648 | 0 | case SID_IMAP: |
1649 | 0 | case SID_IMAP_EXEC: |
1650 | 0 | { |
1651 | 0 | sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); |
1652 | 0 | SfxChildWindow *pChildWindow = rVFrame.HasChildWindow(nId) ? |
1653 | 0 | rVFrame.GetChildWindow(nId) : nullptr; |
1654 | 0 | SvxIMapDlg *pDlg = pChildWindow ? |
1655 | 0 | static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr; |
1656 | |
|
1657 | 0 | if( pDlg && ( SID_IMAP_EXEC == nSlot || |
1658 | 0 | ( SID_IMAP == nSlot && !bProtect)) && |
1659 | 0 | pDlg->GetEditingObject() != rSh.GetIMapInventor()) |
1660 | 0 | lcl_UpdateIMapDlg( rSh ); |
1661 | |
|
1662 | 0 | if( !bProtect && SID_IMAP == nSlot ) |
1663 | 0 | { |
1664 | 0 | bSetState = true; |
1665 | 0 | bState = nullptr != pDlg; |
1666 | 0 | } |
1667 | 0 | } |
1668 | 0 | break; |
1669 | | |
1670 | 0 | case SID_CONTOUR_DLG: |
1671 | 0 | if( !bProtect ) |
1672 | 0 | { |
1673 | 0 | sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); |
1674 | 0 | SfxChildWindow *pChildWindow = rVFrame.HasChildWindow(nId) ? |
1675 | 0 | rVFrame.GetChildWindow(nId) : nullptr; |
1676 | 0 | SvxIMapDlg *pDlg = pChildWindow ? |
1677 | 0 | static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr; |
1678 | 0 | if( pDlg && pDlg->GetEditingObject() != |
1679 | 0 | rSh.GetIMapInventor() ) |
1680 | 0 | lcl_UpdateContourDlg( rSh, SelectionType::Graphic ); |
1681 | |
|
1682 | 0 | bSetState = true; |
1683 | 0 | bState = nullptr != pDlg; |
1684 | 0 | } |
1685 | 0 | break; |
1686 | | |
1687 | 0 | case FN_FRAME_WRAP_CONTOUR: |
1688 | 0 | if( !bProtect ) |
1689 | 0 | { |
1690 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_SURROUND, RES_SURROUND>(GetPool())); |
1691 | 0 | rSh.GetFlyFrameAttr(aSet); |
1692 | 0 | const SwFormatSurround& rWrap = aSet.Get(RES_SURROUND); |
1693 | 0 | bSetState = true; |
1694 | 0 | bState = rWrap.IsContour(); |
1695 | 0 | } |
1696 | 0 | break; |
1697 | | |
1698 | 0 | case SID_GRFFILTER: |
1699 | 0 | case SID_GRFFILTER_INVERT: |
1700 | 0 | case SID_GRFFILTER_SMOOTH: |
1701 | 0 | case SID_GRFFILTER_SHARPEN: |
1702 | 0 | case SID_GRFFILTER_REMOVENOISE: |
1703 | 0 | case SID_GRFFILTER_SOBEL: |
1704 | 0 | case SID_GRFFILTER_MOSAIC: |
1705 | 0 | case SID_GRFFILTER_EMBOSS: |
1706 | 0 | case SID_GRFFILTER_POSTER: |
1707 | 0 | case SID_GRFFILTER_POPART: |
1708 | 0 | case SID_GRFFILTER_SEPIA: |
1709 | 0 | case SID_GRFFILTER_SOLARIZE: |
1710 | 0 | bSetState = bState = GraphicType::Bitmap == nGrfType; |
1711 | 0 | break; |
1712 | 0 | } |
1713 | | |
1714 | 0 | if( bSetState ) |
1715 | 0 | { |
1716 | 0 | SfxBoolItem aBool( nSlot, bState ); |
1717 | 0 | if( m_pGetStateSet ) |
1718 | 0 | m_pGetStateSet->Put( aBool ); |
1719 | 0 | else |
1720 | 0 | rVFrame.GetBindings().SetState( aBool ); |
1721 | 0 | } |
1722 | 0 | } |
1723 | 0 | m_aGrfUpdateSlots.clear(); |
1724 | 0 | } |
1725 | | |
1726 | | void SwBaseShell::GetState( SfxItemSet &rSet ) |
1727 | 0 | { |
1728 | 0 | SwWrtShell &rSh = GetShell(); |
1729 | 0 | SfxViewFrame& rVFrame = GetView().GetViewFrame(); |
1730 | 0 | SfxWhichIter aIter( rSet ); |
1731 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
1732 | 0 | m_pGetStateSet = &rSet; |
1733 | 0 | while ( nWhich ) |
1734 | 0 | { |
1735 | 0 | switch ( nWhich ) |
1736 | 0 | { |
1737 | 0 | case SID_GALLERY_FORMATS: |
1738 | 0 | if ( rSh.GetSelectedObjCount() || |
1739 | 0 | (rSh.IsSelFrameMode() && |
1740 | 0 | !(rSh.GetSelectionType() & SelectionType::Graphic)) ) |
1741 | 0 | rSet.DisableItem( nWhich ); |
1742 | 0 | break; |
1743 | 0 | case SID_GALLERY_ENABLE_ADDCOPY: |
1744 | | // #108230# allow copy from gallery in Writer AND Writer/Web! |
1745 | 0 | rSet.Put( SfxBoolItem( SID_GALLERY_ENABLE_ADDCOPY, true ) ); |
1746 | 0 | break; |
1747 | 0 | case FN_EDIT_REGION: |
1748 | 0 | if( !rSh.IsAnySectionInDoc() ) |
1749 | 0 | rSet.DisableItem(nWhich); |
1750 | 0 | break; |
1751 | | |
1752 | 0 | case FN_EDIT_CURRENT_REGION: |
1753 | | //tdf#112808 if cursor is in an index, don't show the edit section. |
1754 | 0 | if( !rSh.GetCurrSection() || |
1755 | 0 | (rSh.GetCurrSection()->GetType() != SectionType::Content && |
1756 | 0 | rSh.GetCurrSection()->GetType() != SectionType::FileLink )) |
1757 | 0 | { |
1758 | 0 | rSet.DisableItem(nWhich); |
1759 | 0 | } |
1760 | 0 | break; |
1761 | | |
1762 | 0 | case FN_INSERT_REGION: |
1763 | 0 | if( rSh.CursorInsideInputField() |
1764 | 0 | || rSh.IsSelFrameMode() |
1765 | 0 | || !rSh.IsInsRegionAvailable() ) |
1766 | 0 | { |
1767 | 0 | rSet.DisableItem( nWhich ); |
1768 | 0 | } |
1769 | 0 | break; |
1770 | | |
1771 | 0 | case FN_CONVERT_TABLE_TO_TEXT: |
1772 | 0 | { |
1773 | 0 | FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true); |
1774 | 0 | if( (eFrameType & FrameTypeFlags::FOOTNOTE) || |
1775 | 0 | !rSh.GetTableFormat() ) |
1776 | 0 | rSet.DisableItem( nWhich ); |
1777 | 0 | } |
1778 | 0 | break; |
1779 | 0 | case FN_CONVERT_TEXT_TO_TABLE: |
1780 | 0 | { |
1781 | 0 | FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true); |
1782 | 0 | if( (eFrameType & FrameTypeFlags::FOOTNOTE) || |
1783 | 0 | !rSh.IsTextToTableAvailable() ) |
1784 | 0 | rSet.DisableItem( nWhich ); |
1785 | 0 | } |
1786 | 0 | break; |
1787 | 0 | case FN_CONVERT_TEXT_TABLE: |
1788 | 0 | { |
1789 | 0 | FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true); |
1790 | 0 | if( (eFrameType & FrameTypeFlags::FOOTNOTE) || |
1791 | 0 | (!rSh.GetTableFormat() && !rSh.IsTextToTableAvailable() ) ) |
1792 | 0 | rSet.DisableItem( nWhich ); |
1793 | 0 | } |
1794 | 0 | break; |
1795 | 0 | case RES_SHADOW: |
1796 | 0 | { |
1797 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_SHADOW, RES_SHADOW>(rSh.GetAttrPool())); |
1798 | | |
1799 | | // Table cell(s) selected? |
1800 | 0 | if ( rSh.IsTableMode() ) |
1801 | 0 | { |
1802 | 0 | SwFrameFormat *pFormat = rSh.GetTableFormat(); |
1803 | 0 | aSet.Put(pFormat->GetFormatAttr( nWhich )); |
1804 | 0 | } |
1805 | 0 | else if( rSh.IsFrameSelected() ) |
1806 | 0 | { |
1807 | 0 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); |
1808 | 0 | aSet.Put( aMgr.GetAttrSet() ); |
1809 | 0 | } |
1810 | 0 | else |
1811 | 0 | rSh.GetCurAttr( aSet ); |
1812 | |
|
1813 | 0 | const SvxShadowItem& rShItem = static_cast<const SvxShadowItem&>(aSet.Get(nWhich)); |
1814 | 0 | rSet.Put(rShItem); |
1815 | 0 | } |
1816 | 0 | break; |
1817 | 0 | case SID_IMAP: |
1818 | 0 | { |
1819 | | // #i59688# |
1820 | | // Improve efficiency: |
1821 | | // If selected object is protected, item has to disabled. |
1822 | 0 | const bool bProtect = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent); |
1823 | 0 | if ( bProtect ) |
1824 | 0 | { |
1825 | 0 | rSet.DisableItem( nWhich ); |
1826 | 0 | } |
1827 | 0 | else |
1828 | 0 | { |
1829 | 0 | const sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); |
1830 | 0 | const bool bHas = rVFrame.HasChildWindow( nId ); |
1831 | 0 | const bool bFrameSel = rSh.IsFrameSelected(); |
1832 | 0 | const bool bIsGraphicSelection = |
1833 | 0 | rSh.GetSelectionType() == SelectionType::Graphic; |
1834 | | |
1835 | | // #i59688# |
1836 | | // Avoid unnecessary loading of selected graphic. |
1837 | | // The graphic is only needed, if the dialog is open. |
1838 | | // If the swapping of the graphic is finished, the status |
1839 | | // must be determined asynchronously, until this the slot |
1840 | | // will be disabled. |
1841 | 0 | if ( bHas && bIsGraphicSelection && rSh.IsLinkedGrfSwapOut() ) |
1842 | 0 | { |
1843 | 0 | if( AddGrfUpdateSlot( nWhich )) |
1844 | 0 | rSh.GetGraphic(false); // start the loading |
1845 | 0 | } |
1846 | 0 | else |
1847 | 0 | { |
1848 | 0 | if ( !bHas && |
1849 | 0 | ( !bFrameSel || |
1850 | 0 | ( bIsGraphicSelection && |
1851 | 0 | rSh.GetGraphicType() == GraphicType::NONE ) ) ) |
1852 | 0 | { |
1853 | 0 | rSet.DisableItem( nWhich ); |
1854 | 0 | } |
1855 | 0 | else |
1856 | 0 | { |
1857 | 0 | SfxBoolItem aBool(nWhich, bHas); |
1858 | 0 | if ( bHas && bFrameSel ) |
1859 | 0 | lcl_UpdateIMapDlg( rSh ); |
1860 | 0 | rSet.Put(aBool); |
1861 | 0 | } |
1862 | 0 | } |
1863 | 0 | } |
1864 | 0 | } |
1865 | 0 | break; |
1866 | 0 | case SID_IMAP_EXEC: |
1867 | 0 | { |
1868 | 0 | bool bDisable = false; |
1869 | 0 | if( !rSh.IsFrameSelected()) |
1870 | 0 | bDisable = true; |
1871 | 0 | sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); |
1872 | 0 | if(!bDisable && rVFrame.HasChildWindow( nId )) |
1873 | 0 | { |
1874 | 0 | if(rSh.GetSelectionType() == SelectionType::Graphic |
1875 | 0 | && rSh.IsLinkedGrfSwapOut()) |
1876 | 0 | { |
1877 | 0 | if( AddGrfUpdateSlot( nWhich )) |
1878 | 0 | rSh.GetGraphic(false); // start the loading |
1879 | 0 | } |
1880 | 0 | else |
1881 | 0 | { |
1882 | 0 | SvxIMapDlg *pDlg = GetIMapDlg(GetView()); |
1883 | 0 | if (pDlg && pDlg->GetEditingObject() != rSh.GetIMapInventor()) |
1884 | 0 | lcl_UpdateIMapDlg( rSh ); |
1885 | 0 | } |
1886 | 0 | } |
1887 | 0 | rSet.Put(SfxBoolItem(nWhich, bDisable)); |
1888 | 0 | } |
1889 | 0 | break; |
1890 | | |
1891 | 0 | case FN_BACKSPACE: |
1892 | 0 | case SID_DELETE: |
1893 | 0 | if ( ( rSh.HasReadonlySel() && !rSh.CursorInsideInputField() ) |
1894 | 0 | || rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE ) |
1895 | 0 | { |
1896 | 0 | rSet.DisableItem( nWhich ); |
1897 | 0 | } |
1898 | 0 | break; |
1899 | | |
1900 | 0 | case SID_CONTOUR_DLG: |
1901 | 0 | { |
1902 | 0 | bool bParentCntProt = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent ); |
1903 | |
|
1904 | 0 | if( bParentCntProt || 0 != (HTMLMODE_ON & ::GetHtmlMode( |
1905 | 0 | GetView().GetDocShell() )) ) |
1906 | 0 | rSet.DisableItem( nWhich ); |
1907 | 0 | else |
1908 | 0 | { |
1909 | 0 | sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); |
1910 | 0 | bool bHas = GetView().GetViewFrame().HasChildWindow( nId ); |
1911 | 0 | SelectionType nSel = rSh.GetSelectionType(); |
1912 | 0 | bool bOk(nSel & (SelectionType::Graphic|SelectionType::Ole)); |
1913 | |
|
1914 | 0 | bool bDisable = false; |
1915 | 0 | if( !bHas && !bOk ) |
1916 | 0 | bDisable = true; |
1917 | | // #i59688# |
1918 | | // Avoid unnecessary loading of selected graphic. |
1919 | | // The graphic is only needed, if the dialog is open. |
1920 | | // If the swapping of the graphic is finished, the status |
1921 | | // must be determined asynchronously, until this the slot |
1922 | | // will be disabled. |
1923 | 0 | else if ( bHas && (nSel & SelectionType::Graphic) && |
1924 | 0 | rSh.IsLinkedGrfSwapOut() ) |
1925 | 0 | { |
1926 | 0 | if( AddGrfUpdateSlot( nWhich )) |
1927 | 0 | rSh.GetGraphic(false); // start the loading |
1928 | | // #i75481# |
1929 | 0 | bDisable = true; |
1930 | 0 | } |
1931 | 0 | else if( bHas && bOk ) |
1932 | 0 | bDisable = !lcl_UpdateContourDlg( rSh, nSel ); |
1933 | 0 | else if( bOk ) |
1934 | 0 | { |
1935 | | // #i75481# |
1936 | | // apply fix #i59688# only for selected graphics |
1937 | 0 | if ( nSel & SelectionType::Graphic ) |
1938 | 0 | bDisable = GraphicType::NONE == rSh.GetGraphicType(); |
1939 | 0 | else |
1940 | 0 | bDisable = GraphicType::NONE == rSh.GetIMapGraphic().GetType(); |
1941 | 0 | } |
1942 | |
|
1943 | 0 | if( bDisable ) |
1944 | 0 | rSet.DisableItem( nWhich ); |
1945 | 0 | else |
1946 | 0 | rSet.Put( SfxBoolItem(nWhich, bHas) ); |
1947 | 0 | } |
1948 | 0 | } |
1949 | 0 | break; |
1950 | 0 | case SID_CONTOUR_EXEC: |
1951 | 0 | { |
1952 | 0 | bool bDisable = false; |
1953 | 0 | SelectionType nSel = rSh.GetSelectionType(); |
1954 | 0 | if( !(nSel & (SelectionType::Graphic|SelectionType::Ole)) ) |
1955 | 0 | bDisable = true; |
1956 | 0 | sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); |
1957 | 0 | if( !bDisable && GetView().GetViewFrame().HasChildWindow( nId )) |
1958 | 0 | { |
1959 | 0 | SvxContourDlg *pDlg = GetContourDlg(GetView()); |
1960 | 0 | if (pDlg && pDlg->GetEditingObject() != rSh.GetIMapInventor()) |
1961 | 0 | bDisable = true; |
1962 | 0 | } |
1963 | 0 | rSet.Put(SfxBoolItem(nWhich, bDisable)); |
1964 | 0 | } |
1965 | 0 | break; |
1966 | | |
1967 | 0 | case SID_ANCHOR_MENU: |
1968 | 0 | case FN_TOOL_ANCHOR_PAGE: |
1969 | 0 | case FN_TOOL_ANCHOR_PARAGRAPH: |
1970 | 0 | case FN_TOOL_ANCHOR_CHAR: |
1971 | 0 | case FN_TOOL_ANCHOR_AT_CHAR: |
1972 | 0 | case FN_TOOL_ANCHOR_FRAME: |
1973 | 0 | { |
1974 | 0 | bool bObj = 0 != rSh.GetSelectedObjCount(); |
1975 | 0 | bool bParentCntProt = rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; |
1976 | |
|
1977 | 0 | if( !bParentCntProt && (bObj || rSh.IsFrameSelected())) |
1978 | 0 | { |
1979 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_ANCHOR, RES_ANCHOR>(GetPool())); |
1980 | 0 | if(bObj) |
1981 | 0 | rSh.GetObjAttr(aSet); |
1982 | 0 | else |
1983 | 0 | rSh.GetFlyFrameAttr(aSet); |
1984 | 0 | RndStdIds eSet = aSet.Get(RES_ANCHOR).GetAnchorId(); |
1985 | 0 | const bool bSet = |
1986 | 0 | ((nWhich == FN_TOOL_ANCHOR_PAGE) && |
1987 | 0 | (eSet == RndStdIds::FLY_AT_PAGE)) |
1988 | 0 | || ((nWhich == FN_TOOL_ANCHOR_PARAGRAPH) && |
1989 | 0 | (eSet == RndStdIds::FLY_AT_PARA)) |
1990 | 0 | || ((nWhich == FN_TOOL_ANCHOR_FRAME) && |
1991 | 0 | (eSet == RndStdIds::FLY_AT_FLY)) |
1992 | 0 | || ((nWhich == FN_TOOL_ANCHOR_AT_CHAR) && |
1993 | 0 | (eSet == RndStdIds::FLY_AT_CHAR)) |
1994 | 0 | || ((nWhich == FN_TOOL_ANCHOR_CHAR) && |
1995 | 0 | (eSet == RndStdIds::FLY_AS_CHAR)); |
1996 | |
|
1997 | 0 | if( nWhich == FN_TOOL_ANCHOR_FRAME && !rSh.IsFlyInFly() ) |
1998 | 0 | rSet.DisableItem(nWhich); |
1999 | 0 | else if(nWhich != SID_ANCHOR_MENU) |
2000 | 0 | rSet.Put(SfxBoolItem(nWhich, bSet)); |
2001 | |
|
2002 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
2003 | 0 | { |
2004 | 0 | if (nWhich == FN_TOOL_ANCHOR_PAGE || nWhich == FN_TOOL_ANCHOR_FRAME) |
2005 | 0 | { |
2006 | 0 | rSet.DisableItem(nWhich); |
2007 | 0 | } |
2008 | 0 | } |
2009 | 0 | } |
2010 | 0 | else |
2011 | 0 | rSet.DisableItem( nWhich ); |
2012 | 0 | } |
2013 | 0 | break; |
2014 | 0 | case FN_FRAME_NOWRAP: |
2015 | 0 | case FN_FRAME_WRAP: |
2016 | 0 | case FN_FRAME_WRAP_IDEAL: |
2017 | 0 | case FN_FRAME_WRAPTHRU: |
2018 | 0 | case FN_FRAME_WRAPTHRU_TRANSP: |
2019 | 0 | case FN_FRAME_WRAPTHRU_TOGGLE: |
2020 | 0 | case FN_FRAME_WRAP_CONTOUR: |
2021 | 0 | case FN_WRAP_ANCHOR_ONLY: |
2022 | 0 | case FN_FRAME_WRAP_LEFT: |
2023 | 0 | case FN_FRAME_WRAP_RIGHT: |
2024 | 0 | { |
2025 | 0 | bool bObj = 0 != rSh.GetSelectedObjCount(); |
2026 | 0 | bool bParentCntProt = rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; |
2027 | |
|
2028 | 0 | if( !bParentCntProt && (bObj || rSh.IsFrameSelected())) |
2029 | 0 | { |
2030 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_OPAQUE, RES_ANCHOR>(GetPool())); |
2031 | 0 | RndStdIds nAnchorType; |
2032 | 0 | if(bObj) |
2033 | 0 | { |
2034 | 0 | rSh.GetObjAttr(aSet); |
2035 | 0 | nAnchorType = rSh.GetAnchorId(); |
2036 | 0 | } |
2037 | 0 | else |
2038 | 0 | { |
2039 | 0 | rSh.GetFlyFrameAttr(aSet); |
2040 | 0 | nAnchorType = aSet.Get(RES_ANCHOR).GetAnchorId(); |
2041 | 0 | } |
2042 | 0 | const SwFormatSurround& rWrap = aSet.Get(RES_SURROUND); |
2043 | |
|
2044 | 0 | const SvxOpaqueItem& rOpaque = aSet.Get(RES_OPAQUE); |
2045 | 0 | bool bOpaque = rOpaque.GetValue(); |
2046 | 0 | css::text::WrapTextMode nSurround = rWrap.GetSurround(); |
2047 | 0 | bool bSet = false; |
2048 | |
|
2049 | 0 | bool bDisable = |
2050 | 0 | (nAnchorType == RndStdIds::UNKNOWN) || (nAnchorType == RndStdIds::FLY_AS_CHAR); |
2051 | 0 | const bool bHtmlMode = |
2052 | 0 | 0 != ::GetHtmlMode(GetView().GetDocShell()); |
2053 | |
|
2054 | 0 | switch( nWhich ) |
2055 | 0 | { |
2056 | 0 | case FN_FRAME_NOWRAP: |
2057 | 0 | bDisable |= |
2058 | 0 | ( (nAnchorType != RndStdIds::FLY_AT_PARA) |
2059 | 0 | && (nAnchorType != RndStdIds::FLY_AT_CHAR) |
2060 | 0 | && (nAnchorType != RndStdIds::FLY_AT_PAGE)); |
2061 | 0 | bSet = nSurround == css::text::WrapTextMode_NONE; |
2062 | 0 | break; |
2063 | 0 | case FN_FRAME_WRAP: |
2064 | 0 | bDisable |= bHtmlMode; |
2065 | 0 | bSet = nSurround == css::text::WrapTextMode_PARALLEL; |
2066 | 0 | break; |
2067 | 0 | case FN_FRAME_WRAP_IDEAL: |
2068 | 0 | bDisable |= bHtmlMode; |
2069 | 0 | bSet = nSurround == css::text::WrapTextMode_DYNAMIC; |
2070 | 0 | break; |
2071 | 0 | case FN_FRAME_WRAPTHRU: |
2072 | 0 | bDisable |= (bHtmlMode || |
2073 | 0 | ( (nAnchorType != RndStdIds::FLY_AT_PARA) |
2074 | 0 | && (nAnchorType != RndStdIds::FLY_AT_CHAR) |
2075 | 0 | && (nAnchorType != RndStdIds::FLY_AT_PAGE))); |
2076 | 0 | if(bObj) |
2077 | 0 | bSet = nSurround == css::text::WrapTextMode_THROUGH && rSh.GetLayerId(); |
2078 | 0 | else |
2079 | 0 | bSet = nSurround == css::text::WrapTextMode_THROUGH && bOpaque; |
2080 | 0 | break; |
2081 | 0 | case FN_FRAME_WRAPTHRU_TRANSP: |
2082 | 0 | case FN_FRAME_WRAPTHRU_TOGGLE: |
2083 | 0 | bDisable |= bHtmlMode; |
2084 | 0 | if(bObj) |
2085 | 0 | bSet = nSurround == css::text::WrapTextMode_THROUGH && !rSh.GetLayerId(); |
2086 | 0 | else |
2087 | 0 | bSet = nSurround == css::text::WrapTextMode_THROUGH && !bOpaque; |
2088 | 0 | break; |
2089 | 0 | case FN_FRAME_WRAP_CONTOUR: |
2090 | 0 | bDisable |= bHtmlMode; |
2091 | | //no contour available when no wrap or wrap through is set |
2092 | 0 | bDisable |= (nSurround == css::text::WrapTextMode_NONE || nSurround == css::text::WrapTextMode_THROUGH); |
2093 | 0 | if( !bDisable ) |
2094 | 0 | { |
2095 | 0 | SelectionType nSel = rSh.GetSelectionType(); |
2096 | 0 | if( (nSel & SelectionType::Graphic) && |
2097 | 0 | rSh.IsLinkedGrfSwapOut()) |
2098 | 0 | { |
2099 | 0 | if( AddGrfUpdateSlot( nWhich )) |
2100 | 0 | rSh.GetGraphic(false); // start the loading |
2101 | 0 | } |
2102 | 0 | else if( rSh.IsFrameSelected() ) |
2103 | 0 | { |
2104 | | // #i102253# applied patch from OD (see task) |
2105 | 0 | bDisable = |
2106 | 0 | nSel & SelectionType::Frame || |
2107 | 0 | GraphicType::NONE == rSh.GetIMapGraphic().GetType(); |
2108 | 0 | } |
2109 | 0 | } |
2110 | 0 | bSet = !bDisable && rWrap.IsContour(); |
2111 | |
|
2112 | 0 | break; |
2113 | 0 | case FN_WRAP_ANCHOR_ONLY: |
2114 | 0 | bDisable |= (bHtmlMode || |
2115 | 0 | (nAnchorType != RndStdIds::FLY_AT_PARA)); |
2116 | 0 | bSet = rWrap.IsAnchorOnly(); |
2117 | 0 | break; |
2118 | 0 | case FN_FRAME_WRAP_LEFT: |
2119 | 0 | bSet = nSurround == css::text::WrapTextMode_LEFT; |
2120 | 0 | break; |
2121 | 0 | case FN_FRAME_WRAP_RIGHT: |
2122 | 0 | bSet = nSurround == css::text::WrapTextMode_RIGHT; |
2123 | 0 | break; |
2124 | 0 | } |
2125 | | |
2126 | 0 | if(bDisable) |
2127 | 0 | rSet.DisableItem(nWhich); |
2128 | 0 | else |
2129 | 0 | rSet.Put(SfxBoolItem(nWhich, bSet)); |
2130 | 0 | } |
2131 | 0 | else |
2132 | 0 | rSet.DisableItem(nWhich); |
2133 | 0 | } |
2134 | 0 | break; |
2135 | 0 | case FN_UPDATE_CHARTS: |
2136 | 0 | if( !rSh.HasCharts() ) |
2137 | 0 | rSet.DisableItem( nWhich ); |
2138 | 0 | break; |
2139 | 0 | case FN_UPDATE_ALL_LINKS: |
2140 | 0 | if ( rSh.GetLinkManager().GetLinks().empty() ) |
2141 | 0 | rSet.DisableItem(nWhich); |
2142 | 0 | break; |
2143 | 0 | case SID_GRAPHIC_SIZE_CHECK: |
2144 | 0 | { |
2145 | 0 | sal_Int32 nDPI = rSh.GetDoc()->getIDocumentSettingAccess().getImagePreferredDPI(); |
2146 | 0 | if (nDPI <= 0) |
2147 | 0 | rSet.DisableItem(nWhich); |
2148 | 0 | } |
2149 | 0 | break; |
2150 | 0 | case SID_THEME_DIALOG: |
2151 | 0 | { |
2152 | 0 | bool bDisable = true; |
2153 | 0 | auto* pDocument = rSh.GetDoc(); |
2154 | 0 | auto* pDocumentShell = pDocument->GetDocShell(); |
2155 | 0 | if (pDocumentShell) |
2156 | 0 | { |
2157 | 0 | SdrModel* pModel = pDocument->getIDocumentDrawModelAccess().GetDrawModel(); |
2158 | 0 | if (pModel) |
2159 | 0 | { |
2160 | 0 | auto const& pTheme = pModel->getTheme(); |
2161 | 0 | if (pTheme) |
2162 | 0 | bDisable = false; |
2163 | 0 | } |
2164 | 0 | } |
2165 | 0 | if (bDisable) |
2166 | 0 | rSet.DisableItem(nWhich); |
2167 | 0 | } |
2168 | 0 | break; |
2169 | 0 | case FN_SET_TRACKED_CHANGES_IN_TEXT: |
2170 | 0 | { |
2171 | 0 | bool bShowRedlines = !rSh.GetLayout()->IsHideRedlines(); |
2172 | 0 | const SwViewOption* pOptions = rSh.GetViewOptions(); |
2173 | | // First setting is false: inline. |
2174 | 0 | bool bAllInText = bShowRedlines && !pOptions->IsShowChangesInMargin(); |
2175 | 0 | rSet.Put(SfxBoolItem(nWhich, bAllInText)); |
2176 | 0 | } |
2177 | 0 | break; |
2178 | 0 | case FN_SET_TRACKED_DELETIONS_IN_MARGIN: |
2179 | 0 | { |
2180 | 0 | bool bShowRedlines = !rSh.GetLayout()->IsHideRedlines(); |
2181 | 0 | const SwViewOption* pOptions = rSh.GetViewOptions(); |
2182 | | // Second setting is false: show deletions in margin. |
2183 | 0 | bool bDelInMargin = bShowRedlines && pOptions->IsShowChangesInMargin() |
2184 | 0 | && !pOptions->IsShowChangesInMargin2(); |
2185 | 0 | rSet.Put(SfxBoolItem(nWhich, bDelInMargin)); |
2186 | 0 | } |
2187 | 0 | break; |
2188 | 0 | case FN_SET_TRACKED_INSERTIONS_IN_MARGIN: |
2189 | 0 | { |
2190 | 0 | bool bShowRedlines = !rSh.GetLayout()->IsHideRedlines(); |
2191 | 0 | const SwViewOption* pOptions = rSh.GetViewOptions(); |
2192 | | // Second setting is true: show insertions in margin. |
2193 | 0 | bool bInsInMargin = bShowRedlines && pOptions->IsShowChangesInMargin() |
2194 | 0 | && pOptions->IsShowChangesInMargin2(); |
2195 | 0 | rSet.Put(SfxBoolItem(nWhich, bInsInMargin)); |
2196 | 0 | } |
2197 | 0 | break; |
2198 | 0 | case SID_PROTECTSIZE: |
2199 | 0 | case SID_PROTECTPOS: |
2200 | 0 | { |
2201 | 0 | if( rSh.GetGraphicType() == GraphicType::NONE ) |
2202 | 0 | rSet.DisableItem(nWhich); |
2203 | 0 | else |
2204 | 0 | { |
2205 | 0 | const bool bIsProtected |
2206 | 0 | = rSh.IsSelObjProtected(nWhich == SID_PROTECTSIZE ? FlyProtectFlags::Size |
2207 | 0 | : FlyProtectFlags::Pos) |
2208 | 0 | != FlyProtectFlags::NONE; |
2209 | 0 | rSet.Put(SfxBoolItem(nWhich, bIsProtected)); |
2210 | 0 | } |
2211 | 0 | } |
2212 | 0 | break; |
2213 | |
|
2214 | 0 | } |
2215 | 0 | nWhich = aIter.NextWhich(); |
2216 | 0 | } |
2217 | 0 | m_pGetStateSet = nullptr; |
2218 | 0 | } |
2219 | | |
2220 | | // Disable the slots with this status method |
2221 | | |
2222 | | void SwBaseShell::StateDisableItems( SfxItemSet &rSet ) |
2223 | 0 | { |
2224 | 0 | SfxWhichIter aIter(rSet); |
2225 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
2226 | |
|
2227 | 0 | while (nWhich) |
2228 | 0 | { |
2229 | 0 | rSet.DisableItem( nWhich ); |
2230 | 0 | nWhich = aIter.NextWhich(); |
2231 | 0 | } |
2232 | 0 | } |
2233 | | |
2234 | | // Disable the slots with this status method |
2235 | | |
2236 | | void SwBaseShell::StateStyle( SfxItemSet &rSet ) |
2237 | 0 | { |
2238 | 0 | bool bParentCntProt = GetShell().IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; |
2239 | 0 | ShellMode eMode = GetView().GetShellMode(); |
2240 | |
|
2241 | 0 | if ( bParentCntProt || |
2242 | 0 | ShellMode::Draw == eMode || |
2243 | 0 | ShellMode::DrawForm == eMode || |
2244 | 0 | ShellMode::DrawText == eMode || |
2245 | 0 | ShellMode::Bezier == eMode ) |
2246 | 0 | { |
2247 | 0 | SfxWhichIter aIter( rSet ); |
2248 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
2249 | 0 | while ( nWhich ) |
2250 | 0 | { |
2251 | 0 | rSet.DisableItem( nWhich ); |
2252 | 0 | nWhich = aIter.NextWhich(); |
2253 | 0 | } |
2254 | 0 | } |
2255 | 0 | else |
2256 | 0 | GetView().GetDocShell()->StateStyleSheet(rSet, &GetShell()); |
2257 | 0 | } |
2258 | | |
2259 | | void SwBaseShell::SetWrapMode( sal_uInt16 nSlot ) |
2260 | 0 | { |
2261 | 0 | SwWrtShell &rSh = GetShell(); |
2262 | 0 | bool bObj = 0 != rSh.GetSelectedObjCount(); |
2263 | 0 | if( !bObj && !rSh.IsFrameSelected()) |
2264 | 0 | return; |
2265 | | |
2266 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_OPAQUE, RES_SURROUND>(GetPool())); |
2267 | 0 | if(bObj) |
2268 | 0 | rSh.GetObjAttr(aSet); |
2269 | 0 | else |
2270 | 0 | rSh.GetFlyFrameAttr(aSet); |
2271 | 0 | SwFormatSurround aWrap( aSet.Get(RES_SURROUND) ); |
2272 | 0 | css::text::WrapTextMode nOldSurround(aWrap.GetSurround()); |
2273 | 0 | css::text::WrapTextMode nSurround = css::text::WrapTextMode_PARALLEL; |
2274 | |
|
2275 | 0 | switch (nSlot) |
2276 | 0 | { |
2277 | 0 | case FN_FRAME_NOWRAP: |
2278 | 0 | nSurround = css::text::WrapTextMode_NONE; |
2279 | 0 | if (aWrap.IsContour()) |
2280 | 0 | aWrap.SetContour(false); |
2281 | 0 | break; |
2282 | 0 | case FN_FRAME_WRAP_IDEAL: |
2283 | 0 | nSurround = css::text::WrapTextMode_DYNAMIC; |
2284 | 0 | break; |
2285 | 0 | case FN_WRAP_ANCHOR_ONLY: |
2286 | 0 | aWrap.SetAnchorOnly(!aWrap.IsAnchorOnly()); |
2287 | | |
2288 | | // keep previous wrapping |
2289 | | |
2290 | | // switch to wrap css::text::WrapTextMode_PARALLEL, if previous wrap is css::text::WrapTextMode_NONE |
2291 | 0 | if ( nOldSurround != css::text::WrapTextMode_NONE ) |
2292 | 0 | { |
2293 | 0 | nSurround = nOldSurround; |
2294 | 0 | } |
2295 | 0 | break; |
2296 | 0 | case FN_FRAME_WRAP_CONTOUR: |
2297 | 0 | aWrap.SetContour(!aWrap.IsContour()); |
2298 | | // Contour is meaningless in no-wrap or wrap-through context. Otherwise keep existing wrap. |
2299 | 0 | if ( !aWrap.IsContour() || |
2300 | 0 | ( nOldSurround != css::text::WrapTextMode_NONE && |
2301 | 0 | nOldSurround != css::text::WrapTextMode_THROUGH ) ) |
2302 | 0 | { |
2303 | 0 | nSurround = nOldSurround; |
2304 | 0 | } |
2305 | 0 | break; |
2306 | 0 | case FN_FRAME_WRAPTHRU_TRANSP: |
2307 | 0 | case FN_FRAME_WRAPTHRU_TOGGLE: |
2308 | 0 | if (aWrap.IsContour()) |
2309 | 0 | aWrap.SetContour(false); |
2310 | 0 | [[fallthrough]]; |
2311 | 0 | case FN_FRAME_WRAPTHRU: |
2312 | 0 | nSurround = css::text::WrapTextMode_THROUGH; |
2313 | 0 | break; |
2314 | | |
2315 | 0 | case FN_FRAME_WRAP_LEFT: |
2316 | 0 | nSurround = css::text::WrapTextMode_LEFT; |
2317 | 0 | break; |
2318 | | |
2319 | 0 | case FN_FRAME_WRAP_RIGHT: |
2320 | 0 | nSurround = css::text::WrapTextMode_RIGHT; |
2321 | 0 | break; |
2322 | | |
2323 | 0 | default: |
2324 | 0 | break; |
2325 | 0 | } |
2326 | 0 | aWrap.SetSurround(nSurround); |
2327 | |
|
2328 | 0 | if (nSlot != FN_FRAME_WRAP_CONTOUR) |
2329 | 0 | { |
2330 | | // Defaulting the contour wrap on draw objects. |
2331 | 0 | if (bObj && nOldSurround != nSurround && |
2332 | 0 | (nOldSurround == css::text::WrapTextMode_NONE || nOldSurround == css::text::WrapTextMode_THROUGH)) |
2333 | 0 | { |
2334 | 0 | aWrap.SetContour(true); |
2335 | 0 | } |
2336 | 0 | } |
2337 | |
|
2338 | 0 | aSet.Put( aWrap ); |
2339 | |
|
2340 | 0 | bool bOpaque = nSlot != FN_FRAME_WRAPTHRU_TRANSP && nSlot != FN_FRAME_WRAPTHRU_TOGGLE; |
2341 | 0 | if( nSlot == FN_FRAME_WRAPTHRU_TOGGLE ) |
2342 | 0 | { |
2343 | 0 | if( bObj ) |
2344 | 0 | bOpaque = !rSh.GetLayerId(); |
2345 | 0 | else |
2346 | 0 | { |
2347 | 0 | const SvxOpaqueItem& aOpaque( aSet.Get(RES_OPAQUE) ); |
2348 | 0 | bOpaque = !aOpaque.GetValue(); |
2349 | 0 | } |
2350 | 0 | } |
2351 | 0 | aSet.Put(SvxOpaqueItem(RES_OPAQUE, bOpaque )); |
2352 | |
|
2353 | 0 | if(bObj) |
2354 | 0 | { |
2355 | 0 | rSh.SetObjAttr(aSet); |
2356 | 0 | if ( bOpaque ) |
2357 | 0 | rSh.SelectionToHeaven(); |
2358 | 0 | else |
2359 | 0 | rSh.SelectionToHell(); |
2360 | 0 | } |
2361 | 0 | else |
2362 | 0 | rSh.SetFlyFrameAttr(aSet); |
2363 | |
|
2364 | 0 | } |
2365 | | |
2366 | | //Force update of the status line |
2367 | | |
2368 | | void SwBaseShell::SetFrameMode(FlyMode eMode, SwWrtShell *pSh ) |
2369 | 0 | { |
2370 | 0 | s_eFrameMode = eMode; |
2371 | 0 | SfxBindings &rBnd = pSh->GetView().GetViewFrame().GetBindings(); |
2372 | |
|
2373 | 0 | if( eMode == FLY_DRAG || pSh->IsFrameSelected() || pSh->GetSelectedObjCount() ) |
2374 | 0 | { |
2375 | 0 | const SfxPointItem aTmp1( SID_ATTR_POSITION, pSh->GetAnchorObjDiff()); |
2376 | 0 | const SvxSizeItem aTmp2( SID_ATTR_SIZE, pSh->GetObjSize()); |
2377 | 0 | rBnd.SetState( aTmp1 ); |
2378 | 0 | rBnd.SetState( aTmp2 ); |
2379 | 0 | } |
2380 | 0 | else if( eMode == FLY_DRAG_END ) |
2381 | 0 | { |
2382 | 0 | static const sal_uInt16 aInval[] = |
2383 | 0 | { |
2384 | 0 | SID_ATTR_POSITION, SID_ATTR_SIZE, 0 |
2385 | 0 | }; |
2386 | 0 | rBnd.Invalidate(aInval); |
2387 | 0 | } |
2388 | 0 | } |
2389 | | |
2390 | | SwBaseShell::SwBaseShell(SwView& rVw) : |
2391 | 7.37k | SfxShell( &rVw ), |
2392 | 7.37k | m_rView(rVw), |
2393 | 7.37k | m_pGetStateSet(nullptr) |
2394 | 7.37k | { |
2395 | 7.37k | SwWrtShell& rWrtSh = m_rView.GetWrtShell(); |
2396 | | |
2397 | 7.37k | SetPool(&rWrtSh.GetAttrPool()); |
2398 | 7.37k | SetName(u"Base"_ustr); |
2399 | 7.37k | rWrtSh.SetGrfArrivedLnk( LINK( this, SwBaseShell, GraphicArrivedHdl)); |
2400 | 7.37k | } |
2401 | | |
2402 | | SwBaseShell::~SwBaseShell() |
2403 | 7.37k | { |
2404 | 7.37k | if( m_rView.GetCurShell() == this ) |
2405 | 0 | m_rView.ResetSubShell(); |
2406 | | |
2407 | 7.37k | Link<SwCursorShell&,void> aTmp( LINK( this, SwBaseShell, GraphicArrivedHdl)); |
2408 | 7.37k | if( aTmp == m_rView.GetWrtShell().GetGrfArrivedLnk() ) |
2409 | 3.67k | m_rView.GetWrtShell().SetGrfArrivedLnk( Link<SwCursorShell&,void>() ); |
2410 | 7.37k | } |
2411 | | |
2412 | | void SwBaseShell::ExecTextCtrl( SfxRequest& rReq ) |
2413 | 0 | { |
2414 | 0 | const SfxItemSet *pArgs = rReq.GetArgs(); |
2415 | 0 | const sal_uInt16 nSlot = rReq.GetSlot(); |
2416 | |
|
2417 | 0 | if( pArgs) |
2418 | 0 | { |
2419 | 0 | SwWrtShell &rSh = GetShell(); |
2420 | 0 | std::unique_ptr<SvxScriptSetItem> pSSetItem; |
2421 | 0 | SfxItemPool& rPool = rSh.GetAttrPool(); |
2422 | 0 | sal_uInt16 nWhich = rPool.GetWhichIDFromSlotID( nSlot ); |
2423 | 0 | SvtScriptType nScripts = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX; |
2424 | 0 | SfxItemSet aHeightSet(SfxItemSet::makeFixedSfxItemSet< |
2425 | 0 | RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE, |
2426 | 0 | RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_FONTSIZE, |
2427 | 0 | RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_FONTSIZE>(GetPool())); |
2428 | |
|
2429 | 0 | switch( nSlot ) |
2430 | 0 | { |
2431 | 0 | case SID_ATTR_CHAR_FONT: |
2432 | 0 | { |
2433 | 0 | nScripts = rSh.GetScriptType(); |
2434 | | // #i42732# input language should be preferred over |
2435 | | // current cursor position to detect script type |
2436 | 0 | if(!rSh.HasSelection()) |
2437 | 0 | { |
2438 | 0 | LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage(); |
2439 | 0 | if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) |
2440 | 0 | nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); |
2441 | 0 | } |
2442 | 0 | [[fallthrough]]; |
2443 | 0 | } |
2444 | 0 | case SID_ATTR_CHAR_POSTURE: |
2445 | 0 | case SID_ATTR_CHAR_WEIGHT: |
2446 | 0 | { |
2447 | 0 | pSSetItem.reset(new SvxScriptSetItem( nSlot, rPool )); |
2448 | 0 | pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich )); |
2449 | 0 | pArgs = &pSSetItem->GetItemSet(); |
2450 | 0 | } |
2451 | 0 | break; |
2452 | 0 | case SID_ATTR_CHAR_FONTHEIGHT: |
2453 | 0 | { |
2454 | 0 | if(rSh.HasSelection()) |
2455 | 0 | { |
2456 | 0 | pSSetItem.reset(new SvxScriptSetItem( nSlot, rPool )); |
2457 | 0 | pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich )); |
2458 | 0 | pArgs = &pSSetItem->GetItemSet(); |
2459 | 0 | } |
2460 | 0 | else |
2461 | 0 | { |
2462 | 0 | nScripts = rSh.GetScriptType(); |
2463 | 0 | LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage(); |
2464 | 0 | if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) |
2465 | 0 | nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); |
2466 | 0 | sal_uInt32 nHeight = static_cast< const SvxFontHeightItem& >(pArgs->Get( nWhich )).GetHeight(); |
2467 | 0 | SwStdFontConfig* pStdFont = SwModule::get()->GetStdFontConfig(); |
2468 | |
|
2469 | 0 | SfxItemSet aLangSet(SfxItemSet::makeFixedSfxItemSet< |
2470 | 0 | RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, |
2471 | 0 | RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, |
2472 | 0 | RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE>(GetPool())); |
2473 | 0 | rSh.GetCurAttr( aLangSet ); |
2474 | |
|
2475 | 0 | sal_Int32 nWesternSize = |
2476 | 0 | pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_DEFAULT, |
2477 | 0 | aLangSet.Get( RES_CHRATR_LANGUAGE).GetLanguage()); |
2478 | 0 | sal_Int32 nCJKSize = |
2479 | 0 | pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CJK, |
2480 | 0 | aLangSet.Get( RES_CHRATR_CJK_LANGUAGE).GetLanguage()); |
2481 | 0 | sal_Int32 nCTLSize = |
2482 | 0 | pStdFont->GetFontHeight(FONT_STANDARD, FONT_GROUP_CTL, |
2483 | 0 | aLangSet.Get( RES_CHRATR_CTL_LANGUAGE).GetLanguage()); |
2484 | |
|
2485 | 0 | switch(nScripts) |
2486 | 0 | { |
2487 | 0 | case SvtScriptType::LATIN: |
2488 | 0 | nCJKSize = nHeight * nCJKSize / nWesternSize; |
2489 | 0 | nCTLSize = nHeight * nCTLSize / nWesternSize; |
2490 | 0 | nWesternSize = static_cast<sal_Int32>(nHeight); |
2491 | 0 | break; |
2492 | 0 | case SvtScriptType::ASIAN: |
2493 | 0 | nCTLSize = nHeight* nCTLSize / nCJKSize; |
2494 | 0 | nWesternSize = nHeight * nWesternSize / nCJKSize; |
2495 | 0 | nCJKSize = static_cast<sal_Int32>(nHeight); |
2496 | 0 | break; |
2497 | 0 | case SvtScriptType::COMPLEX: |
2498 | 0 | nCJKSize = nHeight * nCJKSize / nCTLSize; |
2499 | 0 | nWesternSize = nHeight * nWesternSize / nCTLSize; |
2500 | 0 | nCTLSize = static_cast<sal_Int32>(nHeight); |
2501 | 0 | break; |
2502 | 0 | default: break; |
2503 | 0 | } |
2504 | 0 | aHeightSet.Put( SvxFontHeightItem( static_cast<sal_uInt32>(nWesternSize), 100, RES_CHRATR_FONTSIZE )); |
2505 | 0 | aHeightSet.Put( SvxFontHeightItem( static_cast<sal_uInt32>(nCJKSize), 100, RES_CHRATR_CJK_FONTSIZE )); |
2506 | 0 | aHeightSet.Put( SvxFontHeightItem( static_cast<sal_uInt32>(nCTLSize), 100, RES_CHRATR_CTL_FONTSIZE )); |
2507 | 0 | pArgs = &aHeightSet; |
2508 | 0 | } |
2509 | 0 | } |
2510 | 0 | break; |
2511 | 0 | } |
2512 | | |
2513 | 0 | if( pArgs ) |
2514 | 0 | { |
2515 | 0 | bool bAuto = false; |
2516 | 0 | if ( !isCHRATR(nWhich) || |
2517 | 0 | ( rSh.HasSelection() && rSh.IsSelFullPara() ) ) |
2518 | 0 | { |
2519 | 0 | SwTextFormatColl * pColl = rSh.GetCurTextFormatColl(); |
2520 | 0 | if ( pColl && pColl->IsAutoUpdateOnDirectFormat() ) |
2521 | 0 | { |
2522 | 0 | rSh.AutoUpdatePara( pColl, *pArgs ); |
2523 | 0 | bAuto = true; |
2524 | 0 | } |
2525 | 0 | } |
2526 | |
|
2527 | 0 | if (!bAuto) |
2528 | 0 | { |
2529 | 0 | rSh.SetAttrSet( *pArgs ); |
2530 | 0 | } |
2531 | 0 | } |
2532 | 0 | } |
2533 | 0 | else |
2534 | 0 | { |
2535 | 0 | if (nSlot == SID_ATTR_CHAR_KERNING) |
2536 | 0 | GetView().GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG_POSITION); |
2537 | 0 | else if (nSlot == SID_ATTR_CHAR_COLOR) |
2538 | 0 | GetView().GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG_EFFECT); |
2539 | 0 | else |
2540 | 0 | GetView().GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG); |
2541 | 0 | } |
2542 | 0 | rReq.Done(); |
2543 | 0 | } |
2544 | | |
2545 | | void SwBaseShell::GetTextCtrlState( SfxItemSet& rSet ) |
2546 | 0 | { |
2547 | 0 | SwWrtShell &rSh = GetShell(); |
2548 | 0 | rSh.GetCurAttr( rSet ); |
2549 | 0 | } |
2550 | | |
2551 | | void SwBaseShell::GetTextFontCtrlState( SfxItemSet& rSet ) |
2552 | 0 | { |
2553 | 0 | SwWrtShell &rSh = GetShell(); |
2554 | 0 | bool bFirst = true; |
2555 | 0 | std::optional<SfxItemSet> pFntCoreSet; |
2556 | 0 | SvtScriptType nScriptType = SvtScriptType::LATIN; |
2557 | 0 | SfxWhichIter aIter( rSet ); |
2558 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
2559 | 0 | while( nWhich ) |
2560 | 0 | { |
2561 | 0 | switch( nWhich ) |
2562 | 0 | { |
2563 | 0 | case RES_CHRATR_FONT: |
2564 | 0 | case RES_CHRATR_FONTSIZE: |
2565 | 0 | case RES_CHRATR_WEIGHT: |
2566 | 0 | case RES_CHRATR_POSTURE: |
2567 | 0 | { |
2568 | 0 | if( !pFntCoreSet ) |
2569 | 0 | { |
2570 | 0 | pFntCoreSet.emplace( *rSet.GetPool(), |
2571 | 0 | svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1> ); |
2572 | 0 | rSh.GetCurAttr( *pFntCoreSet ); |
2573 | 0 | nScriptType = rSh.GetScriptType(); |
2574 | | // #i42732# input language should be preferred over |
2575 | | // current cursor position to detect script type |
2576 | 0 | SwEditWin& rEditWin = GetView().GetEditWin(); |
2577 | 0 | if( rEditWin.IsUseInputLanguage() ) |
2578 | 0 | { |
2579 | 0 | if(!rSh.HasSelection() && ( |
2580 | 0 | nWhich == RES_CHRATR_FONT || |
2581 | 0 | nWhich == RES_CHRATR_FONTSIZE )) |
2582 | 0 | { |
2583 | 0 | LanguageType nInputLang = rEditWin.GetInputLanguage(); |
2584 | 0 | if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) |
2585 | 0 | nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); |
2586 | 0 | } |
2587 | 0 | } |
2588 | 0 | } |
2589 | 0 | SfxItemPool& rPool = *rSet.GetPool(); |
2590 | 0 | SvxScriptSetItem aSetItem( rPool.GetSlotId( nWhich ), rPool ); |
2591 | 0 | aSetItem.GetItemSet().Put( *pFntCoreSet, false ); |
2592 | 0 | const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType ); |
2593 | 0 | if( pI ) |
2594 | 0 | { |
2595 | 0 | rSet.Put( pI->CloneSetWhich(nWhich) ); |
2596 | 0 | } |
2597 | 0 | else |
2598 | 0 | rSet.InvalidateItem( nWhich ); |
2599 | | // Set input context of the SwEditWin according to the selected font and script type |
2600 | 0 | if(RES_CHRATR_FONT == nWhich) |
2601 | 0 | { |
2602 | 0 | vcl::Font aFont; |
2603 | 0 | if (const SvxFontItem* pFontItem = dynamic_cast<const SvxFontItem*>(pI)) |
2604 | 0 | { |
2605 | 0 | aFont.SetFamilyName(pFontItem->GetFamilyName()); |
2606 | 0 | aFont.SetStyleName(pFontItem->GetStyleName()); |
2607 | 0 | aFont.SetFamily(pFontItem->GetFamily()); |
2608 | 0 | aFont.SetPitch(pFontItem->GetPitch()); |
2609 | 0 | aFont.SetCharSet(pFontItem->GetCharSet()); |
2610 | 0 | } |
2611 | |
|
2612 | 0 | bool bVertical = rSh.IsInVerticalText(); |
2613 | 0 | aFont.SetOrientation(Degree10(bVertical ? 2700 : 0)); |
2614 | 0 | aFont.SetVertical(bVertical); |
2615 | 0 | GetView().GetEditWin().SetInputContext( InputContext( std::move(aFont), InputContextFlags::Text | |
2616 | 0 | InputContextFlags::ExtText ) ); |
2617 | 0 | } |
2618 | 0 | } |
2619 | 0 | break; |
2620 | | |
2621 | 0 | default: |
2622 | 0 | if( bFirst ) |
2623 | 0 | { |
2624 | 0 | rSh.GetCurAttr( rSet ); |
2625 | 0 | bFirst = false; |
2626 | 0 | } |
2627 | 0 | } |
2628 | 0 | nWhich = aIter.NextWhich(); |
2629 | 0 | } |
2630 | 0 | } |
2631 | | |
2632 | | void SwBaseShell::GetBckColState(SfxItemSet &rSet) |
2633 | 0 | { |
2634 | 0 | SwWrtShell &rSh = GetShell(); |
2635 | 0 | SfxWhichIter aIter(rSet); |
2636 | 0 | sal_uInt16 nWhich(aIter.FirstWhich()); |
2637 | 0 | SelectionType nSelType(rSh.GetSelectionType()); |
2638 | 0 | std::unique_ptr<SvxBrushItem> aBrushItem(std::make_unique<SvxBrushItem>(RES_BACKGROUND)); |
2639 | |
|
2640 | 0 | if( nWhich == SID_TABLE_CELL_BACKGROUND_COLOR ) |
2641 | 0 | { |
2642 | 0 | rSh.GetBoxBackground( aBrushItem ); |
2643 | 0 | } |
2644 | 0 | else |
2645 | 0 | { |
2646 | | // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set |
2647 | 0 | SfxItemSet aCoreSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILL_FIRST, XATTR_FILL_LAST>(GetPool())); |
2648 | |
|
2649 | 0 | aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet()); |
2650 | |
|
2651 | 0 | if(nSelType & SelectionType::Graphic || SelectionType::Frame & nSelType) |
2652 | 0 | { |
2653 | 0 | rSh.GetFlyFrameAttr(aCoreSet); |
2654 | 0 | } |
2655 | 0 | else |
2656 | 0 | { |
2657 | 0 | rSh.GetCurAttr(aCoreSet); |
2658 | 0 | } |
2659 | |
|
2660 | 0 | aBrushItem = getSvxBrushItemFromSourceSet(aCoreSet, RES_BACKGROUND); |
2661 | 0 | } |
2662 | |
|
2663 | 0 | while(nWhich) |
2664 | 0 | { |
2665 | 0 | switch(nWhich) |
2666 | 0 | { |
2667 | 0 | case SID_BACKGROUND_COLOR: |
2668 | 0 | case SID_TABLE_CELL_BACKGROUND_COLOR: |
2669 | 0 | { |
2670 | 0 | SvxColorItem aColorItem(aBrushItem->GetColor(), aBrushItem->getComplexColor(), nWhich); |
2671 | 0 | rSet.Put(aColorItem); |
2672 | 0 | break; |
2673 | 0 | } |
2674 | 0 | case SID_ATTR_BRUSH: |
2675 | 0 | case RES_BACKGROUND: |
2676 | 0 | { |
2677 | | // if this was intended to have a independent copy of the Item to be set |
2678 | | // this is not needed due to the ItemSet/Pool cloning Items which get set anyways. |
2679 | | // Keeping code as reference - it may have had other reasons I do notz see (?!?) |
2680 | | // std::unique_ptr<SfxPoolItem> pNewItem(aBrushItem.CloneSetWhich(GetPool().GetWhich(nWhich))); |
2681 | 0 | rSet.Put(*aBrushItem); |
2682 | 0 | break; |
2683 | 0 | } |
2684 | 0 | } |
2685 | | |
2686 | 0 | nWhich = aIter.NextWhich(); |
2687 | 0 | } |
2688 | 0 | } |
2689 | | |
2690 | | void SwBaseShell::ExecBckCol(SfxRequest& rReq) |
2691 | 0 | { |
2692 | 0 | SwWrtShell &rSh = GetShell(); |
2693 | 0 | SelectionType nSelType(rSh.GetSelectionType()); |
2694 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
2695 | 0 | sal_uInt16 nSlot(rReq.GetSlot()); |
2696 | |
|
2697 | 0 | if (!pArgs && nSlot != SID_BACKGROUND_COLOR && nSlot != SID_TABLE_CELL_BACKGROUND_COLOR) |
2698 | 0 | { |
2699 | 0 | return; |
2700 | 0 | } |
2701 | | |
2702 | 0 | std::unique_ptr<SvxBrushItem> aBrushItem(std::make_unique<SvxBrushItem>(RES_BACKGROUND)); |
2703 | |
|
2704 | 0 | if ( nSlot == SID_TABLE_CELL_BACKGROUND_COLOR ) |
2705 | 0 | { |
2706 | 0 | rSh.GetBoxBackground( aBrushItem ); |
2707 | 0 | } |
2708 | 0 | else |
2709 | 0 | { |
2710 | | // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set |
2711 | 0 | SfxItemSet aCoreSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILL_FIRST, XATTR_FILL_LAST>(GetPool())); |
2712 | |
|
2713 | 0 | aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet()); |
2714 | |
|
2715 | 0 | if((SelectionType::Frame & nSelType) || (SelectionType::Graphic & nSelType)) |
2716 | 0 | { |
2717 | 0 | rSh.GetFlyFrameAttr(aCoreSet); |
2718 | 0 | } |
2719 | 0 | else |
2720 | 0 | { |
2721 | 0 | rSh.GetCurAttr(aCoreSet); |
2722 | 0 | } |
2723 | |
|
2724 | 0 | aBrushItem = getSvxBrushItemFromSourceSet(aCoreSet, RES_BACKGROUND); |
2725 | 0 | } |
2726 | |
|
2727 | 0 | switch(nSlot) |
2728 | 0 | { |
2729 | 0 | case SID_BACKGROUND_COLOR: |
2730 | 0 | case SID_TABLE_CELL_BACKGROUND_COLOR: |
2731 | 0 | { |
2732 | 0 | bool bIsTransparent = false; |
2733 | |
|
2734 | 0 | aBrushItem->SetGraphicPos(GPOS_NONE); |
2735 | |
|
2736 | 0 | sal_uInt16 nSlotId = (nSlot == SID_BACKGROUND_COLOR) ? SID_BACKGROUND_COLOR : SID_TABLE_CELL_BACKGROUND_COLOR; |
2737 | 0 | if (pArgs) |
2738 | 0 | { |
2739 | 0 | const SvxColorItem& rNewColorItem = static_cast<const SvxColorItem&>(pArgs->Get(nSlotId)); |
2740 | 0 | aBrushItem->SetColor(rNewColorItem.GetValue()); |
2741 | 0 | aBrushItem->setComplexColor(rNewColorItem.getComplexColor()); |
2742 | 0 | GetView().GetViewFrame().GetBindings().SetState(rNewColorItem); |
2743 | 0 | } |
2744 | 0 | else |
2745 | 0 | { |
2746 | 0 | bIsTransparent = true; |
2747 | 0 | } |
2748 | |
|
2749 | 0 | if (bIsTransparent) |
2750 | 0 | { |
2751 | 0 | aBrushItem->SetColor(COL_TRANSPARENT); |
2752 | 0 | rReq.AppendItem(SvxColorItem(COL_TRANSPARENT,nSlot)); |
2753 | 0 | } |
2754 | 0 | break; |
2755 | 0 | } |
2756 | | |
2757 | 0 | case SID_ATTR_BRUSH: |
2758 | 0 | case RES_BACKGROUND: |
2759 | 0 | { |
2760 | 0 | assert(pArgs && "only SID_BACKGROUND_COLOR can have !pArgs, checked at entry"); |
2761 | 0 | aBrushItem.reset(static_cast<SvxBrushItem*>(pArgs->Get(GetPool().GetWhichIDFromSlotID(nSlot)).Clone())); |
2762 | 0 | break; |
2763 | 0 | } |
2764 | 0 | default: |
2765 | 0 | { |
2766 | 0 | rReq.Ignore(); |
2767 | 0 | OSL_FAIL("unknown message in ExecuteAttr!" ); |
2768 | 0 | return; |
2769 | 0 | } |
2770 | 0 | } |
2771 | | |
2772 | 0 | if ( nSlot == SID_TABLE_CELL_BACKGROUND_COLOR ) |
2773 | 0 | { |
2774 | 0 | rSh.SetBoxBackground( *aBrushItem ); |
2775 | 0 | } |
2776 | 0 | else |
2777 | 0 | { |
2778 | | // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set |
2779 | 0 | SfxItemSet aCoreSet(SfxItemSet::makeFixedSfxItemSet<XATTR_FILL_FIRST, XATTR_FILL_LAST>(GetPool())); |
2780 | |
|
2781 | 0 | aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet()); |
2782 | 0 | setSvxBrushItemAsFillAttributesToTargetSet(*aBrushItem, aCoreSet); |
2783 | |
|
2784 | 0 | if((SelectionType::Frame & nSelType) || (SelectionType::Graphic & nSelType)) |
2785 | 0 | { |
2786 | | // Template autoupdate |
2787 | 0 | SwFrameFormat* pFormat = rSh.GetSelectedFrameFormat(); |
2788 | |
|
2789 | 0 | if(pFormat && pFormat->IsAutoUpdateOnDirectFormat()) |
2790 | 0 | { |
2791 | 0 | rSh.AutoUpdateFrame(pFormat, aCoreSet); |
2792 | 0 | } |
2793 | 0 | else |
2794 | 0 | { |
2795 | 0 | rSh.SetFlyFrameAttr(aCoreSet); |
2796 | 0 | } |
2797 | 0 | } |
2798 | 0 | else |
2799 | 0 | { |
2800 | 0 | SwTextFormatColl* pColl = rSh.GetCurTextFormatColl(); |
2801 | |
|
2802 | 0 | if(pColl && pColl->IsAutoUpdateOnDirectFormat()) |
2803 | 0 | { |
2804 | 0 | rSh.AutoUpdatePara(pColl, aCoreSet); |
2805 | 0 | } |
2806 | 0 | else |
2807 | 0 | { |
2808 | 0 | rSh.SetAttrSet(aCoreSet); |
2809 | 0 | } |
2810 | 0 | } |
2811 | 0 | } |
2812 | |
|
2813 | 0 | rReq.Done(); |
2814 | 0 | } |
2815 | | |
2816 | | void SwBaseShell::GetBorderState(SfxItemSet &rSet) |
2817 | 0 | { |
2818 | 0 | SwWrtShell &rSh = GetShell(); |
2819 | | // Table cell(s) selected? |
2820 | 0 | bool bPrepare = true; |
2821 | 0 | bool bTableMode = rSh.IsTableMode(); |
2822 | 0 | if ( bTableMode ) |
2823 | 0 | { |
2824 | 0 | SfxItemSet aCoreSet(SfxItemSet::makeFixedSfxItemSet< |
2825 | 0 | RES_BOX, RES_BOX, SID_ATTR_BORDER_INNER, |
2826 | 0 | SID_ATTR_BORDER_INNER>(GetPool())); |
2827 | 0 | SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); |
2828 | 0 | aCoreSet.Put( aBoxInfo ); |
2829 | 0 | rSh.GetTabBorders( aCoreSet ); |
2830 | 0 | rSet.Put( aCoreSet ); |
2831 | 0 | } |
2832 | 0 | else if ( rSh.IsFrameSelected() ) |
2833 | 0 | { |
2834 | 0 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); |
2835 | 0 | rSet.Put( aMgr.GetAttrSet() ); |
2836 | 0 | bPrepare = false; |
2837 | 0 | } |
2838 | 0 | else |
2839 | | // Get border attributes via shell quite normal |
2840 | 0 | rSh.GetCurAttr( rSet ); |
2841 | 0 | if ( bPrepare ) |
2842 | 0 | ::PrepareBoxInfo( rSet, rSh ); |
2843 | | // Switch the border toolbox controller mode |
2844 | 0 | rSet.Put( SfxBoolItem( SID_BORDER_REDUCED_MODE, !bTableMode )); |
2845 | 0 | } |
2846 | | |
2847 | | void SwBaseShell::ExecDlg(SfxRequest &rReq) |
2848 | 0 | { |
2849 | 0 | SwWrtShell &rSh = GetShell(); |
2850 | 0 | weld::Window* pMDI = GetView().GetFrameWeld(); |
2851 | | // So that from the basic no dialogues for the background views are called: |
2852 | 0 | bool bBackground = (&GetView() != GetActiveView()); |
2853 | 0 | const SfxPoolItem* pItem = nullptr; |
2854 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
2855 | |
|
2856 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
2857 | 0 | const SfxItemSet* pOutSet = nullptr; |
2858 | 0 | bool bDone = false; |
2859 | 0 | if(pArgs) |
2860 | 0 | pArgs->GetItemState( GetPool().GetWhichIDFromSlotID(nSlot), false, &pItem ); |
2861 | |
|
2862 | 0 | switch ( nSlot ) |
2863 | 0 | { |
2864 | 0 | case FN_FORMAT_TITLEPAGE_DLG: |
2865 | 0 | { |
2866 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
2867 | 0 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateTitlePageDlg(pMDI)); |
2868 | 0 | VclAbstractDialog::AsyncContext aContext; |
2869 | 0 | aContext.maEndDialogFn = [](sal_Int32){}; |
2870 | 0 | pDlg->StartExecuteAsync(aContext); |
2871 | 0 | } |
2872 | 0 | break; |
2873 | 0 | case FN_FORMAT_PAGE_DLG: |
2874 | 0 | case FN_FORMAT_PAGE_COLUMN_DLG: |
2875 | 0 | case FN_FORMAT_PAGE_SETTING_DLG: |
2876 | 0 | case FN_FORMAT_PAGE_AREA_DLG: |
2877 | 0 | { |
2878 | 0 | if( !bBackground ) |
2879 | 0 | { |
2880 | 0 | const size_t nCurIdx = rSh.GetCurPageDesc(); |
2881 | 0 | const SwPageDesc& rPageDesc = rSh.GetPageDesc( nCurIdx ); |
2882 | | // Temporary view, because the shell does not need to be valid after the dialog |
2883 | | // for example disable header |
2884 | 0 | SwView& rTempView = GetView(); |
2885 | |
|
2886 | 0 | OUString sPageId; |
2887 | 0 | switch (nSlot) |
2888 | 0 | { |
2889 | 0 | case FN_FORMAT_PAGE_COLUMN_DLG: |
2890 | 0 | sPageId = "columns"; |
2891 | 0 | break; |
2892 | 0 | case FN_FORMAT_PAGE_SETTING_DLG: |
2893 | 0 | sPageId = "page"; |
2894 | 0 | break; |
2895 | 0 | case FN_FORMAT_PAGE_AREA_DLG: |
2896 | 0 | sPageId = "area"; |
2897 | 0 | break; |
2898 | 0 | case FN_FORMAT_PAGE_DLG: |
2899 | 0 | if (pItem) |
2900 | 0 | sPageId = static_cast<const SfxStringItem*>(pItem)->GetValue(); |
2901 | 0 | break; |
2902 | 0 | } |
2903 | 0 | rTempView.GetDocShell()->FormatPage(rReq.GetFrameWeld(), rPageDesc.GetName(), sPageId, rSh, &rReq); |
2904 | 0 | rTempView.InvalidateRulerPos(); |
2905 | |
|
2906 | 0 | bDone = true; // FormatPage() takes care of calling Done() |
2907 | 0 | } |
2908 | 0 | } |
2909 | 0 | break; |
2910 | 0 | case FN_FORMAT_BORDER_DLG: |
2911 | 0 | { |
2912 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet< |
2913 | 0 | RES_BOX, RES_SHADOW, SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>(rSh.GetAttrPool())); |
2914 | 0 | ScopedVclPtr<SfxAbstractDialog> pDlg; |
2915 | | // Table cell(s) selected? |
2916 | 0 | if ( rSh.IsTableMode() ) |
2917 | 0 | { |
2918 | | // Set border attributes Get/SetTabBorders() |
2919 | 0 | ::PrepareBoxInfo( aSet, rSh ); |
2920 | 0 | rSh.GetTabBorders( aSet ); |
2921 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
2922 | 0 | pDlg.disposeAndReset(pFact->CreateSwBorderDlg(pMDI, aSet, SwBorderModes::TABLE)); |
2923 | 0 | if ( pDlg->Execute() == RET_OK ) |
2924 | 0 | { |
2925 | 0 | rSh.SetTabBorders( *pDlg->GetOutputItemSet() ); |
2926 | 0 | pOutSet = pDlg->GetOutputItemSet(); |
2927 | 0 | } |
2928 | 0 | } |
2929 | 0 | else if ( rSh.IsFrameSelected() ) |
2930 | 0 | { |
2931 | | // Set border attributes via Frame-Manager |
2932 | 0 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); |
2933 | 0 | aSet.Put( aMgr.GetAttrSet() ); |
2934 | |
|
2935 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
2936 | 0 | pDlg.disposeAndReset(pFact->CreateSwBorderDlg(pMDI, aSet, SwBorderModes::FRAME)); |
2937 | 0 | if ( pDlg->Execute() == RET_OK ) |
2938 | 0 | { |
2939 | 0 | aMgr.SetAttrSet( *pDlg->GetOutputItemSet() ); |
2940 | 0 | aMgr.UpdateFlyFrame(); |
2941 | 0 | pOutSet = pDlg->GetOutputItemSet(); |
2942 | 0 | } |
2943 | 0 | } |
2944 | 0 | else |
2945 | 0 | { |
2946 | | // Set border attributes via Shell quite normal |
2947 | 0 | rSh.GetCurAttr( aSet ); |
2948 | 0 | ::PrepareBoxInfo( aSet, rSh ); |
2949 | |
|
2950 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
2951 | 0 | pDlg.disposeAndReset(pFact->CreateSwBorderDlg(pMDI, aSet, SwBorderModes::PARA)); |
2952 | 0 | if ( pDlg->Execute() == RET_OK ) |
2953 | 0 | { |
2954 | 0 | rSh.SetAttrSet( *pDlg->GetOutputItemSet() ); |
2955 | 0 | pOutSet = pDlg->GetOutputItemSet(); |
2956 | 0 | } |
2957 | 0 | } |
2958 | 0 | if(pOutSet) |
2959 | 0 | { |
2960 | 0 | rReq.Done(*pOutSet); |
2961 | 0 | bDone = true; |
2962 | 0 | } |
2963 | 0 | } |
2964 | 0 | break; |
2965 | 0 | case FN_FORMAT_BACKGROUND_DLG: |
2966 | 0 | { |
2967 | 0 | SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet< |
2968 | 0 | RES_BACKGROUND, RES_BACKGROUND, |
2969 | 0 | XATTR_FILL_FIRST, XATTR_FILL_LAST>(rSh.GetAttrPool())); |
2970 | |
|
2971 | 0 | ScopedVclPtr<SfxAbstractDialog> pDlg; |
2972 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
2973 | | |
2974 | | // Table cell(s) selected? |
2975 | 0 | if ( rSh.IsTableMode() ) |
2976 | 0 | { |
2977 | | // Get background attributes of the table and put it in the set |
2978 | | // tdf#144843 calling GetBoxBackground *requires* an incarnation to be handed over |
2979 | 0 | std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND)); |
2980 | 0 | rSh.GetBoxBackground( aBrush ); |
2981 | 0 | pDlg.disposeAndReset(pFact->CreateSwBackgroundDialog(pMDI, aSet)); |
2982 | 0 | aSet.Put( std::move(aBrush) ); |
2983 | 0 | if ( pDlg->Execute() == RET_OK ) |
2984 | 0 | { |
2985 | |
|
2986 | 0 | rSh.SetBoxBackground( pDlg->GetOutputItemSet()->Get( RES_BACKGROUND ) ); |
2987 | 0 | pOutSet = pDlg->GetOutputItemSet(); |
2988 | 0 | } |
2989 | 0 | } |
2990 | 0 | else if ( rSh.IsFrameSelected() ) |
2991 | 0 | { |
2992 | |
|
2993 | 0 | rSh.GetFlyFrameAttr( aSet ); |
2994 | |
|
2995 | 0 | pDlg.disposeAndReset(pFact->CreateSwBackgroundDialog(pMDI, aSet)); |
2996 | 0 | if ( pDlg->Execute() == RET_OK ) |
2997 | 0 | { |
2998 | 0 | rSh.SetFlyFrameAttr(const_cast<SfxItemSet &>(*pDlg->GetOutputItemSet()) ); |
2999 | 0 | pOutSet = pDlg->GetOutputItemSet(); |
3000 | 0 | } |
3001 | 0 | } |
3002 | 0 | else |
3003 | 0 | { |
3004 | | // Set border attributes Umrandungsattribute with the shell quite normal. |
3005 | 0 | rSh.GetCurAttr( aSet ); |
3006 | |
|
3007 | 0 | pDlg.disposeAndReset(pFact->CreateSwBackgroundDialog(pMDI, aSet)); |
3008 | 0 | if ( pDlg->Execute() == RET_OK ) |
3009 | 0 | { |
3010 | 0 | rSh.SetAttrSet( *pDlg->GetOutputItemSet() ); |
3011 | 0 | pOutSet = pDlg->GetOutputItemSet(); |
3012 | 0 | } |
3013 | 0 | } |
3014 | 0 | if(pOutSet) |
3015 | 0 | { |
3016 | 0 | rReq.Done(*pOutSet); |
3017 | 0 | bDone = true; |
3018 | 0 | } |
3019 | 0 | } |
3020 | 0 | break; |
3021 | | |
3022 | 0 | case SID_GRAPHIC_SIZE_CHECK: |
3023 | 0 | { |
3024 | 0 | sw::GraphicSizeCheckGUIResult aResult(rSh.GetDoc()); |
3025 | 0 | svx::GenericCheckDialog aDialog(pMDI, aResult); |
3026 | 0 | aDialog.run(); |
3027 | 0 | } |
3028 | 0 | break; |
3029 | | |
3030 | 0 | case SID_THEME_DIALOG: |
3031 | 0 | { |
3032 | 0 | auto* pDocument = rSh.GetDoc(); |
3033 | 0 | auto* pDocumentShell = pDocument->GetDocShell(); |
3034 | 0 | if (pDocumentShell) |
3035 | 0 | { |
3036 | 0 | SdrModel* pModel = pDocument->getIDocumentDrawModelAccess().GetDrawModel(); |
3037 | 0 | auto const& pTheme = pModel->getTheme(); |
3038 | 0 | if (pTheme) |
3039 | 0 | { |
3040 | 0 | std::shared_ptr<svx::IThemeColorChanger> xChanger(new sw::ThemeColorChanger(pDocumentShell)); |
3041 | 0 | auto pDialog = std::make_shared<svx::ThemeDialog>(pMDI, pTheme.get()); |
3042 | 0 | weld::DialogController::runAsync(pDialog, [pDialog, xChanger=std::move(xChanger)](sal_uInt32 nResult) { |
3043 | 0 | if (RET_OK != nResult) |
3044 | 0 | return; |
3045 | | |
3046 | 0 | auto pColorSet = pDialog->getCurrentColorSet(); |
3047 | 0 | if (pColorSet) |
3048 | 0 | { |
3049 | 0 | xChanger->apply(pColorSet); |
3050 | 0 | } |
3051 | 0 | }); |
3052 | 0 | } |
3053 | 0 | } |
3054 | 0 | } |
3055 | 0 | break; |
3056 | | |
3057 | 0 | default:OSL_FAIL("wrong Dispatcher (basesh.cxx)"); |
3058 | 0 | } |
3059 | 0 | if(!bDone) |
3060 | 0 | rReq.Done(); |
3061 | 0 | } |
3062 | | |
3063 | | SwWrtShell& SwBaseShell::GetShell() |
3064 | 0 | { |
3065 | 0 | return m_rView.GetWrtShell(); |
3066 | 0 | } |
3067 | | |
3068 | | SwWrtShell* SwBaseShell::GetShellPtr() |
3069 | 0 | { |
3070 | 0 | return m_rView.GetWrtShellPtr(); |
3071 | 0 | } |
3072 | | |
3073 | | static void EndUndo(SwWrtShell& rSh) |
3074 | 0 | { |
3075 | 0 | SwRewriter aRewriter; |
3076 | |
|
3077 | 0 | if (rSh.GetTableFormat()) |
3078 | 0 | { |
3079 | 0 | aRewriter.AddRule(UndoArg1, SwResId(STR_START_QUOTE)); |
3080 | 0 | aRewriter.AddRule(UndoArg2, rSh.GetTableFormat()->GetName()); |
3081 | 0 | aRewriter.AddRule(UndoArg3, SwResId(STR_END_QUOTE)); |
3082 | |
|
3083 | 0 | } |
3084 | 0 | rSh.EndUndo(SwUndoId::INSTABLE, &aRewriter); // If possible change the Shell |
3085 | 0 | } |
3086 | | |
3087 | | static void InsertTableImpl(SwWrtShell& rSh, |
3088 | | SwView &rTempView, |
3089 | | const UIName& aTableName, |
3090 | | sal_uInt16 nRows, |
3091 | | sal_uInt16 nCols, |
3092 | | SwInsertTableOptions aInsTableOpts, |
3093 | | const TableStyleName& aAutoName, |
3094 | | const std::unique_ptr<SwTableAutoFormat>& pTAFormat) |
3095 | 0 | { |
3096 | 0 | rSh.StartUndo(SwUndoId::INSTABLE); |
3097 | |
|
3098 | 0 | rSh.StartAllAction(); |
3099 | 0 | if( rSh.HasSelection() ) |
3100 | 0 | rSh.DelRight(); |
3101 | |
|
3102 | 0 | rSh.InsertTable( aInsTableOpts, nRows, nCols, pTAFormat.get() ); |
3103 | 0 | rSh.MoveTable( GotoPrevTable, fnTableStart ); |
3104 | |
|
3105 | 0 | if( !aTableName.isEmpty() && !rSh.GetTableStyle( aTableName ) ) |
3106 | 0 | rSh.GetTableFormat()->SetFormatName( aTableName ); |
3107 | |
|
3108 | 0 | if( pTAFormat != nullptr && !aAutoName.isEmpty() |
3109 | 0 | && aAutoName != SwViewShell::GetShellRes()->aStrNone ) |
3110 | 0 | { |
3111 | 0 | SwTableNode* pTableNode = const_cast<SwTableNode*>( rSh.IsCursorInTable() ); |
3112 | 0 | if ( pTableNode ) |
3113 | 0 | { |
3114 | 0 | pTableNode->GetTable().SetTableStyleName( aAutoName ); |
3115 | 0 | SwUndoTableAutoFormat* pUndo = new SwUndoTableAutoFormat( *pTableNode, *pTAFormat ); |
3116 | 0 | rSh.GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) ); |
3117 | 0 | } |
3118 | 0 | } |
3119 | |
|
3120 | 0 | rSh.EndAllAction(); |
3121 | 0 | rTempView.AutoCaption(TABLE_CAP); |
3122 | 0 | } |
3123 | | |
3124 | | void SwBaseShell::InsertTable( SfxRequest& _rRequest ) |
3125 | 0 | { |
3126 | 0 | const SfxItemSet* pArgs = _rRequest.GetArgs(); |
3127 | 0 | SwWrtShell& rSh = GetShell(); |
3128 | |
|
3129 | 0 | if ( rSh.GetFrameType( nullptr, true ) & FrameTypeFlags::FOOTNOTE ) |
3130 | 0 | return; |
3131 | | |
3132 | 0 | SwView &rTempView = GetView(); // Because GetView() does not work after the shell exchange |
3133 | 0 | bool bHTMLMode = 0 != (::GetHtmlMode(rTempView.GetDocShell())&HTMLMODE_ON); |
3134 | 0 | bool bCallEndUndo = false; |
3135 | |
|
3136 | 0 | if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() && |
3137 | 0 | !rSh.IsTableMode() ) |
3138 | 0 | { |
3139 | 0 | const SwModuleOptions* pModOpt = SwModule::get()->GetModuleConfig(); |
3140 | 0 | SwInsertTableOptions aInsTableOpts = pModOpt->GetInsTableFlags(bHTMLMode); |
3141 | |
|
3142 | 0 | rSh.StartUndo(SwUndoId::INSTABLE); |
3143 | 0 | bCallEndUndo = true; |
3144 | |
|
3145 | 0 | bool bInserted = rSh.TextToTable( aInsTableOpts, '\t' ); |
3146 | 0 | rSh.EnterStdMode(); |
3147 | 0 | if (bInserted) |
3148 | 0 | rTempView.AutoCaption(TABLE_CAP); |
3149 | 0 | _rRequest.Done(); |
3150 | 0 | } |
3151 | 0 | else |
3152 | 0 | { |
3153 | 0 | sal_uInt16 nColsIn = 0; |
3154 | 0 | sal_uInt16 nRowsIn = 0; |
3155 | 0 | SwInsertTableOptions aInsTableOptsIn( SwInsertTableFlags::All, 1 ); |
3156 | 0 | OUString aTableNameIn; |
3157 | 0 | OUString aAutoNameIn; |
3158 | 0 | std::unique_ptr<SwTableAutoFormat> pTAFormatIn; |
3159 | |
|
3160 | 0 | if( pArgs && pArgs->Count() >= 2 ) |
3161 | 0 | { |
3162 | 0 | const SfxStringItem* pName = _rRequest.GetArg<SfxStringItem>(FN_INSERT_TABLE); |
3163 | 0 | const SfxUInt16Item* pCols = _rRequest.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_COLUMN); |
3164 | 0 | const SfxUInt16Item* pRows = _rRequest.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_ROW); |
3165 | 0 | const SfxInt32Item* pFlags = _rRequest.GetArg<SfxInt32Item>(FN_PARAM_1); |
3166 | 0 | const SfxStringItem* pAuto = _rRequest.GetArg<SfxStringItem>(FN_PARAM_2); |
3167 | |
|
3168 | 0 | if ( pName ) |
3169 | 0 | aTableNameIn = pName->GetValue(); |
3170 | 0 | if ( pCols ) |
3171 | 0 | nColsIn = pCols->GetValue(); |
3172 | 0 | if ( pRows ) |
3173 | 0 | nRowsIn = pRows->GetValue(); |
3174 | 0 | if ( pAuto ) |
3175 | 0 | { |
3176 | 0 | aAutoNameIn = pAuto->GetValue(); |
3177 | 0 | if ( !aAutoNameIn.isEmpty() ) |
3178 | 0 | { |
3179 | 0 | const SwTableAutoFormatTable& rTableTable = SwModule::get()->GetAutoFormatTable(); |
3180 | 0 | for (size_t n = 0; n < rTableTable.size(); ++n) |
3181 | 0 | { |
3182 | 0 | if (rTableTable[n].GetName() == aAutoNameIn) |
3183 | 0 | { |
3184 | 0 | pTAFormatIn.reset(new SwTableAutoFormat(rTableTable[n])); |
3185 | 0 | break; |
3186 | 0 | } |
3187 | 0 | } |
3188 | 0 | } |
3189 | 0 | } |
3190 | |
|
3191 | 0 | if ( pFlags ) |
3192 | 0 | aInsTableOptsIn.mnInsMode = static_cast<SwInsertTableFlags>(pFlags->GetValue()); |
3193 | 0 | else |
3194 | 0 | { |
3195 | 0 | const SwModuleOptions* pModOpt = SwModule::get()->GetModuleConfig(); |
3196 | 0 | aInsTableOptsIn = pModOpt->GetInsTableFlags(bHTMLMode); |
3197 | 0 | } |
3198 | 0 | } |
3199 | |
|
3200 | 0 | if( !nColsIn || !nRowsIn ) |
3201 | 0 | { |
3202 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
3203 | 0 | std::shared_ptr<AbstractInsTableDlg> pAbstractDialog(pFact->CreateInsTableDlg(rTempView)); |
3204 | 0 | std::shared_ptr<weld::DialogController> pDialogController(pAbstractDialog->getDialogController()); |
3205 | |
|
3206 | 0 | weld::DialogController::runAsync(pDialogController, |
3207 | 0 | [pAbstractDialog=std::move(pAbstractDialog), &rSh, &rTempView, aTableNameIn, |
3208 | 0 | nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn] (sal_Int32 nResult) { |
3209 | 0 | if( RET_OK == nResult ) |
3210 | 0 | { |
3211 | 0 | sal_uInt16 nCols = nColsIn; |
3212 | 0 | sal_uInt16 nRows = nRowsIn; |
3213 | 0 | SwInsertTableOptions aInsTableOpts = aInsTableOptsIn; |
3214 | 0 | OUString aTableName = aTableNameIn; |
3215 | 0 | OUString aAutoName = aAutoNameIn; |
3216 | 0 | std::unique_ptr<SwTableAutoFormat> pTAFormat; |
3217 | |
|
3218 | 0 | pAbstractDialog->GetValues( aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat ); |
3219 | |
|
3220 | 0 | if( nCols && nRows ) |
3221 | 0 | { |
3222 | 0 | InsertTableImpl( rSh, rTempView, UIName(aTableName), nRows, nCols, aInsTableOpts, TableStyleName(aAutoName), pTAFormat ); |
3223 | 0 | EndUndo(rSh); |
3224 | 0 | } |
3225 | 0 | } |
3226 | 0 | } |
3227 | 0 | ); |
3228 | 0 | } |
3229 | 0 | else |
3230 | 0 | { |
3231 | | // record before shell change |
3232 | 0 | _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableNameIn ) ); |
3233 | 0 | if ( !aAutoNameIn.isEmpty() ) |
3234 | 0 | _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoNameIn ) ); |
3235 | 0 | _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nColsIn ) ); |
3236 | 0 | _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRowsIn ) ); |
3237 | 0 | _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, static_cast<sal_Int32>(aInsTableOptsIn.mnInsMode) ) ); |
3238 | 0 | _rRequest.Done(); |
3239 | |
|
3240 | 0 | InsertTableImpl( rSh, rTempView, UIName(aTableNameIn), nRowsIn, nColsIn, aInsTableOptsIn, TableStyleName(aAutoNameIn), pTAFormatIn ); |
3241 | |
|
3242 | 0 | bCallEndUndo = true; |
3243 | 0 | } |
3244 | 0 | } |
3245 | |
|
3246 | 0 | if( bCallEndUndo ) |
3247 | 0 | EndUndo(rSh); |
3248 | 0 | } |
3249 | | |
3250 | | void SwBaseShell::GetGalleryState( SfxItemSet &rSet ) |
3251 | 0 | { |
3252 | 0 | SwWrtShell &rSh = GetShell(); |
3253 | 0 | SfxWhichIter aIter( rSet ); |
3254 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
3255 | 0 | switch ( nWhich ) |
3256 | 0 | { |
3257 | 0 | case SID_GALLERY_BG_BRUSH: |
3258 | 0 | { |
3259 | 0 | SelectionType nSel = rSh.GetSelectionType(); |
3260 | 0 | SfxStringListItem aLst( nWhich ); |
3261 | 0 | std::vector<OUString> &rLst = aLst.GetList(); |
3262 | 0 | nParagraphPos = nGraphicPos = nOlePos = nFramePos = nTablePos = |
3263 | 0 | nTableRowPos = nTableCellPos = nPagePos = |
3264 | 0 | nHeaderPos = nFooterPos = 0; |
3265 | 0 | sal_uInt8 nPos = 1; |
3266 | 0 | rLst.push_back( SwResId( STR_SWBG_PAGE ) ); |
3267 | 0 | nPagePos = nPos++; |
3268 | 0 | sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); |
3269 | 0 | bool bHtmlMode = 0 != (nHtmlMode & HTMLMODE_ON); |
3270 | |
|
3271 | 0 | if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES)) && |
3272 | 0 | (nSel & SelectionType::Text) ) |
3273 | 0 | { |
3274 | 0 | rLst.push_back( SwResId( STR_SWBG_PARAGRAPH ) ); |
3275 | 0 | nParagraphPos = nPos++; |
3276 | 0 | } |
3277 | 0 | if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_SOME_STYLES)) && |
3278 | 0 | nSel & (SelectionType::Table|SelectionType::TableCell) ) |
3279 | 0 | { |
3280 | 0 | rLst.push_back( SwResId( STR_SWBG_TABLE ) ); |
3281 | 0 | nTablePos = nPos++; |
3282 | |
|
3283 | 0 | if(!bHtmlMode) |
3284 | 0 | { |
3285 | 0 | rLst.push_back( SwResId( STR_SWBG_TABLE_ROW ) ); |
3286 | 0 | nTableRowPos = nPos++; |
3287 | 0 | } |
3288 | |
|
3289 | 0 | rLst.push_back( SwResId( STR_SWBG_TABLE_CELL) ); |
3290 | 0 | nTableCellPos = nPos++; |
3291 | 0 | } |
3292 | 0 | if(!bHtmlMode) |
3293 | 0 | { |
3294 | 0 | if ( nSel & SelectionType::Frame ) |
3295 | 0 | { |
3296 | 0 | rLst.push_back( SwResId( STR_SWBG_FRAME ) ); |
3297 | 0 | nFramePos = nPos++; |
3298 | 0 | } |
3299 | 0 | if ( nSel & SelectionType::Graphic ) |
3300 | 0 | { |
3301 | 0 | rLst.push_back( SwResId( STR_SWBG_GRAPHIC ) ); |
3302 | 0 | nGraphicPos = nPos++; |
3303 | 0 | } |
3304 | 0 | if ( nSel & SelectionType::Ole ) |
3305 | 0 | { |
3306 | 0 | rLst.push_back( SwResId( STR_SWBG_OLE ) ); |
3307 | 0 | nOlePos = nPos++; |
3308 | 0 | } |
3309 | 0 | const FrameTypeFlags nType = rSh.GetFrameType(nullptr,true); |
3310 | 0 | if ( nType & FrameTypeFlags::HEADER ) |
3311 | 0 | { |
3312 | 0 | rLst.push_back( SwResId( STR_SWBG_HEADER ) ); |
3313 | 0 | nHeaderPos = nPos++; |
3314 | 0 | } |
3315 | 0 | if ( nType & FrameTypeFlags::FOOTER ) |
3316 | 0 | { |
3317 | 0 | rLst.push_back( SwResId( STR_SWBG_FOOTER ) ); |
3318 | 0 | nFooterPos = nPos; |
3319 | 0 | } |
3320 | 0 | } |
3321 | 0 | if ( rLst.empty() ) |
3322 | 0 | rSet.DisableItem( nWhich ); |
3323 | 0 | else |
3324 | 0 | rSet.Put( aLst ); |
3325 | 0 | break; |
3326 | 0 | } |
3327 | 0 | } |
3328 | 0 | } |
3329 | | |
3330 | | void SwBaseShell::ExecuteGallery(SfxRequest &rReq) |
3331 | 0 | { |
3332 | 0 | SwWrtShell &rSh = GetShell(); |
3333 | 0 | rSh.StartAction(); |
3334 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
3335 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
3336 | 0 | switch(nSlot) |
3337 | 0 | { |
3338 | 0 | case SID_GALLERY_BG_BRUSH: |
3339 | 0 | { |
3340 | 0 | if ( !pArgs ) |
3341 | 0 | break; |
3342 | | |
3343 | 0 | SelectionType nSel = rSh.GetSelectionType(); |
3344 | 0 | if ( nSel & SelectionType::DrawObjectEditMode ) |
3345 | 0 | break; |
3346 | | |
3347 | 0 | const SfxUInt16Item* pPos = rReq.GetArg<SfxUInt16Item>(SID_GALLERY_BG_POS); |
3348 | 0 | const SvxBrushItem* pBrush = rReq.GetArg<SvxBrushItem>(SID_GALLERY_BG_BRUSH); |
3349 | 0 | if ( !pPos || !pBrush ) |
3350 | 0 | break; |
3351 | | |
3352 | 0 | sal_uInt8 nPos = pPos->GetValue(); |
3353 | 0 | ++nPos; |
3354 | |
|
3355 | 0 | SvxBrushItem aBrush( *pBrush ); |
3356 | 0 | aBrush.SetWhich( RES_BACKGROUND ); |
3357 | 0 | if ( nPos == nParagraphPos ) |
3358 | 0 | rSh.SetAttrItem( aBrush ); |
3359 | 0 | else if ( nPos == nTablePos ) |
3360 | 0 | rSh.SetTabBackground( aBrush ); |
3361 | 0 | else if ( nPos == nTableRowPos ) |
3362 | 0 | rSh.SetRowBackground( aBrush ); |
3363 | 0 | else if ( nPos == nTableCellPos ) |
3364 | 0 | rSh.SetBoxBackground( aBrush ); |
3365 | 0 | else if ( nPos == nFramePos || nPos == nGraphicPos || nPos == nOlePos ) |
3366 | 0 | { |
3367 | 0 | SfxItemSet aCoreSet(SfxItemSet::makeFixedSfxItemSet<RES_BACKGROUND, RES_BACKGROUND>(GetPool())); |
3368 | 0 | aCoreSet.Put( aBrush ); |
3369 | 0 | rSh.SetFlyFrameAttr( aCoreSet ); |
3370 | 0 | } |
3371 | 0 | else if ( nPos == nPagePos || nPos == nHeaderPos || nPos == nFooterPos ) |
3372 | 0 | { |
3373 | 0 | sal_uInt16 nDesc = rSh.GetCurPageDesc(); |
3374 | 0 | SwPageDesc aDesc( rSh.GetPageDesc( nDesc ) ); |
3375 | 0 | if ( nPos == nPagePos ) |
3376 | 0 | aDesc.GetMaster().SetFormatAttr( aBrush ); |
3377 | 0 | else if ( nPos == nHeaderPos ) |
3378 | 0 | { |
3379 | 0 | SwFormatHeader aHead( aDesc.GetMaster().GetHeader() ); |
3380 | 0 | aHead.GetHeaderFormat()->SetFormatAttr( aBrush ); |
3381 | 0 | aDesc.GetMaster().SetFormatAttr( aHead ); |
3382 | 0 | } |
3383 | 0 | else if ( nPos == nFooterPos ) |
3384 | 0 | { |
3385 | 0 | SwFormatFooter aFoot( aDesc.GetMaster().GetFooter() ); |
3386 | 0 | aFoot.GetFooterFormat()->SetFormatAttr( aBrush ); |
3387 | 0 | aDesc.GetMaster().SetFormatAttr( aFoot ); |
3388 | 0 | } |
3389 | 0 | rSh.ChgPageDesc( nDesc, aDesc ); |
3390 | 0 | } |
3391 | 0 | break; |
3392 | 0 | } |
3393 | 0 | } |
3394 | 0 | rSh.EndAction(); |
3395 | 0 | rReq.Done(); |
3396 | 0 | } |
3397 | | |
3398 | | void SwBaseShell::ExecField( SfxRequest const & rReq ) |
3399 | 0 | { |
3400 | 0 | sal_uInt16 nSlot = rReq.GetSlot(); |
3401 | 0 | switch( nSlot ) |
3402 | 0 | { |
3403 | | #if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS |
3404 | | case FN_CHANGE_DBFIELD: |
3405 | | { |
3406 | | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
3407 | | VclPtr<AbstractChangeDbDialog> pDlg(pFact->CreateSwChangeDBDlg(GetView())); |
3408 | | pDlg->StartExecuteAsync( |
3409 | | [pDlg] (sal_Int32 nResult)->void |
3410 | | { |
3411 | | if (nResult == RET_OK) |
3412 | | pDlg->UpdateFields(); |
3413 | | pDlg->disposeOnce(); |
3414 | | } |
3415 | | ); |
3416 | | } |
3417 | | break; |
3418 | | #endif |
3419 | 0 | default: |
3420 | 0 | OSL_FAIL("wrong dispatcher"); |
3421 | 0 | } |
3422 | 0 | } |
3423 | | |
3424 | | std::shared_ptr<std::vector<std::unique_ptr<SwPaM>>> SwBaseShell::CopyPaMRing(SwPaM& rOrig) |
3425 | 0 | { |
3426 | 0 | auto vCursors = std::make_shared<std::vector<std::unique_ptr<SwPaM>>>(); |
3427 | 0 | vCursors->emplace_back(std::make_unique<SwPaM>(rOrig, nullptr)); |
3428 | 0 | for (auto& rCursor : rOrig.GetRingContainer()) |
3429 | 0 | { |
3430 | 0 | if (&rCursor != &rOrig) |
3431 | 0 | vCursors->emplace_back(std::make_unique<SwPaM>(rCursor, vCursors->front().get())); |
3432 | 0 | } |
3433 | 0 | return vCursors; |
3434 | 0 | } |
3435 | | |
3436 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |