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