[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - 2 commits - sw/qa sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Aug 17 07:46:45 UTC 2016
sw/qa/extras/rtfimport/data/tdf100507.rtf | 22 ++++++++++++++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 6 ++++++
sw/source/uibase/shells/textsh.cxx | 5 +++++
writerfilter/source/rtftok/rtfdispatchflag.cxx | 3 ++-
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 19 ++++++++++++++++++-
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 4 ++++
6 files changed, 57 insertions(+), 2 deletions(-)
New commits:
commit faaec32b1b6f2a9f8fb0541a5355beddfec37432
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Aug 16 09:16:47 2016 +0200
tdf#100507 RTF import: don't set default para style to the 0th char style
Regression from commit 1be0a3fa9ebb22b607c54b47739d4467acfed259
(n#825305: writerfilter RTF import: override style properties like Word,
2014-06-17), the problem was that the RTF_PARD handler wanted to set a
default paragraph style, but it didn't check if the 0th style is
actually a paragraph one. This resulted in using a character style name
as a paragraph one, throwing in SwUnoCursorHelper::SetTextFormatColl()
-> all paragraph properties were lost, including the left indent.
Fix this by tracking the style type, and filtering out character styles
when looking up a default paragraph style.
Change-Id: I41faab0e72667b89ec9a507014b395a675847abf
(cherry picked from commit 2de168e99ba9cd2539f1ddbeffad7e3eb71a7b1b)
Reviewed-on: https://gerrit.libreoffice.org/28167
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/qa/extras/rtfimport/data/tdf100507.rtf b/sw/qa/extras/rtfimport/data/tdf100507.rtf
new file mode 100644
index 0000000..1665c4e
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf100507.rtf
@@ -0,0 +1,22 @@
+{\rtf1\ansi\ansicpg1252\deff0\dntblnsbdb\viewkind1
+{\fonttbl
+{\f0\froman\fcharset0 Times New Roman;}
+{\f1\fnil\fcharset0 Arial;}
+{\f2\fnil\fcharset0 Arial;}
+{\f3\fnil\fcharset0 Arial;}
+{\f4\fnil\fcharset0 Arial;}
+{\f5\fnil\fcharset0 Arial;}
+{\f6\fnil\fcharset0 Arial;}
+{\f7\fnil\fcharset0 Arial;}
+{\f8\fnil\fcharset0 Arial;}
+}
+{\colortbl;\red255\green255\blue0;\red0\green0\blue255;\red255\green255\blue255;}
+{\stylesheet
+{\*\cs0 Default Paragraph Font;}
+}
+\jexpand\pgwsxn12240\pghsxn15840
+\margl1748\margr1460\margt678\margb478\marglsxn1748\margrsxn1460\cols1\colno1\colw9032
+{\pard\plain \li3752\ql
+{\f2\b\fs20 Generation 1}
+\par}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 1f2a7fb..5f5d27a 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2678,6 +2678,12 @@ DECLARE_RTFIMPORT_TEST(testTdf78506, "tdf78506.rtf")
}
}
+DECLARE_RTFIMPORT_TEST(testTdf100507, "tdf100507.rtf")
+{
+ // This was 0: left margin of the first paragraph was lost on import.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6618), getProperty<sal_Int32>(getParagraph(1), "ParaLeftMargin"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index 8844503..b8f5b7f 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -485,7 +485,8 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
// By default the style with index 0 is applied.
{
OUString const aName = getStyleName(0);
- if (!aName.isEmpty())
+ // But only in case it's not a character style.
+ if (!aName.isEmpty() && getStyleType(0) != NS_ooxml::LN_Value_ST_StyleType_character)
{
m_aStates.top().aParagraphSprms.set(NS_ooxml::LN_CT_PPrBase_pStyle, std::make_shared<RTFValue>(aName));
m_aStates.top().nCurrentStyleIndex = 0;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 8268a2f..93f1207 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -699,6 +699,19 @@ OUString RTFDocumentImpl::getStyleName(int nIndex)
return m_pSuperstream->getStyleName(nIndex);
}
+Id RTFDocumentImpl::getStyleType(int nIndex)
+{
+ if (!m_pSuperstream)
+ {
+ Id nRet = 0;
+ if (m_aStyleTypes.find(nIndex) != m_aStyleTypes.end())
+ nRet = m_aStyleTypes[nIndex];
+ return nRet;
+ }
+ else
+ return m_pSuperstream->getStyleType(nIndex);
+}
+
RTFParserState& RTFDocumentImpl::getDefaultState()
{
if (!m_pSuperstream)
@@ -1246,10 +1259,13 @@ void RTFDocumentImpl::text(OUString& rString)
}
break;
case Destination::STYLEENTRY:
- if (m_aStates.top().aTableAttributes.find(NS_ooxml::LN_CT_Style_type))
+ {
+ RTFValue::Pointer_t pType = m_aStates.top().aTableAttributes.find(NS_ooxml::LN_CT_Style_type);
+ if (pType)
{
// Word strips whitespace around style names.
m_aStyleNames[m_nCurrentStyleIndex] = aName.trim();
+ m_aStyleTypes[m_nCurrentStyleIndex] = pType->getInt();
auto pValue = std::make_shared<RTFValue>(aName.trim());
m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_Style_styleId, pValue);
m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Style_name, pValue);
@@ -1260,6 +1276,7 @@ void RTFDocumentImpl::text(OUString& rString)
else
SAL_INFO("writerfilter", "no RTF style type defined, ignoring");
break;
+ }
case Destination::LISTNAME:
// TODO: what can be done with a list name?
break;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 8870737..1663b90 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -437,6 +437,8 @@ public:
OUString getFontName(int nIndex);
/// Return the style name of an RTF style index.
OUString getStyleName(int nIndex);
+ /// Return the style type of an RTF style index.
+ Id getStyleType(int nIndex);
/// Return the encoding associated with a font index.
rtl_TextEncoding getEncoding(int nFontIndex);
/// Get the default parser state.
@@ -518,6 +520,8 @@ private:
std::vector<int> m_aFontIndexes;
/// Maps style indexes to style names.
std::map<int, OUString> m_aStyleNames;
+ /// Maps style indexes to style types.
+ std::map<int, Id> m_aStyleTypes;
/// Color index <-> RGB color value map
std::vector<sal_uInt32> m_aColorTable;
bool m_bFirstRun;
commit e24ab8340c9e903431a724ea6559517bbdd9e99e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Aug 12 13:10:44 2016 +0200
tdf#91832: ensure GETLINK reports proper contents for reverse selections too
Change-Id: I4e77a55de012b5edd0d922b5e534e4dd6bb714b6
Reviewed-on: https://gerrit.libreoffice.org/28088
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index fe8b827..9a71d4f 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -664,7 +664,12 @@ void SwTextShell::StateInsert( SfxItemSet &rSet )
// Get the text of the Link.
rSh.StartAction();
+ const bool bAtEnd(rSh.IsCursorPtAtEnd());
+ if(!bAtEnd) // tdf#91832: ensure forward selection
+ rSh.SwapPam();
rSh.CreateCursor();
+ if(!bAtEnd)
+ rSh.SwapPam();
rSh.SwCursorShell::SelectTextAttr(RES_TXTATR_INETFMT,true);
OUString sLinkName = rSh.GetSelText();
aHLinkItem.SetName(sLinkName);
More information about the Libreoffice-commits
mailing list