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