libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 37 ++++++++++++++++++-- sw/qa/extras/rtfimport/data/tdf92061.rtf | 5 ++ sw/qa/extras/rtfimport/rtfimport.cxx | 6 +++ writerfilter/source/dmapper/CellMarginHandler.cxx | 16 ++------ writerfilter/source/dmapper/LatentStyleHandler.cxx | 8 +--- writerfilter/source/dmapper/LatentStyleHandler.hxx | 2 - writerfilter/source/dmapper/StyleSheetTable.cxx | 2 - writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 + 8 files changed, 57 insertions(+), 21 deletions(-)
New commits: commit 2e32eff6f1a6ac8bc0ef65e07300531d6f45275b Author: Miklos Vajna <[email protected]> Date: Mon Jun 22 09:10:09 2015 +0200 Use SAL_WARN{,_IF} Change-Id: Idd4693bd48b4bbe3ebfb5c86922ab0edfeba0def diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx index 6e28f62..6d223c2 100644 --- a/writerfilter/source/dmapper/CellMarginHandler.cxx +++ b/writerfilter/source/dmapper/CellMarginHandler.cxx @@ -21,7 +21,6 @@ #include <ConversionHelper.hxx> #include <ooxml/resourceids.hxx> #include <comphelper/sequence.hxx> -#include <osl/diagnose.h> namespace writerfilter { namespace dmapper { @@ -61,11 +60,11 @@ void CellMarginHandler::lcl_attribute(Id rName, Value & rVal) m_nValue = ConversionHelper::convertTwipToMM100Unsigned( nIntValue ); break; case NS_ooxml::LN_CT_TblWidth_type: - OSL_ENSURE( NS_ooxml::LN_Value_ST_TblWidth_dxa == sal::static_int_cast<Id>(nIntValue), "cell margins work for absolute values, only"); + SAL_WARN_IF(NS_ooxml::LN_Value_ST_TblWidth_dxa != sal::static_int_cast<Id>(nIntValue), "writerfilter", "CellMarginHandler: cell margins work for absolute values only"); m_nType = nIntValue; break; default: - OSL_FAIL( "unknown attribute"); + SAL_WARN("writerfilter", "CellMarginHandler::lcl_attribute: unknown attribute"); } } @@ -153,7 +152,7 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm) createGrabBag("right"); break; default: - OSL_FAIL( "unknown sprm"); + SAL_WARN("writerfilter", "CellMarginHandler::lcl_sprm: unknown sprm"); } } m_nValue = 0; commit f43dd61f092e3df6c58a48f587f3cd2fe4238675 Author: Miklos Vajna <[email protected]> Date: Mon Jun 22 09:08:22 2015 +0200 Use comphelper::containerToSequence Change-Id: Ib227023eceacbcc3ca303af47794561eab708a39 diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx index 922a50b..6e28f62 100644 --- a/writerfilter/source/dmapper/CellMarginHandler.cxx +++ b/writerfilter/source/dmapper/CellMarginHandler.cxx @@ -20,6 +20,7 @@ #include <PropertyMap.hxx> #include <ConversionHelper.hxx> #include <ooxml/resourceids.hxx> +#include <comphelper/sequence.hxx> #include <osl/diagnose.h> namespace writerfilter { @@ -167,13 +168,7 @@ beans::PropertyValue CellMarginHandler::getInteropGrabBag() { beans::PropertyValue aRet; aRet.Name = m_aInteropGrabBagName; - - uno::Sequence<beans::PropertyValue> aSeq(m_aInteropGrabBag.size()); - beans::PropertyValue* pSeq = aSeq.getArray(); - for (std::vector<beans::PropertyValue>::iterator i = m_aInteropGrabBag.begin(); i != m_aInteropGrabBag.end(); ++i) - *pSeq++ = *i; - - aRet.Value = uno::makeAny(aSeq); + aRet.Value = uno::makeAny(comphelper::containerToSequence(m_aInteropGrabBag)); return aRet; } diff --git a/writerfilter/source/dmapper/LatentStyleHandler.cxx b/writerfilter/source/dmapper/LatentStyleHandler.cxx index 67e2cb6f..0e9eb58 100644 --- a/writerfilter/source/dmapper/LatentStyleHandler.cxx +++ b/writerfilter/source/dmapper/LatentStyleHandler.cxx @@ -68,13 +68,9 @@ void LatentStyleHandler::lcl_sprm(Sprm& /*rSprm*/) { } -uno::Sequence<beans::PropertyValue> LatentStyleHandler::getAttributes() const +std::vector<beans::PropertyValue> LatentStyleHandler::getAttributes() const { - uno::Sequence<beans::PropertyValue> aAttributes(m_aAttributes.size()); - beans::PropertyValue* pAttributes = aAttributes.getArray(); - for (std::vector<beans::PropertyValue>::const_iterator i = m_aAttributes.begin(); i != m_aAttributes.end(); ++i) - *pAttributes++ = *i; - return aAttributes; + return m_aAttributes; } } // namespace dmapper diff --git a/writerfilter/source/dmapper/LatentStyleHandler.hxx b/writerfilter/source/dmapper/LatentStyleHandler.hxx index 8b1a697..fd7bf6a 100644 --- a/writerfilter/source/dmapper/LatentStyleHandler.hxx +++ b/writerfilter/source/dmapper/LatentStyleHandler.hxx @@ -33,7 +33,7 @@ public: LatentStyleHandler(); virtual ~LatentStyleHandler(); - css::uno::Sequence<css::beans::PropertyValue> getAttributes() const; + std::vector<css::beans::PropertyValue> getAttributes() const; }; typedef std::shared_ptr<LatentStyleHandler> LatentStyleHandlerPtr; diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 713c107..9e652ea 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -737,7 +737,7 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) pProperties->resolve(*pLatentStyleHandler); beans::PropertyValue aValue; aValue.Name = "lsdException"; - aValue.Value = uno::makeAny(pLatentStyleHandler->getAttributes()); + aValue.Value = uno::makeAny(comphelper::containerToSequence(pLatentStyleHandler->getAttributes())); m_pImpl->m_pCurrentEntry->aLsdExceptions.push_back(aValue); } } commit f403cecdaedf263f11081c91bed62640362a3a3e Author: Miklos Vajna <[email protected]> Date: Mon Jun 22 09:06:31 2015 +0200 gtktiledviewer: do HTML copying if possible Change-Id: I24e7b18442cb08814a73dd33b368b368039a11e4 diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 7d4960d..575588e 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -125,16 +125,49 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/) } } +/// Our GtkClipboardGetFunc implementation for HTML. +static void htmlGetFunc(GtkClipboard* /*pClipboard*/, GtkSelectionData* pSelectionData, guint /*info*/, gpointer pUserData) +{ + GdkAtom aAtom(gdk_atom_intern("text/html", false)); + const gchar* pSelection = static_cast<const gchar*>(pUserData); + gtk_selection_data_set(pSelectionData, aAtom, 8, reinterpret_cast<const guchar *>(pSelection), strlen(pSelection)); +} + +/// Our GtkClipboardClearFunc implementation for HTML. +static void htmlClearFunc(GtkClipboard* /*pClipboard*/, gpointer pData) +{ + g_free(pData); +} + +/// Same as gtk_clipboard_set_text(), but sets HTML. +static void clipboardSetHtml(GtkClipboard* pClipboard, const char* pSelection) +{ + GtkTargetList* pList = gtk_target_list_new(0, 0); + GdkAtom aAtom(gdk_atom_intern("text/html", false)); + gtk_target_list_add(pList, aAtom, 0, 0); + gint nTargets = 0; + GtkTargetEntry* pTargets = gtk_target_table_new_from_list(pList, &nTargets); + + gtk_clipboard_set_with_data(pClipboard, pTargets, nTargets, htmlGetFunc, htmlClearFunc, g_strdup(pSelection)); + + gtk_target_table_free(pTargets, nTargets); + gtk_target_list_unref(pList); +} + /// Handler for the copy button: write clipboard. static void doCopy(GtkWidget* /*pButton*/, gpointer /*pItem*/) { LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView); LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView); char* pUsedFormat = 0; - char* pSelection = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8", &pUsedFormat); + char* pSelection = pDocument->pClass->getTextSelection(pDocument, "text/html", &pUsedFormat); GtkClipboard* pClipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(pDocView), GDK_SELECTION_CLIPBOARD); - gtk_clipboard_set_text(pClipboard, pSelection, -1); + std::string aUsedFormat(pUsedFormat); + if (aUsedFormat == "text/plain;charset=utf-8") + gtk_clipboard_set_text(pClipboard, pSelection, -1); + else + clipboardSetHtml(pClipboard, pSelection); free(pSelection); free(pUsedFormat); commit 7b08304b55cf2284a3c583426c60baef618ba206 Author: Miklos Vajna <[email protected]> Date: Mon Jun 22 09:05:30 2015 +0200 tdf#92061 RTF import: fix missing body text after footnote A missing seek in the \footnote handler could result in a situation that the missed text contained a "{" but not its matching "}", which resulted in the parser terminating earlier than the end of the document. Change-Id: I6df476b2d6397dfa918111b33854dc2f95fbe81d diff --git a/sw/qa/extras/rtfimport/data/tdf92061.rtf b/sw/qa/extras/rtfimport/data/tdf92061.rtf new file mode 100644 index 0000000..03978b4 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf92061.rtf @@ -0,0 +1,5 @@ +{\rtf1 +body-before +{\footnote AAAAA {B} C} +body-after\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 8171b6d..8a22358 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2307,6 +2307,12 @@ DECLARE_RTFIMPORT_TEST(testBinSkipping, "bin-skipping.rtf") CPPUNIT_ASSERT_EQUAL(OUString("text"), getRun(getParagraph(1), 1)->getString()); } +DECLARE_RTFIMPORT_TEST(testTdf92061, "tdf92061.rtf") +{ + // This was "C", i.e. part of the footnote ended up in the body text. + CPPUNIT_ASSERT_EQUAL(OUString("body-after"), getRun(getParagraph(1), 3)->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 31e62ee..9b16e5a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1682,11 +1682,13 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) // Check if this is an endnote. OStringBuffer aBuf; char ch; + sal_Size nCurrent = Strm().Tell(); for (int i = 0; i < 7; ++i) { Strm().ReadChar(ch); aBuf.append(ch); } + Strm().Seek(nCurrent); OString aKeyword = aBuf.makeStringAndClear(); if (aKeyword.equals("\\ftnalt")) nId = NS_ooxml::LN_endnote; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
