[Libreoffice-commits] .: 6 commits - sw/source

Fridrich Strba fridrich at kemper.freedesktop.org
Mon Jun 18 03:39:44 PDT 2012


 sw/source/ui/docvw/edtwin.cxx |  139 +++++++++++++++++++-----------------------
 1 file changed, 65 insertions(+), 74 deletions(-)

New commits:
commit 20def8ddd8a21d22deb250ded21a2348ee0e35f4
Author: Brad Sowden <code at sowden.org>
Date:   Mon Jun 18 20:01:42 2012 +1200

    Remove unnecessary temp variable
    
    The only impact aTmpQHD.Move() has on pQuickHlpData is clearing
    m_aHelpStrings but this is done anyway in the pQuickHlpData->Stop()
    
    Change-Id: Ie730ddb1860461c81558275d54e32846c1495abe

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 04e6e73..9f6d2f2 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -4992,12 +4992,9 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
                               rSh.IsCrsrReadonly();
         if(!bIsDocReadOnly)
         {
-            QuickHelpData aTmpQHD;
             if( pQuickHlpData->m_bIsDisplayed )
-            {
-                aTmpQHD.Move( *pQuickHlpData );
                 pQuickHlpData->Stop( rSh );
-            }
+
             String sWord;
             if( rSh.HasDrawView() && rSh.GetDrawView()->IsTextEdit() )
             {
commit 3953c293e435d8ff7656d395feb15d88a5ec6492
Author: Brad Sowden <code at sowden.org>
Date:   Mon Jun 18 20:01:35 2012 +1200

    Remove redundant IF clause
    
    ClearCntnt() already sets m_bIsTip and m_bIsAutoText to true.
    
    Change-Id: Ic3ad53a7659dbfe4f28f7995976e659f5bd14afb

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 9cd1ba2..04e6e73 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -5690,12 +5690,8 @@ void SwEditWin::ShowAutoTextCorrectQuickHelp(
         pList->HasLongName( rWord, &pQuickHlpData->m_aHelpStrings );
     }
 
-    if( !pQuickHlpData->m_aHelpStrings.empty() )
-    {
-        pQuickHlpData->m_bIsTip = true;
-        pQuickHlpData->m_bIsAutoText = true;
-    }
-    else if( pACorr->GetSwFlags().bAutoCompleteWords )
+    if( pQuickHlpData->m_aHelpStrings.empty() &&
+        pACorr->GetSwFlags().bAutoCompleteWords )
     {
         pQuickHlpData->m_bIsAutoText = false;
         pQuickHlpData->m_bIsTip = bFromIME ||
commit 1f77d7c0c316cce295329a338e7df37394831f51
Author: Brad Sowden <code at sowden.org>
Date:   Mon Jun 18 20:01:27 2012 +1200

    Clearer function names
    
    Change-Id: I7434842fe8392eeb6e3c5fd8e605ee444f66b017

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 82be706..9cd1ba2 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -301,12 +301,14 @@ struct QuickHelpData
 
     sal_Bool HasCntnt() const { return !m_aHelpStrings.empty() && 0 != nLen; }
 
-    void Inc( sal_Bool bEndLess )
+    /// Next help string.
+    void Next( sal_Bool bEndLess )
     {
         if( ++nCurArrPos >= m_aHelpStrings.size() )
             nCurArrPos = (bEndLess && !m_bIsAutoText ) ? 0 : nCurArrPos-1;
     }
-    void Dec( sal_Bool bEndLess )
+    /// Previous help string.
+    void Previous( sal_Bool bEndLess )
     {
         if( 0 == nCurArrPos-- )
             nCurArrPos = (bEndLess && !m_bIsAutoText ) ? m_aHelpStrings.size()-1 : 0;
@@ -2070,9 +2072,9 @@ KEYINPUT_CHECKTABLE_INSDEL:
                     {
                         if( aTmpQHD.HasCntnt() && !rSh.HasSelection() )
                         {
-                            // to the next Tip
-                            aTmpQHD.Inc( pACorr && pACorr->GetSwFlags().
-                                                   bAutoCmpltEndless );
+                            // Next auto-complete suggestion
+                            aTmpQHD.Next( pACorr &&
+                                          pACorr->GetSwFlags().bAutoCmpltEndless );
                             eKeyState = KS_NextPrevGlossary;
                         }
                         else if( rSh.GetTableFmt() )
@@ -2093,9 +2095,9 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
                             !rSh.HasReadonlySel() )
                         {
-                            // to the previous Tip
-                            aTmpQHD.Dec( pACorr && pACorr->GetSwFlags().
-                                                        bAutoCmpltEndless );
+                            // Previous auto-complete suggestion.
+                            aTmpQHD.Previous( pACorr &&
+                                              pACorr->GetSwFlags().bAutoCmpltEndless );
                             eKeyState = KS_NextPrevGlossary;
                         }
                         else if((rSh.GetSelectionType() & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM|
commit dc019876d8eb42b56e259d6a6f6d7ea5f904d870
Author: Brad Sowden <code at sowden.org>
Date:   Mon Jun 18 20:01:20 2012 +1200

    Member variables can be made local
    
    Change-Id: I571eaa936f8d1afb421da3137aa090e916e633ba

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 532bc16..82be706 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -292,10 +292,7 @@ struct QuickHelpData
     /// Help string is currently displayed.
     bool m_bIsDisplayed;
 
-    sal_uInt16* pAttrs;
-    CommandExtTextInputData* pCETID;
-
-    QuickHelpData() : pAttrs( 0 ), pCETID( 0 ) { ClearCntnt(); }
+    QuickHelpData() { ClearCntnt(); }
 
     void Move( QuickHelpData& rCpy );
     void ClearCntnt();
@@ -5485,14 +5482,6 @@ void QuickHelpData::Move( QuickHelpData& rCpy )
     m_bAppendSpace = rCpy.m_bAppendSpace;
     m_bIsTip = rCpy.m_bIsTip;
     m_bIsAutoText = rCpy.m_bIsAutoText;
-
-    delete pCETID;
-    pCETID = rCpy.pCETID;
-    rCpy.pCETID = 0;
-
-    delete[] pAttrs;
-    pAttrs = rCpy.pAttrs;
-    rCpy.pAttrs = 0;
 }
 
 void QuickHelpData::ClearCntnt()
@@ -5503,18 +5492,10 @@ void QuickHelpData::ClearCntnt()
     m_aHelpStrings.clear();
     m_bIsTip = true;
     m_bIsAutoText = true;
-    delete pCETID, pCETID = 0;
-    delete[] pAttrs, pAttrs = 0;
 }
 
 void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
 {
-    delete pCETID;
-    pCETID = 0;
-
-    delete[] pAttrs;
-    pAttrs = 0;
-
     if( USHRT_MAX != nWrdLen )
     {
         nLen = nWrdLen;
@@ -5537,12 +5518,11 @@ void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
         String sStr( m_aHelpStrings[ nCurArrPos ] );
         sStr.Erase( 0, nLen );
         sal_uInt16 nL = sStr.Len();
-        pAttrs = new sal_uInt16[ nL ];
-        for( sal_uInt16 n = nL; n;  )
-            *(pAttrs + --n ) = EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE |
+        const sal_uInt16 nVal = EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE |
                                 EXTTEXTINPUT_ATTR_HIGHLIGHT;
-        pCETID = new CommandExtTextInputData( sStr, pAttrs, nL,
-                                                0, 0, 0, sal_False );
+        const std::vector<sal_uInt16> aAttrs( nL, nVal );
+        CommandExtTextInputData aCETID( sStr, &aAttrs[0], nL,
+                                        0, 0, 0, sal_False );
 
         //fdo#33092. If the current input language is the default
         //language that text would appear in if typed, then don't
@@ -5555,7 +5535,7 @@ void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
         }
 
         rSh.CreateExtTextInput(eInputLanguage);
-        rSh.SetExtTextInputData( *pCETID );
+        rSh.SetExtTextInputData( aCETID );
     }
 }
 
commit d246b853035714d20c7689f54e507640981aeb9b
Author: Brad Sowden <code at sowden.org>
Date:   Mon Jun 18 20:01:07 2012 +1200

    sal_Bool (bit field) to bool and variable renames
    
    bIsAutoText  -> m_bIsAutoText
    bIsTip       -> m_bIsTip
    bChkInsBlank -> m_bAppendSpace
    bClear       -> m_bIsDisplayed
    
    Change-Id: I7aa047b7e14ed6bd05528c8650ba4c4b7fcb07d2

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 2a0aa88..532bc16 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -281,16 +281,16 @@ struct QuickHelpData
     sal_uInt16 nLen;
 
     /// Help data stores AutoText names rather than AutoComplete words.
-    sal_Bool bIsAutoText : 1;
+    bool m_bIsAutoText;
     /// Display help string as a tip rather than inline.
-    sal_Bool bIsTip : 1;
+    bool m_bIsTip;
     /// Tip ID when a help string is displayed as a tip.
     sal_uLong nTipId;
     /// Append a space character to the displayed help string (if appropriate).
-    sal_Bool bChkInsBlank : 1;
+    bool m_bAppendSpace;
 
     /// Help string is currently displayed.
-    sal_Bool bClear : 1;
+    bool m_bIsDisplayed;
 
     sal_uInt16* pAttrs;
     CommandExtTextInputData* pCETID;
@@ -307,12 +307,12 @@ struct QuickHelpData
     void Inc( sal_Bool bEndLess )
     {
         if( ++nCurArrPos >= m_aHelpStrings.size() )
-            nCurArrPos = (bEndLess && !bIsAutoText ) ? 0 : nCurArrPos-1;
+            nCurArrPos = (bEndLess && !m_bIsAutoText ) ? 0 : nCurArrPos-1;
     }
     void Dec( sal_Bool bEndLess )
     {
         if( 0 == nCurArrPos-- )
-            nCurArrPos = (bEndLess && !bIsAutoText ) ? m_aHelpStrings.size()-1 : 0;
+            nCurArrPos = (bEndLess && !m_bIsAutoText ) ? m_aHelpStrings.size()-1 : 0;
     }
     void FillStrArr( SwWrtShell& rSh, const String& rWord );
     void SortAndFilter();
@@ -1352,7 +1352,7 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
     eBufferLanguage = eNewLanguage;
 
     QuickHelpData aTmpQHD;
-    if( pQuickHlpData->bClear )
+    if( pQuickHlpData->m_bIsDisplayed )
     {
         aTmpQHD.Move( *pQuickHlpData );
         pQuickHlpData->Stop( rSh );
@@ -1374,8 +1374,8 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
 
     sal_Bool bFlushBuffer = sal_False;
     sal_Bool bNormalChar = sal_False;
-    sal_Bool bChkInsBlank = pQuickHlpData->bChkInsBlank;
-    pQuickHlpData->bChkInsBlank = sal_False;
+    bool bAppendSpace = pQuickHlpData->m_bAppendSpace;
+    pQuickHlpData->m_bAppendSpace = false;
 
     if ( getenv("SW_DEBUG") && rKEvt.GetKeyCode().GetCode() == KEY_F12 )
     {
@@ -1615,7 +1615,7 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
             else
             {
                 if( pACorr && aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
-                    !rSh.HasReadonlySel() && !aTmpQHD.bIsAutoText &&
+                    !rSh.HasReadonlySel() && !aTmpQHD.m_bIsAutoText &&
                     pACorr->GetSwFlags().nAutoCmpltExpandKey ==
                     (rKeyCode.GetModifier() | rKeyCode.GetCode()) )
                 {
@@ -1831,7 +1831,7 @@ KEYINPUT_CHECKTABLE_INSDEL:
                                 rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)
                             eKeyState = KS_GoIntoDrawing;
                         else if( aTmpQHD.HasCntnt() && !rSh.HasSelection() &&
-                            aTmpQHD.bIsAutoText )
+                            aTmpQHD.m_bIsAutoText )
                             eKeyState = KS_GlossaryExpand;
 
                         //RETURN and empty paragraph in numbering -> end numbering
@@ -2323,7 +2323,7 @@ KEYINPUT_CHECKTABLE_INSDEL:
             {
                 sal_Bool bIsNormalChar = GetAppCharClass().isLetterNumeric(
                                                             String( aCh ), 0 );
-                if( bChkInsBlank && bIsNormalChar &&
+                if( bAppendSpace && bIsNormalChar &&
                     (aInBuffer.Len() || !rSh.IsSttPara() || !rSh.IsEndPara() ))
                 {
                     // insert a blank ahead of the character. this ends up
@@ -2485,7 +2485,7 @@ KEYINPUT_CHECKTABLE_INSDEL:
                 rSh.StartUndo( UNDO_START );
 
                 String sFnd( aTmpQHD.m_aHelpStrings[ aTmpQHD.nCurArrPos ] );
-                if( aTmpQHD.bIsAutoText )
+                if( aTmpQHD.m_bIsAutoText )
                 {
                     SwGlossaryList* pList = ::GetGlossaryList();
                     String sShrtNm;
@@ -2497,13 +2497,13 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         SwGlossaryHdl* pGlosHdl = GetView().GetGlosHdl();
                         pGlosHdl->SetCurGroup(sGroup, sal_True);
                         pGlosHdl->InsertGlossary( sShrtNm);
-                        pQuickHlpData->bChkInsBlank = sal_True;
+                        pQuickHlpData->m_bAppendSpace = true;
                     }
                 }
                 else
                 {
                     rSh.Insert( sFnd.Erase( 0, aTmpQHD.nLen ));
-                    pQuickHlpData->bChkInsBlank = !pACorr ||
+                    pQuickHlpData->m_bAppendSpace = !pACorr ||
                             pACorr->GetSwFlags().bAutoCmpltAppendBlanc;
                 }
                 rSh.EndUndo( UNDO_END );
@@ -2697,9 +2697,9 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
     sal_Bool bIsDocReadOnly = rView.GetDocShell()->IsReadOnly();
     sal_Bool bCallBase = sal_True;
 
-    if( pQuickHlpData->bClear )
+    if( pQuickHlpData->m_bIsDisplayed )
         pQuickHlpData->Stop( rSh );
-    pQuickHlpData->bChkInsBlank = sal_False;
+    pQuickHlpData->m_bAppendSpace = false;
 
     if( rSh.FinishOLEObj() )
         return; // end InPlace and the click doesn't count anymore
@@ -4620,7 +4620,7 @@ SwEditWin::~SwEditWin()
     aKeyInputTimer.Stop();
     delete pShadCrsr;
     delete pRowColumnSelectionStart;
-    if( pQuickHlpData->bClear && rView.GetWrtShellPtr() )
+    if( pQuickHlpData->m_bIsDisplayed && rView.GetWrtShellPtr() )
         pQuickHlpData->Stop( rView.GetWrtShell() );
     bExecuteDrag = sal_False;
     delete pApplyTempl;
@@ -4714,7 +4714,7 @@ void SwEditWin::LoseFocus()
 {
     rView.GetWrtShell().InvalidateAccessibleFocus();
     Window::LoseFocus();
-    if( pQuickHlpData->bClear )
+    if( pQuickHlpData->m_bIsDisplayed )
         pQuickHlpData->Stop( rView.GetWrtShell() );
     rView.LostFocus();
 }
@@ -4994,7 +4994,7 @@ void SwEditWin::Command( const CommandEvent& rCEvt )
         if(!bIsDocReadOnly)
         {
             QuickHelpData aTmpQHD;
-            if( pQuickHlpData->bClear )
+            if( pQuickHlpData->m_bIsDisplayed )
             {
                 aTmpQHD.Move( *pQuickHlpData );
                 pQuickHlpData->Stop( rSh );
@@ -5429,7 +5429,7 @@ void SwEditWin::_FinitStaticData()
  * of autocorrection suggestions */
 void SwEditWin::StopQuickHelp()
 {
-    if( HasFocus() && pQuickHlpData && pQuickHlpData->bClear  )
+    if( HasFocus() && pQuickHlpData && pQuickHlpData->m_bIsDisplayed  )
         pQuickHlpData->Stop( rView.GetWrtShell() );
 }
 
@@ -5479,12 +5479,12 @@ void QuickHelpData::Move( QuickHelpData& rCpy )
     m_aHelpStrings.clear();
     m_aHelpStrings.swap( rCpy.m_aHelpStrings );
 
-    bClear = rCpy.bClear;
+    m_bIsDisplayed = rCpy.m_bIsDisplayed;
     nLen = rCpy.nLen;
     nCurArrPos = rCpy.nCurArrPos;
-    bChkInsBlank = rCpy.bChkInsBlank;
-    bIsTip = rCpy.bIsTip;
-    bIsAutoText = rCpy.bIsAutoText;
+    m_bAppendSpace = rCpy.m_bAppendSpace;
+    m_bIsTip = rCpy.m_bIsTip;
+    m_bIsAutoText = rCpy.m_bIsAutoText;
 
     delete pCETID;
     pCETID = rCpy.pCETID;
@@ -5498,11 +5498,11 @@ void QuickHelpData::Move( QuickHelpData& rCpy )
 void QuickHelpData::ClearCntnt()
 {
     nLen = nCurArrPos = 0;
-    bClear = bChkInsBlank = sal_False;
+    m_bIsDisplayed = m_bAppendSpace = false;
     nTipId = 0;
     m_aHelpStrings.clear();
-    bIsTip = sal_True;
-    bIsAutoText = sal_True;
+    m_bIsTip = true;
+    m_bIsAutoText = true;
     delete pCETID, pCETID = 0;
     delete[] pAttrs, pAttrs = 0;
 }
@@ -5520,10 +5520,10 @@ void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
         nLen = nWrdLen;
         nCurArrPos = 0;
     }
-    bClear = sal_True;
+    m_bIsDisplayed = true;
 
     Window& rWin = rSh.GetView().GetEditWin();
-    if( bIsTip )
+    if( m_bIsTip )
     {
         Point aPt( rWin.OutputToScreenPixel( rWin.LogicToPixel(
                     rSh.GetCharRect().Pos() )));
@@ -5561,7 +5561,7 @@ void QuickHelpData::Start( SwWrtShell& rSh, sal_uInt16 nWrdLen )
 
 void QuickHelpData::Stop( SwWrtShell& rSh )
 {
-    if( !bIsTip )
+    if( !m_bIsTip )
         rSh.DeleteExtTextInput( 0, sal_False );
     else if( nTipId )
         Help::HideTip( nTipId );
@@ -5710,13 +5710,13 @@ void SwEditWin::ShowAutoTextCorrectQuickHelp(
 
     if( !pQuickHlpData->m_aHelpStrings.empty() )
     {
-        pQuickHlpData->bIsTip = sal_True;
-        pQuickHlpData->bIsAutoText = sal_True;
+        pQuickHlpData->m_bIsTip = true;
+        pQuickHlpData->m_bIsAutoText = true;
     }
     else if( pACorr->GetSwFlags().bAutoCompleteWords )
     {
-        pQuickHlpData->bIsAutoText = sal_False;
-        pQuickHlpData->bIsTip = bFromIME ||
+        pQuickHlpData->m_bIsAutoText = false;
+        pQuickHlpData->m_bIsTip = bFromIME ||
                     !pACorr ||
                     pACorr->GetSwFlags().bAutoCmpltShowAsTip;
 
commit 25d43d348c1614869fa3adb749f0cf6f1845281e
Author: Brad Sowden <code at sowden.org>
Date:   Mon Jun 18 20:00:58 2012 +1200

    Some doxygen comments for QuickHelpData
    
    Change-Id: Id6e91985f6dbdd8244df9bef0f7a938ac8ecbf3a

diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 6e40e57..2a0aa88 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -270,14 +270,30 @@ public:
     }
 };
 
+/// Assists with auto-completion of AutoComplete words and AutoText names.
 struct QuickHelpData
 {
+    /// Strings that at least partially match an input word.
     std::vector<String> m_aHelpStrings;
+    /// Index of the current help string.
+    sal_uInt16 nCurArrPos;
+    /// Length of the input word associated with the help data.
+    sal_uInt16 nLen;
+
+    /// Help data stores AutoText names rather than AutoComplete words.
+    sal_Bool bIsAutoText : 1;
+    /// Display help string as a tip rather than inline.
+    sal_Bool bIsTip : 1;
+    /// Tip ID when a help string is displayed as a tip.
+    sal_uLong nTipId;
+    /// Append a space character to the displayed help string (if appropriate).
+    sal_Bool bChkInsBlank : 1;
+
+    /// Help string is currently displayed.
+    sal_Bool bClear : 1;
+
     sal_uInt16* pAttrs;
     CommandExtTextInputData* pCETID;
-    sal_uLong nTipId;
-    sal_uInt16 nLen, nCurArrPos;
-    sal_Bool bClear : 1, bChkInsBlank : 1, bIsTip : 1, bIsAutoText : 1;
 
     QuickHelpData() : pAttrs( 0 ), pCETID( 0 ) { ClearCntnt(); }
 


More information about the Libreoffice-commits mailing list