[Libreoffice-commits] core.git: sw/inc sw/source

Michael Stahl mstahl at redhat.com
Fri Nov 24 16:01:38 UTC 2017


 sw/inc/unodraw.hxx                 |    4 ++--
 sw/source/core/unocore/unodraw.cxx |   23 +++++++++++++++--------
 sw/source/uibase/uno/unotxdoc.cxx  |    4 ++--
 3 files changed, 19 insertions(+), 12 deletions(-)

New commits:
commit 67d11883740da4ef242d0002acde83f67d4b327a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Nov 24 16:40:56 2017 +0100

    tdf#113938 sw: apply new default vertical orientation only during import
    
    Commit c79467ba954987f1d239c594c1e1b3af3f5515f6 changed the default
    vertical orientation for shapes in Writer; it turns out that at
    least one extension assumes the previous default.
    
    Tweak SwXShape so that the new default is used for shapes that are
    created during file import, otherwise the old default.
    
    Change-Id: I1dc4d3342dd53ce8e0857984456717b8ffcc97c7

diff --git a/sw/inc/unodraw.hxx b/sw/inc/unodraw.hxx
index ec85124980f7..6b35f6468b4a 100644
--- a/sw/inc/unodraw.hxx
+++ b/sw/inc/unodraw.hxx
@@ -215,7 +215,7 @@ protected:
     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
 
 public:
-    SwXShape(css::uno::Reference< css::uno::XInterface > & xShape);
+    SwXShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const* pDoc);
 
     static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
@@ -275,7 +275,7 @@ class SwXGroupShape :
 protected:
     virtual ~SwXGroupShape() override;
 public:
-    SwXGroupShape(css::uno::Reference< css::uno::XInterface > & xShape);
+    SwXGroupShape(css::uno::Reference<css::uno::XInterface> & xShape, SwDoc const* pDoc);
 
     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
     virtual void SAL_CALL acquire(  ) throw() override;
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 3d080b56391a..c0a5f75b9fb1 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -73,6 +73,7 @@ using namespace ::com::sun::star;
 
 class SwShapeDescriptor_Impl
 {
+    bool m_isInReading;
     SwFormatHoriOrient*    pHOrient;
     SwFormatVertOrient*    pVOrient;
     SwFormatAnchor*        pAnchor;
@@ -95,7 +96,9 @@ public:
     bool    bInitializedPropertyNotifier;
 
 public:
-    SwShapeDescriptor_Impl() :
+    SwShapeDescriptor_Impl(SwDoc const*const pDoc)
+        : m_isInReading(pDoc && pDoc->IsInReading())
+        ,
      // #i32349# - no defaults, in order to determine on
      // adding a shape, if positioning attributes are set or not.
      pHOrient( nullptr ),
@@ -149,7 +152,8 @@ public:
         {
             if(bCreate && !pVOrient)
             {
-                if (!GetAnchor(true) || pAnchor->GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+                if (m_isInReading && // tdf#113938 extensions might rely on old default
+                    (!GetAnchor(true) || pAnchor->GetAnchorId() == RndStdIds::FLY_AS_CHAR))
                 {   // for as-char, NONE ("from-top") is not a good default
                     pVOrient = new SwFormatVertOrient(0, text::VertOrientation::TOP, text::RelOrientation::FRAME);
                 }
@@ -381,9 +385,9 @@ uno::Reference< drawing::XShape > SwFmDrawPage::CreateShape( SdrObject *pObj ) c
             xRet = nullptr;
             uno::Reference< beans::XPropertySet >  xPrSet;
             if ( pObj->IsGroupObject() && (!pObj->Is3DObj() || (dynamic_cast<const E3dScene*>( pObj) !=  nullptr)) )
-                xPrSet = new SwXGroupShape( xCreate );
+                xPrSet = new SwXGroupShape(xCreate, nullptr);
             else
-                xPrSet = new SwXShape( xCreate );
+                xPrSet = new SwXShape(xCreate, nullptr);
             xRet.set(xPrSet, uno::UNO_QUERY);
         }
     }
@@ -900,10 +904,12 @@ namespace
     }
 }
 
-SwXShape::SwXShape(uno::Reference< uno::XInterface > & xShape) :
+SwXShape::SwXShape(uno::Reference<uno::XInterface> & xShape,
+                   SwDoc const*const pDoc)
+    :
     m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE)),
     m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE)),
-    pImpl(new SwShapeDescriptor_Impl()),
+    pImpl(new SwShapeDescriptor_Impl(pDoc)),
     m_bDescriptor(true)
 {
     if(!xShape.is())  // default Ctor
@@ -2716,8 +2722,9 @@ css::drawing::PolyPolygonBezierCoords SwXShape::ConvertPolyPolygonBezierToLayout
     return aConvertedPath;
 }
 
-SwXGroupShape::SwXGroupShape(uno::Reference< XInterface > & xShape) :
-        SwXShape(xShape)
+SwXGroupShape::SwXGroupShape(uno::Reference<XInterface> & xShape,
+                             SwDoc const*const pDoc)
+    : SwXShape(xShape, pDoc)
 {
 #if OSL_DEBUG_LEVEL > 0
     uno::Reference<XShapes> xShapes(xShapeAgg, uno::UNO_QUERY);
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 0d82750de8ce..ce4988f6adc0 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -1680,11 +1680,11 @@ css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
     if (rServiceName == "com.sun.star.drawing.GroupShape"
         || rServiceName == "com.sun.star.drawing.Shape3DSceneObject")
     {
-        return *new SwXGroupShape(xTmp);
+        return *new SwXGroupShape(xTmp, pDocShell->GetDoc());
     }
     if (rServiceName.startsWith("com.sun.star.drawing."))
     {
-        return *new SwXShape(xTmp);
+        return *new SwXShape(xTmp, pDocShell->GetDoc());
     }
     return xTmp;
 }


More information about the Libreoffice-commits mailing list