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 <sfx2/app.hxx>
25 #include <svl/macitem.hxx>
26 
27 #include <swtypes.hxx>
28 #include <wrtsh.hxx>
29 #include <viewopt.hxx>
30 #include <macassgn.hxx>
31 #include <swevent.hxx>
32 #include <docsh.hxx>
33 #include <globals.hrc>
34 #include <strings.hrc>
35 #include <view.hxx>
36 #include <sfx2/viewfrm.hxx>
37 
38 #include <svx/svxdlg.hxx>
39 
40 #include <doc.hxx>
41 
42 
44 {
45  SfxEventNamesItem aItem(SID_EVENTCONFIG);
46 
47  sal_uInt16 nHtmlMode = ::GetHtmlMode(static_cast<const SwDocShell*>(SfxObjectShell::Current()));
48  bool bHtmlMode = nHtmlMode & HTMLMODE_ON;
49 
50  switch( eType )
51  {
52  case MACASSGN_AUTOTEXT:
53  aItem.AddEvent( SwResId(STR_EVENT_START_INS_GLOSSARY), OUString(),
54  SvMacroItemId::SwStartInsGlossary );
55  aItem.AddEvent( SwResId(STR_EVENT_END_INS_GLOSSARY), OUString(),
56  SvMacroItemId::SwEndInsGlossary);
57  // in order for the new handler to become active!
58  break;
59  case MACASSGN_ALLFRM:
60  case MACASSGN_GRAPHIC: // graphics
61  {
62  aItem.AddEvent( SwResId(STR_EVENT_IMAGE_ERROR), OUString(),
63  SvMacroItemId::OnImageLoadError);
64  aItem.AddEvent( SwResId(STR_EVENT_IMAGE_ABORT), OUString(),
65  SvMacroItemId::OnImageLoadCancel);
66  aItem.AddEvent( SwResId(STR_EVENT_IMAGE_LOAD), OUString(),
67  SvMacroItemId::OnImageLoadDone);
68  }
69  [[fallthrough]];
70  case MACASSGN_FRMURL: // Frame - URL-Attributes
71  {
72  if( !bHtmlMode &&
73  (MACASSGN_FRMURL == eType || MACASSGN_ALLFRM == eType))
74  {
75  aItem.AddEvent( SwResId( STR_EVENT_FRM_KEYINPUT_A ), OUString(),
76  SvMacroItemId::SwFrmKeyInputAlpha );
77  aItem.AddEvent( SwResId( STR_EVENT_FRM_KEYINPUT_NOA ), OUString(),
78  SvMacroItemId::SwFrmKeyInputNoAlpha );
79  aItem.AddEvent( SwResId( STR_EVENT_FRM_RESIZE ), OUString(),
80  SvMacroItemId::SwFrmResize );
81  aItem.AddEvent( SwResId( STR_EVENT_FRM_MOVE ), OUString(),
82  SvMacroItemId::SwFrmMove );
83  }
84  }
85  [[fallthrough]];
86  case MACASSGN_OLE: // OLE
87  {
88  if( !bHtmlMode )
89  aItem.AddEvent( SwResId(STR_EVENT_OBJECT_SELECT), OUString(),
90  SvMacroItemId::SwObjectSelect );
91  }
92  [[fallthrough]];
93  case MACASSGN_INETFMT: // INetFormat-Attributes
94  {
95  aItem.AddEvent( SwResId(STR_EVENT_MOUSEOVER_OBJECT), OUString(),
96  SvMacroItemId::OnMouseOver );
97  aItem.AddEvent( SwResId(STR_EVENT_MOUSECLICK_OBJECT), OUString(),
98  SvMacroItemId::OnClick);
99  aItem.AddEvent( SwResId(STR_EVENT_MOUSEOUT_OBJECT), OUString(),
100  SvMacroItemId::OnMouseOut);
101  }
102  break;
103  }
104 
105  return aItem;
106 }
107 
109  std::unique_ptr<SvxMacroItem>& rpINetItem )
110 {
111  bool bRet = false;
113  SvxMacroItem aItem( RES_FRMMACRO );
114  if( !rpINetItem )
115  rpINetItem.reset(new SvxMacroItem( RES_FRMMACRO ));
116  else
117  aItem.SetMacroTable( rpINetItem->GetMacroTable() );
118 
119  aSet.Put( aItem );
120  aSet.Put( AddEvents( MACASSGN_INETFMT ) );
121 
123  ScopedVclPtr<SfxAbstractDialog> pMacroDlg( pFact->CreateEventConfigDialog(pParent, aSet,
125  if ( pMacroDlg && pMacroDlg->Execute() == RET_OK )
126  {
127  const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
128  const SfxPoolItem* pItem;
129  if( SfxItemState::SET == pOutSet->GetItemState( RES_FRMMACRO, false, &pItem ))
130  {
131  rpINetItem->SetMacroTable( static_cast<const SvxMacroItem*>(pItem)->GetMacroTable() );
132  bRet = true;
133  }
134  }
135  return bRet;
136 }
137 
138 /* 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:43
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:614
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
HTMLMODE_ON
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:340
OUString SwResId(const char *pId)
Definition: swmodule.cxx:190
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:108
RET_OK
#define RES_FRMMACRO
Definition: hintids.hxx:215