xref: /trunk/main/sw/source/ui/dialog/macassgn.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #ifdef SW_DLLIMPLEMENTATION
32 #undef SW_DLLIMPLEMENTATION
33 #endif
34 
35 
36 #include "hintids.hxx"
37 
38 #define _SVSTDARR_STRINGSDTOR
39 #include <svl/svstdarr.hxx>
40 #include <svx/htmlmode.hxx>
41 #ifndef _SVX_SVXIDS_HRC //autogen
42 #include <svx/svxids.hrc>
43 #endif
44 #include <sfx2/app.hxx>
45 #include <vcl/msgbox.hxx>
46 
47 #include "swtypes.hxx"
48 #include "wrtsh.hxx"
49 #include "viewopt.hxx"
50 #include "macassgn.hxx"
51 #include "swevent.hxx"
52 #include "docsh.hxx"
53 #include "globals.hrc"
54 #include "view.hxx"
55 #include <sfx2/viewfrm.hxx>
56 
57 #include <svx/svxdlg.hxx>
58 
59 #include <doc.hxx>
60 
61 using ::com::sun::star::uno::Reference;
62 using ::com::sun::star::frame::XFrame;
63 
64 SfxEventNamesItem SwMacroAssignDlg::AddEvents( DlgEventType eType )
65 {
66 	// const SfxItemSet& rSet = rPg.GetItemSet();
67 	SfxEventNamesItem aItem(SID_EVENTCONFIG);
68 
69 	sal_Bool bHtmlMode = sal_False;
70 	sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
71 	bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
72 
73 	switch( eType )
74 	{
75 	case MACASSGN_TEXTBAUST:			// Textbausteine
76 		// rPg.SetGetRangeLink( &_GetRangeHdl );
77 		aItem.AddEvent( String( SW_RES(STR_EVENT_START_INS_GLOSSARY) ), String(),
78 							SW_EVENT_START_INS_GLOSSARY );
79 		aItem.AddEvent( String( SW_RES(STR_EVENT_END_INS_GLOSSARY) ), String(),
80 							SW_EVENT_END_INS_GLOSSARY);
81 		// damit der neue Handler aktiv wird!
82 		// rPg.Reset( rSet );
83 		break;
84 	case MACASSGN_ALLFRM:
85 	case MACASSGN_GRAPHIC:			// Grafiken
86 		{
87 			aItem.AddEvent( String( SW_RES(STR_EVENT_IMAGE_ERROR) ), String(),
88 								SVX_EVENT_IMAGE_ERROR);
89 			aItem.AddEvent( String( SW_RES(STR_EVENT_IMAGE_ABORT) ), String(),
90 								SVX_EVENT_IMAGE_ABORT);
91 			aItem.AddEvent( String( SW_RES(STR_EVENT_IMAGE_LOAD) ), String(),
92 								SVX_EVENT_IMAGE_LOAD);
93 		}
94 		// kein break;
95 	case MACASSGN_FRMURL:			// Frm - URL-Attribute
96 		{
97 			if( !bHtmlMode &&
98 				(MACASSGN_FRMURL == eType || MACASSGN_ALLFRM == eType))
99 			{
100 				aItem.AddEvent( String( SW_RES( STR_EVENT_FRM_KEYINPUT_A ) ), String(),
101 								SW_EVENT_FRM_KEYINPUT_ALPHA );
102 				aItem.AddEvent( String( SW_RES( STR_EVENT_FRM_KEYINPUT_NOA ) ), String(),
103 								SW_EVENT_FRM_KEYINPUT_NOALPHA );
104 				aItem.AddEvent( String( SW_RES( STR_EVENT_FRM_RESIZE ) ), String(),
105 								SW_EVENT_FRM_RESIZE );
106 				aItem.AddEvent( String( SW_RES( STR_EVENT_FRM_MOVE ) ), String(),
107 								SW_EVENT_FRM_MOVE );
108 			}
109 		}
110 		// kein break;
111 	case MACASSGN_OLE:				// OLE
112 		{
113 			if( !bHtmlMode )
114 				aItem.AddEvent( String( SW_RES(STR_EVENT_OBJECT_SELECT) ), String(),
115 								SW_EVENT_OBJECT_SELECT );
116 		}
117 		// kein break;
118 	case MACASSGN_INETFMT:			// INetFmt-Attribute
119 		{
120 			aItem.AddEvent( String( SW_RES(STR_EVENT_MOUSEOVER_OBJECT) ), String(),
121 								SFX_EVENT_MOUSEOVER_OBJECT );
122 			aItem.AddEvent( String( SW_RES(STR_EVENT_MOUSECLICK_OBJECT) ), String(),
123 								SFX_EVENT_MOUSECLICK_OBJECT);
124 			aItem.AddEvent( String( SW_RES(STR_EVENT_MOUSEOUT_OBJECT) ), String(),
125 								SFX_EVENT_MOUSEOUT_OBJECT);
126 		}
127 		break;
128 	}
129 
130 	return aItem;
131 }
132 
133 
134 sal_Bool SwMacroAssignDlg::INetFmtDlg( Window* pParent, SwWrtShell& rSh,
135 									SvxMacroItem*& rpINetItem )
136 {
137 	sal_Bool bRet = sal_False;
138 	SfxItemSet aSet( rSh.GetAttrPool(), RES_FRMMACRO, RES_FRMMACRO, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
139     SvxMacroItem aItem( RES_FRMMACRO );
140 	if( !rpINetItem )
141         rpINetItem = new SvxMacroItem( RES_FRMMACRO );
142 	else
143 		aItem.SetMacroTable( rpINetItem->GetMacroTable() );
144 
145 	aSet.Put( aItem );
146 	aSet.Put( AddEvents( MACASSGN_INETFMT ) );
147 
148 	SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
149 	SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( pParent, aSet,
150 		rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(),
151 		SID_EVENTCONFIG );
152 	if ( pMacroDlg && pMacroDlg->Execute() == RET_OK )
153 	{
154 		const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
155 		const SfxPoolItem* pItem;
156 		if( SFX_ITEM_SET == pOutSet->GetItemState( RES_FRMMACRO, sal_False, &pItem ))
157 		{
158 			rpINetItem->SetMacroTable( ((SvxMacroItem*)pItem)->GetMacroTable() );
159 			bRet = sal_True;
160 		}
161 	}
162 	return bRet;
163 }
164