diff options
author | Thomas Lange [tl] <tl@openoffice.org> | 2010-03-01 11:14:01 +0100 |
---|---|---|
committer | Thomas Lange [tl] <tl@openoffice.org> | 2010-03-01 11:14:01 +0100 |
commit | 1ec7c5a40bbe34b1b1dbba8dea2c1364c492ece7 (patch) | |
tree | c878cb6c3eb00a180b55f4d1395a0c18bd260bcc /cui | |
parent | 6f5a1d754c17404c1dd7a71aaed5a1a9f8d08f3a (diff) |
cws tl74: #i107721#, #i108358# fixing build problems after merge with DEV300_m72
Diffstat (limited to 'cui')
-rwxr-xr-x | cui/source/dialogs/hyphen.cxx | 457 | ||||
-rwxr-xr-x | cui/source/dialogs/thesdlg.cxx | 80 | ||||
-rwxr-xr-x | cui/source/dialogs/thesdlg.src | 5 | ||||
-rwxr-xr-x | cui/source/dialogs/thesdlg_impl.hxx | 12 | ||||
-rwxr-xr-x | cui/source/inc/hyphen.hxx | 21 | ||||
-rwxr-xr-x | cui/source/inc/thesdlg.hxx | 1 |
6 files changed, 286 insertions, 290 deletions
diff --git a/cui/source/dialogs/hyphen.cxx b/cui/source/dialogs/hyphen.cxx index d99a640e20fa..5095593fd7fe 100755 --- a/cui/source/dialogs/hyphen.cxx +++ b/cui/source/dialogs/hyphen.cxx @@ -28,21 +28,22 @@ // 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 "cuires.hrc" -#include "hyphen.hrc" -#include <editeng/svxenum.hxx> #include "hyphen.hxx" +#include "hyphen.hrc" +#include "cuires.hrc" +#include "dialmgr.hxx" + #include <editeng/splwrap.hxx> -#include <svx/dlgutil.hxx> -#include <svx/dialmgr.hxx> +#include <editeng/svxenum.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; @@ -64,7 +65,6 @@ SvxHyphenEdit::SvxHyphenEdit( Window* pParent, const ResId& rResId ) : { } -// ----------------------------------------------------------------------- void SvxHyphenEdit::KeyInput( const KeyEvent& rKEvt ) { @@ -96,6 +96,9 @@ void SvxHyphenEdit::KeyInput( const KeyEvent& rKEvt ) struct SvxHyphenWordDialog_Impl { + SvxHyphenWordDialog * m_pDialog; +// Window * m_pParent; + FixedText aWordFT; SvxHyphenEdit aWordEdit; ImageButton aLeftBtn; @@ -118,24 +121,54 @@ struct SvxHyphenWordDialog_Impl sal_uInt16 nOldPos; sal_Bool bBusy; - SvxHyphenWordDialog_Impl( Window* pParent ); + + 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(); + + 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( Window* pParent ) : - aWordFT ( pParent, SVX_RES( FT_WORD ) ), - aWordEdit ( pParent, SVX_RES( ED_WORD ) ), - aLeftBtn ( pParent, SVX_RES( BTN_LEFT ) ), - aRightBtn ( pParent, SVX_RES( BTN_RIGHT ) ), - aOkBtn ( pParent, SVX_RES( BTN_HYPH_CUT ) ), - aContBtn ( pParent, SVX_RES( BTN_HYPH_CONTINUE ) ), - aDelBtn ( pParent, SVX_RES( BTN_HYPH_DELETE ) ), - aFLBottom ( pParent, SVX_RES( FL_BOTTOM ) ), - aHelpBtn ( pParent, SVX_RES( BTN_HYPH_HELP ) ), - aHyphAll ( pParent, SVX_RES( BTN_HYPH_ALL ) ), - aCancelBtn ( pParent, SVX_RES( BTN_HYPH_CANCEL ) ), - aLabel ( ), +SvxHyphenWordDialog_Impl::SvxHyphenWordDialog_Impl( + SvxHyphenWordDialog * pDialog, + const String &rWord, + LanguageType nLang, + uno::Reference< linguistic2::XHyphenator > &xHyphen, + SvxSpellWrapper* pWrapper ) : + + m_pDialog ( pDialog ), + aWordFT ( pDialog, SVX_RES( FT_WORD ) ), + aWordEdit ( pDialog, SVX_RES( ED_WORD ) ), + aLeftBtn ( pDialog, SVX_RES( BTN_LEFT ) ), + aRightBtn ( pDialog, SVX_RES( BTN_RIGHT ) ), + aOkBtn ( pDialog, SVX_RES( BTN_HYPH_CUT ) ), + aContBtn ( pDialog, SVX_RES( BTN_HYPH_CONTINUE ) ), + aDelBtn ( pDialog, SVX_RES( BTN_HYPH_DELETE ) ), + aFLBottom ( pDialog, SVX_RES( FL_BOTTOM ) ), + aHelpBtn ( pDialog, SVX_RES( BTN_HYPH_HELP ) ), + aHyphAll ( pDialog, SVX_RES( BTN_HYPH_ALL ) ), + aCancelBtn ( pDialog, SVX_RES( BTN_HYPH_CANCEL ) ), + aLabel ( pDialog->GetText() ), pHyphWrapper ( NULL ), xHyphenator ( NULL ), xPossHyph ( NULL ), @@ -146,6 +179,19 @@ SvxHyphenWordDialog_Impl::SvxHyphenWordDialog_Impl( Window* pParent ) : nOldPos ( 0 ), bBusy ( sal_False ) { + aActWord = rWord; + nActLanguage = nLang; + xHyphenator = xHyphen; + pHyphWrapper = pWrapper; + + 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 ) ); } @@ -153,148 +199,39 @@ SvxHyphenWordDialog_Impl::~SvxHyphenWordDialog_Impl() { } -// class SvxHyphenWordDialog --------------------------------------------- - -SvxHyphenWordDialog::SvxHyphenWordDialog( - const String &rWord, LanguageType nLang, - Window* pParent, - uno::Reference< linguistic2::XHyphenator > &xHyphen, - SvxSpellWrapper* pWrapper ) : - SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_HYPHENATE ) ) +void SvxHyphenWordDialog_Impl::EnableLRBtn_Impl() { - m_pImpl = boost::shared_ptr< SvxHyphenWordDialog_Impl >(new SvxHyphenWordDialog_Impl( this )); - - FreeResource(); - - m_pImpl->aLabel = GetText(); - m_pImpl->pHyphWrapper = pWrapper; - m_pImpl->xHyphenator = xHyphen; - m_pImpl->aActWord = rWord; - m_pImpl->nActLanguage = nLang; - - m_pImpl->aLeftBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, Left_Impl ) ); - m_pImpl->aRightBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, Right_Impl ) ); - m_pImpl->aOkBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, CutHdl_Impl ) ); - m_pImpl->aContBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, ContinueHdl_Impl ) ); - m_pImpl->aDelBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, DeleteHdl_Impl ) ); - m_pImpl->aHyphAll.SetClickHdl( LINK( this, SvxHyphenWordDialog, HyphenateAllHdl_Impl ) ); - m_pImpl->aCancelBtn.SetClickHdl( LINK( this, SvxHyphenWordDialog, CancelHdl_Impl ) ); - m_pImpl->aWordEdit.SetGetFocusHdl( LINK( this, SvxHyphenWordDialog, GetFocusHdl_Impl ) ); - - uno::Reference< linguistic2::XHyphenatedWord > xHyphWord( pWrapper ? - pWrapper->GetLast() : uno::Reference< uno::XInterface > () , uno::UNO_QUERY ); - DBG_ASSERT(xHyphWord.is(), "missing hyphenated word"); - m_pImpl->nMaxHyphenationPos = xHyphWord.is() ? xHyphWord->getHyphenationPos() : 0; - SetLabel_Impl( nLang ); - - InitControls_Impl(); - m_pImpl->aWordEdit.GrabFocus(); - - // disable controls if service is not available - if (!m_pImpl->xHyphenator.is()) - Enable( sal_False ); -} - -// ----------------------------------------------------------------------- - -void SvxHyphenWordDialog::SelLeft() -{ - String aTxt( m_pImpl->aWordEdit.GetText() ); - - for ( xub_StrLen i = m_pImpl->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 ( m_pImpl->nOldPos != 0 && m_pImpl->nOldPos != aTxt.Len() ) - aTxt.SetChar( m_pImpl->nOldPos, sal_Unicode( SW_SOFT_HYPHEN ) ); - m_pImpl->nOldPos = i; - m_pImpl->aWordEdit.SetText( aTxt ); - m_pImpl->aWordEdit.GrabFocus(); - m_pImpl->aWordEdit.SetSelection( Selection( i, i + 1 ) ); - break; - } - } - m_pImpl->nHyphPos = GetHyphIndex_Impl(); - EnableLRBtn_Impl(); -} - -// ----------------------------------------------------------------------- - -void SvxHyphenWordDialog::SelRight() -{ - String aTxt( m_pImpl->aWordEdit.GetText() ); - - for ( xub_StrLen i = m_pImpl->nOldPos + 1; i < aTxt.Len(); ++i ) - { - if( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) ) - { - aTxt.SetChar( i, sal_Unicode( HYPHHERE ) ); - - if ( m_pImpl->nOldPos != 0 && m_pImpl->nOldPos != aTxt.Len() ) - aTxt.SetChar( m_pImpl->nOldPos, sal_Unicode( SW_SOFT_HYPHEN ) ); - m_pImpl->nOldPos = i; - m_pImpl->aWordEdit.SetText( aTxt ); - m_pImpl->aWordEdit.GrabFocus(); - m_pImpl->aWordEdit.SetSelection( Selection( i, i + 1 ) ); - break; - } - } - m_pImpl->nHyphPos = GetHyphIndex_Impl(); - EnableLRBtn_Impl(); -} - -// ----------------------------------------------------------------------- - -void SvxHyphenWordDialog::EnableLRBtn_Impl() -{ - String aTxt( m_pImpl->aWordEdit.GetText() ); + String aTxt( aWordEdit.GetText() ); xub_StrLen nLen = aTxt.Len(); xub_StrLen i; - m_pImpl->aRightBtn.Disable(); - for ( i = m_pImpl->nOldPos + 2; i < nLen; ++i ) + aRightBtn.Disable(); + for ( i = nOldPos + 2; i < nLen; ++i ) { if ( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) ) { - m_pImpl->aRightBtn.Enable(); + aRightBtn.Enable(); break; } } - DBG_ASSERT(m_pImpl->nOldPos < aTxt.Len(), "m_pImpl->nOldPos out of range"); - if (m_pImpl->nOldPos >= aTxt.Len()) - m_pImpl->nOldPos = aTxt.Len() - 1; - m_pImpl->aLeftBtn.Disable(); - for ( i = m_pImpl->nOldPos; i-- > 0; ) + 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 ) ) { - m_pImpl->aLeftBtn.Enable(); + aLeftBtn.Enable(); break; } } } -// ----------------------------------------------------------------------- - - -void SvxHyphenWordDialog::SetLabel_Impl( 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 ); -} - -// ----------------------------------------------------------------------- -String SvxHyphenWordDialog::EraseUnusableHyphens_Impl( +String SvxHyphenWordDialog_Impl::EraseUnusableHyphens_Impl( uno::Reference< linguistic2::XPossibleHyphens > &rxPossHyph, sal_uInt16 _nMaxHyphenationPos ) { @@ -349,39 +286,37 @@ String SvxHyphenWordDialog::EraseUnusableHyphens_Impl( return aTxt; } -// ----------------------------------------------------------------------- -void SvxHyphenWordDialog::InitControls_Impl() +void SvxHyphenWordDialog_Impl::InitControls_Impl() { String aTxt; - m_pImpl->xPossHyph = NULL; - if (m_pImpl->xHyphenator.is()) + xPossHyph = NULL; + if (xHyphenator.is()) { - lang::Locale aLocale( SvxCreateLocale(m_pImpl->nActLanguage) ); - m_pImpl->xPossHyph = m_pImpl->xHyphenator->createPossibleHyphens( m_pImpl->aActWord, aLocale, + lang::Locale aLocale( SvxCreateLocale(nActLanguage) ); + xPossHyph = xHyphenator->createPossibleHyphens( aActWord, aLocale, uno::Sequence< beans::PropertyValue >() ); - if (m_pImpl->xPossHyph.is()) + if (xPossHyph.is()) { - aTxt = EraseUnusableHyphens_Impl( m_pImpl->xPossHyph, m_pImpl->nMaxHyphenationPos ); + aTxt = EraseUnusableHyphens_Impl( xPossHyph, nMaxHyphenationPos ); } - SetLabel_Impl( m_pImpl->nActLanguage ); + m_pDialog->SetWindowTitle( nActLanguage ); } - m_pImpl->aWordEdit.SetText( aTxt ); + aWordEdit.SetText( aTxt ); - m_pImpl->nOldPos = aTxt.Len(); - SelLeft(); + nOldPos = aTxt.Len(); + m_pDialog->SelLeft(); EnableLRBtn_Impl(); } -// ----------------------------------------------------------------------- -void SvxHyphenWordDialog::ContinueHyph_Impl( sal_uInt16 nInsPos ) +void SvxHyphenWordDialog_Impl::ContinueHyph_Impl( sal_uInt16 nInsPos ) { - if ( nInsPos != CONTINUE_HYPH && m_pImpl->xPossHyph.is()) + if ( nInsPos != CONTINUE_HYPH && xPossHyph.is()) { if (nInsPos) { - String aTmp( m_pImpl->aWordEdit.GetText() ); + String aTmp( aWordEdit.GetText() ); DBG_ASSERT(nInsPos <= aTmp.Len() - 2, "wrong hyphen position"); sal_uInt16 nIdxPos = 0; @@ -393,46 +328,45 @@ void SvxHyphenWordDialog::ContinueHyph_Impl( sal_uInt16 nInsPos ) nIdxPos++; } - uno::Sequence< sal_Int16 > aSeq = m_pImpl->xPossHyph->getHyphenationPositions(); + uno::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 ]; - m_pImpl->pHyphWrapper->InsertHyphen( nInsPos ); + pHyphWrapper->InsertHyphen( nInsPos ); } } else { //! calling with 0 as argument will remove hyphens! - m_pImpl->pHyphWrapper->InsertHyphen( nInsPos ); + pHyphWrapper->InsertHyphen( nInsPos ); } } - if ( m_pImpl->pHyphWrapper->FindSpellError() ) + if ( pHyphWrapper->FindSpellError() ) { - uno::Reference< linguistic2::XHyphenatedWord > xHyphWord( m_pImpl->pHyphWrapper->GetLast(), uno::UNO_QUERY ); + uno::Reference< linguistic2::XHyphenatedWord > xHyphWord( pHyphWrapper->GetLast(), uno::UNO_QUERY ); // adapt actual word and language to new found hyphenation result if(xHyphWord.is()) { - m_pImpl->aActWord = String( xHyphWord->getWord() ); - m_pImpl->nActLanguage = SvxLocaleToLanguage( xHyphWord->getLocale() ); - m_pImpl->nMaxHyphenationPos = xHyphWord->getHyphenationPos(); + aActWord = String( xHyphWord->getWord() ); + nActLanguage = SvxLocaleToLanguage( xHyphWord->getLocale() ); + nMaxHyphenationPos = xHyphWord->getHyphenationPos(); InitControls_Impl(); } } else - EndDialog( RET_OK ); + m_pDialog->EndDialog( RET_OK ); } -// ----------------------------------------------------------------------- -sal_uInt16 SvxHyphenWordDialog::GetHyphIndex_Impl() +sal_uInt16 SvxHyphenWordDialog_Impl::GetHyphIndex_Impl() { sal_uInt16 nPos = 0; - String aTxt(m_pImpl->aWordEdit.GetText()); + String aTxt( aWordEdit.GetText() ); for ( sal_uInt16 i=0 ; i < aTxt.Len(); ++i ) { @@ -447,24 +381,22 @@ sal_uInt16 SvxHyphenWordDialog::GetHyphIndex_Impl() return nPos; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, CutHdl_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, CutHdl_Impl, Button *, EMPTYARG ) { - if( !m_pImpl->bBusy ) + if( !bBusy ) { - m_pImpl->bBusy = sal_True; - ContinueHyph_Impl( m_pImpl->nHyphPos ); - m_pImpl->bBusy = sal_False; + bBusy = sal_True; + ContinueHyph_Impl( nHyphPos ); + bBusy = sal_False; } return 0; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, HyphenateAllHdl_Impl, Button *, EMPTYARG /*pButton*/ ) +IMPL_LINK( SvxHyphenWordDialog_Impl, HyphenateAllHdl_Impl, Button *, EMPTYARG /*pButton*/ ) { - if( !m_pImpl->bBusy ) + if( !bBusy ) { try { @@ -475,9 +407,9 @@ IMPL_LINK( SvxHyphenWordDialog, HyphenateAllHdl_Impl, Button *, EMPTYARG /*pButt aAny <<= sal_True; xProp->setPropertyValue( aName, aAny ); - m_pImpl->bBusy = sal_True; - ContinueHyph_Impl( m_pImpl->nHyphPos ); - m_pImpl->bBusy = sal_False; + bBusy = sal_True; + ContinueHyph_Impl( nHyphPos ); + bBusy = sal_False; aAny <<= sal_False; xProp->setPropertyValue( aName, aAny ); @@ -491,79 +423,166 @@ IMPL_LINK( SvxHyphenWordDialog, HyphenateAllHdl_Impl, Button *, EMPTYARG /*pButt return 0; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, DeleteHdl_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, DeleteHdl_Impl, Button *, EMPTYARG ) { - if( !m_pImpl->bBusy ) + if( !bBusy ) { - m_pImpl->bBusy = sal_True; + bBusy = sal_True; ContinueHyph_Impl(); - m_pImpl->bBusy = sal_False; + bBusy = sal_False; } return 0; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, ContinueHdl_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, ContinueHdl_Impl, Button *, EMPTYARG ) { - if( !m_pImpl->bBusy ) + if( !bBusy ) { - m_pImpl->bBusy = sal_True; + bBusy = sal_True; ContinueHyph_Impl( CONTINUE_HYPH ); - m_pImpl->bBusy = sal_False; + bBusy = sal_False; } return 0; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, CancelHdl_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, CancelHdl_Impl, Button *, EMPTYARG ) { - if( !m_pImpl->bBusy ) + if( !bBusy ) { - m_pImpl->bBusy = sal_True; - m_pImpl->pHyphWrapper->SpellEnd(); - EndDialog( RET_CANCEL ); - m_pImpl->bBusy = sal_False; + bBusy = sal_True; + pHyphWrapper->SpellEnd(); + m_pDialog->EndDialog( RET_CANCEL ); + bBusy = sal_False; } return 0; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, Left_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, Left_Impl, Button *, EMPTYARG ) { - if( !m_pImpl->bBusy ) + if( !bBusy ) { - m_pImpl->bBusy = sal_True; - SelLeft(); - m_pImpl->bBusy = sal_False; + bBusy = sal_True; + m_pDialog->SelLeft(); + bBusy = sal_False; } return 0; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, Right_Impl, Button *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, Right_Impl, Button *, EMPTYARG ) { - if( !m_pImpl->bBusy ) + if( !bBusy ) { - m_pImpl->bBusy = sal_True; - SelRight(); - m_pImpl->bBusy = sal_False; + bBusy = sal_True; + m_pDialog->SelRight(); + bBusy = sal_False; } return 0; } -// ----------------------------------------------------------------------- -IMPL_LINK( SvxHyphenWordDialog, GetFocusHdl_Impl, Edit *, EMPTYARG ) +IMPL_LINK( SvxHyphenWordDialog_Impl, GetFocusHdl_Impl, Edit *, EMPTYARG ) { - m_pImpl->aWordEdit.SetSelection( Selection( m_pImpl->nOldPos, m_pImpl->nOldPos + 1 ) ); + aWordEdit.SetSelection( Selection( nOldPos, nOldPos + 1 ) ); return 0; } +// class SvxHyphenWordDialog --------------------------------------------- + +SvxHyphenWordDialog::SvxHyphenWordDialog( + const String &rWord, LanguageType nLang, + Window* pParent, + uno::Reference< linguistic2::XHyphenator > &xHyphen, + SvxSpellWrapper* pWrapper ) : + + SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_HYPHENATE ) ) +{ + m_pImpl = boost::shared_ptr< SvxHyphenWordDialog_Impl >( + new SvxHyphenWordDialog_Impl( this, rWord, nLang, xHyphen, pWrapper ) ); + + FreeResource(); + + uno::Reference< linguistic2::XHyphenatedWord > xHyphWord( pWrapper ? + pWrapper->GetLast() : uno::Reference< uno::XInterface > () , uno::UNO_QUERY ); + DBG_ASSERT( xHyphWord.is(), "missing hyphenated word" ); + m_pImpl->nMaxHyphenationPos = xHyphWord.is() ? xHyphWord->getHyphenationPos() : 0; + + m_pImpl->InitControls_Impl(); + m_pImpl->aWordEdit.GrabFocus(); + + SetWindowTitle( nLang ); + + // disable controls if service is not available + 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( m_pImpl->aWordEdit.GetText() ); + for ( xub_StrLen i = m_pImpl->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 ( m_pImpl->nOldPos != 0 && m_pImpl->nOldPos != aTxt.Len() ) + aTxt.SetChar( m_pImpl->nOldPos, sal_Unicode( SW_SOFT_HYPHEN ) ); + m_pImpl->nOldPos = i; + m_pImpl->aWordEdit.SetText( aTxt ); + m_pImpl->aWordEdit.GrabFocus(); + m_pImpl->aWordEdit.SetSelection( Selection( i, i + 1 ) ); + break; + } + } + m_pImpl->nHyphPos = m_pImpl->GetHyphIndex_Impl(); + m_pImpl->EnableLRBtn_Impl(); +} + + +void SvxHyphenWordDialog::SelRight() +{ + String aTxt( m_pImpl->aWordEdit.GetText() ); + for ( xub_StrLen i = m_pImpl->nOldPos + 1; i < aTxt.Len(); ++i ) + { + if( aTxt.GetChar( i ) == sal_Unicode( SW_SOFT_HYPHEN ) ) + { + aTxt.SetChar( i, sal_Unicode( HYPHHERE ) ); + + if ( m_pImpl->nOldPos != 0 && m_pImpl->nOldPos != aTxt.Len() ) + aTxt.SetChar( m_pImpl->nOldPos, sal_Unicode( SW_SOFT_HYPHEN ) ); + m_pImpl->nOldPos = i; + m_pImpl->aWordEdit.SetText( aTxt ); + m_pImpl->aWordEdit.GrabFocus(); + m_pImpl->aWordEdit.SetSelection( Selection( i, i + 1 ) ); + break; + } + } + m_pImpl->nHyphPos = m_pImpl->GetHyphIndex_Impl(); + m_pImpl->EnableLRBtn_Impl(); +} + diff --git a/cui/source/dialogs/thesdlg.cxx b/cui/source/dialogs/thesdlg.cxx index 0a730c4e97e5..f456832c6d16 100755 --- a/cui/source/dialogs/thesdlg.cxx +++ b/cui/source/dialogs/thesdlg.cxx @@ -289,29 +289,28 @@ void ThesaurusAlternativesCtrl_Impl::Paint( const Rectangle& rRect ) // struct SvxThesaurusDialog_Impl ---------------------------------------- -SvxThesaurusDialog_Impl::SvxThesaurusDialog_Impl( Window* pParent ) : - m_pParent ( pParent ), - aVendorImageFI ( pParent , SVX_RES( IMG_VENDOR ) ), - aLeftBtn ( pParent, SVX_RES( BTN_LEFT ) ), - aWordText ( pParent, SVX_RES( FT_WORD ) ), - aWordCB ( pParent, SVX_RES( CB_WORD ), *this ), - m_aAlternativesText ( pParent, SVX_RES( FT_THES_ALTERNATIVES ) ), - m_pAlternativesCT ( new ThesaurusAlternativesCtrl_Impl( pParent, *this ) ), - aReplaceText ( pParent, SVX_RES( FT_REPL ) ), - aReplaceEdit ( pParent, SVX_RES( ED_REPL ) ), - aFL ( pParent, SVX_RES( FL_VAR ) ), - aHelpBtn ( pParent, SVX_RES( BTN_THES_HELP ) ), - aLangMBtn ( pParent, SVX_RES( MB_LANGUAGE ) ), - aReplaceBtn ( pParent, SVX_RES( BTN_THES_OK ) ), - aCancelBtn ( pParent, SVX_RES( BTN_THES_CANCEL ) ), +SvxThesaurusDialog_Impl::SvxThesaurusDialog_Impl( SvxThesaurusDialog * pDialog ) : + m_pDialog ( pDialog ), + aVendorImageFI ( pDialog , SVX_RES( IMG_VENDOR ) ), + aLeftBtn ( pDialog, SVX_RES( BTN_LEFT ) ), + aWordText ( pDialog, SVX_RES( FT_WORD ) ), + aWordCB ( pDialog, SVX_RES( CB_WORD ), *this ), + m_aAlternativesText ( pDialog, SVX_RES( FT_THES_ALTERNATIVES ) ), + m_pAlternativesCT ( new ThesaurusAlternativesCtrl_Impl( pDialog, *this ) ), + aReplaceText ( pDialog, SVX_RES( FT_REPL ) ), + aReplaceEdit ( pDialog, SVX_RES( ED_REPL ) ), + aFL ( pDialog, SVX_RES( FL_VAR ) ), + aHelpBtn ( pDialog, SVX_RES( BTN_THES_HELP ) ), + aLangMBtn ( pDialog, SVX_RES( MB_LANGUAGE ) ), + aReplaceBtn ( pDialog, SVX_RES( BTN_THES_OK ) ), + aCancelBtn ( pDialog, SVX_RES( BTN_THES_CANCEL ) ), aErrStr ( SVX_RES( STR_ERR_TEXTNOTFOUND ) ), aVendorDefaultImage ( SVX_RES( IMG_DEFAULT_VENDOR ) ), aVendorDefaultImageHC ( SVX_RES( IMG_DEFAULT_VENDOR_HC ) ), xThesaurus ( NULL ), aLookUpText (), nLookUpLanguage ( LANGUAGE_NONE ), - m_bWordFound( false ), - pErrContext ( NULL ) + m_bWordFound( false ) { // note: FreeResource must only be called in the c-tor of SvxThesaurusDialog @@ -330,7 +329,6 @@ SvxThesaurusDialog_Impl::SvxThesaurusDialog_Impl( Window* pParent ) : SvxThesaurusDialog_Impl::~SvxThesaurusDialog_Impl() { delete aLangMBtn.GetPopupMenu(); - delete pErrContext; } @@ -396,18 +394,6 @@ bool SvxThesaurusDialog_Impl::UpdateAlternativesBox_Impl() } -void SvxThesaurusDialog_Impl::SetWindowTitle( LanguageType nLanguage ) -{ - // Sprache anpassen - String aStr( m_pParent->GetText() ); - aStr.Erase( aStr.Search( sal_Unicode( '(' ) ) - 1 ); - aStr.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ) ); - aStr += GetLanguageString( (LanguageType) nLanguage ); - aStr.Append( sal_Unicode( ')' ) ); - m_pParent->SetText( aStr ); // set window title -} - - void SvxThesaurusDialog_Impl::LookUp( const String &rText ) { if (rText != aWordCB.GetText()) // avoid moving of the cursor if the text is the same @@ -440,7 +426,7 @@ IMPL_LINK( SvxThesaurusDialog_Impl, LanguageHdl_Impl, MenuButton *, pBtn ) DBG_ASSERT( nLang != LANGUAGE_NONE && nLang != LANGUAGE_DONTKNOW, "failed to get language" ); if (xThesaurus->hasLocale( SvxCreateLocale( nLang ) )) nLookUpLanguage = nLang; - SetWindowTitle( nLang ); + m_pDialog->SetWindowTitle( nLang ); UpdateVendorImage(); LookUp_Impl(); } @@ -588,7 +574,7 @@ static String lcl_GetThesImplName( const lang::Locale &rLocale ) void SvxThesaurusDialog_Impl::UpdateVendorImage() { - m_pParent->SetUpdateMode( sal_False ); + m_pDialog->SetUpdateMode( sal_False ); SvtLinguConfig aCfg; if (aCfg.HasVendorImages( "ThesaurusDialogImage" )) @@ -605,13 +591,13 @@ void SvxThesaurusDialog_Impl::UpdateVendorImage() aVendorImageFI.SetImage( aImage ); } - m_pParent->SetUpdateMode( sal_True ); + m_pDialog->SetUpdateMode( sal_True ); } IMPL_STATIC_LINK( SvxThesaurusDialog_Impl, VendorImageInitHdl, SvxThesaurusDialog_Impl *, EMPTYARG ) { - pThis->m_pParent->SetUpdateMode( sal_False ); + pThis->m_pDialog->SetUpdateMode( sal_False ); SvtLinguConfig aCfg; if (aCfg.HasVendorImages( "ThesaurusDialogImage" )) @@ -656,14 +642,14 @@ IMPL_STATIC_LINK( SvxThesaurusDialog_Impl, VendorImageInitHdl, SvxThesaurusDialo aControls[nControl]->SetPosPixel(aPos); ++nControl; } - Size aDlgSize = pThis->m_pParent->GetSizePixel(); + Size aDlgSize = pThis->m_pDialog->GetSizePixel(); aDlgSize.Height() += nDiff; - pThis->m_pParent->SetSizePixel( aDlgSize ); - pThis->m_pParent->Invalidate(); + pThis->m_pDialog->SetSizePixel( aDlgSize ); + pThis->m_pDialog->Invalidate(); } pThis->UpdateVendorImage(); - pThis->m_pParent->SetUpdateMode( sal_True ); + pThis->m_pDialog->SetUpdateMode( sal_True ); return 0; }; @@ -686,8 +672,6 @@ SvxThesaurusDialog::SvxThesaurusDialog( m_pImpl->nLookUpLanguage = nLanguage; if (rWord.Len() > 0) m_pImpl->aLookUpHistory.push( rWord ); - m_pImpl->pErrContext = new SfxErrorContext( ERRCTX_SVX_LINGU_THESAURUS, String(), this, - RID_SVXERRCTX, &DIALOG_MGR() ); FreeResource(); @@ -698,8 +682,6 @@ SvxThesaurusDialog::SvxThesaurusDialog( m_pImpl->aReplaceEdit.SetText( aTmp2 ); m_pImpl->aWordCB.InsertEntry( aTmp2 ); - m_pImpl->SetWindowTitle( nLanguage ); - m_pImpl->LookUp( aTmp2 ); m_pImpl->m_pAlternativesCT->GrabFocus(); m_pImpl->aLeftBtn.Enable( sal_False ); @@ -726,6 +708,8 @@ SvxThesaurusDialog::SvxThesaurusDialog( pMenu->InsertItem( (USHORT)i+1, aLangVec[i] ); // menu items should be enumerated from 1 and not 0 m_pImpl->aLangMBtn.SetPopupMenu( pMenu ); + SetWindowTitle( nLanguage ); + // disable controls if service is missing if (!m_pImpl->xThesaurus.is()) Enable( sal_False ); @@ -737,6 +721,18 @@ SvxThesaurusDialog::~SvxThesaurusDialog() } +void SvxThesaurusDialog::SetWindowTitle( LanguageType nLanguage ) +{ + // Sprache anpassen + String aStr( GetText() ); + aStr.Erase( aStr.Search( sal_Unicode( '(' ) ) - 1 ); + aStr.Append( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ) ); + aStr += SvtLanguageTable().GetLanguageString( nLanguage ); + aStr.Append( sal_Unicode( ')' ) ); + SetText( aStr ); // set window title +} + + String SvxThesaurusDialog::GetWord() { return m_pImpl->aReplaceEdit.GetText(); diff --git a/cui/source/dialogs/thesdlg.src b/cui/source/dialogs/thesdlg.src index bec4ef14c261..f821ab637fdc 100755 --- a/cui/source/dialogs/thesdlg.src +++ b/cui/source/dialogs/thesdlg.src @@ -24,13 +24,12 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - // include --------------------------------------------------------------- + #include "cuires.hrc" #include "thesdlg.hrc" #include "helpid.hrc" #include <svx/svxids.hrc> // SID_THESAURUS -// pragma ---------------------------------------------------------------- // RID_SVXDLG_THES ------------------------------------------------------- ModalDialog RID_SVXDLG_THESAURUS @@ -85,7 +84,7 @@ ModalDialog RID_SVXDLG_THESAURUS }; Control CT_THES_ALTERNATIVES { - HelpID = HID_CT_THES_ALTERNATIVES ; +// HelpID = HID_CT_THES_ALTERNATIVES ; Pos = MAP_APPFONT ( 5 , 45 ) ; Size = MAP_APPFONT ( 225 , 121 ) ; Border = TRUE; diff --git a/cui/source/dialogs/thesdlg_impl.hxx b/cui/source/dialogs/thesdlg_impl.hxx index 354bc95c09db..70ce91391456 100755 --- a/cui/source/dialogs/thesdlg_impl.hxx +++ b/cui/source/dialogs/thesdlg_impl.hxx @@ -31,9 +31,10 @@ #ifndef _SVX_THESDLG_IMPL_HXX #define _SVX_THESDLG_IMPL_HXX -#include <svx/thesdlg.hxx> -#include <svx/checklbx.hxx> +#include "thesdlg.hxx" +#include <svtools/ehdl.hxx> +#include <svx/checklbx.hxx> #include <vcl/button.hxx> #include <vcl/combobox.hxx> #include <vcl/edit.hxx> @@ -162,7 +163,7 @@ public: struct SvxThesaurusDialog_Impl { - Window * m_pParent; + SvxThesaurusDialog * m_pDialog; FixedImage aVendorImageFI; ImageButton aLeftBtn; @@ -188,8 +189,6 @@ struct SvxThesaurusDialog_Impl std::stack< OUString > aLookUpHistory; bool m_bWordFound; - SfxErrorContext* pErrContext; // error context while dfalog is opened - // Handler DECL_LINK( LeftBtnHdl_Impl, Button * ); @@ -203,7 +202,7 @@ struct SvxThesaurusDialog_Impl DECL_STATIC_LINK( SvxThesaurusDialog_Impl, VendorImageInitHdl, SvxThesaurusDialog_Impl * ); - SvxThesaurusDialog_Impl( Window* pParent ); + SvxThesaurusDialog_Impl( SvxThesaurusDialog * pDialog ); ~SvxThesaurusDialog_Impl(); uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL @@ -211,7 +210,6 @@ struct SvxThesaurusDialog_Impl bool UpdateAlternativesBox_Impl(); void UpdateVendorImage(); - void SetWindowTitle( LanguageType nLanguage ); void LookUp( const String &rText ); void LookUp_Impl(); }; diff --git a/cui/source/inc/hyphen.hxx b/cui/source/inc/hyphen.hxx index a413467f32b2..48f4a31705d0 100755 --- a/cui/source/inc/hyphen.hxx +++ b/cui/source/inc/hyphen.hxx @@ -66,31 +66,14 @@ class SvxHyphenWordDialog : public SfxModalDialog { boost::shared_ptr< SvxHyphenWordDialog_Impl > m_pImpl; -#ifdef _SVX_HYPHEN_CXX - void EnableLRBtn_Impl(); - void SetLabel_Impl( LanguageType nLang ); - 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(); - - 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* ); -#endif - public: SvxHyphenWordDialog( const String &rWord, LanguageType nLang, Window* pParent, ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenator > &xHyphen, SvxSpellWrapper* pWrapper ); + virtual ~SvxHyphenWordDialog(); + void SetWindowTitle( LanguageType nLang ); void SelLeft(); void SelRight(); }; diff --git a/cui/source/inc/thesdlg.hxx b/cui/source/inc/thesdlg.hxx index 9ab865072ce9..f5d0bd91b584 100755 --- a/cui/source/inc/thesdlg.hxx +++ b/cui/source/inc/thesdlg.hxx @@ -52,6 +52,7 @@ public: const String &rWord, LanguageType nLanguage ); ~SvxThesaurusDialog(); + void SetWindowTitle( LanguageType nLanguage ); String GetWord(); sal_uInt16 GetLanguage() const; }; |