Commits

obo  committed 8383704 Merge

CWS-TOOLING: integrate CWS tl74

  • Participants
  • Parent commits 86cbe2c, 6004dfc

Comments (0)

Files changed (227)

File cui/source/dialogs/SpellDialog.cxx

     }
     else
     {
-        if( SvtLinguConfig().HasAnyVendorImages() )
+        if( SvtLinguConfig().HasVendorImages( "SpellAndGrammarDialogImage" ) )
         {
             pThis->aVendorImageFI.Show();
             Size aVendorSize = pThis->aVendorImageFI.GetSizePixel();

File cui/source/dialogs/hyphen.cxx

 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_cui.hxx"
 
-// include ---------------------------------------------------------------
-#include <tools/shl.hxx>
-#include <tools/list.hxx>
-#include <com/sun/star/linguistic2/XPossibleHyphens.hpp>
-#include <vcl/msgbox.hxx>
+#include "hyphen.hxx"
+#include "hyphen.hrc"
 #include "cuires.hrc"
-#include "hyphen.hrc"
+#include "dialmgr.hxx"
+
+#include <editeng/splwrap.hxx>
 #include <editeng/svxenum.hxx>
-#include "hyphen.hxx"
-#include <editeng/splwrap.hxx>
-#include <svx/dlgutil.hxx>
-#include <svx/dialmgr.hxx>
 #include <editeng/unolingu.hxx>
 #include <svtools/langtab.hxx>
-#include "dialmgr.hxx"
+#include <svx/dialmgr.hxx>
+#include <svx/dlgutil.hxx>
+#include <tools/list.hxx>
+#include <tools/shl.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <com/sun/star/linguistic2/XPossibleHyphens.hpp>
 
 using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::linguistic2;
 
-#undef S2U
-#undef U2S
-//#define S2U(s) 						StringToOUString(s, CHARSET_SYSTEM)
-//#define U2S(s)						OUStringToString(s, CHARSET_SYSTEM)
 
-// define ----------------------------------------------------------------
-
-#define HYPHHERE			'-'
+#define HYPH_POS_CHAR       '='
 #define CONTINUE_HYPH       USHRT_MAX
 
-// Dies ist nur ein Hack, weil an dieser Stelle das extern char aus hmwrap
-// nicht bekannt ist, wird demnaechst in hmwrap durch ein define ersetzt.
-#define SW_SOFT_HYPHEN  '='
+#define CUR_HYPH_POS_CHAR   '-'
 
-// class SvxHyphenEdit ---------------------------------------------------
 
-SvxHyphenEdit::SvxHyphenEdit( Window* pParent, const ResId& rResId ) :
+// class HyphenEdit_Impl -------------------------------------------------------
 
+class HyphenEdit_Impl : public Edit
+{
+public:
+    HyphenEdit_Impl( Window* pParent, const ResId& rResId );
+
+protected:
+	virtual void 	KeyInput( const KeyEvent &rKEvt );
+};
+
+
+HyphenEdit_Impl::HyphenEdit_Impl( Window* pParent, const ResId& rResId ) :
 	Edit( pParent, rResId )
 {
 }
 
-// -----------------------------------------------------------------------
 
-void SvxHyphenEdit::KeyInput( const KeyEvent& rKEvt )
+void HyphenEdit_Impl::KeyInput( const KeyEvent& rKEvt )
 {
 //	sal_uInt16 nMod  = rKEvt.GetKeyCode().GetModifier();
 	sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
 	}
 }
 
+
+// struct SvxHyphenWordDialog_Impl ---------------------------------------------
+
+struct SvxHyphenWordDialog_Impl
+{
+    SvxHyphenWordDialog *       m_pDialog;
+//    Window *                    m_pParent;
+    
+    FixedText           aWordFT;
+    HyphenEdit_Impl     aWordEdit;
+    ImageButton         aLeftBtn;
+    ImageButton         aRightBtn;
+    OKButton            aOkBtn;
+    PushButton          aContBtn;
+    PushButton          aDelBtn;
+    FixedLine           aFLBottom;
+    HelpButton          aHelpBtn;
+    PushButton          aHyphAll;
+    CancelButton        aCancelBtn;
+    String              aLabel;
+    SvxSpellWrapper*    pHyphWrapper;
+    uno::Reference< linguistic2::XHyphenator >        xHyphenator;
+    uno::Reference< linguistic2::XPossibleHyphens >   xPossHyph;
+    String              aEditWord;      // aEditWord and aWordEdit.GetText() differ only by the character for the current selected hyphenation position
+    String              aActWord;           // actual word to be hyphenated
+    LanguageType        nActLanguage;       // and its language
+    sal_uInt16          nMaxHyphenationPos; // right most valid hyphenation pos
+    sal_uInt16          nHyphPos;
+    sal_uInt16          nOldPos;
+    sal_Int32           nHyphenationPositionsOffset;
+    sal_Bool            bBusy;
+
+
+    void            EnableLRBtn_Impl();
+    String          EraseUnusableHyphens_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XPossibleHyphens >  &rxPossHyph, sal_uInt16 nMaxHyphenationPos );
+
+    void            InitControls_Impl();
+    void            ContinueHyph_Impl( sal_uInt16 nInsPos = 0 );
+    sal_uInt16      GetHyphIndex_Impl();
+    void            SelLeft_Impl();
+    void            SelRight_Impl();
+
+    DECL_LINK( Left_Impl, Button* );
+    DECL_LINK( Right_Impl, Button* );
+    DECL_LINK( CutHdl_Impl, Button* );
+    DECL_LINK( ContinueHdl_Impl, Button* );
+    DECL_LINK( DeleteHdl_Impl, Button* );
+    DECL_LINK( HyphenateAllHdl_Impl, Button* );
+    DECL_LINK( CancelHdl_Impl, Button* );
+    DECL_LINK( GetFocusHdl_Impl, Edit* );
+
+
+    SvxHyphenWordDialog_Impl( 
+            SvxHyphenWordDialog * pDialog,
+            const String &rWord, 
+            LanguageType nLang,
+            uno::Reference< linguistic2::XHyphenator >  &xHyphen,
+            SvxSpellWrapper* pWrapper );
+    ~SvxHyphenWordDialog_Impl();
+};
+
+
+SvxHyphenWordDialog_Impl::SvxHyphenWordDialog_Impl( 
+        SvxHyphenWordDialog * pDialog,
+        const String &rWord, 
+        LanguageType nLang,
+        uno::Reference< linguistic2::XHyphenator >  &xHyphen,
+        SvxSpellWrapper* pWrapper ) :
+
+    m_pDialog   ( pDialog ),
+    aWordFT     ( pDialog, CUI_RES( FT_WORD ) ),
+    aWordEdit   ( pDialog, CUI_RES( ED_WORD ) ),
+    aLeftBtn    ( pDialog, CUI_RES( BTN_LEFT ) ),
+    aRightBtn   ( pDialog, CUI_RES( BTN_RIGHT ) ),
+    aOkBtn      ( pDialog, CUI_RES( BTN_HYPH_CUT ) ),
+    aContBtn    ( pDialog, CUI_RES( BTN_HYPH_CONTINUE ) ),
+    aDelBtn     ( pDialog, CUI_RES( BTN_HYPH_DELETE ) ),
+    aFLBottom   ( pDialog, CUI_RES( FL_BOTTOM ) ),
+    aHelpBtn    ( pDialog, CUI_RES( BTN_HYPH_HELP ) ),
+    aHyphAll    ( pDialog, CUI_RES( BTN_HYPH_ALL ) ),
+    aCancelBtn  ( pDialog, CUI_RES( BTN_HYPH_CANCEL ) ),
+    aLabel          ( pDialog->GetText() ),
+    pHyphWrapper    ( NULL ),
+    xHyphenator     ( NULL ),
+    xPossHyph       ( NULL ),
+    aActWord        (  ),
+    nActLanguage    ( LANGUAGE_NONE ),
+    nMaxHyphenationPos  ( 0 ),
+    nHyphPos        ( 0 ),
+    nOldPos         ( 0 ),
+    nHyphenationPositionsOffset( 0 ),
+    bBusy           ( sal_False )
+{
+    aActWord       = rWord;
+    nActLanguage   = nLang;
+    xHyphenator    = xHyphen;
+    pHyphWrapper   = pWrapper;
+
+    uno::Reference< linguistic2::XHyphenatedWord >  xHyphWord( pHyphWrapper ? 
+            pHyphWrapper->GetLast() : NULL, uno::UNO_QUERY );
+    DBG_ASSERT( xHyphWord.is(), "hyphenation result missing" );
+    if (xHyphWord.is())
+    {
+        DBG_ASSERT( aActWord == String( xHyphWord->getWord() ), "word mismatch" );
+        DBG_ASSERT( nActLanguage == SvxLocaleToLanguage( xHyphWord->getLocale() ), "language mismatch" );
+        nMaxHyphenationPos = xHyphWord->getHyphenationPos();
+    }
+
+    InitControls_Impl();
+    aWordEdit.GrabFocus();
+    
+    aLeftBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, Left_Impl ) );
+    aRightBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, Right_Impl ) );
+    aOkBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, CutHdl_Impl ) );
+    aContBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, ContinueHdl_Impl ) );
+    aDelBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, DeleteHdl_Impl ) );
+    aHyphAll.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, HyphenateAllHdl_Impl ) );
+    aCancelBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog_Impl, CancelHdl_Impl ) );
+    aWordEdit.SetGetFocusHdl( LINK( this, SvxHyphenWordDialog_Impl, GetFocusHdl_Impl ) );
+}
+    
+
+SvxHyphenWordDialog_Impl::~SvxHyphenWordDialog_Impl()
+{
+}    
+
+
+void SvxHyphenWordDialog_Impl::EnableLRBtn_Impl()
+{
+    String  aTxt( aEditWord );
+    xub_StrLen nLen = aTxt.Len();
+    xub_StrLen i;
+
+    aRightBtn.Disable();
+    for ( i = nOldPos + 2; i < nLen; ++i )
+    {
+        if ( aTxt.GetChar( i ) == sal_Unicode( HYPH_POS_CHAR ) )
+        {
+            aRightBtn.Enable();
+            break;
+        }
+    }
+
+    DBG_ASSERT(nOldPos < aTxt.Len(), "nOldPos out of range");
+    if (nOldPos >= aTxt.Len())
+        nOldPos = aTxt.Len() - 1;
+    aLeftBtn.Disable();
+    for ( i = nOldPos;  i-- > 0; )
+    {
+        if ( aTxt.GetChar( i ) == sal_Unicode( HYPH_POS_CHAR ) )
+        {
+            aLeftBtn.Enable();
+            break;
+        }
+    }
+}
+
+
+String SvxHyphenWordDialog_Impl::EraseUnusableHyphens_Impl(
+        uno::Reference< linguistic2::XPossibleHyphens >  &rxPossHyph,
+        sal_uInt16 _nMaxHyphenationPos )
+{
+    // returns a String showing only those hyphen positions which will result
+    // in a line break if hyphenation is done there
+    // 1) we will need to discard all hyphenation positions at th end that
+    // will not result in a line break where the text to the left still fits 
+    // on the line.
+    // 2) since as from OOo 3.2 '-' are part of a word an thus text like
+    // 'multi-line-editor' is regarded as single word we also need to discard those
+    // hyphenation positions to the left of the rightmost '-' that is still left of
+    // the rightmost valid hyphenation position according to 1)
+    //
+    // Example:
+    // If the possible hyphenation position in 'multi-line-editor' are to eb marked 
+    // by '=' then the text will look like this 'mul=ti-line-ed=it=or'.
+    // If now the first line is only large enough for 'multi-line-edi' we need to discard
+    // the last possible hyphnation point because of 1). The the right most valid 
+    // hyphenation position is "ed=itor". The first '-' left of this position is 
+    // "line-ed", thus because of 2) we now need to discard all possible hyphneation
+    // positions to the left of that as well. Thus in the end leaving us with just
+    // 'multi-line-ed=itor' as return value for this function. (Just one valid hyphenation
+    // position for the user too choose from. However ALL the '-' characters in the word
+    // will ALWAYS be valid implicit hyphenation positions for the core to choose from!
+    // And thus even if this word is skipped in the hyphenation dialog it will still be broken
+    // right after 'multi-line-' (actually it might already be broken up that way before
+    // the hyphenation dialog is called!).
+    // Thus rule 2) just eliminates those positions which will not be used by the core at all
+    // even if the user were to select one of them.
+
+    String aTxt;
+    DBG_ASSERT(rxPossHyph.is(), "missing possible hyphens");
+    if (rxPossHyph.is())
+    {
+        DBG_ASSERT( aActWord == rxPossHyph->getWord(), "word mismatch"  );
+
+        aTxt = String( rxPossHyph->getPossibleHyphens() );
+
+        nHyphenationPositionsOffset = 0;
+        uno::Sequence< sal_Int16 > aHyphenationPositions(
+                rxPossHyph->getHyphenationPositions() );
+        sal_Int32 nLen = aHyphenationPositions.getLength();
+        const sal_Int16 *pHyphenationPos = aHyphenationPositions.getConstArray();
+
+        // find position nIdx after which all hyphen positions are unusable
+        xub_StrLen  nIdx = STRING_NOTFOUND;
+        xub_StrLen  nPos = 0, nPos1 = 0, nPos2 = 0;
+        if (nLen)
+        {
+            xub_StrLen nStart = 0;
+            for (sal_Int32 i = 0;  i < nLen;  ++i)
+            {
+                if (pHyphenationPos[i] > _nMaxHyphenationPos)
+                    break;
+                else
+                {
+                    // find corresponding hyphen pos in string
+                    nPos = aTxt.Search( sal_Unicode( HYPH_POS_CHAR ), nStart );
+
+                    if (nStart == STRING_NOTFOUND)
+                        break;
+                    else
+                    {
+                        nIdx = nPos;
+                        nStart = nPos + 1;
+                    }
+                }
+            }
+        }
+        DBG_ASSERT(nIdx != STRING_NOTFOUND, "no usable hyphenation position");
+
+        // 1) remove all not usable hyphenation positions from the end of the string
+        nPos = nIdx == STRING_NOTFOUND ? 0 : nIdx + 1;
+        nPos1 = nPos;   //save for later use in 2) below
+        const String aTmp( sal_Unicode( HYPH_POS_CHAR ) );
+        const String aEmpty;
+        while (nPos != STRING_NOTFOUND)
+            nPos = aTxt.SearchAndReplace( aTmp, aEmpty, nPos + 1 );
+
+        // 2) remove all hyphenation positions from the start that are not considered by the core
+        const String aSearchRange( aTxt.Copy( 0, nPos1 ) );
+        nPos2 = aSearchRange.SearchBackward( '-' );  // the '-' position the core will use by default
+        if (nPos2 != STRING_NOTFOUND)
+        {
+            String aLeft( aSearchRange.Copy( 0, nPos2 ) );
+            nPos = 0;
+            while (nPos != STRING_NOTFOUND)
+            {
+                nPos = aLeft.SearchAndReplace( aTmp, aEmpty, nPos + 1 );
+                if (nPos != STRING_NOTFOUND)
+                    ++nHyphenationPositionsOffset;
+            }
+            aTxt.Replace( 0, nPos2, aLeft );
+        }
+    }
+    return aTxt;
+}
+
+
+void SvxHyphenWordDialog_Impl::InitControls_Impl()
+{
+    xPossHyph = NULL;
+    if (xHyphenator.is())
+    {
+        lang::Locale aLocale( SvxCreateLocale(nActLanguage) );
+        xPossHyph = xHyphenator->createPossibleHyphens( aActWord, aLocale,
+                                                        uno::Sequence< beans::PropertyValue >() );
+        if (xPossHyph.is())
+            aEditWord = EraseUnusableHyphens_Impl( xPossHyph, nMaxHyphenationPos );
+    }
+    aWordEdit.SetText( aEditWord );
+
+    nOldPos = aEditWord.Len();
+    SelLeft_Impl();
+    EnableLRBtn_Impl();
+}
+
+
+void SvxHyphenWordDialog_Impl::ContinueHyph_Impl( sal_uInt16 nInsPos )
+{
+    if ( nInsPos != CONTINUE_HYPH  &&  xPossHyph.is())
+    {
+        if (nInsPos)
+        {
+            String aTmp( aEditWord );
+            DBG_ASSERT(nInsPos <= aTmp.Len() - 2, "wrong hyphen position");
+
+            sal_Int16 nIdxPos = -1;
+            for (sal_uInt16 i = 0; i <= nInsPos; ++i)
+            {
+                if (HYPH_POS_CHAR == aTmp.GetChar( i ))
+                    nIdxPos++;
+            }
+            // take the possible hyphenation positions that got removed from the
+            // start of the wor dinot account:
+            nIdxPos += nHyphenationPositionsOffset;
+
+            uno::Sequence< sal_Int16 > aSeq = xPossHyph->getHyphenationPositions();
+            sal_Int32 nLen = aSeq.getLength();
+            DBG_ASSERT(nLen, "empty sequence");
+            DBG_ASSERT(0 <= nIdxPos && nIdxPos < nLen, "index out of range");
+            if (nLen && 0 <= nIdxPos && nIdxPos < nLen)
+            {
+                nInsPos = aSeq.getConstArray()[ nIdxPos ];
+                pHyphWrapper->InsertHyphen( nInsPos );
+            }
+        }
+        else
+        {
+            //! calling with 0 as argument will remove hyphens!
+            pHyphWrapper->InsertHyphen( nInsPos );
+        }
+    }
+
+    if ( pHyphWrapper->FindSpellError() )
+    {
+        uno::Reference< linguistic2::XHyphenatedWord >  xHyphWord( pHyphWrapper->GetLast(), uno::UNO_QUERY );
+
+        // adapt actual word and language to new found hyphenation result
+        if(xHyphWord.is())
+        {
+            aActWord    = String( xHyphWord->getWord() );
+            nActLanguage = SvxLocaleToLanguage( xHyphWord->getLocale() );
+            nMaxHyphenationPos = xHyphWord->getHyphenationPos();
+            InitControls_Impl();
+            m_pDialog->SetWindowTitle( nActLanguage );
+        }
+    }
+    else
+        m_pDialog->EndDialog( RET_OK );
+}
+
+
+sal_uInt16 SvxHyphenWordDialog_Impl::GetHyphIndex_Impl()
+{
+    sal_uInt16 nPos = 0;
+    String aTxt( aWordEdit.GetText() );
+
+    for ( sal_uInt16 i=0 ; i < aTxt.Len(); ++i )
+    {
+        sal_Unicode cChar = aTxt.GetChar( i );
+        if ( cChar == CUR_HYPH_POS_CHAR )
+            break;
+        if ( cChar != HYPH_POS_CHAR )
+            nPos++;
+    }
+    return nPos;
+}
+
+
+void SvxHyphenWordDialog_Impl::SelLeft_Impl()
+{
+    DBG_ASSERT( nOldPos > 0, "invalid hyphenation position" );
+    if (nOldPos > 0)
+    {
+        String aTxt( aEditWord );
+        for ( xub_StrLen i = nOldPos - 1;  i > 0; --i)
+        {
+            DBG_ASSERT(i <= aTxt.Len(), "index out of range");
+            if (aTxt.GetChar( i ) == sal_Unicode( HYPH_POS_CHAR ))
+            {
+                aTxt.SetChar( i, sal_Unicode( CUR_HYPH_POS_CHAR ) );
+
+                nOldPos = i;
+                aWordEdit.SetText( aTxt );
+                aWordEdit.GrabFocus();
+                aWordEdit.SetSelection( Selection( i, i + 1 ) );
+                break;
+            }
+        }
+        nHyphPos = GetHyphIndex_Impl();
+        EnableLRBtn_Impl();
+    }
+}
+
+
+void SvxHyphenWordDialog_Impl::SelRight_Impl()
+{
+    String aTxt( aEditWord );
+    for ( xub_StrLen i = nOldPos + 1;  i < aTxt.Len();  ++i )
+    {
+        if (aTxt.GetChar( i ) == sal_Unicode( HYPH_POS_CHAR ))
+        {
+            aTxt.SetChar( i, sal_Unicode( CUR_HYPH_POS_CHAR ) );
+
+            nOldPos = i;
+            aWordEdit.SetText( aTxt );
+            aWordEdit.GrabFocus();
+            aWordEdit.SetSelection( Selection( i, i + 1 ) );
+            break;
+        }
+    }
+    nHyphPos = GetHyphIndex_Impl();
+    EnableLRBtn_Impl();
+}
+
+
+IMPL_LINK( SvxHyphenWordDialog_Impl, CutHdl_Impl, Button *, EMPTYARG )
+{
+    if( !bBusy )
+    {
+        bBusy = sal_True;
+        ContinueHyph_Impl( /*nHyphPos*/nOldPos );
+        bBusy = sal_False;
+    }
+    return 0;
+}
+
+
+IMPL_LINK( SvxHyphenWordDialog_Impl, HyphenateAllHdl_Impl, Button *, EMPTYARG /*pButton*/ )
+{
+    if( !bBusy )
+    {
+        try
+        {
+            uno::Reference< beans::XPropertySet >  xProp( SvxGetLinguPropertySet() );
+            const rtl::OUString aName( rtl::OUString::createFromAscii( "IsHyphAuto" ) );
+            uno::Any aAny;
+        
+            aAny <<= sal_True;
+            xProp->setPropertyValue( aName, aAny );
+
+            bBusy = sal_True;
+            ContinueHyph_Impl( /*nHyphPos*/nOldPos );
+            bBusy = sal_False;
+
+            aAny <<= sal_False;
+            xProp->setPropertyValue( aName, aAny );
+        }
+        catch (uno::Exception &e)
+        {
+            (void) e;
+            DBG_ASSERT( 0, "Hyphenate All failed" );
+        }    
+    }
+    return 0;
+}    
+
+
+IMPL_LINK( SvxHyphenWordDialog_Impl, DeleteHdl_Impl, Button *, EMPTYARG )
+{
+    if( !bBusy )
+    {
+        bBusy = sal_True;
+        ContinueHyph_Impl();
+        bBusy = sal_False;
+    }
+    return 0;
+}
+
+
+IMPL_LINK( SvxHyphenWordDialog_Impl, ContinueHdl_Impl, Button *, EMPTYARG )
+{
+    if( !bBusy )
+    {
+        bBusy = sal_True;
+        ContinueHyph_Impl( CONTINUE_HYPH );
+        bBusy = sal_False;
+    }
+    return 0;
+}
+
+
+IMPL_LINK( SvxHyphenWordDialog_Impl, CancelHdl_Impl, Button *, EMPTYARG )
+{
+    if( !bBusy )
+    {
+        bBusy = sal_True;
+        pHyphWrapper->SpellEnd();
+        m_pDialog->EndDialog( RET_CANCEL );
+        bBusy = sal_False;
+    }
+    return 0;
+}
+
+
+IMPL_LINK( SvxHyphenWordDialog_Impl, Left_Impl, Button *, EMPTYARG )
+{
+    if( !bBusy )
+    {
+        bBusy = sal_True;
+        SelLeft_Impl();
+        bBusy = sal_False;
+    }
+    return 0;
+}
+
+
+IMPL_LINK( SvxHyphenWordDialog_Impl, Right_Impl, Button *, EMPTYARG )
+{
+    if( !bBusy )
+    {
+        bBusy = sal_True;
+        SelRight_Impl();
+        bBusy = sal_False;
+    }
+    return 0;
+}
+
+
+IMPL_LINK( SvxHyphenWordDialog_Impl, GetFocusHdl_Impl, Edit *, EMPTYARG )
+{
+    aWordEdit.SetSelection( Selection( nOldPos, nOldPos + 1 ) );
+    return 0;
+}
+
+    
 // class SvxHyphenWordDialog ---------------------------------------------
 
