include/svx/svdoashp.hxx                 |    7 ++
 svx/source/svdraw/svdoashp.cxx           |   74 ++++++++++++++++++-------------
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |    2 
 sw/source/core/layout/fly.cxx            |   17 +++++++
 4 files changed, 70 insertions(+), 30 deletions(-)

New commits:
commit c00d81612e128b74c23c95e011b482dc3918fca4
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Fri Jun 27 13:47:11 2014 +0200

    SwFlyFrm::Format: inform our custom shape about size changes if needed
    
    This adds support for the following scenario:
    
    - Shape has no editeng text, but a textbox
    - Shape has automatic size
    - User edits the fly frame (serving as the textbox of the draw shape)
      and expects that both the shape and the textbox gets resized
      accordingly
    
    Note that this way we can signal our size request for the textbox, and
    the custom shape takes care of resizing the shape in a way, so that
    after the resize, the text area counted from the custom shape geometry
    will be exactly what we requested. (I.e. just asking the shape to have
    the same size as the fly would work for rectangle, but not e.g. for
    triangles.)
    
    Change-Id: I1e7efd00db52cf28481f6821ea6949f748b855e7

diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 306875b..c87d0cb 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -41,6 +41,7 @@
 #include <ndole.hxx>
 #include <swtable.hxx>
 #include <svx/svdpage.hxx>
+#include <svx/svdoashp.hxx>
 #include "layouter.hxx"
 #include "pagefrm.hxx"
 #include "rootfrm.hxx"
@@ -59,6 +60,7 @@
 #include <vcl/svapp.hxx>
 #include "switerator.hxx"
 #include <IDocumentSettingAccess.hxx>
+#include <textboxhelper.hxx>
 
 using namespace ::com::sun::star;
 
@@ -1275,6 +1277,21 @@ void SwFlyFrm::Format( const SwBorderAttrs *pAttrs )
                 InvalidateObjRectWithSpaces();
             }
             mbValidSize = true;
+
+            std::map<SwFrmFmt*, SwFrmFmt*> aShapes = 
SwTextBoxHelper::findShapes(GetFmt()->GetDoc());
+            if (aShapes.find(GetFmt()) != aShapes.end())
+            {
+                // This fly is a textbox of a draw shape.
+                SdrObject* pShape = aShapes[GetFmt()]->FindSdrObject();
+                if (SdrObjCustomShape* pCustomShape = 
PTR_CAST(SdrObjCustomShape, pShape))
+                {
+                    // The shape is a customshape: then inform it about the 
calculated fly size.
+                    Size aSize((Frm().*fnRect->fnGetWidth)(), 
(Frm().*fnRect->fnGetHeight)());
+                    pCustomShape->SuggestTextFrameSize(aSize);
+                    // Do the calculations normally done after touching 
editeng text of the shape.
+                    pCustomShape->NbcSetOutlinerParaObjectForText(0, 0);
+                }
+            }
         }
         else
         {
commit 4f33a0961d69feba72806d105da65a4dc841ca5e
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Fri Jun 27 13:43:13 2014 +0200

    SdrObjCustomShape::AdjustTextFrameWidthAndHeight: allow external text
    
    So that in Writer, in case we're using Writer TextFrames to handle the
    content of a shape, it's still possible to inform the custom shape about
    the automatic size of the text, just like when native editeng text is
    used.
    
    Change-Id: I2534b942a9b2d62d7aa009ffbfa8d76feb011f92

diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx
index 1b7adf1..e5b3e8f 100644
--- a/include/svx/svdoashp.hxx
+++ b/include/svx/svdoashp.hxx
@@ -136,6 +136,7 @@ protected:
     virtual void AdaptTextMinSize() SAL_OVERRIDE;
 
     OUString      aName;
+    Size          m_aSuggestedTextFrameSize;
 
 public:
 
@@ -212,6 +213,12 @@ public:
     virtual bool MovCreate(SdrDragStat& rStat) SAL_OVERRIDE; // #i37448#
     virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
 
+    /**
+     * Allows suggesting the text frame size: in case the application has its
+     * own text associated to the shape, instead of using the shape's editeng
+     * text.
+     */
+    void SuggestTextFrameSize(Size aSuggestedTextFrameSize);
     virtual bool AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt = 
true, bool bWdt = true) const SAL_OVERRIDE;
     virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt 
= true) SAL_OVERRIDE;
     virtual bool AdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = 
true) SAL_OVERRIDE;
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 8205121..26c563c 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -2312,9 +2312,17 @@ void SdrObjCustomShape::SetVerticalWriting( bool 
bVertical )
         }
     }
 }
+
+void SdrObjCustomShape::SuggestTextFrameSize(Size aSuggestedTextFrameSize)
+{
+    m_aSuggestedTextFrameSize = aSuggestedTextFrameSize;
+}
+
 bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool 
