1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <fuexecuteinteraction.hxx>
#include <app.hrc>
#include <config_features.h>
#include <avmedia/mediawindow.hxx>
#include <basic/sbstar.hxx>
#include <sfx2/app.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/sfxsids.hrc>
#include <sfx2/viewfrm.hxx>
#include <svl/intitem.hxx>
#include <svl/stritem.hxx>
#include <svl/urihelper.hxx>
#include <tools/urlobj.hxx>
#include <o3tl/string_view.hxx>
#include <DrawViewShell.hxx>
#include <GraphicDocShell.hxx>
#include <ViewShell.hxx>
#include <anminfo.hxx>
#include <drawdoc.hxx>
#include <drawview.hxx>
#include <pgjump.hxx>
#include <com/sun/star/media/XPlayer.hpp>
using namespace css;
namespace sd
{
FuExecuteInteraction::FuExecuteInteraction(ViewShell* pViewSh, ::sd::Window* pWin,
::sd::View* pView, SdDrawDocument* pDoc,
SfxRequest& rReq)
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{
}
rtl::Reference<FuPoor> FuExecuteInteraction::Create(ViewShell* pViewSh, ::sd::Window* pWin,
::sd::View* pView, SdDrawDocument* pDoc,
SfxRequest& rReq)
{
rtl::Reference<FuPoor> xFunc(new FuExecuteInteraction(pViewSh, pWin, pView, pDoc, rReq));
xFunc->DoExecute(rReq);
return xFunc;
}
void FuExecuteInteraction::DoExecute(SfxRequest&)
{
const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
if (rMarkList.GetMarkCount() != 1)
return;
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
if (dynamic_cast<const GraphicDocShell*>(mpDocSh) != nullptr
|| dynamic_cast<const DrawView*>(mpView) == nullptr)
return;
assert(mpDocSh);
SdAnimationInfo* pInfo = SdDrawDocument::GetAnimationInfo(pObj);
if (!pInfo)
return;
switch (pInfo->meClickAction)
{
case presentation::ClickAction_BOOKMARK:
{
// Jump to Bookmark (Page or Object)
SfxStringItem aItem(SID_NAVIGATOR_OBJECT, pInfo->GetBookmark());
mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
SID_NAVIGATOR_OBJECT, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
}
break;
case presentation::ClickAction_DOCUMENT:
{
OUString sBookmark(pInfo->GetBookmark());
// Jump to document
if (!sBookmark.isEmpty())
{
SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
SfxStringItem aStrItem(SID_FILE_NAME, sBookmark);
SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
SfxBoolItem aBrowseItem(SID_BROWSE, true);
pFrame->GetDispatcher()->ExecuteList(
SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
{ &aStrItem, &aFrameItem, &aBrowseItem, &aReferer });
}
}
break;
case presentation::ClickAction_PREVPAGE:
{
// Jump to the previous page
SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_PREVIOUS);
mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
}
break;
case presentation::ClickAction_NEXTPAGE:
{
// Jump to the next page
SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_NEXT);
mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
}
break;
case presentation::ClickAction_FIRSTPAGE:
{
// Jump to the first page
SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_FIRST);
mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
}
break;
case presentation::ClickAction_LASTPAGE:
{
// Jump to the last page
SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_LAST);
mpViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
}
break;
case presentation::ClickAction_SOUND:
{
#if HAVE_FEATURE_AVMEDIA
try
{
mxPlayer.set(
avmedia::MediaWindow::createPlayer(pInfo->GetBookmark(), u""_ustr /*TODO?*/),
uno::UNO_SET_THROW);
mxPlayer->start();
}
catch (uno::Exception&)
{
}
#endif
}
break;
case presentation::ClickAction_VERB:
{
// Assign verb
mpView->UnmarkAll();
mpView->MarkObj(pObj, mpView->GetSdrPageView());
DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>(mpViewShell);
pDrViewSh->DoVerb(static_cast<sal_Int16>(pInfo->mnVerb));
}
break;
case presentation::ClickAction_PROGRAM:
{
OUString aBaseURL = GetDocSh()->GetMedium()->GetBaseURL();
INetURLObject aURL(::URIHelper::SmartRel2Abs(
INetURLObject(aBaseURL), pInfo->GetBookmark(), URIHelper::GetMaybeFileHdl(), true,
false, INetURLObject::EncodeMechanism::WasEncoded,
INetURLObject::DecodeMechanism::Unambiguous));
if (INetProtocol::File == aURL.GetProtocol())
{
if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
{
SfxStringItem aUrl(SID_FILE_NAME,
aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE));
SfxBoolItem aBrowsing(SID_BROWSE, true);
pViewFrm->GetDispatcher()->ExecuteList(
SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
{ &aUrl, &aBrowsing });
}
}
}
break;
#if HAVE_FEATURE_SCRIPTING
case presentation::ClickAction_MACRO:
{
// Execute macro
OUString aMacro = pInfo->GetBookmark();
if (SfxApplication::IsXScriptURL(aMacro))
{
uno::Any aRet;
uno::Sequence<sal_Int16> aOutArgsIndex;
uno::Sequence<uno::Any> aParams;
uno::Sequence<uno::Any> aOutArgs;
mpDocSh->CallXScript(aMacro, aParams, aRet, aOutArgsIndex, aOutArgs);
}
else
{
// aMacro has got following format:
// "Macroname.Modulname.Libname.Documentname" or
// "Macroname.Modulname.Libname.Applicationname"
sal_Int32 nIdx{ 0 };
const std::u16string_view aMacroName = o3tl::getToken(aMacro, 0, '.', nIdx);
const std::u16string_view aModulName = o3tl::getToken(aMacro, 0, '.', nIdx);
// Currently the "Call" method only resolves modulename+macroname
mpDocSh->GetBasic()->Call(OUString::Concat(aModulName) + "." + aMacroName);
}
}
break;
#endif
default:
break;
}
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|