-SvxHyphenWordDialog::SvxHyphenWordDialog( const String &rWord, LanguageType nLang,
-										  Window* pParent,
-										  Reference< XHyphenator >  &xHyphen,
-										  SvxSpellWrapper* pWrapper ) :
-	SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_HYPHENATE ) ),
+SvxHyphenWordDialog::SvxHyphenWordDialog( 
+    const String &rWord, LanguageType nLang,
+    Window* pParent,
+    uno::Reference< linguistic2::XHyphenator >  &xHyphen,
+    SvxSpellWrapper* pWrapper ) :
+    
+    SfxModalDialog( pParent, CUI_RES( RID_SVXDLG_HYPHENATE ) )
+{
+    m_pImpl = std::auto_ptr< SvxHyphenWordDialog_Impl >(
+            new SvxHyphenWordDialog_Impl( this, rWord, nLang, xHyphen, pWrapper ) );
 
-    aWordFT     ( this, CUI_RES( FT_WORD ) ),
-	aWordEdit	( this, CUI_RES( ED_WORD ) ),
-	aLeftBtn	( this, CUI_RES( BTN_LEFT ) ),
-	aRightBtn	( this, CUI_RES( BTN_RIGHT ) ),
-	aOkBtn		( this, CUI_RES( BTN_HYPH_CUT ) ),
-	aCancelBtn	( this, CUI_RES( BTN_HYPH_CANCEL ) ),
-	aContBtn	( this, CUI_RES( BTN_HYPH_CONTINUE ) ),
-	aDelBtn		( this, CUI_RES( BTN_HYPH_DELETE ) ),
-	aHelpBtn	( this, CUI_RES( BTN_HYPH_HELP ) ),
-	aLabel			( GetText() ),
-	pHyphWrapper	( pWrapper ),
-	xHyphenator		( xHyphen ),
-	aActWord		( rWord ),
-	nActLanguage	( nLang ),
-	nHyphPos		( 0 ),
-	nOldPos			( 0 ),
-	bBusy			( sal_False )
-{
-	aContBtn.SetClickHdl(
-		LINK( this, SvxHyphenWordDialog, ContinueHdl_Impl ) );
-	aOkBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, CutHdl_Impl ) );
-	aDelBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, DeleteHdl_Impl ) );
-	aCancelBtn.SetClickHdl(
-		LINK( this, SvxHyphenWordDialog, CancelHdl_Impl ) );
-	aLeftBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, Left_Impl ) );
-	aRightBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, Right_Impl ) );
+    FreeResource();
 
