Kaydet (Commit) 1b922da4 authored tarafından Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez

sw/qa: Code refactor.

Change-Id: I552b5111901a2e1011a2bd0acaf0231dadd56614
üst d3e15e0c
...@@ -50,21 +50,30 @@ using namespace oox; ...@@ -50,21 +50,30 @@ using namespace oox;
namespace namespace
{ {
OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj) template<class T>
T lclGetProperty(uno::Reference<drawing::XShape> rShape, OUString rPropName)
{ {
OUString aResult; T aResult;
uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pObj)->getUnoShape(), uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xPropertySet(rShape, uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
uno::Reference<beans::XPropertySetInfo> xPropSetInfo; uno::Reference<beans::XPropertySetInfo> xPropSetInfo;
if (!xPropertySet.is()) if (!xPropertySet.is())
return aResult; return aResult;
xPropSetInfo = xPropertySet->getPropertySetInfo(); xPropSetInfo = xPropertySet->getPropertySetInfo();
if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag")) if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(rPropName))
{ {
uno::Sequence< beans::PropertyValue > propList; xPropertySet->getPropertyValue(rPropName) >>= aResult;
xPropertySet->getPropertyValue("FrameInteropGrabBag") >>= propList; }
return aResult;
}
OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj)
{
OUString aResult;
uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pObj)->getUnoShape(), uno::UNO_QUERY);
uno::Sequence< beans::PropertyValue > propList =
lclGetProperty< uno::Sequence<beans::PropertyValue> >(xShape, "FrameInteropGrabBag");
for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp) for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
{ {
OUString aPropName = propList[nProp].Name; OUString aPropName = propList[nProp].Name;
...@@ -74,7 +83,6 @@ OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj) ...@@ -74,7 +83,6 @@ OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj)
break; break;
} }
} }
}
return aResult; return aResult;
} }
...@@ -555,16 +563,21 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt* ...@@ -555,16 +563,21 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt*
pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef); pFS->singleElementNS(XML_wp, XML_docPr, xDocPrAttrListRef);
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW); uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
uno::Reference< beans::XPropertySet > xPropertySet(xShape, uno::UNO_QUERY); const char* pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
uno::Reference< beans::XPropertySetInfo > xPropSetInfo; if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
if (xPropertySet.is()) pNamespace = "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup";
xPropSetInfo = xPropertySet->getPropertySetInfo(); 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);
bool bLockedCanvas = false; bool bLockedCanvas = false;
if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("InteropGrabBag")) uno::Sequence< beans::PropertyValue > propList =
{ lclGetProperty< uno::Sequence<beans::PropertyValue> >(xShape, "InteropGrabBag");
uno::Sequence< beans::PropertyValue > propList;
xPropertySet->getPropertyValue("InteropGrabBag") >>= propList;
for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp) for (sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp)
{ {
OUString propName = propList[nProp].Name; OUString propName = propList[nProp].Name;
...@@ -574,24 +587,10 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt* ...@@ -574,24 +587,10 @@ void DocxSdrExport::writeDMLDrawing(const SdrObject* pSdrObject, const SwFrmFmt*
* Export as Locked Canvas only if the drawing * Export as Locked Canvas only if the drawing
* was originally a Locked Canvas and is now inside a Text Frame. * 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";
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) if (bLockedCanvas)
pFS->startElementNS(XML_lc, XML_lockedCanvas, pFS->startElementNS(XML_lc, XML_lockedCanvas,
FSNS(XML_xmlns, XML_lc), "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas", FSNS(XML_xmlns, XML_lc), "http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas",
......
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