mirror of
https://github.com/LibreOffice/core.git
synced 2026-01-06 07:52:41 +00:00
vcl: clang-format vcl::unohelper::TextDataObject code
This in particular gets rid of an extra indentation level. Change-Id: I69c8a7bd52f3e2c9d6c0ef1a82a36f8129d7134e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196452 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@ -26,42 +26,44 @@
|
||||
#include <vcl/dllapi.h>
|
||||
#include <vcl/IDialogRenderable.hxx>
|
||||
|
||||
namespace com::sun::star::datatransfer::clipboard {
|
||||
class XClipboard;
|
||||
namespace com::sun::star::datatransfer::clipboard
|
||||
{
|
||||
class XClipboard;
|
||||
}
|
||||
|
||||
namespace vcl::unohelper {
|
||||
namespace vcl::unohelper
|
||||
{
|
||||
class VCL_DLLPUBLIC TextDataObject final : public css::datatransfer::XTransferable,
|
||||
public ::cppu::OWeakObject
|
||||
{
|
||||
private:
|
||||
OUString maText;
|
||||
|
||||
class VCL_DLLPUBLIC TextDataObject final :
|
||||
public css::datatransfer::XTransferable,
|
||||
public ::cppu::OWeakObject
|
||||
{
|
||||
private:
|
||||
OUString maText;
|
||||
public:
|
||||
TextDataObject(OUString aText);
|
||||
SAL_DLLPRIVATE virtual ~TextDataObject() override;
|
||||
|
||||
public:
|
||||
TextDataObject( OUString aText );
|
||||
SAL_DLLPRIVATE virtual ~TextDataObject() override;
|
||||
// css::uno::XInterface
|
||||
SAL_DLLPRIVATE css::uno::Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
|
||||
void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); }
|
||||
void SAL_CALL release() noexcept override { OWeakObject::release(); }
|
||||
|
||||
// css::uno::XInterface
|
||||
SAL_DLLPRIVATE css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
|
||||
void SAL_CALL acquire() noexcept override { OWeakObject::acquire(); }
|
||||
void SAL_CALL release() noexcept override { OWeakObject::release(); }
|
||||
// css::datatransfer::XTransferable
|
||||
SAL_DLLPRIVATE css::uno::Any SAL_CALL
|
||||
getTransferData(const css::datatransfer::DataFlavor& aFlavor) override;
|
||||
SAL_DLLPRIVATE css::uno::Sequence<css::datatransfer::DataFlavor>
|
||||
SAL_CALL getTransferDataFlavors() override;
|
||||
SAL_DLLPRIVATE sal_Bool SAL_CALL
|
||||
isDataFlavorSupported(const css::datatransfer::DataFlavor& aFlavor) override;
|
||||
|
||||
// css::datatransfer::XTransferable
|
||||
SAL_DLLPRIVATE css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override;
|
||||
SAL_DLLPRIVATE css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override;
|
||||
SAL_DLLPRIVATE sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override;
|
||||
/// copies a given string to a given clipboard
|
||||
static void
|
||||
CopyStringTo(const OUString& rContent,
|
||||
const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& rxClipboard,
|
||||
const vcl::ILibreOfficeKitNotifier* pNotifier = nullptr);
|
||||
};
|
||||
|
||||
/// copies a given string to a given clipboard
|
||||
static void CopyStringTo(
|
||||
const OUString& rContent,
|
||||
const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& rxClipboard,
|
||||
const vcl::ILibreOfficeKitNotifier* pNotifier = nullptr
|
||||
);
|
||||
};
|
||||
|
||||
} // namespace vcl::unohelper
|
||||
} // namespace vcl::unohelper
|
||||
|
||||
#endif // INCLUDED_VCL_UNOHELP2_HXX
|
||||
|
||||
|
||||
@ -6195,7 +6195,6 @@ include/vcl/txtattr.hxx
|
||||
include/vcl/uitest/uiobject.hxx
|
||||
include/vcl/uitest/uitest.hxx
|
||||
include/vcl/unohelp.hxx
|
||||
include/vcl/unohelp2.hxx
|
||||
include/vcl/vclenum.hxx
|
||||
include/vcl/vclevent.hxx
|
||||
include/vcl/vcllayout.hxx
|
||||
@ -14446,7 +14445,6 @@ vcl/source/app/svdata.cxx
|
||||
vcl/source/app/svmain.cxx
|
||||
vcl/source/app/timer.cxx
|
||||
vcl/source/app/unohelp.cxx
|
||||
vcl/source/app/unohelp2.cxx
|
||||
vcl/source/app/vclevent.cxx
|
||||
vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
|
||||
vcl/source/bitmap/BitmapScaleSuperFilter.cxx
|
||||
|
||||
@ -33,81 +33,83 @@
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
namespace vcl::unohelper {
|
||||
namespace vcl::unohelper
|
||||
{
|
||||
TextDataObject::TextDataObject(OUString aText)
|
||||
: maText(std::move(aText))
|
||||
{
|
||||
}
|
||||
|
||||
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<TextDataObject> pDataObj = new TextDataObject(rContent);
|
||||
|
||||
SolarMutexReleaser aReleaser;
|
||||
try
|
||||
{
|
||||
}
|
||||
rxClipboard->setContents(pDataObj, nullptr);
|
||||
|
||||
TextDataObject::~TextDataObject()
|
||||
{
|
||||
}
|
||||
uno::Reference<datatransfer::clipboard::XFlushableClipboard> xFlushableClipboard(
|
||||
rxClipboard, uno::UNO_QUERY);
|
||||
if (xFlushableClipboard.is())
|
||||
xFlushableClipboard->flushClipboard();
|
||||
|
||||
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<TextDataObject> 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& )
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
// css::uno::XInterface
|
||||
uno::Any TextDataObject::queryInterface( const uno::Type & rType )
|
||||
catch (const uno::Exception&)
|
||||
{
|
||||
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 )
|
||||
// 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)
|
||||
{
|
||||
SotClipboardFormatId nT = SotExchange::GetFormat( rFlavor );
|
||||
if ( nT != SotClipboardFormatId::STRING )
|
||||
{
|
||||
throw datatransfer::UnsupportedFlavorException();
|
||||
}
|
||||
return uno::Any(maText);
|
||||
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;
|
||||
}
|
||||
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 );
|
||||
}
|
||||
sal_Bool TextDataObject::isDataFlavorSupported(const datatransfer::DataFlavor& rFlavor)
|
||||
{
|
||||
SotClipboardFormatId nT = SotExchange::GetFormat(rFlavor);
|
||||
return (nT == SotClipboardFormatId::STRING);
|
||||
}
|
||||
|
||||
} // namespace vcl::unohelper
|
||||
} // namespace vcl::unohelper
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user