-	aWordEdit.SetGetFocusHdl(
-		LINK( this, SvxHyphenWordDialog, GetFocusHdl_Impl ) );
-
-	Reference< XHyphenatedWord >  xHyphWord( pWrapper ?
-			pWrapper->GetLast() : Reference< XInterface > () , UNO_QUERY );
-	DBG_ASSERT(xHyphWord.is(), "missing hyphenated word");
-	nMaxHyphenationPos = xHyphWord.is() ? xHyphWord->getHyphenationPos() : 0;
-	SetLabel_Impl( nLang );
-
-	InitControls_Impl();
-	aWordEdit.GrabFocus();
-
-	FreeResource();
+    SetWindowTitle( nLang );
 
 	// disable controls if service is not available
-	if (!xHyphenator.is())
+    if (!m_pImpl->xHyphenator.is())
 		Enable( sal_False );
 }
 
-// -----------------------------------------------------------------------
+
+SvxHyphenWordDialog::~SvxHyphenWordDialog()
+{
+}    
+
+
+void SvxHyphenWordDialog::SetWindowTitle( LanguageType nLang )
+{
+    String aLangStr( SvtLanguageTable::GetLanguageString( nLang ) );
+    String aTmp( m_pImpl->aLabel );
+    aTmp.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) );
+    aTmp.Append( aLangStr );
+    aTmp.Append( sal_Unicode( ')' ) );
+    SetText( aTmp );
+}
+
 
 void SvxHyphenWordDialog::SelLeft()
 {
-	String aTxt( aWordEdit.GetText() );
-
-	for ( xub_StrLen i = nOldPos + 1;  i-- > 0 ; )
-	{
-		DBG_ASSERT(i <= aTxt.Len(), "index out of range");
-		if( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) )
-		{
-			aTxt.SetChar( i, sal_Unicode( HYPHHERE ) );
-
-			if ( nOldPos != 0 && nOldPos != aTxt.Len() )
-				aTxt.SetChar( nOldPos, sal_Unicode( SW_SOFT_HYPHEN ) );
-			nOldPos = i;
-			aWordEdit.SetText( aTxt );
-			aWordEdit.GrabFocus();
-			aWordEdit.SetSelection( Selection( i, i + 1 ) );
-			break;
-		}
-	}
-	nHyphPos = GetHyphIndex_Impl();
-	EnableLRBtn_Impl();
+    m_pImpl->SelRight_Impl();
 }
 
