[Libreoffice-commits] core.git: include/oox oox/source sw/qa

Rohit Deshmukh rohit.deshmukh at synerzip.com
Mon Jul 21 07:29:42 PDT 2014


 include/oox/export/drawingml.hxx               |    2 -
 include/oox/export/shapes.hxx                  |    1 
 oox/source/drawingml/customshapeproperties.cxx |   27 +++++++++++++++++++++----
 oox/source/export/drawingml.cxx                |    7 +++++-
 oox/source/export/shapes.cxx                   |   10 ++++++---
 oox/source/shape/WpsContext.cxx                |   11 ++++++++++
 oox/source/token/properties.txt                |    1 
 sw/qa/extras/ooxmlexport/data/fdo80897.docx    |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx       |   10 +++++++++
 9 files changed, 60 insertions(+), 9 deletions(-)

New commits:
commit acd2c90978052723475a41144dd5d92090fbf6b4
Author: Rohit Deshmukh <rohit.deshmukh at synerzip.com>
Date:   Fri Jul 18 12:27:25 2014 +0530

    fdo#80897: Preservation of text warp properties.
    
         - Generic fix for all warp properties
    
    Change-Id: I77c37759aa49706fc3cd1a80770a85face53f0a2

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index bf46326..db685b1 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -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,
diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx
index c7f8d15..925ba72 100644
--- a/include/oox/export/shapes.hxx
+++ b/include/oox/export/shapes.hxx
@@ -73,6 +73,7 @@ private:
 
     ShapeHashMap maShapeMap;
     ShapeHashMap* mpShapeMap;
+    OUString m_presetWarp;
 
 public:
 
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index 5dcc122..efaddba 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -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");
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 75b6cfe..a303365 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -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;
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 02b005b..4389e3e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -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);
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index d79d1c2..89ed320 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -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);
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 44c7597..4735ccf 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -366,6 +366,7 @@ PositionX
 PositionY
 PositiveError
 Prefix
+PresetTextWarp
 PrintAnnotations
 PrintBorder
 PrintDownFirst
diff --git a/sw/qa/extras/ooxmlexport/data/fdo80897.docx b/sw/qa/extras/ooxmlexport/data/fdo80897.docx
new file mode 100755
index 0000000..2f0957e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo80897.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 87fdbd6..02a4d4e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -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: */


More information about the Libreoffice-commits mailing list