[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - sot/CppunitTest_sot_test_sot.mk sot/inc sot/qa sot/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Apr 3 08:20:47 UTC 2018
sot/CppunitTest_sot_test_sot.mk | 5 +++++
sot/inc/sysformats.hxx | 20 ++++++++++++++++++++
sot/qa/cppunit/test_sot.cxx | 37 +++++++++++++++++++++++++++++++++++++
sot/source/base/formats.cxx | 23 ++++++++---------------
4 files changed, 70 insertions(+), 15 deletions(-)
New commits:
commit 886bfd53355698e18d4dfe826287aa454313d1af
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Mar 29 18:27:13 2018 +0200
tdf#115574 sot: fix Excel -> Writer paste
Reported problem is that nothing happens for paste. Direct cause is that
BITMAP is selected as the format, and Excel advertises BITMAP, but when
we try to import that, it fails. There are 3 interesting commits in the
recent history for this topic:
- commit c47db038f98aaf7aec3cbe57c4e5683591afa23e (fdo#52547 SOT: Prefer
embedding image data to embedding linked image., 2014-02-07) was a
bugfix due to newer firefox
- commit 538c13f3d1756f2d105115f64ab1bc0b7426eebc (fdo#78801 fdo#52547
Paste preference is image, then html, then text., 2014-05-28) was a
regression fix from the previous fix
- commit a96a7ce51aa98fb9ee97ea3803e2b7e648611008 (fdo#81835 Don't
prefer GDI Metafiles to RTF/HTML, 2014-08-05), was a regression fix
from the previous fixes
Going back to the original state shows that the Excel -> Writer use-case
used to be RTF.
Restore the old Excel -> Writer (RTF) behavior by:
- going back to the original state, ignoring the enum class conversions
- re-fix fdo#52547: prefer bitmap over html, but leave everything else
unchanged
- fdo#78801 needs no fix in this case
- fdo#81835 needs no fix in this case
- tdf#115574 selects RTF -> table shows up
After all these complications, the actual fix is surprisingly simple.
Change-Id: I2d728afa7d1dd7888fa43525366c197d806eea6c
Reviewed-on: https://gerrit.libreoffice.org/52120
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 29d4ecf32392bc94ab0ba9e73fd79eba65c23fdb)
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 b54dfd95cf82..d3b829ee9d0e 100644
--- a/sot/inc/sysformats.hxx
+++ b/sot/inc/sysformats.hxx
@@ -31,6 +31,26 @@
#endif
#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 c4e961271801..d5ee0fd0b01c 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();
};
@@ -145,6 +166,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 ad0a0c0a5525..6c781c4647ec 100644
--- a/sot/source/base/formats.cxx
+++ b/sot/source/base/formats.cxx
@@ -33,20 +33,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
@@ -896,13 +882,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 },
@@ -1316,6 +1302,13 @@ SotDestinationEntry_Impl const aDestinationArray[] =
} // namespace
+namespace sot
+{
+const SotAction_Impl* GetExchangeDestinationWriterFreeAreaCopy()
+{
+ return aEXCHG_DEST_SWDOC_FREE_AREA_Copy;
+}
+}
// - new style GetExchange methods -
More information about the Libreoffice-commits
mailing list