xref: /aoo41x/main/sw/source/ui/lingu/hhcwrp.cxx (revision 69a74367)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #ifdef PRECOMPILED
27cdf0e10cSrcweir #include "ui_pch.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <hintids.hxx>
32cdf0e10cSrcweir #ifndef _VIEW_HXX
33cdf0e10cSrcweir #include <view.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <wrtsh.hxx>
36cdf0e10cSrcweir #include <swundo.hxx>         // fuer Undo-Ids
37cdf0e10cSrcweir #ifndef _GLOBALS_HRC
38cdf0e10cSrcweir #include <globals.hrc>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include <splargs.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
44cdf0e10cSrcweir #include <vcl/msgbox.hxx>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir #include <editeng/unolingu.hxx>
47cdf0e10cSrcweir #include <editeng/langitem.hxx>
48cdf0e10cSrcweir #include <editeng/fontitem.hxx>
49cdf0e10cSrcweir #include <rtl/ustring.hxx>
50cdf0e10cSrcweir #include <com/sun/star/text/RubyAdjust.hpp>
51cdf0e10cSrcweir #include <hhcwrp.hxx>
52cdf0e10cSrcweir #include <sdrhhcwrap.hxx>
53cdf0e10cSrcweir #include <doc.hxx>
54cdf0e10cSrcweir #include <docsh.hxx>
55cdf0e10cSrcweir #include <txatritr.hxx>
56cdf0e10cSrcweir #include <mdiexp.hxx>		// Progress
57cdf0e10cSrcweir #include <edtwin.hxx>
58cdf0e10cSrcweir #include <crsskip.hxx>
59cdf0e10cSrcweir #include <index.hxx>
60cdf0e10cSrcweir #include <pam.hxx>
61cdf0e10cSrcweir #include <swcrsr.hxx>
62cdf0e10cSrcweir #include <viscrs.hxx>
63cdf0e10cSrcweir #include <ndtxt.hxx>
64cdf0e10cSrcweir #include <fmtruby.hxx>
65cdf0e10cSrcweir #include <breakit.hxx>
66cdf0e10cSrcweir #include <docsh.hxx>
67cdf0e10cSrcweir 
68cdf0e10cSrcweir #ifndef _OLMENU_HRC
69cdf0e10cSrcweir #include <olmenu.hrc>
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir 
72cdf0e10cSrcweir #include <unomid.h>
73cdf0e10cSrcweir 
74cdf0e10cSrcweir using ::rtl::OUString;
75cdf0e10cSrcweir using namespace ::com::sun::star;
76cdf0e10cSrcweir using namespace ::com::sun::star::text;
77cdf0e10cSrcweir using namespace ::com::sun::star::uno;
78cdf0e10cSrcweir using namespace ::com::sun::star::linguistic2;
79cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
80cdf0e10cSrcweir 
81cdf0e10cSrcweir #define CHAR_PAR_BRK    ((sal_Char) 0x0D)
82cdf0e10cSrcweir 
83cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
84cdf0e10cSrcweir //     Beschreibung: Ggf. Rahmen/Objektshell abschalten
85cdf0e10cSrcweir 
lcl_ActivateTextShell(SwWrtShell & rWrtSh)86cdf0e10cSrcweir static void lcl_ActivateTextShell( SwWrtShell & rWrtSh )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir     if( rWrtSh.IsSelFrmMode() || rWrtSh.IsObjSelected() )
89cdf0e10cSrcweir         rWrtSh.EnterStdMode();
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
93cdf0e10cSrcweir 
94cdf0e10cSrcweir class SwKeepConversionDirectionStateContext
95cdf0e10cSrcweir {
96cdf0e10cSrcweir public:
SwKeepConversionDirectionStateContext()97cdf0e10cSrcweir 	SwKeepConversionDirectionStateContext()
98cdf0e10cSrcweir 	{
99cdf0e10cSrcweir 		//!! hack to transport the current conversion direction state settings
100cdf0e10cSrcweir 		//!! into the next incarnation that iterates over the drawing objets
101cdf0e10cSrcweir 		//!! ( see SwHHCWrapper::~SwHHCWrapper() )
102cdf0e10cSrcweir 		editeng::HangulHanjaConversion::SetUseSavedConversionDirectionState( sal_True );
103cdf0e10cSrcweir 	}
104cdf0e10cSrcweir 
~SwKeepConversionDirectionStateContext()105cdf0e10cSrcweir 	~SwKeepConversionDirectionStateContext()
106cdf0e10cSrcweir 	{
107cdf0e10cSrcweir 		editeng::HangulHanjaConversion::SetUseSavedConversionDirectionState( sal_False );
108cdf0e10cSrcweir 	}
109cdf0e10cSrcweir };
110cdf0e10cSrcweir 
111cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
112cdf0e10cSrcweir 
SwHHCWrapper(SwView * pSwView,const uno::Reference<lang::XMultiServiceFactory> & rxMSF,LanguageType nSourceLanguage,LanguageType nTargetLanguage,const Font * pTargetFont,sal_Int32 nConvOptions,sal_Bool bIsInteractive,sal_Bool bStart,sal_Bool bOther,sal_Bool bSelection)113cdf0e10cSrcweir SwHHCWrapper::SwHHCWrapper(
114cdf0e10cSrcweir         SwView* pSwView,
115cdf0e10cSrcweir         const uno::Reference< lang::XMultiServiceFactory >& rxMSF,
116cdf0e10cSrcweir         LanguageType nSourceLanguage,
117cdf0e10cSrcweir         LanguageType nTargetLanguage,
118cdf0e10cSrcweir         const Font *pTargetFont,
119cdf0e10cSrcweir         sal_Int32 nConvOptions,
120cdf0e10cSrcweir         sal_Bool bIsInteractive,
121cdf0e10cSrcweir         sal_Bool bStart, sal_Bool bOther, sal_Bool bSelection ) :
122cdf0e10cSrcweir     editeng::HangulHanjaConversion( &pSwView->GetEditWin(), rxMSF,
123cdf0e10cSrcweir                                 SvxCreateLocale( nSourceLanguage ),
124cdf0e10cSrcweir                                 SvxCreateLocale( nTargetLanguage ),
125cdf0e10cSrcweir                                 pTargetFont,
126cdf0e10cSrcweir                                 nConvOptions,
127cdf0e10cSrcweir                                 bIsInteractive ),
128cdf0e10cSrcweir     rWrtShell( pSwView->GetWrtShell() )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir     pConvArgs       = 0;
131cdf0e10cSrcweir     nLastPos        = 0;
132cdf0e10cSrcweir     nUnitOffset     = 0;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     pView           = pSwView;
135cdf0e10cSrcweir     pWin            = &pSwView->GetEditWin();
136cdf0e10cSrcweir     bIsDrawObj      = sal_False;
137cdf0e10cSrcweir     bIsStart        = bStart;
138cdf0e10cSrcweir     bIsOtherCntnt   = bStartChk     = bOther;
139cdf0e10cSrcweir     bIsConvSpecial  = sal_True;
140cdf0e10cSrcweir     bIsSelection    = bSelection;
141cdf0e10cSrcweir     bInfoBox        = sal_False;
142cdf0e10cSrcweir     bStartDone  = bOther || bStart;
143cdf0e10cSrcweir     bEndDone    = sal_False;
144cdf0e10cSrcweir //    bLastRet    = sal_True;
145cdf0e10cSrcweir     nPageCount  = nPageStart = 0;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
~SwHHCWrapper()149cdf0e10cSrcweir SwHHCWrapper::~SwHHCWrapper()
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     delete pConvArgs;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     rWrtShell.SetCareWin( NULL );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	// check for existence of a draw view which means that there are
156cdf0e10cSrcweir 	// (or previously were) draw objects present in the document.
157cdf0e10cSrcweir 	// I.e. we like to check those too.
158cdf0e10cSrcweir     if ( IsDrawObj() /*&& bLastRet*/ && pView->GetWrtShell().HasDrawView() )
159cdf0e10cSrcweir     {
160cdf0e10cSrcweir         Cursor *pSave = pView->GetWindow()->GetCursor();
161cdf0e10cSrcweir         {
162cdf0e10cSrcweir 			SwKeepConversionDirectionStateContext aContext;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir             SdrHHCWrapper aSdrConvWrap( pView, GetSourceLanguage(),
165cdf0e10cSrcweir                     GetTargetLanguage(), GetTargetFont(),
166cdf0e10cSrcweir                     GetConversionOptions(), IsInteractive() );
167cdf0e10cSrcweir             aSdrConvWrap.StartTextConversion();
168cdf0e10cSrcweir         }
169cdf0e10cSrcweir         pView->GetWindow()->SetCursor( pSave );
170cdf0e10cSrcweir     }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     if( nPageCount )
173cdf0e10cSrcweir         ::EndProgress( pView->GetDocShell() );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     // finally for chinese translation we need to change the the documents
176cdf0e10cSrcweir     // default language and font to the new ones to be used.
177cdf0e10cSrcweir     LanguageType nTargetLang = GetTargetLanguage();
178cdf0e10cSrcweir     if (IsChinese( nTargetLang ))
179cdf0e10cSrcweir     {
180cdf0e10cSrcweir         SwDoc *pDoc = pView->GetDocShell()->GetDoc();
181cdf0e10cSrcweir 
182cdf0e10cSrcweir         //!! Note: This also effects the default language of text boxes (EditEngine/EditView) !!
183cdf0e10cSrcweir         pDoc->SetDefault( SvxLanguageItem( nTargetLang, RES_CHRATR_CJK_LANGUAGE ) );
184cdf0e10cSrcweir         //
185cdf0e10cSrcweir         const Font *pFont = GetTargetFont();
186cdf0e10cSrcweir         if (pFont)
187cdf0e10cSrcweir         {
188cdf0e10cSrcweir             SvxFontItem aFontItem( pFont->GetFamily(), pFont->GetName(),
189cdf0e10cSrcweir                     pFont->GetStyleName(), pFont->GetPitch(),
190cdf0e10cSrcweir                     pFont->GetCharSet(), RES_CHRATR_CJK_FONT );
191cdf0e10cSrcweir             pDoc->SetDefault( aFontItem );
192cdf0e10cSrcweir         }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir /*
197cdf0e10cSrcweir     if( bInfoBox )
198cdf0e10cSrcweir         InfoBox(&pView->GetEditWin(), String(SW_RES(STR_SPELL_OK)) ).Execute();
199cdf0e10cSrcweir */
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
GetNextPortion(::rtl::OUString & rNextPortion,LanguageType & rLangOfPortion,sal_Bool bAllowChanges)203cdf0e10cSrcweir void SwHHCWrapper::GetNextPortion(
204cdf0e10cSrcweir         ::rtl::OUString&    rNextPortion,
205cdf0e10cSrcweir         LanguageType&       rLangOfPortion,
206cdf0e10cSrcweir         sal_Bool bAllowChanges )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir     pConvArgs->bAllowImplicitChangesForNotConvertibleText = bAllowChanges;
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     FindConvText_impl();
211cdf0e10cSrcweir     rNextPortion    = pConvArgs->aConvText;
212cdf0e10cSrcweir     rLangOfPortion  = pConvArgs->nConvTextLang;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     nUnitOffset  = 0;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     // build last pos from currently selected text
217cdf0e10cSrcweir     SwPaM* pCrsr = rWrtShell.GetCrsr();
218cdf0e10cSrcweir     nLastPos =  pCrsr->Start()->nContent.GetIndex();
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 
SelectNewUnit_impl(sal_Int32 nUnitStart,sal_Int32 nUnitEnd)222cdf0e10cSrcweir void SwHHCWrapper::SelectNewUnit_impl( sal_Int32 nUnitStart, sal_Int32 nUnitEnd )
223cdf0e10cSrcweir {
224cdf0e10cSrcweir     SwPaM *pCrsr = rWrtShell.GetCrsr();
225cdf0e10cSrcweir     pCrsr->GetPoint()->nContent = nLastPos;
226cdf0e10cSrcweir     pCrsr->DeleteMark();
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ sal_False,
229cdf0e10cSrcweir                   (sal_uInt16) (nUnitOffset + nUnitStart), sal_True );
230cdf0e10cSrcweir     pCrsr->SetMark();
231cdf0e10cSrcweir     rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ sal_True,
232cdf0e10cSrcweir                   (sal_uInt16) (nUnitEnd - nUnitStart), sal_True );
233cdf0e10cSrcweir 	// end selection now. Otherwise SHIFT+HOME (extending the selection)
234cdf0e10cSrcweir 	// won't work when the dialog is closed without any replacement.
235cdf0e10cSrcweir 	// (see #116346#)
236cdf0e10cSrcweir 	rWrtShell.EndSelect();
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 
HandleNewUnit(const sal_Int32 nUnitStart,const sal_Int32 nUnitEnd)240cdf0e10cSrcweir void SwHHCWrapper::HandleNewUnit(
241cdf0e10cSrcweir         const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir     DBG_ASSERT( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
244cdf0e10cSrcweir     if (!(0 <= nUnitStart && nUnitStart <= nUnitEnd))
245cdf0e10cSrcweir         return;
246cdf0e10cSrcweir 
247cdf0e10cSrcweir     lcl_ActivateTextShell( rWrtShell );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     rWrtShell.StartAllAction();
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     // select current unit
252cdf0e10cSrcweir     SelectNewUnit_impl( nUnitStart, nUnitEnd );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     rWrtShell.EndAllAction();
255cdf0e10cSrcweir }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 
ChangeText(const String & rNewText,const OUString & rOrigText,const uno::Sequence<sal_Int32> * pOffsets,SwPaM * pCrsr)258cdf0e10cSrcweir void SwHHCWrapper::ChangeText( const String &rNewText,
259cdf0e10cSrcweir         const OUString& rOrigText,
260cdf0e10cSrcweir         const uno::Sequence< sal_Int32 > *pOffsets,
261cdf0e10cSrcweir         SwPaM *pCrsr )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir 	//!! please see also TextConvWrapper::ChangeText with is a modified
264cdf0e10cSrcweir 	//!! copy of this code
265cdf0e10cSrcweir 
266cdf0e10cSrcweir     DBG_ASSERT( rNewText.Len() != 0, "unexpected empty string" );
267cdf0e10cSrcweir     if (rNewText.Len() == 0)
268cdf0e10cSrcweir         return;
269cdf0e10cSrcweir 
270cdf0e10cSrcweir     if (pOffsets && pCrsr)  // try to keep as much attributation as possible ?
271cdf0e10cSrcweir     {
272cdf0e10cSrcweir         // remember cursor start position for later setting of the cursor
273cdf0e10cSrcweir         const SwPosition *pStart = pCrsr->Start();
274cdf0e10cSrcweir         const xub_StrLen nStartIndex = pStart->nContent.GetIndex();
275cdf0e10cSrcweir         const SwNodeIndex aStartNodeIndex  = pStart->nNode;
276cdf0e10cSrcweir         SwTxtNode *pStartTxtNode = aStartNodeIndex.GetNode().GetTxtNode();
277cdf0e10cSrcweir 
278cdf0e10cSrcweir         const sal_Int32  nIndices = pOffsets->getLength();
279cdf0e10cSrcweir         const sal_Int32 *pIndices = pOffsets->getConstArray();
280cdf0e10cSrcweir         xub_StrLen nConvTextLen = rNewText.Len();
281cdf0e10cSrcweir         xub_StrLen nPos = 0;
282cdf0e10cSrcweir         xub_StrLen nChgPos = STRING_NOTFOUND;
283cdf0e10cSrcweir         xub_StrLen nChgLen = 0;
284cdf0e10cSrcweir         xub_StrLen nConvChgPos = STRING_NOTFOUND;
285cdf0e10cSrcweir         xub_StrLen nConvChgLen = 0;
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 		// offset to calculate the position in the text taking into
288cdf0e10cSrcweir 		// account that text may have been replaced with new text of
289cdf0e10cSrcweir 		// different length. Negative values allowed!
290cdf0e10cSrcweir 		long nCorrectionOffset = 0;
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 		DBG_ASSERT(nIndices == 0 || nIndices == nConvTextLen,
293cdf0e10cSrcweir                 "mismatch between string length and sequence length!" );
294cdf0e10cSrcweir 
295cdf0e10cSrcweir         // find all substrings that need to be replaced (and only those)
296cdf0e10cSrcweir         while (sal_True)
297cdf0e10cSrcweir         {
298cdf0e10cSrcweir 			// get index in original text that matches nPos in new text
299cdf0e10cSrcweir 			xub_StrLen nIndex;
300cdf0e10cSrcweir 			if (nPos < nConvTextLen)
301cdf0e10cSrcweir 				nIndex = (sal_Int32) nPos < nIndices ? (xub_StrLen) pIndices[nPos] : nPos;
302cdf0e10cSrcweir 			else
303cdf0e10cSrcweir 			{
304cdf0e10cSrcweir 				nPos   = nConvTextLen;
305cdf0e10cSrcweir 				nIndex = static_cast< xub_StrLen >( rOrigText.getLength() );
306cdf0e10cSrcweir 			}
307cdf0e10cSrcweir 
308cdf0e10cSrcweir             if (rOrigText.getStr()[nIndex] == rNewText.GetChar(nPos) ||
309cdf0e10cSrcweir 				nPos == nConvTextLen /* end of string also terminates non-matching char sequence */)
310cdf0e10cSrcweir             {
311cdf0e10cSrcweir                 // substring that needs to be replaced found?
312cdf0e10cSrcweir                 if (nChgPos != STRING_NOTFOUND && nConvChgPos != STRING_NOTFOUND)
313cdf0e10cSrcweir                 {
314cdf0e10cSrcweir                     nChgLen = nIndex - nChgPos;
315cdf0e10cSrcweir                     nConvChgLen = nPos - nConvChgPos;
316cdf0e10cSrcweir #ifdef DEBUG
317cdf0e10cSrcweir                     String aInOrig( rOrigText.copy( nChgPos, nChgLen ) );
318cdf0e10cSrcweir #endif
319cdf0e10cSrcweir                     String aInNew( rNewText.Copy( nConvChgPos, nConvChgLen ) );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 					// set selection to sub string to be replaced in original text
322cdf0e10cSrcweir                     xub_StrLen nChgInNodeStartIndex = static_cast< xub_StrLen >( nStartIndex + nCorrectionOffset + nChgPos );
323cdf0e10cSrcweir                     DBG_ASSERT( rWrtShell.GetCrsr()->HasMark(), "cursor misplaced (nothing selected)" );
324cdf0e10cSrcweir                     rWrtShell.GetCrsr()->GetMark()->nContent.Assign( pStartTxtNode, nChgInNodeStartIndex );
325cdf0e10cSrcweir                     rWrtShell.GetCrsr()->GetPoint()->nContent.Assign( pStartTxtNode, nChgInNodeStartIndex + nChgLen );
326cdf0e10cSrcweir #ifdef DEBUG
327cdf0e10cSrcweir 					String aSelTxt1( rWrtShell.GetSelTxt() );
328cdf0e10cSrcweir #endif
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 					// replace selected sub string with the corresponding
331cdf0e10cSrcweir 					// sub string from the new text while keeping as
332cdf0e10cSrcweir 					// much from the attributes as possible
333cdf0e10cSrcweir                     ChangeText_impl( aInNew, sal_True );
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 					nCorrectionOffset += nConvChgLen - nChgLen;
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 					nChgPos = STRING_NOTFOUND;
338cdf0e10cSrcweir                     nConvChgPos = STRING_NOTFOUND;
339cdf0e10cSrcweir                 }
340cdf0e10cSrcweir             }
341cdf0e10cSrcweir             else
342cdf0e10cSrcweir             {
343cdf0e10cSrcweir                 // begin of non-matching char sequence found ?
344cdf0e10cSrcweir                 if (nChgPos == STRING_NOTFOUND && nConvChgPos == STRING_NOTFOUND)
345cdf0e10cSrcweir                 {
346cdf0e10cSrcweir                     nChgPos = nIndex;
347cdf0e10cSrcweir                     nConvChgPos = nPos;
348cdf0e10cSrcweir                 }
349cdf0e10cSrcweir             }
350cdf0e10cSrcweir 			if (nPos >= nConvTextLen)
351cdf0e10cSrcweir 				break;
352cdf0e10cSrcweir             ++nPos;
353cdf0e10cSrcweir         }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 		// set cursor to the end of all the new text
356cdf0e10cSrcweir         // (as it would happen after ChangeText_impl (Delete and Insert)
357cdf0e10cSrcweir 		// of the whole text in the 'else' branch below)
358cdf0e10cSrcweir         rWrtShell.ClearMark();
359cdf0e10cSrcweir         rWrtShell.GetCrsr()->Start()->nContent.Assign( pStartTxtNode, nStartIndex + nConvTextLen );
360cdf0e10cSrcweir     }
361cdf0e10cSrcweir     else
362cdf0e10cSrcweir     {
363cdf0e10cSrcweir         ChangeText_impl( rNewText, sal_False );
364cdf0e10cSrcweir     }
365cdf0e10cSrcweir }
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 
ChangeText_impl(const String & rNewText,sal_Bool bKeepAttributes)368cdf0e10cSrcweir void SwHHCWrapper::ChangeText_impl( const String &rNewText, sal_Bool bKeepAttributes )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir     if (bKeepAttributes)
371cdf0e10cSrcweir 	{
372cdf0e10cSrcweir         // get item set with all relevant attributes
373cdf0e10cSrcweir         sal_uInt16 aRanges[] = {
374cdf0e10cSrcweir                 RES_CHRATR_BEGIN, RES_FRMATR_END,
375cdf0e10cSrcweir                 0, 0, 0  };
376cdf0e10cSrcweir         SfxItemSet aItemSet( rWrtShell.GetAttrPool(), aRanges );
377cdf0e10cSrcweir         // get all attributes spanning the whole selection in order to
378cdf0e10cSrcweir         // restore those for the new text
379cdf0e10cSrcweir         rWrtShell.GetCurAttr( aItemSet );
380cdf0e10cSrcweir 
381cdf0e10cSrcweir #ifdef DEBUG
382cdf0e10cSrcweir 		String aSelTxt1( rWrtShell.GetSelTxt() );
383cdf0e10cSrcweir #endif
384cdf0e10cSrcweir         rWrtShell.Delete();
385cdf0e10cSrcweir         rWrtShell.Insert( rNewText );
386cdf0e10cSrcweir 
387cdf0e10cSrcweir         // select new inserted text (currently the Point is right after the new text)
388cdf0e10cSrcweir         if (!rWrtShell.GetCrsr()->HasMark())
389cdf0e10cSrcweir             rWrtShell.GetCrsr()->SetMark();
390cdf0e10cSrcweir         SwPosition *pMark = rWrtShell.GetCrsr()->GetMark();
391cdf0e10cSrcweir         pMark->nContent = pMark->nContent.GetIndex() - rNewText.Len();
392cdf0e10cSrcweir #ifdef DEBUG
393cdf0e10cSrcweir 		String aSelTxt2( rWrtShell.GetSelTxt() );
394cdf0e10cSrcweir #endif
395cdf0e10cSrcweir 
396cdf0e10cSrcweir         // since 'SetAttr' below functions like merging with the attributes
397cdf0e10cSrcweir         // from the itemset with any existing ones we have to get rid of all
398cdf0e10cSrcweir         // all attributes now. (Those attributes that may take effect left
399cdf0e10cSrcweir         // to the position where the new text gets inserted after the old text
400cdf0e10cSrcweir         // was deleted)
401cdf0e10cSrcweir         rWrtShell.ResetAttr();
402cdf0e10cSrcweir         // apply previously saved attributes to new text
403*69a74367SOliver-Rainer Wittmann         rWrtShell.SetAttrSet( aItemSet );
404cdf0e10cSrcweir 	}
405cdf0e10cSrcweir 	else
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir         rWrtShell.Delete();
408cdf0e10cSrcweir         rWrtShell.Insert( rNewText );
409cdf0e10cSrcweir 	}
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 
ReplaceUnit(const sal_Int32 nUnitStart,const sal_Int32 nUnitEnd,const::rtl::OUString & rOrigText,const OUString & rReplaceWith,const uno::Sequence<sal_Int32> & rOffsets,ReplacementAction eAction,LanguageType * pNewUnitLanguage)413cdf0e10cSrcweir void SwHHCWrapper::ReplaceUnit(
414cdf0e10cSrcweir          const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd,
415cdf0e10cSrcweir          const ::rtl::OUString& rOrigText,
416cdf0e10cSrcweir          const OUString& rReplaceWith,
417cdf0e10cSrcweir          const uno::Sequence< sal_Int32 > &rOffsets,
418cdf0e10cSrcweir          ReplacementAction eAction,
419cdf0e10cSrcweir          LanguageType *pNewUnitLanguage )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir     static OUString aBracketedStart( C2U( "(" ) );
422cdf0e10cSrcweir     static OUString aBracketedEnd( C2U( ")" ) );
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     DBG_ASSERT( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
425cdf0e10cSrcweir     if (!(nUnitStart >= 0 && nUnitEnd >= nUnitStart))
426cdf0e10cSrcweir         return;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     lcl_ActivateTextShell( rWrtShell );
429cdf0e10cSrcweir 
430cdf0e10cSrcweir     // Das aktuelle Wort austauschen
431cdf0e10cSrcweir     rWrtShell.StartAllAction();
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     // select current unit
434cdf0e10cSrcweir     SelectNewUnit_impl( nUnitStart, nUnitEnd );
435cdf0e10cSrcweir 
436cdf0e10cSrcweir     OUString aOrigTxt( rWrtShell.GetSelTxt() );
437cdf0e10cSrcweir     OUString aNewTxt( rReplaceWith );
438cdf0e10cSrcweir     DBG_ASSERT( aOrigTxt == rOrigText, "!! text mismatch !!" );
439cdf0e10cSrcweir     SwFmtRuby *pRuby = 0;
440cdf0e10cSrcweir     sal_Bool bRubyBelow = sal_False;
441cdf0e10cSrcweir     String  aNewOrigText;
442cdf0e10cSrcweir     switch (eAction)
443cdf0e10cSrcweir     {
444cdf0e10cSrcweir         case eExchange :
445cdf0e10cSrcweir         break;
446cdf0e10cSrcweir         case eReplacementBracketed :
447cdf0e10cSrcweir         {
448cdf0e10cSrcweir             (((aNewTxt = aOrigTxt) += aBracketedStart) += rReplaceWith) += aBracketedEnd;
449cdf0e10cSrcweir         }
450cdf0e10cSrcweir         break;
451cdf0e10cSrcweir         case eOriginalBracketed :
452cdf0e10cSrcweir         {
453cdf0e10cSrcweir             (((aNewTxt = rReplaceWith) += aBracketedStart) += aOrigTxt) += aBracketedEnd;
454cdf0e10cSrcweir         }
455cdf0e10cSrcweir         break;
456cdf0e10cSrcweir         case eReplacementAbove  :
457cdf0e10cSrcweir         {
458cdf0e10cSrcweir             pRuby = new SwFmtRuby( rReplaceWith );
459cdf0e10cSrcweir         }
460cdf0e10cSrcweir         break;
461cdf0e10cSrcweir         case eOriginalAbove :
462cdf0e10cSrcweir         {
463cdf0e10cSrcweir             pRuby = new SwFmtRuby( aOrigTxt );
464cdf0e10cSrcweir             aNewOrigText = rReplaceWith;
465cdf0e10cSrcweir         }
466cdf0e10cSrcweir         break;
467cdf0e10cSrcweir         case eReplacementBelow :
468cdf0e10cSrcweir         {
469cdf0e10cSrcweir             pRuby = new SwFmtRuby( rReplaceWith );
470cdf0e10cSrcweir             bRubyBelow = sal_True;
471cdf0e10cSrcweir         }
472cdf0e10cSrcweir         break;
473cdf0e10cSrcweir         case eOriginalBelow :
474cdf0e10cSrcweir         {
475cdf0e10cSrcweir             pRuby = new SwFmtRuby( aOrigTxt );
476cdf0e10cSrcweir             aNewOrigText = rReplaceWith;
477cdf0e10cSrcweir             bRubyBelow = sal_True;
478cdf0e10cSrcweir         }
479cdf0e10cSrcweir         break;
480cdf0e10cSrcweir         default:
481cdf0e10cSrcweir             DBG_ERROR( "unexpected case" );
482cdf0e10cSrcweir     }
483cdf0e10cSrcweir     nUnitOffset += nUnitStart + aNewTxt.getLength();
484cdf0e10cSrcweir 
485cdf0e10cSrcweir     if (pRuby)
486cdf0e10cSrcweir     {
487cdf0e10cSrcweir         rWrtShell.StartUndo( UNDO_SETRUBYATTR );
488cdf0e10cSrcweir         if (aNewOrigText.Len())
489cdf0e10cSrcweir         {
490cdf0e10cSrcweir             // according to FT we currently should not bother about keeping
491cdf0e10cSrcweir             // attributes in Hangul/Hanja conversion
492cdf0e10cSrcweir             ChangeText( aNewOrigText, rOrigText, NULL, NULL );
493cdf0e10cSrcweir 
494cdf0e10cSrcweir             //!! since Delete, Insert in 'ChangeText' do not set the WrtShells
495cdf0e10cSrcweir             //!! bInSelect flag
496cdf0e10cSrcweir             //!! back to false we do it now manually in order for the selection
497cdf0e10cSrcweir             //!! to be done properly in the following call to Left.
498cdf0e10cSrcweir             // We didn't fix it in Delete and Insert since it is currently
499cdf0e10cSrcweir             // unclear if someone depends on this incorrect behvaiour
500cdf0e10cSrcweir             // of the flag.
501cdf0e10cSrcweir             rWrtShell.EndSelect();
502cdf0e10cSrcweir 
503cdf0e10cSrcweir             rWrtShell.Left( 0, sal_True, aNewOrigText.Len(), sal_True, sal_True );
504cdf0e10cSrcweir         }
505cdf0e10cSrcweir 
506cdf0e10cSrcweir         pRuby->SetPosition( bRubyBelow );
507cdf0e10cSrcweir         pRuby->SetAdjustment( RubyAdjust_CENTER );
508cdf0e10cSrcweir 		//!! the following seem not to be needed
509cdf0e10cSrcweir         //pRuby->SetCharFmtName( const String& rNm );
510cdf0e10cSrcweir         //pRuby->SetCharFmtId( sal_uInt16 nNew );
511cdf0e10cSrcweir #ifdef DEBUG
512cdf0e10cSrcweir         SwPaM *pPaM = rWrtShell.GetCrsr();
513cdf0e10cSrcweir         (void)pPaM;
514cdf0e10cSrcweir #endif
515*69a74367SOliver-Rainer Wittmann         rWrtShell.SetAttrItem(*pRuby);
516cdf0e10cSrcweir         delete pRuby;
517cdf0e10cSrcweir         rWrtShell.EndUndo( UNDO_SETRUBYATTR );
518cdf0e10cSrcweir     }
519cdf0e10cSrcweir     else
520cdf0e10cSrcweir     {
521cdf0e10cSrcweir         rWrtShell.StartUndo( UNDO_OVERWRITE );
522cdf0e10cSrcweir 
523cdf0e10cSrcweir         // according to FT we should currently not bother about keeping
524cdf0e10cSrcweir         // attributes in Hangul/Hanja conversion and leave that untouched.
525cdf0e10cSrcweir         // Thus we do this only for Chinese translation...
526cdf0e10cSrcweir         sal_Bool bIsChineseConversion = IsChinese( GetSourceLanguage() );
527cdf0e10cSrcweir         if (bIsChineseConversion)
528cdf0e10cSrcweir             ChangeText( aNewTxt, rOrigText, &rOffsets, rWrtShell.GetCrsr() );
529cdf0e10cSrcweir         else
530cdf0e10cSrcweir             ChangeText( aNewTxt, rOrigText, NULL, NULL );
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 		// change language and font if necessary
533cdf0e10cSrcweir         if (bIsChineseConversion)
534cdf0e10cSrcweir         {
535cdf0e10cSrcweir 			rWrtShell.SetMark();
536cdf0e10cSrcweir             rWrtShell.GetCrsr()->GetMark()->nContent -= (xub_StrLen) aNewTxt.getLength();
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 			DBG_ASSERT( GetTargetLanguage() == LANGUAGE_CHINESE_SIMPLIFIED || GetTargetLanguage() == LANGUAGE_CHINESE_TRADITIONAL,
539cdf0e10cSrcweir 					"SwHHCWrapper::ReplaceUnit : unexpected target language" );
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 			sal_uInt16 aRanges[] = {
542cdf0e10cSrcweir 					RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
543cdf0e10cSrcweir 					RES_CHRATR_CJK_FONT,     RES_CHRATR_CJK_FONT,
544cdf0e10cSrcweir 					0, 0, 0  };
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 			SfxItemSet aSet( rWrtShell.GetAttrPool(), aRanges );
547cdf0e10cSrcweir             if (pNewUnitLanguage)
548cdf0e10cSrcweir 			{
549cdf0e10cSrcweir 				//DBG_ASSERT(!IsSimilarChinese( *pNewUnitLanguage, nOldLang ),
550cdf0e10cSrcweir 				//		"similar language should not be changed!");
551cdf0e10cSrcweir                 aSet.Put( SvxLanguageItem( *pNewUnitLanguage, RES_CHRATR_CJK_LANGUAGE ) );
552cdf0e10cSrcweir 			}
553cdf0e10cSrcweir 
554cdf0e10cSrcweir             const Font *pTargetFont = GetTargetFont();
555cdf0e10cSrcweir             DBG_ASSERT( pTargetFont, "target font missing?" );
556cdf0e10cSrcweir             if (pTargetFont && pNewUnitLanguage)
557cdf0e10cSrcweir             {
558cdf0e10cSrcweir                 SvxFontItem aFontItem = (SvxFontItem&) aSet.Get( RES_CHRATR_CJK_FONT );
559cdf0e10cSrcweir                 aFontItem.SetFamilyName(    pTargetFont->GetName());
560cdf0e10cSrcweir                 aFontItem.SetFamily(        pTargetFont->GetFamily());
561cdf0e10cSrcweir                 aFontItem.SetStyleName(     pTargetFont->GetStyleName());
562cdf0e10cSrcweir                 aFontItem.SetPitch(         pTargetFont->GetPitch());
563cdf0e10cSrcweir                 aFontItem.SetCharSet( pTargetFont->GetCharSet() );
564cdf0e10cSrcweir                 aSet.Put( aFontItem );
565cdf0e10cSrcweir             }
566cdf0e10cSrcweir 
567*69a74367SOliver-Rainer Wittmann 			rWrtShell.SetAttrSet( aSet );
568cdf0e10cSrcweir 
569cdf0e10cSrcweir 			rWrtShell.ClearMark();
570cdf0e10cSrcweir 		}
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 		rWrtShell.EndUndo( UNDO_OVERWRITE );
573cdf0e10cSrcweir     }
574cdf0e10cSrcweir 
575cdf0e10cSrcweir     rWrtShell.EndAllAction();
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 
HasRubySupport() const579cdf0e10cSrcweir sal_Bool SwHHCWrapper::HasRubySupport() const
580cdf0e10cSrcweir {
581cdf0e10cSrcweir     return sal_True;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir 
584cdf0e10cSrcweir 
Convert()585cdf0e10cSrcweir void SwHHCWrapper::Convert()
586cdf0e10cSrcweir {
587cdf0e10cSrcweir     DBG_ASSERT( pConvArgs == 0, "NULL pointer expected" );
588cdf0e10cSrcweir     {
589cdf0e10cSrcweir         SwPaM *pCrsr = pView->GetWrtShell().GetCrsr();
590cdf0e10cSrcweir         SwPosition* pSttPos = pCrsr->Start();
591cdf0e10cSrcweir         SwPosition* pEndPos = pCrsr->End();
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 		if (pSttPos->nNode.GetNode().IsTxtNode() &&
595cdf0e10cSrcweir 			pEndPos->nNode.GetNode().IsTxtNode())
596cdf0e10cSrcweir 		{
597cdf0e10cSrcweir 			pConvArgs = new SwConversionArgs( GetSourceLanguage(),
598cdf0e10cSrcweir                             pSttPos->nNode.GetNode().GetTxtNode(), pSttPos->nContent,
599cdf0e10cSrcweir                             pEndPos->nNode.GetNode().GetTxtNode(), pEndPos->nContent );
600cdf0e10cSrcweir 		}
601cdf0e10cSrcweir 		else	// we are not in the text (maybe a graphic or OLE object is selected) let's start from the top
602cdf0e10cSrcweir 		{
603cdf0e10cSrcweir 			// get PaM that points to the start of the document
604cdf0e10cSrcweir 			SwNode& rNode = pView->GetDocShell()->GetDoc()->GetNodes().GetEndOfContent();
605cdf0e10cSrcweir 			SwPaM aPam(rNode);
606cdf0e10cSrcweir 			aPam.Move( fnMoveBackward, fnGoDoc ); // move to start of document
607cdf0e10cSrcweir 
608cdf0e10cSrcweir             pSttPos = aPam.GetPoint();  //! using a PaM here makes sure we will get only text nodes
609cdf0e10cSrcweir 			SwTxtNode *pTxtNode = pSttPos->nNode.GetNode().GetTxtNode();
610cdf0e10cSrcweir             // just in case we check anyway...
611cdf0e10cSrcweir             if (!pTxtNode || !pTxtNode->IsTxtNode())
612cdf0e10cSrcweir                 return;
613cdf0e10cSrcweir 			pConvArgs = new SwConversionArgs( GetSourceLanguage(),
614cdf0e10cSrcweir                             pTxtNode, pSttPos->nContent,
615cdf0e10cSrcweir                             pTxtNode, pSttPos->nContent );
616cdf0e10cSrcweir 		}
617cdf0e10cSrcweir         DBG_ASSERT( pConvArgs->pStartNode && pConvArgs->pStartNode->IsTxtNode(),
618cdf0e10cSrcweir                 "failed to get proper start text node" );
619cdf0e10cSrcweir         DBG_ASSERT( pConvArgs->pEndNode && pConvArgs->pEndNode->IsTxtNode(),
620cdf0e10cSrcweir                 "failed to get proper end text node" );
621cdf0e10cSrcweir 
622cdf0e10cSrcweir         // chinese conversion specific settings
623cdf0e10cSrcweir         DBG_ASSERT( IsChinese( GetSourceLanguage() ) == IsChinese( GetTargetLanguage() ),
624cdf0e10cSrcweir                 "source and target language mismatch?" );
625cdf0e10cSrcweir         if (IsChinese( GetTargetLanguage() ))
626cdf0e10cSrcweir         {
627cdf0e10cSrcweir             pConvArgs->nConvTargetLang = GetTargetLanguage();
628cdf0e10cSrcweir             pConvArgs->pTargetFont = GetTargetFont();
629cdf0e10cSrcweir             pConvArgs->bAllowImplicitChangesForNotConvertibleText = sal_True;
630cdf0e10cSrcweir         }
631cdf0e10cSrcweir 
632cdf0e10cSrcweir         // if it is not just a selection and we are about to begin
633cdf0e10cSrcweir         // with the current conversion for the very first time
634cdf0e10cSrcweir         // we need to find the start of the current (initial)
635cdf0e10cSrcweir         // convertible unit in order for the text conversion to give
636cdf0e10cSrcweir         // the correct result for that. Since it is easier to obtain
637cdf0e10cSrcweir         // the start of the word we use that though.
638cdf0e10cSrcweir         if (!pCrsr->HasMark())   // is not a selection?
639cdf0e10cSrcweir         {
640cdf0e10cSrcweir 			// since #118246 / #117803 still occurs if the cursor is placed
641cdf0e10cSrcweir 			// between the two chinese characters to be converted (because both
642cdf0e10cSrcweir 			// of them are words on their own!) using the word boundary here does
643cdf0e10cSrcweir 			// not work. Thus since chinese conversion is not interactive we start
644cdf0e10cSrcweir 			// at the begin of the paragraph to solve the problem, i.e. have the
645cdf0e10cSrcweir 			// TextConversion service get those charcters together in the same call.
646cdf0e10cSrcweir 			xub_StrLen nStartIdx = STRING_MAXLEN;
647cdf0e10cSrcweir 			if (editeng::HangulHanjaConversion::IsChinese( GetSourceLanguage() ) )
648cdf0e10cSrcweir 				nStartIdx = 0;
649cdf0e10cSrcweir 			else
650cdf0e10cSrcweir 			{
651cdf0e10cSrcweir 				OUString aText( pConvArgs->pStartNode->GetTxt() );
652cdf0e10cSrcweir 				long     nPos = pConvArgs->pStartIdx->GetIndex();
653cdf0e10cSrcweir 				Boundary aBoundary( pBreakIt->GetBreakIter()->
654cdf0e10cSrcweir 						getWordBoundary( aText, nPos, pBreakIt->GetLocale( pConvArgs->nConvSrcLang ),
655cdf0e10cSrcweir 								WordType::DICTIONARY_WORD, sal_True ) );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 				// valid result found?
658cdf0e10cSrcweir 				if (aBoundary.startPos < aText.getLength() &&
659cdf0e10cSrcweir 					aBoundary.startPos != aBoundary.endPos)
660cdf0e10cSrcweir 				{
661cdf0e10cSrcweir 					nStartIdx = static_cast< xub_StrLen >(aBoundary.startPos );
662cdf0e10cSrcweir 				}
663cdf0e10cSrcweir 			}
664cdf0e10cSrcweir 
665cdf0e10cSrcweir 			if (STRING_MAXLEN != nStartIdx)
666cdf0e10cSrcweir                 *pConvArgs->pStartIdx = nStartIdx;
667cdf0e10cSrcweir 		}
668cdf0e10cSrcweir     }
669cdf0e10cSrcweir 
670cdf0e10cSrcweir     if ( bIsOtherCntnt )
671cdf0e10cSrcweir         ConvStart_impl( pConvArgs, SVX_SPELL_OTHER );
672cdf0e10cSrcweir     else
673cdf0e10cSrcweir     {
674cdf0e10cSrcweir         bStartChk = sal_False;
675cdf0e10cSrcweir         ConvStart_impl( pConvArgs,  SVX_SPELL_BODY_END );
676cdf0e10cSrcweir     }
677cdf0e10cSrcweir 
678cdf0e10cSrcweir     ConvertDocument();
679cdf0e10cSrcweir 
680cdf0e10cSrcweir     ConvEnd_impl( pConvArgs );
681cdf0e10cSrcweir }
682cdf0e10cSrcweir 
683cdf0e10cSrcweir 
ConvNext_impl()684cdf0e10cSrcweir sal_Bool SwHHCWrapper::ConvNext_impl( )
685cdf0e10cSrcweir {
686cdf0e10cSrcweir     //! modified version of SvxSpellWrapper::SpellNext
687cdf0e10cSrcweir 
688cdf0e10cSrcweir     // Keine Richtungsaenderung, also ist der gewuenschte Bereich ( bStartChk )
689cdf0e10cSrcweir     // vollstaendig abgearbeitet.
690cdf0e10cSrcweir     if( bStartChk )
691cdf0e10cSrcweir         bStartDone = sal_True;
692cdf0e10cSrcweir     else
693cdf0e10cSrcweir         bEndDone = sal_True;
694cdf0e10cSrcweir 
695cdf0e10cSrcweir     if( bIsOtherCntnt && bStartDone && bEndDone ) // Dokument komplett geprueft?
696cdf0e10cSrcweir     {
697cdf0e10cSrcweir         bInfoBox = sal_True;
698cdf0e10cSrcweir         return sal_False;
699cdf0e10cSrcweir     }
700cdf0e10cSrcweir 
701cdf0e10cSrcweir     //ResMgr* pMgr = DIALOG_MGR();
702cdf0e10cSrcweir     sal_Bool bGoOn = sal_False;
703cdf0e10cSrcweir 
704cdf0e10cSrcweir     if ( bIsOtherCntnt )
705cdf0e10cSrcweir     {
706cdf0e10cSrcweir         bStartChk = sal_False;
707cdf0e10cSrcweir         ConvStart_impl( pConvArgs, SVX_SPELL_BODY );
708cdf0e10cSrcweir         bGoOn = sal_True;
709cdf0e10cSrcweir     }
710cdf0e10cSrcweir     else if ( bStartDone && bEndDone )
711cdf0e10cSrcweir     {
712cdf0e10cSrcweir         // Bodybereich erledigt, Frage nach Sonderbereich
713cdf0e10cSrcweir         if( bIsConvSpecial && HasOtherCnt_impl() )
714cdf0e10cSrcweir         {
715cdf0e10cSrcweir             ConvStart_impl( pConvArgs, SVX_SPELL_OTHER );
716cdf0e10cSrcweir             bIsOtherCntnt = bGoOn = sal_True;
717cdf0e10cSrcweir         }
718cdf0e10cSrcweir         else
719cdf0e10cSrcweir             bInfoBox = sal_True;
720cdf0e10cSrcweir     }
721cdf0e10cSrcweir     else
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir         // Ein BODY_Bereich erledigt, Frage nach dem anderen BODY_Bereich
724cdf0e10cSrcweir /*
725cdf0e10cSrcweir         //pWin->LeaveWait();
726cdf0e10cSrcweir 
727cdf0e10cSrcweir         sal_uInt16 nResId = RID_SVXQB_CONTINUE;
728cdf0e10cSrcweir         QueryBox aBox( pWin, ResId( nResId, pMgr ) );
729cdf0e10cSrcweir         if ( aBox.Execute() != RET_YES )
730cdf0e10cSrcweir         {
731cdf0e10cSrcweir             // Verzicht auf den anderen Bereich, ggf. Frage nach Sonderbereich
732cdf0e10cSrcweir             //pWin->EnterWait();
733cdf0e10cSrcweir             bStartDone = bEndDone = sal_True;
734cdf0e10cSrcweir             return SpellNext();
735cdf0e10cSrcweir         }
736cdf0e10cSrcweir         else
737cdf0e10cSrcweir         {
738cdf0e10cSrcweir */
739cdf0e10cSrcweir             bStartChk = !bStartDone;
740cdf0e10cSrcweir             ConvStart_impl( pConvArgs, bStartChk ? SVX_SPELL_BODY_START : SVX_SPELL_BODY_END );
741cdf0e10cSrcweir             bGoOn = sal_True;
742cdf0e10cSrcweir /*
743cdf0e10cSrcweir         }
744cdf0e10cSrcweir         pWin->EnterWait();
745cdf0e10cSrcweir */
746cdf0e10cSrcweir     }
747cdf0e10cSrcweir     return bGoOn;
748cdf0e10cSrcweir }
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 
FindConvText_impl()751cdf0e10cSrcweir sal_Bool SwHHCWrapper::FindConvText_impl()
752cdf0e10cSrcweir {
753cdf0e10cSrcweir     //! modified version of SvxSpellWrapper::FindSpellError
754cdf0e10cSrcweir 
755cdf0e10cSrcweir     //ShowLanguageErrors();
756cdf0e10cSrcweir 
757cdf0e10cSrcweir     sal_Bool bFound = sal_False;
758cdf0e10cSrcweir 
759cdf0e10cSrcweir     pWin->EnterWait();
760cdf0e10cSrcweir     sal_Bool bConv = sal_True;
761cdf0e10cSrcweir 
762cdf0e10cSrcweir     while ( bConv )
763cdf0e10cSrcweir     {
764cdf0e10cSrcweir         bFound = ConvContinue_impl( pConvArgs );
765cdf0e10cSrcweir         if (bFound)
766cdf0e10cSrcweir         {
767cdf0e10cSrcweir             bConv = sal_False;
768cdf0e10cSrcweir         }
769cdf0e10cSrcweir         else
770cdf0e10cSrcweir         {
771cdf0e10cSrcweir             ConvEnd_impl( pConvArgs );
772cdf0e10cSrcweir             bConv = ConvNext_impl();
773cdf0e10cSrcweir         }
774cdf0e10cSrcweir     }
775cdf0e10cSrcweir     pWin->LeaveWait();
776cdf0e10cSrcweir     return bFound;
777cdf0e10cSrcweir }
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 
HasOtherCnt_impl()780cdf0e10cSrcweir sal_Bool SwHHCWrapper::HasOtherCnt_impl()
781cdf0e10cSrcweir {
782cdf0e10cSrcweir     return bIsSelection ? sal_False : rWrtShell.HasOtherCnt();
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir 
ConvStart_impl(SwConversionArgs * pConversionArgs,SvxSpellArea eArea)786cdf0e10cSrcweir void SwHHCWrapper::ConvStart_impl( SwConversionArgs /* [out] */ *pConversionArgs, SvxSpellArea eArea )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir     SetDrawObj( SVX_SPELL_OTHER == eArea );
789cdf0e10cSrcweir     pView->SpellStart( eArea, bStartDone, bEndDone, /* [out] */ pConversionArgs );
790cdf0e10cSrcweir }
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 
ConvEnd_impl(SwConversionArgs * pConversionArgs)793cdf0e10cSrcweir void SwHHCWrapper::ConvEnd_impl( SwConversionArgs *pConversionArgs )
794cdf0e10cSrcweir {
795cdf0e10cSrcweir     pView->SpellEnd( pConversionArgs );
796cdf0e10cSrcweir     //ShowLanguageErrors();
797cdf0e10cSrcweir }
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 
ConvContinue_impl(SwConversionArgs * pConversionArgs)800cdf0e10cSrcweir sal_Bool SwHHCWrapper::ConvContinue_impl( SwConversionArgs *pConversionArgs )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir     sal_Bool bProgress = !bIsDrawObj && !bIsSelection;
803cdf0e10cSrcweir //    bLastRet = aConvText.getLength() == 0;
804cdf0e10cSrcweir     pConversionArgs->aConvText = OUString();
805cdf0e10cSrcweir     pConversionArgs->nConvTextLang = LANGUAGE_NONE;
806cdf0e10cSrcweir     uno::Any  aRet = bProgress ?
807cdf0e10cSrcweir         pView->GetWrtShell().SpellContinue( &nPageCount, &nPageStart, pConversionArgs ) :
808cdf0e10cSrcweir         pView->GetWrtShell().SpellContinue( &nPageCount, NULL, pConversionArgs );
809cdf0e10cSrcweir     //aRet >>= aConvText;
810cdf0e10cSrcweir     return pConversionArgs->aConvText.getLength() != 0;
811cdf0e10cSrcweir }
812cdf0e10cSrcweir 
813cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
814cdf0e10cSrcweir 
815