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 <hhcwrp.hxx>
32 #include "sdrhhcwrap.hxx"
33 #include <doc.hxx>
34 #include <docsh.hxx>
35 #include <mdiexp.hxx>
36 #include <edtwin.hxx>
37 #include <index.hxx>
38 #include <pam.hxx>
39 #include <swcrsr.hxx>
40 #include <ndtxt.hxx>
41 #include <fmtruby.hxx>
42 #include <breakit.hxx>
43 
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::text;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::linguistic2;
48 using namespace ::com::sun::star::i18n;
49 
50 // Description: Turn off frame/object shell if applicable
51 
52 static void lcl_ActivateTextShell( SwWrtShell & rWrtSh )
53 {
54  if( rWrtSh.IsSelFrameMode() || rWrtSh.IsObjSelected() )
55  rWrtSh.EnterStdMode();
56 }
57 
58 namespace {
59 
60 class SwKeepConversionDirectionStateContext
61 {
62 public:
63  SwKeepConversionDirectionStateContext()
64  {
69  }
70 
71  ~SwKeepConversionDirectionStateContext()
72  {
74  }
75 };
76 
77 }
78 
80  SwView* pSwView,
81  const uno::Reference< uno::XComponentContext >& rxContext,
82  LanguageType nSourceLanguage,
83  LanguageType nTargetLanguage,
84  const vcl::Font *pTargetFont,
85  sal_Int32 nConvOptions,
86  bool bIsInteractive,
87  bool bStart, bool bOther, bool bSelection )
88  : editeng::HangulHanjaConversion(pSwView->GetEditWin().GetFrameWeld(), rxContext,
89  LanguageTag::convertToLocale( nSourceLanguage ),
90  LanguageTag::convertToLocale( nTargetLanguage ),
91  pTargetFont,
92  nConvOptions,
93  bIsInteractive )
94  , m_pView( pSwView )
95  , m_pWin( &pSwView->GetEditWin() )
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 
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  static_cast<sal_uInt16>(m_nUnitOffset + nUnitStart), true );
183  pCursor->SetMark();
184  m_rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ true,
185  static_cast<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  sal_uInt16 const aRanges[] {
319  0, 0, 0 };
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( static_cast<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 
469  sal_uInt16 const aRanges[] {
472  0, 0, 0 };
473 
474  SfxItemSet aSet( m_rWrtShell.GetAttrPool(), aRanges );
475  if (pNewUnitLanguage)
476  {
477  aSet.Put( SvxLanguageItem( *pNewUnitLanguage, RES_CHRATR_CJK_LANGUAGE ) );
478  }
479 
480  const vcl::Font *pTargetFont = GetTargetFont();
481  OSL_ENSURE( pTargetFont, "target font missing?" );
482  if (pTargetFont && pNewUnitLanguage)
483  {
484  SvxFontItem aFontItem( aSet.Get( RES_CHRATR_CJK_FONT ) );
485  aFontItem.SetFamilyName( pTargetFont->GetFamilyName());
486  aFontItem.SetFamily( pTargetFont->GetFamilyType());
487  aFontItem.SetStyleName( pTargetFont->GetStyleName());
488  aFontItem.SetPitch( pTargetFont->GetPitch());
489  aFontItem.SetCharSet( pTargetFont->GetCharSet() );
490  aSet.Put( aFontItem );
491  }
492 
493  m_rWrtShell.SetAttrSet( aSet );
494 
496  }
497 
499  }
500 
502 }
503 
505 {
506  return true;
507 }
508 
510 {
511  OSL_ENSURE( m_pConvArgs == nullptr, "NULL pointer expected" );
512  {
513  SwPaM *pCursor = m_pView->GetWrtShell().GetCursor();
514  SwPosition* pSttPos = pCursor->Start();
515  SwPosition* pEndPos = pCursor->End();
516 
517  if (pSttPos->nNode.GetNode().IsTextNode() &&
518  pEndPos->nNode.GetNode().IsTextNode())
519  {
521  pSttPos->nNode.GetNode().GetTextNode(), pSttPos->nContent,
522  pEndPos->nNode.GetNode().GetTextNode(), pEndPos->nContent ) );
523  }
524  else // we are not in the text (maybe a graphic or OLE object is selected) let's start from the top
525  {
526  // get PaM that points to the start of the document
528  SwPaM aPam(rNode);
529  aPam.Move( fnMoveBackward, GoInDoc ); // move to start of document
530 
531  pSttPos = aPam.GetPoint();
532  SwTextNode *pTextNode = pSttPos->nNode.GetNode().GetTextNode();
533  // just in case we check anyway...
534  if (!pTextNode || !pTextNode->IsTextNode())
535  return;
537  pTextNode, pSttPos->nContent,
538  pTextNode, pSttPos->nContent ) );
539  }
540  OSL_ENSURE( m_pConvArgs->pStartNode && m_pConvArgs->pStartNode->IsTextNode(),
541  "failed to get proper start text node" );
542  OSL_ENSURE( m_pConvArgs->pEndNode && m_pConvArgs->pEndNode->IsTextNode(),
543  "failed to get proper end text node" );
544 
545  // chinese conversion specific settings
546  OSL_ENSURE( IsChinese( GetSourceLanguage() ) == IsChinese( GetTargetLanguage() ),
547  "source and target language mismatch?" );
548  if (IsChinese( GetTargetLanguage() ))
549  {
550  m_pConvArgs->nConvTargetLang = GetTargetLanguage();
551  m_pConvArgs->pTargetFont = GetTargetFont();
552  m_pConvArgs->bAllowImplicitChangesForNotConvertibleText = true;
553  }
554 
555  // if it is not just a selection and we are about to begin
556  // with the current conversion for the very first time
557  // we need to find the start of the current (initial)
558  // convertible unit in order for the text conversion to give
559  // the correct result for that. Since it is easier to obtain
560  // the start of the word we use that though.
561  if (!pCursor->HasMark()) // is not a selection?
562  {
563  // since #118246 / #117803 still occurs if the cursor is placed
564  // between the two chinese characters to be converted (because both
565  // of them are words on their own!) using the word boundary here does
566  // not work. Thus since chinese conversion is not interactive we start
567  // at the begin of the paragraph to solve the problem, i.e. have the
568  // TextConversion service get those characters together in the same call.
569  sal_Int32 nStartIdx = -1;
571  nStartIdx = 0;
572  else
573  {
574  OUString aText( m_pConvArgs->pStartNode->GetText() );
575  const sal_Int32 nPos = m_pConvArgs->pStartIdx->GetIndex();
576  Boundary aBoundary( g_pBreakIt->GetBreakIter()->
577  getWordBoundary( aText, nPos, g_pBreakIt->GetLocale( m_pConvArgs->nConvSrcLang ),
578  WordType::DICTIONARY_WORD, true ) );
579 
580  // valid result found?
581  if (aBoundary.startPos < aText.getLength() &&
582  aBoundary.startPos != aBoundary.endPos)
583  {
584  nStartIdx = aBoundary.startPos;
585  }
586  }
587 
588  if (nStartIdx != -1)
589  *m_pConvArgs->pStartIdx = nStartIdx;
590  }
591  }
592 
593  if ( m_bIsOtherContent )
594  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Other );
595  else
596  {
597  m_bStartChk = false;
598  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::BodyEnd );
599  }
600 
601  ConvertDocument();
602 
603  ConvEnd_impl( m_pConvArgs.get() );
604 }
605 
607 {
609 
610  // no change of direction so the desired region is fully processed
611  if( m_bStartChk )
612  m_bStartDone = true;
613  else
614  m_bEndDone = true;
615 
616  if( m_bIsOtherContent && m_bStartDone && m_bEndDone ) // document completely checked?
617  {
618  return false;
619  }
620 
621  bool bGoOn = false;
622 
623  if ( m_bIsOtherContent )
624  {
625  m_bStartChk = false;
626  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Body );
627  bGoOn = true;
628  }
629  else if ( m_bStartDone && m_bEndDone )
630  {
631  // body region done, ask about special region
633  {
634  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Other );
635  m_bIsOtherContent = bGoOn = true;
636  }
637  }
638  else
639  {
641  ConvStart_impl( m_pConvArgs.get(), m_bStartChk ? SvxSpellArea::BodyStart : SvxSpellArea::BodyEnd );
642  bGoOn = true;
643  }
644  return bGoOn;
645 }
646 
648 {
650 
651  bool bFound = false;
652 
653  m_pWin->EnterWait();
654  bool bConv = true;
655 
656  while ( bConv )
657  {
658  bFound = ConvContinue_impl( m_pConvArgs.get() );
659  if (bFound)
660  {
661  bConv = false;
662  }
663  else
664  {
665  ConvEnd_impl( m_pConvArgs.get() );
666  bConv = ConvNext_impl();
667  }
668  }
669  m_pWin->LeaveWait();
670 }
671 
672 void SwHHCWrapper::ConvStart_impl( SwConversionArgs /* [out] */ *pConversionArgs, SvxSpellArea eArea )
673 {
674  m_bIsDrawObj = SvxSpellArea::Other == eArea;
675  m_pView->SpellStart( eArea, m_bStartDone, m_bEndDone, /* [out] */ pConversionArgs );
676 }
677 
678 void SwHHCWrapper::ConvEnd_impl( SwConversionArgs const *pConversionArgs )
679 {
680  m_pView->SpellEnd( pConversionArgs );
681 }
682 
684 {
685  bool bProgress = !m_bIsDrawObj && !m_bIsSelection;
686  pConversionArgs->aConvText.clear();
687  pConversionArgs->nConvTextLang = LANGUAGE_NONE;
688  m_pView->GetWrtShell().SpellContinue( &m_nPageCount, bProgress ? &m_nPageStart : nullptr, pConversionArgs );
689  return !pConversionArgs->aConvText.isEmpty();
690 }
691 
692 /* 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:123
sal_Int32 nIndex
SwWrtShell & m_rWrtShell
Definition: hhcwrp.hxx:37
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:190
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:260
long Long
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:151
Definition: doc.hxx:186
bool HasDrawView() const
Definition: vnew.cxx:360
void ConvEnd_impl(SwConversionArgs const *pConvArgs)
former SpellEnd
Definition: hhcwrp.cxx:678
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:550
void EndProgress(SwDocShell const *pDocShell)
Definition: mainwn.cxx:92
void EndAllAction()
Definition: edws.cxx:97
FontFamily GetFamilyType()
SwWrtShell & GetWrtShell() const
Definition: view.hxx:399
void SetFamilyName(const OUString &rFamilyName)
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
SwIndex nContent
Definition: pam.hxx:38
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:42
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:79
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:606
static void lcl_ActivateTextShell(SwWrtShell &rWrtSh)
Definition: hhcwrp.cxx:52
void Insert(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:61
bool m_bStartDone
Definition: hhcwrp.hxx:54
void FindConvText_impl()
former FindSpellError
Definition: hhcwrp.cxx:647
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
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:424
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:501
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:504
FontPitch GetPitch()
SwView * m_pView
Definition: hhcwrp.hxx:35
sal_uInt16 m_nPageStart
first checked page
Definition: hhcwrp.hxx:48
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:45
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:687
const vcl::Font * GetTargetFont() const
VclPtr< vcl::Window > m_pWin
Definition: hhcwrp.hxx:36
#define LANGUAGE_CHINESE_SIMPLIFIED
void SetMark()
Definition: crsrsh.hxx:875
vcl::Cursor * GetCursor() const
bool m_bEndDone
Definition: hhcwrp.hxx:55
Marks a node in the document model.
Definition: ndindex.hxx:31
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:942
void ConvStart_impl(SwConversionArgs *pConvArgs, SvxSpellArea eSpell)
former SpellStart
Definition: hhcwrp.cxx:672
bool m_bStartChk
Definition: hhcwrp.hxx:52
bool m_bIsDrawObj
Definition: hhcwrp.hxx:50
const SwPosition * Start() const
Definition: pam.hxx:212
SwDocShell * GetDocShell()
Definition: view.cxx:1109
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:90
void Convert()
Definition: hhcwrp.cxx:509
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
constexpr sal_uInt16 RES_FRMATR_END(131)
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:526
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
static void SetCareDialog(const std::shared_ptr< weld::Window > &rNew)
Definition: viewsh.cxx:2553
bool Left(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:106
SvxSpellArea
void SetCursor(vcl::Cursor *pCursor)
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2530
sal_Int32 GetIndex() const
Definition: index.hxx:91
LanguageType GetTargetLanguage() const
SwNodes & GetNodes()
Definition: doc.hxx:405
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
const SwPosition * End() const
Definition: pam.hxx:217
size_t IsObjSelected() const
Definition: feshview.cxx:1149
virtual ~SwHHCWrapper() override
Definition: hhcwrp.cxx:110
sal_uInt16 m_nPageCount
page count for progress bar
Definition: hhcwrp.hxx:47
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:51
void ClearMark()
Definition: crsrsh.cxx:938
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:176
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:683
SAL_DLLPRIVATE void SpellEnd(SwConversionArgs const *pConvArgs)
Definition: viewling.cxx:366
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:475
bool m_bIsSelection
true if only the selected text should be converted
Definition: hhcwrp.hxx:53
void LeaveWait()
std::unique_ptr< SwConversionArgs > m_pConvArgs
object for arguments (and results) needed to find of next convertible text portion ...
Definition: hhcwrp.hxx:39
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:639
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:170
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:845
Base class of the Writer document model elements.
Definition: node.hxx:79