/* -*- 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 #include #include #include #include #include #include #include #include #include #include #include #include using namespace ::com::sun::star; namespace vcl::unohelper { TextDataObject::TextDataObject( OUString aText ) : maText(std::move( aText )) { } TextDataObject::~TextDataObject() { } void TextDataObject::CopyStringTo( const OUString& rContent, const uno::Reference< datatransfer::clipboard::XClipboard >& rxClipboard, const vcl::ILibreOfficeKitNotifier* pNotifier) { SAL_WARN_IF( !rxClipboard.is(), "vcl", "TextDataObject::CopyStringTo: invalid clipboard!" ); if ( !rxClipboard.is() ) return; rtl::Reference pDataObj = new TextDataObject( rContent ); SolarMutexReleaser aReleaser; try { rxClipboard->setContents( pDataObj, nullptr ); uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY ); if( xFlushableClipboard.is() ) xFlushableClipboard->flushClipboard(); if (pNotifier != nullptr && comphelper::LibreOfficeKit::isActive()) { boost::property_tree::ptree aTree; aTree.put("content", rContent); aTree.put("mimeType", "text/plain"); std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_CLIPBOARD_CHANGED, OString(aStream.str())); } } catch( const uno::Exception& ) { } } // css::uno::XInterface uno::Any TextDataObject::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 TextDataObject::getTransferData( const datatransfer::DataFlavor& rFlavor ) { SotClipboardFormatId nT = SotExchange::GetFormat( rFlavor ); if ( nT != SotClipboardFormatId::STRING ) { throw datatransfer::UnsupportedFlavorException(); } return uno::Any(maText); } uno::Sequence< datatransfer::DataFlavor > TextDataObject::getTransferDataFlavors( ) { uno::Sequence< datatransfer::DataFlavor > aDataFlavors(1); SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aDataFlavors.getArray()[0] ); return aDataFlavors; } sal_Bool TextDataObject::isDataFlavorSupported( const datatransfer::DataFlavor& rFlavor ) { SotClipboardFormatId nT = SotExchange::GetFormat( rFlavor ); return ( nT == SotClipboardFormatId::STRING ); } } // namespace vcl::unohelper /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ ra/cp-6.4 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2024-10-29UnoApiTest: rename load to loadFromURL and use it everywhereXisco Fauli
2024-06-18tdf#131562: move test to svl and extend itXisco Fauli
2024-05-21loplugin:ostr in sc/qaNoel Grandin
2024-03-26skip more tests on hi-dpi windowsNoel Grandin
2024-03-14tdf#146619 Remove unused #includes from C/C++ filesRafał Dobrakowski
2024-01-03UnoApiTest::loadFromURL -> UnoApiTest::loadFromFileMike Kaganski
2023-10-07loplugin:ostr: automatic rewriteStephan Bergmann
2023-05-18CppunitTest_sc_vba_macro_test: don't concatenate the name fileXisco Fauli
2023-05-09CppunitTest_sc_vba_macro_test: use CPPUNIT_TEST_FIXTURE()Xisco Fauli
2023-02-21tdf#153752: SbxObject::Execute: extra characters in Option Compatible modeMike Kaganski
2023-02-20VBA: Remove conversions in writer from OORGBTOXLRGB (XLRGB is actually BGR!)Hannah Meeks
2023-02-19tdf#153724: make sure to retrieve the variable value before checking the typeMike Kaganski
2023-02-18Related tdf#149786: add better unit test for vba pdf export macroBalazs Varga
2023-02-14tdf#149786 sc: add VBA function: ExportAsFixedFormatBalazs Varga
2022-11-20tdf#126457 - Add URL and workbook name to window titlesAndreas Heinisch
2022-10-25ChartTest: inherit from UnoApiTestXisco Fauli
2022-10-24UnoApiTest: factor out common codeXisco Fauli
2022-10-21test: merge CalcUnoApiTest and UnoApiTest into oneXisco Fauli
2022-10-21CalcUnoApiTest: work with mxComponent directlyXisco Fauli
2022-10-19sc: factor out common code in testsXisco Fauli
2022-10-17CalcUnoApiTest: factor out tearDownXisco Fauli
2022-10-14CalcUnoApiTest: Move mxComponent to parent and use it everywhereXisco Fauli
2022-10-14sc: inherit from CalcUnoApiTest instead of UnoApiTestXisco Fauli
2022-10-14CppunitTest_sc_vba_macro_test: Do not test specific file on WindowsXisco Fauli
2022-10-11Deduplicate O(U)StringConcatenationMike Kaganski
2022-10-10improve setup/teardown handling in VBAMacrosTestNoel Grandin
2022-09-15CppunitTest_sc_vba_macro_test: unify the way tests are setup and teardownXisco Fauli
2022-09-06tdf#118247 - Correctly handle xlCellTypeConstants parameterAndreas Heinisch
2022-06-17tdf#149579: sc_vba_macro_test: Add unittestXisco Fauli
2022-06-15tdf#52602: sc_vba_macro_test: Add unittestXisco Fauli
2022-06-15CppunitTest_sc_macros_test: move test where it belongsXisco Fauli
2022-06-15CppunitTest_sc_macros_test: split it into twoXisco Fauli
2022-06-15tdf#149325, tdf#149531: sc_macros_test: Add unittestXisco Fauli
2022-03-03improve ScMark* classes a bitLuboš Luňák
2022-02-06intermittent CppunitTest_sc_macros_test failureCaolán McNamara
2022-02-04the tend -> they tendCaolán McNamara
2022-02-02vba: test key-binding define by the macroTomaž Vajngerl
2022-01-27vba: add tests for scrolling, range selecting, print areaTomaž Vajngerl
2022-01-27vba: add support for Application.WindowState + testTomaž Vajngerl
2022-01-27vba: test for selcting and hiding columns from a VBA MacroTomaž Vajngerl
2022-01-21sc: move vba tests to the new vba-macro-test fileXisco Fauli
2022-01-21sc: fix VBA Copy-Paste using same and separate documentTomaž Vajngerl