Kaydet (Commit) acd2c909 authored tarafından Rohit Deshmukh's avatar Rohit Deshmukh Kaydeden (comit) Luboš Luňák

fdo#80897: Preservation of text warp properties.

     - Generic fix for all warp properties

Change-Id: I77c37759aa49706fc3cd1a80770a85face53f0a2
üst c73cb50c
......@@ -166,7 +166,7 @@ public:
void WriteTransformation( const Rectangle& rRectangle,
sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0 );
void WriteText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > rXIface, bool bBodyPr = true, bool bText = true, sal_Int32 nXmlNamespace = 0);
void WriteText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > rXIface, OUString presetWarp, bool bBodyPr = true, bool bText = true, sal_Int32 nXmlNamespace = 0);
void WriteParagraph( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > rParagraph );
void WriteParagraphProperties( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > rParagraph );
void WriteParagraphNumbering( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
......
......@@ -73,6 +73,7 @@ private:
ShapeHashMap maShapeMap;
ShapeHashMap* mpShapeMap;
OUString m_presetWarp;
public:
......
......@@ -151,15 +151,34 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
Sequence< PropertyValue > aSeq = aPropertyMap.makePropertyValueSequence();
aPropSet.setProperty( PROP_CustomShapeGeometry, aSeq );
const OUString sCustomShapeGeometry("CustomShapeGeometry");
uno::Any aGeoPropSet = xPropSet->getPropertyValue( sCustomShapeGeometry );
uno::Sequence< beans::PropertyValue > aGeoPropSeq;
sal_Int32 i, nCount = 0;
if (aGeoPropSet >>= aGeoPropSeq)
{
nCount = aGeoPropSeq.getLength();
for ( i = 0; i < nCount; i++ )
{
const OUString sAdjustmentValues("AdjustmentValues");
if ( aGeoPropSeq[ i ].Name.equals( sAdjustmentValues ) )
{
OUString presetTextWarp;
if ( aGeoPropSeq[ i ].Value >>= presetTextWarp )
{
aPropertyMap.setProperty( PROP_PresetTextWarp, Any( presetTextWarp ) );
}
}
}
}
if ( maAdjustmentGuideList.size() )
{
const OUString sType = "Type";
const OUString sCustomShapeGeometry("CustomShapeGeometry");
uno::Any aGeoPropSet = xPropSet->getPropertyValue( sCustomShapeGeometry );
uno::Sequence< beans::PropertyValue > aGeoPropSeq;
if ( aGeoPropSet >>= aGeoPropSeq )
{
sal_Int32 i, nCount = aGeoPropSeq.getLength();
nCount = aGeoPropSeq.getLength();
for ( i = 0; i < nCount; i++ )
{
const OUString sAdjustmentValues("AdjustmentValues");
......
......@@ -1690,7 +1690,7 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph )
mpFS->endElementNS( XML_a, XML_p );
}
void DrawingML::WriteText( Reference< XInterface > rXIface, bool bBodyPr, bool bText, sal_Int32 nXmlNamespace )
void DrawingML::WriteText( Reference< XInterface > rXIface, OUString presetWarp, bool bBodyPr, bool bText, sal_Int32 nXmlNamespace )
{
Reference< XText > xXText( rXIface, UNO_QUERY );
Reference< XPropertySet > rXPropSet( rXIface, UNO_QUERY );
......@@ -1792,6 +1792,11 @@ void DrawingML::WriteText( Reference< XInterface > rXIface, bool bBodyPr, bool b
XML_anchorCtr, bHorizontalCenter ? "1" : NULL,
XML_vert, sWritingMode,
FSEND );
if( presetWarp != NULL && !presetWarp.isEmpty())
{
mpFS->singleElementNS(XML_a, XML_prstTxWarp, XML_prst,OUStringToOString(presetWarp, RTL_TEXTENCODING_UTF8 ).getStr(),
FSEND );
}
if (GetDocumentType() == DOCUMENT_DOCX)
{
sal_Bool bTextAutoGrowHeight = sal_False;
......
......@@ -328,6 +328,10 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape )
bPredefinedHandlesUsed = false;
// TODO: update nAdjustmentsWhichNeedsToBeConverted here
}
else if ( rProp.Name == "PresetTextWarp" )
{
rProp.Value >>= m_presetWarp;
}
}
}
}
......@@ -822,7 +826,7 @@ ShapeExport& ShapeExport::WriteTextBox( Reference< XInterface > xIface, sal_Int3
if (xPropertySetInfo->hasPropertyByName("TextBox") && xPropertySet->getPropertyValue("TextBox").get<bool>())
{
GetTextExport()->WriteTextBox(uno::Reference<drawing::XShape>(xIface, uno::UNO_QUERY_THROW));
WriteText( xIface, /*bBodyPr=*/true, /*bText=*/false, /*nXmlNamespace=*/nXmlNamespace );
WriteText( xIface, m_presetWarp, /*bBodyPr=*/true, /*bText=*/false, /*nXmlNamespace=*/nXmlNamespace );
return *this;
}
}
......@@ -833,10 +837,10 @@ ShapeExport& ShapeExport::WriteTextBox( Reference< XInterface > xIface, sal_Int3
FSHelperPtr pFS = GetFS();
pFS->startElementNS( nXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_txBody : XML_txbx), FSEND );
WriteText( xIface, /*bBodyPr=*/(GetDocumentType() != DOCUMENT_DOCX), /*bText=*/true );
WriteText( xIface, m_presetWarp, /*bBodyPr=*/(GetDocumentType() != DOCUMENT_DOCX), /*bText=*/true );
pFS->endElementNS( nXmlNamespace, (GetDocumentType() != DOCUMENT_DOCX ? XML_txBody : XML_txbx) );
if (GetDocumentType() == DOCUMENT_DOCX)
WriteText( xIface, /*bBodyPr=*/true, /*bText=*/false, /*nXmlNamespace=*/nXmlNamespace );
WriteText( xIface, m_presetWarp, /*bBodyPr=*/true, /*bText=*/false, /*nXmlNamespace=*/nXmlNamespace );
}
else if (GetDocumentType() == DOCUMENT_DOCX)
mpFS->singleElementNS(nXmlNamespace, XML_bodyPr, FSEND);
......
......@@ -127,6 +127,17 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
}
}
break;
case XML_prstTxWarp:
if( rAttribs.hasAttribute( XML_prst ) )
{
uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
oox::OptValue<OUString> presetShapeName = rAttribs.getString( XML_prst );
OUString preset = presetShapeName.get();
comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
aCustomShapeGeometry["PresetTextWarp"] = uno::makeAny(preset);
xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList()));
}
break;
case XML_txbx:
{
mpShape->getCustomShapeProperties()->setShapeTypeOverride(true);
......
......@@ -366,6 +366,7 @@ PositionX
PositionY
PositiveError
Prefix
PresetTextWarp
PrintAnnotations
PrintBorder
PrintDownFirst
......
......@@ -3397,6 +3397,16 @@ DECLARE_OOXMLEXPORT_TEST(testPlausableBorder, "plausable-border.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
}
DECLARE_OOXMLEXPORT_TEST(testfdo80897 , "fdo80897.docx")
{
xmlDocPtr pXmlDoc = parseExport();
if (!pXmlDoc)
return;
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr/a:prstTxWarp", "prst", "textTriangle");
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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