include/oox/drawingml/shape.hxx             |    3 +++
 oox/source/drawingml/shape.cxx              |    2 ++
 oox/source/drawingml/shapecontext.cxx       |    2 ++
 oox/source/ppt/pptshape.cxx                 |   10 ++++++++--
 sd/qa/unit/data/pptx/shape-master-text.pptx |binary
 sd/qa/unit/import-tests2.cxx                |   13 +++++++++++++
 6 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit e63a9553c022a9976d59113938df068f9d2b5d6c
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Fri Jul 28 12:16:36 2023 +0200
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Mon Jul 31 18:32:36 2023 +0200

    pptx: import ellipse shape correctly
    
    Preset geometry "ellipse" was ignored:
    <a:prstGeom prst="ellipse">
    
    Don't change service name to com.sun.star.presentation.OutlinerShape
    it should stay CustomShape to be correctly shown as an ellipse.
    
    Added next case: XML_body subtype in Layout and Slide mode.
    
    This is continuation for:
    commit 6df267780c4d41b41101c1be0a954b2f16ee8012
    tdf#132557: PPTX import: Workaround for slide footer shape presets
    
    Signed-off-by: Szymon Kłos <szymon.k...@collabora.com>
    Change-Id: Ifb914c58203a1ad533f9cc9b1857a48983354de6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155015
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Henry Castro <hcas...@collabora.com>

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 0baf47e49815..2d0924406536 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -335,8 +335,10 @@ void PPTShape::addShape(
         // Need to use service name css.drawing.CustomShape if they have a non 
default shape.
         // This workaround has the drawback of them not really being processed 
as placeholders
         // so it is only done for slide footers...
-        if ((mnSubType == XML_sldNum || mnSubType == XML_dt || mnSubType == 
XML_ftr)
-            && meShapeLocation == Slide && 
!mpCustomShapePropertiesPtr->representsDefaultShape())
+        bool convertInSlideMode = meShapeLocation == Slide &&
+            (mnSubType == XML_sldNum || mnSubType == XML_dt || mnSubType == 
XML_ftr || mnSubType == XML_body);
+        bool convertInLayoutMode = meShapeLocation == Layout && (mnSubType == 
XML_body);
+        if ((convertInSlideMode || convertInLayoutMode) && 
!mpCustomShapePropertiesPtr->representsDefaultShape())
         {
             sServiceName = "com.sun.star.drawing.CustomShape";
         }
commit 1eed2e57b1848e8f129e98d1bbdb5f8851740d6b
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Thu Jul 27 08:43:59 2023 +0200
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Mon Jul 31 18:32:27 2023 +0200

    pptx: import shape text from master page
    
    If shape has custom text defined in master page
    but no text itself - don't prefer placeholder text
    but text from master page.
    
    Change-Id: Id4f7aeca0e74ecd8565905cd656a182c1195fa30
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154980
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Henry Castro <hcas...@collabora.com>

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 72ce51ef6476..b5bf52ff0a5b 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -236,6 +236,8 @@ public:
     void                setTxbxHasLinkedTxtBox( const bool rhs){ 
mbHasLinkedTxbx = rhs; };
     const LinkedTxbxAttr&     getLinkedTxbxAttributes() const { return 
maLinkedTxbxAttr; };
     bool                isLinkedTxbx() const { return mbHasLinkedTxbx; };
+    void                setHasCustomPrompt(bool bValue) { mbHasCustomPrompt = 
bValue; }
+    bool                hasCustomPrompt() { return mbHasCustomPrompt; }
 
     void setZOrder(sal_Int32 nZOrder) { mnZOrder = nZOrder; }
 
@@ -391,6 +393,7 @@ private:
     bool mbTextBox; ///< This shape has a textbox.
     LinkedTxbxAttr                  maLinkedTxbxAttr;
     bool                            mbHasLinkedTxbx; // this text box has 
linked text box ?
+    bool                            mbHasCustomPrompt; // indicates that it's 
not a generic placeholder
 
     css::uno::Sequence<css::beans::PropertyValue> maDiagramDoms;
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 497fd57db922..039b51977850 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -149,6 +149,7 @@ Shape::Shape( const char* pServiceName, bool bDefaultHeight 
)
 , mbWps( false )
 , mbTextBox( false )
 , mbHasLinkedTxbx( false )
+, mbHasCustomPrompt( false )
 , maDiagramDoms( 0 )
 , mpDiagramHelper( nullptr )
 {
@@ -193,6 +194,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
 , mbWps( pSourceShape->mbWps )
 , mbTextBox( pSourceShape->mbTextBox )
 , mbHasLinkedTxbx(false)
+, mbHasCustomPrompt( pSourceShape->mbHasCustomPrompt )
 , maDiagramDoms( pSourceShape->maDiagramDoms )
 , mnZOrder(pSourceShape->mnZOrder)
 , mnZOrderOff(pSourceShape->mnZOrderOff)
diff --git a/oox/source/drawingml/shapecontext.cxx 
b/oox/source/drawingml/shapecontext.cxx
index 3ac32abd11aa..55c6639d8fe4 100644
--- a/oox/source/drawingml/shapecontext.cxx
+++ b/oox/source/drawingml/shapecontext.cxx
@@ -81,6 +81,8 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 
aElementToken, const
         mpShapePtr->setSubType( rAttribs.getToken( XML_type, XML_obj ) );
         if( rAttribs.hasAttribute( XML_idx ) )
             mpShapePtr->setSubTypeIndex( rAttribs.getInteger( XML_idx, 0 ) );
+        if( rAttribs.hasAttribute( XML_hasCustomPrompt ) )
+            mpShapePtr->setHasCustomPrompt( rAttribs.getBool( 
XML_hasCustomPrompt, false ) );
         break;
     // nvSpPr CT_ShapeNonVisual end
 
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index be7046c7498e..0baf47e49815 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -454,6 +454,10 @@ void PPTShape::addShape(
                 Reference < XText > xText(mxShape, UNO_QUERY);
                 if (xText.is())
                 {
+                    if (mpPlaceholder && mpPlaceholder->getTextBody() && 
!mpPlaceholder->getTextBody()->isEmpty()
+                        && mpPlaceholder->hasCustomPrompt())
+                        
xText->setString(mpPlaceholder->getTextBody()->toString());
+
                     TextCharacterProperties aCharStyleProperties;
                     getTextBody()->ApplyStyleEmpty(rFilterBase, xText, 
aCharStyleProperties, mpMasterTextListStyle);
                 }
diff --git a/sd/qa/unit/data/pptx/shape-master-text.pptx 
b/sd/qa/unit/data/pptx/shape-master-text.pptx
new file mode 100644
index 000000000000..ca056b852d3a
Binary files /dev/null and b/sd/qa/unit/data/pptx/shape-master-text.pptx differ
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index e3fe25a955ac..1168fdabeb55 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -147,6 +147,7 @@ public:
     void testTdf149961AutofitIndentation();
     void testTdf149588TransparentSolidFill();
     void testOverflowBehaviorClip();
+    void testShapeMasterText();
 
     CPPUNIT_TEST_SUITE(SdImportTest2);
 
@@ -227,6 +228,7 @@ public:
     CPPUNIT_TEST(testTdf149961AutofitIndentation);
     CPPUNIT_TEST(testTdf149588TransparentSolidFill);
     CPPUNIT_TEST(testOverflowBehaviorClip);
+    CPPUNIT_TEST(testShapeMasterText);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -2051,6 +2053,17 @@ void SdImportTest2::testOverflowBehaviorClip()
     }
 }
 
+void SdImportTest2::testShapeMasterText()
+{
+    createSdImpressDoc("pptx/shape-master-text.pptx");
+    uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
+
+    uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, 
xShape));
+
+    uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
+    CPPUNIT_ASSERT_EQUAL(OUString("Custom"), xRun->getString());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2);
 CPPUNIT_PLUGIN_IMPLEMENT();
 

Reply via email to