bHgt, bool bWdt) const
 {
-     if ( pModel && HasText() && !rR.IsEmpty() )
+    // Either we have text or the application has native text and suggested 
its size to us.
+    bool bHasText = HasText() || (m_aSuggestedTextFrameSize.Width() != 0 && 
m_aSuggestedTextFrameSize.Height() != 0);
+    if ( pModel && bHasText && !rR.IsEmpty() )
     {
         bool bWdtGrow=bWdt && IsAutoGrowWidth();
         bool bHgtGrow=bHgt && IsAutoGrowHeight();
@@ -2353,41 +2361,49 @@ bool 
SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt,
             if ( aSiz.Height() < 2 )
                 aSiz.Height() = 2; // minimum size=2
 
-            if(pEdtOutl)
+            if (HasText())
             {
-                pEdtOutl->SetMaxAutoPaperSize( aSiz );
-                if (bWdtGrow)
+                if(pEdtOutl)
                 {
-                    Size aSiz2(pEdtOutl->CalcTextSize());
-                    nWdt=aSiz2.Width()+1; // a little more tolerance
-                    if (bHgtGrow) nHgt=aSiz2.Height()+1; // a little more 
tolerance
-                } else
+                    pEdtOutl->SetMaxAutoPaperSize( aSiz );
+                    if (bWdtGrow)
+                    {
+                        Size aSiz2(pEdtOutl->CalcTextSize());
+                        nWdt=aSiz2.Width()+1; // a little more tolerance
+                        if (bHgtGrow) nHgt=aSiz2.Height()+1; // a little more 
tolerance
+                    } else
+                    {
+                        nHgt=pEdtOutl->GetTextHeight()+1; // a little more 
tolerance
+                    }
+                }
+                else
                 {
-                    nHgt=pEdtOutl->GetTextHeight()+1; // a little more 
tolerance
+                    Outliner& rOutliner=ImpGetDrawOutliner();
+                    rOutliner.SetPaperSize(aSiz);
+                    rOutliner.SetUpdateMode(true);
+                    // TODO: add the optimization with bPortionInfoChecked 
again.
+                    OutlinerParaObject* pOutlinerParaObject = 
GetOutlinerParaObject();
+                    if( pOutlinerParaObject != NULL )
+                    {
+                        rOutliner.SetText(*pOutlinerParaObject);
+                        rOutliner.SetFixedCellHeight(((const 
SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
+                    }
+                    if ( bWdtGrow )
+                    {
+                        Size aSiz2(rOutliner.CalcTextSize());
+                        nWdt=aSiz2.Width()+1; // a little more tolerance
+                        if ( bHgtGrow )
+                            nHgt=aSiz2.Height()+1; // a little more tolerance
+                    }
+                    else
+                        nHgt = rOutliner.GetTextHeight()+1; // a little more 
tolerance
+                    rOutliner.Clear();
                 }
             }
             else
             {
-                Outliner& rOutliner=ImpGetDrawOutliner();
-                rOutliner.SetPaperSize(aSiz);
-                rOutliner.SetUpdateMode(true);
-                // TODO: add the optimization with bPortionInfoChecked again.
-                OutlinerParaObject* pOutlinerParaObject = 
GetOutlinerParaObject();
-                if( pOutlinerParaObject != NULL )
-                {
-                    rOutliner.SetText(*pOutlinerParaObject);
-                    rOutliner.SetFixedCellHeight(((const 
SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
-                }
-                if ( bWdtGrow )
-                {
-                    Size aSiz2(rOutliner.CalcTextSize());
-                    nWdt=aSiz2.Width()+1; // a little more tolerance
-                    if ( bHgtGrow )
-                        nHgt=aSiz2.Height()+1; // a little more tolerance
-                }
-                else
-                    nHgt = rOutliner.GetTextHeight()+1; // a little more 
tolerance
-                rOutliner.Clear();
+                nHgt = m_aSuggestedTextFrameSize.Height();
+                nWdt = m_aSuggestedTextFrameSize.Width();
             }
             if ( nWdt < nMinWdt )
                 nWdt = nMinWdt;
commit f2ad42f97b1f9534da9be96b5a07255434890187
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Fri Jun 27 13:26:52 2014 +0200

    CppunitTest_sw_ooxmlimport: use exact value from bugdoc in testMceNested()
    
    Bugdoc has 2514600 EMU's as the vertical position, use that, and allow
    larger values, as originally this was 0, and we have additional 2 mm100,
    probably due to rounding errors.
    
    Change-Id: I7495a0f9e913332a24d0a830b0252ecb6a39d806

diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index a0697fe..b209755 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1708,7 +1708,7 @@ DECLARE_OOXMLIMPORT_TEST(testMceNested, "mce-nested.docx")
     // Vertical position of the shape was incorrect due to incorrect nested 
mce handling.
     uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
     // positionV's posOffset from the bugdoc, was 0.
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(6987), getProperty<sal_Int32>(xShape, 
"VertOrientPosition"));
+    CPPUNIT_ASSERT(6985 <= getProperty<sal_Int32>(xShape, 
"VertOrientPosition"));
     // This was -1 (default), make sure the background color is set.
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), getProperty<sal_Int32>(xShape, 
"FillColor"));
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to