diff options
Diffstat (limited to 'vcl/source/app')
-rw-r--r-- | vcl/source/app/htmltransferable.cxx | 78 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 65 | ||||
-rw-r--r-- | vcl/source/app/scheduler.cxx | 6 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 29 |
4 files changed, 143 insertions, 35 deletions
diff --git a/vcl/source/app/htmltransferable.cxx b/vcl/source/app/htmltransferable.cxx new file mode 100644 index 000000000000..24f65fe929b1 --- /dev/null +++ b/vcl/source/app/htmltransferable.cxx @@ -0,0 +1,78 @@ +/* -*- 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 <vcl/htmltransferable.hxx> +#include <sot/exchange.hxx> +#include <sot/formats.hxx> +#include <vcl/svapp.hxx> +#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp> +#include <cppuhelper/queryinterface.hxx> +#include <boost/property_tree/json_parser.hpp> + +using namespace ::com::sun::star; + +namespace vcl::unohelper +{ +HtmlTransferable::HtmlTransferable(OString sData) + : data(sData) +{ +} + +HtmlTransferable::~HtmlTransferable() {} + +// css::uno::XInterface +uno::Any HtmlTransferable::queryInterface(const uno::Type& rType) +{ + uno::Any aRet = ::cppu::queryInterface(rType, static_cast<datatransfer::XTransferable*>(this)); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface(rType)); +} + +// css::datatransfer::XTransferable +uno::Any HtmlTransferable::getTransferData(const datatransfer::DataFlavor& rFlavor) +{ + SotClipboardFormatId nT = SotExchange::GetFormat(rFlavor); + if (nT != SotClipboardFormatId::HTML) + { + throw datatransfer::UnsupportedFlavorException(); + } + size_t size = data.getLength(); + uno::Sequence<sal_Int8> sData(size); + std::memcpy(sData.getArray(), data.getStr(), size); + return uno::Any(sData); +} + +uno::Sequence<datatransfer::DataFlavor> HtmlTransferable::getTransferDataFlavors() +{ + uno::Sequence<datatransfer::DataFlavor> aDataFlavors(1); + auto ref = aDataFlavors.getArray()[0]; + ref.MimeType = "text/html"; + ref.DataType = cppu::UnoType<uno::Sequence<sal_Int8>>::get(); + SotExchange::GetFormatDataFlavor(SotClipboardFormatId::HTML, aDataFlavors.getArray()[0]); + return aDataFlavors; +} + +sal_Bool HtmlTransferable::isDataFlavorSupported(const datatransfer::DataFlavor& rFlavor) +{ + SotClipboardFormatId nT = SotExchange::GetFormat(rFlavor); + return (nT == SotClipboardFormatId::HTML); +} + +} // namespace vcl::unohelper diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 46d51c2c2cee..67cb0e5805ee 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -418,6 +418,15 @@ void SalInstanceWidget::set_tooltip_text(const OUString& rTip) OUString SalInstanceWidget::get_tooltip_text() const { return m_xWidget->GetQuickHelpText(); } +void SalInstanceWidget::set_cursor_data(void* pData) +{ + vcl::Cursor* pCursor = static_cast<vcl::Cursor*>(pData); + if (!pCursor) + return; + + m_xWidget->SetCursor(pCursor); +} + void SalInstanceWidget::connect_focus_in(const Link<Widget&, void>& rLink) { ensure_event_listener(); @@ -510,6 +519,11 @@ void SalInstanceWidget::thaw() void SalInstanceWidget::set_busy_cursor(bool bBusy) { + if (!m_xWidget) + { + return; + } + if (bBusy) m_xWidget->EnterWait(); else @@ -1542,6 +1556,11 @@ weld::ScreenShotCollection SalInstanceWindow::collect_screenshot_data() return aRet; } +const vcl::ILibreOfficeKitNotifier* SalInstanceWindow::GetLOKNotifier() +{ + return m_xWindow ? m_xWindow->GetLOKNotifier() : nullptr; +} + SalInstanceWindow::~SalInstanceWindow() { // tdf#129745 only undo overriding child help for the normal case, not for @@ -4943,29 +4962,17 @@ SalInstanceTreeView::~SalInstanceTreeView() m_xTreeView->SetSelectHdl(Link<SvTreeListBox*, void>()); m_xTreeView->SetDeselectHdl(Link<SvTreeListBox*, void>()); m_xTreeView->SetScrolledHdl(Link<SvTreeListBox*, void>()); - m_xTreeView->SetTooltipHdl(Link<const HelpEvent&, bool>()); + m_xTreeView->SetTooltipHdl({}); m_xTreeView->SetCustomRenderHdl(Link<svtree_render_args, void>()); m_xTreeView->SetCustomMeasureHdl(Link<svtree_measure_args, Size>()); } -IMPL_LINK(SalInstanceTreeView, TooltipHdl, const HelpEvent&, rHEvt, bool) +IMPL_LINK(SalInstanceTreeView, TooltipHdl, SvTreeListEntry*, pEntry, OUString) { - if (notify_events_disabled()) - return false; - Point aPos(m_xTreeView->ScreenToOutputPixel(rHEvt.GetMousePosPixel())); - SvTreeListEntry* pEntry = m_xTreeView->GetEntry(aPos); - if (pEntry) - { - SalInstanceTreeIter aIter(pEntry); - OUString aTooltip = signal_query_tooltip(aIter); - if (aTooltip.isEmpty()) - return false; - Size aSize(m_xTreeView->GetOutputSizePixel().Width(), m_xTreeView->GetEntryHeight()); - tools::Rectangle aScreenRect( - m_xTreeView->OutputToScreenPixel(m_xTreeView->GetEntryPosition(pEntry)), aSize); - Help::ShowQuickHelp(m_xTreeView, aScreenRect, aTooltip); - } - return true; + if (pEntry && !notify_events_disabled()) + return signal_query_tooltip(SalInstanceTreeIter(pEntry)); + + return {}; } IMPL_LINK(SalInstanceTreeView, CustomRenderHdl, svtree_render_args, payload, void) @@ -5319,24 +5326,12 @@ void SalInstanceIconView::insert_separator(int pos, const OUString* /* pId */) pViewData->SetSelectable(false); } -IMPL_LINK(SalInstanceIconView, TooltipHdl, const HelpEvent&, rHEvt, bool) +IMPL_LINK(SalInstanceIconView, TooltipHdl, SvTreeListEntry*, pEntry, OUString) { - if (notify_events_disabled()) - return false; - Point aPos(m_xIconView->ScreenToOutputPixel(rHEvt.GetMousePosPixel())); - SvTreeListEntry* pEntry = m_xIconView->GetEntry(aPos); - if (pEntry) - { - SalInstanceTreeIter aIter(pEntry); - OUString aTooltip = signal_query_tooltip(aIter); - if (aTooltip.isEmpty()) - return false; - Size aSize(m_xIconView->GetOutputSizePixel().Width(), m_xIconView->GetEntryHeight()); - tools::Rectangle aScreenRect( - m_xIconView->OutputToScreenPixel(m_xIconView->GetEntryPosition(pEntry)), aSize); - Help::ShowQuickHelp(m_xIconView, aScreenRect, aTooltip); - } - return true; + if (pEntry && !notify_events_disabled()) + return signal_query_tooltip(SalInstanceTreeIter(pEntry)); + + return {}; } IMPL_LINK(SalInstanceIconView, EntryAccessibleDescriptionHdl, SvTreeListEntry*, pEntry, OUString) diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 5da5c2465c60..927de71c4fbb 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -419,6 +419,11 @@ void Scheduler::CallbackTaskScheduling() break; } +// tdf#148435 Apparently calling AnyInput on Mac and filtering for just input, gives +// you window creation / re-sizing events which then trigger idle paint +// events which then deadlock if called with the scheduler lock. +// So since this is an optimisation, just don't do this on mac. +#ifndef MACOSX // Delay invoking tasks with idle priorities as long as there are user input or repaint events // in the OS event queue. This will often effectively compress such events and repaint only // once at the end, improving performance in cases such as repeated zooming with a complex document. @@ -430,6 +435,7 @@ void Scheduler::CallbackTaskScheduling() pMostUrgent = nullptr; nMinPeriod = 0; } +#endif if (InfiniteTimeoutMs != nMinPeriod) SAL_INFO("vcl.schedule", diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index c925869a3daf..2846badba117 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -29,6 +29,7 @@ #include <tools/debug.hxx> #include <tools/time.hxx> #include <tools/stream.hxx> +#include <tools/json_writer.hxx> #include <unotools/configmgr.hxx> #include <unotools/resmgr.hxx> @@ -318,6 +319,7 @@ void Application::notifyWindow(vcl::LOKWindowId /*nLOKWindowId*/, const OUString& /*rAction*/, const std::vector<vcl::LOKPayloadItem>& /*rPayload = std::vector<LOKPayloadItem>()*/) const { + SAL_WARN("vcl", "Invoked not implemented method: Application::notifyWindow"); } void Application::libreOfficeKitViewCallback(int nType, const char* pPayload) const @@ -331,6 +333,9 @@ void Application::libreOfficeKitViewCallback(int nType, const char* pPayload) co } } +void Application::notifyInvalidation(tools::Rectangle const* /*pRect*/) const +{ +} namespace { @@ -1790,12 +1795,36 @@ bool isUnipoll() void numberOfViewsChanged(int count) { + if (count == 0) + return; ImplSVData * pSVData = ImplGetSVData(); auto& rCache = pSVData->maGDIData.maScaleCache; // Normally the cache size is set to 10, scale according to the number of users. rCache.setMaxSize(count * 10); } +void dumpState(rtl::OStringBuffer &rState) +{ + ImplSVData* pSVData = ImplGetSVData(); + if (!pSVData) + return; + + rState.append("\nWindows:\t"); + rState.append(static_cast<sal_Int32>(Application::GetTopWindowCount())); + + vcl::Window *pWin = Application::GetFirstTopLevelWindow(); + while (pWin) + { + tools::JsonWriter props; + pWin->DumpAsPropertyTree(props); + + rState.append("\n\tWindow: "); + rState.append(props.extractAsOString()); + + pWin = Application::GetNextTopLevelWindow( pWin ); + } +} + } // namespace lok, namespace vcl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |