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

Hrishabh rajputhrishabh at gmail.com
Fri Apr 13 12:22:32 UTC 2018


 sfx2/source/appl/workwin.cxx    |   23 +++++-
 sfx2/source/inc/workwin.hxx     |    2 
 sw/inc/editsh.hxx               |    3 
 sw/source/core/edit/edlingu.cxx |  150 ++++++++++++++--------------------------
 4 files changed, 83 insertions(+), 95 deletions(-)

New commits:
commit f17a04df424dac553195c1922a4e4aa1f4ad5b9d
Author: Hrishabh <rajputhrishabh at gmail.com>
Date:   Sat Mar 10 14:13:06 2018 +0530

    tdf#39593 fixed copy paste code in sw edlingu.cxx
    
    Change-Id: I5d4909e7c16aee488971b4793b20a5cf3ae6bddf
    Reviewed-on: https://gerrit.libreoffice.org/51173
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 8b9e5662fbe6..3a7ecbd9e030 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -791,6 +791,9 @@ public:
     /// Is hyphenation active somewhere else?
     static bool HasHyphIter();
 
+    void HandleCorrectionError( const OUString aText, SwPosition aPos,
+            sal_Int32 nBegin, sal_Int32 nLen, SwPaM* pCursor,
+            const Point* pPt, SwRect& rSelectRect );
     css::uno::Reference< css::linguistic2::XSpellAlternatives >
             GetCorrection( const Point* pPt, SwRect& rSelectRect );
 
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index c4f602ce0e36..74401bb03f05 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -815,6 +815,60 @@ void SwEditShell::HyphIgnore()
     g_pHyphIter->ShowSelection();
 }
 
+void SwEditShell::HandleCorrectionError(
+    const OUString aText, SwPosition aPos, sal_Int32 nBegin,
+    sal_Int32 nLen, SwPaM* pCursor,
+    const Point* pPt, SwRect& rSelectRect )
+{
+    // save the start and end positions of the line and the starting point
+    Push();
+    LeftMargin();
+    const sal_Int32 nLineStart = GetCursor()->GetPoint()->nContent.GetIndex();
+    RightMargin();
+    const sal_Int32 nLineEnd = GetCursor()->GetPoint()->nContent.GetIndex();
+    Pop(PopMode::DeleteCurrent);
+
+    // make sure the selection build later from the data below does
+    // not "in word" character to the left and right in order to
+    // preserve those. Therefore count those "in words" in order to
+    // modify the selection accordingly.
+    const sal_Unicode* pChar = aText.getStr();
+    sal_Int32 nLeft = 0;
+    while (*pChar++ == CH_TXTATR_INWORD)
+        ++nLeft;
+    pChar = aText.getLength() ? aText.getStr() + aText.getLength() - 1 : nullptr;
+    sal_Int32 nRight = 0;
+    while (pChar && *pChar-- == CH_TXTATR_INWORD)
+        ++nRight;
+
+    aPos.nContent = nBegin + nLeft;
+    pCursor = GetCursor();
+    *pCursor->GetPoint() = aPos;
+    pCursor->SetMark();
+    ExtendSelection( true, nLen - nLeft - nRight );
+    // don't determine the rectangle in the current line
+    const sal_Int32 nWordStart = (nBegin + nLeft) < nLineStart ? nLineStart : nBegin + nLeft;
+    // take one less than the line end - otherwise the next line would be calculated
+    const sal_Int32 nWordEnd = (nBegin + nLen - nLeft - nRight) > nLineEnd
+                            ? nLineEnd : (nBegin + nLen - nLeft - nRight);
+    Push();
+    pCursor->DeleteMark();
+    SwIndex& rContent = GetCursor()->GetPoint()->nContent;
+    rContent = nWordStart;
+    SwRect aStartRect;
+    SwCursorMoveState aState;
+    aState.m_bRealWidth = true;
+    SwContentNode* pContentNode = pCursor->GetContentNode();
+    SwContentFrame *pContentFrame = pContentNode->getLayoutFrame( GetLayout(), pPt, pCursor->GetPoint(), false);
+
+    pContentFrame->GetCharRect( aStartRect, *pCursor->GetPoint(), &aState );
+    rContent = nWordEnd - 1;
+    SwRect aEndRect;
+    pContentFrame->GetCharRect( aEndRect, *pCursor->GetPoint(),&aState );
+    rSelectRect = aStartRect.Union( aEndRect );
+    Pop(PopMode::DeleteCurrent);
+}
+
 /** Get a list of potential corrections for misspelled word.
  *
  * If empty, word is unknown but there are no corrections available.
@@ -877,53 +931,7 @@ uno::Reference< XSpellAlternatives >
 
             if ( xSpellAlt.is() )   // error found?
             {
-                // save the start and end positions of the line and the starting point
-                Push();
-                LeftMargin();
-                const sal_Int32 nLineStart = GetCursor()->GetPoint()->nContent.GetIndex();
-                RightMargin();
-                const sal_Int32 nLineEnd = GetCursor()->GetPoint()->nContent.GetIndex();
-                Pop(PopMode::DeleteCurrent);
-
-                // make sure the selection build later from the data below does
-                // not "in word" character to the left and right in order to
-                // preserve those. Therefore count those "in words" in order to
-                // modify the selection accordingly.
-                const sal_Unicode* pChar = aText.getStr();
-                sal_Int32 nLeft = 0;
-                while (*pChar++ == CH_TXTATR_INWORD)
-                    ++nLeft;
-                pChar = aText.getLength() ? aText.getStr() + aText.getLength() - 1 : nullptr;
-                sal_Int32 nRight = 0;
-                while (pChar && *pChar-- == CH_TXTATR_INWORD)
-                    ++nRight;
-
-                aPos.nContent = nBegin + nLeft;
-                pCursor = GetCursor();
-                *pCursor->GetPoint() = aPos;
-                pCursor->SetMark();
-                ExtendSelection( true, nLen - nLeft - nRight );
-                // don't determine the rectangle in the current line
-                const sal_Int32 nWordStart = (nBegin + nLeft) < nLineStart ? nLineStart : nBegin + nLeft;
-                // take one less than the line end - otherwise the next line would be calculated
-                const sal_Int32 nWordEnd = (nBegin + nLen - nLeft - nRight) > nLineEnd
-                                        ? nLineEnd : (nBegin + nLen - nLeft - nRight);
-                Push();
-                pCursor->DeleteMark();
-                SwIndex& rContent = GetCursor()->GetPoint()->nContent;
-                rContent = nWordStart;
-                SwRect aStartRect;
-                SwCursorMoveState aState;
-                aState.m_bRealWidth = true;
-                SwContentNode* pContentNode = pCursor->GetContentNode();
-                SwContentFrame *pContentFrame = pContentNode->getLayoutFrame( GetLayout(), pPt, pCursor->GetPoint(), false);
-
-                pContentFrame->GetCharRect( aStartRect, *pCursor->GetPoint(), &aState );
-                rContent = nWordEnd - 1;
-                SwRect aEndRect;
-                pContentFrame->GetCharRect( aEndRect, *pCursor->GetPoint(),&aState );
-                rSelectRect = aStartRect.Union( aEndRect );
-                Pop(PopMode::DeleteCurrent);
+                HandleCorrectionError( aText, aPos, nBegin, nLen, pCursor, pPt, rSelectRect );
             }
         }
     }
@@ -1002,53 +1010,7 @@ bool SwEditShell::GetGrammarCorrection(
 
             if (rResult.aErrors.getLength() > 0)    // error found?
             {
-                // save the start and end positions of the line and the starting point
-                Push();
-                LeftMargin();
-                const sal_Int32 nLineStart = GetCursor()->GetPoint()->nContent.GetIndex();
-                RightMargin();
-                const sal_Int32 nLineEnd = GetCursor()->GetPoint()->nContent.GetIndex();
-                Pop(PopMode::DeleteCurrent);
-
-                // make sure the selection build later from the data below does
-                // not include "in word" character to the left and right in
-                // order to preserve those. Therefore count those "in words" in
-                // order to modify the selection accordingly.
-                const sal_Unicode* pChar = aText.getStr();
-                sal_Int32 nLeft = 0;
-                while (*pChar++ == CH_TXTATR_INWORD)
-                    ++nLeft;
-                pChar = aText.getLength() ? aText.getStr() + aText.getLength() - 1 : nullptr;
-                sal_Int32 nRight = 0;
-                while (pChar && *pChar-- == CH_TXTATR_INWORD)
-                    ++nRight;
-
-                aPos.nContent = nBegin + nLeft;
-                pCursor = GetCursor();
-                *pCursor->GetPoint() = aPos;
-                pCursor->SetMark();
-                ExtendSelection( true, nLen - nLeft - nRight );
-                // don't determine the rectangle in the current line
-                const sal_Int32 nWordStart = (nBegin + nLeft) < nLineStart ? nLineStart : nBegin + nLeft;
-                // take one less than the line end - otherwise the next line would be calculated
-                const sal_Int32 nWordEnd = (nBegin + nLen - nLeft - nRight) > nLineEnd
-                                        ? nLineEnd : (nBegin + nLen - nLeft - nRight);
-                Push();
-                pCursor->DeleteMark();
-                SwIndex& rContent = GetCursor()->GetPoint()->nContent;
-                rContent = nWordStart;
-                SwRect aStartRect;
-                SwCursorMoveState aState;
-                aState.m_bRealWidth = true;
-                SwContentNode* pContentNode = pCursor->GetContentNode();
-                SwContentFrame *pContentFrame = pContentNode->getLayoutFrame( GetLayout(), pPt, pCursor->GetPoint(), false);
-
-                pContentFrame->GetCharRect( aStartRect, *pCursor->GetPoint(), &aState );
-                rContent = nWordEnd - 1;
-                SwRect aEndRect;
-                pContentFrame->GetCharRect( aEndRect, *pCursor->GetPoint(),&aState );
-                rSelectRect = aStartRect.Union( aEndRect );
-                Pop(PopMode::DeleteCurrent);
+                HandleCorrectionError( aText, aPos, nBegin, nLen, pCursor, pPt, rSelectRect );
             }
         }
     }
commit 1670f6aaf28907403e5305b78ebcf93de4ebc19b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 10:10:29 2018 +0100

    Resolves: tdf#116865 trigger pending sizing timers before arranging
    
    trigger pending sizing timers now so we arrange with the final size of the
    client area
    
    Otherwise calling GetSizePixel in the Arranging loop will trigger the timers
    anyway, causing reentry into Arrange_Impl again where the inner Arrange_Impl
    arranges with the final size, and then returns to this outer Arrange_Impl which
    would rearrange with the old client area size.
    
    Change-Id: Ibc2b97f679ceaa0a825cee015576f403703a5f9e
    Reviewed-on: https://gerrit.libreoffice.org/52815
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx
index 1f8ad2a573c9..baff47e83bda 100644
--- a/sfx2/source/appl/workwin.cxx
+++ b/sfx2/source/appl/workwin.cxx
@@ -695,6 +695,20 @@ void SfxWorkWindow::ArrangeChildren_Impl( bool bForce )
     ArrangeAutoHideWindows( nullptr );
 }
 
+void SfxWorkWindow::FlushPendingChildSizes()
+{
+    // tdf#116865, if any windows are being resized, i.e. their
+    // resize timer is active, then calling GetSizePixel on
+    // them forces the timer to fire and sets the final
+    // size to which they are getting resized towards.
+    for (size_t i = 0; i < aChildren.size(); ++i)
+    {
+        SfxChild_Impl *pCli = aChildren[i];
+        if (!pCli || !pCli->pWin)
+            continue;
+        (void)pCli->pWin->GetSizePixel();
+    }
+}
 
 SvBorder SfxWorkWindow::Arrange_Impl()
 
@@ -706,7 +720,14 @@ SvBorder SfxWorkWindow::Arrange_Impl()
     ClientArea, it is set to "not visible".
 */
 {
-
+    //tdf#116865 trigger pending sizing timers now so we arrange
+    //with the final size of the client area.
+    //
+    //Otherwise calling GetSizePixel in the following loop will trigger the
+    //timers, causing reentry into Arrange_Impl again where the inner
+    //Arrange_Impl arranges with the final size, and then returns to this outer
+    //Arrange_Impl which would rearrange with the old client area size
+    FlushPendingChildSizes();
     aClientArea = GetTopRect_Impl();
     aUpperClientArea = aClientArea;
 
diff --git a/sfx2/source/inc/workwin.hxx b/sfx2/source/inc/workwin.hxx
index 5f5f19228d27..c3286960a568 100644
--- a/sfx2/source/inc/workwin.hxx
+++ b/sfx2/source/inc/workwin.hxx
@@ -224,6 +224,8 @@ class SfxWorkWindow final
     void                    SaveStatus_Impl(SfxChildWindow*, const SfxChildWinInfo&);
     static bool             IsPluginMode( SfxObjectShell const * pObjShell );
 
+    void                    FlushPendingChildSizes();
+
 public:
                             SfxWorkWindow( vcl::Window* pWin, SfxFrame* pFrm, SfxFrame* pMaster );
                             ~SfxWorkWindow();


More information about the Libreoffice-commits mailing list