diff options
-rw-r--r-- | sot/CppunitTest_sot_test_sot.mk | 5 | ||||
-rw-r--r-- | sot/inc/sysformats.hxx | 20 | ||||
-rw-r--r-- | sot/qa/cppunit/test_sot.cxx | 37 | ||||
-rw-r--r-- | sot/source/base/formats.cxx | 23 |
4 files changed, 70 insertions, 15 deletions
diff --git a/sot/CppunitTest_sot_test_sot.mk b/sot/CppunitTest_sot_test_sot.mk index 7fb75975f1b4..1f550759d86d 100644 --- a/sot/CppunitTest_sot_test_sot.mk +++ b/sot/CppunitTest_sot_test_sot.mk @@ -25,6 +25,11 @@ $(eval $(call gb_CppunitTest_use_libraries,sot_test_sot, \ unotest \ )) +$(eval $(call gb_CppunitTest_set_include,sot_test_sot,\ + -I$(SRCDIR)/sot/inc \ + $$(INCLUDE) \ +)) + $(eval $(call gb_CppunitTest_use_sdk_api,sot_test_sot,)) $(eval $(call gb_CppunitTest_use_ure,sot_test_sot)) diff --git a/sot/inc/sysformats.hxx b/sot/inc/sysformats.hxx index d744be74cfae..c04f8bb8be95 100644 --- a/sot/inc/sysformats.hxx +++ b/sot/inc/sysformats.hxx @@ -24,6 +24,26 @@ #include <shlobj.h> #endif +#include <sot/sotdllapi.h> + +struct SotAction_Impl +{ + SotClipboardFormatId nFormatId; // Clipboard Id + sal_uInt16 nAction; // Action Id + SotExchangeActionFlags nFlags; // Action Id + sal_uInt8 nContextCheckId; // additional check of content in clipboard + + constexpr SotAction_Impl(SotClipboardFormatId _nFormatId, sal_uInt16 _nAction, SotExchangeActionFlags _nFlags, sal_uInt8 _nContextCheckId) + : nFormatId(_nFormatId), nAction(_nAction), nFlags(_nFlags), nContextCheckId(_nContextCheckId) {} + constexpr SotAction_Impl(SotClipboardFormatId _nFormatId, sal_uInt16 _nAction) + : nFormatId(_nFormatId), nAction(_nAction), nFlags(SotExchangeActionFlags::NONE), nContextCheckId(0) {} +}; + +namespace sot +{ +SOT_DLLPUBLIC const SotAction_Impl* GetExchangeDestinationWriterFreeAreaCopy(); +} + #endif // INCLUDED_SOT_SYSFORMATS_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sot/qa/cppunit/test_sot.cxx b/sot/qa/cppunit/test_sot.cxx index 0ffbe758a1ec..62fa4b1b5b3b 100644 --- a/sot/qa/cppunit/test_sot.cxx +++ b/sot/qa/cppunit/test_sot.cxx @@ -14,11 +14,30 @@ #include <osl/process.h> #include <sot/storage.hxx> #include <sot/storinfo.hxx> +#include <sysformats.hxx> using namespace ::com::sun::star; namespace { + size_t FindFormatIndex(const SotAction_Impl* pFormats, SotClipboardFormatId eFormat) + { + size_t nRet = 0; + SotClipboardFormatId nId = pFormats->nFormatId; + + while (nId != static_cast<SotClipboardFormatId>(0xffff)) + { + if (nId == eFormat) + break; + + ++pFormats; + ++nRet; + nId = pFormats->nFormatId; + } + + return nRet; + } + class SotTest : public test::FiltersTest , public test::BootstrapFixtureBase @@ -37,10 +56,12 @@ namespace void test(); void testSize(); + void testClipboard(); CPPUNIT_TEST_SUITE(SotTest); CPPUNIT_TEST(test); CPPUNIT_TEST(testSize); + CPPUNIT_TEST(testClipboard); CPPUNIT_TEST_SUITE_END(); }; @@ -144,6 +165,22 @@ namespace CPPUNIT_ASSERT_EQUAL_MESSAGE("stream not at beginning", static_cast<sal_uInt64>(0), xStream->Tell()); } + void SotTest::testClipboard() + { + const SotAction_Impl* pFormats = sot::GetExchangeDestinationWriterFreeAreaCopy(); + // tdf#52547 prefer BITMAP over HTML + CPPUNIT_ASSERT(FindFormatIndex(pFormats, SotClipboardFormatId::BITMAP) < FindFormatIndex(pFormats, SotClipboardFormatId::HTML)); + // tdf#78801 prefer imager over html over text + CPPUNIT_ASSERT(FindFormatIndex(pFormats, SotClipboardFormatId::BITMAP) < FindFormatIndex(pFormats, SotClipboardFormatId::HTML)); + CPPUNIT_ASSERT(FindFormatIndex(pFormats, SotClipboardFormatId::HTML) < FindFormatIndex(pFormats, SotClipboardFormatId::STRING)); + // tdf#81835 prefer RTF/HTML over GDI Metafile + CPPUNIT_ASSERT(FindFormatIndex(pFormats, SotClipboardFormatId::RTF) < FindFormatIndex(pFormats, SotClipboardFormatId::GDIMETAFILE)); + CPPUNIT_ASSERT(FindFormatIndex(pFormats, SotClipboardFormatId::HTML) < FindFormatIndex(pFormats, SotClipboardFormatId::GDIMETAFILE)); + // tdf#115574 prefer RTF over BITMAP (Excel provides a BITMAP we can't + // read, also Excel paste result used to be an editable table) + CPPUNIT_ASSERT(FindFormatIndex(pFormats, SotClipboardFormatId::RTF) < FindFormatIndex(pFormats, SotClipboardFormatId::BITMAP)); + } + CPPUNIT_TEST_SUITE_REGISTRATION(SotTest); } diff --git a/sot/source/base/formats.cxx b/sot/source/base/formats.cxx index afdb25674f0c..692798b5f19e 100644 --- a/sot/source/base/formats.cxx +++ b/sot/source/base/formats.cxx @@ -34,20 +34,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::datatransfer; -struct SotAction_Impl -{ - SotClipboardFormatId nFormatId; // Clipboard Id - sal_uInt16 nAction; // Action Id - SotExchangeActionFlags nFlags; // Action Id - sal_uInt8 nContextCheckId; // additional check of content in clipboard - - constexpr SotAction_Impl(SotClipboardFormatId _nFormatId, sal_uInt16 _nAction, SotExchangeActionFlags _nFlags, sal_uInt8 _nContextCheckId) - : nFormatId(_nFormatId), nAction(_nAction), nFlags(_nFlags), nContextCheckId(_nContextCheckId) {} - constexpr SotAction_Impl(SotClipboardFormatId _nFormatId, sal_uInt16 _nAction) - : nFormatId(_nFormatId), nAction(_nAction), nFlags(SotExchangeActionFlags::NONE), nContextCheckId(0) {} -}; - - // define a context check Id for every formatid #define FILEGRPDSC_ONLY_URL 1 @@ -894,13 +880,13 @@ SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Copy[] = { SotClipboardFormatId::SD_OLE, EXCHG_OUT_ACTION_INSERT_OLE, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::EMBED_SOURCE, EXCHG_OUT_ACTION_INSERT_OLE, SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::EMBEDDED_OBJ, EXCHG_OUT_ACTION_INSERT_OLE, SotExchangeActionFlags::InsertTargetUrl, 0 }, + { SotClipboardFormatId::RTF, EXCHG_IN_ACTION_COPY, SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::PNG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::JPEG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::BITMAP, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::HTML, EXCHG_OUT_ACTION_INSERT_HTML, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::HTML_NO_COMMENT, EXCHG_OUT_ACTION_INSERT_HTML, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::HTML_SIMPLE, EXCHG_OUT_ACTION_INSERT_HTML, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, - { SotClipboardFormatId::RTF, EXCHG_IN_ACTION_COPY, SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::NETSCAPE_IMAGE, EXCHG_IN_ACTION_COPY, SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::STRING, EXCHG_OUT_ACTION_INSERT_STRING, SotExchangeActionFlags::InsertTargetUrl, 0 }, { SotClipboardFormatId::NETSCAPE_BOOKMARK, EXCHG_OUT_ACTION_INSERT_HYPERLINK, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 }, @@ -1314,6 +1300,13 @@ SotDestinationEntry_Impl const aDestinationArray[] = } // namespace +namespace sot +{ +const SotAction_Impl* GetExchangeDestinationWriterFreeAreaCopy() +{ + return aEXCHG_DEST_SWDOC_FREE_AREA_Copy; +} +} // - new style GetExchange methods - |