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  {
47  case MACASSGN_AUTOTEXT:
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 &&
68  (MACASSGN_FRMURL == eType || MACASSGN_ALLFRM == eType))
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::unique_ptr<SvxMacroItem>& rpINetItem )
105 {
106  bool bRet = false;
108  SvxMacroItem aItem( RES_FRMMACRO );
109  if( !rpINetItem )
110  rpINetItem.reset(new SvxMacroItem( RES_FRMMACRO ));
111  else
112  aItem.SetMacroTable( rpINetItem->GetMacroTable() );
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  const SfxPoolItem* pItem;
124  if( SfxItemState::SET == pOutSet->GetItemState( RES_FRMMACRO, false, &pItem ))
125  {
126  rpINetItem->SetMacroTable( static_cast<const SvxMacroItem*>(pItem)->GetMacroTable() );
127  bRet = true;
128  }
129  }
130  return bRet;
131 }
132 
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
virtual const SfxItemSet * GetOutputItemSet() const =0
static SvxAbstractDialogFactory * Create()
virtual VclPtr< SfxAbstractDialog > CreateEventConfigDialog(weld::Widget *pParent, const SfxItemSet &rAttr, const css::uno::Reference< css::frame::XFrame > &rFrame)=0
static SfxObjectShell * Current()
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
const SwView & GetView() const
Definition: wrtsh.hxx:428
SfxFrame & GetFrame() const
static SfxEventNamesItem AddEvents(DlgEventType eType)
Definition: macassgn.cxx:38
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:612
void AddEvent(const OUString &, const OUString &, SvMacroItemId)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
DlgEventType
Definition: macassgn.hxx:28
constexpr TypedWhichId< SvxMacroItem > RES_FRMMACRO(108)
HTMLMODE_ON
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:345
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
static bool INetFormatDlg(weld::Window *pParent, SwWrtShell &rSh, std::unique_ptr< SvxMacroItem > &rpINetItem)
Definition: macassgn.cxx:103
RET_OK