-// -----------------------------------------------------------------------
 
 void SvxHyphenWordDialog::SelRight()
 {
-	String aTxt( aWordEdit.GetText() );
-
-	for ( xub_StrLen i = nOldPos + 1;  i < aTxt.Len();  ++i )
-	{
-		if( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) )
-		{
-			aTxt.SetChar( i, sal_Unicode( HYPHHERE ) );
-
-			if ( nOldPos != 0 && nOldPos != aTxt.Len() )
-				aTxt.SetChar( nOldPos, sal_Unicode( SW_SOFT_HYPHEN ) );
-			nOldPos = i;
-			aWordEdit.SetText( aTxt );
-			aWordEdit.GrabFocus();
-			aWordEdit.SetSelection( Selection( i, i + 1 ) );
-			break;
-		}
-	}
-	nHyphPos = GetHyphIndex_Impl();
-	EnableLRBtn_Impl();
+    m_pImpl->SelLeft_Impl();
 }
 
-// -----------------------------------------------------------------------
 
-void SvxHyphenWordDialog::EnableLRBtn_Impl()
-{
-	String	aTxt( aWordEdit.GetText() );
-	xub_StrLen nLen = aTxt.Len();
-	xub_StrLen i;
-
-	aRightBtn.Disable();
-	for ( i = nOldPos + 2; i < nLen; ++i )
-	{
-		if ( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) )
-		{
-			aRightBtn.Enable();
-			break;
-		}
-	}
-
-	DBG_ASSERT(nOldPos < aTxt.Len(), "nOldPos out of range");
-	if (nOldPos >= aTxt.Len())
-		nOldPos = aTxt.Len() - 1;
-	aLeftBtn.Disable();
-	for ( i = nOldPos;  i-- > 0; )
-	{
-		if ( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) )
-		{
-			aLeftBtn.Enable();
-			break;
-		}
-	}
-}
-
-// -----------------------------------------------------------------------
-
-
-void SvxHyphenWordDialog::SetLabel_Impl( LanguageType nLang )
-{
-	String aLangStr( SvtLanguageTable::GetLanguageString( nLang ) );
-	String aTmp( aLabel );
-	aTmp.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) );
-	aTmp.Append( aLangStr );
-	aTmp.Append( sal_Unicode( ')' ) );
-	SetText( aTmp );
-}
-
-// -----------------------------------------------------------------------
-
-String SvxHyphenWordDialog::EraseUnusableHyphens_Impl(
-		Reference< XPossibleHyphens >  &rxPossHyph,
-		sal_uInt16 _nMaxHyphenationPos )
-{
-	// returns a String showing only those hyphen positions which will result
-	// in a line break if hyphenation is done there
-
-	String aTxt;
-	DBG_ASSERT(rxPossHyph.is(), "missing possible hyphens");
-	if (rxPossHyph.is())
-	{
-		aTxt = String( rxPossHyph->getPossibleHyphens() );
-
-		Sequence< sal_Int16 > aHyphenationPositions(
-				rxPossHyph->getHyphenationPositions() );
-		sal_Int32 nLen = aHyphenationPositions.getLength();
-		const sal_Int16 *pHyphenationPos = aHyphenationPositions.getConstArray();
-
-		// find position nIdx after which all hyphen positions are unusable
-		xub_StrLen nIdx = STRING_NOTFOUND,
-			  nPos;
-		if (nLen)
-		{
-			xub_StrLen nStart = 0;
-			for (sal_Int32 i = 0;  i < nLen;  ++i)
-			{
-				if (pHyphenationPos[i] > _nMaxHyphenationPos)
-					break;
-				else
-				{
-					// find corresponding hyphen pos in string
-					nPos = aTxt.Search( sal_Unicode( SW_SOFT_HYPHEN ), nStart );
-
-					if (nStart == STRING_NOTFOUND)
-						break;
-					else
-					{
-						nIdx = nPos;
-						nStart = nPos + 1;
-					}
-				}
-			}
-		}
-		DBG_ASSERT(nIdx != STRING_NOTFOUND, "no usable hyphenation position");
-
-		// remove not usable hyphens from string
-		nPos = nIdx == STRING_NOTFOUND ? 0 : nIdx + 1;
-		String aTmp( sal_Unicode( SW_SOFT_HYPHEN ) ),
-			   aEmpty;
-		while (nPos != STRING_NOTFOUND)
-			nPos = aTxt.SearchAndReplace( aTmp, aEmpty, nPos + 1 );
-	}
-	return aTxt;
-}
-
-// -----------------------------------------------------------------------
-
-void SvxHyphenWordDialog::InitControls_Impl()
-{
-	String aTxt;
-	xPossHyph = NULL;
-	if (xHyphenator.is())
-	{
-		lang::Locale aLocale( SvxCreateLocale(nActLanguage) );
-		xPossHyph = xHyphenator->createPossibleHyphens( aActWord, aLocale,
-														Sequence< PropertyValue >() );
-		if (xPossHyph.is())
-		{
-			aTxt = EraseUnusableHyphens_Impl( xPossHyph, nMaxHyphenationPos );
-		}
-		SetLabel_Impl( nActLanguage );
-	}
-	aWordEdit.SetText( aTxt );
-
-	nOldPos = aTxt.Len();
-	SelLeft();
-	EnableLRBtn_Impl();
-}
-
-// -----------------------------------------------------------------------
-
-void SvxHyphenWordDialog::ContinueHyph_Impl( sal_uInt16 nInsPos )
-{
-	if ( nInsPos != CONTINUE_HYPH  &&  xPossHyph.is())
-	{
-		if (nInsPos)
-		{
-			//String aTmp( U2S( xPossHyph->getPossibleHyphens() ) );
-			String aTmp( aWordEdit.GetText() );
-			DBG_ASSERT(nInsPos <= aTmp.Len() - 2, "wrong hyphen position");
-
-			sal_uInt16 nIdxPos = 0;
-			sal_uInt16 i = 0;
-			sal_Unicode  c;
-			while (i < aTmp.Len()  &&  HYPHHERE != (c = aTmp.GetChar(i++)) )
-			{
-				if (SW_SOFT_HYPHEN == c)
-					nIdxPos++;
-			}
-
-			Sequence< sal_Int16 > aSeq = xPossHyph->getHyphenationPositions();
-			sal_Int32 nLen = aSeq.getLength();
-			DBG_ASSERT(nLen, "empty sequence");
-			DBG_ASSERT(nIdxPos < nLen, "index out of range");
-			if (nLen && nIdxPos < nLen)
-			{
-				nInsPos = aSeq.getConstArray()[ nIdxPos ];
-				pHyphWrapper->InsertHyphen( nInsPos );
-			}
-		}
-		else
-		{
-			//! calling with 0 as argument will remove hyphens!
-			pHyphWrapper->InsertHyphen( nInsPos );
-		}
-	}
-
-	if ( pHyphWrapper->FindSpellError() )
-	{
-		Reference< XHyphenatedWord >  xHyphWord( pHyphWrapper->GetLast(), UNO_QUERY );
-
-		// adapt actual word and language to new found hyphenation result
-		if(xHyphWord.is())
-		{
-			aActWord	 = String( xHyphWord->getWord() );
-			nActLanguage = SvxLocaleToLanguage( xHyphWord->getLocale() );
-			nMaxHyphenationPos = xHyphWord->getHyphenationPos();
-			InitControls_Impl();
-		}
-	}
-	else
-		EndDialog( RET_OK );
-}
-
-// -----------------------------------------------------------------------
-
-sal_uInt16 SvxHyphenWordDialog::GetHyphIndex_Impl()
-{
-	sal_uInt16 nPos = 0;
-	String aTxt(aWordEdit.GetText());
-
-	for ( sal_uInt16 i=0 ; i < aTxt.Len(); ++i )
-	{
-		sal_Unicode nChar = aTxt.GetChar( i );
-
-		if ( nChar == HYPHHERE )
-			break;
-
-		if ( nChar != SW_SOFT_HYPHEN )
-			nPos++;
-	}
-	return nPos;
-}
-
-// -----------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( SvxHyphenWordDialog, CutHdl_Impl, Button *, EMPTYARG )
-{
-	if( !bBusy )
-	{
-		bBusy = sal_True;
-		ContinueHyph_Impl( nHyphPos );
-		bBusy = sal_False;
-	}
-	return 0;
-}
-IMPL_LINK_INLINE_END( SvxHyphenWordDialog, CutHdl_Impl, Button *, EMPTYARG )
-
-// -----------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( SvxHyphenWordDialog, DeleteHdl_Impl, Button *, EMPTYARG )
-{
-	if( !bBusy )
-	{
-		bBusy = sal_True;
-		ContinueHyph_Impl();
-		bBusy = sal_False;
-	}
-	return 0;
-}
-IMPL_LINK_INLINE_END( SvxHyphenWordDialog, DeleteHdl_Impl, Button *, EMPTYARG )
-
-// -----------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( SvxHyphenWordDialog, ContinueHdl_Impl, Button *, EMPTYARG )
-{
-	if( !bBusy )
-	{
-		bBusy = sal_True;
-		ContinueHyph_Impl( CONTINUE_HYPH );
-		bBusy = sal_False;
-	}
-	return 0;
-}
-IMPL_LINK_INLINE_END( SvxHyphenWordDialog, ContinueHdl_Impl, Button *, EMPTYARG )
-
-// -----------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( SvxHyphenWordDialog, CancelHdl_Impl, Button *, EMPTYARG )
-{
-	if( !bBusy )
-	{
-		bBusy = sal_True;
-		pHyphWrapper->SpellEnd();
-		EndDialog( RET_CANCEL );
-		bBusy = sal_False;
-	}
-	return 0;
-}
-IMPL_LINK_INLINE_END( SvxHyphenWordDialog, CancelHdl_Impl, Button *, EMPTYARG )
-
-// -----------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( SvxHyphenWordDialog, Left_Impl, Button *, EMPTYARG )
-{
-	if( !bBusy )
-	{
-		bBusy = sal_True;
-		SelLeft();
-		bBusy = sal_False;
-	}
-	return 0;
-}
-IMPL_LINK_INLINE_END( SvxHyphenWordDialog, Left_Impl, Button *, EMPTYARG )
-
-// -----------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( SvxHyphenWordDialog, Right_Impl, Button *, EMPTYARG )
-{
-	if( !bBusy )
-	{
-		bBusy = sal_True;
-		SelRight();
-		bBusy = sal_False;
-	}
-	return 0;
-}
-IMPL_LINK_INLINE_END( SvxHyphenWordDialog, Right_Impl, Button *, EMPTYARG )
-
-// -----------------------------------------------------------------------
-
-IMPL_LINK_INLINE_START( SvxHyphenWordDialog, GetFocusHdl_Impl, Edit *, EMPTYARG )
-{
-	aWordEdit.SetSelection( Selection( nOldPos, nOldPos + 1 ) );
-	return 0;
-}
-IMPL_LINK_INLINE_END( SvxHyphenWordDialog, GetFocusHdl_Impl, Edit *, EMPTYARG )
-
-// -----------------------------------------------------------------------
-
-IMPL_LINK( SvxHyphenWordDialog, LangError_Impl, void *, nLang )
-{
-	// Status anzeigen
-	String aErr( SvtLanguageTable::GetLanguageString( (LanguageType)(sal_IntPtr)nLang ) );
-	aErr += CUI_RESSTR( RID_SVXSTR_HMERR_CHECKINSTALL );
-	InfoBox( this, aErr ).Execute();
-	return 0;
-}
-
-

