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 <svx/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 : sal_Bool bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
50 :
51 0 : switch( eType )
52 : {
53 : case MACASSGN_AUTOTEXT:
54 : aItem.AddEvent( String( SW_RES(STR_EVENT_START_INS_GLOSSARY) ), String(),
55 0 : SW_EVENT_START_INS_GLOSSARY );
56 : aItem.AddEvent( String( SW_RES(STR_EVENT_END_INS_GLOSSARY) ), String(),
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( String( SW_RES(STR_EVENT_IMAGE_ERROR) ), String(),
64 0 : SVX_EVENT_IMAGE_ERROR);
65 : aItem.AddEvent( String( SW_RES(STR_EVENT_IMAGE_ABORT) ), String(),
66 0 : SVX_EVENT_IMAGE_ABORT);
67 : aItem.AddEvent( String( SW_RES(STR_EVENT_IMAGE_LOAD) ), String(),
68 0 : SVX_EVENT_IMAGE_LOAD);
69 : }
70 : // no break;
71 : case MACASSGN_FRMURL: // Frm - URL-Attributes
72 : {
73 0 : if( !bHtmlMode &&
74 : (MACASSGN_FRMURL == eType || MACASSGN_ALLFRM == eType))
75 : {
76 : aItem.AddEvent( String( SW_RES( STR_EVENT_FRM_KEYINPUT_A ) ), String(),
77 0 : SW_EVENT_FRM_KEYINPUT_ALPHA );
78 : aItem.AddEvent( String( SW_RES( STR_EVENT_FRM_KEYINPUT_NOA ) ), String(),
79 0 : SW_EVENT_FRM_KEYINPUT_NOALPHA );
80 : aItem.AddEvent( String( SW_RES( STR_EVENT_FRM_RESIZE ) ), String(),
81 0 : SW_EVENT_FRM_RESIZE );
82 : aItem.AddEvent( String( SW_RES( STR_EVENT_FRM_MOVE ) ), String(),
83 0 : SW_EVENT_FRM_MOVE );
84 : }
85 : }
86 : // no break;
87 : case MACASSGN_OLE: // OLE
88 : {
89 0 : if( !bHtmlMode )
90 : aItem.AddEvent( String( SW_RES(STR_EVENT_OBJECT_SELECT) ), String(),
91 0 : SW_EVENT_OBJECT_SELECT );
92 : }
93 : // no break;
94 : case MACASSGN_INETFMT: // INetFmt-Attributes
95 : {
96 : aItem.AddEvent( String( SW_RES(STR_EVENT_MOUSEOVER_OBJECT) ), String(),
97 0 : SFX_EVENT_MOUSEOVER_OBJECT );
98 : aItem.AddEvent( String( SW_RES(STR_EVENT_MOUSECLICK_OBJECT) ), String(),
99 0 : SFX_EVENT_MOUSECLICK_OBJECT);
100 : aItem.AddEvent( String( SW_RES(STR_EVENT_MOUSEOUT_OBJECT) ), String(),
101 0 : SFX_EVENT_MOUSEOUT_OBJECT);
102 : }
103 0 : break;
104 : }
105 :
106 0 : return aItem;
107 : }
108 :
109 :
110 0 : sal_Bool SwMacroAssignDlg::INetFmtDlg( Window* pParent, SwWrtShell& rSh,
111 : SvxMacroItem*& rpINetItem )
112 : {
113 0 : sal_Bool bRet = sal_False;
114 0 : SfxItemSet aSet( rSh.GetAttrPool(), RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
115 0 : SvxMacroItem aItem( RES_FRMMACRO );
116 0 : if( !rpINetItem )
117 0 : rpINetItem = new SvxMacroItem( RES_FRMMACRO );
118 : else
119 0 : aItem.SetMacroTable( rpINetItem->GetMacroTable() );
120 :
121 0 : aSet.Put( aItem );
122 0 : aSet.Put( AddEvents( MACASSGN_INETFMT ) );
123 :
124 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
125 : SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( pParent, aSet,
126 0 : rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(),
127 0 : SID_EVENTCONFIG );
128 0 : if ( pMacroDlg && pMacroDlg->Execute() == RET_OK )
129 : {
130 0 : const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
131 : const SfxPoolItem* pItem;
132 0 : if( SFX_ITEM_SET == pOutSet->GetItemState( RES_FRMMACRO, sal_False, &pItem ))
133 : {
134 0 : rpINetItem->SetMacroTable( ((SvxMacroItem*)pItem)->GetMacroTable() );
135 0 : bRet = sal_True;
136 : }
137 : }
138 0 : return bRet;
139 0 : }
140 :
141 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|