LibreOffice Module sw (master) 1
macassgn.cxx
Go to the documentation of this file.
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 <hintids.hxx>
21
22#include <sfx2/htmlmode.hxx>
23#include <svx/svxids.hrc>
24#include <svl/macitem.hxx>
25
26#include <swtypes.hxx>
27#include <wrtsh.hxx>
28#include <viewopt.hxx>
29#include <macassgn.hxx>
30#include <docsh.hxx>
31#include <strings.hrc>
32#include <view.hxx>
33#include <sfx2/viewfrm.hxx>
34
35#include <svx/svxdlg.hxx>
36
37
39{
40 SfxEventNamesItem aItem(SID_EVENTCONFIG);
41
42 sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
43 bool bHtmlMode = nHtmlMode & HTMLMODE_ON;
44
45 switch( eType )
46 {
48 aItem.AddEvent( SwResId(STR_EVENT_START_INS_GLOSSARY), OUString(),
49 SvMacroItemId::SwStartInsGlossary );
50 aItem.AddEvent( SwResId(STR_EVENT_END_INS_GLOSSARY), OUString(),
51 SvMacroItemId::SwEndInsGlossary);
52 // in order for the new handler to become active!
53 break;
54 case MACASSGN_ALLFRM:
55 case MACASSGN_GRAPHIC: // graphics
56 {
57 aItem.AddEvent( SwResId(STR_EVENT_IMAGE_ERROR), OUString(),
58 SvMacroItemId::OnImageLoadError);
59 aItem.AddEvent( SwResId(STR_EVENT_IMAGE_ABORT), OUString(),
60 SvMacroItemId::OnImageLoadCancel);
61 aItem.AddEvent( SwResId(STR_EVENT_IMAGE_LOAD), OUString(),
62 SvMacroItemId::OnImageLoadDone);
63 }
64 [[fallthrough]];
65 case MACASSGN_FRMURL: // Frame - URL-Attributes
66 {
67 if( !bHtmlMode &&
69 {
70 aItem.AddEvent( SwResId( STR_EVENT_FRM_KEYINPUT_A ), OUString(),
71 SvMacroItemId::SwFrmKeyInputAlpha );
72 aItem.AddEvent( SwResId( STR_EVENT_FRM_KEYINPUT_NOA ), OUString(),
73 SvMacroItemId::SwFrmKeyInputNoAlpha );
74 aItem.AddEvent( SwResId( STR_EVENT_FRM_RESIZE ), OUString(),
75 SvMacroItemId::SwFrmResize );
76 aItem.AddEvent( SwResId( STR_EVENT_FRM_MOVE ), OUString(),
77 SvMacroItemId::SwFrmMove );
78 }
79 }
80 [[fallthrough]];
81 case MACASSGN_OLE: // OLE
82 {
83 if( !bHtmlMode )
84 aItem.AddEvent( SwResId(STR_EVENT_OBJECT_SELECT), OUString(),
85 SvMacroItemId::SwObjectSelect );
86 }
87 [[fallthrough]];
88 case MACASSGN_INETFMT: // INetFormat-Attributes
89 {
90 aItem.AddEvent( SwResId(STR_EVENT_MOUSEOVER_OBJECT), OUString(),
91 SvMacroItemId::OnMouseOver );
92 aItem.AddEvent( SwResId(STR_EVENT_MOUSECLICK_OBJECT), OUString(),
93 SvMacroItemId::OnClick);
94 aItem.AddEvent( SwResId(STR_EVENT_MOUSEOUT_OBJECT), OUString(),
95 SvMacroItemId::OnMouseOut);
96 }
97 break;
98 }
99
100 return aItem;
101}
102
104 std::optional<SvxMacroTableDtor>& rpINetItem )
105{
106 bool bRet = false;
108 SvxMacroItem aItem( RES_FRMMACRO );
109 if( !rpINetItem )
110 rpINetItem.emplace();
111 else
112 aItem.SetMacroTable( *rpINetItem );
113
114 aSet.Put( aItem );
115 aSet.Put( AddEvents( MACASSGN_INETFMT ) );
116
118 ScopedVclPtr<SfxAbstractDialog> pMacroDlg( pFact->CreateEventConfigDialog(pParent, aSet,
120 if ( pMacroDlg && pMacroDlg->Execute() == RET_OK )
121 {
122 const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
123 if( const SvxMacroItem* pItem = pOutSet->GetItemIfSet( RES_FRMMACRO, false ))
124 {
125 rpINetItem.emplace(pItem->GetMacroTable());
126 bRet = true;
127 }
128 }
129 return bRet;
130}
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddEvent(const OUString &, const OUString &, SvMacroItemId)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
SfxFrame & GetFrame() const
SfxViewFrame * GetViewFrame() const
virtual VclPtr< SfxAbstractDialog > CreateEventConfigDialog(weld::Widget *pParent, const SfxItemSet &rAttr, const css::uno::Reference< css::frame::XFrame > &rFrame)=0
static SvxAbstractDialogFactory * Create()
void SetMacroTable(const SvxMacroTableDtor &rTbl)
static SfxEventNamesItem AddEvents(DlgEventType eType)
Definition: macassgn.cxx:38
static bool INetFormatDlg(weld::Window *pParent, SwWrtShell &rSh, std::optional< SvxMacroTableDtor > &rpINetItem)
Definition: macassgn.cxx:103
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:625
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
const SwView & GetView() const
Definition: wrtsh.hxx:443
DocumentType eType
constexpr TypedWhichId< SvxMacroItem > RES_FRMMACRO(108)
HTMLMODE_ON
DlgEventType
Definition: macassgn.hxx:30
@ MACASSGN_GRAPHIC
Definition: macassgn.hxx:32
@ MACASSGN_AUTOTEXT
Definition: macassgn.hxx:31
@ MACASSGN_FRMURL
Definition: macassgn.hxx:34
@ MACASSGN_INETFMT
Definition: macassgn.hxx:35
@ MACASSGN_ALLFRM
Definition: macassgn.hxx:36
@ MACASSGN_OLE
Definition: macassgn.hxx:33
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168
RET_OK
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:332