Kaydet (Commit) 79747314 authored tarafından Rohit Deshmukh's avatar Rohit Deshmukh Kaydeden (comit) Miklos Vajna

fdo#76248: Fix for file corruption which contains Polyline shape.

Reviewed on:
	https://gerrit.libreoffice.org/8623

Change-Id: I042eeb0829c55d6a0fd5d85c1712c7b1cddc8c96
üst 092be17c
...@@ -2878,6 +2878,14 @@ DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx") ...@@ -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 #endif
......
...@@ -536,95 +536,98 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrmFmt& rFr ...@@ -536,95 +536,98 @@ void DocxSdrExport::writeVMLDrawing(const SdrObject* sdrObj, const SwFrmFmt& rFr
void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt* pFrmFmt, int nAnchorId) 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<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObject)->getUnoShape(), uno::UNO_QUERY_THROW);
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW); if (m_pImpl->isSupportedDMLShape(xShape))
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"))
{ {
uno::Sequence< beans::PropertyValue > propList; sax_fastparser::FSHelperPtr pFS = m_pImpl->m_pSerializer;
xPropertySet->getPropertyValue("InteropGrabBag") >>= propList; Size aSize(pSdrObject->GetLogicRect().GetWidth(), pSdrObject->GetLogicRect().GetHeight());
for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp) 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; uno::Sequence< beans::PropertyValue > propList;
if (propName == "LockedCanvas") xPropertySet->getPropertyValue("InteropGrabBag") >>= propList;
for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
{ {
/* OUString propName = propList[nProp].Name;
* Export as Locked Canvas only if the drawing if (propName == "LockedCanvas")
* was originally a Locked Canvas and is now inside a Text Frame. {
*/ /*
* 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; bLockedCanvas = m_pImpl->m_bIsInDMLTextFrame;
break; break;
}
} }
} }
} const char* pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
const char* pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"; if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape")) pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"; else if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
else if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape")) pNamespace = "http://schemas.openxmlformats.org/drawingml/2006/picture";
pNamespace = "http://schemas.openxmlformats.org/drawingml/2006/picture"; pFS->startElementNS(XML_a, XML_graphic,
pFS->startElementNS(XML_a, XML_graphic, FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main",
FSNS(XML_xmlns, XML_a), "http://schemas.openxmlformats.org/drawingml/2006/main", FSEND);
FSEND); pFS->startElementNS(XML_a, XML_graphicData,
pFS->startElementNS(XML_a, XML_graphicData, XML_uri, pNamespace,
XML_uri, pNamespace,
FSEND);
if (bLockedCanvas)
pFS->startElementNS(XML_lc, XML_lockedCanvas,
FSNS(XML_xmlns, XML_lc), "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas",
FSEND); 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) m_pImpl->m_rExport.OutputDML(xShape);
pFS->endElementNS(XML_lc, XML_lockedCanvas);
pFS->endElementNS(XML_a, XML_graphicData);
pFS->endElementNS(XML_a, XML_graphic);
// Relative size of the drawing. if (bLockedCanvas)
if (pSdrObject->GetRelativeWidth()) pFS->endElementNS(XML_lc, XML_lockedCanvas);
{ pFS->endElementNS(XML_a, XML_graphicData);
// At the moment drawinglayer objects are always relative from page. pFS->endElementNS(XML_a, XML_graphic);
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); // 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) void DocxSdrExport::Impl::textFrameShadow(const SwFrmFmt& rFrmFmt)
...@@ -669,7 +672,7 @@ bool DocxSdrExport::Impl::isSupportedDMLShape(uno::Reference<drawing::XShape> xS ...@@ -669,7 +672,7 @@ bool DocxSdrExport::Impl::isSupportedDMLShape(uno::Reference<drawing::XShape> xS
bool supported = true; bool supported = true;
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW); 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; supported = false;
return supported; return supported;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment