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  {
141  SwDoc *pDoc = m_pView->GetDocShell()->GetDoc();
142 
144  pDoc->SetDefault( SvxLanguageItem( nTargetLang, RES_CHRATR_CJK_LANGUAGE ) );
145 
146  const vcl::Font *pFont = GetTargetFont();
147  if (pFont)
148  {
149  SvxFontItem aFontItem( pFont->GetFamilyType(), pFont->GetFamilyName(),
150  pFont->GetStyleName(), pFont->GetPitch(),
151  pFont->GetCharSet(), RES_CHRATR_CJK_FONT );
152  pDoc->SetDefault( aFontItem );
153  }
154 
155  }
156 }
157 
159  OUString& rNextPortion,
160  LanguageType& rLangOfPortion,
161  bool bAllowChanges )
162 {
163  m_pConvArgs->bAllowImplicitChangesForNotConvertibleText = bAllowChanges;
164 
166  rNextPortion = m_pConvArgs->aConvText;
167  rLangOfPortion = m_pConvArgs->nConvTextLang;
168 
169  m_nUnitOffset = 0;
170 
171  // build last pos from currently selected text
172  SwPaM* pCursor = m_rWrtShell.GetCursor();
173  m_nLastPos = pCursor->Start()->nContent.GetIndex();
174 }
175 
176 void SwHHCWrapper::SelectNewUnit_impl( sal_Int32 nUnitStart, sal_Int32 nUnitEnd )
177 {
178  SwPaM *pCursor = m_rWrtShell.GetCursor();
179  pCursor->GetPoint()->nContent = m_nLastPos;
180  pCursor->DeleteMark();
181 
182  m_rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ false,
183  static_cast<sal_uInt16>(m_nUnitOffset + nUnitStart), true );
184  pCursor->SetMark();
185  m_rWrtShell.Right( CRSR_SKIP_CHARS, /*bExpand*/ true,
186  static_cast<sal_uInt16>(nUnitEnd - nUnitStart), true );
187  // end selection now. Otherwise SHIFT+HOME (extending the selection)
188  // won't work when the dialog is closed without any replacement.
189  // (see #116346#)
191 }
192 
194  const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd )
195 {
196  OSL_ENSURE( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
197  if (0 > nUnitStart || nUnitStart > nUnitEnd)
198  return;
199 
201 
203 
204  // select current unit
205  SelectNewUnit_impl( nUnitStart, nUnitEnd );
206 
208 }
209 
210 void SwHHCWrapper::ChangeText( const OUString &rNewText,
211  const OUString& rOrigText,
212  const uno::Sequence< sal_Int32 > *pOffsets,
213  SwPaM *pCursor )
214 {
217 
218  OSL_ENSURE( !rNewText.isEmpty(), "unexpected empty string" );
219  if (rNewText.isEmpty())
220  return;
221 
222  if (pOffsets && pCursor) // try to keep as much attributation as possible ?
223  {
224  // remember cursor start position for later setting of the cursor
225  const SwPosition *pStart = pCursor->Start();
226  const sal_Int32 nStartIndex = pStart->nContent.GetIndex();
227  const SwNodeIndex aStartNodeIndex = pStart->nNode;
228  SwTextNode *pStartTextNode = aStartNodeIndex.GetNode().GetTextNode();
229 
230  const sal_Int32 nIndices = pOffsets->getLength();
231  const sal_Int32 *pIndices = pOffsets->getConstArray();
232  sal_Int32 nConvTextLen = rNewText.getLength();
233  sal_Int32 nPos = 0;
234  sal_Int32 nChgPos = -1;
235  sal_Int32 nChgLen = 0;
236  sal_Int32 nConvChgPos = -1;
237  sal_Int32 nConvChgLen = 0;
238 
239  // offset to calculate the position in the text taking into
240  // account that text may have been replaced with new text of
241  // different length. Negative values allowed!
242  long nCorrectionOffset = 0;
243 
244  OSL_ENSURE(nIndices == 0 || nIndices == nConvTextLen,
245  "mismatch between string length and sequence length!" );
246 
247  // find all substrings that need to be replaced (and only those)
248  while (true)
249  {
250  // get index in original text that matches nPos in new text
251  sal_Int32 nIndex;
252  if (nPos < nConvTextLen)
253  nIndex = nPos < nIndices ? pIndices[nPos] : nPos;
254  else
255  {
256  nPos = nConvTextLen;
257  nIndex = rOrigText.getLength();
258  }
259 
260  if (nPos == nConvTextLen || /* end of string also terminates non-matching char sequence */
261  rOrigText[nIndex] == rNewText[nPos])
262  {
263  // substring that needs to be replaced found?
264  if (nChgPos != -1 && nConvChgPos != -1)
265  {
266  nChgLen = nIndex - nChgPos;
267  nConvChgLen = nPos - nConvChgPos;
268  OUString aInNew( rNewText.copy( nConvChgPos, nConvChgLen ) );
269 
270  // set selection to sub string to be replaced in original text
271  sal_Int32 nChgInNodeStartIndex = nStartIndex + nCorrectionOffset + nChgPos;
272  OSL_ENSURE( m_rWrtShell.GetCursor()->HasMark(), "cursor misplaced (nothing selected)" );
273  m_rWrtShell.GetCursor()->GetMark()->nContent.Assign( pStartTextNode, nChgInNodeStartIndex );
274  m_rWrtShell.GetCursor()->GetPoint()->nContent.Assign( pStartTextNode, nChgInNodeStartIndex + nChgLen );
275 
276  // replace selected sub string with the corresponding
277  // sub string from the new text while keeping as
278  // much from the attributes as possible
279  ChangeText_impl( aInNew, true );
280 
281  nCorrectionOffset += nConvChgLen - nChgLen;
282 
283  nChgPos = -1;
284  nConvChgPos = -1;
285  }
286  }
287  else
288  {
289  // begin of non-matching char sequence found ?
290  if (nChgPos == -1 && nConvChgPos == -1)
291  {
292  nChgPos = nIndex;
293  nConvChgPos = nPos;
294  }
295  }
296  if (nPos >= nConvTextLen)
297  break;
298  ++nPos;
299  }
300 
301  // set cursor to the end of all the new text
302  // (as it would happen after ChangeText_impl (Delete and Insert)
303  // of the whole text in the 'else' branch below)
305  m_rWrtShell.GetCursor()->Start()->nContent.Assign( pStartTextNode, nStartIndex + nConvTextLen );
306  }
307  else
308  {
309  ChangeText_impl( rNewText, false );
310  }
311 }
312 
313 void SwHHCWrapper::ChangeText_impl( const OUString &rNewText, bool bKeepAttributes )
314 {
315  if (bKeepAttributes)
316  {
317  // get item set with all relevant attributes
318  sal_uInt16 const aRanges[] {
320  0, 0, 0 };
321  SfxItemSet aItemSet( m_rWrtShell.GetAttrPool(), aRanges );
322  // get all attributes spanning the whole selection in order to
323  // restore those for the new text
324  m_rWrtShell.GetCurAttr( aItemSet );
325 
327  m_rWrtShell.Insert( rNewText );
328 
329  // select new inserted text (currently the Point is right after the new text)
330  if (!m_rWrtShell.GetCursor()->HasMark())
332  SwPosition *pMark = m_rWrtShell.GetCursor()->GetMark();
333  pMark->nContent = pMark->nContent.GetIndex() - rNewText.getLength();
334 
335  // since 'SetAttr' below functions like merging with the attributes
336  // from the itemset with any existing ones we have to get rid of all
337  // all attributes now. (Those attributes that may take effect left
338  // to the position where the new text gets inserted after the old text
339  // was deleted)
341  // apply previously saved attributes to new text
342  m_rWrtShell.SetAttrSet( aItemSet );
343  }
344  else
345  {
347  m_rWrtShell.Insert( rNewText );
348  }
349 }
350 
352  const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd,
353  const OUString& rOrigText,
354  const OUString& rReplaceWith,
355  const uno::Sequence< sal_Int32 > &rOffsets,
356  ReplacementAction eAction,
357  LanguageType *pNewUnitLanguage )
358 {
359  OSL_ENSURE( nUnitStart >= 0 && nUnitEnd >= nUnitStart, "wrong arguments" );
360  if (nUnitStart < 0 || nUnitEnd < nUnitStart)
361  return;
362 
364 
365  // replace the current word
367 
368  // select current unit
369  SelectNewUnit_impl( nUnitStart, nUnitEnd );
370 
371  OUString aOrigText( m_rWrtShell.GetSelText() );
372  OUString aNewText( rReplaceWith );
373  OSL_ENSURE( aOrigText == rOrigText, "!! text mismatch !!" );
374  std::unique_ptr<SwFormatRuby> pRuby;
375  bool bRubyBelow = false;
376  OUString aNewOrigText;
377  switch (eAction)
378  {
379  case eExchange :
380  break;
381  case eReplacementBracketed :
382  {
383  aNewText = aOrigText + "(" + rReplaceWith + ")";
384  }
385  break;
386  case eOriginalBracketed :
387  {
388  aNewText = rReplaceWith + "(" + aOrigText + ")";
389  }
390  break;
391  case eReplacementAbove :
392  {
393  pRuby.reset(new SwFormatRuby( rReplaceWith ));
394  }
395  break;
396  case eOriginalAbove :
397  {
398  pRuby.reset(new SwFormatRuby( aOrigText ));
399  aNewOrigText = rReplaceWith;
400  }
401  break;
402  case eReplacementBelow :
403  {
404  pRuby.reset(new SwFormatRuby( rReplaceWith ));
405  bRubyBelow = true;
406  }
407  break;
408  case eOriginalBelow :
409  {
410  pRuby.reset(new SwFormatRuby( aOrigText ));
411  aNewOrigText = rReplaceWith;
412  bRubyBelow = true;
413  }
414  break;
415  default:
416  OSL_FAIL("unexpected case" );
417  }
418  m_nUnitOffset += nUnitStart + aNewText.getLength();
419 
420  if (pRuby)
421  {
423  if (!aNewOrigText.isEmpty())
424  {
425  // according to FT we currently should not bother about keeping
426  // attributes in Hangul/Hanja conversion
427  ChangeText( aNewOrigText, rOrigText, nullptr, nullptr );
428 
433  // We didn't fix it in Delete and Insert since it is currently
434  // unclear if someone depends on this incorrect behaviour
435  // of the flag.
437 
438  m_rWrtShell.Left( 0, true, aNewOrigText.getLength(), true, true );
439  }
440 
441  pRuby->SetPosition( static_cast<sal_uInt16>(bRubyBelow) );
442  pRuby->SetAdjustment( RubyAdjust_CENTER );
443 
444  m_rWrtShell.SetAttrItem(*pRuby);
445  pRuby.reset();
447  }
448  else
449  {
451 
452  // according to FT we should currently not bother about keeping
453  // attributes in Hangul/Hanja conversion and leave that untouched.
454  // Thus we do this only for Chinese translation...
455  const bool bIsChineseConversion = IsChinese( GetSourceLanguage() );
456  if (bIsChineseConversion)
457  ChangeText( aNewText, rOrigText, &rOffsets, m_rWrtShell.GetCursor() );
458  else
459  ChangeText( aNewText, rOrigText, nullptr, nullptr );
460 
461  // change language and font if necessary
462  if (bIsChineseConversion)
463  {
465  m_rWrtShell.GetCursor()->GetMark()->nContent -= aNewText.getLength();
466 
468  "SwHHCWrapper::ReplaceUnit : unexpected target language" );
469 
470  sal_uInt16 const aRanges[] {
473  0, 0, 0 };
474 
475  SfxItemSet aSet( m_rWrtShell.GetAttrPool(), aRanges );
476  if (pNewUnitLanguage)
477  {
478  aSet.Put( SvxLanguageItem( *pNewUnitLanguage, RES_CHRATR_CJK_LANGUAGE ) );
479  }
480 
481  const vcl::Font *pTargetFont = GetTargetFont();
482  OSL_ENSURE( pTargetFont, "target font missing?" );
483  if (pTargetFont && pNewUnitLanguage)
484  {
485  SvxFontItem aFontItem( aSet.Get( RES_CHRATR_CJK_FONT ) );
486  aFontItem.SetFamilyName( pTargetFont->GetFamilyName());
487  aFontItem.SetFamily( pTargetFont->GetFamilyType());
488  aFontItem.SetStyleName( pTargetFont->GetStyleName());
489  aFontItem.SetPitch( pTargetFont->GetPitch());
490  aFontItem.SetCharSet( pTargetFont->GetCharSet() );
491  aSet.Put( aFontItem );
492  }
493 
494  m_rWrtShell.SetAttrSet( aSet );
495 
497  }
498 
500  }
501 
503 }
504 
506 {
507  return true;
508 }
509 
511 {
512  OSL_ENSURE( m_pConvArgs == nullptr, "NULL pointer expected" );
513  {
514  SwPaM *pCursor = m_pView->GetWrtShell().GetCursor();
515  SwPosition* pSttPos = pCursor->Start();
516  SwPosition* pEndPos = pCursor->End();
517 
518  if (pSttPos->nNode.GetNode().IsTextNode() &&
519  pEndPos->nNode.GetNode().IsTextNode())
520  {
522  pSttPos->nNode.GetNode().GetTextNode(), pSttPos->nContent,
523  pEndPos->nNode.GetNode().GetTextNode(), pEndPos->nContent ) );
524  }
525  else // we are not in the text (maybe a graphic or OLE object is selected) let's start from the top
526  {
527  // get PaM that points to the start of the document
529  SwPaM aPam(rNode);
530  aPam.Move( fnMoveBackward, GoInDoc ); // move to start of document
531 
532  pSttPos = aPam.GetPoint();
533  SwTextNode *pTextNode = pSttPos->nNode.GetNode().GetTextNode();
534  // just in case we check anyway...
535  if (!pTextNode || !pTextNode->IsTextNode())
536  return;
538  pTextNode, pSttPos->nContent,
539  pTextNode, pSttPos->nContent ) );
540  }
541  OSL_ENSURE( m_pConvArgs->pStartNode && m_pConvArgs->pStartNode->IsTextNode(),
542  "failed to get proper start text node" );
543  OSL_ENSURE( m_pConvArgs->pEndNode && m_pConvArgs->pEndNode->IsTextNode(),
544  "failed to get proper end text node" );
545 
546  // chinese conversion specific settings
547  OSL_ENSURE( IsChinese( GetSourceLanguage() ) == IsChinese( GetTargetLanguage() ),
548  "source and target language mismatch?" );
549  if (IsChinese( GetTargetLanguage() ))
550  {
551  m_pConvArgs->nConvTargetLang = GetTargetLanguage();
552  m_pConvArgs->pTargetFont = GetTargetFont();
553  m_pConvArgs->bAllowImplicitChangesForNotConvertibleText = true;
554  }
555 
556  // if it is not just a selection and we are about to begin
557  // with the current conversion for the very first time
558  // we need to find the start of the current (initial)
559  // convertible unit in order for the text conversion to give
560  // the correct result for that. Since it is easier to obtain
561  // the start of the word we use that though.
562  if (!pCursor->HasMark()) // is not a selection?
563  {
564  // since #118246 / #117803 still occurs if the cursor is placed
565  // between the two chinese characters to be converted (because both
566  // of them are words on their own!) using the word boundary here does
567  // not work. Thus since chinese conversion is not interactive we start
568  // at the begin of the paragraph to solve the problem, i.e. have the
569  // TextConversion service get those characters together in the same call.
570  sal_Int32 nStartIdx = -1;
572  nStartIdx = 0;
573  else
574  {
575  OUString aText( m_pConvArgs->pStartNode->GetText() );
576  const sal_Int32 nPos = m_pConvArgs->pStartIdx->GetIndex();
577  Boundary aBoundary( g_pBreakIt->GetBreakIter()->
578  getWordBoundary( aText, nPos, g_pBreakIt->GetLocale( m_pConvArgs->nConvSrcLang ),
579  WordType::DICTIONARY_WORD, true ) );
580 
581  // valid result found?
582  if (aBoundary.startPos < aText.getLength() &&
583  aBoundary.startPos != aBoundary.endPos)
584  {
585  nStartIdx = aBoundary.startPos;
586  }
587  }
588 
589  if (nStartIdx != -1)
590  *m_pConvArgs->pStartIdx = nStartIdx;
591  }
592  }
593 
594  if ( m_bIsOtherContent )
595  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Other );
596  else
597  {
598  m_bStartChk = false;
599  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::BodyEnd );
600  }
601 
602  ConvertDocument();
603 
604  ConvEnd_impl( m_pConvArgs.get() );
605 }
606 
608 {
610 
611  // no change of direction so the desired region is fully processed
612  if( m_bStartChk )
613  m_bStartDone = true;
614  else
615  m_bEndDone = true;
616 
617  if( m_bIsOtherContent && m_bStartDone && m_bEndDone ) // document completely checked?
618  {
619  return false;
620  }
621 
622  bool bGoOn = false;
623 
624  if ( m_bIsOtherContent )
625  {
626  m_bStartChk = false;
627  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Body );
628  bGoOn = true;
629  }
630  else if ( m_bStartDone && m_bEndDone )
631  {
632  // body region done, ask about special region
634  {
635  ConvStart_impl( m_pConvArgs.get(), SvxSpellArea::Other );
636  m_bIsOtherContent = bGoOn = true;
637  }
638  }
639  else
640  {
642  ConvStart_impl( m_pConvArgs.get(), m_bStartChk ? SvxSpellArea::BodyStart : SvxSpellArea::BodyEnd );
643  bGoOn = true;
644  }
645  return bGoOn;
646 }
647 
649 {
651 
652  bool bFound = false;
653 
654  m_pWin->EnterWait();
655  bool bConv = true;
656 
657  while ( bConv )
658  {
659  bFound = ConvContinue_impl( m_pConvArgs.get() );
660  if (bFound)
661  {
662  bConv = false;
663  }
664  else
665  {
666  ConvEnd_impl( m_pConvArgs.get() );
667  bConv = ConvNext_impl();
668  }
669  }
670  m_pWin->LeaveWait();
671 }
672 
673 void SwHHCWrapper::ConvStart_impl( SwConversionArgs /* [out] */ *pConversionArgs, SvxSpellArea eArea )
674 {
675  m_bIsDrawObj = SvxSpellArea::Other == eArea;
676  m_pView->SpellStart( eArea, m_bStartDone, m_bEndDone, /* [out] */ pConversionArgs );
677 }
678 
679 void SwHHCWrapper::ConvEnd_impl( SwConversionArgs const *pConversionArgs )
680 {
681  m_pView->SpellEnd( pConversionArgs );
682 }
683 
685 {
686  bool bProgress = !m_bIsDrawObj && !m_bIsSelection;
687  pConversionArgs->aConvText.clear();
688  pConversionArgs->nConvTextLang = LANGUAGE_NONE;
689  m_pView->GetWrtShell().SpellContinue( &m_nPageCount, bProgress ? &m_nPageStart : nullptr, pConversionArgs );
690  return !pConversionArgs->aConvText.isEmpty();
691 }
692 
693 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ChangeText_impl(const OUString &rNewText, bool bKeepAttributes)
Definition: hhcwrp.cxx:313
#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:189
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
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:184
bool HasDrawView() const
Definition: vnew.cxx:360
void ConvEnd_impl(SwConversionArgs const *pConvArgs)
former SpellEnd
Definition: hhcwrp.cxx:679
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:398
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:158
bool ConvNext_impl()
from SvxSpellWrapper copied and modified
Definition: hhcwrp.cxx:607
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:648
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:505
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:176
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:676
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:673
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:1107
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:510
virtual void HandleNewUnit(const sal_Int32 nUnitStart, const sal_Int32 nUnitEnd) override
Definition: hhcwrp.cxx:193
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:2490
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:2526
sal_Int32 GetIndex() const
Definition: index.hxx:95
LanguageType GetTargetLanguage() const
SwNodes & GetNodes()
Definition: doc.hxx:403
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
const SwPosition * End() const
Definition: pam.hxx:217
size_t IsObjSelected() const
Definition: feshview.cxx:1150
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:210
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:63
#define LANGUAGE_CHINESE_TRADITIONAL
bool ConvContinue_impl(SwConversionArgs *pConvArgs)
former SpellContinue
Definition: hhcwrp.cxx:684
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
void ResetAttr(const std::set< sal_uInt16 > &attrs=std::set< sal_uInt16 >(), SwPaM *pCursor=nullptr)
Definition: edatmisc.cxx:32
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:351
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
bool IsTextNode() const
Definition: node.hxx:636
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:836
Base class of the Writer document model elements.
Definition: node.hxx:79