File cui/source/dialogs/hyphen.hrc

 #define BTN_LEFT			11
 #define BTN_RIGHT			12
 #define FT_WORD             13
+#define FL_BOTTOM           14
 
 #define BTN_HYPH_CONTINUE	20
 #define BTN_HYPH_DELETE		21
 #define BTN_HYPH_CUT		22
 #define BTN_HYPH_CANCEL		23
 #define BTN_HYPH_HELP		24
-
+#define BTN_HYPH_ALL        25
 
 #endif
 

File cui/source/dialogs/hyphen.src

 ModalDialog RID_SVXDLG_HYPHENATE
 {
 	HelpId = HID_HYPHENATE ;
-    Size = MAP_APPFONT ( 188 , 100 ) ;
+    Size = MAP_APPFONT ( 200 , 111 ) ;
 	OutputSize = TRUE ;
 	SvLook = TRUE ;
 	Text [ en-US ] = "Hyphenation" ;
 	Moveable = TRUE ;
+
+    FixedText FT_WORD
+    {
+        Pos = MAP_APPFONT ( 5 , 5 ) ;
+        Size = MAP_APPFONT ( 120 , 8 ) ;
+        Text [ en-US ] = "~Word" ;
+    };
 	Edit ED_WORD
 	{
 		BORDER = TRUE ;
-        Pos = MAP_APPFONT ( 6 , 17 ) ;
-        Size = MAP_APPFONT ( 120 , 12 ) ;
+        Pos = MAP_APPFONT ( 5 , 17 ) ;
+        Size = MAP_APPFONT ( 132 , 12 ) ;
 		TABSTOP = TRUE ;
 		LEFT = TRUE ;
 	};
 	ImageButton BTN_LEFT
 	{
-        Pos = MAP_APPFONT ( 6 , 33 ) ;
+        Pos = MAP_APPFONT ( 56 , 33 ) ;
 		Size = MAP_APPFONT ( 14 , 14 ) ;
 		TABSTOP = TRUE ;
 		SYMBOL = IMAGEBUTTON_ARROW_LEFT ;
 	};
 	ImageButton BTN_RIGHT
 	{
-        Pos = MAP_APPFONT ( 22 , 33 ) ;
+        Pos = MAP_APPFONT ( 75 , 33 ) ;
 		Size = MAP_APPFONT ( 14 , 14 ) ;
 		TABSTOP = TRUE ;
 		Symbol = IMAGEBUTTON_ARROW_RIGHT ;
 	};
-    FixedText FT_WORD
-	{
-        Pos = MAP_APPFONT ( 6 , 6 ) ;
-        Size = MAP_APPFONT ( 120 , 8 ) ;
-        Text [ en-US ] = "~Word" ;
-	};
+    OKButton BTN_HYPH_CUT
+    {
+        Pos = MAP_APPFONT ( 144 , 17 ) ;
+        Size = MAP_APPFONT ( 50 , 14 ) ;
+        Text [ en-US ] = "H~yphenate" ;
+        TABSTOP = TRUE ;
+        DEFBUTTON = TRUE ;
+    };
 	PushButton BTN_HYPH_CONTINUE
 	{
-        Pos = MAP_APPFONT ( 132 , 43 ) ;
-		Size = MAP_APPFONT ( 50 , 14 ) ;
-		Text [ en-US ] = "~Next" ;
+        Pos = MAP_APPFONT ( 144 , 35 ) ;
+        Size = MAP_APPFONT ( 50 , 14 ) ;
+        Text [ en-US ] = "~Skip" ;
 		TABSTOP = TRUE ;
 	};
 	PushButton BTN_HYPH_DELETE
 	{
-        Pos = MAP_APPFONT ( 132 , 60 ) ;
+        Pos = MAP_APPFONT ( 144 , 52 ) ;
 		Size = MAP_APPFONT ( 50 , 14 ) ;
 		Text [ en-US ] = "~Remove" ;
 		TABSTOP = TRUE ;
 	};
-	OKButton BTN_HYPH_CUT
-	{
-        Pos = MAP_APPFONT ( 132 , 6 ) ;
-		Size = MAP_APPFONT ( 50 , 14 ) ;
-		Text [ en-US ] = "~Hyphenate" ;
-		TABSTOP = TRUE ;
-		DEFBUTTON = TRUE ;
-	};
+    FixedLine FL_BOTTOM
+    {
+        Pos = MAP_APPFONT ( 0 , 81 ) ;
+        Size = MAP_APPFONT ( 200 , 8 ) ;
+    };
+    HelpButton BTN_HYPH_HELP
+    {
+        Pos = MAP_APPFONT ( 5 , 93 ) ;
+        Size = MAP_APPFONT ( 50 , 14 ) ;
+        TABSTOP = TRUE ;
+    };
+    PushButton BTN_HYPH_ALL
+    {
+        Pos = MAP_APPFONT ( 63 , 93 ) ;
+        Size = MAP_APPFONT ( 74 , 14 ) ;
+        Text [ en-US ] = "Hyphenate ~All" ;
+        TABSTOP = TRUE ;
+    };
 	CancelButton BTN_HYPH_CANCEL
 	{
-        Pos = MAP_APPFONT ( 132 , 23 ) ;
+        Pos = MAP_APPFONT ( 144 , 93 ) ;
 		Size = MAP_APPFONT ( 50 , 14 ) ;
-		TABSTOP = TRUE ;
-	};
-	HelpButton BTN_HYPH_HELP
-	{
-        Pos = MAP_APPFONT ( 132 , 80 ) ;
-		Size = MAP_APPFONT ( 50 , 14 ) ;
+        Text [ en-US ] = "~Close";
 		TABSTOP = TRUE ;
 	};
 };
