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

Caolán McNamara caolanm at redhat.com
Tue Feb 10 08:28:14 PST 2015


 sw/source/core/docnode/swbaslnk.cxx |   46 +++++++++++++++++++++++-------------
 sw/source/filter/html/htmlgrin.cxx  |   11 ++++++++
 vcl/source/window/builder.cxx       |    1 
 3 files changed, 41 insertions(+), 17 deletions(-)

New commits:
commit 233da237ad4b593c945903c3b32185a540025516
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Feb 10 16:05:58 2015 +0000

    Resolves: tdf#87083 images in help html stuck at default placeholder size
    
    regression from the SwapIn work.
    
    The graphic size during SetGrfFlySize appears to assume its the pre-swapped in
    size, i.e. the old 0 by 0 "size is not set" for an html image used to be the
    value used here. So get that value (and update it if necessary) before updating
    the image data and pass that to SetGrfFlySize
    
    Without the swap-in in the html filter the data gets swapped in during the
    initial draw of the image which is too late to update the image size, so
    restore the equivalent of that swap-in via GetTwipSize
    
    commit 61a5abd5fab308c9e6580e752fa846f5bf0d7e51
    Author: Zolnai Tamás <tamas.zolnai at collabora.com>
    Date:   Fri Nov 7 10:43:34 2014 +0100
    
        Make SwGrfNode swapping methods private
    
        Change the filter test accordingly.
    
        Change-Id: Ide3043f2f245c097a7b4c07ba2e0713510296b3e
    
    Change-Id: I0afe244f79d8628236b1e552036587a2b4540a76

diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index f52e285..85ec6f8 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -53,7 +53,7 @@
 
 using namespace com::sun::star;
 
-static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd );
+static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd, const Size &rOrigGrfSize );
 
 TYPEINIT1( SwBaseLink, ::sfx2::SvBaseLink );
 
@@ -103,6 +103,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
     {
         // Only a status change - serve Events?
         OUString sState;
+
         if( rValue.hasValue() && ( rValue >>= sState ))
         {
             sal_uInt16 nEvent = 0;
@@ -128,12 +129,15 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
     bool bGraphicArrived = false;
     bool bGraphicPieceArrived = false;
     bool bDontNotify = false;
-    Size aGrfSz, aFrmFmtSz;
+    Size aGrfSz, aOldSz, aFrmFmtSz;
+
+    SwGrfNode* pSwGrfNode = NULL;
 
-    if( pCntntNode->IsGrfNode() )
+    if (pCntntNode->IsGrfNode())
     {
-        SwGrfNode* pSwGrfNode = pCntntNode->GetGrfNode();
-        OSL_ENSURE(pSwGrfNode, "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)");
+        pSwGrfNode = pCntntNode->GetGrfNode();
+        assert(pSwGrfNode && "Error, pSwGrfNode expected when node answers IsGrfNode() with true (!)");
+        aOldSz = pSwGrfNode->GetTwipSize();
         const GraphicObject& rGrfObj = pSwGrfNode->GetGrfObj();
 
         bDontNotify = pSwGrfNode->IsFrameInPaint();
@@ -143,6 +147,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
         pSwGrfNode->SetGraphicArrived( bGraphicArrived );
 
         Graphic aGrf;
+
         if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGrf ) &&
             ( GRAPHIC_DEFAULT != aGrf.GetType() ||
               GRAPHIC_DEFAULT != rGrfObj.GetType() ) )
@@ -159,10 +164,9 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
             {
                 aFrmFmtSz = aGrfSz;
             }
-            Size aSz( pSwGrfNode->GetTwipSize() );
 
             if( bGraphicPieceArrived && GRAPHIC_DEFAULT != aGrf.GetType() &&
-                ( !aSz.Width() || !aSz.Height() ) )
+                ( !aOldSz.Width() || !aOldSz.Height() ) )
             {
                 // If only a part arrives, but the size is not set
                 // we need to go through bGraphicArrived down there.
@@ -181,9 +185,12 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
             {
                 // Always use the correct graphic size
                 if( aGrfSz.Height() && aGrfSz.Width() &&
-                    aSz.Height() && aSz.Width() &&
-                    aGrfSz != aSz )
+                    aOldSz.Height() && aOldSz.Width() &&
+                    aGrfSz != aOldSz )
+                {
                     pSwGrfNode->SetTwipSize( aGrfSz );
+                    aOldSz = aGrfSz;
+                }
             }
         }
         if ( bUpdate && !bGraphicArrived && !bGraphicPieceArrived )
