patch: fixes zoom page under win32

From: Jordi Mas (jmas@softcatala.org)
Date: Mon Sep 01 2003 - 07:17:45 EDT

  • Next message: Jordi Mas: "Re: commit: es-ES, yi, nn-NO and related / problem with Spanish es-es.string"

    Hello,

    This patch fixes two bugs related two win32 zooming:

    - First, at EV_Win32Toolbar::_ComboWndProc we were getting a string from a
    combobox and then we were using the UT_UCS4_strcpy_utf8_char function
    instead of UT_UCS4_strcpy_char. Remember that our Windows win32 build uses
    ANSI strings converted to the user locale. Not Unicode not UTF-8. When the
    Zoom strings had special characters (e.g. were localised) the conversion was
    wrong.

    - Second, the function Defun(zoom) at ap_EditMethods.cpp was using getValue
    to obtain UTF8 strings from the StringSet. Remember, that many Unices locales
    work on UTF-8 but in Windows we do not use UTF-8 and under win32 we were
    getting ANSI encoded strings instead of UTF8!. You XP wizards guys remember to
    use getValueUTF8 if you really want a UTF-8 encoded string.

    This this two fixes now we you select the Zoom View to a non-numeric value
    with localised version of Windows works, before was not working.

    I hope that this makes sense to everyone.

    Best Regards,

    -- 
    

    Jordi Mas i Hernāndez - Abiword developer - http://www.abisource.com jmas@softcatala.org - Softcatalā member - http://www.softcatala.org - Personal Homepage http://www.softcatala.org/~jmas

    Index: src/af/ev/win/ev_Win32Toolbar.cpp
    ===================================================================
    RCS file: /cvsroot/abi/src/af/ev/win/ev_Win32Toolbar.cpp,v
    retrieving revision 1.74
    diff -c -r1.74 ev_Win32Toolbar.cpp
    *** src/af/ev/win/ev_Win32Toolbar.cpp 26 Jul 2003 21:38:34 -0000 1.74
    --- src/af/ev/win/ev_Win32Toolbar.cpp 1 Sep 2003 11:21:19 -0000
    ***************
    *** 404,410 ****
      
                                                      UT_uint32 dataLength = GetWindowText(hWnd, buf, COMBO_BUF_LEN);
      
    ! UT_UCS4_strcpy_utf8_char(ucs_buf, buf);
                                                      UT_UCSChar * pData = (UT_UCSChar *) ucs_buf; // HACK: should be void *
                                                      
                                                      if(dataLength)
    --- 404,410 ----
      
                                                      UT_uint32 dataLength = GetWindowText(hWnd, buf, COMBO_BUF_LEN);
      
    ! UT_UCS4_strcpy_char(ucs_buf, buf);
                                                      UT_UCSChar * pData = (UT_UCSChar *) ucs_buf; // HACK: should be void *
                                                      
                                                      if(dataLength)
    Index: src/wp/ap/xp/ap_EditMethods.cpp
    ===================================================================
    RCS file: /cvsroot/abi/src/wp/ap/xp/ap_EditMethods.cpp,v
    retrieving revision 1.618
    diff -c -r1.618 ap_EditMethods.cpp
    *** src/wp/ap/xp/ap_EditMethods.cpp 28 Aug 2003 07:23:15 -0000 1.618
    --- src/wp/ap/xp/ap_EditMethods.cpp 1 Sep 2003 11:22:05 -0000
    ***************
    *** 8173,8193 ****
      
              const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet();
      
    ! if(strcmp(p_zoom, pSS->getValue(XAP_STRING_ID_TB_Zoom_PageWidth)) == 0)
              {
                      pPrefsScheme->setValue(static_cast<const XML_Char*>(XAP_PREF_KEY_ZoomType),
                                                       static_cast<const XML_Char*>("Width"));
                      pFrame->setZoomType(XAP_Frame::z_PAGEWIDTH);
                      iZoom = pView->calculateZoomPercentForPageWidth();
              }
    ! else if(strcmp(p_zoom, pSS->getValue(XAP_STRING_ID_TB_Zoom_WholePage)) == 0)
              {
                      pFrame->setZoomType(XAP_Frame::z_WHOLEPAGE);
                      pPrefsScheme->setValue(static_cast<const XML_Char*>(XAP_PREF_KEY_ZoomType),
                                                       static_cast<const XML_Char*>("Page"));
                      iZoom = pView->calculateZoomPercentForWholePage();
              }
    ! else if(strcmp(p_zoom, pSS->getValue(XAP_STRING_ID_TB_Zoom_Percent)) == 0)
              {
                      // invoke the zoom dialog instead for some custom value
                      return EX(dlgZoom);
    --- 8173,8197 ----
      
              const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet();
      
    ! UT_String sPageWidth = pSS->getValueUTF8(XAP_STRING_ID_TB_Zoom_PageWidth);
    ! UT_String sWholePage = pSS->getValueUTF8(XAP_STRING_ID_TB_Zoom_WholePage);
    ! UT_String sPercent = pSS->getValueUTF8(XAP_STRING_ID_TB_Zoom_Percent);
    !
    ! if(strcmp(p_zoom, sPageWidth.c_str()) == 0)
              {
                      pPrefsScheme->setValue(static_cast<const XML_Char*>(XAP_PREF_KEY_ZoomType),
                                                       static_cast<const XML_Char*>("Width"));
                      pFrame->setZoomType(XAP_Frame::z_PAGEWIDTH);
                      iZoom = pView->calculateZoomPercentForPageWidth();
              }
    ! else if(strcmp(p_zoom, sWholePage.c_str()) == 0)
              {
                      pFrame->setZoomType(XAP_Frame::z_WHOLEPAGE);
                      pPrefsScheme->setValue(static_cast<const XML_Char*>(XAP_PREF_KEY_ZoomType),
                                                       static_cast<const XML_Char*>("Page"));
                      iZoom = pView->calculateZoomPercentForWholePage();
              }
    ! else if(strcmp(p_zoom, sPercent.c_str()) == 0)
              {
                      // invoke the zoom dialog instead for some custom value
                      return EX(dlgZoom);
    ***************
    *** 8203,8209 ****
                      pFrame->setZoomType(XAP_Frame::z_PERCENT);
                      iZoom = atoi(p_zoom);
              }
    !
              UT_ASSERT(iZoom > 0);
      
              s_StartStopLoadingCursor(true, pFrame);
    --- 8207,8213 ----
                      pFrame->setZoomType(XAP_Frame::z_PERCENT);
                      iZoom = atoi(p_zoom);
              }
    !
              UT_ASSERT(iZoom > 0);
      
              s_StartStopLoadingCursor(true, pFrame);



    This archive was generated by hypermail 2.1.4 : Mon Sep 01 2003 - 07:31:15 EDT