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
317  static const WhichRangesContainer aRanges(svl::Items<
319  >);
320  SfxItemSet aItemSet( m_rWrtShell.GetAttrPool(), aRanges );
321  // get all attributes spanning the whole selection in order to
322  // restore those for the new text
323  m_rWrtShell.GetCurAttr( aItemSet );
324 
326  m_rWrtShell.Insert( rNewText );
327 
328  // select new inserted text (currently the Point is right after the new text)
329  if (!m_rWrtShell.GetCursor()->HasMark())
331  SwPosition *pMark = m_rWrtShell.GetCursor()->GetMark();
332  pMark->nContent = pMark->nContent.GetIndex() - rNewText.getLength();
333 
334  // since 'SetAttr' below functions like merging with the attributes
335  // from the itemset with any existing ones we have to get rid of all
336  // all attributes now. (Those attributes that may take effect left
337  // to the position where the new text gets inserted after the old text
338  // was deleted)
340  // apply previously saved attributes to new text
341  m_rWrtShell.SetAttrSet( aItemSet );
342  }
343  else
344  {
346  m_rWrtShell.Insert( rNewText );
347  }
348 }
349 
351  const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd,
352  const OUString& rOrigText,
353  const OUString& rReplaceWith,
354  const uno::Sequence< sal_Int32 > &rOffsets,
355  ReplacementAction eAction,
356  LanguageType *pNewUnitLanguage )
357 {
358  OSL_ENSURE( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
359  if (nUnitStart < 0 || nUnitEnd < nUnitStart)
360  return;
361 
363 
364  // replace the current word
366 
367  // select current unit
368  SelectNewUnit_impl( nUnitStart, nUnitEnd );
369 
370  OUString aOrigText( m_rWrtShell.GetSelText() );
371  OUString aNewText( rReplaceWith );
372  OSL_ENSURE( aOrigText == rOrigText, "!! text mismatch !!" );
373  std::unique_ptr<SwFormatRuby> pRuby;
374  bool bRubyBelow = false;
375  OUString aNewOrigText;
376  switch (eAction)
377  {
378  case eExchange :
379  break;
380  case eReplacementBracketed :
381  {
382  aNewText = aOrigText + "(" + rReplaceWith + ")";
383  }
384  break;
385  case eOriginalBracketed :
386  {
387  aNewText = rReplaceWith + "(" + aOrigText + ")";
388  }
389  break;
390  case eReplacementAbove :
391  {
392  pRuby.reset(new SwFormatRuby( rReplaceWith ));
393  }
394  break;
395  case eOriginalAbove :
396  {
397  pRuby.reset(new SwFormatRuby( aOrigText ));
398  aNewOrigText = rReplaceWith;
399  }
400  break;
401  case eReplacementBelow :
402  {
403  pRuby.reset(new SwFormatRuby( rReplaceWith ));
404  bRubyBelow = true;
405  }
406  break;
407  case eOriginalBelow :
408  {
409  pRuby.reset(new SwFormatRuby( aOrigText ));
410  aNewOrigText = rReplaceWith;
411  bRubyBelow = true;
412  }
413  break;
414  default:
415  OSL_FAIL("unexpected case" );
416  }
417  m_nUnitOffset += nUnitStart + aNewText.getLength();
418 
419  if (pRuby)
420  {
422  if (!aNewOrigText.isEmpty())
423  {
424  // according to FT we currently should not bother about keeping
425  // attributes in Hangul/Hanja conversion
426  ChangeText( aNewOrigText, rOrigText, nullptr, nullptr );
427 
432  // We didn't fix it in Delete and Insert since it is currently
433  // unclear if someone depends on this incorrect behaviour
434  // of the flag.
436 
437  m_rWrtShell.Left( 0, true, aNewOrigText.getLength(), true, true );
438  }
439 
440  pRuby->SetPosition( o3tl::narrowing<sal_uInt16>(bRubyBelow) );
441  pRuby->SetAdjustment( RubyAdjust_CENTER );
442 
443  m_rWrtShell.SetAttrItem(*pRuby);
444  pRuby.reset();
446  }
447  else
448  {
450 
451  // according to FT we should currently not bother about keeping
452  // attributes in Hangul/Hanja conversion and leave that untouched.
453  // Thus we do this only for Chinese translation...
454  const bool bIsChineseConversion = IsChinese( GetSourceLanguage() );
455  if (bIsChineseConversion)
456  ChangeText( aNewText, rOrigText, &rOffsets, m_rWrtShell.GetCursor() );
457  else
458  ChangeText( aNewText, rOrigText, nullptr, nullptr );
459 
460  // change language and font if necessary
461  if (bIsChineseConversion)
462  {
464  m_rWrtShell.GetCursor()->GetMark()->nContent -= aNewText.getLength();
465 
467  "SwHHCWrapper::ReplaceUnit : unexpected target language" );
468 
471  RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE> );
472  if (pNewUnitLanguage)
473  {
474  aSet.Put( SvxLanguageItem( *pNewUnitLanguage, RES_CHRATR_CJK_LANGUAGE ) );
475  }
476 
477  const vcl::Font *pTargetFont = GetTargetFont();
478  OSL_ENSURE( pTargetFont, "target font missing?" );
479  if (pTargetFont && pNewUnitLanguage)
480  {
481  SvxFontItem aFontItem( aSet.Get( RES_CHRATR_CJK_FONT ) );
482  aFontItem.SetFamilyName( pTargetFont->GetFamilyName());
483  aFontItem.SetFamily( pTargetFont->GetFamilyType());
484  aFontItem.SetStyleName( pTargetFont->GetStyleName());
485  aFontItem.SetPitch( pTargetFont->GetPitch());
486  aFontItem.SetCharSet( pTargetFont->GetCharSet() );
487  aSet.Put( aFontItem );
488  }
489 
490  m_rWrtShell.SetAttrSet( aSet );
491 
493  }
494 
496  }
497 
499 }
500 
502 {
503  return true;
504 }
505 
507 {
508  OSL_ENSURE( m_pConvArgs == nullptr, "NULL pointer expected" );
509  {
510  SwPaM *pCursor = m_pView->GetWrtShell().GetCursor();
511  SwPosition* pSttPos = pCursor->Start();
512  SwPosition* pEndPos = pCursor->End();
513 
514  if (pSttPos->nNode.GetNode().IsTextNode() &&
515  pEndPos->nNode.GetNode().IsTextNode())
516  {
518  pSttPos->nNode.GetNode().GetTextNode(), pSttPos->nContent,
519  pEndPos->nNode.GetNode().GetTextNode(), pEndPos->nContent ) );
520  }
521  else // we are not in the text (maybe a graphic or OLE object is selected) let's start from the top
522  {
523  // get PaM that points to the start of the document
525  SwPaM aPam(rNode);
526  aPam.Move( fnMoveBackward, GoInDoc ); // move to start of document
527 
528  pSttPos = aPam.GetPoint();
529  SwTextNode *pTextNode = pSttPos->nNode.GetNode().GetTextNode();
530  // just in case we check anyway...
531  if (!pTextNode || !pTextNode->IsTextNode())
532  return;
534  pTextNode, pSttPos->nContent,
535  pTextNode, pSttPos->nContent ) );
536  }
537  OSL_ENSURE( m_pConvArgs->pStartNode && m_pConvArgs->pStartNode->IsTextNode(),
538  "failed to get proper start text node" );
539  OSL_ENSURE( m_pConvArgs->pEndNode && m_pConvArgs->pEndNode->IsTextNode(),
540  "failed to get proper end text node" );
541 
542  // chinese conversion specific settings
543  OSL_ENSURE( IsChinese( GetSourceLanguage() ) == IsChinese( GetTargetLanguage() ),
544  "source and target language mismatch?" );
545  if (IsChinese( GetTargetLanguage() ))
546  {
547  m_pConvArgs->nConvTargetLang = GetTargetLanguage();
548  m_pConvArgs->pTargetFont = GetTargetFont();
549  m_pConvArgs->bAllowImplicitChangesForNotConvertibleText = true;
550  }
551 
552  // if it is not just a selection and we are about to begin
553  // with the current conversion for the very first time
554  // we need to find the start of the current (initial)
555  // convertible unit in order for the text conversion to give
556  // the correct result for that. Since it is easier to obtain
557  // the start of the word we use that though.
558  if (!pCursor->HasMark()) // is not a selection?
559  {
560  // since #118246 / #117803 still occurs if the cursor is placed
561  // between the two chinese characters to be converted (because both
562  // of them are words on their own!) using the word boundary here does
563  // not work. Thus since chinese conversion is not interactive we start
564  // at the begin of the paragraph to solve the problem, i.e. have the
565  // TextConversion service get those characters together in the same call.
566  sal_Int32 nStartIdx = -1;
568  nStartIdx = 0;
569  else
570  {
571  OUString aText( m_pConvArgs->pStartNode->GetText() );
572  const sal_Int32 nPos = m_pConvArgs->pStartIdx->GetIndex();
573  Boundary aBoundary( g_pBreakIt->GetBreakIter()->
574  getWordBoundary( aText, nPos, g_pBreakIt->GetLocale( m_pConvArgs->nConvSrcLang ),
575  WordType::DICTIONARY_WORD, true ) );
576 
577  // valid result found?
578  if (aBoundary.startPos < aText.getLength() &&
579  aBoundary.startPos != aBoundary.endPos)
580  {
581  nStartIdx = aBoundary.startPos;
582  }
583  }
584 
585  if (nStartIdx != -1)
586  *m_pConvArgs->pStartIdx = nStartIdx;
587  }
588  }
589 
590  if ( m_bIsOtherContent )
591  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Other );
592  else
593  {
594  m_bStartChk = false;
595  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::BodyEnd );
596  }
597 
598  ConvertDocument();
599 
600  ConvEnd_impl( m_pConvArgs.get() );
601 }
602 
604 {
606 
607  // no change of direction so the desired region is fully processed
608  if( m_bStartChk )
609  m_bStartDone = true;
610  else
611  m_bEndDone = true;
612 
613  if( m_bIsOtherContent && m_bStartDone && m_bEndDone ) // document completely checked?
614  {
615  return false;
616  }
617 
618  bool bGoOn = false;
619 
620  if ( m_bIsOtherContent )
621  {
622  m_bStartChk = false;
623  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Body );
624  bGoOn = true;
625  }
626  else if ( m_bStartDone && m_bEndDone )
627  {
628  // body region done, ask about special region
630  {
631  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Other );
632  m_bIsOtherContent = bGoOn = true;
633  }
634  }
635  else
636  {
638  ConvStart_impl( m_pConvArgs.get(), m_bStartChk ? SvxSpellArea::BodyStart : SvxSpellArea::BodyEnd );
639  bGoOn = true;
640  }
641  return bGoOn;
642 }
643 
645 {
647 
648  bool bFound = false;
649 
650  weld::WaitObject aWait(GetUIParent());
651  bool bConv = true;
652 
653  while ( bConv )
654  {
655  bFound = ConvContinue_impl( m_pConvArgs.get() );
656  if (bFound)
657  {
658  bConv = false;
659  }
660  else
661  {
662  ConvEnd_impl( m_pConvArgs.get() );
663  bConv = ConvNext_impl();
664  }
665  }
666 }
667 
668 void SwHHCWrapper::ConvStart_impl( SwConversionArgs /* [out] */ *pConversionArgs, SvxSpellArea eArea )
669 {
670  m_bIsDrawObj = SvxSpellArea::Other == eArea;
671  m_pView->SpellStart( eArea, m_bStartDone, m_bEndDone, /* [out] */ pConversionArgs );
672 }
673 
674 void SwHHCWrapper::ConvEnd_impl( SwConversionArgs const *pConversionArgs )
675 {
676  m_pView->SpellEnd( pConversionArgs );
677 }
678 
680 {
681  bool bProgress = !m_bIsDrawObj && !m_bIsSelection;
682  pConversionArgs->aConvText.clear();
683  pConversionArgs->nConvTextLang = LANGUAGE_NONE;
684  m_pView->GetWrtShell().SpellContinue( &m_nPageCount, bProgress ? &m_nPageStart : nullptr, pConversionArgs );
685  return !pConversionArgs->aConvText.isEmpty();
686 }
687 
688 /* 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:177
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:35
const OUString & GetFamilyName() const
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
static constexpr auto Items
const OUString & GetStyleName() const
SwNodeIndex nNode
Definition: pam.hxx:37
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:209
void SetAttrSet(const SfxItemSet &, SetAttrMode nFlags=SetAttrMode::DEFAULT, SwPaM *pCursor=nullptr, const bool bParagraphSetting=false)
Definition: edatmisc.cxx:151
Definition: doc.hxx:188
constexpr sal_uInt16 RES_FRMATR_END(133)
bool HasDrawView() const
Definition: vnew.cxx:358
void ConvEnd_impl(SwConversionArgs const *pConvArgs)
former SpellEnd
Definition: hhcwrp.cxx:674
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:119
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:38
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
bool ConvNext_impl()
from SvxSpellWrapper copied and modified
Definition: hhcwrp.cxx:603
static void lcl_ActivateTextShell(SwWrtShell &rWrtSh)
Definition: hhcwrp.cxx:53
void Insert(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:62
bool m_bStartDone
Definition: hhcwrp.hxx:51
void FindConvText_impl()
former FindSpellError
Definition: hhcwrp.cxx:644
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
LanguageType GetSourceLanguage() const
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
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:612
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:501
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:207
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:205
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:875
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:949
void ConvStart_impl(SwConversionArgs *pConvArgs, SvxSpellArea eSpell)
former SpellStart
Definition: hhcwrp.cxx:668
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:1122
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:506
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:538
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
static void SetCareDialog(const std::shared_ptr< weld::Window > &rNew)
Definition: viewsh.cxx:2558
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:2542
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:217
size_t IsObjSelected() const
Definition: feshview.cxx:1240
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:939
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:177
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:679
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:350
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
bool IsTextNode() const
Definition: node.hxx:637
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:850
Base class of the Writer document model elements.
Definition: node.hxx:80