LibreOffice Module sfx2 (master) 1
lokhelper.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
10#include <sal/config.h>
11
12#include <string_view>
13
15#include <sfx2/lokhelper.hxx>
16
17#include <com/sun/star/frame/Desktop.hpp>
18#include <com/sun/star/ui/ContextChangeEventObject.hpp>
19
21#include <o3tl/string_view.hxx>
22#include <rtl/strbuf.hxx>
23#include <vcl/lok.hxx>
24#include <vcl/svapp.hxx>
25#include <vcl/commandevent.hxx>
26#include <vcl/window.hxx>
27#include <sal/log.hxx>
28#include <sfx2/msg.hxx>
29#include <sfx2/viewsh.hxx>
30#include <sfx2/request.hxx>
31#include <sfx2/sfxsids.hrc>
32#include <sfx2/viewfrm.hxx>
33#include <LibreOfficeKit/LibreOfficeKitEnums.h>
34#include <comphelper/lok.hxx>
35#include <sfx2/msgpool.hxx>
36
37#include <boost/property_tree/json_parser.hpp>
38
39using namespace com::sun::star;
40
41namespace {
47class DisableCallbacks
48{
49public:
50 DisableCallbacks()
51 {
52 assert(m_nDisabled >= 0 && "Expected non-negative DisabledCallbacks state when disabling.");
53 ++m_nDisabled;
54 }
55
56 ~DisableCallbacks()
57 {
58 assert(m_nDisabled > 0 && "Expected positive DisabledCallbacks state when re-enabling.");
59 --m_nDisabled;
60 }
61
62 static inline bool disabled()
63 {
64 return !comphelper::LibreOfficeKit::isActive() || m_nDisabled != 0;
65 }
66
67private:
68 static int m_nDisabled;
69};
70
71int DisableCallbacks::m_nDisabled = 0;
72}
73
74namespace
75{
76LanguageTag g_defaultLanguageTag("en-US", true);
77LanguageTag g_loadLanguageTag("en-US", true); //< The language used to load.
79bool g_isDefaultTimezoneSet = false;
80OUString g_DefaultTimezone;
81}
82
84{
85 assert(docId >= ViewShellDocId(0) && "Cannot createView for invalid (negative) DocId.");
86
88 SfxRequest aRequest(rViewFrame, SID_NEWWINDOW);
89 rViewFrame.ExecView_Impl(aRequest);
90 SfxViewShell* pViewShell = SfxViewShell::Current();
91 if (pViewShell == nullptr)
92 return -1;
93
94 assert(pViewShell->GetDocId() == docId && "DocId must be already set!");
95 return static_cast<sal_Int32>(pViewShell->GetViewShellId());
96}
97
99{
100 // Assumes a single document, or at least that the
101 // current view belongs to the document on which the
102 // view will be created.
103 SfxViewShell* pViewShell = SfxViewShell::Current();
104 if (pViewShell == nullptr)
105 return -1;
106
107 return createView(pViewShell->GetViewFrame(), pViewShell->GetDocId());
108}
109
110std::unordered_map<OUString, css::uno::Reference<com::sun::star::ui::XAcceleratorConfiguration>>& SfxLokHelper::getAcceleratorConfs()
111{
113}
114
116{
117 const SfxApplication* pApp = SfxApplication::Get();
118 if (pApp == nullptr)
119 return -1;
120
121 // Find a shell with the given DocId.
122 const ViewShellDocId docId(nDocId);
123 for (const SfxViewShell* pViewShell : pApp->GetViewShells_Impl())
124 {
125 if (pViewShell->GetDocId() == docId)
126 return createView(pViewShell->GetViewFrame(), docId);
127 }
128
129 // No frame with nDocId found.
130 return -1;
131}
132
133void SfxLokHelper::setEditMode(int nMode, vcl::ITiledRenderable* pDoc)
134{
135 DisableCallbacks dc;
136 pDoc->setEditMode(nMode);
137}
138
140{
141 const SfxApplication* pApp = SfxApplication::Get();
142 if (pApp == nullptr)
143 return;
144
145 const ViewShellId nViewShellId(nId);
146 std::vector<SfxViewShell*>& rViewArr = pApp->GetViewShells_Impl();
147
148 for (SfxViewShell* pViewShell : rViewArr)
149 {
150 if (pViewShell->GetViewShellId() == nViewShellId)
151 {
152 pViewShell->SetLOKAccessibilityState(false);
153 SfxViewFrame& rViewFrame = pViewShell->GetViewFrame();
154 SfxRequest aRequest(rViewFrame, SID_CLOSEWIN);
155 rViewFrame.Exec_Impl(aRequest);
156 break;
157 }
158 }
159}
160
162{
164 if (pApp == nullptr)
165 return;
166
167 const ViewShellId nViewShellId(nId);
168 std::vector<SfxViewShell*>& rViewArr = pApp->GetViewShells_Impl();
169
170 for (const SfxViewShell* pViewShell : rViewArr)
171 {
172 if (pViewShell->GetViewShellId() == nViewShellId)
173 {
174 DisableCallbacks dc;
175
176 if (pViewShell == SfxViewShell::Current())
177 return;
178
179 // update the current LOK language and locale for the dialog tunneling
180 comphelper::LibreOfficeKit::setLanguageTag(pViewShell->GetLOKLanguageTag());
181 comphelper::LibreOfficeKit::setLocale(pViewShell->GetLOKLocale());
182
183 SfxViewFrame& rViewFrame = pViewShell->GetViewFrame();
184 rViewFrame.MakeActive_Impl(false);
185
186 // Make comphelper::dispatchCommand() find the correct frame.
187 uno::Reference<frame::XFrame> xFrame = rViewFrame.GetFrame().GetFrameInterface();
188 uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(comphelper::getProcessComponentContext());
189 xDesktop->setActiveFrame(xFrame);
190 return;
191 }
192 }
193
194}
195
197{
199 if (pApp == nullptr)
200 return nullptr;
201
202 const ViewShellId nViewShellId(nId);
203 std::vector<SfxViewShell*>& rViewArr = pApp->GetViewShells_Impl();
204 for (SfxViewShell* pViewShell : rViewArr)
205 {
206 if (pViewShell->GetViewShellId() == nViewShellId)
207 return pViewShell;
208 }
209
210 return nullptr;
211}
212
214{
215 if (!pViewShell)
216 pViewShell = SfxViewShell::Current();
217 // Still no valid view shell? Then no idea.
218 if (!pViewShell)
219 return -1;
220
221 return static_cast<sal_Int32>(pViewShell->GetViewShellId());
222}
223
224std::size_t SfxLokHelper::getViewsCount(int nDocId)
225{
226 assert(nDocId != -1 && "Cannot getViewsCount for invalid DocId -1");
227
229 if (!pApp)
230 return 0;
231
232 const ViewShellDocId nCurrentDocId(nDocId);
233 std::size_t n = 0;
234 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
235 while (pViewShell)
236 {
237 if (pViewShell->GetDocId() == nCurrentDocId)
238 n++;
239 pViewShell = SfxViewShell::GetNext(*pViewShell);
240 }
241
242 return n;
243}
244
245bool SfxLokHelper::getViewIds(int nDocId, int* pArray, size_t nSize)
246{
247 assert(nDocId != -1 && "Cannot getViewsIds for invalid DocId -1");
248
250 if (!pApp)
251 return false;
252
253 const ViewShellDocId nCurrentDocId(nDocId);
254 std::size_t n = 0;
255 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
256 while (pViewShell)
257 {
258 if (pViewShell->GetDocId() == nCurrentDocId)
259 {
260 if (n == nSize)
261 return false;
262
263 pArray[n] = static_cast<sal_Int32>(pViewShell->GetViewShellId());
264 n++;
265 }
266
267 pViewShell = SfxViewShell::GetNext(*pViewShell);
268 }
269
270 return true;
271}
272
274{
275 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
276 while (pViewShell)
277 {
278 if (pViewShell->GetViewShellId() == ViewShellId(nViewId))
279 return static_cast<int>(pViewShell->GetDocId());
280 pViewShell = SfxViewShell::GetNext(*pViewShell);
281 }
282 return -1;
283}
284
286{
287 return g_defaultLanguageTag;
288}
289
290void SfxLokHelper::setDefaultLanguage(const OUString& rBcp47LanguageTag)
291{
292 g_defaultLanguageTag = LanguageTag(rBcp47LanguageTag, true);
293}
294
295const LanguageTag& SfxLokHelper::getLoadLanguage() { return g_loadLanguageTag; }
296
297void SfxLokHelper::setLoadLanguage(const OUString& rBcp47LanguageTag)
298{
299 g_loadLanguageTag = LanguageTag(rBcp47LanguageTag, true);
300}
301
302void SfxLokHelper::setViewLanguage(int nId, const OUString& rBcp47LanguageTag)
303{
304 std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl();
305
306 for (SfxViewShell* pViewShell : rViewArr)
307 {
308 if (pViewShell->GetViewShellId() == ViewShellId(nId))
309 {
310 pViewShell->SetLOKLanguageTag(rBcp47LanguageTag);
311 return;
312 }
313 }
314}
315
316void SfxLokHelper::setAccessibilityState(int nId, bool nEnabled)
317{
318 std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl();
319
320 for (SfxViewShell* pViewShell : rViewArr)
321 {
322 if (pViewShell->GetViewShellId() == ViewShellId(nId))
323 {
324 pViewShell->SetLOKAccessibilityState(nEnabled);
325 return;
326 }
327 }
328}
329
330void SfxLokHelper::setViewLocale(int nId, const OUString& rBcp47LanguageTag)
331{
332 std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl();
333
334 for (SfxViewShell* pViewShell : rViewArr)
335 {
336 if (pViewShell->GetViewShellId() == ViewShellId(nId))
337 {
338 pViewShell->SetLOKLocale(rBcp47LanguageTag);
339 return;
340 }
341 }
342}
343
345{
346 return g_deviceFormFactor;
347}
348
349void SfxLokHelper::setDeviceFormFactor(std::u16string_view rDeviceFormFactor)
350{
351 if (rDeviceFormFactor == u"desktop")
352 g_deviceFormFactor = LOKDeviceFormFactor::DESKTOP;
353 else if (rDeviceFormFactor == u"tablet")
354 g_deviceFormFactor = LOKDeviceFormFactor::TABLET;
355 else if (rDeviceFormFactor == u"mobile")
356 g_deviceFormFactor = LOKDeviceFormFactor::MOBILE;
357 else
358 g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN;
359}
360
361void SfxLokHelper::setDefaultTimezone(bool isSet, const OUString& rTimezone)
362{
363 g_isDefaultTimezoneSet = isSet;
364 g_DefaultTimezone = rTimezone;
365}
366
367std::pair<bool, OUString> SfxLokHelper::getDefaultTimezone()
368{
369 return { g_isDefaultTimezoneSet, g_DefaultTimezone };
370}
371
372void SfxLokHelper::setViewTimezone(int nId, bool isSet, const OUString& rTimezone)
373{
374 std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl();
375
376 for (SfxViewShell* pViewShell : rViewArr)
377 {
378 if (pViewShell->GetViewShellId() == ViewShellId(nId))
379 {
380 pViewShell->SetLOKTimezone(isSet, rTimezone);
381 return;
382 }
383 }
384}
385
386std::pair<bool, OUString> SfxLokHelper::getViewTimezone(int nId)
387{
388 std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl();
389
390 for (SfxViewShell* pViewShell : rViewArr)
391 {
392 if (pViewShell->GetViewShellId() == ViewShellId(nId))
393 {
394 return pViewShell->GetLOKTimezone();
395 }
396 }
397
398 return {};
399}
400
401/*
402* Used for putting a whole JSON string into a string value
403* e.g { key: "{JSON}" }
404*/
405static OString lcl_sanitizeJSONAsValue(const OString &rStr)
406{
407 if (rStr.getLength() < 1)
408 return rStr;
409 // FIXME: need an optimized 'escape' method for O[U]String.
410 OStringBuffer aBuf(rStr.getLength() + 8);
411 for (sal_Int32 i = 0; i < rStr.getLength(); ++i)
412 {
413 if (rStr[i] == '"' || rStr[i] == '\\')
414 aBuf.append('\\');
415
416 if (rStr[i] != '\n')
417 aBuf.append(rStr[i]);
418 }
419 return aBuf.makeStringAndClear();
420}
421
422static OString lcl_generateJSON(const SfxViewShell* pView, const boost::property_tree::ptree& rTree)
423{
424 assert(pView != nullptr && "pView must be valid");
425 boost::property_tree::ptree aMessageProps = rTree;
426 aMessageProps.put("viewId", SfxLokHelper::getView(pView));
427 aMessageProps.put("part", pView->getPart());
428 aMessageProps.put("mode", pView->getEditMode());
429 std::stringstream aStream;
430 boost::property_tree::write_json(aStream, aMessageProps, false /* pretty */);
431 return OString(o3tl::trim(aStream.str()));
432}
433
434static inline OString lcl_generateJSON(const SfxViewShell* pView, int nViewId, std::string_view rKey,
435 const OString& rPayload)
436{
437 assert(pView != nullptr && "pView must be valid");
438 return OString::Concat("{ \"viewId\": \"") + OString::number(nViewId)
439 + "\", \"part\": \"" + OString::number(pView->getPart()) + "\", \"mode\": \""
440 + OString::number(pView->getEditMode()) + "\", \"" + rKey + "\": \""
441 + lcl_sanitizeJSONAsValue(rPayload) + "\" }";
442}
443
444static inline OString lcl_generateJSON(const SfxViewShell* pView, std::string_view rKey,
445 const OString& rPayload)
446{
447 return lcl_generateJSON(pView, SfxLokHelper::getView(pView), rKey, rPayload);
448}
449
450void SfxLokHelper::notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView,
451 int nType, std::string_view rKey, const OString& rPayload)
452{
453 assert(pThisView != nullptr && "pThisView must be valid");
454 if (DisableCallbacks::disabled())
455 return;
456
457 const OString aPayload = lcl_generateJSON(pThisView, rKey, rPayload);
458 const int viewId = SfxLokHelper::getView(pThisView);
459 pOtherView->libreOfficeKitViewCallbackWithViewId(nType, aPayload, viewId);
460}
461
462void SfxLokHelper::notifyOtherView(const SfxViewShell* pThisView, SfxViewShell const* pOtherView,
463 int nType, const boost::property_tree::ptree& rTree)
464{
465 assert(pThisView != nullptr && "pThisView must be valid");
466 if (DisableCallbacks::disabled())
467 return;
468
469 const int viewId = SfxLokHelper::getView(pThisView);
470 pOtherView->libreOfficeKitViewCallbackWithViewId(nType, lcl_generateJSON(pThisView, rTree), viewId);
471}
472
473void SfxLokHelper::notifyOtherViews(const SfxViewShell* pThisView, int nType, std::string_view rKey,
474 const OString& rPayload)
475{
476 assert(pThisView != nullptr && "pThisView must be valid");
477 if (DisableCallbacks::disabled())
478 return;
479
480 // Cache the payload so we only have to generate it once, at most.
481 OString aPayload;
482 int viewId = -1;
483
484 const ViewShellDocId nCurrentDocId = pThisView->GetDocId();
485 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
486 while (pViewShell)
487 {
488 if (pViewShell != pThisView && nCurrentDocId == pViewShell->GetDocId())
489 {
490 // Payload is only dependent on pThisView.
491 if (aPayload.isEmpty())
492 {
493 aPayload = lcl_generateJSON(pThisView, rKey, rPayload);
494 viewId = SfxLokHelper::getView(pThisView);
495 }
496
497 pViewShell->libreOfficeKitViewCallbackWithViewId(nType, aPayload, viewId);
498 }
499
500 pViewShell = SfxViewShell::GetNext(*pViewShell);
501 }
502}
503
504void SfxLokHelper::notifyOtherViews(const SfxViewShell* pThisView, int nType,
505 const boost::property_tree::ptree& rTree)
506{
507 assert(pThisView != nullptr && "pThisView must be valid");
508 if (DisableCallbacks::disabled())
509 return;
510
511 // Cache the payload so we only have to generate it once, at most.
512 OString aPayload;
513 int viewId = -1;
514
515 const ViewShellDocId nCurrentDocId = pThisView->GetDocId();
516 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
517 while (pViewShell)
518 {
519 if (pViewShell != pThisView && nCurrentDocId == pViewShell->GetDocId())
520 {
521 // Payload is only dependent on pThisView.
522 if (aPayload.isEmpty())
523 {
524 aPayload = lcl_generateJSON(pThisView, rTree);
525 viewId = SfxLokHelper::getView(pThisView);
526 }
527
528 pViewShell->libreOfficeKitViewCallbackWithViewId(nType, aPayload, viewId);
529 }
530
531 pViewShell = SfxViewShell::GetNext(*pViewShell);
532 }
533}
534
535OString SfxLokHelper::makePayloadJSON(const SfxViewShell* pThisView, int nViewId, std::string_view rKey, const OString& rPayload)
536{
537 return lcl_generateJSON(pThisView, nViewId, rKey, rPayload);
538}
539
540namespace {
541 OUString lcl_getNameForSlot(const SfxViewShell* pShell, sal_uInt16 nWhich)
542 {
543 if (pShell && pShell->GetFrame())
544 {
545 const SfxSlot* pSlot = SfxSlotPool::GetSlotPool(pShell->GetFrame()).GetSlot(nWhich);
546 if (pSlot)
547 {
548 if (!pSlot->GetUnoName().isEmpty())
549 {
550 return pSlot->GetCommand();
551 }
552 }
553 }
554
555 return "";
556 }
557}
558
559void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem)
560{
561 if (!pShell || !pItem || pItem == INVALID_POOL_ITEM || DisableCallbacks::disabled())
562 return;
563
564 boost::property_tree::ptree aItem = pItem->dumpAsJSON();
565
566 if (aItem.count("state"))
567 {
568 OUString sCommand = lcl_getNameForSlot(pShell, pItem->Which());
569 if (!sCommand.isEmpty())
570 aItem.put("commandName", sCommand);
571
572 std::stringstream aStream;
573 boost::property_tree::write_json(aStream, aItem);
574 pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, OString(aStream.str()));
575 }
576}
577
578void SfxLokHelper::notifyViewRenderState(const SfxViewShell* pShell, vcl::ITiledRenderable* pDoc)
579{
580 pShell->libreOfficeKitViewCallback(LOK_CALLBACK_VIEW_RENDER_STATE, pDoc->getViewRenderState());
581}
582
584 vcl::LOKWindowId nLOKWindowId,
585 std::u16string_view rAction,
586 const std::vector<vcl::LOKPayloadItem>& rPayload)
587{
588 assert(pThisView != nullptr && "pThisView must be valid");
589
590 if (nLOKWindowId == 0 || DisableCallbacks::disabled())
591 return;
592
593 OStringBuffer aPayload =
594 "{ \"id\": \"" + OString::number(nLOKWindowId) + "\""
595 ", \"action\": \"" + OUStringToOString(rAction, RTL_TEXTENCODING_UTF8) + "\"";
596
597 for (const auto& rItem: rPayload)
598 {
599 if (!rItem.first.isEmpty() && !rItem.second.isEmpty())
600 {
601 auto aFirst = rItem.first.replaceAll("\"", "\\\"");
602 auto aSecond = rItem.second.replaceAll("\"", "\\\"");
603 aPayload.append(", \"" + aFirst + "\": \"" + aSecond + "\"");
604 }
605 }
606 aPayload.append('}');
607
608 const OString s = aPayload.makeStringAndClear();
609 pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_WINDOW, s);
610}
611
613{
614 if (DisableCallbacks::disabled())
615 return;
616
617 // -1 means all parts
618 const int nPart = comphelper::LibreOfficeKit::isPartInInvalidation() ? pThisView->getPart() : INT_MIN;
619 const int nMode = pThisView->getEditMode();
620 pThisView->libreOfficeKitViewInvalidateTilesCallback(pRect, nPart, nMode);
621}
622
623void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll)
624{
625 if (!pDoc || pDoc->isDisposed() || DisableCallbacks::disabled())
626 return;
627
628 if (bInvalidateAll)
629 {
630 for (int i = 0; i < pDoc->getParts(); ++i)
631 {
632 tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
633 const int nMode = pThisView->getEditMode();
634 pThisView->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, i, nMode);
635 }
636 }
637 pThisView->libreOfficeKitViewCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, rPayload);
638}
639
640void SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, bool bInvalidateAll)
641{
642 if (DisableCallbacks::disabled())
643 return;
644
645 // FIXME: Do we know whether it is the views for the document that is in the "current" view that has changed?
646 const SfxViewShell* const pCurrentViewShell = SfxViewShell::Current();
647 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
648 while (pViewShell)
649 {
650 // FIXME: What if SfxViewShell::Current() returned null?
651 // Should we then do this for all views of all open documents
652 // or not?
653 if (pCurrentViewShell == nullptr || pViewShell->GetDocId() == pCurrentViewShell-> GetDocId())
654 {
655 SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pDoc, bInvalidateAll);
656 bInvalidateAll = false; // we direct invalidations to all views anyway.
657 }
658 pViewShell = SfxViewShell::GetNext(*pViewShell);
659 }
660}
661
662void SfxLokHelper::notifyPartSizeChangedAllViews(vcl::ITiledRenderable* pDoc, int nPart)
663{
664 if (DisableCallbacks::disabled())
665 return;
666
667 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
668 while (pViewShell)
669 {
670 if (pViewShell->getPart() == nPart)
671 SfxLokHelper::notifyDocumentSizeChanged(pViewShell, "", pDoc, false);
672 pViewShell = SfxViewShell::GetNext(*pViewShell);
673 }
674}
675
676OString SfxLokHelper::makeVisCursorInvalidation(int nViewId, const OString& rRectangle,
677 bool bMispelledWord, const OString& rHyperlink)
678{
680 {
681 OString sHyperlink = rHyperlink.isEmpty() ? "{}" : rHyperlink;
682 return OString::Concat("{ \"viewId\": \"") + OString::number(nViewId) +
683 "\", \"rectangle\": \"" + rRectangle +
684 "\", \"mispelledWord\": \"" + OString::number(bMispelledWord ? 1 : 0) +
685 "\", \"hyperlink\": " + sHyperlink + " }";
686 }
687 else
688 {
689 return rRectangle;
690 }
691}
692
693void SfxLokHelper::notifyAllViews(int nType, const OString& rPayload)
694{
695 if (DisableCallbacks::disabled())
696 return;
697
698 const auto payload = rPayload.getStr();
699 const SfxViewShell* const pCurrentViewShell = SfxViewShell::Current();
700 if (!pCurrentViewShell)
701 return;
702 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
703 while (pViewShell)
704 {
705 if (pViewShell->GetDocId() == pCurrentViewShell->GetDocId())
706 pViewShell->libreOfficeKitViewCallback(nType, payload);
707 pViewShell = SfxViewShell::GetNext(*pViewShell);
708 }
709}
710
711void SfxLokHelper::notifyContextChange(const css::ui::ContextChangeEventObject& rEvent)
712{
713 if (DisableCallbacks::disabled())
714 return;
715
716 SfxViewShell* pViewShell = SfxViewShell::Get({ rEvent.Source, css::uno::UNO_QUERY });
717 if (!pViewShell)
718 return;
719
720 OUString aBuffer =
721 rEvent.ApplicationName.replace(' ', '_') +
722 " " +
723 rEvent.ContextName.replace(' ', '_');
724 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_CHANGED, aBuffer.toUtf8());
725}
726
727void SfxLokHelper::notifyUpdate(SfxViewShell const* pThisView, int nType)
728{
729 if (DisableCallbacks::disabled())
730 return;
731
733}
734
735void SfxLokHelper::notifyUpdatePerViewId(SfxViewShell const* pThisView, int nType)
736{
737 notifyUpdatePerViewId(pThisView, pThisView, pThisView, nType);
738}
739
740void SfxLokHelper::notifyUpdatePerViewId(SfxViewShell const* pTargetShell, SfxViewShell const* pViewShell,
741 SfxViewShell const* pSourceShell, int nType)
742{
743 if (DisableCallbacks::disabled())
744 return;
745
746 int viewId = SfxLokHelper::getView(pViewShell);
747 int sourceViewId = SfxLokHelper::getView(pSourceShell);
748 pTargetShell->libreOfficeKitViewUpdatedCallbackPerViewId(nType, viewId, sourceViewId);
749}
750
752{
753 assert(pThisView != nullptr && "pThisView must be valid");
754 if (DisableCallbacks::disabled())
755 return;
756
757 int viewId = SfxLokHelper::getView(pThisView);
758 const ViewShellDocId nCurrentDocId = pThisView->GetDocId();
759 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
760 while (pViewShell)
761 {
762 if (pViewShell != pThisView && nCurrentDocId == pViewShell->GetDocId())
763 pViewShell->libreOfficeKitViewUpdatedCallbackPerViewId(nType, viewId, viewId);
764
765 pViewShell = SfxViewShell::GetNext(*pViewShell);
766 }
767}
768
769namespace
770{
771 struct LOKAsyncEventData
772 {
773 int mnView; // Window is not enough.
775 VclEventId mnEvent;
776 MouseEvent maMouseEvent;
777 KeyEvent maKeyEvent;
778 OUString maText;
779 };
780
781 void LOKPostAsyncEvent(void* pEv, void*)
782 {
783 std::unique_ptr<LOKAsyncEventData> pLOKEv(static_cast<LOKAsyncEventData*>(pEv));
784 if (pLOKEv->mpWindow->isDisposed())
785 return;
786
787 int nView = SfxLokHelper::getView(nullptr);
788 if (nView != pLOKEv->mnView)
789 {
790 SAL_INFO("sfx.view", "LOK - view mismatch " << nView << " vs. " << pLOKEv->mnView);
791 SfxLokHelper::setView(pLOKEv->mnView);
792 }
793
794 if (!pLOKEv->mpWindow->HasChildPathFocus(true))
795 {
796 SAL_INFO("sfx.view", "LOK - focus mismatch, switching focus");
797 pLOKEv->mpWindow->GrabFocus();
798 }
799
800 VclPtr<vcl::Window> pFocusWindow = pLOKEv->mpWindow->GetFocusedWindow();
801 if (!pFocusWindow)
802 pFocusWindow = pLOKEv->mpWindow;
803
804 if (pLOKEv->mpWindow->isDisposed())
805 return;
806
807 switch (pLOKEv->mnEvent)
808 {
809 case VclEventId::WindowKeyInput:
810 {
811 sal_uInt16 nRepeat = pLOKEv->maKeyEvent.GetRepeat();
812 KeyEvent singlePress(pLOKEv->maKeyEvent.GetCharCode(),
813 pLOKEv->maKeyEvent.GetKeyCode());
814 for (sal_uInt16 i = 0; i <= nRepeat; ++i)
815 if (!pFocusWindow->isDisposed())
816 pFocusWindow->KeyInput(singlePress);
817 break;
818 }
819 case VclEventId::WindowKeyUp:
820 if (!pFocusWindow->isDisposed())
821 pFocusWindow->KeyUp(pLOKEv->maKeyEvent);
822 break;
823 case VclEventId::WindowMouseButtonDown:
824 pLOKEv->mpWindow->SetLastMousePos(pLOKEv->maMouseEvent.GetPosPixel());
825 pLOKEv->mpWindow->MouseButtonDown(pLOKEv->maMouseEvent);
826 // Invoke the context menu
827 if (pLOKEv->maMouseEvent.GetButtons() & MOUSE_RIGHT)
828 {
829 const CommandEvent aCEvt(pLOKEv->maMouseEvent.GetPosPixel(), CommandEventId::ContextMenu, true, nullptr);
830 pLOKEv->mpWindow->Command(aCEvt);
831 }
832 break;
833 case VclEventId::WindowMouseButtonUp:
834 pLOKEv->mpWindow->SetLastMousePos(pLOKEv->maMouseEvent.GetPosPixel());
835 pLOKEv->mpWindow->MouseButtonUp(pLOKEv->maMouseEvent);
836
837 // sometimes MouseButtonDown captures mouse and starts tracking, and VCL
838 // will not take care of releasing that with tiled rendering
839 if (pLOKEv->mpWindow->IsTracking())
840 pLOKEv->mpWindow->EndTracking();
841
842 break;
843 case VclEventId::WindowMouseMove:
844 pLOKEv->mpWindow->SetLastMousePos(pLOKEv->maMouseEvent.GetPosPixel());
845 pLOKEv->mpWindow->MouseMove(pLOKEv->maMouseEvent);
846 break;
847 case VclEventId::ExtTextInput:
848 case VclEventId::EndExtTextInput:
849 pLOKEv->mpWindow->PostExtTextInputEvent(pLOKEv->mnEvent, pLOKEv->maText);
850 break;
851 default:
852 assert(false);
853 break;
854 }
855 }
856
857 void postEventAsync(LOKAsyncEventData *pEvent)
858 {
859 if (!pEvent->mpWindow || pEvent->mpWindow->isDisposed())
860 {
861 SAL_WARN("vcl", "Async event post - but no valid window as destination " << pEvent->mpWindow.get());
862 delete pEvent;
863 return;
864 }
865
866 pEvent->mnView = SfxLokHelper::getView(nullptr);
868 {
870 SAL_WARN("lok", "Posting event directly but not called from main thread!");
871 LOKPostAsyncEvent(pEvent, nullptr);
872 }
873 else
874 Application::PostUserEvent(Link<void*, void>(pEvent, LOKPostAsyncEvent));
875 }
876}
877
879 int nType, int nCharCode, int nKeyCode, int nRepeat)
880{
881 LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
882 switch (nType)
883 {
884 case LOK_KEYEVENT_KEYINPUT:
885 pLOKEv->mnEvent = VclEventId::WindowKeyInput;
886 break;
887 case LOK_KEYEVENT_KEYUP:
888 pLOKEv->mnEvent = VclEventId::WindowKeyUp;
889 break;
890 default:
891 assert(false);
892 }
893 pLOKEv->maKeyEvent = KeyEvent(nCharCode, nKeyCode, nRepeat);
894 pLOKEv->mpWindow = xWindow;
895 postEventAsync(pLOKEv);
896}
897
898void SfxLokHelper::setBlockedCommandList(int nViewId, const char* blockedCommandList)
899{
900 SfxViewShell* pViewShell = SfxLokHelper::getViewOfId(nViewId);
901
902 if(pViewShell)
903 {
904 pViewShell->setBlockedCommandList(blockedCommandList);
905 }
906}
907
909 int nType, const OUString &rText)
910{
911 LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
912 switch (nType)
913 {
914 case LOK_EXT_TEXTINPUT:
915 pLOKEv->mnEvent = VclEventId::ExtTextInput;
916 pLOKEv->maText = rText;
917 break;
918 case LOK_EXT_TEXTINPUT_END:
919 pLOKEv->mnEvent = VclEventId::EndExtTextInput;
920 pLOKEv->maText = "";
921 break;
922 default:
923 assert(false);
924 }
925 pLOKEv->mpWindow = xWindow;
926 postEventAsync(pLOKEv);
927}
928
929void SfxLokHelper::postMouseEventAsync(const VclPtr<vcl::Window> &xWindow, LokMouseEventData const & rLokMouseEventData)
930{
931 LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
932 switch (rLokMouseEventData.mnType)
933 {
934 case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
935 pLOKEv->mnEvent = VclEventId::WindowMouseButtonDown;
936 break;
937 case LOK_MOUSEEVENT_MOUSEBUTTONUP:
938 pLOKEv->mnEvent = VclEventId::WindowMouseButtonUp;
939 break;
940 case LOK_MOUSEEVENT_MOUSEMOVE:
941 pLOKEv->mnEvent = VclEventId::WindowMouseMove;
942 break;
943 default:
944 assert(false);
945 }
946
947 // no reason - just always true so far.
948 assert (rLokMouseEventData.meModifiers == MouseEventModifiers::SIMPLECLICK);
949
950 pLOKEv->maMouseEvent = MouseEvent(rLokMouseEventData.maPosition, rLokMouseEventData.mnCount,
951 rLokMouseEventData.meModifiers, rLokMouseEventData.mnButtons,
952 rLokMouseEventData.mnModifier);
953 if (rLokMouseEventData.maLogicPosition)
954 {
955 pLOKEv->maMouseEvent.setLogicPosition(*rLokMouseEventData.maLogicPosition);
956 }
957 pLOKEv->mpWindow = xWindow;
958 postEventAsync(pLOKEv);
959}
960
961void SfxLokHelper::dumpState(rtl::OStringBuffer &rState)
962{
964 sal_Int32 nDocId = pShell ? static_cast<sal_Int32>(pShell->GetDocId().get()) : -1;
965
966 rState.append("\n\tDocId:\t");
967 rState.append(nDocId);
968
969 if (nDocId < 0)
970 return;
971
972 rState.append("\n\tViewCount:\t");
973 rState.append(static_cast<sal_Int32>(getViewsCount(nDocId)));
974
975 const SfxViewShell* const pCurrentViewShell = SfxViewShell::Current();
976 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
977 while (pViewShell)
978 {
979 if (pCurrentViewShell == nullptr || pViewShell->GetDocId() == pCurrentViewShell-> GetDocId())
980 pViewShell->dumpLibreOfficeKitViewState(rState);
981
982 pViewShell = SfxViewShell::GetNext(*pViewShell);
983 }
984}
985
987 int nY, int nCount, int nButtons,
988 int nModifier, double fScaleX, double fScaleY,
989 bool bNegativeX)
990{
991 // In LOK RTL mode draw/svx operates in negative X coordinates
992 // But the coordinates from client is always positive, so negate nX.
993 if (bNegativeX)
994 nX = -nX;
995
996 // check if the user hit a chart/math object which is being edited by this view
997 if (LokChartHelper aChartHelper(pViewShell, bNegativeX);
998 aChartHelper.postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier, fScaleX, fScaleY))
999 return true;
1000
1001 if (LokStarMathHelper aMathHelper(pViewShell);
1002 aMathHelper.postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier, fScaleX, fScaleY))
1003 return true;
1004
1005 // check if the user hit a chart which is being edited by someone else
1006 // and, if so, skip current mouse event
1007 if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
1008 {
1009 if (LokChartHelper::HitAny({nX, nY}, bNegativeX))
1010 return true;
1011 }
1012
1013 return false;
1014}
1015
1017{
1018 if (VclPtr<vcl::Window> pWindow = LokChartHelper(pViewShell).GetWindow())
1019 return pWindow;
1020 if (VclPtr<vcl::Window> pWindow = LokStarMathHelper(pViewShell).GetWidgetWindow())
1021 return pWindow;
1022 return {};
1023}
1024
1025/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Text maText
SfxApplication * SfxGetpApp()
Definition: app.hxx:231
static bool IsMainThread()
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
A class for chart editing support via LibreOfficeKit.
static bool HitAny(const Point &aPos, bool bNegativeX=false)
bool postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, double fScaleX=1.0, double fScaleY=1.0)
A class for math editing support via LibreOfficeKit.
bool postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, double fPPTScaleX, double fPPTScaleY)
static SfxApplication * Get()
Definition: app.cxx:70
SAL_DLLPRIVATE std::vector< SfxViewShell * > & GetViewShells_Impl() const
Definition: app.cxx:365
SAL_DLLPRIVATE std::unordered_map< OUString, css::uno::Reference< css::ui::XAcceleratorConfiguration > > & GetAcceleratorConfs_Impl() const
Definition: app.cxx:370
static SfxApplication * GetOrCreate()
Definition: app.cxx:89
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
Definition: frame.cxx:515
static std::pair< bool, OUString > getViewTimezone(int nId)
Get the timezone of the given view.
Definition: lokhelper.cxx:386
static void notifyInvalidation(SfxViewShell const *pThisView, tools::Rectangle const *)
Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
Definition: lokhelper.cxx:612
static void setBlockedCommandList(int nViewId, const char *blockedCommandList)
Set View Blocked for some uno commands.
Definition: lokhelper.cxx:898
static void setView(int nId)
Set a view shell as current one.
Definition: lokhelper.cxx:161
static void notifyAllViews(int nType, const OString &rPayload)
Notifies all views with the given type and payload.
Definition: lokhelper.cxx:693
static OString makeVisCursorInvalidation(int nViewId, const OString &rRectangle, bool bMispelledWord=false, const OString &rHyperlink="")
Makes a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR payload, but tweaks it according to setOptionalFeature...
Definition: lokhelper.cxx:676
static std::size_t getViewsCount(int nDocId)
Get the number of views of the current DocId.
Definition: lokhelper.cxx:224
static void postKeyEventAsync(const VclPtr< vcl::Window > &xWindow, int nType, int nCharCode, int nKeyCode, int nRepeat=0)
Helper for posting async key event.
Definition: lokhelper.cxx:878
static LOKDeviceFormFactor getDeviceFormFactor()
Get the device form factor that should be used for a new view.
Definition: lokhelper.cxx:344
static void notifyUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
Definition: lokhelper.cxx:735
static int createView()
Create a new view shell from the current view frame.
Definition: lokhelper.cxx:98
static void notifyWindow(const SfxViewShell *pThisView, vcl::LOKWindowId nWindowId, std::u16string_view rAction, const std::vector< vcl::LOKPayloadItem > &rPayload=std::vector< vcl::LOKPayloadItem >())
Emits a LOK_CALLBACK_WINDOW.
Definition: lokhelper.cxx:583
static void notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable *pDoc, bool bInvalidateAll=true)
Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same document - if @bInvalidateAll - ...
Definition: lokhelper.cxx:640
static void setViewTimezone(int nId, bool isSet, const OUString &rTimezone)
Set the timezone of the given view.
Definition: lokhelper.cxx:372
static void notifyOtherView(const SfxViewShell *pThisView, SfxViewShell const *pOtherView, int nType, std::string_view rKey, const OString &rPayload)
Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
Definition: lokhelper.cxx:450
static void sendUnoStatus(const SfxViewShell *pShell, const SfxPoolItem *pItem)
Emits a LOK_CALLBACK_STATE_CHANGED.
Definition: lokhelper.cxx:559
static void destroyView(int nId)
Destroy a view shell from the global shell list.
Definition: lokhelper.cxx:139
static void setDefaultTimezone(bool isSet, const OUString &rTimezone)
Set timezone of the given view.
Definition: lokhelper.cxx:361
static bool testInPlaceComponentMouseEventHit(SfxViewShell *pViewShell, int nType, int nX, int nY, int nCount, int nButtons, int nModifier, double fScaleX, double fScaleY, bool bNegativeX=false)
Process the mouse event in the currently active in-place component (if any).
Definition: lokhelper.cxx:986
static void setViewLocale(int nId, const OUString &rBcp47LanguageTag)
Set the locale for the given view.
Definition: lokhelper.cxx:330
static void notifyUpdate(SfxViewShell const *pViewShell, int nType)
Definition: lokhelper.cxx:727
static void notifyPartSizeChangedAllViews(vcl::ITiledRenderable *pDoc, int nPart)
Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED for all views of the same document with the same part.
Definition: lokhelper.cxx:662
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
Invoke the LOK callback of all other views showing the same document as pThisView,...
Definition: lokhelper.cxx:473
static void setDeviceFormFactor(std::u16string_view rDeviceFormFactor)
Set the device form factor that should be used for a new view.
Definition: lokhelper.cxx:349
static bool getViewIds(int nDocId, int *pArray, size_t nSize)
Get viewIds of views of the current DocId.
Definition: lokhelper.cxx:245
static void postExtTextEventAsync(const VclPtr< vcl::Window > &xWindow, int nType, const OUString &rText)
Helper for posting input event.
Definition: lokhelper.cxx:908
static const LanguageTag & getDefaultLanguage()
Get the default language that should be used for views.
Definition: lokhelper.cxx:285
static void setDefaultLanguage(const OUString &rBcp47LanguageTag)
Set the default language for views.
Definition: lokhelper.cxx:290
static OString makePayloadJSON(const SfxViewShell *pThisView, int nViewId, std::string_view rKey, const OString &rPayload)
Definition: lokhelper.cxx:535
static VclPtr< vcl::Window > getInPlaceDocWindow(SfxViewShell *pViewShell)
Definition: lokhelper.cxx:1016
static std::unordered_map< OUString, css::uno::Reference< com::sun::star::ui::XAcceleratorConfiguration > > & getAcceleratorConfs()
Gets the short cut accelerators.
Definition: lokhelper.cxx:110
static void notifyOtherViewsUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
Definition: lokhelper.cxx:751
static void setLoadLanguage(const OUString &rBcp47LanguageTag)
Set the language used by the loading view (used for all save operations).
Definition: lokhelper.cxx:297
static std::pair< bool, OUString > getDefaultTimezone()
Get timezone of the given view. See @setDefaultTimezone.
Definition: lokhelper.cxx:367
static SfxViewShell * getViewOfId(int nId)
Get view shell with id.
Definition: lokhelper.cxx:196
static void setAccessibilityState(int nId, bool nEnabled)
Enable/Disable AT support for the given view.
Definition: lokhelper.cxx:316
static void postMouseEventAsync(const VclPtr< vcl::Window > &xWindow, LokMouseEventData const &rLokMouseEventData)
Helper for posting async mouse event.
Definition: lokhelper.cxx:929
static void notifyDocumentSizeChanged(SfxViewShell const *pThisView, const OString &rPayload, vcl::ITiledRenderable *pDoc, bool bInvalidateAll=true)
Emits a LOK_CALLBACK_DOCUMENT_SIZE_CHANGED - if @bInvalidateAll - first invalidates all parts.
Definition: lokhelper.cxx:623
static int getView(const SfxViewShell *pViewShell=nullptr)
Get the currently active view.
Definition: lokhelper.cxx:213
static void notifyViewRenderState(SfxViewShell const *pViewShell, vcl::ITiledRenderable *pDoc)
Emits an LOK_CALLBACK_VIEW_RENDER_STATE.
Definition: lokhelper.cxx:578
static const LanguageTag & getLoadLanguage()
Get the language used by the loading view (used for all save operations).
Definition: lokhelper.cxx:295
static void notifyContextChange(const css::ui::ContextChangeEventObject &rEvent)
Notify about the editing context change.
Definition: lokhelper.cxx:711
static int getDocumentIdOfView(int nViewId)
Get the document id for a view.
Definition: lokhelper.cxx:273
static void setViewLanguage(int nId, const OUString &rBcp47LanguageTag)
Set language of the given view.
Definition: lokhelper.cxx:302
static void setEditMode(int nMode, vcl::ITiledRenderable *pDoc)
Set the edit mode for a document with callbacks disabled.
Definition: lokhelper.cxx:133
static void dumpState(rtl::OStringBuffer &rState)
Helper for diagnosing run-time problems.
Definition: lokhelper.cxx:961
sal_uInt16 Which() const
virtual boost::property_tree::ptree dumpAsJSON() const
SfxViewFrame * GetFrame() const
This method returns a pointer to the <SfxViewFrame> to which this SfxShell instance is associated or ...
Definition: shell.cxx:134
static SfxSlotPool & GetSlotPool(SfxViewFrame *pFrame=nullptr)
Definition: msgpool.cxx:316
const SfxSlot * GetSlot(sal_uInt16 nId) const
Definition: msgpool.cxx:155
Definition: msg.hxx:184
SFX2_DLLPUBLIC OUString GetCommand() const
Definition: msg.cxx:46
const OUString & GetUnoName() const
Definition: msg.hxx:237
SAL_DLLPRIVATE void Exec_Impl(SfxRequest &)
Definition: viewfrm2.cxx:149
SfxFrame & GetFrame() const
Definition: viewfrm.cxx:2782
SAL_DLLPRIVATE void MakeActive_Impl(bool bActivate)
Definition: viewfrm.cxx:2178
SAL_DLLPRIVATE void ExecView_Impl(SfxRequest &rReq)
Definition: viewfrm.cxx:2558
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
Definition: viewsh.hxx:165
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
Invokes the registered callback, if there are any.
Definition: viewsh.cxx:2244
ViewShellDocId GetDocId() const override
Get the DocId used by Mobile LOKit to load multiple documents.
Definition: viewsh.cxx:2436
ViewShellId GetViewShellId() const override
See OutlinerViewShell::GetViewShellId().
Definition: viewsh.cxx:2426
SfxViewFrame & GetViewFrame() const
Definition: viewsh.hxx:290
static SAL_WARN_UNUSED_RESULT SfxViewShell * Get(const css::uno::Reference< css::frame::XController > &i_rController)
Definition: viewsh.cxx:1855
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
Definition: viewsh.cxx:2046
virtual int getEditMode() const
See lok::Document::getMode().
Definition: viewsh.cxx:2421
virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) const override
Definition: viewsh.cxx:2270
virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle *pRect, int nPart, int nMode) const override
Definition: viewsh.cxx:2219
void dumpLibreOfficeKitViewState(rtl::OStringBuffer &rState)
dump view state for diagnostics
Definition: viewsh.cxx:2177
virtual void libreOfficeKitViewUpdatedCallback(int nType) const override
Definition: viewsh.cxx:2257
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
Definition: viewsh.cxx:2017
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
Definition: viewsh.cxx:1848
static void SetCurrentDocId(ViewShellDocId nId)
Set the current DocId, which is used by Mobile LOKit to load multiple documents and yet identify the ...
Definition: viewsh.cxx:2431
void setBlockedCommandList(const char *blockedCommandList)
Definition: viewsh.cxx:2896
virtual void libreOfficeKitViewCallbackWithViewId(int nType, const OString &pPayload, int nViewId) const override
Definition: viewsh.cxx:2231
virtual int getPart() const
See lok::Document::getPart().
Definition: viewsh.cxx:2416
int nCount
float u
sal_Int64 n
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
static OString lcl_sanitizeJSONAsValue(const OString &rStr)
Definition: lokhelper.cxx:405
static OString lcl_generateJSON(const SfxViewShell *pView, const boost::property_tree::ptree &rTree)
Definition: lokhelper.cxx:422
aBuf
Definition: mgetempl.cxx:389
void setLocale(const LanguageTag &languageTag)
void setLanguageTag(const LanguageTag &languageTag)
Reference< XComponentContext > getProcessComponentContext()
int i
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
bool isUnipoll()
sal_uInt32 LOKWindowId
sal_Int16 nId
#define INVALID_POOL_ITEM
QPRO_FUNC_TYPE nType
std::optional< Point > maLogicPosition
Definition: lokhelper.hxx:36
MouseEventModifiers meModifiers
Definition: lokhelper.hxx:33
UNDERLYING_TYPE get() const
Reference< XFrame > xFrame
VclEventId
LOKDeviceFormFactor
Definition: viewsh.hxx:122
std::unique_ptr< char[]> aBuffer
VclPtr< vcl::Window > mpWindow