LibreOffice Module sw (master)  1
hhcwrp.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <hintids.hxx>
21 #include <view.hxx>
22 #include <wrtsh.hxx>
23 #include <swundo.hxx>
24 #include <globals.hrc>
25 #include <splargs.hxx>
26 
27 #include <editeng/unolingu.hxx>
28 #include <editeng/langitem.hxx>
29 #include <editeng/fontitem.hxx>
30 #include <rtl/ustring.hxx>
31 #include <com/sun/star/text/RubyAdjust.hpp>
32 #include <com/sun/star/i18n/XBreakIterator.hpp>
33 #include <hhcwrp.hxx>
34 #include "sdrhhcwrap.hxx"
35 #include <doc.hxx>
36 #include <docsh.hxx>
37 #include <mdiexp.hxx>
38 #include <edtwin.hxx>
39 #include <index.hxx>
40 #include <pam.hxx>
41 #include <swcrsr.hxx>
42 #include <viscrs.hxx>
43 #include <ndtxt.hxx>
44 #include <fmtruby.hxx>
45 #include <breakit.hxx>
46 
47 #include <olmenu.hxx>
48 
49 #include <unomid.h>
50 
51 using namespace ::com::sun::star;
52 using namespace ::com::sun::star::text;
53 using namespace ::com::sun::star::uno;
54 using namespace ::com::sun::star::linguistic2;
55 using namespace ::com::sun::star::i18n;
56 
57 // Description: Turn off frame/object shell if applicable
58 
59 static void lcl_ActivateTextShell( SwWrtShell & rWrtSh )
60 {
61  if( rWrtSh.IsSelFrameMode() || rWrtSh.IsObjSelected() )
62  rWrtSh.EnterStdMode();
63 }
64 
66 {
67 public:
69  {
74  }
75 
77  {
79  }
80 };
81 
83  SwView* pSwView,
84  const uno::Reference< uno::XComponentContext >& rxContext,
85  LanguageType nSourceLanguage,
86  LanguageType nTargetLanguage,
87  const vcl::Font *pTargetFont,
88  sal_Int32 nConvOptions,
89  bool bIsInteractive,
90  bool bStart, bool bOther, bool bSelection )
91  : editeng::HangulHanjaConversion(pSwView->GetEditWin().GetFrameWeld(), rxContext,
92  LanguageTag::convertToLocale( nSourceLanguage ),
93  LanguageTag::convertToLocale( nTargetLanguage ),
94  pTargetFont,
95  nConvOptions,
96  bIsInteractive )
97  , m_pView( pSwView )
98  , m_pWin( &pSwView->GetEditWin() )
99  , m_rWrtShell( pSwView->GetWrtShell() )
100  , m_nLastPos( 0 )
101  , m_nUnitOffset( 0 )
102  , m_nPageCount( 0 )
103  , m_nPageStart( 0 )
104  , m_bIsDrawObj( false )
105  , m_bIsOtherContent( bOther )
106  , m_bStartChk( bOther )
107  , m_bIsSelection( bSelection )
108  , m_bStartDone( bOther || bStart )
109  , m_bEndDone( false )
110 {
111 }
112 
114 {
115  m_pConvArgs.reset();
116 
118 
119  // check for existence of a draw view which means that there are
120  // (or previously were) draw objects present in the document.
121  // I.e. we like to check those too.
122  if ( m_bIsDrawObj /*&& bLastRet*/ && m_pView->GetWrtShell().HasDrawView() )
123  {
124  vcl::Cursor *pSave = m_pView->GetWindow()->GetCursor();
125  {
127 
128  SdrHHCWrapper aSdrConvWrap( m_pView, GetSourceLanguage(),
131  aSdrConvWrap.StartTextConversion();
132  }
133  m_pView->GetWindow()->SetCursor( pSave );
134  }
135 
136  if( m_nPageCount )
138 
139  // finally for chinese translation we need to change the documents
140  // default language and font to the new ones to be used.
141  LanguageType nTargetLang = GetTargetLanguage();
142  if (IsChinese( nTargetLang ))
143  {
144  SwDoc *pDoc = m_pView->GetDocShell()->GetDoc();
145 
147  pDoc->SetDefault( SvxLanguageItem( nTargetLang, RES_CHRATR_CJK_LANGUAGE ) );
148 
149  const vcl::Font *pFont = GetTargetFont();
150  if (pFont)
151  {
152  SvxFontItem aFontItem( pFont->GetFamilyType(), pFont->GetFamilyName(),
153  pFont->GetStyleName(), pFont->GetPitch(),
154  pFont->GetCharSet(), RES_CHRATR_CJK_FONT );
155  pDoc->SetDefault( aFontItem );
156  }
157 
158  }
159 }
160 
162  OUString& rNextPortion,
163  LanguageType& rLangOfPortion,
164  bool bAllowChanges )
165 {
166  m_pConvArgs->bAllowImplicitChangesForNotConvertibleText = bAllowChanges;
167 
169  rNextPortion = m_pConvArgs->aConvText;
170  rLangOfPortion = m_pConvArgs->nConvTextLang;
171 
172  m_nUnitOffset = 0;
173 
174  // build last pos from currently selected text
175  SwPaM* pCursor = m_rWrtShell.GetCursor();
176  m_nLastPos = pCursor->Start()->nContent.GetIndex();
177 }
178 
179 void SwHHCWrapper::SelectNewUnit_impl( sal_Int32 nUnitStart, sal_Int32 nUnitEnd )
180 {
181  SwPaM *pCursor = m_rWrtShell.GetCursor();
182  pCursor->GetPoint()->nContent = m_nLastPos;
183  pCursor->DeleteMark();
184 
185  m_rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ false,
186  static_cast<sal_uInt16>(m_nUnitOffset + nUnitStart), true );
187  pCursor->SetMark();
188  m_rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ true,
189  static_cast<sal_uInt16>(nUnitEnd - nUnitStart), true );
190  // end selection now. Otherwise SHIFT+HOME (extending the selection)
191  // won't work when the dialog is closed without any replacement.
192  // (see #116346#)
194 }
195 
197  const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd )
198 {
199  OSL_ENSURE( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
200  if (!(0 <= nUnitStart && nUnitStart <= nUnitEnd))
201  return;
202 
204 
206 
207  // select current unit
208  SelectNewUnit_impl( nUnitStart, nUnitEnd );
209 
211 }
212 
213 void SwHHCWrapper::ChangeText( const OUString &rNewText,
214  const OUString& rOrigText,
215  const uno::Sequence< sal_Int32 > *pOffsets,
216  SwPaM *pCursor )
217 {
220 
221  OSL_ENSURE( !rNewText.isEmpty(), "unexpected empty string" );
222  if (rNewText.isEmpty())
223  return;
224 
225  if (pOffsets && pCursor) // try to keep as much attributation as possible ?
226  {
227  // remember cursor start position for later setting of the cursor
228  const SwPosition *pStart = pCursor->Start();
229  const sal_Int32 nStartIndex = pStart->nContent.GetIndex();
230  const SwNodeIndex aStartNodeIndex = pStart->nNode;
231  SwTextNode *pStartTextNode = aStartNodeIndex.GetNode().GetTextNode();
232 
233  const sal_Int32 nIndices = pOffsets->getLength();
234  const sal_Int32 *pIndices = pOffsets->getConstArray();
235  sal_Int32 nConvTextLen = rNewText.getLength();
236  sal_Int32 nPos = 0;
237  sal_Int32 nChgPos = -1;
238  sal_Int32 nChgLen = 0;
239  sal_Int32 nConvChgPos = -1;
240  sal_Int32 nConvChgLen = 0;
241 
242  // offset to calculate the position in the text taking into
243  // account that text may have been replaced with new text of
244  // different length. Negative values allowed!
245  long nCorrectionOffset = 0;
246 
247  OSL_ENSURE(nIndices == 0 || nIndices == nConvTextLen,
248  "mismatch between string length and sequence length!" );
249 
250  // find all substrings that need to be replaced (and only those)
251  while (true)
252  {
253  // get index in original text that matches nPos in new text
254  sal_Int32 nIndex;
255  if (nPos < nConvTextLen)
256  nIndex = nPos < nIndices ? pIndices[nPos] : nPos;
257  else
258  {
259  nPos = nConvTextLen;
260  nIndex = rOrigText.getLength();
261  }
262 
263  if (nPos == nConvTextLen || /* end of string also terminates non-matching char sequence */
264  rOrigText[nIndex] == rNewText[nPos])
265  {
266  // substring that needs to be replaced found?
267  if (nChgPos != -1 && nConvChgPos != -1)
268  {
269  nChgLen = nIndex - nChgPos;
270  nConvChgLen = nPos - nConvChgPos;
271  OUString aInNew( rNewText.copy( nConvChgPos, nConvChgLen ) );
272 
273  // set selection to sub string to be replaced in original text
274  sal_Int32 nChgInNodeStartIndex = nStartIndex + nCorrectionOffset + nChgPos;
275  OSL_ENSURE( m_rWrtShell.GetCursor()->HasMark(), "cursor misplaced (nothing selected)" );
276  m_rWrtShell.GetCursor()->GetMark()->nContent.Assign( pStartTextNode, nChgInNodeStartIndex );
277  m_rWrtShell.GetCursor()->GetPoint()->nContent.Assign( pStartTextNode, nChgInNodeStartIndex + nChgLen );
278 
279  // replace selected sub string with the corresponding
280  // sub string from the new text while keeping as
281  // much from the attributes as possible
282  ChangeText_impl( aInNew, true );
283 
284  nCorrectionOffset += nConvChgLen - nChgLen;
285 
286  nChgPos = -1;
287  nConvChgPos = -1;
288  }
289  }
290  else
291  {
292  // begin of non-matching char sequence found ?
293  if (nChgPos == -1 && nConvChgPos == -1)
294  {
295  nChgPos = nIndex;
296  nConvChgPos = nPos;
297  }
298  }
299  if (nPos >= nConvTextLen)
300  break;
301  ++nPos;
302  }
303 
304  // set cursor to the end of all the new text
305  // (as it would happen after ChangeText_impl (Delete and Insert)
306  // of the whole text in the 'else' branch below)
308  m_rWrtShell.GetCursor()->Start()->nContent.Assign( pStartTextNode, nStartIndex + nConvTextLen );
309  }
310  else
311  {
312  ChangeText_impl( rNewText, false );
313  }
314 }
315 
316 void SwHHCWrapper::ChangeText_impl( const OUString &rNewText, bool bKeepAttributes )
317 {
318  if (bKeepAttributes)
319  {
320  // get item set with all relevant attributes
321  sal_uInt16 const aRanges[] {
323  0, 0, 0 };
324  SfxItemSet aItemSet( m_rWrtShell.GetAttrPool(), aRanges );
325  // get all attributes spanning the whole selection in order to
326  // restore those for the new text
327  m_rWrtShell.GetCurAttr( aItemSet );
328 
330  m_rWrtShell.Insert( rNewText );
331 
332  // select new inserted text (currently the Point is right after the new text)
333  if (!m_rWrtShell.GetCursor()->HasMark())
335  SwPosition *pMark = m_rWrtShell.GetCursor()->GetMark();
336  pMark->nContent = pMark->nContent.GetIndex() - rNewText.getLength();
337 
338  // since 'SetAttr' below functions like merging with the attributes
339  // from the itemset with any existing ones we have to get rid of all
340  // all attributes now. (Those attributes that may take effect left
341  // to the position where the new text gets inserted after the old text
342  // was deleted)
344  // apply previously saved attributes to new text
345  m_rWrtShell.SetAttrSet( aItemSet );
346  }
347  else
348  {
350  m_rWrtShell.Insert( rNewText );
351  }
352 }
353 
355  const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd,
356  const OUString& rOrigText,
357  const OUString& rReplaceWith,
358  const uno::Sequence< sal_Int32 > &rOffsets,
359  ReplacementAction eAction,
360  LanguageType *pNewUnitLanguage )
361 {
362  OSL_ENSURE( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
363  if (!(nUnitStart >= 0 && nUnitEnd >= nUnitStart))
364  return;
365 
367 
368  // replace the current word
370 
371  // select current unit
372  SelectNewUnit_impl( nUnitStart, nUnitEnd );
373 
374  OUString aOrigText( m_rWrtShell.GetSelText() );
375  OUString aNewText( rReplaceWith );
376  OSL_ENSURE( aOrigText == rOrigText, "!! text mismatch !!" );
377  std::unique_ptr<SwFormatRuby> pRuby;
378  bool bRubyBelow = false;
379  OUString aNewOrigText;
380  switch (eAction)
381  {
382  case eExchange :
383  break;
384  case eReplacementBracketed :
385  {
386  aNewText = aOrigText + "(" + rReplaceWith + ")";
387  }
388  break;
389  case eOriginalBracketed :
390  {
391  aNewText = rReplaceWith + "(" + aOrigText + ")";
392  }
393  break;
394  case eReplacementAbove :
395  {
396  pRuby.reset(new SwFormatRuby( rReplaceWith ));
397  }
398  break;
399  case eOriginalAbove :
400  {
401  pRuby.reset(new SwFormatRuby( aOrigText ));
402  aNewOrigText = rReplaceWith;
403  }
404  break;
405  case eReplacementBelow :
406  {
407  pRuby.reset(new SwFormatRuby( rReplaceWith ));
408  bRubyBelow = true;
409  }
410  break;
411  case eOriginalBelow :
412  {
413  pRuby.reset(new SwFormatRuby( aOrigText ));
414  aNewOrigText = rReplaceWith;
415  bRubyBelow = true;
416  }
417  break;
418  default:
419  OSL_FAIL("unexpected case" );
420  }
421  m_nUnitOffset += nUnitStart + aNewText.getLength();
422 
423  if (pRuby)
424  {
426  if (!aNewOrigText.isEmpty())
427  {
428  // according to FT we currently should not bother about keeping
429  // attributes in Hangul/Hanja conversion
430  ChangeText( aNewOrigText, rOrigText, nullptr, nullptr );
431 
436  // We didn't fix it in Delete and Insert since it is currently
437  // unclear if someone depends on this incorrect behaviour
438  // of the flag.
440 
441  m_rWrtShell.Left( 0, true, aNewOrigText.getLength(), true, true );
442  }
443 
444  pRuby->SetPosition( static_cast<sal_uInt16>(bRubyBelow) );
445  pRuby->SetAdjustment( RubyAdjust_CENTER );
446 
447  m_rWrtShell.SetAttrItem(*pRuby);
448  pRuby.reset();
450  }
451  else
452  {
454 
455  // according to FT we should currently not bother about keeping
456  // attributes in Hangul/Hanja conversion and leave that untouched.
457  // Thus we do this only for Chinese translation...
458  const bool bIsChineseConversion = IsChinese( GetSourceLanguage() );
459  if (bIsChineseConversion)
460  ChangeText( aNewText, rOrigText, &rOffsets, m_rWrtShell.GetCursor() );
461  else
462  ChangeText( aNewText, rOrigText, nullptr, nullptr );
463 
464  // change language and font if necessary
465  if (bIsChineseConversion)
466  {
468  m_rWrtShell.GetCursor()->GetMark()->nContent -= aNewText.getLength();
469 
471  "SwHHCWrapper::ReplaceUnit : unexpected target language" );
472 
473  sal_uInt16 const aRanges[] {
476  0, 0, 0 };
477 
478  SfxItemSet aSet( m_rWrtShell.GetAttrPool(), aRanges );
479  if (pNewUnitLanguage)
480  {
481  aSet.Put( SvxLanguageItem( *pNewUnitLanguage, RES_CHRATR_CJK_LANGUAGE ) );
482  }
483 
484  const vcl::Font *pTargetFont = GetTargetFont();
485  OSL_ENSURE( pTargetFont, "target font missing?" );
486  if (pTargetFont && pNewUnitLanguage)
487  {
488  SvxFontItem aFontItem( aSet.Get( RES_CHRATR_CJK_FONT ) );
489  aFontItem.SetFamilyName( pTargetFont->GetFamilyName());
490  aFontItem.SetFamily( pTargetFont->GetFamilyType());
491  aFontItem.SetStyleName( pTargetFont->GetStyleName());
492  aFontItem.SetPitch( pTargetFont->GetPitch());
493  aFontItem.SetCharSet( pTargetFont->GetCharSet() );
494  aSet.Put( aFontItem );
495  }
496 
497  m_rWrtShell.SetAttrSet( aSet );
498 
500  }
501 
503  }
504 
506 }
507 
509 {
510  return true;
511 }
512 
514 {
515  OSL_ENSURE( m_pConvArgs == nullptr, "NULL pointer expected" );
516  {
517  SwPaM *pCursor = m_pView->GetWrtShell().GetCursor();
518  SwPosition* pSttPos = pCursor->Start();
519  SwPosition* pEndPos = pCursor->End();
520 
521  if (pSttPos->nNode.GetNode().IsTextNode() &&
522  pEndPos->nNode.GetNode().IsTextNode())
523  {
525  pSttPos->nNode.GetNode().GetTextNode(), pSttPos->nContent,
526  pEndPos->nNode.GetNode().GetTextNode(), pEndPos->nContent ) );
527  }
528  else // we are not in the text (maybe a graphic or OLE object is selected) let's start from the top
529  {
530  // get PaM that points to the start of the document
532  SwPaM aPam(rNode);
533  aPam.Move( fnMoveBackward, GoInDoc ); // move to start of document
534 
535  pSttPos = aPam.GetPoint();
536  SwTextNode *pTextNode = pSttPos->nNode.GetNode().GetTextNode();
537  // just in case we check anyway...
538  if (!pTextNode || !pTextNode->IsTextNode())
539  return;
541  pTextNode, pSttPos->nContent,
542  pTextNode, pSttPos->nContent ) );
543  }
544  OSL_ENSURE( m_pConvArgs->pStartNode && m_pConvArgs->pStartNode->IsTextNode(),
545  "failed to get proper start text node" );
546  OSL_ENSURE( m_pConvArgs->pEndNode && m_pConvArgs->pEndNode->IsTextNode(),
547  "failed to get proper end text node" );
548 
549  // chinese conversion specific settings
550  OSL_ENSURE( IsChinese( GetSourceLanguage() ) == IsChinese( GetTargetLanguage() ),
551  "source and target language mismatch?" );
552  if (IsChinese( GetTargetLanguage() ))
553  {
554  m_pConvArgs->nConvTargetLang = GetTargetLanguage();
555  m_pConvArgs->pTargetFont = GetTargetFont();
556  m_pConvArgs->bAllowImplicitChangesForNotConvertibleText = true;
557  }
558 
559  // if it is not just a selection and we are about to begin
560  // with the current conversion for the very first time
561  // we need to find the start of the current (initial)
562  // convertible unit in order for the text conversion to give
563  // the correct result for that. Since it is easier to obtain
564  // the start of the word we use that though.
565  if (!pCursor->HasMark()) // is not a selection?
566  {
567  // since #118246 / #117803 still occurs if the cursor is placed
568  // between the two chinese characters to be converted (because both
569  // of them are words on their own!) using the word boundary here does
570  // not work. Thus since chinese conversion is not interactive we start
571  // at the begin of the paragraph to solve the problem, i.e. have the
572  // TextConversion service get those characters together in the same call.
573  sal_Int32 nStartIdx = -1;
575  nStartIdx = 0;
576  else
577  {
578  OUString aText( m_pConvArgs->pStartNode->GetText() );
579  const sal_Int32 nPos = m_pConvArgs->pStartIdx->GetIndex();
580  Boundary aBoundary( g_pBreakIt->GetBreakIter()->
581  getWordBoundary( aText, nPos, g_pBreakIt->GetLocale( m_pConvArgs->nConvSrcLang ),
582  WordType::DICTIONARY_WORD, true ) );
583 
584  // valid result found?
585  if (aBoundary.startPos < aText.getLength() &&
586  aBoundary.startPos != aBoundary.endPos)
587  {
588  nStartIdx = aBoundary.startPos;
589  }
590  }
591 
592  if (nStartIdx != -1)
593  *m_pConvArgs->pStartIdx = nStartIdx;
594  }
595  }
596 
597  if ( m_bIsOtherContent )
598  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Other );
599  else
600  {
601  m_bStartChk = false;
602  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::BodyEnd );
603  }
604 
605  ConvertDocument();
606 
607  ConvEnd_impl( m_pConvArgs.get() );
608 }
609 
611 {
613 
614  // no change of direction so the desired region is fully processed
615  if( m_bStartChk )
616  m_bStartDone = true;
617  else
618  m_bEndDone = true;
619 
620  if( m_bIsOtherContent && m_bStartDone && m_bEndDone ) // document completely checked?
621  {
622  return false;
623  }
624 
625  bool bGoOn = false;
626 
627  if ( m_bIsOtherContent )
628  {
629  m_bStartChk = false;
630  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Body );
631  bGoOn = true;
632  }
633  else if ( m_bStartDone && m_bEndDone )
634  {
635  // body region done, ask about special region
637  {
638  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Other );
639  m_bIsOtherContent = bGoOn = true;
640  }
641  }
642  else
643  {
645  ConvStart_impl( m_pConvArgs.get(), m_bStartChk ? SvxSpellArea::BodyStart : SvxSpellArea::BodyEnd );
646  bGoOn = true;
647  }
648  return bGoOn;
649 }
650 
652 {
654 
655  bool bFound = false;
656 
657  m_pWin->EnterWait();
658  bool bConv = true;
659 
660  while ( bConv )
661  {
662  bFound = ConvContinue_impl( m_pConvArgs.get() );
663  if (bFound)
664  {
665  bConv = false;
666  }
667  else
668  {
669  ConvEnd_impl( m_pConvArgs.get() );
670  bConv = ConvNext_impl();
671  }
672  }
673  m_pWin->LeaveWait();
674 }
675 
676 void SwHHCWrapper::ConvStart_impl( SwConversionArgs /* [out] */ *pConversionArgs, SvxSpellArea eArea )
677 {
678  m_bIsDrawObj = SvxSpellArea::Other == eArea;
679  m_pView->SpellStart( eArea, m_bStartDone, m_bEndDone, /* [out] */ pConversionArgs );
680 }
681 
682 void SwHHCWrapper::ConvEnd_impl( SwConversionArgs const *pConversionArgs )
683 {
684  m_pView->SpellEnd( pConversionArgs );
685 }
686 
688 {
689  bool bProgress = !m_bIsDrawObj && !m_bIsSelection;
690  pConversionArgs->aConvText.clear();
691  pConversionArgs->nConvTextLang = LANGUAGE_NONE;
692  m_pView->GetWrtShell().SpellContinue( &m_nPageCount, bProgress ? &m_nPageStart : nullptr, pConversionArgs );
693  return !pConversionArgs->aConvText.isEmpty();
694 }
695 
696 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ChangeText_impl(const OUString &rNewText, bool bKeepAttributes)
Definition: hhcwrp.cxx:316
#define LANGUAGE_NONE
void DeleteMark()
Definition: pam.hxx:177
bool Right(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:119
SwWrtShell & m_rWrtShell
Definition: hhcwrp.hxx:34
bool const m_bIsSelection
true if only the selected text should be converted
Definition: hhcwrp.hxx:50
Marks a position in the document model.
Definition: pam.hxx:35
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:92
const OUString & GetFamilyName() const
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:185
const OUString & GetStyleName() const
SwNodeIndex nNode
Definition: pam.hxx:37
void Insert(SwField const &)
Definition: wrtsh2.cxx:71
SAL_DLLPRIVATE void SpellStart(SvxSpellArea eSpell, bool bStartDone, bool bEndDone, SwConversionArgs *pConvArgs)
Definition: viewling.cxx:274
void EnterWait()
const SwPosition * GetMark() const
Definition: pam.hxx:209
void SetAttrSet(const SfxItemSet &, SetAttrMode nFlags=SetAttrMode::DEFAULT, SwPaM *pCursor=nullptr, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:152
#define RES_FRMATR_END
Definition: hintids.hxx:236
Definition: doc.hxx:185
bool HasDrawView() const
Definition: vnew.cxx:361
void ConvEnd_impl(SwConversionArgs const *pConvArgs)
former SpellEnd
Definition: hhcwrp.cxx:682
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:233
SwNode & GetNode() const
Definition: ndindex.hxx:118
void EnterStdMode()
Definition: select.cxx:552
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:88
#define RES_CHRATR_CJK_FONT
Definition: hintids.hxx:90
void EndAllAction()
Definition: edws.cxx:96
FontFamily GetFamilyType()
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
void SetFamilyName(const OUString &rFamilyName)
Used by the UI to modify the document model.
Definition: wrtsh.hxx:86
SwIndex nContent
Definition: pam.hxx:38
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:34
sal_Int32 m_nLastPos
starting position of the last found text part (needs to be sth that gets not moved like SwPaM or SwPo...
Definition: hhcwrp.hxx:39
SwHHCWrapper(SwView *pView, const css::uno::Reference< css::uno::XComponentContext > &rxContext, LanguageType nSourceLanguage, LanguageType nTargetLanguage, const vcl::Font *pTargetFont, sal_Int32 nConvOptions, bool bIsInteractive, bool bStart, bool bOther, bool bSelection)
Definition: hhcwrp.cxx:82
virtual void GetNextPortion(OUString &rNextPortion, LanguageType &rLangOfPortion, bool bAllowImplicitChangesForNotConvertibleText) override
Definition: hhcwrp.cxx:161
bool ConvNext_impl()
from SvxSpellWrapper copied and modified
Definition: hhcwrp.cxx:610
static void lcl_ActivateTextShell(SwWrtShell &rWrtSh)
Definition: hhcwrp.cxx:59
bool m_bStartDone
Definition: hhcwrp.hxx:51
void FindConvText_impl()
former FindSpellError
Definition: hhcwrp.cxx:651
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:164
LanguageType GetSourceLanguage() const
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:202
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
void EndSelect()
Definition: select.cxx:426
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:483
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:614
LanguageType nConvTextLang
Definition: splargs.hxx:66
bool HasOtherCnt() const
Are there frames, footnotes, etc.
Definition: edws.cxx:143
virtual bool HasRubySupport() const override
Definition: hhcwrp.cxx:508
FontPitch GetPitch()
SwView * m_pView
Definition: hhcwrp.hxx:32
sal_uInt16 m_nPageStart
first checked page
Definition: hhcwrp.hxx:45
void SelectNewUnit_impl(const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd)
Definition: hhcwrp.cxx:179
const SwPosition * GetPoint() const
Definition: pam.hxx:207
sal_Int32 m_nUnitOffset
Definition: hhcwrp.hxx:42
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
void SetAttrItem(const SfxPoolItem &, SetAttrMode nFlags=SetAttrMode::DEFAULT, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:113
static bool IsChinese(LanguageType nLang)
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:222
sal_Int32 GetConversionOptions() const
css::uno::Any SpellContinue(sal_uInt16 *pPageCnt, sal_uInt16 *pPageSt, SwConversionArgs const *pConvArgs)
Definition: edlingu.cxx:672
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:68
weld::Window * GetFrameWeld(SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
const vcl::Font * GetTargetFont() const
VclPtr< vcl::Window > m_pWin
Definition: hhcwrp.hxx:33
#define LANGUAGE_CHINESE_SIMPLIFIED
void SetMark()
Definition: crsrsh.hxx:871
vcl::Cursor * GetCursor() const
bool m_bEndDone
Definition: hhcwrp.hxx:52
Marks a node in the document model.
Definition: ndindex.hxx:31
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:882
void ConvStart_impl(SwConversionArgs *pConvArgs, SvxSpellArea eSpell)
former SpellStart
Definition: hhcwrp.cxx:676
bool m_bStartChk
Definition: hhcwrp.hxx:49
bool m_bIsDrawObj
Definition: hhcwrp.hxx:47
const SwPosition * Start() const
Definition: pam.hxx:212
SwDocShell * GetDocShell()
Definition: view.cxx:1115
bool Delete()
Delete content of all ranges.
Definition: eddel.cxx:117
void StartTextConversion()
Definition: sdrhhcwrap.cxx:102
void Convert()
Definition: hhcwrp.cxx:513
virtual void HandleNewUnit(const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd) override
Definition: hhcwrp.cxx:196
OUString aConvText
Definition: splargs.hxx:64
const css::lang::Locale & GetLocale(const LanguageType aLang)
Definition: breakit.hxx:67
void SetDefault(const SfxPoolItem &)
Set attribute as new default attribute in current document.
Definition: docfmt.cxx:554
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
static void SetCareDialog(const std::shared_ptr< weld::Window > &rNew)
Definition: viewsh.cxx:2495
bool Left(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:102
SvxSpellArea
void SetCursor(vcl::Cursor *pCursor)
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2429
sal_Int32 GetIndex() const
Definition: index.hxx:95
LanguageType GetTargetLanguage() const
SwNodes & GetNodes()
Definition: doc.hxx:403
const SwPosition * End() const
Definition: pam.hxx:217
size_t IsObjSelected() const
Definition: feshview.cxx:1167
virtual ~SwHHCWrapper() override
Definition: hhcwrp.cxx:113
sal_uInt16 m_nPageCount
page count for progress bar
Definition: hhcwrp.hxx:44
vcl::Window * GetWindow() const
void ChangeText(const OUString &rNewText, const OUString &rOrigText, const css::uno::Sequence< sal_Int32 > *pOffsets, SwPaM *pCursor)
Definition: hhcwrp.cxx:213
bool m_bIsOtherContent
Definition: hhcwrp.hxx:48
void ClearMark()
Definition: crsrsh.cxx:927
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:181
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter()
Definition: breakit.hxx:62
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
#define LANGUAGE_CHINESE_TRADITIONAL
bool ConvContinue_impl(SwConversionArgs *pConvArgs)
former SpellContinue
Definition: hhcwrp.cxx:687
SAL_DLLPRIVATE void SpellEnd(SwConversionArgs const *pConvArgs)
Definition: viewling.cxx:380
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:457
void ResetAttr(const std::set< sal_uInt16 > &attrs=std::set< sal_uInt16 >(), SwPaM *pCursor=nullptr)
Definition: edatmisc.cxx:33
void LeaveWait()
std::unique_ptr< SwConversionArgs > m_pConvArgs
object for arguments (and results) needed to find of next convertible text portion ...
Definition: hhcwrp.hxx:36
virtual void ReplaceUnit(const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd, const OUString &rOrigText, const OUString &rReplaceWith, const css::uno::Sequence< sal_Int32 > &rOffsets, ReplacementAction eAction, LanguageType *pNewUnitLanguage) override
Definition: hhcwrp.cxx:354
void StartAllAction()
For all views of this document.
Definition: edws.cxx:85
sal_Int32 nPos
bool IsTextNode() const
Definition: node.hxx:636
static void SetUseSavedConversionDirectionState(bool bVal)
rtl_TextEncoding GetCharSet() const
Definition: view.hxx:146
bool IsSelFrameMode() const
Definition: wrtsh.hxx:166
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
Base class of the Writer document model elements.
Definition: node.hxx:79