[Libreoffice-commits] core.git: 3 commits - sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Fri Mar 1 08:54:02 PST 2013
sw/qa/extras/rtfimport/data/fdo59638.rtf | 35 +++++++++++++++++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 25 +++++++++++++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 35 ++++++++++++++++++++-----
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1
4 files changed, 90 insertions(+), 6 deletions(-)
New commits:
commit 58c30a3545a5725d704eabd79071db02f1f2cb23
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Mar 1 17:38:03 2013 +0100
fdo#59638 handle RTF_F inside RTF_LISTLEVEL
Word typically uses the Symbol font to describe bullet characters
instead of using a sane Unicode value, the previous can only be handled
if we parse the custom font set for the list.
Change-Id: I1491f07c40953949e381a035c1596c207cdc4c35
diff --git a/sw/qa/extras/rtfimport/data/fdo59638.rtf b/sw/qa/extras/rtfimport/data/fdo59638.rtf
new file mode 100644
index 0000000..e2572bf
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo59638.rtf
@@ -0,0 +1,35 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi0\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+{\fonttbl
+{\f0\fbidi \froman\fcharset238\fprq2
+Times New Roman;}
+{\f2\fbidi \fmodern\fcharset238\fprq1
+Courier New;}
+{\f3\fbidi \froman\fcharset2\fprq2
+Symbol;}
+}
+{\*\listtable
+{\list\listtemplateid-1784933330\listsimple
+{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat0\levelspace0\levelindent0
+{\leveltext\'01*;}
+{\levelnumbers;}
+\hres0\chhres0 }
+{\listname ;}
+\listid-2}
+}
+{\*\listoverridetable
+{\listoverride\listid-2\listoverridecount1
+{\lfolevel\listoverrideformat
+{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat0\levelold\levelspace0
+\levelindent0
+{\leveltext\'01\u-3913 ?;}
+{\levelnumbers;}
+\f3\fbias0 }
+}
+\ls1}
+}
+\pard\plain \ltrpar\ql \fi-360\li720\ri0\nowidctlpar\wrapdefault
+\faauto\ls1\rin0\lin720\itap0\pararsid7241016 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang1031\langfe1031\loch\af31506\hich\af31506\dbch\af31505\cgrid\langnp1031\langfenp1031
+{\rtlch\fcs1 \af37 \ltrch\fcs0
+\f37\insrsid15285686 \hich\af37\dbch\af31505\loch\f37 3
+\par }
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index f923762..e577f42 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -143,6 +143,7 @@ public:
void testFdo59419();
void testFdo58076_2();
void testFdo59953();
+ void testFdo59638();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -258,6 +259,7 @@ void Test::run()
{"fdo59419.rtf", &Test::testFdo59419},
{"fdo58076-2.rtf", &Test::testFdo58076_2},
{"fdo59953.rtf", &Test::testFdo59953},
+ {"fdo59638.rtf", &Test::testFdo59638},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1120,6 +1122,29 @@ void Test::testFdo59953()
CPPUNIT_ASSERT_EQUAL(sal_Int16(7650), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
}
+void Test::testFdo59638()
+{
+ // The problem was that w:lvlOverride inside w:num was ignores by dmapper.
+
+ uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aProps;
+ xLevels->getByIndex(0) >>= aProps; // 1st level
+
+ for (int i = 0; i < aProps.getLength(); ++i)
+ {
+ const beans::PropertyValue& rProp = aProps[i];
+
+ if (rProp.Name == "BulletChar")
+ {
+ // Was '*', should be 'o'.
+ CPPUNIT_ASSERT_EQUAL(OUString("\xEF\x82\xB7", 3, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>());
+ return;
+ }
+ }
+ CPPUNIT_FAIL("no BulletChar property");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 6ef8009..077ce50 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2721,6 +2721,14 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
m_aFontIndexes.push_back(nParam);
m_nCurrentFontIndex = getFontIndex(nParam);
}
+ else if (m_aStates.top().nDestinationState == DESTINATION_LISTLEVEL)
+ {
+ RTFSprms aFontSprms;
+ aFontSprms.set(NS_sprm::LN_CRgFtc0, RTFValue::Pointer_t(new RTFValue(getFontIndex(nParam))));
+ RTFSprms aRunPropsSprms;
+ aRunPropsSprms.set(NS_ooxml::LN_EG_RPrBase_rFonts, RTFValue::Pointer_t(new RTFValue(RTFSprms(), aFontSprms)));
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_rPr, RTFValue::Pointer_t(new RTFValue(RTFSprms(), aRunPropsSprms)));
+ }
else
{
int nFontIndex = getFontIndex(nParam);
commit 2f82a08d3565239c2bfe8d21fbebd89bd4657708
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Mar 1 17:02:59 2013 +0100
fdo#59638 import RTF_LFOLEVEL
Change-Id: Icd0ba0bcbf519a15006af2e0eb176c37766345a3
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index fdc8bb8..6ef8009 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1239,6 +1239,10 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_LIST:
m_aStates.top().nDestinationState = DESTINATION_LISTENTRY;
break;
+ case RTF_LFOLEVEL:
+ m_aStates.top().nDestinationState = DESTINATION_LFOLEVEL;
+ m_aStates.top().aTableSprms.clear();
+ break;
case RTF_LISTOVERRIDETABLE:
m_aStates.top().nDestinationState = DESTINATION_LISTOVERRIDETABLE;
break;
@@ -4196,7 +4200,18 @@ int RTFDocumentImpl::popState()
aState.aTableAttributes.set(NS_ooxml::LN_CT_Lvl_ilvl, pInnerValue);
RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
- m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, false);
+ if (m_aStates.top().nDestinationState != DESTINATION_LFOLEVEL)
+ m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, false);
+ else
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_NumLvl_lvl, pValue);
+ }
+ else if (aState.nDestinationState == DESTINATION_LFOLEVEL)
+ {
+ RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
+ aState.aTableAttributes.set(NS_ooxml::LN_CT_NumLvl_ilvl, pInnerValue);
+
+ RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
+ m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Num_lvlOverride, pValue);
}
// list override table
else if (aState.nDestinationState == DESTINATION_LISTOVERRIDEENTRY)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index a26d3ff..c7affd7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -179,6 +179,7 @@ namespace writerfilter {
DESTINATION_MBOX,
DESTINATION_MEQARR,
DESTINATION_UPR,
+ DESTINATION_LFOLEVEL,
};
enum RTFBorderState
commit 24ba80686c9028b4f6dd1f63bfe905c029068b11
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Mar 1 13:04:41 2013 +0100
rtftok: clean this up, SAL_INFO already provides location info
Change-Id: Ib81753bbe26050e2f108c30a1e596a7c34d72fa3
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9266505..fdc8bb8 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1627,7 +1627,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
m_aStates.top().nDestinationState = DESTINATION_NORMAL;
break;
default:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
+ SAL_INFO("writerfilter", "TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
// Make sure we skip destinations (even without \*) till we don't handle them
m_aStates.top().nDestinationState = DESTINATION_SKIP;
aSkip.setParsed(false);
@@ -1904,7 +1904,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
}
break;
default:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle symbol '" << lcl_RtfToString(nKeyword) << "'");
+ SAL_INFO("writerfilter", "TODO handle symbol '" << lcl_RtfToString(nKeyword) << "'");
aSkip.setParsed(false);
break;
}
@@ -2593,7 +2593,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue("CornerRadius", uno::makeAny(sal_Int32(83)));
break;
default:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
+ SAL_INFO("writerfilter", "TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
aSkip.setParsed(false);
break;
}
@@ -3415,7 +3415,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
default:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
+ SAL_INFO("writerfilter", "TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
aSkip.setParsed(false);
break;
}
@@ -3512,7 +3512,7 @@ int RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam
}
break;
default:
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle toggle '" << lcl_RtfToString(nKeyword) << "'");
+ SAL_INFO("writerfilter", "TODO handle toggle '" << lcl_RtfToString(nKeyword) << "'");
aSkip.setParsed(false);
break;
}
More information about the Libreoffice-commits
mailing list