Line data Source code
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 <vcl/msgbox.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 "view.hxx"
35 : #include <sfx2/viewfrm.hxx>
36 :
37 : #include <svx/svxdlg.hxx>
38 :
39 : #include <doc.hxx>
40 :
41 : using ::com::sun::star::uno::Reference;
42 : using ::com::sun::star::frame::XFrame;
43 :
44 0 : SfxEventNamesItem SwMacroAssignDlg::AddEvents( DlgEventType eType )
45 : {
46 0 : SfxEventNamesItem aItem(SID_EVENTCONFIG);
47 :
48 0 : sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
49 0 : bool bHtmlMode = nHtmlMode & HTMLMODE_ON;
50 :
51 0 : switch( eType )
52 : {
53 : case MACASSGN_AUTOTEXT:
54 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_START_INS_GLOSSARY) ), OUString(),
55 0 : SW_EVENT_START_INS_GLOSSARY );
56 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_END_INS_GLOSSARY) ), OUString(),
57 0 : SW_EVENT_END_INS_GLOSSARY);
58 : // in order for the new handler to become active!
59 0 : break;
60 : case MACASSGN_ALLFRM:
61 : case MACASSGN_GRAPHIC: // graphics
62 : {
63 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_IMAGE_ERROR) ), OUString(),
64 0 : SVX_EVENT_IMAGE_ERROR);
65 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_IMAGE_ABORT) ), OUString(),
66 0 : SVX_EVENT_IMAGE_ABORT);
67 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_IMAGE_LOAD) ), OUString(),
68 0 : SVX_EVENT_IMAGE_LOAD);
69 : }
70 : // no break;
71 : case MACASSGN_FRMURL: // Frm - URL-Attributes
72 : {
73 0 : if( !bHtmlMode &&
74 0 : (MACASSGN_FRMURL == eType || MACASSGN_ALLFRM == eType))
75 : {
76 : aItem.AddEvent( OUString( SW_RES( STR_EVENT_FRM_KEYINPUT_A ) ), OUString(),
77 0 : SW_EVENT_FRM_KEYINPUT_ALPHA );
78 : aItem.AddEvent( OUString( SW_RES( STR_EVENT_FRM_KEYINPUT_NOA ) ), OUString(),
79 0 : SW_EVENT_FRM_KEYINPUT_NOALPHA );
80 : aItem.AddEvent( OUString( SW_RES( STR_EVENT_FRM_RESIZE ) ), OUString(),
81 0 : SW_EVENT_FRM_RESIZE );
82 : aItem.AddEvent( OUString( SW_RES( STR_EVENT_FRM_MOVE ) ), OUString(),
83 0 : SW_EVENT_FRM_MOVE );
84 : }
85 : }
86 : // no break;
87 : case MACASSGN_OLE: // OLE
88 : {
89 0 : if( !bHtmlMode )
90 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_OBJECT_SELECT) ), OUString(),
91 0 : SW_EVENT_OBJECT_SELECT );
92 : }
93 : // no break;
94 : case MACASSGN_INETFMT: // INetFmt-Attributes
95 : {
96 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_MOUSEOVER_OBJECT) ), OUString(),
97 0 : SFX_EVENT_MOUSEOVER_OBJECT );
98 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_MOUSECLICK_OBJECT) ), OUString(),
99 0 : SFX_EVENT_MOUSECLICK_OBJECT);
100 : aItem.AddEvent( OUString( SW_RES(STR_EVENT_MOUSEOUT_OBJECT) ), OUString(),
101 0 : SFX_EVENT_MOUSEOUT_OBJECT);
102 : }
103 0 : break;
104 : }
105 :
106 0 : return aItem;
107 : }
108 :
109 0 : bool SwMacroAssignDlg::INetFmtDlg( Window* pParent, SwWrtShell& rSh,
110 : SvxMacroItem*& rpINetItem )
111 : {
112 0 : bool bRet = false;
113 0 : SfxItemSet aSet( rSh.GetAttrPool(), RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
114 0 : SvxMacroItem aItem( RES_FRMMACRO );
115 0 : if( !rpINetItem )
116 0 : rpINetItem = new SvxMacroItem( RES_FRMMACRO );
117 : else
118 0 : aItem.SetMacroTable( rpINetItem->GetMacroTable() );
119 :
120 0 : aSet.Put( aItem );
121 0 : aSet.Put( AddEvents( MACASSGN_INETFMT ) );
122 :
123 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
124 : SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( pParent, aSet,
125 0 : rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(),
126 0 : SID_EVENTCONFIG );
127 0 : if ( pMacroDlg && pMacroDlg->Execute() == RET_OK )
128 : {
129 0 : const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
130 : const SfxPoolItem* pItem;
131 0 : if( SFX_ITEM_SET == pOutSet->GetItemState( RES_FRMMACRO, false, &pItem ))
132 : {
133 0 : rpINetItem->SetMacroTable( ((SvxMacroItem*)pItem)->GetMacroTable() );
134 0 : bRet = true;
135 : }
136 : }
137 0 : return bRet;
138 0 : }
139 :
140 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|