- // ******************************************************************* EOF
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

File cui/source/dialogs/thesdlg.cxx

  ************************************************************************/
 
 // MARKER(update_precomp.py): autogen include statement, do not remove
+
 #include "precompiled_cui.hxx"
 
+#include "thesdlg.hrc"
+#include "thesdlg.hxx"
+#include "thesdlg_impl.hxx"
+#include "cuires.hrc"
+#include "dialmgr.hxx"
+
+#include <editeng/unolingu.hxx>
 #include <tools/shl.hxx>
 #include <svl/lngmisc.hxx>
+#include <svtools/filter.hxx>
+#include <svtools/svlbitm.hxx>
+#include <svtools/svtreebx.hxx>
 #include <vcl/wrkwin.hxx>
 #include <vcl/msgbox.hxx>
 #include <vcl/svapp.hxx>
 #include <svx/dlgutil.hxx>
 #include <svx/dialmgr.hxx>
 #include <svx/svxerr.hxx>
-#include "cuires.hrc"
-#include "thesdlg.hrc"
 #include <editeng/unolingu.hxx>
 #include <svx/langbox.hxx>
 #include <svtools/langtab.hxx>
-#include "dialmgr.hxx"
-#include <svx/dialogs.hrc>
-#include <editeng/editerr.hxx>
+#include <unotools/lingucfg.hxx>
+#include <i18npool/mslangid.hxx>
+#include <comphelper/processfactory.hxx>
+#include <osl/file.hxx>
+
+
+#include <stack>
+#include <algorithm>
+
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/linguistic2/XMeaning.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
 
 using namespace ::com::sun::star;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::linguistic2;
+using ::rtl::OUString;
 
-#undef S2U
-#undef U2S
-//#define S2U(s) 						StringToOUString(s, CHARSET_SYSTEM)
-//#define U2S(s)						OUStringToString(s, CHARSET_SYSTEM)
+
+#define A2S(x)          String::CreateFromAscii( x )
+
 
 
 // GetReplaceEditString -------------------------------
     rText.EraseLeadingAndTrailingChars( sal_Unicode(' ') );
 }
 
-// struct ThesDlg_Impl ---------------------------------------------------
+// class LookUpComboBox_Impl --------------------------------------------------
+    
+LookUpComboBox_Impl::LookUpComboBox_Impl( 
+    Window *pParent, const ResId &rResId, SvxThesaurusDialog_Impl &rImpl ) :
+    ComboBox        (pParent, rResId),
+    m_rDialogImpl( rImpl )
+{
+    m_aModifyTimer.SetTimeoutHdl( LINK( this, LookUpComboBox_Impl, ModifyTimer_Hdl ) );
+    m_aModifyTimer.SetTimeout( 500 );
+    
+    EnableAutocomplete( FALSE );
+}
+    
 
-struct ThesDlg_Impl
+LookUpComboBox_Impl::~LookUpComboBox_Impl()
 {
-	Reference< XThesaurus >	xThesaurus;
-	::rtl::OUString				aLookUpText;
-	sal_Int16				nLookUpLanguage;
+}
+    
 
-	ThesDlg_Impl( Reference< XThesaurus > & xThes );
-	SfxErrorContext*	pErrContext;	// ErrorContext,
-										// w"ahrend der Dialog oben ist
-};
-
-ThesDlg_Impl::ThesDlg_Impl(Reference< XThesaurus > & xThes) :
-	xThesaurus	(xThes)
+void LookUpComboBox_Impl::Modify()
 {
-	pErrContext = NULL;
-	nLookUpLanguage = LANGUAGE_NONE;
+    m_aModifyTimer.Start();
 }
 
 
-// class SvxThesaurusLanguageDlg_Impl ------------------------------------
-
-class SvxThesaurusLanguageDlg_Impl : public ModalDialog
+IMPL_LINK( LookUpComboBox_Impl, ModifyTimer_Hdl, Timer *, EMPTYARG /*pTimer*/ )
 {
-private:
-	SvxLanguageBox	aLangLB;
-    FixedLine       aLangFL;
-	OKButton		aOKBtn;
-	CancelButton	aCancelBtn;
-	HelpButton		aHelpBtn;
-
-	DECL_LINK( DoubleClickHdl_Impl, ListBox * );
-
-public:
-	SvxThesaurusLanguageDlg_Impl( Window* pParent );
-
-	sal_uInt16		GetLanguage() const;
-	void			SetLanguage( sal_uInt16 nLang );
-};
-
-// -----------------------------------------------------------------------
-
-
-SvxThesaurusLanguageDlg_Impl::SvxThesaurusLanguageDlg_Impl( Window* pParent ) :
-
-	ModalDialog( pParent, CUI_RES( RID_SVXDLG_THES_LANGUAGE ) ),
-
-	aLangLB		( this, CUI_RES( LB_THES_LANGUAGE ) ),
-    aLangFL     ( this, CUI_RES( FL_THES_LANGUAGE ) ),
-	aOKBtn		( this, CUI_RES( BTN_LANG_OK ) ),
-	aCancelBtn	( this, CUI_RES( BTN_LANG_CANCEL ) ),
-	aHelpBtn	( this, CUI_RES( BTN_LANG_HELP ) )
-{
-	FreeResource();
-
-    aLangLB.SetLanguageList( LANG_LIST_THES_USED, FALSE, FALSE );
-	aLangLB.SetDoubleClickHdl(
-		LINK( this, SvxThesaurusLanguageDlg_Impl, DoubleClickHdl_Impl ) );
+    m_rDialogImpl.LookUp( GetText() );
+    m_aModifyTimer.Stop();
+    return 0;
 }
 
 
-// -----------------------------------------------------------------------
+// class ReplaceEdit_Impl --------------------------------------------------
+    
+ReplaceEdit_Impl::ReplaceEdit_Impl( 
+    Window *pParent, const ResId &rResId ) :
+    Edit        (pParent, rResId)
+{
+}
+    
 
-sal_uInt16 SvxThesaurusLanguageDlg_Impl::GetLanguage() const
+ReplaceEdit_Impl::~ReplaceEdit_Impl()
 {
-	sal_uInt16 nLang = aLangLB.GetSelectLanguage();
-	return nLang;
+}
+    
+
+void ReplaceEdit_Impl::Modify()
+{
+    if (m_pBtn)
+        m_pBtn->Enable( GetText().Len() > 0 );
 }
 
-// -----------------------------------------------------------------------
-
-void SvxThesaurusLanguageDlg_Impl::SetLanguage( sal_uInt16 nLang )
+void ReplaceEdit_Impl::SetText( const XubString& rStr )
 {
-	aLangLB.SelectLanguage( nLang );
+    Edit::SetText( rStr );
+    Modify();
 }
 
-// -----------------------------------------------------------------------
+    
+void ReplaceEdit_Impl::SetText( const XubString& rStr, const Selection& rNewSelection )
+{
+    Edit::SetText( rStr, rNewSelection );
+    Modify();
+}    
 
