1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hhcwrp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
38 #include <hintids.hxx>
43 #include <swundo.hxx> // fuer Undo-Ids
45 #include <globals.hrc>
47 #include <splargs.hxx>
50 #ifndef _MSGBOX_HXX //autogen
51 #include <vcl/msgbox.hxx>
53 #include <svx/unolingu.hxx>
54 #include <svx/langitem.hxx>
55 #include <svx/fontitem.hxx>
56 #include <rtl/ustring.hxx>
57 #include <com/sun/star/text/RubyAdjust.hpp>
59 #include <sdrhhcwrap.hxx>
62 #include <txatritr.hxx>
63 #include <mdiexp.hxx> // Progress
65 #include <crsskip.hxx>
71 #include <fmtruby.hxx>
72 #include <breakit.hxx>
81 using ::rtl::OUString
;
82 using namespace ::com::sun::star
;
83 using namespace ::com::sun::star::text
;
84 using namespace ::com::sun::star::uno
;
85 using namespace ::com::sun::star::linguistic2
;
86 using namespace ::com::sun::star::i18n
;
88 #define CHAR_PAR_BRK ((sal_Char) 0x0D)
90 //////////////////////////////////////////////////////////////////////
91 // Beschreibung: Ggf. Rahmen/Objektshell abschalten
93 static void lcl_ActivateTextShell( SwWrtShell
& rWrtSh
)
95 if( rWrtSh
.IsSelFrmMode() || rWrtSh
.IsObjSelected() )
96 rWrtSh
.EnterStdMode();
99 //////////////////////////////////////////////////////////////////////
101 class SwKeepConversionDirectionStateContext
104 SwKeepConversionDirectionStateContext()
106 //!! hack to transport the current conversion direction state settings
107 //!! into the next incarnation that iterates over the drawing objets
108 //!! ( see SwHHCWrapper::~SwHHCWrapper() )
109 svx::HangulHanjaConversion::SetUseSavedConversionDirectionState( sal_True
);
112 ~SwKeepConversionDirectionStateContext()
114 svx::HangulHanjaConversion::SetUseSavedConversionDirectionState( sal_False
);
118 //////////////////////////////////////////////////////////////////////
120 SwHHCWrapper::SwHHCWrapper(
122 const uno::Reference
< lang::XMultiServiceFactory
>& rxMSF
,
123 LanguageType nSourceLanguage
,
124 LanguageType nTargetLanguage
,
125 const Font
*pTargetFont
,
126 sal_Int32 nConvOptions
,
127 sal_Bool bIsInteractive
,
128 sal_Bool bStart
, sal_Bool bOther
, sal_Bool bSelection
) :
129 svx::HangulHanjaConversion( &pSwView
->GetEditWin(), rxMSF
,
130 SvxCreateLocale( nSourceLanguage
),
131 SvxCreateLocale( nTargetLanguage
),
135 rWrtShell( pSwView
->GetWrtShell() )
142 pWin
= &pSwView
->GetEditWin();
143 bIsDrawObj
= sal_False
;
145 bIsOtherCntnt
= bStartChk
= bOther
;
146 bIsConvSpecial
= sal_True
;
147 bIsSelection
= bSelection
;
148 bInfoBox
= sal_False
;
149 bStartDone
= bOther
|| bStart
;
150 bEndDone
= sal_False
;
151 // bLastRet = sal_True;
152 nPageCount
= nPageStart
= 0;
156 SwHHCWrapper::~SwHHCWrapper()
160 rWrtShell
.SetCareWin( NULL
);
162 // check for existence of a draw view which means that there are
163 // (or previously were) draw objects present in the document.
164 // I.e. we like to check those too.
165 if ( IsDrawObj() /*&& bLastRet*/ && pView
->GetWrtShell().HasDrawView() )
167 Cursor
*pSave
= pView
->GetWindow()->GetCursor();
169 SwKeepConversionDirectionStateContext aContext
;
171 SdrHHCWrapper
aSdrConvWrap( pView
, GetSourceLanguage(),
172 GetTargetLanguage(), GetTargetFont(),
173 GetConversionOptions(), IsInteractive() );
174 aSdrConvWrap
.StartTextConversion();
176 pView
->GetWindow()->SetCursor( pSave
);
180 ::EndProgress( pView
->GetDocShell() );
182 // finally for chinese translation we need to change the the documents
183 // default language and font to the new ones to be used.
184 LanguageType nTargetLang
= GetTargetLanguage();
185 if (IsChinese( nTargetLang
))
187 SwDoc
*pDoc
= pView
->GetDocShell()->GetDoc();
189 //!! Note: This also effects the default language of text boxes (EditEngine/EditView) !!
190 pDoc
->SetDefault( SvxLanguageItem( nTargetLang
, RES_CHRATR_CJK_LANGUAGE
) );
192 const Font
*pFont
= GetTargetFont();
195 SvxFontItem
aFontItem( pFont
->GetFamily(), pFont
->GetName(),
196 pFont
->GetStyleName(), pFont
->GetPitch(),
197 pFont
->GetCharSet(), RES_CHRATR_CJK_FONT
);
198 pDoc
->SetDefault( aFontItem
);
205 InfoBox(&pView->GetEditWin(), String(SW_RES(STR_SPELL_OK)) ).Execute();
210 void SwHHCWrapper::GetNextPortion(
211 ::rtl::OUString
& rNextPortion
,
212 LanguageType
& rLangOfPortion
,
213 sal_Bool bAllowChanges
)
215 pConvArgs
->bAllowImplicitChangesForNotConvertibleText
= bAllowChanges
;
218 rNextPortion
= pConvArgs
->aConvText
;
219 rLangOfPortion
= pConvArgs
->nConvTextLang
;
223 // build last pos from currently selected text
224 SwPaM
* pCrsr
= rWrtShell
.GetCrsr();
225 nLastPos
= pCrsr
->Start()->nContent
.GetIndex();
229 void SwHHCWrapper::SelectNewUnit_impl( sal_Int32 nUnitStart
, sal_Int32 nUnitEnd
)
231 SwPaM
*pCrsr
= rWrtShell
.GetCrsr();
232 pCrsr
->GetPoint()->nContent
= nLastPos
;
235 rWrtShell
.Right( CRSR_SKIP_CHARS
, /*bExpand*/ sal_False
,
236 (USHORT
) (nUnitOffset
+ nUnitStart
), sal_True
);
238 rWrtShell
.Right( CRSR_SKIP_CHARS
, /*bExpand*/ sal_True
,
239 (USHORT
) (nUnitEnd
- nUnitStart
), sal_True
);
240 // end selection now. Otherwise SHIFT+HOME (extending the selection)
241 // won't work when the dialog is closed without any replacement.
243 rWrtShell
.EndSelect();
247 void SwHHCWrapper::HandleNewUnit(
248 const sal_Int32 nUnitStart
, const sal_Int32 nUnitEnd
)
250 DBG_ASSERT( nUnitStart
>= 0 && nUnitEnd
>= nUnitStart
, "wrong arguments" );
251 if (!(0 <= nUnitStart
&& nUnitStart
<= nUnitEnd
))
254 lcl_ActivateTextShell( rWrtShell
);
256 rWrtShell
.StartAllAction();
258 // select current unit
259 SelectNewUnit_impl( nUnitStart
, nUnitEnd
);
261 rWrtShell
.EndAllAction();
265 void SwHHCWrapper::ChangeText( const String
&rNewText
,
266 const OUString
& rOrigText
,
267 const uno::Sequence
< sal_Int32
> *pOffsets
,
270 //!! please see also TextConvWrapper::ChangeText with is a modified
271 //!! copy of this code
273 DBG_ASSERT( rNewText
.Len() != 0, "unexpected empty string" );
274 if (rNewText
.Len() == 0)
277 if (pOffsets
&& pCrsr
) // try to keep as much attributation as possible ?
279 // remember cursor start position for later setting of the cursor
280 const SwPosition
*pStart
= pCrsr
->Start();
281 const xub_StrLen nStartIndex
= pStart
->nContent
.GetIndex();
282 const SwNodeIndex aStartNodeIndex
= pStart
->nNode
;
283 SwTxtNode
*pStartTxtNode
= aStartNodeIndex
.GetNode().GetTxtNode();
285 const sal_Int32 nIndices
= pOffsets
->getLength();
286 const sal_Int32
*pIndices
= pOffsets
->getConstArray();
287 xub_StrLen nConvTextLen
= rNewText
.Len();
289 xub_StrLen nChgPos
= STRING_NOTFOUND
;
290 xub_StrLen nChgLen
= 0;
291 xub_StrLen nConvChgPos
= STRING_NOTFOUND
;
292 xub_StrLen nConvChgLen
= 0;
294 // offset to calculate the position in the text taking into
295 // account that text may have been replaced with new text of
296 // different length. Negative values allowed!
297 long nCorrectionOffset
= 0;
299 DBG_ASSERT(nIndices
== 0 || nIndices
== nConvTextLen
,
300 "mismatch between string length and sequence length!" );
302 // find all substrings that need to be replaced (and only those)
305 // get index in original text that matches nPos in new text
307 if (nPos
< nConvTextLen
)
308 nIndex
= (sal_Int32
) nPos
< nIndices
? (xub_StrLen
) pIndices
[nPos
] : nPos
;
312 nIndex
= static_cast< xub_StrLen
>( rOrigText
.getLength() );
315 if (rOrigText
.getStr()[nIndex
] == rNewText
.GetChar(nPos
) ||
316 nPos
== nConvTextLen
/* end of string also terminates non-matching char sequence */)
318 // substring that needs to be replaced found?
319 if (nChgPos
!= STRING_NOTFOUND
&& nConvChgPos
!= STRING_NOTFOUND
)
321 nChgLen
= nIndex
- nChgPos
;
322 nConvChgLen
= nPos
- nConvChgPos
;
324 String
aInOrig( rOrigText
.copy( nChgPos
, nChgLen
) );
326 String
aInNew( rNewText
.Copy( nConvChgPos
, nConvChgLen
) );
328 // set selection to sub string to be replaced in original text
329 xub_StrLen nChgInNodeStartIndex
= static_cast< xub_StrLen
>( nStartIndex
+ nCorrectionOffset
+ nChgPos
);
330 DBG_ASSERT( rWrtShell
.GetCrsr()->HasMark(), "cursor misplaced (nothing selected)" );
331 rWrtShell
.GetCrsr()->GetMark()->nContent
.Assign( pStartTxtNode
, nChgInNodeStartIndex
);
332 rWrtShell
.GetCrsr()->GetPoint()->nContent
.Assign( pStartTxtNode
, nChgInNodeStartIndex
+ nChgLen
);
334 String
aSelTxt1( rWrtShell
.GetSelTxt() );
337 // replace selected sub string with the corresponding
338 // sub string from the new text while keeping as
339 // much from the attributes as possible
340 ChangeText_impl( aInNew
, sal_True
);
342 nCorrectionOffset
+= nConvChgLen
- nChgLen
;
344 nChgPos
= STRING_NOTFOUND
;
345 nConvChgPos
= STRING_NOTFOUND
;
350 // begin of non-matching char sequence found ?
351 if (nChgPos
== STRING_NOTFOUND
&& nConvChgPos
== STRING_NOTFOUND
)
357 if (nPos
>= nConvTextLen
)
362 // set cursor to the end of all the new text
363 // (as it would happen after ChangeText_impl (Delete and Insert)
364 // of the whole text in the 'else' branch below)
365 rWrtShell
.ClearMark();
366 rWrtShell
.GetCrsr()->Start()->nContent
.Assign( pStartTxtNode
, nStartIndex
+ nConvTextLen
);
370 ChangeText_impl( rNewText
, sal_False
);
375 void SwHHCWrapper::ChangeText_impl( const String
&rNewText
, sal_Bool bKeepAttributes
)
379 // get item set with all relevant attributes
380 sal_uInt16 aRanges
[] = {
381 RES_CHRATR_BEGIN
, RES_FRMATR_END
,
383 SfxItemSet
aItemSet( rWrtShell
.GetAttrPool(), aRanges
);
384 // get all attributes spanning the whole selection in order to
385 // restore those for the new text
386 rWrtShell
.GetCurAttr( aItemSet
);
389 String
aSelTxt1( rWrtShell
.GetSelTxt() );
392 rWrtShell
.Insert( rNewText
);
394 // select new inserted text (currently the Point is right after the new text)
395 if (!rWrtShell
.GetCrsr()->HasMark())
396 rWrtShell
.GetCrsr()->SetMark();
397 SwPosition
*pMark
= rWrtShell
.GetCrsr()->GetMark();
398 pMark
->nContent
= pMark
->nContent
.GetIndex() - rNewText
.Len();
400 String
aSelTxt2( rWrtShell
.GetSelTxt() );
403 // since 'SetAttr' below functions like merging with the attributes
404 // from the itemset with any existing ones we have to get rid of all
405 // all attributes now. (Those attributes that may take effect left
406 // to the position where the new text gets inserted after the old text
408 rWrtShell
.ResetAttr();
409 // apply previously saved attributes to new text
410 rWrtShell
.SetAttr( aItemSet
);
415 rWrtShell
.Insert( rNewText
);
420 void SwHHCWrapper::ReplaceUnit(
421 const sal_Int32 nUnitStart
, const sal_Int32 nUnitEnd
,
422 const ::rtl::OUString
& rOrigText
,
423 const OUString
& rReplaceWith
,
424 const uno::Sequence
< sal_Int32
> &rOffsets
,
425 ReplacementAction eAction
,
426 LanguageType
*pNewUnitLanguage
)
428 static OUString
aBracketedStart( C2U( "(" ) );
429 static OUString
aBracketedEnd( C2U( ")" ) );
431 DBG_ASSERT( nUnitStart
>= 0 && nUnitEnd
>= nUnitStart
, "wrong arguments" );
432 if (!(nUnitStart
>= 0 && nUnitEnd
>= nUnitStart
))
435 lcl_ActivateTextShell( rWrtShell
);
437 // Das aktuelle Wort austauschen
438 rWrtShell
.StartAllAction();
440 // select current unit
441 SelectNewUnit_impl( nUnitStart
, nUnitEnd
);
443 OUString
aOrigTxt( rWrtShell
.GetSelTxt() );
444 OUString
aNewTxt( rReplaceWith
);
445 DBG_ASSERT( aOrigTxt
== rOrigText
, "!! text mismatch !!" );
446 SwFmtRuby
*pRuby
= 0;
447 sal_Bool bRubyBelow
= sal_False
;
453 case eReplacementBracketed
:
455 (((aNewTxt
= aOrigTxt
) += aBracketedStart
) += rReplaceWith
) += aBracketedEnd
;
458 case eOriginalBracketed
:
460 (((aNewTxt
= rReplaceWith
) += aBracketedStart
) += aOrigTxt
) += aBracketedEnd
;
463 case eReplacementAbove
:
465 pRuby
= new SwFmtRuby( rReplaceWith
);
468 case eOriginalAbove
:
470 pRuby
= new SwFmtRuby( aOrigTxt
);
471 aNewOrigText
= rReplaceWith
;
474 case eReplacementBelow
:
476 pRuby
= new SwFmtRuby( rReplaceWith
);
477 bRubyBelow
= sal_True
;
480 case eOriginalBelow
:
482 pRuby
= new SwFmtRuby( aOrigTxt
);
483 aNewOrigText
= rReplaceWith
;
484 bRubyBelow
= sal_True
;
488 DBG_ERROR( "unexpected case" );
490 nUnitOffset
+= nUnitStart
+ aNewTxt
.getLength();
494 rWrtShell
.StartUndo( UNDO_SETRUBYATTR
);
495 if (aNewOrigText
.Len())
497 // according to FT we currently should not bother about keeping
498 // attributes in Hangul/Hanja conversion
499 ChangeText( aNewOrigText
, rOrigText
, NULL
, NULL
);
501 //!! since Delete, Insert in 'ChangeText' do not set the WrtShells
503 //!! back to false we do it now manually in order for the selection
504 //!! to be done properly in the following call to Left.
505 // We didn't fix it in Delete and Insert since it is currently
506 // unclear if someone depends on this incorrect behvaiour
508 rWrtShell
.EndSelect();
510 rWrtShell
.Left( 0, TRUE
, aNewOrigText
.Len(), TRUE
, TRUE
);
513 pRuby
->SetPosition( bRubyBelow
);
514 pRuby
->SetAdjustment( RubyAdjust_CENTER
);
515 //!! the following seem not to be needed
516 //pRuby->SetCharFmtName( const String& rNm );
517 //pRuby->SetCharFmtId( USHORT nNew );
519 SwPaM
*pPaM
= rWrtShell
.GetCrsr();
522 rWrtShell
.SetAttr(*pRuby
);
524 rWrtShell
.EndUndo( UNDO_SETRUBYATTR
);
528 rWrtShell
.StartUndo( UNDO_OVERWRITE
);
530 // according to FT we should currently not bother about keeping
531 // attributes in Hangul/Hanja conversion and leave that untouched.
532 // Thus we do this only for Chinese translation...
533 sal_Bool bIsChineseConversion
= IsChinese( GetSourceLanguage() );
534 if (bIsChineseConversion
)
535 ChangeText( aNewTxt
, rOrigText
, &rOffsets
, rWrtShell
.GetCrsr() );
537 ChangeText( aNewTxt
, rOrigText
, NULL
, NULL
);
539 // change language and font if necessary
540 if (bIsChineseConversion
)
543 rWrtShell
.GetCrsr()->GetMark()->nContent
-= (xub_StrLen
) aNewTxt
.getLength();
545 DBG_ASSERT( GetTargetLanguage() == LANGUAGE_CHINESE_SIMPLIFIED
|| GetTargetLanguage() == LANGUAGE_CHINESE_TRADITIONAL
,
546 "SwHHCWrapper::ReplaceUnit : unexpected target language" );
548 sal_uInt16 aRanges
[] = {
549 RES_CHRATR_CJK_LANGUAGE
, RES_CHRATR_CJK_LANGUAGE
,
550 RES_CHRATR_CJK_FONT
, RES_CHRATR_CJK_FONT
,
553 SfxItemSet
aSet( rWrtShell
.GetAttrPool(), aRanges
);
554 if (pNewUnitLanguage
)
556 //DBG_ASSERT(!IsSimilarChinese( *pNewUnitLanguage, nOldLang ),
557 // "similar language should not be changed!");
558 aSet
.Put( SvxLanguageItem( *pNewUnitLanguage
, RES_CHRATR_CJK_LANGUAGE
) );
561 const Font
*pTargetFont
= GetTargetFont();
562 DBG_ASSERT( pTargetFont
, "target font missing?" );
563 if (pTargetFont
&& pNewUnitLanguage
)
565 SvxFontItem aFontItem
= (SvxFontItem
&) aSet
.Get( RES_CHRATR_CJK_FONT
);
566 aFontItem
.GetFamilyName() = pTargetFont
->GetName();
567 aFontItem
.GetFamily() = pTargetFont
->GetFamily();
568 aFontItem
.GetStyleName() = pTargetFont
->GetStyleName();
569 aFontItem
.GetPitch() = pTargetFont
->GetPitch();
570 aFontItem
.GetCharSet() = pTargetFont
->GetCharSet();
571 aSet
.Put( aFontItem
);
574 rWrtShell
.SetAttr( aSet
);
576 rWrtShell
.ClearMark();
579 rWrtShell
.EndUndo( UNDO_OVERWRITE
);
582 rWrtShell
.EndAllAction();
586 sal_Bool
SwHHCWrapper::HasRubySupport() const
592 void SwHHCWrapper::Convert()
594 DBG_ASSERT( pConvArgs
== 0, "NULL pointer expected" );
596 SwPaM
*pCrsr
= pView
->GetWrtShell().GetCrsr();
597 SwPosition
* pSttPos
= pCrsr
->Start();
598 SwPosition
* pEndPos
= pCrsr
->End();
601 if (pSttPos
->nNode
.GetNode().IsTxtNode() &&
602 pEndPos
->nNode
.GetNode().IsTxtNode())
604 pConvArgs
= new SwConversionArgs( GetSourceLanguage(),
605 pSttPos
->nNode
.GetNode().GetTxtNode(), pSttPos
->nContent
,
606 pEndPos
->nNode
.GetNode().GetTxtNode(), pEndPos
->nContent
);
608 else // we are not in the text (maybe a graphic or OLE object is selected) let's start from the top
610 // get PaM that points to the start of the document
611 SwNode
& rNode
= pView
->GetDocShell()->GetDoc()->GetNodes().GetEndOfContent();
613 aPam
.Move( fnMoveBackward
, fnGoDoc
); // move to start of document
615 pSttPos
= aPam
.GetPoint(); //! using a PaM here makes sure we will get only text nodes
616 SwTxtNode
*pTxtNode
= pSttPos
->nNode
.GetNode().GetTxtNode();
617 // just in case we check anyway...
618 if (!pTxtNode
|| !pTxtNode
->IsTxtNode())
620 pConvArgs
= new SwConversionArgs( GetSourceLanguage(),
621 pTxtNode
, pSttPos
->nContent
,
622 pTxtNode
, pSttPos
->nContent
);
624 DBG_ASSERT( pConvArgs
->pStartNode
&& pConvArgs
->pStartNode
->IsTxtNode(),
625 "failed to get proper start text node" );
626 DBG_ASSERT( pConvArgs
->pEndNode
&& pConvArgs
->pEndNode
->IsTxtNode(),
627 "failed to get proper end text node" );
629 // chinese conversion specific settings
630 DBG_ASSERT( IsChinese( GetSourceLanguage() ) == IsChinese( GetTargetLanguage() ),
631 "source and target language mismatch?" );
632 if (IsChinese( GetTargetLanguage() ))
634 pConvArgs
->nConvTargetLang
= GetTargetLanguage();
635 pConvArgs
->pTargetFont
= GetTargetFont();
636 pConvArgs
->bAllowImplicitChangesForNotConvertibleText
= sal_True
;
639 // if it is not just a selection and we are about to begin
640 // with the current conversion for the very first time
641 // we need to find the start of the current (initial)
642 // convertible unit in order for the text conversion to give
643 // the correct result for that. Since it is easier to obtain
644 // the start of the word we use that though.
645 if (!pCrsr
->HasMark()) // is not a selection?
647 // since #118246 / #117803 still occurs if the cursor is placed
648 // between the two chinese characters to be converted (because both
649 // of them are words on their own!) using the word boundary here does
650 // not work. Thus since chinese conversion is not interactive we start
651 // at the begin of the paragraph to solve the problem, i.e. have the
652 // TextConversion service get those charcters together in the same call.
653 xub_StrLen nStartIdx
= STRING_MAXLEN
;
654 if (svx::HangulHanjaConversion::IsChinese( GetSourceLanguage() ) )
658 OUString
aText( pConvArgs
->pStartNode
->GetTxt() );
659 long nPos
= pConvArgs
->pStartIdx
->GetIndex();
660 Boundary
aBoundary( pBreakIt
->GetBreakIter()->
661 getWordBoundary( aText
, nPos
, pBreakIt
->GetLocale( pConvArgs
->nConvSrcLang
),
662 WordType::DICTIONARY_WORD
, sal_True
) );
664 // valid result found?
665 if (aBoundary
.startPos
< aText
.getLength() &&
666 aBoundary
.startPos
!= aBoundary
.endPos
)
668 nStartIdx
= static_cast< xub_StrLen
>(aBoundary
.startPos
);
672 if (STRING_MAXLEN
!= nStartIdx
)
673 *pConvArgs
->pStartIdx
= nStartIdx
;
678 ConvStart_impl( pConvArgs
, SVX_SPELL_OTHER
);
681 bStartChk
= sal_False
;
682 ConvStart_impl( pConvArgs
, SVX_SPELL_BODY_END
);
687 ConvEnd_impl( pConvArgs
);
691 sal_Bool
SwHHCWrapper::ConvNext_impl( )
693 //! modified version of SvxSpellWrapper::SpellNext
695 // Keine Richtungsaenderung, also ist der gewuenschte Bereich ( bStartChk )
696 // vollstaendig abgearbeitet.
698 bStartDone
= sal_True
;
702 if( bIsOtherCntnt
&& bStartDone
&& bEndDone
) // Dokument komplett geprueft?
708 //ResMgr* pMgr = DIALOG_MGR();
709 sal_Bool bGoOn
= sal_False
;
713 bStartChk
= sal_False
;
714 ConvStart_impl( pConvArgs
, SVX_SPELL_BODY
);
717 else if ( bStartDone
&& bEndDone
)
719 // Bodybereich erledigt, Frage nach Sonderbereich
720 if( bIsConvSpecial
&& HasOtherCnt_impl() )
722 ConvStart_impl( pConvArgs
, SVX_SPELL_OTHER
);
723 bIsOtherCntnt
= bGoOn
= sal_True
;
730 // Ein BODY_Bereich erledigt, Frage nach dem anderen BODY_Bereich
734 sal_uInt16 nResId = RID_SVXQB_CONTINUE;
735 QueryBox aBox( pWin, ResId( nResId, pMgr ) );
736 if ( aBox.Execute() != RET_YES )
738 // Verzicht auf den anderen Bereich, ggf. Frage nach Sonderbereich
740 bStartDone = bEndDone = sal_True;
746 bStartChk
= !bStartDone
;
747 ConvStart_impl( pConvArgs
, bStartChk
? SVX_SPELL_BODY_START
: SVX_SPELL_BODY_END
);
758 sal_Bool
SwHHCWrapper::FindConvText_impl()
760 //! modified version of SvxSpellWrapper::FindSpellError
762 //ShowLanguageErrors();
764 sal_Bool bFound
= sal_False
;
767 sal_Bool bConv
= sal_True
;
771 bFound
= ConvContinue_impl( pConvArgs
);
778 ConvEnd_impl( pConvArgs
);
779 bConv
= ConvNext_impl();
787 sal_Bool
SwHHCWrapper::HasOtherCnt_impl()
789 return bIsSelection
? sal_False
: rWrtShell
.HasOtherCnt();
793 void SwHHCWrapper::ConvStart_impl( SwConversionArgs
/* [out] */ *pConversionArgs
, SvxSpellArea eArea
)
795 SetDrawObj( SVX_SPELL_OTHER
== eArea
);
796 pView
->SpellStart( eArea
, bStartDone
, bEndDone
, /* [out] */ pConversionArgs
);
800 void SwHHCWrapper::ConvEnd_impl( SwConversionArgs
*pConversionArgs
)
802 pView
->SpellEnd( pConversionArgs
);
803 //ShowLanguageErrors();
807 sal_Bool
SwHHCWrapper::ConvContinue_impl( SwConversionArgs
*pConversionArgs
)
809 sal_Bool bProgress
= !bIsDrawObj
&& !bIsSelection
;
810 // bLastRet = aConvText.getLength() == 0;
811 pConversionArgs
->aConvText
= OUString();
812 pConversionArgs
->nConvTextLang
= LANGUAGE_NONE
;
813 uno::Any aRet
= bProgress
?
814 pView
->GetWrtShell().SpellContinue( &nPageCount
, &nPageStart
, pConversionArgs
) :
815 pView
->GetWrtShell().SpellContinue( &nPageCount
, NULL
, pConversionArgs
);
816 //aRet >>= aConvText;
817 return pConversionArgs
->aConvText
.getLength() != 0;
820 //////////////////////////////////////////////////////////////////////