summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRohit Deshmukh <rohit.deshmukh@synerzip.com>2014-03-17 15:08:04 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-19 14:16:11 +0100
commit79747314d368ab253e171877209d7172fd993c74 (patch)
treed96f1d6b21035c3ae15c7e47992be23067195ba1
parent092be17c69b5789414da907197856c0d239da015 (diff)
fdo#76248: Fix for file corruption which contains Polyline shape.
Reviewed on: https://gerrit.libreoffice.org/8623 Change-Id: I042eeb0829c55d6a0fd5d85c1712c7b1cddc8c96
-rw-r--r--sw/qa/extras/ooxmlexport/data/FDO76248.docxbin0 -> 22330 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx8
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx159
3 files changed, 89 insertions, 78 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/FDO76248.docx b/sw/qa/extras/ooxmlexport/data/FDO76248.docx
new file mode 100644
index 000000000000..c7b868e3f6ae
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/FDO76248.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 0a77ab5d75b5..6a50defc8c35 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2878,6 +2878,14 @@ DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx")
}
+DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx")
+{
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+ xCursor->jumpToLastPage();
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCursor->getPage());
+}
#endif
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index be0baa1b2149..0e6297313a2f 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -536,95 +536,98 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrmFmt& rFr
void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt* pFrmFmt, int nAnchorId)
{
- sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
- Size aSize(pSdrObject->GetLogicRect().GetWidth(), pSdrObject->GetLogicRect().GetHeight());
- startDMLAnchorInline(pFrmFmt, aSize);
-
- sax_fastparser::FastAttributeList* pDocPrAttrList = pFS->createAttrList();
- pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
- pDocPrAttrList->add(XML_name, OUStringToOString(pSdrObject->GetName(), RTL_TEXTENCODING_UTF8));
- if (!pSdrObject->GetTitle().isEmpty())
- pDocPrAttrList->add(XML_title, OUStringToOString(pSdrObject->GetTitle(), RTL_TEXTENCODING_UTF8));
- if (!pSdrObject->GetDescription().isEmpty())
- pDocPrAttrList->add(XML_descr, OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8));
- sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
- pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
-
uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape(), uno::UNO_QUERY_THROW);
- uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
- uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY);
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
- if (xPropertySet.is())
- xPropSetInfo = xPropertySet->getPropertySetInfo();
-
- bool bLockedCanvas = false;
- if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("InteropGrabBag"))
+ if (m_pImpl->isSupportedDMLShape(xShape))
{
- uno::Sequence< beans::PropertyValue > propList;
- xPropertySet->getPropertyValue("InteropGrabBag") >>= propList;
- for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
+ sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
+ Size aSize(pSdrObject->GetLogicRect().GetWidth(), pSdrObject->GetLogicRect().GetHeight());
+ startDMLAnchorInline(pFrmFmt, aSize);
+
+ sax_fastparser::FastAttributeList* pDocPrAttrList = pFS->createAttrList();
+ pDocPrAttrList->add(XML_id, OString::number(nAnchorId).getStr());
+ pDocPrAttrList->add(XML_name, OUStringToOString(pSdrObject->GetName(), RTL_TEXTENCODING_UTF8));
+ if (!pSdrObject->GetTitle().isEmpty())
+ pDocPrAttrList->add(XML_title, OUStringToOString(pSdrObject->GetTitle(), RTL_TEXTENCODING_UTF8));
+ if (!pSdrObject->GetDescription().isEmpty())
+ pDocPrAttrList->add(XML_descr, OUStringToOString(pSdrObject->GetDescription(), RTL_TEXTENCODING_UTF8));
+ sax_fastparser::XFastAttributeListRef xDocPrAttrListRef(pDocPrAttrList);
+ pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
+
+ uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo;
+ if (xPropertySet.is())
+ xPropSetInfo = xPropertySet->getPropertySetInfo();
+
+ bool bLockedCanvas = false;
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("InteropGrabBag"))
{
- OUString propName = propList[nProp].Name;
- if (propName == "LockedCanvas")
+ uno::Sequence< beans::PropertyValue > propList;
+ xPropertySet->getPropertyValue("InteropGrabBag") >>= propList;
+ for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
{
- /*
- * Export as Locked Canvas only if the drawing
- * was originally a Locked Canvas and is now inside a Text Frame.
- */
+ OUString propName = propList[nProp].Name;
+ if (propName == "LockedCanvas")
+ {
+ /*
+ * Export as Locked Canvas only if the drawing
+ * was originally a Locked Canvas and is now inside a Text Frame.
+ */
- bLockedCanvas = m_pImpl->m_bIsInDMLTextFrame;
- break;
+ bLockedCanvas = m_pImpl->m_bIsInDMLTextFrame;
+ break;
+ }
}
}
- }
- const char* pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
- if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
- pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
- else if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
- pNamespace = "http://schemas.openxmlformats.org/drawingml/2006/picture";
- pFS->startElementNS(XML_a, XML_graphic,
- FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main",
- FSEND);
- pFS->startElementNS(XML_a, XML_graphicData,
- XML_uri, pNamespace,
- FSEND);
-
- if (bLockedCanvas)
- pFS->startElementNS(XML_lc, XML_lockedCanvas,
- FSNS(XML_xmlns, XML_lc), "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas",
+ const char* pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
+ if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
+ pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
+ else if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
+ pNamespace = "http://schemas.openxmlformats.org/drawingml/2006/picture";
+ pFS->startElementNS(XML_a, XML_graphic,
+ FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main",
+ FSEND);
+ pFS->startElementNS(XML_a, XML_graphicData,
+ XML_uri, pNamespace,
FSEND);
- m_pImpl->m_rExport.OutputDML(xShape);
+ if (bLockedCanvas)
+ pFS->startElementNS(XML_lc, XML_lockedCanvas,
+ FSNS(XML_xmlns, XML_lc), "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas",
+ FSEND);
- if (bLockedCanvas)
- pFS->endElementNS(XML_lc, XML_lockedCanvas);
- pFS->endElementNS(XML_a, XML_graphicData);
- pFS->endElementNS(XML_a, XML_graphic);
+ m_pImpl->m_rExport.OutputDML(xShape);
- // Relative size of the drawing.
- if (pSdrObject->GetRelativeWidth())
- {
- // At the moment drawinglayer objects are always relative from page.
- pFS->startElementNS(XML_wp14, XML_sizeRelH,
- XML_relativeFrom, (pSdrObject->GetRelativeWidthRelation() == text::RelOrientation::FRAME ? "margin" : "page"),
- FSEND);
- pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
- pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeWidth() * 100 * oox::drawingml::PER_PERCENT));
- pFS->endElementNS(XML_wp14, XML_pctWidth);
- pFS->endElementNS(XML_wp14, XML_sizeRelH);
- }
- if (pSdrObject->GetRelativeHeight())
- {
- pFS->startElementNS(XML_wp14, XML_sizeRelV,
- XML_relativeFrom, (pSdrObject->GetRelativeHeightRelation() == text::RelOrientation::FRAME ? "margin" : "page"),
- FSEND);
- pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
- pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeHeight() * 100 * oox::drawingml::PER_PERCENT));
- pFS->endElementNS(XML_wp14, XML_pctHeight);
- pFS->endElementNS(XML_wp14, XML_sizeRelV);
- }
+ if (bLockedCanvas)
+ pFS->endElementNS(XML_lc, XML_lockedCanvas);
+ pFS->endElementNS(XML_a, XML_graphicData);
+ pFS->endElementNS(XML_a, XML_graphic);
- endDMLAnchorInline(pFrmFmt);
+ // Relative size of the drawing.
+ if (pSdrObject->GetRelativeWidth())
+ {
+ // At the moment drawinglayer objects are always relative from page.
+ pFS->startElementNS(XML_wp14, XML_sizeRelH,
+ XML_relativeFrom, (pSdrObject->GetRelativeWidthRelation() == text::RelOrientation::FRAME ? "margin" : "page"),
+ FSEND);
+ pFS->startElementNS(XML_wp14, XML_pctWidth, FSEND);
+ pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeWidth() * 100 * oox::drawingml::PER_PERCENT));
+ pFS->endElementNS(XML_wp14, XML_pctWidth);
+ pFS->endElementNS(XML_wp14, XML_sizeRelH);
+ }
+ if (pSdrObject->GetRelativeHeight())
+ {
+ pFS->startElementNS(XML_wp14, XML_sizeRelV,
+ XML_relativeFrom, (pSdrObject->GetRelativeHeightRelation() == text::RelOrientation::FRAME ? "margin" : "page"),
+ FSEND);
+ pFS->startElementNS(XML_wp14, XML_pctHeight, FSEND);
+ pFS->writeEscaped(OUString::number(*pSdrObject->GetRelativeHeight() * 100 * oox::drawingml::PER_PERCENT));
+ pFS->endElementNS(XML_wp14, XML_pctHeight);
+ pFS->endElementNS(XML_wp14, XML_sizeRelV);
+ }
+
+ endDMLAnchorInline(pFrmFmt);
+ }
}
void DocxSdrExport::Impl::textFrameShadow(const SwFrmFmt& rFrmFmt)
@@ -669,7 +672,7 @@ bool DocxSdrExport::Impl::isSupportedDMLShape(uno::Reference<drawing::XShape> xS
bool supported = true;
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
- if (xServiceInfo->supportsService("com.sun.star.drawing.PolyPolygonShape"))
+ if (xServiceInfo->supportsService("com.sun.star.drawing.PolyPolygonShape") || xServiceInfo->supportsService("com.sun.star.drawing.PolyLineShape"))
supported = false;
return supported;