Disregard the patch from the previous email.  The correct one is attached
to this email.

Sorry 'bout that,
Will Robinson
Index: abi/src/text/fmt/xp/fv_View.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fv_View.cpp,v
retrieving revision 1.416
diff -c -c -r1.416 fv_View.cpp
*** abi/src/text/fmt/xp/fv_View.cpp     2001/04/03 10:14:28     1.416
--- abi/src/text/fmt/xp/fv_View.cpp     2001/04/04 06:33:40
***************
*** 240,248 ****
  
  // first character after each space gets capitalized
  static void _toggleTitle (const UT_UCSChar * src, 
!                         UT_UCSChar * dest, UT_uint32 len)
  {
!   bool wasSpace = false;
  
    UT_UCSChar ch;
    
--- 240,249 ----
  
  // first character after each space gets capitalized
  static void _toggleTitle (const UT_UCSChar * src, 
!                         UT_UCSChar * dest, UT_uint32 len,
!                           bool spaceBeforeFirstChar)
  {
!   bool wasSpace = spaceBeforeFirstChar;
  
    UT_UCSChar ch;
    
***************
*** 282,287 ****
--- 283,316 ----
      }
  }
  
+ // returns true iff the character BEFORE pos is a space.
+ // Special cases:
+ // -returns true if pos is at the beginning of the document
+ // -returns false if pos is not within the document
+ bool FV_View::_isSpaceBefore(PT_DocPosition pos)
+ {
+       UT_GrowBuf buffer;
+ 
+       fl_BlockLayout * block = m_pLayout->findBlockAtPosition(pos);
+       if (block)
+       {
+ 
+             PT_DocPosition offset = pos - block->getPosition(false);
+             // Just look at the previous character in this block, if there is one...
+             if (offset > 0)
+             {
+                   block->getBlockBuf(&buffer);
+                   return (UT_UCS_isspace(*(UT_UCSChar *)buffer.getPointer(offset - 
+1)));
+             }
+             else
+             {      
+                   return true;
+             }
+       }
+       else
+             return false;
+ }
+ 
  void FV_View::toggleCase (ToggleCase c)
  {
    // 1. get selection
***************
*** 294,301 ****
--- 323,332 ----
      return;
  
    UT_UCSChar * cur, * replace;
+   UT_GrowBuf buffer;
  
    cur = getSelectionText();
+   PT_DocPosition low = (m_iInsPoint < m_iSelectionAnchor ? m_iInsPoint : 
+m_iSelectionAnchor);
  
    if (!cur)
      return;
***************
*** 317,323 ****
      case CASE_UPPER: _toggleUpper (cur, replace, replace_len);
        break;
  
!     case CASE_TITLE: _toggleTitle (cur, replace, replace_len);
        break;
  
      case CASE_TOGGLE: _toggleToggle (cur, replace, replace_len);
--- 348,354 ----
      case CASE_UPPER: _toggleUpper (cur, replace, replace_len);
        break;
  
!     case CASE_TITLE: _toggleTitle (cur, replace, replace_len, _isSpaceBefore(low));
        break;
  
      case CASE_TOGGLE: _toggleToggle (cur, replace, replace_len);
***************
*** 3206,3222 ****
        differently.
  */
  UT_UCSChar * FV_View::getSelectionText(void)
! {
!       UT_ASSERT(!isSelectionEmpty());
! 
!       UT_GrowBuf buffer;      
! 
!       UT_uint32 selLength = labs(m_iInsPoint - m_iSelectionAnchor);
! 
!       PT_DocPosition low;
!       if (m_iInsPoint > m_iSelectionAnchor)
!       {
!               low = m_iSelectionAnchor;
        }
        else
        {
--- 3237,3253 ----
        differently.
  */
  UT_UCSChar * FV_View::getSelectionText(void)
!   {
!       UT_ASSERT(!isSelectionEmpty());
!   
!       UT_GrowBuf buffer;      
!   
!       UT_uint32 selLength = labs(m_iInsPoint - m_iSelectionAnchor);
!   
!       PT_DocPosition low;
!       if (m_iInsPoint > m_iSelectionAnchor)
!       {
!               low = m_iSelectionAnchor;
        }
        else
        {
Index: abi/src/text/fmt/xp/fv_View.h
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fv_View.h,v
retrieving revision 1.170
diff -c -c -r1.170 fv_View.h
*** abi/src/text/fmt/xp/fv_View.h       2001/04/03 10:14:28     1.170
--- abi/src/text/fmt/xp/fv_View.h       2001/04/04 06:33:41
***************
*** 412,417 ****
--- 412,419 ----
  
        void                            _checkPendingWordForSpell(void);
  
+         bool                            _isSpaceBefore(PT_DocPosition pos);
+ 
        PT_DocPosition          m_iInsPoint;
        UT_sint32                       m_xPoint;
        UT_sint32                       m_yPoint;

Reply via email to