-IMPL_LINK_INLINE_START( SvxThesaurusLanguageDlg_Impl, DoubleClickHdl_Impl, ListBox *, EMPTYARG )
+
+// class ThesaurusAlternativesCtrl_Impl ----------------------------------
+
+void AlternativesString_Impl::Paint( 
+    const Point& rPos, 
+    SvLBox& rDev, USHORT,
+	SvLBoxEntry* pEntry )
 {
-	EndDialog( RET_OK );
-	return 0;
-}
-IMPL_LINK_INLINE_END( SvxThesaurusLanguageDlg_Impl, DoubleClickHdl_Impl, ListBox *, EMPTYARG )
-
-// class SvxThesaurusDialog ----------------------------------------------
-
-
-// -----------------------------------------------------------------------
-
-
-SvxThesaurusDialog::SvxThesaurusDialog( Window* pParent, Reference< XThesaurus >  xThes,
-										const String &rWord, sal_Int16 nLanguage) :
-
-	SvxStandardDialog( pParent, CUI_RES( RID_SVXDLG_THESAURUS ) ),
-
-	aWordText	( this, CUI_RES( FT_WORD ) ),
-	aWordLB		( this, CUI_RES( LB_WORD ) ),
-	aReplaceText( this, CUI_RES( FT_REPL ) ),
-	aReplaceEdit( this, CUI_RES( ED_REPL ) ),
-	aMeanText	( this, CUI_RES( FT_MEAN ) ),
-	aMeanLB		( this, CUI_RES( LB_MEAN ) ),
-	aSynonymText( this, CUI_RES( FT_SYNON ) ),
-	aSynonymLB	( this, CUI_RES( LB_SYNON ) ),
-    aVarFL      ( this, CUI_RES( FL_VAR ) ),
-	aOkBtn		( this,	CUI_RES( BTN_THES_OK ) ),
-	aCancelBtn	( this, CUI_RES( BTN_THES_CANCEL ) ),
-	aLookUpBtn	( this, CUI_RES( BTN_LOOKUP ) ),
-	aLangBtn	( this, CUI_RES( BTN_LANGUAGE ) ),
-	aHelpBtn	( this, CUI_RES( BTN_THES_HELP ) ),
-	aErrStr		(		CUI_RES( STR_ERR_WORDNOTFOUND ) )
-{
-	pImpl = new ThesDlg_Impl( xThes );
-	pImpl->aLookUpText = ::rtl::OUString( rWord );
-	pImpl->nLookUpLanguage = nLanguage;
-	pImpl->pErrContext =
-		new	SfxErrorContext( ERRCTX_SVX_LINGU_THESAURUS, String(), this,
-							 RID_SVXERRCTX, &DIALOG_MGR() );
-
-	aLangBtn.SetClickHdl( LINK( this, SvxThesaurusDialog, LanguageHdl_Impl ) );
-	aLookUpBtn.SetClickHdl( LINK( this, SvxThesaurusDialog, LookUpHdl_Impl ) );
-	aMeanLB.SetSelectHdl( LINK( this, SvxThesaurusDialog, EntryHdl_Impl ) );
-	aSynonymLB.SetSelectHdl( LINK( this, SvxThesaurusDialog, SynonymHdl_Impl ) );
-	Link aLink = LINK( this, SvxThesaurusDialog, SelectHdl_Impl );
-	aMeanLB.SetDoubleClickHdl( aLink );
-	aSynonymLB.SetDoubleClickHdl( aLink );
-	aWordLB.SetSelectHdl( aLink );
-
-	FreeResource();
-
-	::rtl::OUString aTmp( rWord );
-	linguistic::RemoveHyphens( aTmp );
-    linguistic::ReplaceControlChars( aTmp );
-	aReplaceEdit.SetText( aTmp );
-	aWordLB.InsertEntry( aTmp );
-	aWordLB.SelectEntry( aTmp );
-
-	Init_Impl( nLanguage );
-
-	// disable controls if service is missing
-	if (!pImpl->xThesaurus.is())
-		Enable( sal_False );
+	AlternativesUserData_Impl* pData = (AlternativesUserData_Impl*)pEntry->GetUserData();
+	Point aPos( rPos );
+	Font aOldFont( rDev.GetFont());
+	if (pData && pData->IsHeader())
+	{
+		Font aFont( aOldFont );
+		aFont.SetWeight( WEIGHT_BOLD );
+		rDev.SetFont( aFont );
+		aPos.X() = 0;
+	}
+	else
+		aPos.X() += 5;
+	rDev.DrawText( aPos, GetText() );
+	rDev.SetFont( aOldFont );
 }
 
 
-// -----------------------------------------------------------------------
-
-SvxThesaurusDialog::~SvxThesaurusDialog()
+ThesaurusAlternativesCtrl_Impl::ThesaurusAlternativesCtrl_Impl( 
+        Window* pParent,
+        SvxThesaurusDialog_Impl &rImpl ) : 
+    SvxCheckListBox( pParent, CUI_RES( CT_THES_ALTERNATIVES ) ),
+    m_rDialogImpl( rImpl )
 {
-	delete pImpl->pErrContext;
-	delete pImpl;
+	SetWindowBits( WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE );
+	SetHighlightRange();
 }
 
-// -----------------------------------------------------------------------
 
-uno::Sequence< Reference< XMeaning > > SAL_CALL
-    SvxThesaurusDialog::queryMeanings_Impl(
-            ::rtl::OUString& rTerm,
-            const Locale& rLocale,
-            const beans::PropertyValues& rProperties )
-        throw(lang::IllegalArgumentException, uno::RuntimeException)
+ThesaurusAlternativesCtrl_Impl::~ThesaurusAlternativesCtrl_Impl()
 {
-    uno::Sequence< Reference< XMeaning > > aMeanings(
-            pImpl->xThesaurus->queryMeanings( rTerm, rLocale, rProperties ) );
+    ClearUserData();
+}
+
+
+void ThesaurusAlternativesCtrl_Impl::ClearUserData()
+{
+	for (USHORT i = 0; i < GetEntryCount(); ++i)
+		delete (AlternativesUserData_Impl*)GetEntry(i)->GetUserData();
+}
+
+
+SvLBoxEntry * ThesaurusAlternativesCtrl_Impl::AddEntry( sal_Int32 nVal, const String &rText, bool bIsHeader )
+{
+	SvLBoxEntry* pEntry = new SvLBoxEntry;
+    String aText;
+    if (bIsHeader && nVal >= 0)
+    {
+        aText = String::CreateFromInt32( nVal );
+        aText += A2S( ". " );
+    }
+    pEntry->AddItem( new SvLBoxString( pEntry, 0, String() ) );	// add empty column
+    aText += rText;
+    pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) );  // otherwise crash
+	pEntry->AddItem( new AlternativesString_Impl( pEntry, 0, aText ) );
+
+    AlternativesUserData_Impl* pUserData = new AlternativesUserData_Impl( rText, bIsHeader );
+	pEntry->SetUserData( pUserData );
+    GetModel()->Insert( pEntry );
+    
+    if (bIsHeader)
+        GetViewDataEntry( pEntry )->SetSelectable( false );
+
+	return pEntry;
+}
+
+
+void ThesaurusAlternativesCtrl_Impl::KeyInput( const KeyEvent& rKEvt )
+{
+    const KeyCode& rKey = rKEvt.GetKeyCode();
+
+    if (rKey.GetCode() == KEY_RETURN || rKey.GetCode() == KEY_ESCAPE)
+        GetParent()->KeyInput( rKEvt ); // parent will close dialog...
+    else if (rKey.GetCode() == KEY_SPACE)
+        m_rDialogImpl.AlternativesDoubleClickHdl_Impl( this ); // look up current selected entry
+    else if (GetEntryCount())
+        SvxCheckListBox::KeyInput( rKEvt );
+}    
+
+
+void ThesaurusAlternativesCtrl_Impl::Paint( const Rectangle& rRect )
+{
+    if (!m_rDialogImpl.m_bWordFound)
+    {
+/*        Push( PUSH_FONT );
+        
+        Font aFont( GetFont() );
+        aFont.SetHeight( 2 * aFont.GetHeight() );
+        SetFont( aFont );
+*/        
+        Size aTextSize( GetTextWidth( m_rDialogImpl.aErrStr ), GetTextHeight() );
+        aTextSize  = LogicToPixel( aTextSize );
+        Point aPos;
+        aPos.X() += GetSizePixel().Width() / 2  - aTextSize.Width() / 2;
+        aPos.Y() += GetSizePixel().Height() / 2 /*- aTextSize.Height() / 2*/;
+        aPos = PixelToLogic( aPos );
+        DrawText( aPos, m_rDialogImpl.aErrStr );
+        
+//        Pop();
+    }
+    else
+        SvxCheckListBox::Paint( rRect );
+}
+    
+
+// struct SvxThesaurusDialog_Impl ----------------------------------------
+
+SvxThesaurusDialog_Impl::SvxThesaurusDialog_Impl( SvxThesaurusDialog * pDialog ) :
+    m_pDialog       ( pDialog ),
+    aVendorImageFI  ( pDialog, CUI_RES( IMG_VENDOR ) ),
+    aLeftBtn        ( pDialog, CUI_RES( BTN_LEFT ) ),
+    aWordText       ( pDialog, CUI_RES( FT_WORD ) ),
+    aWordCB         ( pDialog, CUI_RES( CB_WORD ), *this ),
+    m_aAlternativesText  ( pDialog, CUI_RES( FT_THES_ALTERNATIVES ) ),
+    m_pAlternativesCT    ( new ThesaurusAlternativesCtrl_Impl( pDialog, *this ) ),
+    aReplaceText    ( pDialog, CUI_RES( FT_REPL ) ),
+    aReplaceEdit    ( pDialog, CUI_RES( ED_REPL ) ),
+    aFL             ( pDialog, CUI_RES( FL_VAR ) ),
+    aHelpBtn        ( pDialog, CUI_RES( BTN_THES_HELP ) ),
+    aLangMBtn       ( pDialog, CUI_RES( MB_LANGUAGE ) ),
+    aReplaceBtn     ( pDialog, CUI_RES( BTN_THES_OK ) ),
+    aCancelBtn      ( pDialog, CUI_RES( BTN_THES_CANCEL ) ),
+    aErrStr                 ( CUI_RES( STR_ERR_TEXTNOTFOUND ) ),
+    aVendorDefaultImage     ( CUI_RES( IMG_DEFAULT_VENDOR ) ),
+    aVendorDefaultImageHC   ( CUI_RES( IMG_DEFAULT_VENDOR_HC ) ),
+    xThesaurus      ( NULL ),
+    aLookUpText     (),
+    nLookUpLanguage ( LANGUAGE_NONE ),
+    m_bWordFound( false )
+{
+    // note: FreeResource must only be called in the c-tor of SvxThesaurusDialog
+    
+    aReplaceEdit.SetButton( &aReplaceBtn );
+
+    aLeftBtn.SetClickHdl( LINK( this, SvxThesaurusDialog_Impl, LeftBtnHdl_Impl ) );
+    aWordCB.SetSelectHdl( LINK( this, SvxThesaurusDialog_Impl, WordSelectHdl_Impl ) );
+    aLangMBtn.SetSelectHdl( LINK( this, SvxThesaurusDialog_Impl, LanguageHdl_Impl ) );
+    m_pAlternativesCT->SetSelectHdl( LINK( this, SvxThesaurusDialog_Impl, AlternativesSelectHdl_Impl ));
+    m_pAlternativesCT->SetDoubleClickHdl( LINK( this, SvxThesaurusDialog_Impl, AlternativesDoubleClickHdl_Impl ));
+
+    Application::PostUserEvent( STATIC_LINK( this, SvxThesaurusDialog_Impl, VendorImageInitHdl ) );
+}
+
+
+SvxThesaurusDialog_Impl::~SvxThesaurusDialog_Impl()
+{
+    delete aLangMBtn.GetPopupMenu();
+}
+
+
+uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL SvxThesaurusDialog_Impl::queryMeanings_Impl(
+        OUString& rTerm,
+        const lang::Locale& rLocale,
+        const beans::PropertyValues& rProperties )
+    throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+    uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeanings(
+            xThesaurus->queryMeanings( rTerm, rLocale, rProperties ) );
 
     // text with '.' at the end?
     if (0 == aMeanings.getLength() && rTerm.getLength() &&
         // end of a sentence and not an abbreviation...
         String aTxt( rTerm );
         aTxt.EraseTrailingChars( '.' );
-        aMeanings = pImpl->xThesaurus->queryMeanings( aTxt, rLocale, rProperties );
+        aMeanings = xThesaurus->queryMeanings( aTxt, rLocale, rProperties );
         if (aMeanings.getLength())
         {
             rTerm = aTxt;
     return aMeanings;
 }
 
-// -----------------------------------------------------------------------
+
+bool SvxThesaurusDialog_Impl::UpdateAlternativesBox_Impl()
+{
+    lang::Locale aLocale( SvxCreateLocale( nLookUpLanguage ) );
+    uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeanings = queryMeanings_Impl(
+            aLookUpText, aLocale, uno::Sequence< beans::PropertyValue >() );
+    const sal_Int32 nMeanings = aMeanings.getLength();
+    const uno::Reference< linguistic2::XMeaning > *pMeanings = aMeanings.getConstArray();
+
+    m_pAlternativesCT->SetUpdateMode( FALSE );
+    
+    // clear old user data of control before creating new ones via AddEntry below
+    m_pAlternativesCT->ClearUserData();
+
+    m_pAlternativesCT->Clear();
+    for (sal_Int32 i = 0;  i < nMeanings;  ++i)
+    {
+        OUString rMeaningTxt = pMeanings[i]->getMeaning();
+        uno::Sequence< OUString > aSynonyms( pMeanings[i]->querySynonyms() );
+        const sal_Int32 nSynonyms = aSynonyms.getLength();
+        const OUString *pSynonyms = aSynonyms.getConstArray();
+        DBG_ASSERT( rMeaningTxt.getLength() > 0, "meaning with empty text" );
+        DBG_ASSERT( nSynonyms > 0, "meaning without synonym" );
+        
+        m_pAlternativesCT->AddEntry( i + 1, rMeaningTxt, true );
+        for (sal_Int32 k = 0;  k < nSynonyms;  ++k)
+            m_pAlternativesCT->AddEntry( -1, pSynonyms[k], false );
+    }
+
+    m_pAlternativesCT->SetUpdateMode( TRUE );
+
+    return nMeanings > 0;
+}    
+
+
+void SvxThesaurusDialog_Impl::LookUp( const String &rText )
+{
+    if (rText != aWordCB.GetText()) // avoid moving of the cursor if the text is the same
+        aWordCB.SetText( rText );
+    LookUp_Impl();
+}    
+
+
+IMPL_LINK( SvxThesaurusDialog_Impl, LeftBtnHdl_Impl, Button *, pBtn )
+{
+    if (pBtn && aLookUpHistory.size() >= 2)
+    {
+        aLookUpHistory.pop();                       // remove current look up word from stack
+        aWordCB.SetText( aLookUpHistory.top() );    // retrieve previous look up word
+        aLookUpHistory.pop();
+        LookUp_Impl();
+    }
+    return 0;
+}
+
+
+IMPL_LINK( SvxThesaurusDialog_Impl, LanguageHdl_Impl, MenuButton *, pBtn )
+{
+    PopupMenu *pMenu = aLangMBtn.GetPopupMenu();
+    if (pMenu && pBtn)
+    {
+        USHORT nItem = pBtn->GetCurItemId();
+        String aLangText( pMenu->GetItemText( nItem ) );
+        LanguageType nLang = SvtLanguageTable().GetType( aLangText );
+        DBG_ASSERT( nLang != LANGUAGE_NONE && nLang != LANGUAGE_DONTKNOW, "failed to get language" );
+        if (xThesaurus->hasLocale( SvxCreateLocale( nLang ) ))
+            nLookUpLanguage = nLang;
+        m_pDialog->SetWindowTitle( nLang );
+        UpdateVendorImage();
+        LookUp_Impl();
+    }
+    return 0;
+}
+
+
+void SvxThesaurusDialog_Impl::LookUp_Impl()
+{
+    String aText( aWordCB.GetText() );
+
+    aLookUpText = OUString( aText );
+    if (aLookUpText.getLength() > 0 && 
+            (aLookUpHistory.size() == 0 || aLookUpText != aLookUpHistory.top()))
+        aLookUpHistory.push( aLookUpText );
+
+    m_bWordFound = UpdateAlternativesBox_Impl();
+    m_pAlternativesCT->Enable( m_bWordFound );
+
+    if ( aWordCB.GetEntryPos( aText ) == LISTBOX_ENTRY_NOTFOUND )
+        aWordCB.InsertEntry( aText );
+
+    aReplaceEdit.SetText( String() );
+    aLeftBtn.Enable( aLookUpHistory.size() > 1 );
+}
+
+
+IMPL_LINK( SvxThesaurusDialog_Impl, WordSelectHdl_Impl, ComboBox *, pBox )
+{
+    if (pBox && !aWordCB.IsTravelSelect())  // act only upon return key and not when traveling with cursor keys
+    {
+        USHORT nPos = pBox->GetSelectEntryPos();
+        String aStr( pBox->GetEntry( nPos ) );
+        GetReplaceEditString( aStr );
+        aWordCB.SetText( aStr );
+        LookUp_Impl();
+    }
+
+    return 0;
+}
+
+
+IMPL_LINK( SvxThesaurusDialog_Impl, AlternativesSelectHdl_Impl, SvxCheckListBox *, pBox )
+{
+    SvLBoxEntry *pEntry = pBox ? pBox->GetCurEntry() : NULL;
+    if (pEntry)
+    {
+        AlternativesUserData_Impl * pData = (AlternativesUserData_Impl *) pEntry->GetUserData();
+        String aStr;
+        if (!pData->IsHeader())
+        {
+            aStr = pData->GetText();