Kaydet (Commit) 29d4ecf3 authored tarafından Miklos Vajna's avatar Miklos Vajna

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 c47db038 (fdo#52547 SOT: Prefer
  embedding image data to embedding linked image., 2014-02-07) was a
  bugfix due to newer firefox
- commit 538c13f3 (fdo#78801 fdo#52547
  Paste preference is image, then html, then text., 2014-05-28) was a
  regression fix from the previous fix
- commit a96a7ce5 (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/52120Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst d7a8fa7a
...@@ -25,6 +25,11 @@ $(eval $(call gb_CppunitTest_use_libraries,sot_test_sot, \ ...@@ -25,6 +25,11 @@ $(eval $(call gb_CppunitTest_use_libraries,sot_test_sot, \
unotest \ 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_sdk_api,sot_test_sot,))
$(eval $(call gb_CppunitTest_use_ure,sot_test_sot)) $(eval $(call gb_CppunitTest_use_ure,sot_test_sot))
......
...@@ -24,6 +24,26 @@ ...@@ -24,6 +24,26 @@
#include <shlobj.h> #include <shlobj.h>
#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 #endif // INCLUDED_SOT_SYSFORMATS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -14,11 +14,30 @@ ...@@ -14,11 +14,30 @@
#include <osl/process.h> #include <osl/process.h>
#include <sot/storage.hxx> #include <sot/storage.hxx>
#include <sot/storinfo.hxx> #include <sot/storinfo.hxx>
#include <sysformats.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
namespace 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 class SotTest
: public test::FiltersTest : public test::FiltersTest
, public test::BootstrapFixtureBase , public test::BootstrapFixtureBase
...@@ -37,10 +56,12 @@ namespace ...@@ -37,10 +56,12 @@ namespace
void test(); void test();
void testSize(); void testSize();
void testClipboard();
CPPUNIT_TEST_SUITE(SotTest); CPPUNIT_TEST_SUITE(SotTest);
CPPUNIT_TEST(test); CPPUNIT_TEST(test);
CPPUNIT_TEST(testSize); CPPUNIT_TEST(testSize);
CPPUNIT_TEST(testClipboard);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -144,6 +165,22 @@ namespace ...@@ -144,6 +165,22 @@ namespace
CPPUNIT_ASSERT_EQUAL_MESSAGE("stream not at beginning", static_cast<sal_uInt64>(0), xStream->Tell()); 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); CPPUNIT_TEST_SUITE_REGISTRATION(SotTest);
} }
......
...@@ -34,20 +34,6 @@ ...@@ -34,20 +34,6 @@
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::datatransfer; 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 a context check Id for every formatid
#define FILEGRPDSC_ONLY_URL 1 #define FILEGRPDSC_ONLY_URL 1
...@@ -894,13 +880,13 @@ SotAction_Impl const aEXCHG_DEST_SWDOC_FREE_AREA_Copy[] = ...@@ -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::SD_OLE, EXCHG_OUT_ACTION_INSERT_OLE, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 },
{ SotClipboardFormatId::EMBED_SOURCE, EXCHG_OUT_ACTION_INSERT_OLE, 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::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::PNG, EXCHG_OUT_ACTION_INSERT_BITMAP, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 },
{ SotClipboardFormatId::JPEG, 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::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, 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_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::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::NETSCAPE_IMAGE, EXCHG_IN_ACTION_COPY, SotExchangeActionFlags::InsertTargetUrl, 0 },
{ SotClipboardFormatId::STRING, EXCHG_OUT_ACTION_INSERT_STRING, 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 }, { SotClipboardFormatId::NETSCAPE_BOOKMARK, EXCHG_OUT_ACTION_INSERT_HYPERLINK, SotExchangeActionFlags::InsertImageMap | SotExchangeActionFlags::InsertTargetUrl, 0 },
...@@ -1314,6 +1300,13 @@ SotDestinationEntry_Impl const aDestinationArray[] = ...@@ -1314,6 +1300,13 @@ SotDestinationEntry_Impl const aDestinationArray[] =
} // namespace } // namespace
namespace sot
{
const SotAction_Impl* GetExchangeDestinationWriterFreeAreaCopy()
{
return aEXCHG_DEST_SWDOC_FREE_AREA_Copy;
}
}
// - new style GetExchange methods - // - new style GetExchange methods -
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment