[Libreoffice-commits] core.git: 3 commits - sw/qa sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Jul 16 02:30:10 PDT 2014
sw/qa/extras/README | 19 ++++++++++
sw/qa/extras/ooxmlexport/data/fdo79817.docx |binary
sw/qa/extras/ooxmlexport/data/sdt-citation-run.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 35 +++++++++++++-------
sw/source/filter/ww8/docxattributeoutput.cxx | 2 +
writerfilter/source/dmapper/DomainMapper.cxx | 12 +++++-
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 15 ++------
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 +
8 files changed, 61 insertions(+), 25 deletions(-)
New commits:
commit 033f59dad003333d449fec8b8eccf8674ee59d8e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jul 16 11:27:33 2014 +0200
sw/qa/extras/README: document how to run a single test
This was already documented in the code, but first it got copy&pasted
several times, then now it's "hidden" in a header, so not so easy to
find.
Change-Id: I6c6814a14bb6208d9f31ee66f0c0f9b843ee7157
diff --git a/sw/qa/extras/README b/sw/qa/extras/README
index fbc6aac..1959f68 100644
--- a/sw/qa/extras/README
+++ b/sw/qa/extras/README
@@ -128,6 +128,25 @@ uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName(DE
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle, "IsLandscape"));
----
+== CppUnit tips
+
+=== sal_Bool
+
+In case an UNO method returns sal_Bool, and the assert fails, CppUnit won't be
+able to print a usable error message, as it will think that the value is a
+printable character. Best to use `bool` for the expected value and cast the
+actual value to `bool` as well before comparing.
+
+=== Running only a single test
+
+If you want to run only a single test to allow quick development iteration,
+then you need to do two things:
+
+- change the `#if 1` in `inc/swmodeltestbase.hxx` to `#if 0` to define the test
+ macro with the `_ONLY` suffix
+- change the used macro for the test you want to run, i.e.
+ `DECLARE_OOXMLEXPORT_TEST` -> `DECLARE_OOXMLEXPORT_TEST_ONLY`
+
== UNO, in more details, various tips:
=== writing code based xray inspection:
commit b2bc4ea8ddae6b01f344469d988e21fed3143c42
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jul 16 10:46:38 2014 +0200
DOCX import: handle SDT around citation field
There were two problems here:
1) Citation field was around a run, but was exported as around the
paragraph.
2) The SDT properties were discarded, as they were inserted into a
character context that was thrown away. To fix this, add a (character
properties) context to the field state, so when it's inserted, it can
have the requested properties.
Change-Id: Ic36deff616060f049147874633c6c7264ae8ecf2
diff --git a/sw/qa/extras/ooxmlexport/data/sdt-citation-run.docx b/sw/qa/extras/ooxmlexport/data/sdt-citation-run.docx
new file mode 100644
index 0000000..cd97f93
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/sdt-citation-run.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 646bf57..0e69a54 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2903,7 +2903,7 @@ DECLARE_OOXMLEXPORT_TEST(test_FieldType, "99_Fields.docx")
// Checking for three field types (BIBLIOGRAPHY, BIDIOUTLINE, CITATION) in sequence
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:r[2]/w:instrText[1]",1);
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[5]/w:r[2]/w:instrText[1]",1);
- assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:sdt/w:sdtContent/w:p/w:r[2]/w:instrText[1]",1);
+ assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p/w:sdt/w:sdtContent/w:r[2]/w:instrText[1]",1);
}
DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx")
@@ -3002,8 +3002,8 @@ DECLARE_OOXMLEXPORT_TEST(testCitation,"FDO74775.docx")
xmlDocPtr pXmlDoc = parseExport();
if (!pXmlDoc)
return;
- assertXPathContent(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[3]/w:instrText", " CITATION Kra06 \\l 1033 ");
- assertXPathContent(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[5]/w:t", "(Kramer & Chen, 2006)");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:sdt/w:sdtContent/w:r[2]/w:instrText", " CITATION Kra06 \\l 1033 ");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:sdt/w:sdtContent/w:r[4]/w:t", "(Kramer & Chen, 2006)");
}
DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx")
@@ -3101,11 +3101,11 @@ DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx")
if (!pXmlDoc)
return;
- assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:text", 1);
- assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:id", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:sdt/w:sdtPr/w:text", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:sdt/w:sdtPr/w:id", 1);
assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:picture", 1);
assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:group", 1);
- assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:citation", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:citation", 1);
}
@@ -3799,6 +3799,17 @@ DECLARE_OOXMLEXPORT_TEST(testfdo81031, "fdo81031.docx")
CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(148), xBitmap->getSize().Height );
}
+DECLARE_OOXMLEXPORT_TEST(testSdtCitationRun, "sdt-citation-run.docx")
+{
+ // The problem was that the SDT was around the whole paragraph, not only around the citation field.
+ if (xmlDocPtr pXmlDoc = parseExport())
+ {
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/w:t", "Before sdt.");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:instrText", " CITATION BBC11 \\l 1033 ");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:t", "After sdt.");
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 30179bb..92e4a96 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -7828,6 +7828,8 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem )
else if (aPropertyValue.Name == "ooxml:CT_SdtPr_id" && m_nRunSdtPrToken == 0)
// only write id token as a marker if no other exist
m_nRunSdtPrToken = FSNS( XML_w, XML_id );
+ else if (aPropertyValue.Name == "ooxml:CT_SdtPr_citation")
+ m_nRunSdtPrToken = FSNS( XML_w, XML_citation );
}
}
else
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 4804131..df682c7 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2799,10 +2799,18 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
if(m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_checkbox") ||
m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_text") ||
m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_dataBinding") ||
+ m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_citation") ||
(m_pImpl->m_pSdtHelper->containedInInteropGrabBag("ooxml:CT_SdtPr_id") &&
m_pImpl->m_pSdtHelper->getInteropGrabBagSize() == 1))
- m_pImpl->GetTopContextOfType(CONTEXT_CHARACTER)->Insert(PROP_SDTPR,
- uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, CHAR_GRAB_BAG);
+ {
+ PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_CHARACTER);
+
+ if (m_pImpl->IsOpenField())
+ // We have a field, insert the SDT properties to the field's grab-bag, so they won't be lost.
+ pContext = m_pImpl->GetTopFieldContext()->getProperties();
+
+ pContext->Insert(PROP_SDTPR, uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, CHAR_GRAB_BAG);
+ }
else
m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)->Insert(PROP_SDTPR,
uno::makeAny(m_pImpl->m_pSdtHelper->getInteropGrabBagAndClear()), true, PARA_GRAB_BAG);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9983b99..d3c5d75 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2486,6 +2486,7 @@ FieldContext::FieldContext(uno::Reference< text::XTextRange > xStart) :
m_bFieldCommandCompleted( false )
,m_xStartRange( xStart )
{
+ m_pProperties.reset(new PropertyMap());
}
@@ -3838,17 +3839,9 @@ void DomainMapper_Impl::CloseFieldCommand()
uno::makeAny(aValues));
}
uno::Reference< text::XTextContent > xToInsert( xTC, uno::UNO_QUERY );
- uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
- if (xTextAppend.is())
- {
- uno::Reference< text::XTextCursor > xCrsr = xTextAppend->getText()->createTextCursor();
- uno::Reference< text::XText > xText = xTextAppend->getText();
- if(xCrsr.is() && xText.is())
- {
- xCrsr->gotoEnd(false);
- xText->insertTextContent(uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW ), xToInsert, sal_False);
- }
- }
+
+ uno::Sequence<beans::PropertyValue> aValues = m_aFieldStack.top()->getProperties()->GetPropertyValues();
+ appendTextContent(xToInsert, aValues);
m_bSetCitation = true;
}
break;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 60c8c65..f374ede 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -132,6 +132,8 @@ class FieldContext
OUString m_sHyperlinkURL;
FFDataHandler::Pointer_t m_pFFDataHandler;
FormControlHelper::Pointer_t m_pFormControlHelper;
+ /// (Character) properties of the field itself.
+ PropertyMapPtr m_pProperties;
public:
FieldContext(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xStart);
@@ -169,6 +171,7 @@ public:
void setFormControlHelper(FormControlHelper::Pointer_t pFormControlHelper) { m_pFormControlHelper = pFormControlHelper; }
FormControlHelper::Pointer_t getFormControlHelper() const { return m_pFormControlHelper; }
+ PropertyMapPtr getProperties() { return m_pProperties; }
::std::vector<OUString> GetCommandParts() const;
};
commit 1fcbc55b284463a3613849caa43c2e9c82aced1c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jul 16 10:30:43 2014 +0200
CppunitTest_sw_ooxmlexport: clean up testfdo79817
Instead of checking the third paragraph, remove everything else from the
bugdoc, so checking the only paragraph is enough.
Change-Id: I74e8db16cb1f27370ac88d9dff136aaeceb63cdb
diff --git a/sw/qa/extras/ooxmlexport/data/fdo79817.docx b/sw/qa/extras/ooxmlexport/data/fdo79817.docx
index 4194c43..7e948c5 100644
Binary files a/sw/qa/extras/ooxmlexport/data/fdo79817.docx and b/sw/qa/extras/ooxmlexport/data/fdo79817.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 7dd37a2..646bf57 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3561,13 +3561,13 @@ DECLARE_OOXMLEXPORT_TEST(testFDO79915, "fdo79915.docx")
assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[8]/w:t", "How much buoyancy does the water provide?");
}
-DECLARE_OOXMLEXPORT_TEST(testfdo79817,"fdo79817.docx")
+DECLARE_OOXMLEXPORT_TEST(testfdo79817, "fdo79817.docx")
{
- xmlDocPtr pXmlDoc = parseExport("word/document.xml");
- if (!pXmlDoc)
- return;
- assertXPath ( pXmlDoc, "/w:document/w:body/w:p[3]/w:sdt/w:sdtPr/w:dataBinding", "storeItemID","{9222E47B-A68B-4AEB-9855-21C912B9D3D2}");
- assertXPath ( pXmlDoc, "/w:document/w:body/w:p[3]/w:sdt/w:sdtPr/w:dataBinding", "xpath","/ns0:properties[1]/documentManagement[1]/ns2:Responsible_x0020_Officer_x0020_Title[1]");
+ if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
+ {
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "storeItemID", "{9222E47B-A68B-4AEB-9855-21C912B9D3D2}");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns0:properties[1]/documentManagement[1]/ns2:Responsible_x0020_Officer_x0020_Title[1]");
+ }
}
More information about the Libreoffice-commits
mailing list