Patch: Bug [rfe] display the spell checker language in the status bar

From: Andrew Dunbar (hippietrail@yahoo.com)
Date: Thu Oct 10 2002 - 22:28:23 EDT

  • Next message: Andrew Dunbar: "Re: commit: initial babarism support for ispell"

    Marc's site with my shell account has been down for a
    couple of days so I'll have to submit this patch the
    old way.

    I've Fixed
    http://bugzilla.abisource.com/show_bug.cgi?id=3275
    "[rfe] display the spell checker language in the
    status bar"

    Our status fields are in a different order to MSWord's
    but I tried to put the new field in a similar relative
    spot. You'll probably notice especially on *nix
    builds
    that the new field is off the right-side of the
    window.
    This is not the fault of this patch - so run along and
    fix this bug to make it right:
    http://bugzilla.abisource.com/show_bug.cgi?id=4135
    "Status bar doesn't resize."

    There's also a new feature for the RTF importer (sorry
    to mix two things in one patch).
    MS Word and RTF have two concepts for language and
    spelling that we currently cover with a single
    concept.
    They allow you to set the language for some text and
    flag it as not spell-checked with the \noproof
    keyword.
    We were ignoring this keyword. We now treat this key-
    word the same as setting the language for a selection
    to "none".
    MS Word and RTF support "none" as a language when you
    import a file with it but they don't have a "none" or
    "no proofing" in their language selection list so it
    wasn't very easy to make a document which proofed the
    same way on Word and AbiWord.

    Andrew.

    =====
    http://linguaphile.sourceforge.net/cgi-bin/translator.pl http://www.abisource.com

    __________________________________________________
    Do You Yahoo!?
    Everything you'll ever need on one web page
    from News and Sport to Email and Music Charts
    http://uk.my.yahoo.com

    diff --strip-trailing-cr -ru /cygdrive/c/AbiCVS/HEAD/abi/src/wp/ap/xp/ap_StatusBar.cpp /cygdrive/c/Program Files/Microsoft Visual Studio/MyProjects/abiword/abi/src/wp/ap/xp/ap_StatusBar.cpp
    --- /cygdrive/c/AbiCVS/HEAD/abi/src/wp/ap/xp/ap_StatusBar.cpp 2002-08-13 08:14:10.000000000 +0800
    +++ /cygdrive/c/Program Files/Microsoft Visual Studio/MyProjects/abiword/abi/src/wp/ap/xp/ap_StatusBar.cpp 2002-10-09 22:22:56.000000000 +0800
    @@ -512,6 +512,9 @@
             }
     }
     
    +//////////////////////////////////////////////////////////////////
    +//////////////////////////////////////////////////////////////////
    +
     class ap_sb_Field_InsertMode : public ap_sb_Field
     {
     public:
    @@ -596,6 +599,109 @@
         }
     }
     
    +
    +//////////////////////////////////////////////////////////////////
    +//////////////////////////////////////////////////////////////////
    +
    +class ap_sb_Field_Language : public ap_sb_Field
    +{
    +public:
    + ap_sb_Field_Language(AP_StatusBar * pSB);
    + virtual ~ap_sb_Field_Language(void);
    +
    + virtual UT_uint32 getDesiredWidth(void);
    + virtual void draw(void);
    + virtual void notify(AV_View * pView, const AV_ChangeMask mask);
    +
    +private:
    + UT_UCSChar m_Language[AP_MAX_MESSAGE_FIELD];
    + UT_uint32 m_iDesiredWidth;
    +};
    +
    +ap_sb_Field_Language::ap_sb_Field_Language(AP_StatusBar * pSB)
    + : ap_sb_Field(pSB)
    +{
    + m_Language[0] = 0;
    + m_iDesiredWidth = 0;
    +}
    +
    +ap_sb_Field_Language::~ap_sb_Field_Language(void)
    +{
    +}
    +
    +UT_uint32 ap_sb_Field_Language::getDesiredWidth(void)
    +{
    + if (!m_iDesiredWidth)
    + {
    + UT_GrowBufElement charWidths[AP_MAX_MESSAGE_FIELD];
    +
    + // TODO language tags can be longer, eg "art-lojban"
    + UT_UCSChar language[5+1];
    + // Use m/M to measure string since it's a fat letter
    + UT_UCS4_strcpy_char(language,"mm-MM");
    +
    + // TODO language tags can be longer, eg "art-lojban"
    + m_iDesiredWidth = m_pSB->getGraphics()->measureString(language,0,5,charWidths);
    + UT_ASSERT(m_iDesiredWidth);
    + m_iDesiredWidth = MyMin(m_iDesiredWidth,_UL(300)) + _UL(6);
    + }
    + return m_iDesiredWidth;
    +}
    +
    +/*
    + UT_GrowBufElement charWidths[AP_MAX_MESSAGE_FIELD];
    +
    + // Use m/M to measure string since it's a fat letter
    + // TODO language tags can be longer, eg "art-lojban"
    + m_iDesiredWidth = m_pSB->getGraphics()->measureString("mm-MM",0,5,charWidths);
    +
    +*/
    +
    +void ap_sb_Field_Language::draw(void)
    +{
    + _draw3D();
    + int len;
    +
    + UT_UCSChar *bufLanguage = m_Language;
    +
    + len = UT_UCS4_strlen(bufLanguage);
    +
    + if (len)
    + {
    + GR_Graphics * pG = m_pSB->getGraphics();
    + UT_uint32 iFontHeight = pG->getFontHeight();
    +
    + UT_uint32 x = m_rect3d.left + _UL(3);
    + UT_uint32 y = m_rect3d.top + (m_rect3d.height-iFontHeight)/2;
    +
    + pG->setColor3D(GR_Graphics::CLR3D_Foreground);
    +
    + pG->setClipRect(&m_rect3d);
    + pG->drawChars(bufLanguage,0,len,x,y);
    + pG->setClipRect(NULL);
    + }
    +}
    +
    +void ap_sb_Field_Language::notify(AV_View * pavView, const AV_ChangeMask mask)
    +{
    + // TODO do we want our own bit for language change?
    + //if (mask & (AV_CHG_INSERTMODE))
    + {
    + const char * szLang = NULL;
    +
    + const XML_Char ** props_in = NULL;
    + if (pavView && static_cast<FV_View *>(pavView)->getCharFormat(&props_in))
    + {
    + szLang = UT_getAttribute("lang", props_in);
    + FREEP(props_in);
    +
    + UT_UCS4_strcpy_char(m_Language,szLang ? szLang : "");
    + }
    +
    + draw();
    + }
    +}
    +
     //////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////
     
    @@ -673,6 +779,8 @@
                     DclField(ap_sb_Field_InsertMode, pf4);
                     DclField(ap_sb_Field_InputMode, pf3);
                     
    + DclField(ap_sb_Field_Language, pf5);
    +
                     // TODO add other fields
     
     #undef DclField
    @@ -699,6 +807,8 @@
     
     void AP_StatusBar::setWidth(UT_uint32 iWidth)
     {
    + // TODO change status message control width
    + // TODO change x position of all controls to right of status message
             m_iWidth = iWidth;
     }
     
    @@ -713,8 +823,8 @@
     
             // We choose to clear any status message we may have,
             // since it's a pain for the code which set the message
    - // to hang around and clear it at somepoint in the future.
    - // This way, message will get cleared anytime the user does
    + // to hang around and clear it at some point in the future.
    + // This way, message will get cleared any time the user does
             // something with the window.
     
             if (*m_bufUCS)
    diff --strip-trailing-cr -ru /cygdrive/c/AbiCVS/HEAD/abi/src/wp/impexp/xp/ie_imp_RTF.cpp /cygdrive/c/Program Files/Microsoft Visual Studio/MyProjects/abiword/abi/src/wp/impexp/xp/ie_imp_RTF.cpp
    --- /cygdrive/c/AbiCVS/HEAD/abi/src/wp/impexp/xp/ie_imp_RTF.cpp 2002-09-13 00:16:38.000000000 +0800
    +++ /cygdrive/c/Program Files/Microsoft Visual Studio/MyProjects/abiword/abi/src/wp/impexp/xp/ie_imp_RTF.cpp 2002-10-06 18:54:10.000000000 +0800
    @@ -3265,6 +3265,18 @@
                             }
                     break;
     
    + case 'n':
    + if (strcmp((char*)pKeyword,"noproof") == 0)
    + {
    + // Set language to none for \noproof
    + // TODO actually implement proofing flag separate to language setting
    + UT_DEBUGMSG(("HIPI: RTF import keyword \\noproof\n"));
    + // mark language for spell checking
    + m_currentRTFState.m_charProps.m_szLang = "-none-";
    + return true;
    + }
    + break;
    +
             case 'o':
                     if (strcmp((char*)pKeyword,"ol") == 0)
                     {



    This archive was generated by hypermail 2.1.4 : Thu Oct 10 2002 - 22:35:02 EDT