fdo#70942 Preserve original shape type, if shape contains text.
Currently we change shape type to textframe if a shape contains text. Due to this shape information is not preserved when file is saved. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/7372 Change-Id: I7af3ce29f857d6fa2ceab0350937d91638361e7c
This commit is contained in:
parent
8313f68355
commit
3cf58da99e
@ -135,6 +135,8 @@ public:
|
|||||||
sal_Int32 getShapePresetType() const { return mnShapePresetType; }
|
sal_Int32 getShapePresetType() const { return mnShapePresetType; }
|
||||||
OUString getShapePresetTypeName() const;
|
OUString getShapePresetTypeName() const;
|
||||||
void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; };
|
void setShapePresetType( sal_Int32 nShapePresetType ){ mnShapePresetType = nShapePresetType; };
|
||||||
|
sal_Bool getShapeTypeOverride(){ return mbShapeTypeOverride; };
|
||||||
|
void setShapeTypeOverride( sal_Bool bShapeTypeOverride ) { mbShapeTypeOverride = bShapeTypeOverride; };
|
||||||
|
|
||||||
std::vector< CustomShapeGuide >& getAdjustmentGuideList(){ return maAdjustmentGuideList; };
|
std::vector< CustomShapeGuide >& getAdjustmentGuideList(){ return maAdjustmentGuideList; };
|
||||||
std::vector< CustomShapeGuide >& getGuideList(){ return maGuideList; };
|
std::vector< CustomShapeGuide >& getGuideList(){ return maGuideList; };
|
||||||
@ -155,6 +157,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
sal_Int32 mnShapePresetType;
|
sal_Int32 mnShapePresetType;
|
||||||
|
sal_Bool mbShapeTypeOverride;
|
||||||
std::vector< CustomShapeGuide > maAdjustmentGuideList;
|
std::vector< CustomShapeGuide > maAdjustmentGuideList;
|
||||||
std::vector< CustomShapeGuide > maGuideList;
|
std::vector< CustomShapeGuide > maGuideList;
|
||||||
std::vector< AdjustHandle > maAdjustHandleList;
|
std::vector< AdjustHandle > maAdjustHandleList;
|
||||||
|
@ -44,6 +44,7 @@ namespace oox { namespace drawingml {
|
|||||||
|
|
||||||
CustomShapeProperties::CustomShapeProperties()
|
CustomShapeProperties::CustomShapeProperties()
|
||||||
: mnShapePresetType ( -1 )
|
: mnShapePresetType ( -1 )
|
||||||
|
, mbShapeTypeOverride(sal_False)
|
||||||
, mbMirroredX ( sal_False )
|
, mbMirroredX ( sal_False )
|
||||||
, mbMirroredY ( sal_False )
|
, mbMirroredY ( sal_False )
|
||||||
, mnTextRotateAngle ( 0 )
|
, mnTextRotateAngle ( 0 )
|
||||||
|
@ -621,6 +621,18 @@ Reference< XShape > Shape::createAndInsert(
|
|||||||
{
|
{
|
||||||
if (aServiceName == "com.sun.star.text.TextFrame")
|
if (aServiceName == "com.sun.star.text.TextFrame")
|
||||||
{
|
{
|
||||||
|
if (mpCustomShapePropertiesPtr != NULL && mpCustomShapePropertiesPtr->getShapeTypeOverride())
|
||||||
|
{
|
||||||
|
uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
|
||||||
|
uno::Sequence<beans::PropertyValue> aGrabBag;
|
||||||
|
propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
|
||||||
|
sal_Int32 length = aGrabBag.getLength();
|
||||||
|
aGrabBag.realloc( length+1);
|
||||||
|
aGrabBag[length].Name = "mso-orig-shape-type";
|
||||||
|
aGrabBag[length].Value = uno::makeAny(mpCustomShapePropertiesPtr->getShapePresetTypeName());
|
||||||
|
propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag));
|
||||||
|
}
|
||||||
|
|
||||||
// TextFrames have BackColor, not FillColor
|
// TextFrames have BackColor, not FillColor
|
||||||
if (aShapeProps.hasProperty(PROP_FillColor))
|
if (aShapeProps.hasProperty(PROP_FillColor))
|
||||||
{
|
{
|
||||||
|
@ -101,6 +101,7 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XML_txbx:
|
case XML_txbx:
|
||||||
|
mpShape->getCustomShapeProperties()->setShapeTypeOverride(true);
|
||||||
mpShape->setServiceName("com.sun.star.text.TextFrame");
|
mpShape->setServiceName("com.sun.star.text.TextFrame");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
BIN
sw/qa/extras/ooxmlexport/data/fdo70942.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/fdo70942.docx
Normal file
Binary file not shown.
@ -2413,6 +2413,15 @@ DECLARE_OOXMLEXPORT_TEST(testFdo73247, "fdo73247.docx")
|
|||||||
"rot", "1969698");
|
"rot", "1969698");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECLARE_OOXMLEXPORT_TEST(testFdo70942, "fdo70942.docx")
|
||||||
|
{
|
||||||
|
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
|
||||||
|
if (!pXmlDoc)
|
||||||
|
return;
|
||||||
|
assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom",
|
||||||
|
"prst", "ellipse");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@ -309,13 +309,12 @@ void DocxAttributeOutput::WriteDMLTextFrame(sw::Frame* pParentFrame)
|
|||||||
uno::Reference< drawing::XShape > xShape( ((SdrObject*)pSdrObj)->getUnoShape(), uno::UNO_QUERY );
|
uno::Reference< drawing::XShape > xShape( ((SdrObject*)pSdrObj)->getUnoShape(), uno::UNO_QUERY );
|
||||||
uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY );
|
uno::Reference< beans::XPropertySet > xPropertySet( xShape, uno::UNO_QUERY );
|
||||||
uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropertySet->getPropertySetInfo();
|
uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropertySet->getPropertySetInfo();
|
||||||
OUString pName = "FrameInteropGrabBag";
|
|
||||||
sal_Int32 nRotation = 0;
|
sal_Int32 nRotation = 0;
|
||||||
|
|
||||||
if ( xPropSetInfo->hasPropertyByName( pName ) )
|
if ( xPropSetInfo->hasPropertyByName( "FrameInteropGrabBag" ) )
|
||||||
{
|
{
|
||||||
uno::Sequence< beans::PropertyValue > propList;
|
uno::Sequence< beans::PropertyValue > propList;
|
||||||
xPropertySet->getPropertyValue( pName ) >>= propList;
|
xPropertySet->getPropertyValue( "FrameInteropGrabBag" ) >>= 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;
|
||||||
@ -352,8 +351,24 @@ void DocxAttributeOutput::WriteDMLTextFrame(sw::Frame* pParentFrame)
|
|||||||
XML_cy, aHeight.getStr(),
|
XML_cy, aHeight.getStr(),
|
||||||
FSEND);
|
FSEND);
|
||||||
m_pSerializer->endElementNS(XML_a, XML_xfrm);
|
m_pSerializer->endElementNS(XML_a, XML_xfrm);
|
||||||
|
OUString shapeType = "rect";
|
||||||
|
if ( xPropSetInfo->hasPropertyByName( "FrameInteropGrabBag" ) )
|
||||||
|
{
|
||||||
|
uno::Sequence< beans::PropertyValue > propList;
|
||||||
|
xPropertySet->getPropertyValue( "FrameInteropGrabBag" ) >>= propList;
|
||||||
|
for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
|
||||||
|
{
|
||||||
|
OUString propName = propList[nProp].Name;
|
||||||
|
if ( propName == "mso-orig-shape-type")
|
||||||
|
{
|
||||||
|
propList[nProp].Value >>= shapeType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_pSerializer->singleElementNS(XML_a, XML_prstGeom,
|
m_pSerializer->singleElementNS(XML_a, XML_prstGeom,
|
||||||
XML_prst, "rect",
|
XML_prst, OUStringToOString( shapeType, RTL_TEXTENCODING_UTF8 ).getStr(),
|
||||||
FSEND);
|
FSEND);
|
||||||
m_bDMLTextFrameSyntax = true;
|
m_bDMLTextFrameSyntax = true;
|
||||||
m_pBodyPrAttrList = m_pSerializer->createAttrList();
|
m_pBodyPrAttrList = m_pSerializer->createAttrList();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user