LibreOffice Module sd (master) 1
fuexecuteinteraction.cxx
Go to the documentation of this file.
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
21
22#include <app.hrc>
23#include <config_features.h>
25#include <basic/sbstar.hxx>
26#include <sfx2/app.hxx>
27#include <sfx2/bindings.hxx>
28#include <sfx2/dispatch.hxx>
29#include <sfx2/docfile.hxx>
30#include <sfx2/sfxsids.hrc>
31#include <sfx2/viewfrm.hxx>
32#include <svl/intitem.hxx>
33#include <svl/stritem.hxx>
34#include <svl/urihelper.hxx>
35#include <tools/urlobj.hxx>
36#include <o3tl/string_view.hxx>
37
38#include <DrawViewShell.hxx>
39#include <GraphicDocShell.hxx>
40#include <ViewShell.hxx>
41#include <anminfo.hxx>
42#include <drawdoc.hxx>
43#include <drawview.hxx>
44#include <pgjump.hxx>
45
46#include <com/sun/star/media/XPlayer.hpp>
47
48using namespace css;
49
50namespace sd
51{
53 ::sd::View* pView, SdDrawDocument* pDoc,
54 SfxRequest& rReq)
55 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
56{
57}
58
60 ::sd::View* pView, SdDrawDocument* pDoc,
61 SfxRequest& rReq)
62{
63 rtl::Reference<FuPoor> xFunc(new FuExecuteInteraction(pViewSh, pWin, pView, pDoc, rReq));
64 xFunc->DoExecute(rReq);
65 return xFunc;
66}
67
69{
70 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
71
72 if (rMarkList.GetMarkCount() != 1)
73 return;
74
75 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
76
77 if (dynamic_cast<const GraphicDocShell*>(mpDocSh) != nullptr
78 || dynamic_cast<const DrawView*>(mpView) == nullptr)
79 return;
80
82 if (!pInfo)
83 return;
84
85 switch (pInfo->meClickAction)
86 {
87 case presentation::ClickAction_BOOKMARK:
88 {
89 // Jump to Bookmark (Page or Object)
90 SfxStringItem aItem(SID_NAVIGATOR_OBJECT, pInfo->GetBookmark());
92 SID_NAVIGATOR_OBJECT, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
93 }
94 break;
95
96 case presentation::ClickAction_DOCUMENT:
97 {
98 OUString sBookmark(pInfo->GetBookmark());
99 // Jump to document
100 if (!sBookmark.isEmpty())
101 {
102 SfxStringItem aReferer(SID_REFERER, mpDocSh->GetMedium()->GetName());
103 SfxStringItem aStrItem(SID_FILE_NAME, sBookmark);
105 SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
106 SfxBoolItem aBrowseItem(SID_BROWSE, true);
107 pFrame->GetDispatcher()->ExecuteList(
108 SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
109 { &aStrItem, &aFrameItem, &aBrowseItem, &aReferer });
110 }
111 }
112 break;
113
114 case presentation::ClickAction_PREVPAGE:
115 {
116 // Jump to the previous page
117 SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_PREVIOUS);
119 SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
120 }
121 break;
122
123 case presentation::ClickAction_NEXTPAGE:
124 {
125 // Jump to the next page
126 SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_NEXT);
128 SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
129 }
130 break;
131
132 case presentation::ClickAction_FIRSTPAGE:
133 {
134 // Jump to the first page
135 SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_FIRST);
137 SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
138 }
139 break;
140
141 case presentation::ClickAction_LASTPAGE:
142 {
143 // Jump to the last page
144 SfxUInt16Item aItem(SID_NAVIGATOR_PAGE, PAGE_LAST);
146 SID_NAVIGATOR_PAGE, SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
147 }
148 break;
149
150 case presentation::ClickAction_SOUND:
151 {
152#if HAVE_FEATURE_AVMEDIA
153 try
154 {
155 mxPlayer.set(avmedia::MediaWindow::createPlayer(pInfo->GetBookmark(), "" /*TODO?*/),
156 uno::UNO_SET_THROW);
157 mxPlayer->start();
158 }
159 catch (uno::Exception&)
160 {
161 }
162#endif
163 }
164 break;
165
166 case presentation::ClickAction_VERB:
167 {
168 // Assign verb
169 mpView->UnmarkAll();
171 DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>(mpViewShell);
172 pDrViewSh->DoVerb(static_cast<sal_Int16>(pInfo->mnVerb));
173 }
174 break;
175
176 case presentation::ClickAction_PROGRAM:
177 {
178 OUString aBaseURL = GetDocSh()->GetMedium()->GetBaseURL();
179 INetURLObject aURL(::URIHelper::SmartRel2Abs(
180 INetURLObject(aBaseURL), pInfo->GetBookmark(), URIHelper::GetMaybeFileHdl(), true,
183
184 if (INetProtocol::File == aURL.GetProtocol())
185 {
186 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
187 {
188 SfxStringItem aUrl(SID_FILE_NAME,
190 SfxBoolItem aBrowsing(SID_BROWSE, true);
191
192 pViewFrm->GetDispatcher()->ExecuteList(
193 SID_OPENDOC, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
194 { &aUrl, &aBrowsing });
195 }
196 }
197 }
198 break;
199
200#if HAVE_FEATURE_SCRIPTING
201 case presentation::ClickAction_MACRO:
202 {
203 // Execute macro
204 OUString aMacro = pInfo->GetBookmark();
205
207 {
208 uno::Any aRet;
209 uno::Sequence<sal_Int16> aOutArgsIndex;
210 uno::Sequence<uno::Any> aParams;
211 uno::Sequence<uno::Any> aOutArgs;
212
213 mpDocSh->CallXScript(aMacro, aParams, aRet, aOutArgsIndex, aOutArgs);
214 }
215 else
216 {
217 // aMacro has got following format:
218 // "Macroname.Modulname.Libname.Documentname" or
219 // "Macroname.Modulname.Libname.Applicationname"
220 sal_Int32 nIdx{ 0 };
221 const std::u16string_view aMacroName = o3tl::getToken(aMacro, 0, '.', nIdx);
222 const std::u16string_view aModulName = o3tl::getToken(aMacro, 0, '.', nIdx);
223
224 // Currently the "Call" method only resolves modulename+macroname
225 mpDocSh->GetBasic()->Call(OUString::Concat(aModulName) + "." + aMacroName);
226 }
227 }
228 break;
229#endif
230
231 default:
232 break;
233 }
234}
235
236} // end of namespace sd
237
238/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::presentation::ClickAction meClickAction
Action at mouse click.
Definition: anminfo.hxx:48
sal_uInt16 mnVerb
for OLE object
Definition: anminfo.hxx:54
OUString GetBookmark() const
Definition: anminfo.cxx:110
static SAL_DLLPRIVATE SdAnimationInfo * GetAnimationInfo(SdrObject *pObject)
deprecated
Definition: drawdoc2.cxx:950
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
SdrObject * GetMarkedSdrObj() const
SdrPageView * GetSdrPageView() const
void UnmarkAll()
static bool IsXScriptURL(const OUString &rScriptURL)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
OUString GetBaseURL(bool bForSaving=false)
const OUString & GetName() const
ErrCode CallXScript(const OUString &rScriptURL, const css::uno::Sequence< css::uno::Any > &aParams, css::uno::Any &aRet, css::uno::Sequence< sal_Int16 > &aOutParamIndex, css::uno::Sequence< css::uno::Any > &aOutParam, bool bRaiseError=true, const css::uno::Any *aCaller=nullptr)
SfxMedium * GetMedium() const
StarBASIC * GetBasic() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxDispatcher * GetDispatcher()
virtual bool Call(const OUString &, SbxArray *=nullptr) override
static css::uno::Reference< css::media::XPlayer > createPlayer(const OUString &rURL, const OUString &rReferer, const OUString *pMimeType=nullptr)
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
virtual ErrCode DoVerb(sal_Int32 nVerb) override
Apply "Verb" on OLE-object.
Definition: drviews1.cxx:730
Derivative of sd::View; contains also a pointer to the document.
Definition: drawview.hxx:35
virtual void DoExecute(SfxRequest &rReq) override
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
FuExecuteInteraction(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
css::uno::Reference< css::media::XPlayer > mxPlayer
Base class for all functions.
Definition: fupoor.hxx:48
DrawDocShell * GetDocSh()
Definition: fupoor.hxx:60
ViewShell * mpViewShell
Definition: fupoor.hxx:145
DrawDocShell * mpDocSh
Definition: fupoor.hxx:147
::sd::View * mpView
Definition: fupoor.hxx:144
document shell for draw documents
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
URL aURL
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
@ PAGE_NEXT
Definition: pgjump.hxx:27
@ PAGE_FIRST
Definition: pgjump.hxx:25
@ PAGE_LAST
Definition: pgjump.hxx:28
@ PAGE_PREVIOUS
Definition: pgjump.hxx:26