@@ -244,6 +251,8 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
                         ( !bSwapIn ||
                             GRAPHIC_DEFAULT == pGrfNd->GetGrfObj().GetType()))
                     {
+                        Size aPreArriveSize(pGrfNd->GetTwipSize());
+
                         pBLink->bIgnoreDataChanged = false;
                         pBLink->DataChanged( rMimeType, rValue );
                         pBLink->bIgnoreDataChanged = true;
@@ -252,13 +261,18 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
                                                     IsGraphicArrived() );
 
                         // Adjust the Fly's graphic
-                        if( !::SetGrfFlySize( aGrfSz, aFrmFmtSz, pGrfNd ) )
+                        if (!::SetGrfFlySize(aGrfSz, aFrmFmtSz, pGrfNd, aPreArriveSize))
                             ::lcl_CallModify( *pGrfNd, aMsgHint );
                     }
-                    else if( pBLink == this &&
-                            !::SetGrfFlySize( aGrfSz, aFrmFmtSz, pGrfNd ) )
-                        // Adjust the Fly's graphic
-                        ::lcl_CallModify( *pGrfNd, aMsgHint );
+                    else if (pBLink == this)
+                    {
+                        assert(pGrfNd == pSwGrfNode && "fdo#87083 needs a different fix");
+                        if (!::SetGrfFlySize(aGrfSz, aFrmFmtSz, pGrfNd, aOldSz))
+                        {
+                            // Adjust the Fly's graphic
+                            ::lcl_CallModify( *pGrfNd, aMsgHint );
+                        }
+                    }
                 }
             }
 
@@ -286,7 +300,7 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
     return SUCCESS;
 }
 
-static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd )
+static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd, const Size& rOrigGrfSize )
 {
     bool bRet = false;
     SwViewShell *pSh = pGrfNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
@@ -294,7 +308,7 @@ static bool SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pG
     if ( pGrfNd->GetDoc()->GetEditShell() )
         pCurr = new CurrShell( pSh );
 
-    Size aSz = pGrfNd->GetTwipSize();
+    Size aSz = rOrigGrfSize;
     if ( !(aSz.Width() && aSz.Height()) &&
             rGrfSz.Width() && rGrfSz.Height() )
     {
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index 0ca3373..cb4db4c 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -597,6 +597,7 @@ IMAGE_SETEVENT:
     Size aGrfSz( 0, 0 );
     bool bSetTwipSize = true;       // Twip-Size am Node setzen?
     bool bChangeFrmSize = false;    // Frame-Format nachtraeglich anpassen?
+    bool bRequestGrfNow = false;
     bool bSetScaleImageMap = false;
     sal_uInt8 nPrcWidth = 0, nPrcHeight = 0;
 
@@ -608,6 +609,7 @@ IMAGE_SETEVENT:
         // Tabelle layoutet wird.
         if( pTable!=0 && !nWidth )
         {
+            bRequestGrfNow = true;
             IncGrfsThatResizeTable();
         }
 
@@ -811,6 +813,15 @@ IMAGE_SETEVENT:
     if( !aMacroItem.GetMacroTable().empty() )
         pFlyFmt->SetFmtAttr( aMacroItem );
 
+    // tdf#87083 If the graphic has not been loaded yet, then load it now.
+    // Otherwise it may be loaded during the first paint of the object and it
+    // will be too late to adapt the size of the graphic at that point.
+    if (bRequestGrfNow && pGrfNd)
+    {
+        Size aUpdatedSize = pGrfNd->GetTwipSize();  //trigger a swap-in
+        SAL_WARN_IF(!aUpdatedSize.Width() || !aUpdatedSize.Width(), "sw.html", "html image with no width or height");
+    }
+
     // Ggf. Frames anlegen und Auto-gebundenen Rahmen registrieren
     RegisterFlyFrm( pFlyFmt );
 
commit 8c8e536c2c36cdf31494e7b9b9c0871169ed043c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Feb 10 13:35:17 2015 +0000

    coverity#1267630 Logically dead code
    
    Change-Id: Idf857f5681766923675bdc210c02a796e0f58024

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 80e1478..5a6475f 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -2031,7 +2031,6 @@ void VclBuilder::handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader)
                         else if (sInternalChild.startsWith("action_area") || sInternalChild.startsWith("messagedialog-action_area"))
                         {
                             vcl::Window *pContentArea = pCurrentChild->GetParent();
-                            assert(pContentArea && pContentArea->GetType() == WINDOW_CONTAINER);
                             if (Dialog *pBoxParent = dynamic_cast<Dialog*>(pContentArea ? pContentArea->GetParent() : NULL))
                             {
                                 pBoxParent->set_action_area(static_cast<VclButtonBox*>(pCurrentChild));


More information about the Libreoffice-commits mailing list