File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 192, column 9 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
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 | ||||
22 | #include <sal/config.h> | |||
23 | ||||
24 | #include <hintids.hxx> | |||
25 | #include <svl/languageoptions.hxx> | |||
26 | #include <sfx2/linkmgr.hxx> | |||
27 | #include <sfx2/htmlmode.hxx> | |||
28 | #include <svx/imapdlg.hxx> | |||
29 | #include <sfx2/dispatch.hxx> | |||
30 | #include <sfx2/viewfrm.hxx> | |||
31 | #include <sfx2/request.hxx> | |||
32 | #include <svl/whiter.hxx> | |||
33 | #include <svl/visitem.hxx> | |||
34 | #include <editeng/langitem.hxx> | |||
35 | #include <svx/clipfmtitem.hxx> | |||
36 | #include <svx/contdlg.hxx> | |||
37 | #include <vcl/graph.hxx> | |||
38 | #include <vcl/inputctx.hxx> | |||
39 | #include <svl/slstitm.hxx> | |||
40 | #include <svl/ptitem.hxx> | |||
41 | #include <svl/stritem.hxx> | |||
42 | #include <editeng/colritem.hxx> | |||
43 | #include <editeng/fhgtitem.hxx> | |||
44 | #include <editeng/fontitem.hxx> | |||
45 | #include <editeng/shaditem.hxx> | |||
46 | #include <editeng/boxitem.hxx> | |||
47 | #include <editeng/brushitem.hxx> | |||
48 | #include <editeng/opaqitem.hxx> | |||
49 | #include <editeng/sizeitem.hxx> | |||
50 | #include <svx/flagsdef.hxx> | |||
51 | #include <editeng/scripttypeitem.hxx> | |||
52 | #include <sfx2/objface.hxx> | |||
53 | #include <fmturl.hxx> | |||
54 | #include <fmthdft.hxx> | |||
55 | #include <fmtclds.hxx> | |||
56 | #include <docsh.hxx> | |||
57 | #include <wrtsh.hxx> | |||
58 | #include <view.hxx> | |||
59 | #include <swmodule.hxx> | |||
60 | #include <swundo.hxx> | |||
61 | #include <fldbas.hxx> | |||
62 | #include <uitool.hxx> | |||
63 | #include <basesh.hxx> | |||
64 | #include <viewopt.hxx> | |||
65 | #include <fontcfg.hxx> | |||
66 | #include <fmtsrnd.hxx> | |||
67 | #include <fldmgr.hxx> | |||
68 | #include <frmmgr.hxx> | |||
69 | #include <tablemgr.hxx> | |||
70 | #include <mdiexp.hxx> | |||
71 | #include <swdtflvr.hxx> | |||
72 | #include <pagedesc.hxx> | |||
73 | #include <fmtcol.hxx> | |||
74 | #include <edtwin.hxx> | |||
75 | #include <tblafmt.hxx> | |||
76 | #include <swwait.hxx> | |||
77 | #include <cmdid.h> | |||
78 | #include <strings.hrc> | |||
79 | #include <unotxdoc.hxx> | |||
80 | #include <doc.hxx> | |||
81 | #include <IDocumentSettingAccess.hxx> | |||
82 | #include <IDocumentUndoRedo.hxx> | |||
83 | #include <swabstdlg.hxx> | |||
84 | #include <modcfg.hxx> | |||
85 | #include <svx/fmshell.hxx> | |||
86 | #include <SwRewriter.hxx> | |||
87 | #include <svx/galleryitem.hxx> | |||
88 | #include <com/sun/star/gallery/GalleryItemType.hpp> | |||
89 | #include <memory> | |||
90 | ||||
91 | #include <svx/unobrushitemhelper.hxx> | |||
92 | #include <comphelper/scopeguard.hxx> | |||
93 | #include <comphelper/lok.hxx> | |||
94 | ||||
95 | #include <svx/svxdlg.hxx> | |||
96 | ||||
97 | #include <shellres.hxx> | |||
98 | #include <UndoTable.hxx> | |||
99 | ||||
100 | FlyMode SwBaseShell::eFrameMode = FLY_DRAG_END; | |||
101 | ||||
102 | // These variables keep the state of Gallery (slot SID_GALLERY_BG_BRUSH) | |||
103 | // detected by GetGalleryState() for the subsequent ExecuteGallery() call. | |||
104 | ||||
105 | static sal_uInt8 nParagraphPos; | |||
106 | static sal_uInt8 nGraphicPos; | |||
107 | static sal_uInt8 nOlePos; | |||
108 | static sal_uInt8 nFramePos; | |||
109 | static sal_uInt8 nTablePos; | |||
110 | static sal_uInt8 nTableRowPos; | |||
111 | static sal_uInt8 nTableCellPos; | |||
112 | static sal_uInt8 nPagePos; | |||
113 | static sal_uInt8 nHeaderPos; | |||
114 | static sal_uInt8 nFooterPos; | |||
115 | ||||
116 | #define ShellClass_SwBaseShell | |||
117 | #include <sfx2/msg.hxx> | |||
118 | #include <swslots.hxx> | |||
119 | ||||
120 | #include <AccessibilityCheck.hxx> | |||
121 | #include <svx/AccessibilityCheckDialog.hxx> | |||
122 | ||||
123 | namespace | |||
124 | { | |||
125 | SvxContourDlg* GetContourDlg(SwView const &rView) | |||
126 | { | |||
127 | SfxChildWindow *pWnd = rView.GetViewFrame()->GetChildWindow(SvxContourDlgChildWindow::GetChildWindowId()); | |||
128 | return pWnd ? static_cast<SvxContourDlg*>(pWnd->GetController().get()) : nullptr; | |||
129 | } | |||
130 | ||||
131 | SvxIMapDlg* GetIMapDlg(SwView const &rView) | |||
132 | { | |||
133 | SfxChildWindow* pWnd = rView.GetViewFrame()->GetChildWindow(SvxIMapDlgChildWindow::GetChildWindowId()); | |||
134 | return pWnd ? static_cast<SvxIMapDlg*>(pWnd->GetController().get()) : nullptr; | |||
135 | } | |||
136 | } | |||
137 | ||||
138 | using namespace ::com::sun::star; | |||
139 | using namespace ::com::sun::star::uno; | |||
140 | using namespace ::com::sun::star::frame; | |||
141 | using namespace ::com::sun::star::lang; | |||
142 | ||||
143 | SFX_IMPL_SUPERCLASS_INTERFACE(SwBaseShell, SfxShell)SfxInterface* SwBaseShell::pInterface = nullptr; SfxInterface * SwBaseShell::GetStaticInterface() { if ( !pInterface ) { pInterface = new SfxInterface( "SwBaseShell", true, GetInterfaceId(), SfxShell ::GetStaticInterface(), aSwBaseShellSlots_Impl[0], sal_uInt16 (sizeof(aSwBaseShellSlots_Impl) / sizeof(SfxSlot) ) ); InitInterface_Impl (); } return pInterface; } SfxInterface* SwBaseShell::GetInterface () const { return GetStaticInterface(); } void SwBaseShell::RegisterInterface (const SfxModule* pMod) { GetStaticInterface()->Register(pMod ); } | |||
144 | ||||
145 | void SwBaseShell::InitInterface_Impl() | |||
146 | { | |||
147 | GetStaticInterface()->RegisterChildWindow(SvxIMapDlgChildWindow::GetChildWindowId()); | |||
148 | GetStaticInterface()->RegisterChildWindow(SvxContourDlgChildWindow::GetChildWindowId()); | |||
149 | } | |||
150 | ||||
151 | ||||
152 | static void lcl_UpdateIMapDlg( SwWrtShell& rSh ) | |||
153 | { | |||
154 | Graphic aGrf( rSh.GetIMapGraphic() ); | |||
155 | GraphicType nGrfType = aGrf.GetType(); | |||
156 | void* pEditObj = GraphicType::NONE != nGrfType && GraphicType::Default != nGrfType | |||
157 | ? rSh.GetIMapInventor() : nullptr; | |||
158 | std::unique_ptr<TargetList> pList(new TargetList); | |||
159 | SfxFrame::GetDefaultTargetList(*pList); | |||
160 | ||||
161 | SfxItemSet aSet( rSh.GetAttrPool(), svl::Items<RES_URL, RES_URL>{} ); | |||
162 | rSh.GetFlyFrameAttr( aSet ); | |||
163 | const SwFormatURL &rURL = aSet.Get( RES_URL ); | |||
164 | SvxIMapDlgChildWindow::UpdateIMapDlg( | |||
165 | aGrf, rURL.GetMap(), pList.get(), pEditObj ); | |||
166 | } | |||
167 | ||||
168 | static bool lcl_UpdateContourDlg( SwWrtShell &rSh, SelectionType nSel ) | |||
169 | { | |||
170 | Graphic aGraf( rSh.GetIMapGraphic() ); | |||
171 | GraphicType nGrfType = aGraf.GetType(); | |||
172 | bool bRet = GraphicType::NONE != nGrfType && GraphicType::Default != nGrfType; | |||
173 | if( bRet ) | |||
174 | { | |||
175 | OUString aGrfName; | |||
176 | if ( nSel & SelectionType::Graphic ) | |||
177 | rSh.GetGrfNms( &aGrfName, nullptr ); | |||
178 | ||||
179 | SvxContourDlg *pDlg = GetContourDlg(rSh.GetView()); | |||
180 | if (pDlg) | |||
181 | { | |||
182 | pDlg->Update(aGraf, !aGrfName.isEmpty(), | |||
183 | rSh.GetGraphicPolygon(), rSh.GetIMapInventor()); | |||
184 | } | |||
185 | } | |||
186 | return bRet; | |||
187 | } | |||
188 | ||||
189 | void SwBaseShell::ExecDelete(SfxRequest &rReq) | |||
190 | { | |||
191 | SwWrtShell &rSh = GetShell(); | |||
192 | SwEditWin& rTmpEditWin = GetView().GetEditWin(); | |||
193 | switch(rReq.GetSlot()) | |||
194 | { | |||
195 | case SID_DELETE(5000 + 713): | |||
196 | rSh.DelRight(); | |||
197 | break; | |||
198 | ||||
199 | case FN_BACKSPACE((20000 + 900) + 26): | |||
200 | ||||
201 | if( rSh.IsNoNum() ) | |||
202 | { | |||
203 | rSh.SttCursorMove(); | |||
204 | bool bLeft = rSh.Left( CRSR_SKIP_CHARS, true, 1, false ); | |||
205 | if( bLeft ) | |||
206 | { | |||
207 | rSh.DelLeft(); | |||
208 | } | |||
209 | else | |||
210 | // JP 15.07.96: If it no longer goes forward, cancel | |||
211 | // the numbering. For example at the beginning | |||
212 | // of a doc, frame, table or an area. | |||
213 | rSh.DelNumRules(); | |||
214 | ||||
215 | rSh.EndCursorMove(); | |||
216 | break; | |||
217 | } | |||
218 | ||||
219 | [[fallthrough]]; // otherwise call DelLeft | |||
220 | case FN_SHIFT_BACKSPACE((20000 + 900) + 42): | |||
221 | rSh.DelLeft(); | |||
222 | break; | |||
223 | default: | |||
224 | OSL_FAIL("wrong Dispatcher")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "224" ": "), "%s", "wrong Dispatcher"); } } while (false ); | |||
225 | return; | |||
226 | } | |||
227 | rReq.Done(); | |||
228 | ||||
229 | //#i42732# - notify the edit window that from now on we do not use the input language | |||
230 | rTmpEditWin.SetUseInputLanguage( false ); | |||
231 | } | |||
232 | ||||
233 | void SwBaseShell::ExecClpbrd(SfxRequest &rReq) | |||
234 | { | |||
235 | // Attention: At risk of suicide! | |||
236 | // After paste, paste special the shell can be destroy. | |||
237 | ||||
238 | SwWrtShell &rSh = GetShell(); | |||
239 | sal_uInt16 nId = rReq.GetSlot(); | |||
240 | bool bIgnore = false; | |||
241 | PasteTableType ePasteTable = PasteTableType::PASTE_DEFAULT; | |||
242 | ||||
243 | switch( nId ) | |||
244 | { | |||
245 | case SID_CUT(5000 + 710): | |||
246 | case SID_COPY(5000 + 711): | |||
247 | rView.GetEditWin().FlushInBuffer(); | |||
248 | if ( rSh.HasSelection() ) | |||
249 | { | |||
250 | rtl::Reference<SwTransferable> pTransfer = new SwTransferable( rSh ); | |||
251 | ||||
252 | if ( nId == SID_CUT(5000 + 710) && FlyProtectFlags::NONE == rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent) ) | |||
253 | pTransfer->Cut(); | |||
254 | else | |||
255 | { | |||
256 | const bool bLockedView = rSh.IsViewLocked(); | |||
257 | rSh.LockView( true ); //lock visible section | |||
258 | pTransfer->Copy(); | |||
259 | rSh.LockView( bLockedView ); | |||
260 | } | |||
261 | break; | |||
262 | } | |||
263 | return; | |||
264 | ||||
265 | case FN_PASTE_NESTED_TABLE((20000 + 1400) + 30): | |||
266 | case FN_TABLE_PASTE_ROW_BEFORE((20000 + 1400) + 31): | |||
267 | case FN_TABLE_PASTE_COL_BEFORE((20000 + 1400) + 32): | |||
268 | switch ( nId ) | |||
269 | { | |||
270 | case FN_PASTE_NESTED_TABLE((20000 + 1400) + 30): | |||
271 | ePasteTable = PasteTableType::PASTE_TABLE; | |||
272 | break; | |||
273 | case FN_TABLE_PASTE_ROW_BEFORE((20000 + 1400) + 31): | |||
274 | ePasteTable = PasteTableType::PASTE_ROW; | |||
275 | break; | |||
276 | case FN_TABLE_PASTE_COL_BEFORE((20000 + 1400) + 32): | |||
277 | ePasteTable = PasteTableType::PASTE_COLUMN; | |||
278 | break; | |||
279 | default: | |||
280 | ; | |||
281 | } | |||
282 | [[fallthrough]]; | |||
283 | case SID_PASTE(5000 + 712): | |||
284 | { | |||
285 | TransferableDataHelper aDataHelper( | |||
286 | TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin() ) ); | |||
287 | if( aDataHelper.GetXTransferable().is() | |||
288 | && SwTransferable::IsPaste( rSh, aDataHelper ) ) | |||
289 | { | |||
290 | // Temporary variables, because the shell could already be | |||
291 | // destroyed after the paste. | |||
292 | SwView* pView = &rView; | |||
293 | ||||
294 | RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA; | |||
295 | const SfxUInt16Item* pAnchorType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1((20000 + 1100)+60)); | |||
296 | if (pAnchorType) | |||
297 | nAnchorType = static_cast<RndStdIds>(pAnchorType->GetValue()); | |||
298 | bool bIgnoreComments = false; | |||
299 | const SfxBoolItem* pIgnoreComments = rReq.GetArg<SfxBoolItem>(FN_PARAM_2((20000 + 1100)+61)); | |||
300 | if (pIgnoreComments) | |||
301 | bIgnoreComments = pIgnoreComments->GetValue(); | |||
302 | SwTransferable::Paste(rSh, aDataHelper, nAnchorType, bIgnoreComments, ePasteTable); | |||
303 | ||||
304 | if( rSh.IsFrameSelected() || rSh.IsObjSelected() ) | |||
305 | rSh.EnterSelFrameMode(); | |||
306 | pView->AttrChangedNotify(nullptr); | |||
307 | } | |||
308 | else | |||
309 | return; | |||
310 | } | |||
311 | break; | |||
312 | ||||
313 | case SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312): | |||
314 | { | |||
315 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
316 | const SfxPoolItem* pFormat; | |||
317 | if( pArgs && SfxItemState::SET == pArgs->GetItemState( nId, false, &pFormat ) ) | |||
318 | { | |||
319 | TransferableDataHelper aDataHelper( | |||
320 | TransferableDataHelper::CreateFromSystemClipboard( | |||
321 | &rSh.GetView().GetEditWin()) ); | |||
322 | if( aDataHelper.GetXTransferable().is() | |||
323 | /*&& SwTransferable::IsPaste( rSh, aDataHelper )*/ ) | |||
324 | { | |||
325 | // Temporary variables, because the shell could already be | |||
326 | // destroyed after the paste. | |||
327 | SwView* pView = &rView; | |||
328 | ||||
329 | SwTransferable::PasteFormat( rSh, aDataHelper, | |||
330 | static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pFormat)->GetValue()) ); | |||
331 | ||||
332 | //Done() has to be called before the shell has been removed | |||
333 | rReq.Done(); | |||
334 | bIgnore = true; | |||
335 | if( rSh.IsFrameSelected() || rSh.IsObjSelected()) | |||
336 | rSh.EnterSelFrameMode(); | |||
337 | pView->AttrChangedNotify(nullptr); | |||
338 | } | |||
339 | } | |||
340 | } | |||
341 | break; | |||
342 | ||||
343 | case SID_PASTE_UNFORMATTED(5000 + 314): | |||
344 | { | |||
345 | TransferableDataHelper aDataHelper( | |||
346 | TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin()) ); | |||
347 | if( aDataHelper.GetXTransferable().is() | |||
348 | && SwTransferable::IsPaste( rSh, aDataHelper ) ) | |||
349 | { | |||
350 | // Temporary variables, because the shell could already be | |||
351 | // destroyed after the paste. | |||
352 | SwView* pView = &rView; | |||
353 | rReq.Ignore(); | |||
354 | bIgnore = true; | |||
355 | if(SwTransferable::PasteUnformatted( rSh, aDataHelper )) | |||
356 | { | |||
357 | SfxViewFrame* pViewFrame = pView->GetViewFrame(); | |||
358 | uno::Reference< frame::XDispatchRecorder > xRecorder = | |||
359 | pViewFrame->GetBindings().GetRecorder(); | |||
360 | if(xRecorder.is()) { | |||
361 | SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312) ); | |||
362 | aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312), static_cast<sal_uInt32>(SotClipboardFormatId::STRING) ) ); | |||
363 | aReq.Done(); | |||
364 | } | |||
365 | } | |||
366 | ||||
367 | if (rSh.IsFrameSelected() || rSh.IsObjSelected()) | |||
368 | rSh.EnterSelFrameMode(); | |||
369 | pView->AttrChangedNotify(nullptr); | |||
370 | } | |||
371 | else | |||
372 | return; | |||
373 | } | |||
374 | break; | |||
375 | ||||
376 | case SID_PASTE_SPECIAL(5000 + 311): | |||
377 | { | |||
378 | std::shared_ptr<TransferableDataHelper> aDataHelper = | |||
379 | std::make_shared<TransferableDataHelper>(TransferableDataHelper::CreateFromSystemClipboard( &rSh.GetView().GetEditWin())); | |||
380 | ||||
381 | if( aDataHelper->GetXTransferable().is() | |||
382 | && SwTransferable::IsPaste( rSh, *aDataHelper ) | |||
383 | && !rSh.CursorInsideInputField() ) | |||
384 | { | |||
385 | rReq.Ignore(); | |||
386 | bIgnore = true; | |||
387 | ||||
388 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | |||
389 | VclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( rReq.GetFrameWeld() )); | |||
390 | ||||
391 | // Prepare the dialog | |||
392 | SwTransferable::PrePasteSpecial(rSh, *aDataHelper, pDlg); | |||
393 | pDlg->PreGetFormat(*aDataHelper); | |||
394 | ||||
395 | ||||
396 | pDlg->StartExecuteAsync([aDataHelper, pDlg, &rSh, this](sal_Int32 nResult){ | |||
397 | if (nResult == RET_OK) | |||
398 | { | |||
399 | // Temporary variables, because the shell could already be | |||
400 | // destroyed after the paste. | |||
401 | SwView* pView = &rView; | |||
402 | bool bRet = false; | |||
403 | SotClipboardFormatId nFormatId = pDlg->GetFormatOnly(); | |||
404 | ||||
405 | if( nFormatId != SotClipboardFormatId::NONE ) | |||
406 | bRet = SwTransferable::PasteFormat( rSh, *aDataHelper, nFormatId ); | |||
407 | ||||
408 | if (bRet) | |||
409 | { | |||
410 | SfxViewFrame* pViewFrame = pView->GetViewFrame(); | |||
411 | uno::Reference< frame::XDispatchRecorder > xRecorder = | |||
412 | pViewFrame->GetBindings().GetRecorder(); | |||
413 | if(xRecorder.is()) { | |||
414 | SfxRequest aReq( pViewFrame, SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312) ); | |||
415 | aReq.AppendItem( SfxUInt32Item( SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312), static_cast<sal_uInt32>(nFormatId) ) ); | |||
416 | aReq.Done(); | |||
417 | } | |||
418 | } | |||
419 | ||||
420 | if (rSh.IsFrameSelected() || rSh.IsObjSelected()) | |||
421 | rSh.EnterSelFrameMode(); | |||
422 | pView->AttrChangedNotify(nullptr); | |||
423 | } | |||
424 | ||||
425 | pDlg->disposeOnce(); | |||
426 | ||||
427 | }); | |||
428 | } | |||
429 | else | |||
430 | return; | |||
431 | } | |||
432 | break; | |||
433 | ||||
434 | default: | |||
435 | OSL_FAIL("wrong Dispatcher")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "435" ": "), "%s", "wrong Dispatcher"); } } while (false ); | |||
436 | return; | |||
437 | } | |||
438 | if(!bIgnore) | |||
439 | rReq.Done(); | |||
440 | } | |||
441 | ||||
442 | // ClipBoard state | |||
443 | ||||
444 | void SwBaseShell::StateClpbrd(SfxItemSet &rSet) | |||
445 | { | |||
446 | SwWrtShell &rSh = GetShell(); | |||
447 | SfxWhichIter aIter(rSet); | |||
448 | ||||
449 | const bool bCopy = rSh.HasSelection(); | |||
450 | ||||
451 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
452 | ||||
453 | while(nWhich) | |||
454 | { | |||
455 | switch(nWhich) | |||
456 | { | |||
457 | case SID_CUT(5000 + 710): | |||
458 | if( FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent ) ) | |||
459 | { | |||
460 | rSet.DisableItem( nWhich ); | |||
461 | break; | |||
462 | } | |||
463 | [[fallthrough]]; | |||
464 | case SID_COPY(5000 + 711): | |||
465 | if( !bCopy || GetObjectShell()->isContentExtractionLocked()) | |||
466 | rSet.DisableItem( nWhich ); | |||
467 | break; | |||
468 | ||||
469 | case FN_PASTE_NESTED_TABLE((20000 + 1400) + 30): | |||
470 | case FN_TABLE_PASTE_ROW_BEFORE((20000 + 1400) + 31): | |||
471 | case FN_TABLE_PASTE_COL_BEFORE((20000 + 1400) + 32): | |||
472 | if( !rSh.IsCursorInTable() | |||
473 | || !GetView().IsPasteSpecialAllowed() | |||
474 | || rSh.CursorInsideInputField() | |||
475 | // disable if not a native Writer table and not a spreadsheet format | |||
476 | || !GetView().IsPasteSpreadsheet(rSh.GetTableCopied()) ) | |||
477 | { | |||
478 | rSet.DisableItem( nWhich ); | |||
479 | } | |||
480 | break; | |||
481 | ||||
482 | case SID_PASTE(5000 + 712): | |||
483 | if( !GetView().IsPasteAllowed() ) | |||
484 | { | |||
485 | rSet.DisableItem( nWhich ); | |||
486 | } | |||
487 | break; | |||
488 | ||||
489 | case SID_PASTE_SPECIAL(5000 + 311): | |||
490 | if( !GetView().IsPasteSpecialAllowed() | |||
491 | || rSh.CursorInsideInputField() ) | |||
492 | { | |||
493 | rSet.DisableItem( nWhich ); | |||
494 | } | |||
495 | break; | |||
496 | ||||
497 | case SID_PASTE_UNFORMATTED(5000 + 314): | |||
498 | if( !GetView().IsPasteSpecialAllowed() ) | |||
499 | { | |||
500 | rSet.DisableItem( nWhich ); | |||
501 | } | |||
502 | break; | |||
503 | ||||
504 | case SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312): | |||
505 | { | |||
506 | TransferableDataHelper aDataHelper( | |||
507 | TransferableDataHelper::CreateFromSystemClipboard( | |||
508 | &rSh.GetView().GetEditWin()) ); | |||
509 | ||||
510 | SvxClipboardFormatItem aFormatItem( nWhich ); | |||
511 | SwTransferable::FillClipFormatItem( rSh, aDataHelper, aFormatItem ); | |||
512 | rSet.Put( aFormatItem ); | |||
513 | } | |||
514 | break; | |||
515 | } | |||
516 | nWhich = aIter.NextWhich(); | |||
517 | } | |||
518 | } | |||
519 | ||||
520 | // Perform undo | |||
521 | ||||
522 | void SwBaseShell::ExecUndo(SfxRequest &rReq) | |||
523 | { | |||
524 | SwWrtShell &rWrtShell = GetShell(); | |||
525 | ||||
526 | SwUndoId nUndoId(SwUndoId::EMPTY); | |||
527 | sal_uInt16 nId = rReq.GetSlot(), nCnt = 1; | |||
528 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
529 | const SfxPoolItem* pItem; | |||
530 | if( pArgs && SfxItemState::SET == pArgs->GetItemState( nId, false, &pItem )) | |||
531 | nCnt = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); | |||
532 | ||||
533 | // Repair mode: allow undo/redo of all undo actions, even if access would | |||
534 | // be limited based on the view shell ID. | |||
535 | bool bRepair = false; | |||
536 | if (pArgs && pArgs->GetItemState(SID_REPAIRPACKAGE(5000 + 1683), false, &pItem) == SfxItemState::SET) | |||
537 | bRepair = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | |||
538 | ||||
539 | // #i106349#: save pointer: undo/redo may delete the shell, i.e., this! | |||
540 | SfxViewFrame *const pViewFrame( GetView().GetViewFrame() ); | |||
541 | ||||
542 | IDocumentUndoRedo& rUndoRedo = rWrtShell.GetIDocumentUndoRedo(); | |||
543 | bool bWasRepair = rUndoRedo.DoesRepair(); | |||
544 | rUndoRedo.DoRepair(bRepair); | |||
545 | comphelper::ScopeGuard aGuard([&rUndoRedo, bWasRepair]() | |||
546 | { | |||
547 | rUndoRedo.DoRepair(bWasRepair); | |||
548 | }); | |||
549 | ||||
550 | switch( nId ) | |||
551 | { | |||
552 | case SID_UNDO(5000 + 701): | |||
553 | if (rUndoRedo.GetLastUndoInfo(nullptr, &nUndoId, &rWrtShell.GetView())) | |||
554 | { | |||
555 | for (SwViewShell& rShell : rWrtShell.GetRingContainer()) | |||
556 | rShell.LockPaint(); | |||
557 | rWrtShell.Do( SwWrtShell::UNDO, nCnt ); | |||
558 | for (SwViewShell& rShell : rWrtShell.GetRingContainer()) | |||
559 | rShell.UnlockPaint(); | |||
560 | } | |||
561 | break; | |||
562 | ||||
563 | case SID_REDO(5000 + 700): | |||
564 | if (rUndoRedo.GetFirstRedoInfo(nullptr, &nUndoId, &rWrtShell.GetView())) | |||
565 | { | |||
566 | for (SwViewShell& rShell : rWrtShell.GetRingContainer()) | |||
567 | rShell.LockPaint(); | |||
568 | rWrtShell.Do( SwWrtShell::REDO, nCnt ); | |||
569 | for (SwViewShell& rShell : rWrtShell.GetRingContainer()) | |||
570 | rShell.UnlockPaint(); | |||
571 | } | |||
572 | break; | |||
573 | ||||
574 | case SID_REPEAT(5000 + 702): | |||
575 | rWrtShell.Do( SwWrtShell::REPEAT ); | |||
576 | break; | |||
577 | default: | |||
578 | OSL_FAIL("wrong Dispatcher")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "578" ": "), "%s", "wrong Dispatcher"); } } while (false ); | |||
579 | } | |||
580 | ||||
581 | if (nUndoId == SwUndoId::CONFLICT) | |||
582 | { | |||
583 | rReq.SetReturnValue( SfxUInt32Item(nId, static_cast<sal_uInt32>(SID_REPAIRPACKAGE(5000 + 1683))) ); | |||
584 | } | |||
585 | else if (nUndoId == SwUndoId::INSFMTATTR) | |||
586 | { | |||
587 | rWrtShell.GetDoc()->GetDocShell()->GetStyleSheetPool()->Broadcast(SfxHint(SfxHintId::StyleSheetModified)); | |||
588 | } | |||
589 | ||||
590 | if (pViewFrame) { pViewFrame->GetBindings().InvalidateAll(false); } | |||
591 | } | |||
592 | ||||
593 | // State of undo | |||
594 | ||||
595 | void SwBaseShell::StateUndo(SfxItemSet &rSet) | |||
596 | { | |||
597 | SwUndoId nUndoId(SwUndoId::EMPTY); | |||
598 | SwWrtShell &rSh = GetShell(); | |||
599 | SfxWhichIter aIter(rSet); | |||
600 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
601 | while(nWhich) | |||
602 | { | |||
603 | switch(nWhich) | |||
604 | { | |||
605 | case SID_UNDO(5000 + 701): | |||
606 | { | |||
607 | if (rSh.GetLastUndoInfo(nullptr, &nUndoId, &rSh.GetView())) | |||
608 | { | |||
609 | rSet.Put( SfxStringItem(nWhich, | |||
610 | rSh.GetDoString(SwWrtShell::UNDO))); | |||
611 | } | |||
612 | else if (nUndoId == SwUndoId::CONFLICT) | |||
613 | { | |||
614 | rSet.Put( SfxUInt32Item(nWhich, static_cast<sal_uInt32>(SID_REPAIRPACKAGE(5000 + 1683))) ); | |||
615 | } | |||
616 | else | |||
617 | rSet.DisableItem(nWhich); | |||
618 | ||||
619 | break; | |||
620 | } | |||
621 | case SID_REDO(5000 + 700): | |||
622 | { | |||
623 | if (rSh.GetFirstRedoInfo(nullptr, &nUndoId, &rSh.GetView())) | |||
624 | { | |||
625 | rSet.Put(SfxStringItem(nWhich, | |||
626 | rSh.GetDoString(SwWrtShell::REDO))); | |||
627 | } | |||
628 | else if (nUndoId == SwUndoId::CONFLICT) | |||
629 | { | |||
630 | rSet.Put( SfxInt32Item(nWhich, static_cast<sal_uInt32>(SID_REPAIRPACKAGE(5000 + 1683))) ); | |||
631 | } | |||
632 | else | |||
633 | rSet.DisableItem(nWhich); | |||
634 | break; | |||
635 | } | |||
636 | case SID_REPEAT(5000 + 702): | |||
637 | { // Repeat is only possible if no REDO is possible - UI-Restriction | |||
638 | if ((!rSh.GetFirstRedoInfo(nullptr, nullptr)) && | |||
639 | !rSh.IsSelFrameMode() && | |||
640 | (SwUndoId::EMPTY != rSh.GetRepeatInfo(nullptr))) | |||
641 | { | |||
642 | rSet.Put(SfxStringItem(nWhich, rSh.GetRepeatString())); | |||
643 | } | |||
644 | else | |||
645 | rSet.DisableItem(nWhich); | |||
646 | break; | |||
647 | } | |||
648 | ||||
649 | case SID_GETUNDOSTRINGS( 10000 + 923 ): | |||
650 | if (rSh.GetLastUndoInfo(nullptr, nullptr)) | |||
651 | { | |||
652 | SfxStringListItem aStrLst( nWhich ); | |||
653 | rSh.GetDoStrings( SwWrtShell::UNDO, aStrLst ); | |||
654 | rSet.Put( aStrLst ); | |||
655 | } | |||
656 | else | |||
657 | rSet.DisableItem( nWhich ); | |||
658 | break; | |||
659 | ||||
660 | case SID_GETREDOSTRINGS( 10000 + 924 ): | |||
661 | if (rSh.GetFirstRedoInfo(nullptr, nullptr)) | |||
662 | { | |||
663 | SfxStringListItem aStrLst( nWhich ); | |||
664 | rSh.GetDoStrings( SwWrtShell::REDO, aStrLst ); | |||
665 | rSet.Put( aStrLst ); | |||
666 | } | |||
667 | else | |||
668 | rSet.DisableItem( nWhich ); | |||
669 | break; | |||
670 | } | |||
671 | nWhich = aIter.NextWhich(); | |||
672 | } | |||
673 | } | |||
674 | ||||
675 | // Evaluate respectively dispatching the slot Id | |||
676 | ||||
677 | void SwBaseShell::Execute(SfxRequest &rReq) | |||
678 | { | |||
679 | const SfxPoolItem *pItem; | |||
680 | SwWrtShell &rSh = GetShell(); | |||
681 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
682 | bool bMore = false; | |||
683 | ||||
684 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
685 | switch(nSlot) | |||
686 | { | |||
687 | case FN_REPAGINATE((20000 + 100) + 61): | |||
688 | { | |||
689 | Reference < XModel > xModel = GetView().GetDocShell()->GetModel(); | |||
690 | auto pDoc = comphelper::getUnoTunnelImplementation<SwXTextDocument>(xModel); | |||
691 | pDoc->NotifyRefreshListeners(); | |||
692 | rSh.CalcLayout(); | |||
693 | } | |||
694 | break; | |||
695 | case FN_UPDATE_FIELDS((20000 + 100) + 26): | |||
696 | { | |||
697 | rSh.UpdateDocStat(); | |||
698 | rSh.EndAllTableBoxEdit(); | |||
699 | rSh.SwViewShell::UpdateFields(true); | |||
700 | ||||
701 | if( rSh.IsCursorInTable() ) | |||
702 | { | |||
703 | if( !rSh.IsTableComplexForChart() ) | |||
704 | SwTableFUNC( &rSh ).UpdateChart(); | |||
705 | rSh.ClearTableBoxContent(); | |||
706 | rSh.SaveTableBoxContent(); | |||
707 | } | |||
708 | } | |||
709 | break; | |||
710 | case FN_UPDATE_CHARTS((20000 + 1800) + 34): | |||
711 | { | |||
712 | SwWait aWait( *rView.GetDocShell(), true ); | |||
713 | rSh.UpdateAllCharts(); | |||
714 | } | |||
715 | break; | |||
716 | ||||
717 | case FN_UPDATE_ALL((20000 + 1800) + 28): | |||
718 | { | |||
719 | comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer | |||
720 | = GetObjectShell()->getEmbeddedObjectContainer(); | |||
721 | rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true); | |||
722 | ||||
723 | SwView& rTempView = GetView(); | |||
724 | rSh.EnterStdMode(); | |||
725 | if( !rSh.GetLinkManager().GetLinks().empty() ) | |||
726 | { | |||
727 | rSh.StartAllAction(); | |||
728 | rSh.GetLinkManager().UpdateAllLinks( false, true, nullptr ); | |||
729 | rSh.EndAllAction(); | |||
730 | } | |||
731 | SfxDispatcher &rDis = *rTempView.GetViewFrame()->GetDispatcher(); | |||
732 | rDis.Execute( FN_UPDATE_FIELDS((20000 + 100) + 26) ); | |||
733 | rDis.Execute( FN_UPDATE_TOX((20000 + 600) + 53) ); | |||
734 | rDis.Execute( FN_UPDATE_CHARTS((20000 + 1800) + 34) ); | |||
735 | rSh.CalcLayout(); | |||
736 | } | |||
737 | break; | |||
738 | ||||
739 | case FN_UPDATE_INPUTFIELDS((20000 + 100) + 43): | |||
740 | rSh.UpdateInputFields(); | |||
741 | break; | |||
742 | ||||
743 | case FN_PREV_BOOKMARK((20000 + 100) + 69): | |||
744 | rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoPrevBookmark())); | |||
745 | break; | |||
746 | case FN_NEXT_BOOKMARK((20000 + 100) + 68): | |||
747 | rReq.SetReturnValue(SfxBoolItem( nSlot, rSh.GoNextBookmark())); | |||
748 | break; | |||
749 | ||||
750 | case FN_GOTO_NEXT_MARK((20000 + 900) + 76): | |||
751 | case FN_GOTO_PREV_MARK((20000 + 900) + 77): | |||
752 | { | |||
753 | SwFieldMgr aFieldMgr; | |||
754 | SwFieldType* pFieldType = aFieldMgr.GetFieldType(SwFieldIds::JumpEdit); | |||
755 | ||||
756 | if (pFieldType) | |||
757 | { | |||
758 | if (rSh.IsSelFrameMode()) | |||
759 | { | |||
760 | rSh.UnSelectFrame(); | |||
761 | rSh.LeaveSelFrameMode(); | |||
762 | } | |||
763 | ||||
764 | if (rSh.HasMark()) | |||
765 | { | |||
766 | SwMvContext aMvContext(&rSh); | |||
767 | if (rSh.IsCursorPtAtEnd()) | |||
768 | rSh.SwapPam(); | |||
769 | rSh.ClearMark(); | |||
770 | rSh.EndSelect(); | |||
771 | } | |||
772 | bool bRet = rSh.MoveFieldType( pFieldType, nSlot == FN_GOTO_NEXT_MARK((20000 + 900) + 76) ); | |||
773 | SwField* pCurField = bRet ? rSh.GetCurField() : nullptr; | |||
774 | if (pCurField) | |||
775 | rSh.ClickToField(*pCurField); | |||
776 | rReq.SetReturnValue(SfxBoolItem( nSlot, bRet)); | |||
777 | } | |||
778 | } | |||
779 | break; | |||
780 | ||||
781 | case FN_START_DOC_DIRECT((20000 + 900) + 78): | |||
782 | case FN_END_DOC_DIRECT((20000 + 900) + 79): | |||
783 | { | |||
784 | if (rSh.IsSelFrameMode()) | |||
785 | { | |||
786 | rSh.UnSelectFrame(); | |||
787 | rSh.LeaveSelFrameMode(); | |||
788 | } | |||
789 | rSh.EnterStdMode(); | |||
790 | nSlot == FN_START_DOC_DIRECT((20000 + 900) + 78) ? | |||
791 | rSh.SttEndDoc(true) : | |||
792 | rSh.SttEndDoc(false); | |||
793 | } | |||
794 | break; | |||
795 | case FN_GOTO_PREV_OBJ((20000 + 900) + 45): | |||
796 | case FN_GOTO_NEXT_OBJ((20000 + 900) + 44): | |||
797 | { | |||
798 | bool bSuccess = rSh.GotoObj( nSlot == FN_GOTO_NEXT_OBJ((20000 + 900) + 44) ); | |||
799 | rReq.SetReturnValue(SfxBoolItem(nSlot, bSuccess)); | |||
800 | if (bSuccess && !rSh.IsSelFrameMode()) | |||
801 | { | |||
802 | rSh.HideCursor(); | |||
803 | rSh.EnterSelFrameMode(); | |||
804 | GetView().AttrChangedNotify(nullptr); | |||
805 | } | |||
806 | } | |||
807 | break; | |||
808 | case SID_GALLERY_FORMATS( 10000 + 280 ): | |||
809 | { | |||
810 | const SvxGalleryItem* pGalleryItem = SfxItemSet::GetItem<SvxGalleryItem>(pArgs, SID_GALLERY_FORMATS( 10000 + 280 ), false); | |||
811 | if ( !pGalleryItem ) | |||
812 | break; | |||
813 | ||||
814 | const SelectionType nSelType = rSh.GetSelectionType(); | |||
815 | sal_Int8 nGalleryItemType( pGalleryItem->GetType() ); | |||
816 | ||||
817 | if ( (!rSh.IsSelFrameMode() || nSelType & SelectionType::Graphic) && | |||
818 | nGalleryItemType == css::gallery::GalleryItemType::GRAPHIC ) | |||
819 | { | |||
820 | SwWait aWait( *rView.GetDocShell(), true ); | |||
821 | ||||
822 | OUString aGrfName, aFltName; | |||
823 | const Graphic aGrf( pGalleryItem->GetGraphic() ); | |||
824 | ||||
825 | if ( nSelType & SelectionType::Graphic ) | |||
826 | rSh.ReRead( aGrfName, aFltName, &aGrf ); | |||
827 | else | |||
828 | rSh.Insert( aGrfName, aFltName, aGrf ); | |||
829 | ||||
830 | GetView().GetEditWin().GrabFocus(); | |||
831 | } | |||
832 | else if(!rSh.IsSelFrameMode() && | |||
833 | nGalleryItemType == css::gallery::GalleryItemType::MEDIA ) | |||
834 | { | |||
835 | const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA(5000 + 1696), pGalleryItem->GetURL() ); | |||
836 | GetView().GetViewFrame()->GetDispatcher()->ExecuteList( | |||
837 | SID_INSERT_AVMEDIA(5000 + 1696), SfxCallMode::SYNCHRON, | |||
838 | { &aMediaURLItem }); | |||
839 | } | |||
840 | } | |||
841 | break; | |||
842 | case FN_PAGE_STYLE_SET_COLS((20000 + 400) + 138): | |||
843 | { | |||
844 | if (pArgs) | |||
845 | { | |||
846 | // Determine the current PageDescriptor and fill the set with that. | |||
847 | const size_t nCurIdx = rSh.GetCurPageDesc(); | |||
848 | SwPageDesc aPageDesc(rSh.GetPageDesc(nCurIdx)); | |||
849 | ||||
850 | SwFrameFormat &rFormat = aPageDesc.GetMaster(); | |||
851 | ||||
852 | SwFormatCol aFormatCol = rFormat.GetCol(); | |||
853 | ||||
854 | sal_uInt16 nCount; | |||
855 | if(SfxItemState::SET == pArgs->GetItemState(nSlot)) | |||
856 | nCount = static_cast<const SfxUInt16Item &>(pArgs->Get(nSlot)).GetValue(); | |||
857 | else | |||
858 | nCount = pArgs->Get(SID_ATTR_COLUMNSTypedWhichId<SfxUInt16Item>( 10000 + 220 )).GetValue(); | |||
859 | sal_uInt16 nGutterWidth = DEF_GUTTER_WIDTH(283 / 5 * 3); | |||
860 | ||||
861 | aFormatCol.Init(nCount ? nCount : 1, nGutterWidth, USHRT_MAX(32767 *2 +1)); | |||
862 | aFormatCol.SetWishWidth(USHRT_MAX(32767 *2 +1)); | |||
863 | aFormatCol.SetGutterWidth(nGutterWidth, USHRT_MAX(32767 *2 +1)); | |||
864 | ||||
865 | rFormat.SetFormatAttr(aFormatCol); | |||
866 | ||||
867 | rSh.ChgPageDesc(nCurIdx, aPageDesc); | |||
868 | } | |||
869 | else | |||
870 | GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_COLUMN_DLG((20000 + 400) + 49)); | |||
871 | } | |||
872 | break; | |||
873 | case FN_CONVERT_TABLE_TO_TEXT((20000 + 400) + 132): | |||
874 | case FN_CONVERT_TEXT_TO_TABLE((20000 + 400) + 131): | |||
875 | case FN_CONVERT_TEXT_TABLE((20000 + 400) + 100): | |||
876 | { | |||
877 | sal_Unicode cDelim = 0; | |||
878 | bool bToTable = false; | |||
879 | if( nSlot == FN_CONVERT_TEXT_TO_TABLE((20000 + 400) + 131) || | |||
880 | ( nSlot == FN_CONVERT_TEXT_TABLE((20000 + 400) + 100) && nullptr == rSh.GetTableFormat() )) | |||
881 | bToTable = true; | |||
882 | SwInsertTableOptions aInsTableOpts( SwInsertTableFlags::All, 1 ); | |||
883 | SwTableAutoFormat const* pTAFormat = nullptr; | |||
884 | std::unique_ptr<SwTableAutoFormatTable> pAutoFormatTable; | |||
885 | bool bDeleteFormat = true; | |||
886 | if(pArgs && SfxItemState::SET == pArgs->GetItemState( FN_PARAM_1((20000 + 1100)+60), true, &pItem)) | |||
887 | { | |||
888 | aInsTableOpts.mnInsMode = SwInsertTableFlags::NONE; | |||
889 | // Delimiter | |||
890 | OUString sDelim = static_cast< const SfxStringItem* >(pItem)->GetValue(); | |||
891 | if(!sDelim.isEmpty()) | |||
892 | cDelim = sDelim[0]; | |||
893 | // AutoFormat | |||
894 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_2((20000 + 1100)+61), true, &pItem)) | |||
895 | { | |||
896 | OUString sAutoFormat = static_cast< const SfxStringItem* >(pItem)->GetValue(); | |||
897 | ||||
898 | pAutoFormatTable.reset(new SwTableAutoFormatTable); | |||
899 | pAutoFormatTable->Load(); | |||
900 | ||||
901 | for( sal_uInt16 i = 0, nCount = pAutoFormatTable->size(); i < nCount; i++ ) | |||
902 | { | |||
903 | SwTableAutoFormat const*const pFormat = &(*pAutoFormatTable)[ i ]; | |||
904 | if( pFormat->GetName() == sAutoFormat ) | |||
905 | { | |||
906 | pTAFormat = pFormat; | |||
907 | bDeleteFormat = false; | |||
908 | break; | |||
909 | } | |||
910 | } | |||
911 | } | |||
912 | //WithHeader | |||
913 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_3((20000 + 1100)+62), true, &pItem) && | |||
914 | static_cast< const SfxBoolItem* >(pItem)->GetValue()) | |||
915 | aInsTableOpts.mnInsMode |= SwInsertTableFlags::Headline; | |||
916 | // RepeatHeaderLines | |||
917 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_4((20000 + 1100)+63), true, &pItem)) | |||
918 | aInsTableOpts.mnRowsToRepeat = | |||
919 | static_cast<sal_uInt16>(static_cast< const SfxInt16Item* >(pItem)->GetValue()); | |||
920 | //WithBorder | |||
921 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_5((20000 + 1100)+64), true, &pItem) && | |||
922 | static_cast< const SfxBoolItem* >(pItem)->GetValue()) | |||
923 | aInsTableOpts.mnInsMode |= SwInsertTableFlags::DefaultBorder; | |||
924 | //DontSplitTable | |||
925 | if(SfxItemState::SET == pArgs->GetItemState( FN_PARAM_6((20000 + 1100)+65), true, &pItem) && | |||
926 | !static_cast< const SfxBoolItem* >(pItem)->GetValue() ) | |||
927 | aInsTableOpts.mnInsMode |= SwInsertTableFlags::SplitLayout; | |||
928 | } | |||
929 | else | |||
930 | { | |||
931 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
932 | ScopedVclPtr<AbstractSwConvertTableDlg> pDlg(pFact->CreateSwConvertTableDlg(GetView(), bToTable)); | |||
933 | if( RET_OK == pDlg->Execute() ) | |||
934 | { | |||
935 | pDlg->GetValues( cDelim, aInsTableOpts, pTAFormat ); | |||
936 | ||||
937 | } | |||
938 | } | |||
939 | ||||
940 | if( cDelim ) | |||
941 | { | |||
942 | //Shell change! | |||
943 | SwView& rSaveView = rView; | |||
944 | bool bInserted = false; | |||
945 | //recording: | |||
946 | SfxViewFrame* pViewFrame = GetView().GetViewFrame(); | |||
947 | if( SfxRequest::HasMacroRecorder(pViewFrame) ) | |||
948 | { | |||
949 | SfxRequest aReq( pViewFrame, nSlot); | |||
950 | aReq.AppendItem( SfxStringItem( FN_PARAM_1((20000 + 1100)+60), OUString(cDelim) )); | |||
951 | if(bToTable) | |||
952 | { | |||
953 | if(pTAFormat) | |||
954 | aReq.AppendItem( SfxStringItem( FN_PARAM_2((20000 + 1100)+61), pTAFormat->GetName())); | |||
955 | aReq.AppendItem( SfxBoolItem ( FN_PARAM_3((20000 + 1100)+62), bool(aInsTableOpts.mnInsMode & SwInsertTableFlags::Headline))); | |||
956 | aReq.AppendItem( SfxInt16Item( FN_PARAM_4((20000 + 1100)+63), static_cast<short>(aInsTableOpts.mnRowsToRepeat) )); | |||
957 | aReq.AppendItem( SfxBoolItem ( FN_PARAM_5((20000 + 1100)+64), bool(aInsTableOpts.mnInsMode & SwInsertTableFlags::DefaultBorder) )); | |||
958 | aReq.AppendItem( SfxBoolItem ( FN_PARAM_6((20000 + 1100)+65), !(aInsTableOpts.mnInsMode & SwInsertTableFlags::SplitLayout))); | |||
959 | } | |||
960 | aReq.Done(); | |||
961 | } | |||
962 | ||||
963 | if( !bToTable ) | |||
964 | rSh.TableToText( cDelim ); | |||
965 | else | |||
966 | { | |||
967 | bInserted = rSh.TextToTable( aInsTableOpts, cDelim, pTAFormat ); | |||
968 | } | |||
969 | rSh.EnterStdMode(); | |||
970 | ||||
971 | if( bInserted ) | |||
972 | rSaveView.AutoCaption( TABLE_CAP ); | |||
973 | } | |||
974 | if(bDeleteFormat) | |||
975 | delete pTAFormat; | |||
976 | } | |||
977 | break; | |||
978 | case SID_STYLE_WATERCAN(5000 + 554): | |||
979 | case SID_STYLE_UPDATE_BY_EXAMPLE(5000 + 556): | |||
980 | case SID_STYLE_NEW_BY_EXAMPLE(5000 + 555): | |||
981 | case SID_STYLE_APPLY(5000 + 552): | |||
982 | { | |||
983 | ShellMode eMode = GetView().GetShellMode(); | |||
984 | if ( ShellMode::Draw != eMode && | |||
985 | ShellMode::DrawForm != eMode && | |||
986 | ShellMode::DrawText != eMode && | |||
987 | ShellMode::Bezier != eMode ) | |||
988 | { | |||
989 | // oj #107754# | |||
990 | if ( SID_STYLE_WATERCAN(5000 + 554) == nSlot ) | |||
991 | { | |||
992 | const bool bLockedView = rSh.IsViewLocked(); | |||
993 | rSh.LockView( true ); //lock visible section | |||
994 | ||||
995 | GetView().GetDocShell()->ExecStyleSheet(rReq); | |||
996 | ||||
997 | rSh.LockView( bLockedView ); | |||
998 | } | |||
999 | else | |||
1000 | // Will be recorded from the DocShell | |||
1001 | GetView().GetDocShell()->ExecStyleSheet(rReq); | |||
1002 | } | |||
1003 | } | |||
1004 | break; | |||
1005 | case SID_CLASSIFICATION_APPLY(5000 + 672): | |||
1006 | { | |||
1007 | GetView().GetDocShell()->Execute(rReq); | |||
1008 | } | |||
1009 | break; | |||
1010 | case SID_CLASSIFICATION_DIALOG( 10000 + 1171 ): | |||
1011 | { | |||
1012 | GetView().GetDocShell()->Execute(rReq); | |||
1013 | } | |||
1014 | break; | |||
1015 | case SID_PARAGRAPH_SIGN_CLASSIFY_DLG( 10000 + 1170 ): | |||
1016 | { | |||
1017 | GetView().GetDocShell()->Execute(rReq); | |||
1018 | } | |||
1019 | break; | |||
1020 | case SID_WATERMARK(5000 + 676): | |||
1021 | { | |||
1022 | GetView().GetDocShell()->Execute(rReq); | |||
1023 | } | |||
1024 | break; | |||
1025 | case FN_ESCAPE((20000 + 900) + 41): | |||
1026 | GetView().ExecuteSlot(rReq); | |||
1027 | break; | |||
1028 | case SID_IMAP( 10000 + 371 ): | |||
1029 | { | |||
1030 | sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); | |||
1031 | ||||
1032 | SfxViewFrame* pVFrame = GetView().GetViewFrame(); | |||
1033 | pVFrame->ToggleChildWindow( nId ); | |||
1034 | pVFrame->GetBindings().Invalidate( SID_IMAP( 10000 + 371 ) ); | |||
1035 | ||||
1036 | if ( pVFrame->HasChildWindow( nId ) && rSh.IsFrameSelected() ) | |||
1037 | lcl_UpdateIMapDlg( rSh ); | |||
1038 | } | |||
1039 | break; | |||
1040 | case SID_IMAP_EXEC( 10000 + 374 ): | |||
1041 | { | |||
1042 | SvxIMapDlg* pDlg = GetIMapDlg(GetView()); | |||
1043 | ||||
1044 | // Check, if the allocation is useful or allowed at all. | |||
1045 | if ( rSh.IsFrameSelected() && | |||
1046 | pDlg->GetEditingObject() == rSh.GetIMapInventor() ) | |||
1047 | { | |||
1048 | SfxItemSet aSet( rSh.GetAttrPool(), svl::Items<RES_URL, RES_URL>{} ); | |||
1049 | rSh.GetFlyFrameAttr( aSet ); | |||
1050 | SwFormatURL aURL( aSet.Get( RES_URL ) ); | |||
1051 | aURL.SetMap( &pDlg->GetImageMap() ); | |||
1052 | aSet.Put( aURL ); | |||
1053 | rSh.SetFlyFrameAttr( aSet ); | |||
1054 | } | |||
1055 | } | |||
1056 | break; | |||
1057 | case SID_CONTOUR_DLG( 10000 + 334 ): | |||
1058 | { | |||
1059 | sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); | |||
1060 | ||||
1061 | SfxViewFrame* pVFrame = GetView().GetViewFrame(); | |||
1062 | pVFrame->ToggleChildWindow( nId ); | |||
1063 | pVFrame->GetBindings().Invalidate( SID_CONTOUR_DLG( 10000 + 334 ) ); | |||
1064 | ||||
1065 | SelectionType nSel = rSh.GetSelectionType(); | |||
1066 | if ( pVFrame->HasChildWindow( nId ) && | |||
1067 | (nSel & (SelectionType::Graphic|SelectionType::Ole)) ) | |||
1068 | { | |||
1069 | lcl_UpdateContourDlg( rSh, nSel ); | |||
1070 | } | |||
1071 | } | |||
1072 | break; | |||
1073 | case SID_CONTOUR_EXEC( 10000 + 335 ): | |||
1074 | { | |||
1075 | SvxContourDlg *pDlg = GetContourDlg(GetView()); | |||
1076 | // Check, if the allocation is useful or allowed at all. | |||
1077 | SelectionType nSel = rSh.GetSelectionType(); | |||
1078 | if ( nSel & (SelectionType::Graphic|SelectionType::Ole) ) | |||
1079 | { | |||
1080 | if (pDlg && pDlg->GetEditingObject() == rSh.GetIMapInventor()) | |||
1081 | { | |||
1082 | rSh.StartAction(); | |||
1083 | SfxItemSet aSet( rSh.GetAttrPool(), svl::Items<RES_SURROUND, RES_SURROUND>{}); | |||
1084 | rSh.GetFlyFrameAttr( aSet ); | |||
1085 | SwFormatSurround aSur( aSet.Get( RES_SURROUND ) ); | |||
1086 | if ( !aSur.IsContour() ) | |||
1087 | { | |||
1088 | aSur.SetContour( true ); | |||
1089 | if ( aSur.GetSurround() == css::text::WrapTextMode_NONE ) | |||
1090 | aSur.SetSurround( css::text::WrapTextMode_PARALLEL ); | |||
1091 | aSet.Put( aSur ); | |||
1092 | rSh.SetFlyFrameAttr( aSet ); | |||
1093 | } | |||
1094 | const tools::PolyPolygon aPoly( pDlg->GetPolyPolygon() ); | |||
1095 | rSh.SetGraphicPolygon( &aPoly ); | |||
1096 | if ( pDlg->IsGraphicChanged() ) | |||
1097 | rSh.ReRead( OUString(), OUString(), &pDlg->GetGraphic()); | |||
1098 | rSh.EndAction(); | |||
1099 | } | |||
1100 | } | |||
1101 | } | |||
1102 | break; | |||
1103 | case FN_FRAME_TO_ANCHOR((20000 + 900) + 59): | |||
1104 | { | |||
1105 | rSh.GotoFlyAnchor(); | |||
1106 | rSh.EnterStdMode(); | |||
1107 | rSh.CallChgLnk(); | |||
1108 | } | |||
1109 | break; | |||
1110 | case FN_TOOL_ANCHOR_PAGE((20000 + 300) + 50): | |||
1111 | case FN_TOOL_ANCHOR_PARAGRAPH((20000 + 300) + 51): | |||
1112 | case FN_TOOL_ANCHOR_CHAR((20000 + 300) + 84): | |||
1113 | case FN_TOOL_ANCHOR_AT_CHAR((20000 + 1400) + 12): | |||
1114 | case FN_TOOL_ANCHOR_FRAME((20000 + 300) + 66): | |||
1115 | { | |||
1116 | RndStdIds eSet = nSlot == FN_TOOL_ANCHOR_PAGE((20000 + 300) + 50) | |||
1117 | ? RndStdIds::FLY_AT_PAGE | |||
1118 | : nSlot == FN_TOOL_ANCHOR_PARAGRAPH((20000 + 300) + 51) | |||
1119 | ? RndStdIds::FLY_AT_PARA | |||
1120 | : nSlot == FN_TOOL_ANCHOR_FRAME((20000 + 300) + 66) | |||
1121 | ? RndStdIds::FLY_AT_FLY | |||
1122 | : nSlot == FN_TOOL_ANCHOR_CHAR((20000 + 300) + 84) | |||
1123 | ? RndStdIds::FLY_AS_CHAR | |||
1124 | : RndStdIds::FLY_AT_CHAR; | |||
1125 | rSh.StartUndo(); | |||
1126 | if (rSh.IsObjSelected()) | |||
1127 | rSh.ChgAnchor(eSet); | |||
1128 | else if (rSh.IsFrameSelected()) | |||
1129 | { | |||
1130 | SwFormatAnchor aAnc(eSet, rSh.GetPhyPageNum()); | |||
1131 | SfxItemSet aSet(SwFEShell::makeItemSetFromFormatAnchor(GetPool(), aAnc)); | |||
1132 | rSh.SetFlyFrameAttr(aSet); | |||
1133 | } | |||
1134 | // if new anchor is 'as char' and it is a Math object and the usual | |||
1135 | // pre-conditions are met then align the formula to the baseline of the text | |||
1136 | const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() ); | |||
1137 | const bool bDoMathBaselineAlignment = xObj.is() && SotExchange::IsMath( xObj->getClassID() ) | |||
1138 | && RndStdIds::FLY_AS_CHAR == eSet && rSh.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ); | |||
1139 | if (bDoMathBaselineAlignment) | |||
1140 | rSh.AlignFormulaToBaseline( xObj ); | |||
1141 | ||||
1142 | sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); | |||
1143 | if( nHtmlMode ) | |||
1144 | { | |||
1145 | SfxItemSet aSet(GetPool(), svl::Items<RES_SURROUND, RES_HORI_ORIENT>{}); | |||
1146 | rSh.GetFlyFrameAttr(aSet); | |||
1147 | ||||
1148 | const SwFormatSurround& rSurround = aSet.Get(RES_SURROUND); | |||
1149 | const SwFormatVertOrient& rVert = aSet.Get(RES_VERT_ORIENT); | |||
1150 | const SwFormatHoriOrient& rHori = aSet.Get(RES_HORI_ORIENT); | |||
1151 | sal_Int16 eVOrient = rVert.GetVertOrient(); | |||
1152 | sal_Int16 eHOrient = rHori.GetHoriOrient(); | |||
1153 | css::text::WrapTextMode eSurround = rSurround.GetSurround(); | |||
1154 | ||||
1155 | switch( eSet ) | |||
1156 | { | |||
1157 | case RndStdIds::FLY_AT_FLY: | |||
1158 | case RndStdIds::FLY_AT_PAGE: | |||
1159 | //Wrap through, left or from left, top, from top | |||
1160 | if(eSurround != css::text::WrapTextMode_THROUGH) | |||
1161 | aSet.Put(SwFormatSurround(css::text::WrapTextMode_THROUGH)); | |||
1162 | ||||
1163 | if( eVOrient != text::VertOrientation::TOP && eVOrient != text::VertOrientation::NONE) | |||
1164 | aSet.Put(SwFormatVertOrient(0, text::VertOrientation::TOP)); | |||
1165 | ||||
1166 | if (eHOrient != text::HoriOrientation::NONE && eHOrient != text::HoriOrientation::LEFT) | |||
1167 | aSet.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT)); | |||
1168 | break; | |||
1169 | ||||
1170 | case RndStdIds::FLY_AT_PARA: | |||
1171 | // left, from left, right, top, no wrap, wrap left and right | |||
1172 | if (eSurround != css::text::WrapTextMode_LEFT && eSurround != css::text::WrapTextMode_RIGHT) | |||
1173 | aSet.Put(SwFormatSurround(css::text::WrapTextMode_LEFT)); | |||
1174 | ||||
1175 | if( eVOrient != text::VertOrientation::TOP) | |||
1176 | aSet.Put(SwFormatVertOrient(0, text::VertOrientation::TOP)); | |||
1177 | ||||
1178 | if (eHOrient != text::HoriOrientation::NONE && eHOrient != text::HoriOrientation::LEFT && eHOrient != text::HoriOrientation::RIGHT) | |||
1179 | aSet.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT)); | |||
1180 | break; | |||
1181 | ||||
1182 | case RndStdIds::FLY_AT_CHAR: | |||
1183 | // left, from left, right, top, wrap through | |||
1184 | if(eSurround != css::text::WrapTextMode_THROUGH) | |||
1185 | aSet.Put(SwFormatSurround(css::text::WrapTextMode_THROUGH)); | |||
1186 | ||||
1187 | if( eVOrient != text::VertOrientation::TOP) | |||
1188 | aSet.Put(SwFormatVertOrient(0, text::VertOrientation::TOP)); | |||
1189 | ||||
1190 | if (eHOrient != text::HoriOrientation::NONE && eHOrient != text::HoriOrientation::LEFT && eHOrient != text::HoriOrientation::RIGHT) | |||
1191 | aSet.Put(SwFormatHoriOrient(0, text::HoriOrientation::LEFT)); | |||
1192 | break; | |||
1193 | ||||
1194 | default: | |||
1195 | ; | |||
1196 | } | |||
1197 | ||||
1198 | if( aSet.Count() ) | |||
1199 | rSh.SetFlyFrameAttr( aSet ); | |||
1200 | } | |||
1201 | rSh.EndUndo(); | |||
1202 | ||||
1203 | GetView().GetViewFrame()->GetBindings().Invalidate( SID_ANCHOR_MENU( 10000 + 1172 ) ); | |||
1204 | } | |||
1205 | break; | |||
1206 | ||||
1207 | case FN_FRAME_NOWRAP((20000 + 400) + 72): | |||
1208 | case FN_FRAME_WRAP((20000 + 400) + 73): | |||
1209 | case FN_FRAME_WRAP_IDEAL((20000 + 400) + 162): | |||
1210 | case FN_FRAME_WRAPTHRU((20000 + 400) + 74): | |||
1211 | case FN_FRAME_WRAPTHRU_TRANSP((20000 + 400) + 164): | |||
1212 | case FN_FRAME_WRAPTHRU_TOGGLE((20000 + 400) + 163): | |||
1213 | case FN_FRAME_WRAP_CONTOUR((20000 + 400) + 184): | |||
1214 | case FN_WRAP_ANCHOR_ONLY((20000 + 400) + 181): | |||
1215 | case FN_FRAME_WRAP_LEFT((20000 + 400) + 172): | |||
1216 | case FN_FRAME_WRAP_RIGHT((20000 + 400) + 173): | |||
1217 | SetWrapMode( nSlot ); | |||
1218 | break; | |||
1219 | ||||
1220 | case FN_UPDATE_ALL_LINKS((20000 + 1800) + 24): | |||
1221 | { | |||
1222 | if( !rSh.GetLinkManager().GetLinks().empty() ) | |||
1223 | { | |||
1224 | rSh.EnterStdMode(); | |||
1225 | rSh.StartAllAction(); | |||
1226 | rSh.GetLinkManager().UpdateAllLinks( false, false, nullptr ); | |||
1227 | rSh.EndAllAction(); | |||
1228 | } | |||
1229 | } | |||
1230 | break; | |||
1231 | ||||
1232 | case FN_XFORMS_DESIGN_MODE((20000 + 2200) + 99): | |||
1233 | if (pArgs && pArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET) | |||
1234 | { | |||
1235 | if (const SfxBoolItem* pBoolItem = dynamic_cast<const SfxBoolItem*>(pItem)) | |||
1236 | { | |||
1237 | bool bDesignMode = pBoolItem->GetValue(); | |||
1238 | ||||
1239 | // set from design mode | |||
1240 | OSL_ENSURE( GetView().GetFormShell() != nullptr, "form shell?" )do { if (true && (!(GetView().GetFormShell() != nullptr ))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl" ), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "1240" ": "), "%s", "form shell?"); } } while (false); | |||
1241 | SfxRequest aReq( GetView().GetViewFrame(), SID_FM_DESIGN_MODE( 10000 + 629 ) ); | |||
1242 | aReq.AppendItem( SfxBoolItem( SID_FM_DESIGN_MODE( 10000 + 629 ), bDesignMode ) ); | |||
1243 | GetView().GetFormShell()->Execute( aReq ); | |||
1244 | aReq.Done(); | |||
1245 | ||||
1246 | // also set suitable view options | |||
1247 | SwViewOption aViewOption = *rSh.GetViewOptions(); | |||
1248 | aViewOption.SetFormView( ! bDesignMode ); | |||
1249 | rSh.ApplyViewOptions( aViewOption ); | |||
1250 | } | |||
1251 | } | |||
1252 | break; | |||
1253 | ||||
1254 | default: | |||
1255 | bMore = true; | |||
1256 | } | |||
1257 | ||||
1258 | ||||
1259 | if(!bMore || !pArgs) | |||
1260 | return; | |||
1261 | ||||
1262 | pItem = nullptr; | |||
1263 | pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem); | |||
1264 | if(!pItem) | |||
1265 | return; | |||
1266 | ||||
1267 | switch(nSlot) | |||
1268 | { | |||
1269 | case SID_ATTR_BRUSH( 10000 + 1 ): | |||
1270 | case SID_ATTR_BORDER_SHADOW( 10000 + 25 ): | |||
1271 | case RES_SHADOW: | |||
1272 | { | |||
1273 | rSh.StartAllAction(); | |||
1274 | // Tabele cell(s) selected? | |||
1275 | if ( rSh.IsTableMode() ) | |||
1276 | { | |||
1277 | SwFrameFormat *pFormat = rSh.GetTableFormat(); | |||
1278 | pFormat->SetFormatAttr( *pItem ); | |||
1279 | } | |||
1280 | else if ( rSh.IsFrameSelected() ) | |||
1281 | { | |||
1282 | // Set border attributes via Frame-Manager. | |||
1283 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); | |||
1284 | aMgr.SetAttrSet( *pArgs ); | |||
1285 | aMgr.UpdateFlyFrame(); | |||
1286 | } | |||
1287 | else | |||
1288 | { | |||
1289 | rSh.SetAttrSet( *pArgs ); | |||
1290 | } | |||
1291 | rSh.EndAllAction(); | |||
1292 | } | |||
1293 | break; | |||
1294 | case FN_PAGE_STYLE_SET_LR_MARGIN((20000 + 400) + 130): | |||
1295 | case FN_PAGE_STYLE_SET_UL_MARGIN((20000 + 400) + 131): | |||
1296 | case FN_PAGE_STYLE_SET_NUMBER_FORMAT((20000 + 400) + 137): | |||
1297 | case FN_PAGE_STYLE_SET_PAPER_SIZE((20000 + 400) + 135): | |||
1298 | case FN_PAGE_STYLE_SET_PAPER_BIN((20000 + 400) + 136): | |||
1299 | { | |||
1300 | OSL_FAIL("not implemented")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "1300" ": "), "%s", "not implemented"); } } while (false ); | |||
1301 | } | |||
1302 | break; | |||
1303 | ||||
1304 | case SID_ATTR_BORDER_OUTER( 10000 + 24 ): | |||
1305 | { | |||
1306 | // Tabele cell(s) selected? | |||
1307 | if ( rSh.IsTableMode() ) | |||
1308 | { | |||
1309 | // Set border attributes Get/SetTabBorders() | |||
1310 | rSh.SetTabBorders(*pArgs); | |||
1311 | } | |||
1312 | else if ( rSh.IsFrameSelected() ) | |||
1313 | { | |||
1314 | // Set border attributes via Frame-Manager. | |||
1315 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); | |||
1316 | aMgr.SetAttrSet(*pArgs); | |||
1317 | aMgr.UpdateFlyFrame(); | |||
1318 | } | |||
1319 | else | |||
1320 | { | |||
1321 | // Set border attributes via shell quite normally. | |||
1322 | rSh.SetAttrItem( *pItem ); | |||
1323 | } | |||
1324 | } | |||
1325 | break; | |||
1326 | default: | |||
1327 | OSL_FAIL("wrong Dispatcher")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "1327" ": "), "%s", "wrong Dispatcher"); } } while (false ); | |||
1328 | } | |||
1329 | } | |||
1330 | ||||
1331 | // Here the state for SID_IMAP / SID_CONTOUR will be handled | |||
1332 | // until the swapping of the graphic is finished. | |||
1333 | ||||
1334 | IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void)void SwBaseShell::LinkStubGraphicArrivedHdl(void * instance, SwCursorShell & data) { return static_cast<SwBaseShell *>(instance )->GraphicArrivedHdl(data); } void SwBaseShell::GraphicArrivedHdl (__attribute__ ((unused)) SwCursorShell&) | |||
1335 | { | |||
1336 | SwWrtShell &rSh = GetShell(); | |||
1337 | if (CNT_GRF0x0002 != rSh.SwEditShell::GetCntType()) | |||
1338 | return; | |||
1339 | GraphicType const nGrfType(rSh.GetGraphicType()); | |||
1340 | if (GraphicType::NONE == nGrfType || aGrfUpdateSlots.empty()) | |||
1341 | return; | |||
1342 | ||||
1343 | bool bProtect = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent); | |||
1344 | SfxViewFrame* pVFrame = GetView().GetViewFrame(); | |||
1345 | for( const auto nSlot : aGrfUpdateSlots ) | |||
1346 | { | |||
1347 | bool bSetState = false; | |||
1348 | bool bState = false; | |||
1349 | switch( nSlot ) | |||
1350 | { | |||
1351 | case SID_IMAP( 10000 + 371 ): | |||
1352 | case SID_IMAP_EXEC( 10000 + 374 ): | |||
1353 | { | |||
1354 | sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); | |||
1355 | SfxChildWindow *pChildWindow = pVFrame->HasChildWindow(nId) ? | |||
1356 | pVFrame->GetChildWindow(nId) : nullptr; | |||
1357 | SvxIMapDlg *pDlg = pChildWindow ? | |||
1358 | static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr; | |||
1359 | ||||
1360 | if( pDlg && ( SID_IMAP_EXEC( 10000 + 374 ) == nSlot || | |||
1361 | ( SID_IMAP( 10000 + 371 ) == nSlot && !bProtect)) && | |||
1362 | pDlg->GetEditingObject() != rSh.GetIMapInventor()) | |||
1363 | lcl_UpdateIMapDlg( rSh ); | |||
1364 | ||||
1365 | if( !bProtect && SID_IMAP( 10000 + 371 ) == nSlot ) | |||
1366 | { | |||
1367 | bSetState = true; | |||
1368 | bState = nullptr != pDlg; | |||
1369 | } | |||
1370 | } | |||
1371 | break; | |||
1372 | ||||
1373 | case SID_CONTOUR_DLG( 10000 + 334 ): | |||
1374 | if( !bProtect ) | |||
1375 | { | |||
1376 | sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); | |||
1377 | SfxChildWindow *pChildWindow = pVFrame->HasChildWindow(nId) ? | |||
1378 | pVFrame->GetChildWindow(nId) : nullptr; | |||
1379 | SvxIMapDlg *pDlg = pChildWindow ? | |||
1380 | static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr; | |||
1381 | if( pDlg && pDlg->GetEditingObject() != | |||
1382 | rSh.GetIMapInventor() ) | |||
1383 | lcl_UpdateContourDlg( rSh, SelectionType::Graphic ); | |||
1384 | ||||
1385 | bSetState = true; | |||
1386 | bState = nullptr != pDlg; | |||
1387 | } | |||
1388 | break; | |||
1389 | ||||
1390 | case FN_FRAME_WRAP_CONTOUR((20000 + 400) + 184): | |||
1391 | if( !bProtect ) | |||
1392 | { | |||
1393 | SfxItemSet aSet(GetPool(), svl::Items<RES_SURROUND, RES_SURROUND>{}); | |||
1394 | rSh.GetFlyFrameAttr(aSet); | |||
1395 | const SwFormatSurround& rWrap = aSet.Get(RES_SURROUND); | |||
1396 | bSetState = true; | |||
1397 | bState = rWrap.IsContour(); | |||
1398 | } | |||
1399 | break; | |||
1400 | ||||
1401 | case SID_GRFFILTER( 10000 + 469 ): | |||
1402 | case SID_GRFFILTER_INVERT( 10000 + 470 ): | |||
1403 | case SID_GRFFILTER_SMOOTH( 10000 + 471 ): | |||
1404 | case SID_GRFFILTER_SHARPEN( 10000 + 472 ): | |||
1405 | case SID_GRFFILTER_REMOVENOISE( 10000 + 473 ): | |||
1406 | case SID_GRFFILTER_SOBEL( 10000 + 474 ): | |||
1407 | case SID_GRFFILTER_MOSAIC( 10000 + 475 ): | |||
1408 | case SID_GRFFILTER_EMBOSS( 10000 + 476 ): | |||
1409 | case SID_GRFFILTER_POSTER( 10000 + 477 ): | |||
1410 | case SID_GRFFILTER_POPART( 10000 + 478 ): | |||
1411 | case SID_GRFFILTER_SEPIA( 10000 + 479 ): | |||
1412 | case SID_GRFFILTER_SOLARIZE( 10000 + 480 ): | |||
1413 | bSetState = bState = GraphicType::Bitmap == nGrfType; | |||
1414 | break; | |||
1415 | } | |||
1416 | ||||
1417 | if( bSetState ) | |||
1418 | { | |||
1419 | SfxBoolItem aBool( nSlot, bState ); | |||
1420 | if( pGetStateSet ) | |||
1421 | pGetStateSet->Put( aBool ); | |||
1422 | else | |||
1423 | pVFrame->GetBindings().SetState( aBool ); | |||
1424 | } | |||
1425 | } | |||
1426 | aGrfUpdateSlots.clear(); | |||
1427 | } | |||
1428 | ||||
1429 | void SwBaseShell::GetState( SfxItemSet &rSet ) | |||
1430 | { | |||
1431 | SwWrtShell &rSh = GetShell(); | |||
1432 | SfxViewFrame* pVFrame = GetView().GetViewFrame(); | |||
1433 | SfxWhichIter aIter( rSet ); | |||
1434 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1435 | pGetStateSet = &rSet; | |||
1436 | while ( nWhich ) | |||
1437 | { | |||
1438 | switch ( nWhich ) | |||
1439 | { | |||
1440 | case SID_GALLERY_FORMATS( 10000 + 280 ): | |||
1441 | if ( rSh.IsObjSelected() || | |||
1442 | (rSh.IsSelFrameMode() && | |||
1443 | !(rSh.GetSelectionType() & SelectionType::Graphic)) ) | |||
1444 | rSet.DisableItem( nWhich ); | |||
1445 | break; | |||
1446 | case SID_GALLERY_ENABLE_ADDCOPY( 10000 + 276 ): | |||
1447 | // #108230# allow copy from gallery in Writer AND Writer/Web! | |||
1448 | rSet.Put( SfxBoolItem( SID_GALLERY_ENABLE_ADDCOPY( 10000 + 276 ), true ) ); | |||
1449 | break; | |||
1450 | case FN_EDIT_REGION((20000 + 100) + 65): | |||
1451 | if( !rSh.IsAnySectionInDoc() ) | |||
1452 | rSet.DisableItem(nWhich); | |||
1453 | break; | |||
1454 | ||||
1455 | case FN_EDIT_CURRENT_REGION((20000 + 100) + 67): | |||
1456 | //tdf#112808 if cursor is in an index, don't show the edit section. | |||
1457 | if( !rSh.GetCurrSection() || | |||
1458 | (rSh.GetCurrSection()->GetType() != SectionType::Content && | |||
1459 | rSh.GetCurrSection()->GetType() != SectionType::FileLink )) | |||
1460 | { | |||
1461 | rSet.DisableItem(nWhich); | |||
1462 | } | |||
1463 | break; | |||
1464 | ||||
1465 | case FN_INSERT_REGION((20000 + 1400) + 19): | |||
1466 | if( rSh.CursorInsideInputField() | |||
1467 | || rSh.IsSelFrameMode() | |||
1468 | || !rSh.IsInsRegionAvailable() ) | |||
1469 | { | |||
1470 | rSet.DisableItem( nWhich ); | |||
1471 | } | |||
1472 | break; | |||
1473 | ||||
1474 | case FN_CONVERT_TABLE_TO_TEXT((20000 + 400) + 132): | |||
1475 | { | |||
1476 | FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true); | |||
1477 | if( (eFrameType & FrameTypeFlags::FOOTNOTE) || | |||
1478 | !rSh.GetTableFormat() ) | |||
1479 | rSet.DisableItem( nWhich ); | |||
1480 | } | |||
1481 | break; | |||
1482 | case FN_CONVERT_TEXT_TO_TABLE((20000 + 400) + 131): | |||
1483 | { | |||
1484 | FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true); | |||
1485 | if( (eFrameType & FrameTypeFlags::FOOTNOTE) || | |||
1486 | !rSh.IsTextToTableAvailable() ) | |||
1487 | rSet.DisableItem( nWhich ); | |||
1488 | } | |||
1489 | break; | |||
1490 | case FN_CONVERT_TEXT_TABLE((20000 + 400) + 100): | |||
1491 | { | |||
1492 | FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true); | |||
1493 | if( (eFrameType & FrameTypeFlags::FOOTNOTE) || | |||
1494 | (!rSh.GetTableFormat() && !rSh.IsTextToTableAvailable() ) ) | |||
1495 | rSet.DisableItem( nWhich ); | |||
1496 | } | |||
1497 | break; | |||
1498 | case RES_SHADOW: | |||
1499 | { | |||
1500 | SfxItemSet aSet( rSh.GetAttrPool(), | |||
1501 | svl::Items<RES_SHADOW, RES_SHADOW>{} ); | |||
1502 | ||||
1503 | // Table cell(s) selected? | |||
1504 | if ( rSh.IsTableMode() ) | |||
1505 | { | |||
1506 | SwFrameFormat *pFormat = rSh.GetTableFormat(); | |||
1507 | aSet.Put(pFormat->GetFormatAttr( nWhich )); | |||
1508 | } | |||
1509 | else if( rSh.IsFrameSelected() ) | |||
1510 | { | |||
1511 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); | |||
1512 | aSet.Put( aMgr.GetAttrSet() ); | |||
1513 | } | |||
1514 | else | |||
1515 | rSh.GetCurAttr( aSet ); | |||
1516 | ||||
1517 | const SvxShadowItem& rShItem = static_cast<const SvxShadowItem&>(aSet.Get(nWhich)); | |||
1518 | rSet.Put(rShItem); | |||
1519 | } | |||
1520 | break; | |||
1521 | case SID_IMAP( 10000 + 371 ): | |||
1522 | { | |||
1523 | // #i59688# | |||
1524 | // Improve efficiency: | |||
1525 | // If selected object is protected, item has to disabled. | |||
1526 | const bool bProtect = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent); | |||
1527 | if ( bProtect ) | |||
1528 | { | |||
1529 | rSet.DisableItem( nWhich ); | |||
1530 | } | |||
1531 | else | |||
1532 | { | |||
1533 | const sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); | |||
1534 | const bool bHas = pVFrame->HasChildWindow( nId ); | |||
1535 | const bool bFrameSel = rSh.IsFrameSelected(); | |||
1536 | const bool bIsGraphicSelection = | |||
1537 | rSh.GetSelectionType() == SelectionType::Graphic; | |||
1538 | ||||
1539 | // #i59688# | |||
1540 | // Avoid unnecessary loading of selected graphic. | |||
1541 | // The graphic is only needed, if the dialog is open. | |||
1542 | // If the swapping of the graphic is finished, the status | |||
1543 | // must be determined asynchronously, until this the slot | |||
1544 | // will be disabled. | |||
1545 | if ( bHas && bIsGraphicSelection && rSh.IsLinkedGrfSwapOut() ) | |||
1546 | { | |||
1547 | if( AddGrfUpdateSlot( nWhich )) | |||
1548 | rSh.GetGraphic(false); // start the loading | |||
1549 | } | |||
1550 | else | |||
1551 | { | |||
1552 | if ( !bHas && | |||
1553 | ( !bFrameSel || | |||
1554 | ( bIsGraphicSelection && | |||
1555 | rSh.GetGraphicType() == GraphicType::NONE ) ) ) | |||
1556 | { | |||
1557 | rSet.DisableItem( nWhich ); | |||
1558 | } | |||
1559 | else | |||
1560 | { | |||
1561 | SfxBoolItem aBool(nWhich, bHas); | |||
1562 | if ( bHas && bFrameSel ) | |||
1563 | lcl_UpdateIMapDlg( rSh ); | |||
1564 | rSet.Put(aBool); | |||
1565 | } | |||
1566 | } | |||
1567 | } | |||
1568 | } | |||
1569 | break; | |||
1570 | case SID_IMAP_EXEC( 10000 + 374 ): | |||
1571 | { | |||
1572 | bool bDisable = false; | |||
1573 | if( !rSh.IsFrameSelected()) | |||
1574 | bDisable = true; | |||
1575 | sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); | |||
1576 | if(!bDisable && pVFrame->HasChildWindow( nId )) | |||
1577 | { | |||
1578 | if(rSh.GetSelectionType() == SelectionType::Graphic | |||
1579 | && rSh.IsLinkedGrfSwapOut()) | |||
1580 | { | |||
1581 | if( AddGrfUpdateSlot( nWhich )) | |||
1582 | rSh.GetGraphic(false); // start the loading | |||
1583 | } | |||
1584 | else | |||
1585 | { | |||
1586 | SvxIMapDlg *pDlg = GetIMapDlg(GetView()); | |||
1587 | if (pDlg && pDlg->GetEditingObject() != rSh.GetIMapInventor()) | |||
1588 | lcl_UpdateIMapDlg( rSh ); | |||
1589 | } | |||
1590 | } | |||
1591 | rSet.Put(SfxBoolItem(nWhich, bDisable)); | |||
1592 | } | |||
1593 | break; | |||
1594 | ||||
1595 | case FN_BACKSPACE((20000 + 900) + 26): | |||
1596 | case SID_DELETE(5000 + 713): | |||
1597 | if ( ( rSh.HasReadonlySel() && !rSh.CursorInsideInputField() ) | |||
1598 | || rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE ) | |||
1599 | { | |||
1600 | rSet.DisableItem( nWhich ); | |||
1601 | } | |||
1602 | break; | |||
1603 | ||||
1604 | case SID_CONTOUR_DLG( 10000 + 334 ): | |||
1605 | { | |||
1606 | bool bParentCntProt = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent ); | |||
1607 | ||||
1608 | if( bParentCntProt || 0 != (HTMLMODE_ON & ::GetHtmlMode( | |||
1609 | GetView().GetDocShell() )) ) | |||
1610 | rSet.DisableItem( nWhich ); | |||
1611 | else | |||
1612 | { | |||
1613 | sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); | |||
1614 | bool bHas = GetView().GetViewFrame()->HasChildWindow( nId ); | |||
1615 | SelectionType nSel = rSh.GetSelectionType(); | |||
1616 | bool bOk(nSel & (SelectionType::Graphic|SelectionType::Ole)); | |||
1617 | ||||
1618 | bool bDisable = false; | |||
1619 | if( !bHas && !bOk ) | |||
1620 | bDisable = true; | |||
1621 | // #i59688# | |||
1622 | // Avoid unnecessary loading of selected graphic. | |||
1623 | // The graphic is only needed, if the dialog is open. | |||
1624 | // If the swapping of the graphic is finished, the status | |||
1625 | // must be determined asynchronously, until this the slot | |||
1626 | // will be disabled. | |||
1627 | else if ( bHas && (nSel & SelectionType::Graphic) && | |||
1628 | rSh.IsLinkedGrfSwapOut() ) | |||
1629 | { | |||
1630 | if( AddGrfUpdateSlot( nWhich )) | |||
1631 | rSh.GetGraphic(false); // start the loading | |||
1632 | // #i75481# | |||
1633 | bDisable = true; | |||
1634 | } | |||
1635 | else if( bHas && bOk ) | |||
1636 | bDisable = !lcl_UpdateContourDlg( rSh, nSel ); | |||
1637 | else if( bOk ) | |||
1638 | { | |||
1639 | // #i75481# | |||
1640 | // apply fix #i59688# only for selected graphics | |||
1641 | if ( nSel & SelectionType::Graphic ) | |||
1642 | bDisable = GraphicType::NONE == rSh.GetGraphicType(); | |||
1643 | else | |||
1644 | bDisable = GraphicType::NONE == rSh.GetIMapGraphic().GetType(); | |||
1645 | } | |||
1646 | ||||
1647 | if( bDisable ) | |||
1648 | rSet.DisableItem( nWhich ); | |||
1649 | else | |||
1650 | rSet.Put( SfxBoolItem(nWhich, bHas) ); | |||
1651 | } | |||
1652 | } | |||
1653 | break; | |||
1654 | case SID_CONTOUR_EXEC( 10000 + 335 ): | |||
1655 | { | |||
1656 | bool bDisable = false; | |||
1657 | SelectionType nSel = rSh.GetSelectionType(); | |||
1658 | if( !(nSel & (SelectionType::Graphic|SelectionType::Ole)) ) | |||
1659 | bDisable = true; | |||
1660 | sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); | |||
1661 | if( !bDisable && GetView().GetViewFrame()->HasChildWindow( nId )) | |||
1662 | { | |||
1663 | SvxContourDlg *pDlg = GetContourDlg(GetView()); | |||
1664 | if (pDlg && pDlg->GetEditingObject() != rSh.GetIMapInventor()) | |||
1665 | bDisable = true; | |||
1666 | } | |||
1667 | rSet.Put(SfxBoolItem(nWhich, bDisable)); | |||
1668 | } | |||
1669 | break; | |||
1670 | ||||
1671 | case SID_ANCHOR_MENU( 10000 + 1172 ): | |||
1672 | case FN_TOOL_ANCHOR_PAGE((20000 + 300) + 50): | |||
1673 | case FN_TOOL_ANCHOR_PARAGRAPH((20000 + 300) + 51): | |||
1674 | case FN_TOOL_ANCHOR_CHAR((20000 + 300) + 84): | |||
1675 | case FN_TOOL_ANCHOR_AT_CHAR((20000 + 1400) + 12): | |||
1676 | case FN_TOOL_ANCHOR_FRAME((20000 + 300) + 66): | |||
1677 | { | |||
1678 | bool bObj = 0 != rSh.IsObjSelected(); | |||
1679 | bool bParentCntProt = rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; | |||
1680 | ||||
1681 | if( !bParentCntProt && (bObj || rSh.IsFrameSelected())) | |||
1682 | { | |||
1683 | SfxItemSet aSet(GetPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{}); | |||
1684 | if(bObj) | |||
1685 | rSh.GetObjAttr(aSet); | |||
1686 | else | |||
1687 | rSh.GetFlyFrameAttr(aSet); | |||
1688 | RndStdIds eSet = aSet.Get(RES_ANCHOR).GetAnchorId(); | |||
1689 | const bool bSet = | |||
1690 | ((nWhich == FN_TOOL_ANCHOR_PAGE((20000 + 300) + 50)) && | |||
1691 | (eSet == RndStdIds::FLY_AT_PAGE)) | |||
1692 | || ((nWhich == FN_TOOL_ANCHOR_PARAGRAPH((20000 + 300) + 51)) && | |||
1693 | (eSet == RndStdIds::FLY_AT_PARA)) | |||
1694 | || ((nWhich == FN_TOOL_ANCHOR_FRAME((20000 + 300) + 66)) && | |||
1695 | (eSet == RndStdIds::FLY_AT_FLY)) | |||
1696 | || ((nWhich == FN_TOOL_ANCHOR_AT_CHAR((20000 + 1400) + 12)) && | |||
1697 | (eSet == RndStdIds::FLY_AT_CHAR)) | |||
1698 | || ((nWhich == FN_TOOL_ANCHOR_CHAR((20000 + 300) + 84)) && | |||
1699 | (eSet == RndStdIds::FLY_AS_CHAR)); | |||
1700 | ||||
1701 | if( nWhich == FN_TOOL_ANCHOR_FRAME((20000 + 300) + 66) && !rSh.IsFlyInFly() ) | |||
1702 | rSet.DisableItem(nWhich); | |||
1703 | else if(nWhich != SID_ANCHOR_MENU( 10000 + 1172 )) | |||
1704 | rSet.Put(SfxBoolItem(nWhich, bSet)); | |||
1705 | ||||
1706 | if (comphelper::LibreOfficeKit::isActive()) | |||
1707 | { | |||
1708 | if (nWhich == FN_TOOL_ANCHOR_PAGE((20000 + 300) + 50) || nWhich == FN_TOOL_ANCHOR_PARAGRAPH((20000 + 300) + 51) | |||
1709 | || nWhich == FN_TOOL_ANCHOR_FRAME((20000 + 300) + 66)) | |||
1710 | { | |||
1711 | rSet.DisableItem(nWhich); | |||
1712 | } | |||
1713 | } | |||
1714 | } | |||
1715 | else | |||
1716 | rSet.DisableItem( nWhich ); | |||
1717 | } | |||
1718 | break; | |||
1719 | case FN_FRAME_NOWRAP((20000 + 400) + 72): | |||
1720 | case FN_FRAME_WRAP((20000 + 400) + 73): | |||
1721 | case FN_FRAME_WRAP_IDEAL((20000 + 400) + 162): | |||
1722 | case FN_FRAME_WRAPTHRU((20000 + 400) + 74): | |||
1723 | case FN_FRAME_WRAPTHRU_TRANSP((20000 + 400) + 164): | |||
1724 | case FN_FRAME_WRAPTHRU_TOGGLE((20000 + 400) + 163): | |||
1725 | case FN_FRAME_WRAP_CONTOUR((20000 + 400) + 184): | |||
1726 | case FN_WRAP_ANCHOR_ONLY((20000 + 400) + 181): | |||
1727 | case FN_FRAME_WRAP_LEFT((20000 + 400) + 172): | |||
1728 | case FN_FRAME_WRAP_RIGHT((20000 + 400) + 173): | |||
1729 | { | |||
1730 | bool bObj = 0 != rSh.IsObjSelected(); | |||
1731 | bool bParentCntProt = rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; | |||
1732 | ||||
1733 | if( !bParentCntProt && (bObj || rSh.IsFrameSelected())) | |||
1734 | { | |||
1735 | SfxItemSet aSet(GetPool(), svl::Items<RES_OPAQUE, RES_ANCHOR>{}); | |||
1736 | RndStdIds nAnchorType; | |||
1737 | if(bObj) | |||
1738 | { | |||
1739 | rSh.GetObjAttr(aSet); | |||
1740 | nAnchorType = rSh.GetAnchorId(); | |||
1741 | } | |||
1742 | else | |||
1743 | { | |||
1744 | rSh.GetFlyFrameAttr(aSet); | |||
1745 | nAnchorType = aSet.Get(RES_ANCHOR).GetAnchorId(); | |||
1746 | } | |||
1747 | const SwFormatSurround& rWrap = aSet.Get(RES_SURROUND); | |||
1748 | ||||
1749 | const SvxOpaqueItem& rOpaque = aSet.Get(RES_OPAQUE); | |||
1750 | bool bOpaque = rOpaque.GetValue(); | |||
1751 | css::text::WrapTextMode nSurround = rWrap.GetSurround(); | |||
1752 | bool bSet = false; | |||
1753 | ||||
1754 | bool bDisable = | |||
1755 | (nAnchorType == RndStdIds::UNKNOWN) || (nAnchorType == RndStdIds::FLY_AS_CHAR); | |||
1756 | const bool bHtmlMode = | |||
1757 | 0 != ::GetHtmlMode(GetView().GetDocShell()); | |||
1758 | ||||
1759 | switch( nWhich ) | |||
1760 | { | |||
1761 | case FN_FRAME_NOWRAP((20000 + 400) + 72): | |||
1762 | bDisable |= | |||
1763 | ( (nAnchorType != RndStdIds::FLY_AT_PARA) | |||
1764 | && (nAnchorType != RndStdIds::FLY_AT_CHAR) | |||
1765 | && (nAnchorType != RndStdIds::FLY_AT_PAGE)); | |||
1766 | bSet = nSurround == css::text::WrapTextMode_NONE; | |||
1767 | break; | |||
1768 | case FN_FRAME_WRAP((20000 + 400) + 73): | |||
1769 | bDisable |= bHtmlMode; | |||
1770 | bSet = nSurround == css::text::WrapTextMode_PARALLEL; | |||
1771 | break; | |||
1772 | case FN_FRAME_WRAP_IDEAL((20000 + 400) + 162): | |||
1773 | bDisable |= bHtmlMode; | |||
1774 | bSet = nSurround == css::text::WrapTextMode_DYNAMIC; | |||
1775 | break; | |||
1776 | case FN_FRAME_WRAPTHRU((20000 + 400) + 74): | |||
1777 | bDisable |= (bHtmlMode || | |||
1778 | ( (nAnchorType != RndStdIds::FLY_AT_PARA) | |||
1779 | && (nAnchorType != RndStdIds::FLY_AT_CHAR) | |||
1780 | && (nAnchorType != RndStdIds::FLY_AT_PAGE))); | |||
1781 | if(bObj) | |||
1782 | bSet = nSurround == css::text::WrapTextMode_THROUGH && rSh.GetLayerId(); | |||
1783 | else | |||
1784 | bSet = nSurround == css::text::WrapTextMode_THROUGH && bOpaque; | |||
1785 | break; | |||
1786 | case FN_FRAME_WRAPTHRU_TRANSP((20000 + 400) + 164): | |||
1787 | case FN_FRAME_WRAPTHRU_TOGGLE((20000 + 400) + 163): | |||
1788 | bDisable |= bHtmlMode; | |||
1789 | if(bObj) | |||
1790 | bSet = nSurround == css::text::WrapTextMode_THROUGH && !rSh.GetLayerId(); | |||
1791 | else | |||
1792 | bSet = nSurround == css::text::WrapTextMode_THROUGH && !bOpaque; | |||
1793 | break; | |||
1794 | case FN_FRAME_WRAP_CONTOUR((20000 + 400) + 184): | |||
1795 | bDisable |= bHtmlMode; | |||
1796 | //no contour available whenn no wrap or wrap through is set | |||
1797 | bDisable |= (nSurround == css::text::WrapTextMode_NONE || nSurround == css::text::WrapTextMode_THROUGH); | |||
1798 | if( !bDisable ) | |||
1799 | { | |||
1800 | SelectionType nSel = rSh.GetSelectionType(); | |||
1801 | if( (nSel & SelectionType::Graphic) && | |||
1802 | rSh.IsLinkedGrfSwapOut()) | |||
1803 | { | |||
1804 | if( AddGrfUpdateSlot( nWhich )) | |||
1805 | rSh.GetGraphic(false); // start the loading | |||
1806 | } | |||
1807 | else if( rSh.IsFrameSelected() ) | |||
1808 | { | |||
1809 | // #i102253# applied patch from OD (see task) | |||
1810 | bDisable = | |||
1811 | nSel & SelectionType::Frame || | |||
1812 | GraphicType::NONE == rSh.GetIMapGraphic().GetType(); | |||
1813 | } | |||
1814 | } | |||
1815 | bSet = !bDisable && rWrap.IsContour(); | |||
1816 | ||||
1817 | break; | |||
1818 | case FN_WRAP_ANCHOR_ONLY((20000 + 400) + 181): | |||
1819 | bDisable |= (bHtmlMode || | |||
1820 | (nAnchorType != RndStdIds::FLY_AT_PARA)); | |||
1821 | bSet = rWrap.IsAnchorOnly(); | |||
1822 | break; | |||
1823 | case FN_FRAME_WRAP_LEFT((20000 + 400) + 172): | |||
1824 | bSet = nSurround == css::text::WrapTextMode_LEFT; | |||
1825 | break; | |||
1826 | case FN_FRAME_WRAP_RIGHT((20000 + 400) + 173): | |||
1827 | bSet = nSurround == css::text::WrapTextMode_RIGHT; | |||
1828 | break; | |||
1829 | } | |||
1830 | ||||
1831 | if(bDisable) | |||
1832 | rSet.DisableItem(nWhich); | |||
1833 | else | |||
1834 | rSet.Put(SfxBoolItem(nWhich, bSet)); | |||
1835 | } | |||
1836 | else | |||
1837 | rSet.DisableItem(nWhich); | |||
1838 | } | |||
1839 | break; | |||
1840 | case FN_UPDATE_CHARTS((20000 + 1800) + 34): | |||
1841 | if( !rSh.HasCharts() ) | |||
1842 | rSet.DisableItem( nWhich ); | |||
1843 | break; | |||
1844 | case FN_UPDATE_ALL_LINKS((20000 + 1800) + 24): | |||
1845 | if ( rSh.GetLinkManager().GetLinks().empty() ) | |||
1846 | rSet.DisableItem(nWhich); | |||
1847 | break; | |||
1848 | case FN_XFORMS_DESIGN_MODE((20000 + 2200) + 99): | |||
1849 | // enable if in XForms document | |||
1850 | if( rSh.GetDoc()->isXForms() ) | |||
1851 | { | |||
1852 | // determine current state from view options | |||
1853 | bool bValue = ! rSh.GetViewOptions()->IsFormView(); | |||
1854 | rSet.Put( SfxBoolItem( nWhich, bValue ) ); | |||
1855 | } | |||
1856 | else | |||
1857 | rSet.Put( SfxVisibilityItem( nWhich, false ) ); | |||
1858 | break; | |||
1859 | } | |||
1860 | nWhich = aIter.NextWhich(); | |||
1861 | } | |||
1862 | pGetStateSet = nullptr; | |||
1863 | } | |||
1864 | ||||
1865 | // Disable the slots with this status method | |||
1866 | ||||
1867 | void SwBaseShell::StateDisableItems( SfxItemSet &rSet ) | |||
1868 | { | |||
1869 | SfxWhichIter aIter(rSet); | |||
1870 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1871 | ||||
1872 | while (nWhich) | |||
1873 | { | |||
1874 | rSet.DisableItem( nWhich ); | |||
1875 | nWhich = aIter.NextWhich(); | |||
1876 | } | |||
1877 | } | |||
1878 | ||||
1879 | // Disable the slots with this status method | |||
1880 | ||||
1881 | void SwBaseShell::StateStyle( SfxItemSet &rSet ) | |||
1882 | { | |||
1883 | bool bParentCntProt = GetShell().IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; | |||
1884 | ShellMode eMode = GetView().GetShellMode(); | |||
1885 | ||||
1886 | if ( bParentCntProt || | |||
1887 | ShellMode::Draw == eMode || | |||
1888 | ShellMode::DrawForm == eMode || | |||
1889 | ShellMode::DrawText == eMode || | |||
1890 | ShellMode::Bezier == eMode ) | |||
1891 | { | |||
1892 | SfxWhichIter aIter( rSet ); | |||
1893 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
1894 | while ( nWhich ) | |||
1895 | { | |||
1896 | rSet.DisableItem( nWhich ); | |||
1897 | nWhich = aIter.NextWhich(); | |||
1898 | } | |||
1899 | } | |||
1900 | else | |||
1901 | GetView().GetDocShell()->StateStyleSheet(rSet, &GetShell()); | |||
1902 | } | |||
1903 | ||||
1904 | void SwBaseShell::SetWrapMode( sal_uInt16 nSlot ) | |||
1905 | { | |||
1906 | SwWrtShell &rSh = GetShell(); | |||
1907 | bool bObj = 0 != rSh.IsObjSelected(); | |||
1908 | if( !bObj && !rSh.IsFrameSelected()) | |||
1909 | return; | |||
1910 | ||||
1911 | SfxItemSet aSet(GetPool(), svl::Items<RES_OPAQUE, RES_SURROUND>{}); | |||
1912 | if(bObj) | |||
1913 | rSh.GetObjAttr(aSet); | |||
1914 | else | |||
1915 | rSh.GetFlyFrameAttr(aSet); | |||
1916 | SwFormatSurround aWrap( aSet.Get(RES_SURROUND) ); | |||
1917 | css::text::WrapTextMode nOldSurround(aWrap.GetSurround()); | |||
1918 | css::text::WrapTextMode nSurround = css::text::WrapTextMode_PARALLEL; | |||
1919 | ||||
1920 | switch (nSlot) | |||
1921 | { | |||
1922 | case FN_FRAME_NOWRAP((20000 + 400) + 72): | |||
1923 | nSurround = css::text::WrapTextMode_NONE; | |||
1924 | if (aWrap.IsContour()) | |||
1925 | aWrap.SetContour(false); | |||
1926 | break; | |||
1927 | case FN_FRAME_WRAP_IDEAL((20000 + 400) + 162): | |||
1928 | nSurround = css::text::WrapTextMode_DYNAMIC; | |||
1929 | break; | |||
1930 | case FN_WRAP_ANCHOR_ONLY((20000 + 400) + 181): | |||
1931 | aWrap.SetAnchorOnly(!aWrap.IsAnchorOnly()); | |||
1932 | ||||
1933 | // keep previous wrapping | |||
1934 | ||||
1935 | // switch to wrap css::text::WrapTextMode_PARALLEL, if previous wrap is css::text::WrapTextMode_NONE | |||
1936 | if ( nOldSurround != css::text::WrapTextMode_NONE ) | |||
1937 | { | |||
1938 | nSurround = nOldSurround; | |||
1939 | } | |||
1940 | break; | |||
1941 | case FN_FRAME_WRAP_CONTOUR((20000 + 400) + 184): | |||
1942 | aWrap.SetContour(!aWrap.IsContour()); | |||
1943 | // Contour is meaningless in no-wrap or wrap-through context. Otherwise keep existing wrap. | |||
1944 | if ( !aWrap.IsContour() || | |||
1945 | ( nOldSurround != css::text::WrapTextMode_NONE && | |||
1946 | nOldSurround != css::text::WrapTextMode_THROUGH ) ) | |||
1947 | { | |||
1948 | nSurround = nOldSurround; | |||
1949 | } | |||
1950 | break; | |||
1951 | case FN_FRAME_WRAPTHRU_TRANSP((20000 + 400) + 164): | |||
1952 | case FN_FRAME_WRAPTHRU_TOGGLE((20000 + 400) + 163): | |||
1953 | if (aWrap.IsContour()) | |||
1954 | aWrap.SetContour(false); | |||
1955 | [[fallthrough]]; | |||
1956 | case FN_FRAME_WRAPTHRU((20000 + 400) + 74): | |||
1957 | nSurround = css::text::WrapTextMode_THROUGH; | |||
1958 | break; | |||
1959 | ||||
1960 | case FN_FRAME_WRAP_LEFT((20000 + 400) + 172): | |||
1961 | nSurround = css::text::WrapTextMode_LEFT; | |||
1962 | break; | |||
1963 | ||||
1964 | case FN_FRAME_WRAP_RIGHT((20000 + 400) + 173): | |||
1965 | nSurround = css::text::WrapTextMode_RIGHT; | |||
1966 | break; | |||
1967 | ||||
1968 | default: | |||
1969 | break; | |||
1970 | } | |||
1971 | aWrap.SetSurround(nSurround); | |||
1972 | ||||
1973 | if (nSlot != FN_FRAME_WRAP_CONTOUR((20000 + 400) + 184)) | |||
1974 | { | |||
1975 | // Defaulting the contour wrap on draw objects. | |||
1976 | if (bObj && nOldSurround != nSurround && | |||
1977 | (nOldSurround == css::text::WrapTextMode_NONE || nOldSurround == css::text::WrapTextMode_THROUGH)) | |||
1978 | { | |||
1979 | aWrap.SetContour(true); | |||
1980 | } | |||
1981 | } | |||
1982 | ||||
1983 | aSet.Put( aWrap ); | |||
1984 | ||||
1985 | bool bOpaque = nSlot != FN_FRAME_WRAPTHRU_TRANSP((20000 + 400) + 164) && nSlot != FN_FRAME_WRAPTHRU_TOGGLE((20000 + 400) + 163); | |||
1986 | if( nSlot == FN_FRAME_WRAPTHRU_TOGGLE((20000 + 400) + 163) ) | |||
1987 | { | |||
1988 | if( bObj ) | |||
1989 | bOpaque = !rSh.GetLayerId(); | |||
1990 | else | |||
1991 | { | |||
1992 | const SvxOpaqueItem& aOpaque( aSet.Get(RES_OPAQUE) ); | |||
1993 | bOpaque = !aOpaque.GetValue(); | |||
1994 | } | |||
1995 | } | |||
1996 | aSet.Put(SvxOpaqueItem(RES_OPAQUE, bOpaque )); | |||
1997 | ||||
1998 | if(bObj) | |||
1999 | { | |||
2000 | rSh.SetObjAttr(aSet); | |||
2001 | if ( bOpaque ) | |||
2002 | rSh.SelectionToHeaven(); | |||
2003 | else | |||
2004 | rSh.SelectionToHell(); | |||
2005 | } | |||
2006 | else | |||
2007 | rSh.SetFlyFrameAttr(aSet); | |||
2008 | ||||
2009 | } | |||
2010 | ||||
2011 | //Force update of the status line | |||
2012 | ||||
2013 | void SwBaseShell::SetFrameMode(FlyMode eMode, SwWrtShell *pSh ) | |||
2014 | { | |||
2015 | eFrameMode = eMode; | |||
2016 | SfxBindings &rBnd = pSh->GetView().GetViewFrame()->GetBindings(); | |||
2017 | ||||
2018 | if( eMode == FLY_DRAG || pSh->IsFrameSelected() || pSh->IsObjSelected() ) | |||
2019 | { | |||
2020 | const SfxPointItem aTmp1( SID_ATTR_POSITIONTypedWhichId<SfxPointItem>( 10000 + 223 ), pSh->GetAnchorObjDiff()); | |||
2021 | const SvxSizeItem aTmp2( SID_ATTR_SIZETypedWhichId<SvxSizeItem>( 10000 + 224 ), pSh->GetObjSize()); | |||
2022 | rBnd.SetState( aTmp1 ); | |||
2023 | rBnd.SetState( aTmp2 ); | |||
2024 | } | |||
2025 | else if( eMode == FLY_DRAG_END ) | |||
2026 | { | |||
2027 | static sal_uInt16 aInval[] = | |||
2028 | { | |||
2029 | SID_ATTR_POSITIONTypedWhichId<SfxPointItem>( 10000 + 223 ), SID_ATTR_SIZETypedWhichId<SvxSizeItem>( 10000 + 224 ), 0 | |||
2030 | }; | |||
2031 | rBnd.Invalidate(aInval); | |||
2032 | } | |||
2033 | } | |||
2034 | ||||
2035 | SwBaseShell::SwBaseShell(SwView& rVw) : | |||
2036 | SfxShell( &rVw ), | |||
2037 | rView(rVw), | |||
2038 | pGetStateSet(nullptr) | |||
2039 | { | |||
2040 | SwWrtShell& rWrtSh = rView.GetWrtShell(); | |||
2041 | ||||
2042 | SetPool(&rWrtSh.GetAttrPool()); | |||
2043 | SetName("Base"); | |||
2044 | rWrtSh.SetGrfArrivedLnk( LINK( this, SwBaseShell, GraphicArrivedHdl)::tools::detail::makeLink( ::tools::detail::castTo<SwBaseShell *>(this), &SwBaseShell::LinkStubGraphicArrivedHdl)); | |||
2045 | } | |||
2046 | ||||
2047 | SwBaseShell::~SwBaseShell() | |||
2048 | { | |||
2049 | if( rView.GetCurShell() == this ) | |||
2050 | rView.ResetSubShell(); | |||
2051 | ||||
2052 | Link<SwCursorShell&,void> aTmp( LINK( this, SwBaseShell, GraphicArrivedHdl)::tools::detail::makeLink( ::tools::detail::castTo<SwBaseShell *>(this), &SwBaseShell::LinkStubGraphicArrivedHdl)); | |||
2053 | if( aTmp == rView.GetWrtShell().GetGrfArrivedLnk() ) | |||
2054 | rView.GetWrtShell().SetGrfArrivedLnk( Link<SwCursorShell&,void>() ); | |||
2055 | } | |||
2056 | ||||
2057 | void SwBaseShell::ExecTextCtrl( SfxRequest& rReq ) | |||
2058 | { | |||
2059 | const SfxItemSet *pArgs = rReq.GetArgs(); | |||
2060 | ||||
2061 | if( pArgs) | |||
2062 | { | |||
2063 | SwWrtShell &rSh = GetShell(); | |||
2064 | std::unique_ptr<SvxScriptSetItem> pSSetItem; | |||
2065 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
2066 | SfxItemPool& rPool = rSh.GetAttrPool(); | |||
2067 | sal_uInt16 nWhich = rPool.GetWhich( nSlot ); | |||
2068 | SvtScriptType nScripts = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX; | |||
2069 | SfxItemSet aHeightSet( GetPool(), svl::Items<RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE, | |||
2070 | RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CJK_FONTSIZE, | |||
2071 | RES_CHRATR_CTL_FONTSIZE, RES_CHRATR_CTL_FONTSIZE>{}); | |||
2072 | ||||
2073 | switch( nSlot ) | |||
2074 | { | |||
2075 | case SID_ATTR_CHAR_FONT( 10000 + 7 ): | |||
2076 | { | |||
2077 | nScripts = rSh.GetScriptType(); | |||
2078 | // #i42732# input language should be preferred over | |||
2079 | // current cursor position to detect script type | |||
2080 | if(!rSh.HasSelection()) | |||
2081 | { | |||
2082 | LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage(); | |||
2083 | if(nInputLang != LANGUAGE_DONTKNOWLanguageType(0x03FF) && nInputLang != LANGUAGE_SYSTEMLanguageType(0x0000)) | |||
2084 | nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); | |||
2085 | } | |||
2086 | [[fallthrough]]; | |||
2087 | } | |||
2088 | case SID_ATTR_CHAR_POSTURE( 10000 + 8 ): | |||
2089 | case SID_ATTR_CHAR_WEIGHT( 10000 + 9 ): | |||
2090 | { | |||
2091 | pSSetItem.reset(new SvxScriptSetItem( nSlot, rPool )); | |||
2092 | pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich )); | |||
2093 | pArgs = &pSSetItem->GetItemSet(); | |||
2094 | } | |||
2095 | break; | |||
2096 | case SID_ATTR_CHAR_FONTHEIGHT( 10000 + 15 ): | |||
2097 | { | |||
2098 | if(rSh.HasSelection()) | |||
2099 | { | |||
2100 | pSSetItem.reset(new SvxScriptSetItem( nSlot, rPool )); | |||
2101 | pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich )); | |||
2102 | pArgs = &pSSetItem->GetItemSet(); | |||
2103 | } | |||
2104 | else | |||
2105 | { | |||
2106 | nScripts = rSh.GetScriptType(); | |||
2107 | LanguageType nInputLang = GetView().GetEditWin().GetInputLanguage(); | |||
2108 | if(nInputLang != LANGUAGE_DONTKNOWLanguageType(0x03FF) && nInputLang != LANGUAGE_SYSTEMLanguageType(0x0000)) | |||
2109 | nScripts = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); | |||
2110 | sal_uInt32 nHeight = static_cast< const SvxFontHeightItem& >(pArgs->Get( nWhich )).GetHeight(); | |||
2111 | SwStdFontConfig* pStdFont = SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule ::Writer)))->GetStdFontConfig(); | |||
2112 | ||||
2113 | SfxItemSet aLangSet( GetPool(), svl::Items<RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, | |||
2114 | RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, | |||
2115 | RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE>{}); | |||
2116 | rSh.GetCurAttr( aLangSet ); | |||
2117 | ||||
2118 | sal_Int32 nWesternSize = | |||
2119 | pStdFont->GetFontHeight(FONT_STANDARD0, FONT_GROUP_DEFAULT0, | |||
2120 | aLangSet.Get( RES_CHRATR_LANGUAGE).GetLanguage()); | |||
2121 | sal_Int32 nCJKSize = | |||
2122 | pStdFont->GetFontHeight(FONT_STANDARD0, FONT_GROUP_CJK1, | |||
2123 | aLangSet.Get( RES_CHRATR_CJK_LANGUAGE).GetLanguage()); | |||
2124 | sal_Int32 nCTLSize = | |||
2125 | pStdFont->GetFontHeight(FONT_STANDARD0, FONT_GROUP_CTL2, | |||
2126 | aLangSet.Get( RES_CHRATR_CTL_LANGUAGE).GetLanguage()); | |||
2127 | ||||
2128 | switch(nScripts) | |||
2129 | { | |||
2130 | case SvtScriptType::LATIN: | |||
2131 | nCJKSize = nHeight * nCJKSize / nWesternSize; | |||
2132 | nCTLSize = nHeight * nCTLSize / nWesternSize; | |||
2133 | nWesternSize = static_cast<sal_Int32>(nHeight); | |||
2134 | break; | |||
2135 | case SvtScriptType::ASIAN: | |||
2136 | nCTLSize = nHeight* nCTLSize / nCJKSize; | |||
2137 | nWesternSize = nHeight * nWesternSize / nCJKSize; | |||
2138 | nCJKSize = static_cast<sal_Int32>(nHeight); | |||
2139 | break; | |||
2140 | case SvtScriptType::COMPLEX: | |||
2141 | nCJKSize = nHeight * nCJKSize / nCTLSize; | |||
2142 | nWesternSize = nHeight * nWesternSize / nCTLSize; | |||
2143 | nCTLSize = static_cast<sal_Int32>(nHeight); | |||
2144 | break; | |||
2145 | default: break; | |||
2146 | } | |||
2147 | aHeightSet.Put( SvxFontHeightItem( static_cast<sal_uInt32>(nWesternSize), 100, RES_CHRATR_FONTSIZE )); | |||
2148 | aHeightSet.Put( SvxFontHeightItem( static_cast<sal_uInt32>(nCJKSize), 100, RES_CHRATR_CJK_FONTSIZE )); | |||
2149 | aHeightSet.Put( SvxFontHeightItem( static_cast<sal_uInt32>(nCTLSize), 100, RES_CHRATR_CTL_FONTSIZE )); | |||
2150 | pArgs = &aHeightSet; | |||
2151 | } | |||
2152 | } | |||
2153 | break; | |||
2154 | } | |||
2155 | ||||
2156 | if( pArgs ) | |||
2157 | { | |||
2158 | bool bAuto = false; | |||
2159 | if ( !isCHRATR(nWhich) || | |||
2160 | ( rSh.HasSelection() && rSh.IsSelFullPara() ) ) | |||
2161 | { | |||
2162 | SwTextFormatColl * pColl = rSh.GetCurTextFormatColl(); | |||
2163 | if ( pColl && pColl->IsAutoUpdateFormat() ) | |||
2164 | { | |||
2165 | rSh.AutoUpdatePara( pColl, *pArgs ); | |||
2166 | bAuto = true; | |||
2167 | } | |||
2168 | } | |||
2169 | ||||
2170 | if (!bAuto) | |||
2171 | { | |||
2172 | rSh.SetAttrSet( *pArgs ); | |||
2173 | } | |||
2174 | } | |||
2175 | } | |||
2176 | else | |||
2177 | GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG( 10000 + 296 ) ); | |||
2178 | rReq.Done(); | |||
2179 | } | |||
2180 | ||||
2181 | void SwBaseShell::GetTextCtrlState( SfxItemSet& rSet ) | |||
2182 | { | |||
2183 | SwWrtShell &rSh = GetShell(); | |||
2184 | rSh.GetCurAttr( rSet ); | |||
2185 | } | |||
2186 | ||||
2187 | void SwBaseShell::GetTextFontCtrlState( SfxItemSet& rSet ) | |||
2188 | { | |||
2189 | SwWrtShell &rSh = GetShell(); | |||
2190 | bool bFirst = true; | |||
2191 | std::unique_ptr<SfxItemSet> pFntCoreSet; | |||
2192 | SvtScriptType nScriptType = SvtScriptType::LATIN; | |||
2193 | SfxWhichIter aIter( rSet ); | |||
2194 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
2195 | while( nWhich ) | |||
2196 | { | |||
2197 | switch( nWhich ) | |||
2198 | { | |||
2199 | case RES_CHRATR_FONT: | |||
2200 | case RES_CHRATR_FONTSIZE: | |||
2201 | case RES_CHRATR_WEIGHT: | |||
2202 | case RES_CHRATR_POSTURE: | |||
2203 | { | |||
2204 | if( !pFntCoreSet ) | |||
2205 | { | |||
2206 | pFntCoreSet.reset(new SfxItemSet( *rSet.GetPool(), | |||
2207 | svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1>{} )); | |||
2208 | rSh.GetCurAttr( *pFntCoreSet ); | |||
2209 | nScriptType = rSh.GetScriptType(); | |||
2210 | // #i42732# input language should be preferred over | |||
2211 | // current cursor position to detect script type | |||
2212 | SwEditWin& rEditWin = GetView().GetEditWin(); | |||
2213 | if( rEditWin.IsUseInputLanguage() ) | |||
2214 | { | |||
2215 | if(!rSh.HasSelection() && ( | |||
2216 | nWhich == RES_CHRATR_FONT || | |||
2217 | nWhich == RES_CHRATR_FONTSIZE )) | |||
2218 | { | |||
2219 | LanguageType nInputLang = rEditWin.GetInputLanguage(); | |||
2220 | if(nInputLang != LANGUAGE_DONTKNOWLanguageType(0x03FF) && nInputLang != LANGUAGE_SYSTEMLanguageType(0x0000)) | |||
2221 | nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); | |||
2222 | } | |||
2223 | } | |||
2224 | } | |||
2225 | SfxItemPool& rPool = *rSet.GetPool(); | |||
2226 | SvxScriptSetItem aSetItem( rPool.GetSlotId( nWhich ), rPool ); | |||
2227 | aSetItem.GetItemSet().Put( *pFntCoreSet, false ); | |||
2228 | const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType ); | |||
2229 | if( pI ) | |||
2230 | { | |||
2231 | rSet.Put( pI->CloneSetWhich(nWhich) ); | |||
2232 | } | |||
2233 | else | |||
2234 | rSet.InvalidateItem( nWhich ); | |||
2235 | // Set input context of the SwEditWin according to the selected font and script type | |||
2236 | if(RES_CHRATR_FONT == nWhich) | |||
2237 | { | |||
2238 | vcl::Font aFont; | |||
2239 | if (const SvxFontItem* pFontItem = dynamic_cast<const SvxFontItem*>(pI)) | |||
2240 | { | |||
2241 | aFont.SetFamilyName(pFontItem->GetFamilyName()); | |||
2242 | aFont.SetStyleName(pFontItem->GetStyleName()); | |||
2243 | aFont.SetFamily(pFontItem->GetFamily()); | |||
2244 | aFont.SetPitch(pFontItem->GetPitch()); | |||
2245 | aFont.SetCharSet(pFontItem->GetCharSet()); | |||
2246 | } | |||
2247 | ||||
2248 | bool bVertical = rSh.IsInVerticalText(); | |||
2249 | aFont.SetOrientation(bVertical ? 2700 : 0); | |||
2250 | aFont.SetVertical(bVertical); | |||
2251 | GetView().GetEditWin().SetInputContext( InputContext( aFont, InputContextFlags::Text | | |||
2252 | InputContextFlags::ExtText ) ); | |||
2253 | } | |||
2254 | } | |||
2255 | break; | |||
2256 | ||||
2257 | default: | |||
2258 | if( bFirst ) | |||
2259 | { | |||
2260 | rSh.GetCurAttr( rSet ); | |||
2261 | bFirst = false; | |||
2262 | } | |||
2263 | } | |||
2264 | nWhich = aIter.NextWhich(); | |||
2265 | } | |||
2266 | } | |||
2267 | ||||
2268 | void SwBaseShell::GetBckColState(SfxItemSet &rSet) | |||
2269 | { | |||
2270 | SwWrtShell &rSh = GetShell(); | |||
2271 | SfxWhichIter aIter(rSet); | |||
2272 | sal_uInt16 nWhich(aIter.FirstWhich()); | |||
2273 | SelectionType nSelType(rSh.GetSelectionType()); | |||
2274 | std::unique_ptr<SvxBrushItem> aBrushItem(std::make_unique<SvxBrushItem>(RES_BACKGROUND)); | |||
2275 | ||||
2276 | if( nWhich == SID_TABLE_CELL_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 1189 ) ) | |||
2277 | { | |||
2278 | rSh.GetBoxBackground( aBrushItem ); | |||
2279 | } | |||
2280 | else | |||
2281 | { | |||
2282 | // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set | |||
2283 | SfxItemSet aCoreSet(GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}); | |||
2284 | ||||
2285 | aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet()); | |||
2286 | ||||
2287 | if(nSelType & SelectionType::Graphic || SelectionType::Frame & nSelType) | |||
2288 | { | |||
2289 | rSh.GetFlyFrameAttr(aCoreSet); | |||
2290 | } | |||
2291 | else | |||
2292 | { | |||
2293 | rSh.GetCurAttr(aCoreSet); | |||
2294 | } | |||
2295 | ||||
2296 | aBrushItem = getSvxBrushItemFromSourceSet(aCoreSet, RES_BACKGROUND); | |||
2297 | } | |||
2298 | ||||
2299 | while(nWhich) | |||
2300 | { | |||
2301 | switch(nWhich) | |||
2302 | { | |||
2303 | case SID_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 186 ): | |||
2304 | case SID_TABLE_CELL_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 1189 ): | |||
2305 | { | |||
2306 | SvxColorItem aColorItem(aBrushItem->GetColor(), nWhich); | |||
2307 | rSet.Put(aColorItem); | |||
2308 | break; | |||
2309 | } | |||
2310 | case SID_ATTR_BRUSH( 10000 + 1 ): | |||
2311 | case RES_BACKGROUND: | |||
2312 | { | |||
2313 | // if this was intended to have a independent copy of the Item to be set | |||
2314 | // this is not needed due to the ItemSet/Pool cloning Items which get set anyways. | |||
2315 | // Keeping code as reference - it may have had other reasons I do notz see (?!?) | |||
2316 | // std::unique_ptr<SfxPoolItem> pNewItem(aBrushItem.CloneSetWhich(GetPool().GetWhich(nWhich))); | |||
2317 | rSet.Put(*aBrushItem); | |||
2318 | break; | |||
2319 | } | |||
2320 | } | |||
2321 | ||||
2322 | nWhich = aIter.NextWhich(); | |||
2323 | } | |||
2324 | } | |||
2325 | ||||
2326 | void SwBaseShell::ExecBckCol(SfxRequest& rReq) | |||
2327 | { | |||
2328 | SwWrtShell &rSh = GetShell(); | |||
2329 | SelectionType nSelType(rSh.GetSelectionType()); | |||
2330 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
2331 | sal_uInt16 nSlot(rReq.GetSlot()); | |||
2332 | ||||
2333 | if (!pArgs && nSlot != SID_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 186 ) && nSlot != SID_TABLE_CELL_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 1189 )) | |||
2334 | { | |||
2335 | return; | |||
2336 | } | |||
2337 | ||||
2338 | std::unique_ptr<SvxBrushItem> aBrushItem(std::make_unique<SvxBrushItem>(RES_BACKGROUND)); | |||
2339 | ||||
2340 | if ( nSlot == SID_TABLE_CELL_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 1189 ) ) | |||
2341 | { | |||
2342 | rSh.GetBoxBackground( aBrushItem ); | |||
2343 | } | |||
2344 | else | |||
2345 | { | |||
2346 | // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set | |||
2347 | SfxItemSet aCoreSet(GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}); | |||
2348 | ||||
2349 | aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet()); | |||
2350 | ||||
2351 | if((SelectionType::Frame & nSelType) || (SelectionType::Graphic & nSelType)) | |||
2352 | { | |||
2353 | rSh.GetFlyFrameAttr(aCoreSet); | |||
2354 | } | |||
2355 | else | |||
2356 | { | |||
2357 | rSh.GetCurAttr(aCoreSet); | |||
2358 | } | |||
2359 | ||||
2360 | aBrushItem = getSvxBrushItemFromSourceSet(aCoreSet, RES_BACKGROUND); | |||
2361 | } | |||
2362 | ||||
2363 | switch(nSlot) | |||
2364 | { | |||
2365 | case SID_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 186 ): | |||
2366 | case SID_TABLE_CELL_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 1189 ): | |||
2367 | { | |||
2368 | const SfxPoolItem* pColorStringItem = nullptr; | |||
2369 | bool bIsTransparent = false; | |||
2370 | ||||
2371 | aBrushItem->SetGraphicPos(GPOS_NONE); | |||
2372 | ||||
2373 | sal_uInt16 nSlotId = (nSlot == SID_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 186 )) ? SID_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 186 ) : SID_TABLE_CELL_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 1189 ); | |||
2374 | if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR(10000 + 540), false, &pColorStringItem)) | |||
2375 | { | |||
2376 | OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); | |||
2377 | if (sColor == "transparent") | |||
2378 | { | |||
2379 | bIsTransparent = true; | |||
2380 | } | |||
2381 | else | |||
2382 | { | |||
2383 | Color aColor(sColor.toInt32(16)); | |||
2384 | ||||
2385 | aBrushItem->SetColor(aColor); | |||
2386 | ||||
2387 | SvxColorItem aNewColorItem(nSlotId); | |||
2388 | aNewColorItem.SetValue(aColor); | |||
2389 | ||||
2390 | GetView().GetViewFrame()->GetBindings().SetState(aNewColorItem); | |||
2391 | } | |||
2392 | } | |||
2393 | else if (pArgs) | |||
2394 | { | |||
2395 | const SvxColorItem& rNewColorItem = static_cast<const SvxColorItem&>(pArgs->Get(nSlotId)); | |||
2396 | const Color& rNewColor = rNewColorItem.GetValue(); | |||
2397 | aBrushItem->SetColor(rNewColor); | |||
2398 | GetView().GetViewFrame()->GetBindings().SetState(rNewColorItem); | |||
2399 | } | |||
2400 | else | |||
2401 | { | |||
2402 | bIsTransparent = true; | |||
2403 | } | |||
2404 | ||||
2405 | if (bIsTransparent) | |||
2406 | { | |||
2407 | aBrushItem->SetColor(COL_TRANSPARENT); | |||
2408 | rReq.AppendItem(SvxColorItem(COL_TRANSPARENT,nSlot)); | |||
2409 | } | |||
2410 | break; | |||
2411 | } | |||
2412 | ||||
2413 | case SID_ATTR_BRUSH( 10000 + 1 ): | |||
2414 | case RES_BACKGROUND: | |||
2415 | { | |||
2416 | assert(pArgs && "only SID_BACKGROUND_COLOR can have !pArgs, checked at entry")(static_cast <bool> (pArgs && "only SID_BACKGROUND_COLOR can have !pArgs, checked at entry" ) ? void (0) : __assert_fail ("pArgs && \"only SID_BACKGROUND_COLOR can have !pArgs, checked at entry\"" , "/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" , 2416, __extension__ __PRETTY_FUNCTION__)); | |||
2417 | aBrushItem.reset(static_cast<SvxBrushItem*>(pArgs->Get(GetPool().GetWhich(nSlot)).Clone())); | |||
2418 | break; | |||
2419 | } | |||
2420 | default: | |||
2421 | { | |||
2422 | rReq.Ignore(); | |||
2423 | OSL_FAIL("unknown message in ExecuteAttr!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "2423" ": "), "%s", "unknown message in ExecuteAttr!"); } } while (false); | |||
2424 | return; | |||
2425 | } | |||
2426 | } | |||
2427 | ||||
2428 | if ( nSlot == SID_TABLE_CELL_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 1189 ) ) | |||
2429 | { | |||
2430 | rSh.SetBoxBackground( *aBrushItem ); | |||
2431 | } | |||
2432 | else | |||
2433 | { | |||
2434 | // Adapt to new DrawingLayer FillStyle; use a parent which has XFILL_NONE set | |||
2435 | SfxItemSet aCoreSet(GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}); | |||
2436 | ||||
2437 | aCoreSet.SetParent(&GetView().GetDocShell()->GetDoc()->GetDfltFrameFormat()->GetAttrSet()); | |||
2438 | setSvxBrushItemAsFillAttributesToTargetSet(*aBrushItem, aCoreSet); | |||
2439 | ||||
2440 | if((SelectionType::Frame & nSelType) || (SelectionType::Graphic & nSelType)) | |||
2441 | { | |||
2442 | // Template autoupdate | |||
2443 | SwFrameFormat* pFormat = rSh.GetSelectedFrameFormat(); | |||
2444 | ||||
2445 | if(pFormat && pFormat->IsAutoUpdateFormat()) | |||
2446 | { | |||
2447 | rSh.AutoUpdateFrame(pFormat, aCoreSet); | |||
2448 | } | |||
2449 | else | |||
2450 | { | |||
2451 | rSh.SetFlyFrameAttr(aCoreSet); | |||
2452 | } | |||
2453 | } | |||
2454 | else | |||
2455 | { | |||
2456 | SwTextFormatColl* pColl = rSh.GetCurTextFormatColl(); | |||
2457 | ||||
2458 | if(pColl && pColl->IsAutoUpdateFormat()) | |||
2459 | { | |||
2460 | rSh.AutoUpdatePara(pColl, aCoreSet); | |||
2461 | } | |||
2462 | else | |||
2463 | { | |||
2464 | rSh.SetAttrSet(aCoreSet); | |||
2465 | } | |||
2466 | } | |||
2467 | } | |||
2468 | ||||
2469 | rReq.Done(); | |||
2470 | } | |||
2471 | ||||
2472 | void SwBaseShell::GetBorderState(SfxItemSet &rSet) | |||
2473 | { | |||
2474 | SwWrtShell &rSh = GetShell(); | |||
2475 | // Tabele cell(s) selected? | |||
2476 | bool bPrepare = true; | |||
2477 | bool bTableMode = rSh.IsTableMode(); | |||
2478 | if ( bTableMode ) | |||
2479 | { | |||
2480 | SfxItemSet aCoreSet( GetPool(), | |||
2481 | svl::Items<RES_BOX, RES_BOX, | |||
2482 | SID_ATTR_BORDER_INNERTypedWhichId<SvxBoxInfoItem>( 10000 + 23 ), SID_ATTR_BORDER_INNERTypedWhichId<SvxBoxInfoItem>( 10000 + 23 )>{} ); | |||
2483 | SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNERTypedWhichId<SvxBoxInfoItem>( 10000 + 23 ) ); | |||
2484 | aCoreSet.Put( aBoxInfo ); | |||
2485 | rSh.GetTabBorders( aCoreSet ); | |||
2486 | rSet.Put( aCoreSet ); | |||
2487 | } | |||
2488 | else if ( rSh.IsFrameSelected() ) | |||
2489 | { | |||
2490 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); | |||
2491 | rSet.Put( aMgr.GetAttrSet() ); | |||
2492 | bPrepare = false; | |||
2493 | } | |||
2494 | else | |||
2495 | // Get border attributes via shell quite normal | |||
2496 | rSh.GetCurAttr( rSet ); | |||
2497 | if ( bPrepare ) | |||
2498 | ::PrepareBoxInfo( rSet, rSh ); | |||
2499 | // Switch the border toolbox controller mode | |||
2500 | rSet.Put( SfxBoolItem( SID_BORDER_REDUCED_MODE( 10000 + 1055 ), !bTableMode )); | |||
2501 | } | |||
2502 | ||||
2503 | void SwBaseShell::ExecDlg(SfxRequest &rReq) | |||
2504 | { | |||
2505 | SwWrtShell &rSh = GetShell(); | |||
2506 | weld::Window* pMDI = GetView().GetFrameWeld(); | |||
2507 | // So that from the basic no dialogues for the background views are called: | |||
2508 | bool bBackground = (&GetView() != GetActiveView()); | |||
2509 | const SfxPoolItem* pItem = nullptr; | |||
2510 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
2511 | ||||
2512 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
2513 | const SfxItemSet* pOutSet = nullptr; | |||
2514 | bool bDone = false; | |||
2515 | if(pArgs) | |||
2516 | pArgs->GetItemState( GetPool().GetWhich(nSlot), false, &pItem ); | |||
2517 | ||||
2518 | switch ( nSlot ) | |||
2519 | { | |||
2520 | case FN_FORMAT_TITLEPAGE_DLG((20000 + 400) + 98): | |||
2521 | { | |||
2522 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
2523 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateTitlePageDlg(pMDI)); | |||
2524 | VclAbstractDialog::AsyncContext aContext; | |||
2525 | aContext.maEndDialogFn = [](sal_Int32){}; | |||
2526 | pDlg->StartExecuteAsync(aContext); | |||
2527 | } | |||
2528 | break; | |||
2529 | case FN_FORMAT_PAGE_DLG((20000 + 400) + 52): | |||
2530 | case FN_FORMAT_PAGE_COLUMN_DLG((20000 + 400) + 49): | |||
2531 | case FN_FORMAT_PAGE_SETTING_DLG((20000 + 400) + 42): | |||
2532 | { | |||
2533 | if( !bBackground ) | |||
2534 | { | |||
2535 | const size_t nCurIdx = rSh.GetCurPageDesc(); | |||
2536 | const SwPageDesc& rPageDesc = rSh.GetPageDesc( nCurIdx ); | |||
2537 | // Temporary view, because the shell does not need to be valid after the dialog | |||
2538 | // for example disable header | |||
2539 | SwView& rTempView = GetView(); | |||
2540 | ||||
2541 | OString sPageId; | |||
2542 | switch (nSlot) | |||
2543 | { | |||
2544 | case FN_FORMAT_PAGE_COLUMN_DLG((20000 + 400) + 49): | |||
2545 | sPageId = "columns"; | |||
2546 | break; | |||
2547 | case FN_FORMAT_PAGE_SETTING_DLG((20000 + 400) + 42): | |||
2548 | sPageId = "page"; | |||
2549 | break; | |||
2550 | case FN_FORMAT_PAGE_DLG((20000 + 400) + 52): | |||
2551 | if (pItem) | |||
2552 | sPageId = OUStringToOString(static_cast<const SfxStringItem*>(pItem)->GetValue(), RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))); | |||
2553 | break; | |||
2554 | } | |||
2555 | rTempView.GetDocShell()->FormatPage(rPageDesc.GetName(), sPageId, rSh, &rReq); | |||
2556 | rTempView.InvalidateRulerPos(); | |||
2557 | ||||
2558 | bDone = true; // FormatPage() takes care of calling Done() | |||
2559 | } | |||
2560 | } | |||
2561 | break; | |||
2562 | case FN_FORMAT_BORDER_DLG((20000 + 400) + 48): | |||
2563 | { | |||
2564 | SfxItemSet aSet( rSh.GetAttrPool(), | |||
2565 | svl::Items<RES_BOX , RES_SHADOW, | |||
2566 | SID_ATTR_BORDER_INNERTypedWhichId<SvxBoxInfoItem>( 10000 + 23 ), SID_ATTR_BORDER_INNERTypedWhichId<SvxBoxInfoItem>( 10000 + 23 )>{} ); | |||
2567 | ScopedVclPtr<SfxAbstractDialog> pDlg; | |||
2568 | // Table cell(s) selected? | |||
2569 | if ( rSh.IsTableMode() ) | |||
2570 | { | |||
2571 | // Set border attributes Get/SetTabBorders() | |||
2572 | ::PrepareBoxInfo( aSet, rSh ); | |||
2573 | rSh.GetTabBorders( aSet ); | |||
2574 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
2575 | pDlg.disposeAndReset(pFact->CreateSwBorderDlg(pMDI, aSet, SwBorderModes::TABLE)); | |||
2576 | if ( pDlg->Execute() == RET_OK ) | |||
2577 | { | |||
2578 | rSh.SetTabBorders( *pDlg->GetOutputItemSet() ); | |||
2579 | pOutSet = pDlg->GetOutputItemSet(); | |||
2580 | } | |||
2581 | } | |||
2582 | else if ( rSh.IsFrameSelected() ) | |||
2583 | { | |||
2584 | // Set border attributes via Frame-Manager | |||
2585 | SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); | |||
2586 | aSet.Put( aMgr.GetAttrSet() ); | |||
2587 | ||||
2588 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
2589 | pDlg.disposeAndReset(pFact->CreateSwBorderDlg(pMDI, aSet, SwBorderModes::FRAME)); | |||
2590 | if ( pDlg->Execute() == RET_OK ) | |||
2591 | { | |||
2592 | aMgr.SetAttrSet( *pDlg->GetOutputItemSet() ); | |||
2593 | aMgr.UpdateFlyFrame(); | |||
2594 | pOutSet = pDlg->GetOutputItemSet(); | |||
2595 | } | |||
2596 | } | |||
2597 | else | |||
2598 | { | |||
2599 | // Set border attributes via Shell quite normal | |||
2600 | rSh.GetCurAttr( aSet ); | |||
2601 | ::PrepareBoxInfo( aSet, rSh ); | |||
2602 | ||||
2603 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
2604 | pDlg.disposeAndReset(pFact->CreateSwBorderDlg(pMDI, aSet, SwBorderModes::PARA)); | |||
2605 | if ( pDlg->Execute() == RET_OK ) | |||
2606 | { | |||
2607 | rSh.SetAttrSet( *pDlg->GetOutputItemSet() ); | |||
2608 | pOutSet = pDlg->GetOutputItemSet(); | |||
2609 | } | |||
2610 | } | |||
2611 | if(pOutSet) | |||
2612 | { | |||
2613 | rReq.Done(*pOutSet); | |||
2614 | bDone = true; | |||
2615 | } | |||
2616 | } | |||
2617 | break; | |||
2618 | case FN_FORMAT_BACKGROUND_DLG((20000 + 400) + 50): | |||
2619 | { | |||
2620 | SfxItemSet aSet( rSh.GetAttrPool(), | |||
2621 | svl::Items<RES_BACKGROUND, RES_BACKGROUND, | |||
2622 | XATTR_FILL_FIRST, XATTR_FILL_LAST>{} ); | |||
2623 | ||||
2624 | ScopedVclPtr<SfxAbstractDialog> pDlg; | |||
2625 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
2626 | ||||
2627 | // Table cell(s) selected? | |||
2628 | if ( rSh.IsTableMode() ) | |||
2629 | { | |||
2630 | // Get background attributes of the table and put it in the set | |||
2631 | std::unique_ptr<SvxBrushItem> aBrush; | |||
2632 | rSh.GetBoxBackground( aBrush ); | |||
2633 | pDlg.disposeAndReset(pFact->CreateSwBackgroundDialog(pMDI, aSet)); | |||
2634 | aSet.Put( *aBrush ); | |||
2635 | if ( pDlg->Execute() == RET_OK ) | |||
2636 | { | |||
2637 | ||||
2638 | rSh.SetBoxBackground( pDlg->GetOutputItemSet()->Get( RES_BACKGROUND ) ); | |||
2639 | pOutSet = pDlg->GetOutputItemSet(); | |||
2640 | } | |||
2641 | } | |||
2642 | else if ( rSh.IsFrameSelected() ) | |||
2643 | { | |||
2644 | ||||
2645 | rSh.GetFlyFrameAttr( aSet ); | |||
2646 | ||||
2647 | pDlg.disposeAndReset(pFact->CreateSwBackgroundDialog(pMDI, aSet)); | |||
2648 | if ( pDlg->Execute() == RET_OK ) | |||
2649 | { | |||
2650 | rSh.SetFlyFrameAttr(const_cast<SfxItemSet &>(*pDlg->GetOutputItemSet()) ); | |||
2651 | pOutSet = pDlg->GetOutputItemSet(); | |||
2652 | } | |||
2653 | } | |||
2654 | else | |||
2655 | { | |||
2656 | // Set border attributes Umrandungsattribute with the shell quite normal. | |||
2657 | rSh.GetCurAttr( aSet ); | |||
2658 | ||||
2659 | pDlg.disposeAndReset(pFact->CreateSwBackgroundDialog(pMDI, aSet)); | |||
2660 | if ( pDlg->Execute() == RET_OK ) | |||
2661 | { | |||
2662 | rSh.SetAttrSet( *pDlg->GetOutputItemSet() ); | |||
2663 | pOutSet = pDlg->GetOutputItemSet(); | |||
2664 | } | |||
2665 | } | |||
2666 | if(pOutSet) | |||
2667 | { | |||
2668 | rReq.Done(*pOutSet); | |||
2669 | bDone = true; | |||
2670 | } | |||
2671 | } | |||
2672 | break; | |||
2673 | case SID_ACCESSIBILITY_CHECK(5000 + 810): | |||
2674 | { | |||
2675 | sw::AccessibilityCheck aCheck(rSh.GetDoc()); | |||
2676 | aCheck.check(); | |||
2677 | svx::AccessibilityCheckDialog aDialog(pMDI, aCheck.getIssueCollection()); | |||
2678 | aDialog.run(); | |||
2679 | } | |||
2680 | break; | |||
2681 | default:OSL_FAIL("wrong Dispatcher (basesh.cxx)")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "2681" ": "), "%s", "wrong Dispatcher (basesh.cxx)"); } } while (false); | |||
2682 | } | |||
2683 | if(!bDone) | |||
2684 | rReq.Done(); | |||
2685 | } | |||
2686 | ||||
2687 | SwWrtShell& SwBaseShell::GetShell() | |||
2688 | { | |||
2689 | return rView.GetWrtShell(); | |||
2690 | } | |||
2691 | ||||
2692 | SwWrtShell* SwBaseShell::GetShellPtr() | |||
2693 | { | |||
2694 | return rView.GetWrtShellPtr(); | |||
2695 | } | |||
2696 | ||||
2697 | static void EndUndo(SwWrtShell& rSh) | |||
2698 | { | |||
2699 | SwRewriter aRewriter; | |||
2700 | ||||
2701 | if (rSh.GetTableFormat()) | |||
2702 | { | |||
2703 | aRewriter.AddRule(UndoArg1, SwResId(STR_START_QUOTEreinterpret_cast<char const *>("STR_START_QUOTE" "\004" u8"“"))); | |||
2704 | aRewriter.AddRule(UndoArg2, rSh.GetTableFormat()->GetName()); | |||
2705 | aRewriter.AddRule(UndoArg3, SwResId(STR_END_QUOTEreinterpret_cast<char const *>("STR_END_QUOTE" "\004" u8"”" ))); | |||
2706 | ||||
2707 | } | |||
2708 | rSh.EndUndo(SwUndoId::INSTABLE, &aRewriter); // If possible change the Shell | |||
2709 | } | |||
2710 | ||||
2711 | static void InsertTableImpl(SwWrtShell& rSh, | |||
2712 | SwView &rTempView, | |||
2713 | const OUString& aTableName, | |||
2714 | sal_uInt16 nRows, | |||
2715 | sal_uInt16 nCols, | |||
2716 | SwInsertTableOptions aInsTableOpts, | |||
2717 | const OUString& aAutoName, | |||
2718 | const std::unique_ptr<SwTableAutoFormat>& pTAFormat) | |||
2719 | { | |||
2720 | rSh.StartUndo(SwUndoId::INSTABLE); | |||
2721 | ||||
2722 | rSh.StartAllAction(); | |||
2723 | if( rSh.HasSelection() ) | |||
2724 | rSh.DelRight(); | |||
2725 | ||||
2726 | rSh.InsertTable( aInsTableOpts, nRows, nCols, pTAFormat.get() ); | |||
2727 | rSh.MoveTable( GotoPrevTable, fnTableStart ); | |||
2728 | ||||
2729 | if( !aTableName.isEmpty() && !rSh.GetTableStyle( aTableName ) ) | |||
2730 | rSh.GetTableFormat()->SetName( aTableName ); | |||
2731 | ||||
2732 | if( pTAFormat != nullptr && !aAutoName.isEmpty() | |||
2733 | && aAutoName != SwViewShell::GetShellRes()->aStrNone ) | |||
2734 | { | |||
2735 | SwTableNode* pTableNode = const_cast<SwTableNode*>( rSh.IsCursorInTable() ); | |||
2736 | if ( pTableNode ) | |||
2737 | { | |||
2738 | pTableNode->GetTable().SetTableStyleName( aAutoName ); | |||
2739 | SwUndoTableAutoFormat* pUndo = new SwUndoTableAutoFormat( *pTableNode, *pTAFormat ); | |||
2740 | if ( pUndo ) | |||
2741 | rSh.GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) ); | |||
2742 | } | |||
2743 | } | |||
2744 | ||||
2745 | rSh.EndAllAction(); | |||
2746 | rTempView.AutoCaption(TABLE_CAP); | |||
2747 | } | |||
2748 | ||||
2749 | void SwBaseShell::InsertTable( SfxRequest& _rRequest ) | |||
2750 | { | |||
2751 | const SfxItemSet* pArgs = _rRequest.GetArgs(); | |||
2752 | SwWrtShell& rSh = GetShell(); | |||
2753 | ||||
2754 | if ( rSh.GetFrameType( nullptr, true ) & FrameTypeFlags::FOOTNOTE ) | |||
2755 | return; | |||
2756 | ||||
2757 | SwView &rTempView = GetView(); // Because GetView() does not work after the shell exchange | |||
2758 | bool bHTMLMode = 0 != (::GetHtmlMode(rTempView.GetDocShell())&HTMLMODE_ON); | |||
2759 | bool bCallEndUndo = false; | |||
2760 | ||||
2761 | if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() && | |||
2762 | !rSh.IsTableMode() ) | |||
2763 | { | |||
2764 | const SwModuleOptions* pModOpt = SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule ::Writer)))->GetModuleConfig(); | |||
2765 | SwInsertTableOptions aInsTableOpts = pModOpt->GetInsTableFlags(bHTMLMode); | |||
2766 | ||||
2767 | rSh.StartUndo(SwUndoId::INSTABLE); | |||
2768 | bCallEndUndo = true; | |||
2769 | ||||
2770 | bool bInserted = rSh.TextToTable( aInsTableOpts, '\t' ); | |||
2771 | rSh.EnterStdMode(); | |||
2772 | if (bInserted) | |||
2773 | rTempView.AutoCaption(TABLE_CAP); | |||
2774 | _rRequest.Done(); | |||
2775 | } | |||
2776 | else | |||
2777 | { | |||
2778 | sal_uInt16 nColsIn = 0; | |||
2779 | sal_uInt16 nRowsIn = 0; | |||
2780 | SwInsertTableOptions aInsTableOptsIn( SwInsertTableFlags::All, 1 ); | |||
2781 | OUString aTableNameIn; | |||
2782 | OUString aAutoNameIn; | |||
2783 | std::unique_ptr<SwTableAutoFormat> pTAFormatIn; | |||
2784 | ||||
2785 | if( pArgs && pArgs->Count() >= 2 ) | |||
2786 | { | |||
2787 | const SfxStringItem* pName = _rRequest.GetArg<SfxStringItem>(FN_INSERT_TABLE((20000 + 300) + 30)); | |||
2788 | const SfxUInt16Item* pCols = _rRequest.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_COLUMNTypedWhichId<SfxUInt16Item>( 10000 + 218 )); | |||
2789 | const SfxUInt16Item* pRows = _rRequest.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_ROWTypedWhichId<SfxUInt16Item>( 10000 + 219 )); | |||
2790 | const SfxInt32Item* pFlags = _rRequest.GetArg<SfxInt32Item>(FN_PARAM_1((20000 + 1100)+60)); | |||
2791 | const SfxStringItem* pAuto = _rRequest.GetArg<SfxStringItem>(FN_PARAM_2((20000 + 1100)+61)); | |||
2792 | ||||
2793 | if ( pName ) | |||
2794 | aTableNameIn = pName->GetValue(); | |||
2795 | if ( pCols ) | |||
2796 | nColsIn = pCols->GetValue(); | |||
2797 | if ( pRows ) | |||
2798 | nRowsIn = pRows->GetValue(); | |||
2799 | if ( pAuto ) | |||
2800 | { | |||
2801 | aAutoNameIn = pAuto->GetValue(); | |||
2802 | if ( !aAutoNameIn.isEmpty() ) | |||
2803 | { | |||
2804 | SwTableAutoFormatTable aTableTable; | |||
2805 | aTableTable.Load(); | |||
2806 | for ( size_t n=0; n<aTableTable.size(); n++ ) | |||
2807 | { | |||
2808 | if ( aTableTable[n].GetName() == aAutoNameIn ) | |||
2809 | { | |||
2810 | pTAFormatIn.reset(new SwTableAutoFormat( aTableTable[n] )); | |||
2811 | break; | |||
2812 | } | |||
2813 | } | |||
2814 | } | |||
2815 | } | |||
2816 | ||||
2817 | if ( pFlags ) | |||
2818 | aInsTableOptsIn.mnInsMode = static_cast<SwInsertTableFlags>(pFlags->GetValue()); | |||
2819 | else | |||
2820 | { | |||
2821 | const SwModuleOptions* pModOpt = SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule ::Writer)))->GetModuleConfig(); | |||
2822 | aInsTableOptsIn = pModOpt->GetInsTableFlags(bHTMLMode); | |||
2823 | } | |||
2824 | } | |||
2825 | ||||
2826 | if( !nColsIn || !nRowsIn ) | |||
2827 | { | |||
2828 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
2829 | std::shared_ptr<AbstractInsTableDlg> pAbstractDialog(pFact->CreateInsTableDlg(rTempView)); | |||
2830 | std::shared_ptr<weld::DialogController> pDialogController(pAbstractDialog->getDialogController()); | |||
2831 | ||||
2832 | weld::DialogController::runAsync(pDialogController, | |||
2833 | [pAbstractDialog, &rSh, &rTempView, aTableNameIn, nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn] (sal_Int32 nResult) { | |||
2834 | if( RET_OK == nResult ) | |||
2835 | { | |||
2836 | sal_uInt16 nCols = nColsIn; | |||
2837 | sal_uInt16 nRows = nRowsIn; | |||
2838 | SwInsertTableOptions aInsTableOpts = aInsTableOptsIn; | |||
2839 | OUString aTableName = aTableNameIn; | |||
2840 | OUString aAutoName = aAutoNameIn; | |||
2841 | std::unique_ptr<SwTableAutoFormat> pTAFormat; | |||
2842 | ||||
2843 | pAbstractDialog->GetValues( aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat ); | |||
2844 | ||||
2845 | if( nCols && nRows ) | |||
2846 | { | |||
2847 | InsertTableImpl( rSh, rTempView, aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat ); | |||
2848 | EndUndo(rSh); | |||
2849 | } | |||
2850 | } | |||
2851 | } | |||
2852 | ); | |||
2853 | } | |||
2854 | else | |||
2855 | { | |||
2856 | // record before shell change | |||
2857 | _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE((20000 + 300) + 30), aTableNameIn ) ); | |||
2858 | if ( !aAutoNameIn.isEmpty() ) | |||
2859 | _rRequest.AppendItem( SfxStringItem( FN_PARAM_2((20000 + 1100)+61), aAutoNameIn ) ); | |||
2860 | _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMNTypedWhichId<SfxUInt16Item>( 10000 + 218 ), nColsIn ) ); | |||
2861 | _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROWTypedWhichId<SfxUInt16Item>( 10000 + 219 ), nRowsIn ) ); | |||
2862 | _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1((20000 + 1100)+60), static_cast<sal_Int32>(aInsTableOptsIn.mnInsMode) ) ); | |||
2863 | _rRequest.Done(); | |||
2864 | ||||
2865 | InsertTableImpl( rSh, rTempView, aTableNameIn, nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn, pTAFormatIn ); | |||
2866 | ||||
2867 | bCallEndUndo = true; | |||
2868 | } | |||
2869 | } | |||
2870 | ||||
2871 | if( bCallEndUndo ) | |||
2872 | EndUndo(rSh); | |||
2873 | } | |||
2874 | ||||
2875 | void SwBaseShell::GetGalleryState( SfxItemSet &rSet ) | |||
2876 | { | |||
2877 | SwWrtShell &rSh = GetShell(); | |||
2878 | SfxWhichIter aIter( rSet ); | |||
2879 | sal_uInt16 nWhich = aIter.FirstWhich(); | |||
2880 | switch ( nWhich ) | |||
2881 | { | |||
2882 | case SID_GALLERY_BG_BRUSH(10000 + 279): | |||
2883 | { | |||
2884 | SelectionType nSel = rSh.GetSelectionType(); | |||
2885 | SfxStringListItem aLst( nWhich ); | |||
2886 | std::vector<OUString> &rLst = aLst.GetList(); | |||
2887 | nParagraphPos = nGraphicPos = nOlePos = nFramePos = nTablePos = | |||
2888 | nTableRowPos = nTableCellPos = nPagePos = | |||
2889 | nHeaderPos = nFooterPos = 0; | |||
2890 | sal_uInt8 nPos = 1; | |||
2891 | rLst.push_back( SwResId( STR_SWBG_PAGEreinterpret_cast<char const *>("STR_SWBG_PAGE" "\004" u8"Page" ) ) ); | |||
2892 | nPagePos = nPos++; | |||
2893 | sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell()); | |||
2894 | bool bHtmlMode = 0 != (nHtmlMode & HTMLMODE_ON); | |||
2895 | ||||
2896 | if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_FULL_STYLES)) && | |||
2897 | (nSel & SelectionType::Text) ) | |||
2898 | { | |||
2899 | rLst.push_back( SwResId( STR_SWBG_PARAGRAPHreinterpret_cast<char const *>("STR_SWBG_PARAGRAPH" "\004" u8"Paragraph") ) ); | |||
2900 | nParagraphPos = nPos++; | |||
2901 | } | |||
2902 | if ( (!bHtmlMode || (nHtmlMode & HTMLMODE_SOME_STYLES)) && | |||
2903 | nSel & (SelectionType::Table|SelectionType::TableCell) ) | |||
2904 | { | |||
2905 | rLst.push_back( SwResId( STR_SWBG_TABLEreinterpret_cast<char const *>("STR_SWBG_TABLE" "\004" u8"Table" ) ) ); | |||
2906 | nTablePos = nPos++; | |||
2907 | ||||
2908 | if(!bHtmlMode) | |||
2909 | { | |||
2910 | rLst.push_back( SwResId( STR_SWBG_TABLE_ROWreinterpret_cast<char const *>("STR_SWBG_TABLE_ROW" "\004" u8"Table row") ) ); | |||
2911 | nTableRowPos = nPos++; | |||
2912 | } | |||
2913 | ||||
2914 | rLst.push_back( SwResId( STR_SWBG_TABLE_CELLreinterpret_cast<char const *>("STR_SWBG_TABLE_CELL" "\004" u8"Table cell")) ); | |||
2915 | nTableCellPos = nPos++; | |||
2916 | } | |||
2917 | if(!bHtmlMode) | |||
2918 | { | |||
2919 | if ( nSel & SelectionType::Frame ) | |||
2920 | { | |||
2921 | rLst.push_back( SwResId( STR_SWBG_FRAMEreinterpret_cast<char const *>("STR_SWBG_FRAME" "\004" u8"Frame" ) ) ); | |||
2922 | nFramePos = nPos++; | |||
2923 | } | |||
2924 | if ( nSel & SelectionType::Graphic ) | |||
2925 | { | |||
2926 | rLst.push_back( SwResId( STR_SWBG_GRAPHICreinterpret_cast<char const *>("STR_SWBG_GRAPHIC" "\004" u8"Image") ) ); | |||
2927 | nGraphicPos = nPos++; | |||
2928 | } | |||
2929 | if ( nSel & SelectionType::Ole ) | |||
2930 | { | |||
2931 | rLst.push_back( SwResId( STR_SWBG_OLEreinterpret_cast<char const *>("STR_SWBG_OLE" "\004" u8"OLE object" ) ) ); | |||
2932 | nOlePos = nPos++; | |||
2933 | } | |||
2934 | const FrameTypeFlags nType = rSh.GetFrameType(nullptr,true); | |||
2935 | if ( nType & FrameTypeFlags::HEADER ) | |||
2936 | { | |||
2937 | rLst.push_back( SwResId( STR_SWBG_HEADERreinterpret_cast<char const *>("STR_SWBG_HEADER" "\004" u8"Header") ) ); | |||
2938 | nHeaderPos = nPos++; | |||
2939 | } | |||
2940 | if ( nType & FrameTypeFlags::FOOTER ) | |||
2941 | { | |||
2942 | rLst.push_back( SwResId( STR_SWBG_FOOTERreinterpret_cast<char const *>("STR_SWBG_FOOTER" "\004" u8"Footer") ) ); | |||
2943 | nFooterPos = nPos; | |||
2944 | } | |||
2945 | } | |||
2946 | if ( rLst.empty() ) | |||
2947 | rSet.DisableItem( nWhich ); | |||
2948 | else | |||
2949 | rSet.Put( aLst ); | |||
2950 | break; | |||
2951 | } | |||
2952 | } | |||
2953 | } | |||
2954 | ||||
2955 | void SwBaseShell::ExecuteGallery(SfxRequest &rReq) | |||
2956 | { | |||
2957 | SwWrtShell &rSh = GetShell(); | |||
2958 | rSh.StartAction(); | |||
2959 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
2960 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
2961 | switch(nSlot) | |||
2962 | { | |||
2963 | case SID_GALLERY_BG_BRUSH(10000 + 279): | |||
2964 | { | |||
2965 | if ( !pArgs ) | |||
2966 | break; | |||
2967 | ||||
2968 | SelectionType nSel = rSh.GetSelectionType(); | |||
2969 | if ( nSel & SelectionType::DrawObjectEditMode ) | |||
2970 | break; | |||
2971 | ||||
2972 | const SfxUInt16Item* pPos = rReq.GetArg<SfxUInt16Item>(SID_GALLERY_BG_POS( 10000 + 278 )); | |||
2973 | const SvxBrushItem* pBrush = rReq.GetArg<SvxBrushItem>(SID_GALLERY_BG_BRUSH(10000 + 279)); | |||
2974 | if ( !pPos || !pBrush ) | |||
2975 | break; | |||
2976 | ||||
2977 | sal_uInt8 nPos = pPos->GetValue(); | |||
2978 | ++nPos; | |||
2979 | ||||
2980 | SvxBrushItem aBrush( *pBrush ); | |||
2981 | aBrush.SetWhich( RES_BACKGROUND ); | |||
2982 | if ( nPos == nParagraphPos ) | |||
2983 | rSh.SetAttrItem( aBrush ); | |||
2984 | else if ( nPos == nTablePos ) | |||
2985 | rSh.SetTabBackground( aBrush ); | |||
2986 | else if ( nPos == nTableRowPos ) | |||
2987 | rSh.SetRowBackground( aBrush ); | |||
2988 | else if ( nPos == nTableCellPos ) | |||
2989 | rSh.SetBoxBackground( aBrush ); | |||
2990 | else if ( nPos == nFramePos || nPos == nGraphicPos || nPos == nOlePos ) | |||
2991 | { | |||
2992 | SfxItemSet aCoreSet(GetPool(), svl::Items<RES_BACKGROUND, RES_BACKGROUND>{}); | |||
2993 | aCoreSet.Put( aBrush ); | |||
2994 | rSh.SetFlyFrameAttr( aCoreSet ); | |||
2995 | } | |||
2996 | else if ( nPos == nPagePos || nPos == nHeaderPos || nPos == nFooterPos ) | |||
2997 | { | |||
2998 | sal_uInt16 nDesc = rSh.GetCurPageDesc(); | |||
2999 | SwPageDesc aDesc( rSh.GetPageDesc( nDesc ) ); | |||
3000 | if ( nPos == nPagePos ) | |||
3001 | aDesc.GetMaster().SetFormatAttr( aBrush ); | |||
3002 | else if ( nPos == nHeaderPos ) | |||
3003 | { | |||
3004 | SwFormatHeader aHead( aDesc.GetMaster().GetHeader() ); | |||
3005 | aHead.GetHeaderFormat()->SetFormatAttr( aBrush ); | |||
3006 | aDesc.GetMaster().SetFormatAttr( aHead ); | |||
3007 | } | |||
3008 | else if ( nPos == nFooterPos ) | |||
3009 | { | |||
3010 | SwFormatFooter aFoot( aDesc.GetMaster().GetFooter() ); | |||
3011 | aFoot.GetFooterFormat()->SetFormatAttr( aBrush ); | |||
3012 | aDesc.GetMaster().SetFormatAttr( aFoot ); | |||
3013 | } | |||
3014 | rSh.ChgPageDesc( nDesc, aDesc ); | |||
3015 | } | |||
3016 | break; | |||
3017 | } | |||
3018 | } | |||
3019 | rSh.EndAction(); | |||
3020 | rReq.Done(); | |||
3021 | } | |||
3022 | ||||
3023 | void SwBaseShell::ExecField( SfxRequest const & rReq ) | |||
3024 | { | |||
3025 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
3026 | switch( nSlot ) | |||
| ||||
3027 | { | |||
3028 | #if HAVE_FEATURE_DBCONNECTIVITY1 | |||
3029 | case FN_CHANGE_DBFIELD((20000 + 300) + 9 ): | |||
3030 | { | |||
3031 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); | |||
3032 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwChangeDBDlg(GetView())); | |||
3033 | pDlg->Execute(); | |||
3034 | } | |||
3035 | break; | |||
3036 | #endif | |||
3037 | default: | |||
3038 | OSL_FAIL("wrong dispatcher")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/shells/basesh.cxx" ":" "3038" ": "), "%s", "wrong dispatcher"); } } while (false ); | |||
3039 | } | |||
3040 | } | |||
3041 | ||||
3042 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||
22 | |||||||||
23 | #include "sal/config.h" | ||||||||
24 | |||||||||
25 | #include <cassert> | ||||||||
26 | #include <cstddef> | ||||||||
27 | #include <functional> | ||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
29 | #include <type_traits> | ||||||||
30 | #endif | ||||||||
31 | |||||||||
32 | #include "sal/types.h" | ||||||||
33 | |||||||||
34 | namespace rtl | ||||||||
35 | { | ||||||||
36 | |||||||||
37 | /** Template reference class for reference type. | ||||||||
38 | */ | ||||||||
39 | template <class reference_type> | ||||||||
40 | class Reference | ||||||||
41 | { | ||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||
43 | */ | ||||||||
44 | reference_type * m_pBody; | ||||||||
45 | |||||||||
46 | |||||||||
47 | public: | ||||||||
48 | /** Constructor... | ||||||||
49 | */ | ||||||||
50 | Reference() | ||||||||
51 | : m_pBody (NULL__null) | ||||||||
52 | {} | ||||||||
53 | |||||||||
54 | |||||||||
55 | /** Constructor... | ||||||||
56 | */ | ||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||
58 | : m_pBody (pBody) | ||||||||
59 | { | ||||||||
60 | } | ||||||||
61 | |||||||||
62 | /** Constructor... | ||||||||
63 | */ | ||||||||
64 | Reference (reference_type * pBody) | ||||||||
65 | : m_pBody (pBody) | ||||||||
66 | { | ||||||||
67 | if (m_pBody) | ||||||||
68 | m_pBody->acquire(); | ||||||||
69 | } | ||||||||
70 | |||||||||
71 | /** Copy constructor... | ||||||||
72 | */ | ||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||
75 | { | ||||||||
76 | if (m_pBody) | ||||||||
77 | m_pBody->acquire(); | ||||||||
78 | } | ||||||||
79 | |||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
81 | /** Move constructor... | ||||||||
82 | */ | ||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||
85 | { | ||||||||
86 | handle.m_pBody = nullptr; | ||||||||
87 | } | ||||||||
88 | #endif | ||||||||
89 | |||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||
92 | |||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||
94 | |||||||||
95 | @param rRef another reference | ||||||||
96 | */ | ||||||||
97 | template< class derived_type > | ||||||||
98 | inline Reference( | ||||||||
99 | const Reference< derived_type > & rRef, | ||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||
101 | : m_pBody (rRef.get()) | ||||||||
102 | { | ||||||||
103 | if (m_pBody) | ||||||||
104 | m_pBody->acquire(); | ||||||||
105 | } | ||||||||
106 | #endif | ||||||||
107 | |||||||||
108 | /** Destructor... | ||||||||
109 | */ | ||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||
111 | { | ||||||||
112 | if (m_pBody
| ||||||||
113 | m_pBody->release(); | ||||||||
114 | } | ||||||||
115 | |||||||||
116 | /** Set... | ||||||||
117 | Similar to assignment. | ||||||||
118 | */ | ||||||||
119 | Reference<reference_type> & | ||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||
121 | { | ||||||||
122 | if (pBody) | ||||||||
123 | pBody->acquire(); | ||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||
125 | m_pBody = pBody; | ||||||||
126 | if (pOld) | ||||||||
127 | pOld->release(); | ||||||||
128 | return *this; | ||||||||
129 | } | ||||||||
130 | |||||||||
131 | /** Assignment. | ||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||
133 | bind it to the body represented by the handle. | ||||||||
134 | */ | ||||||||
135 | Reference<reference_type> & | ||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||
137 | { | ||||||||
138 | return set( handle.m_pBody ); | ||||||||
139 | } | ||||||||
140 | |||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
142 | /** Assignment. | ||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||
144 | * bind it to the body represented by the handle, and | ||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||
146 | */ | ||||||||
147 | Reference<reference_type> & | ||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||
149 | { | ||||||||
150 | // self-movement guts ourself | ||||||||
151 | if (m_pBody) | ||||||||
152 | m_pBody->release(); | ||||||||
153 | m_pBody = handle.m_pBody; | ||||||||
154 | handle.m_pBody = nullptr; | ||||||||
155 | return *this; | ||||||||
156 | } | ||||||||
157 | #endif | ||||||||
158 | |||||||||
159 | /** Assignment... | ||||||||
160 | */ | ||||||||
161 | Reference<reference_type> & | ||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||
163 | { | ||||||||
164 | return set( pBody ); | ||||||||
165 | } | ||||||||
166 | |||||||||
167 | /** Unbind the body from this handle. | ||||||||
168 | Note that for a handle representing a large body, | ||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||
171 | since in the second case two large objects exist in memory | ||||||||
172 | (the old body and the new body). | ||||||||
173 | */ | ||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||
175 | { | ||||||||
176 | if (m_pBody) | ||||||||
177 | { | ||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||
179 | m_pBody = NULL__null; | ||||||||
180 | pOld->release(); | ||||||||
181 | } | ||||||||
182 | return *this; | ||||||||
183 | } | ||||||||
184 | |||||||||
185 | |||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||
188 | are the same. | ||||||||
189 | */ | ||||||||
190 | reference_type * SAL_CALL get() const | ||||||||
191 | { | ||||||||
192 | return m_pBody; | ||||||||
| |||||||||
193 | } | ||||||||
194 | |||||||||
195 | |||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||
197 | */ | ||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||
199 | { | ||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||
201 | return m_pBody; | ||||||||
202 | } | ||||||||
203 | |||||||||
204 | |||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||
206 | */ | ||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||
208 | { | ||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||
210 | return *m_pBody; | ||||||||
211 | } | ||||||||
212 | |||||||||
213 | |||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||
215 | */ | ||||||||
216 | bool SAL_CALL is() const | ||||||||
217 | { | ||||||||
218 | return (m_pBody != NULL__null); | ||||||||
219 | } | ||||||||
220 | |||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||
223 | */ | ||||||||
224 | explicit operator bool() const | ||||||||
225 | { | ||||||||
226 | return is(); | ||||||||
227 | } | ||||||||
228 | #endif | ||||||||
229 | |||||||||
230 | /** Returns True if this points to pBody. | ||||||||
231 | */ | ||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||
233 | { | ||||||||
234 | return (m_pBody == pBody); | ||||||||
235 | } | ||||||||
236 | |||||||||
237 | |||||||||
238 | /** Returns True if handle points to the same body. | ||||||||
239 | */ | ||||||||
240 | bool | ||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||
242 | { | ||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||
244 | } | ||||||||
245 | |||||||||
246 | |||||||||
247 | /** Needed to place References into STL collection. | ||||||||
248 | */ | ||||||||
249 | bool | ||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||
251 | { | ||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||
253 | } | ||||||||
254 | |||||||||
255 | |||||||||
256 | /** Needed to place References into STL collection. | ||||||||
257 | */ | ||||||||
258 | bool | ||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||
260 | { | ||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||
262 | } | ||||||||
263 | |||||||||
264 | |||||||||
265 | /** Needed to place References into STL collection. | ||||||||
266 | */ | ||||||||
267 | bool | ||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||
269 | { | ||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||
271 | } | ||||||||
272 | }; | ||||||||
273 | |||||||||
274 | } // namespace rtl | ||||||||
275 | |||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
277 | namespace std | ||||||||
278 | { | ||||||||
279 | |||||||||
280 | /// @cond INTERNAL | ||||||||
281 | /** | ||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||
283 | |||||||||
284 | @since LibreOffice 6.3 | ||||||||
285 | */ | ||||||||
286 | template<typename T> | ||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||
288 | { | ||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||
290 | { return std::size_t(s.get()); } | ||||||||
291 | }; | ||||||||
292 | /// @endcond | ||||||||
293 | |||||||||
294 | } | ||||||||
295 | |||||||||
296 | #endif | ||||||||
297 | |||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||
299 | |||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |