LibreOffice Module sw (master)  1
drwtxtex.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 
21 #include <com/sun/star/linguistic2/XThesaurus.hpp>
22 
23 #include <comphelper/string.hxx>
24 #include <i18nlangtag/mslangid.hxx>
25 #include <sfx2/bindings.hxx>
26 #include <sfx2/dispatch.hxx>
27 #include <sfx2/request.hxx>
28 #include <svx/svdview.hxx>
29 #include <editeng/spltitem.hxx>
30 #include <editeng/lrspitem.hxx>
31 #include <editeng/ulspitem.hxx>
32 #include <editeng/orphitem.hxx>
34 #include <editeng/widwitem.hxx>
35 #include <editeng/kernitem.hxx>
37 #include <editeng/lspcitem.hxx>
38 #include <editeng/flstitem.hxx>
39 #include <editeng/adjustitem.hxx>
41 #include <editeng/shdditem.hxx>
42 #include <editeng/udlnitem.hxx>
43 #include <editeng/fontitem.hxx>
44 #include <editeng/fhgtitem.hxx>
45 #include <editeng/colritem.hxx>
46 #include <editeng/wghtitem.hxx>
47 #include <editeng/contouritem.hxx>
48 #include <editeng/postitem.hxx>
49 #include <editeng/frmdiritem.hxx>
51 #include <svx/svdoutl.hxx>
52 #include <sfx2/viewfrm.hxx>
53 #include <svl/stritem.hxx>
54 #include <svl/whiter.hxx>
55 #include <svl/cjkoptions.hxx>
56 #include <svl/ctloptions.hxx>
57 #include <svtools/langtab.hxx>
58 #include <svl/languageoptions.hxx>
59 #include <editeng/flditem.hxx>
60 #include <editeng/editstat.hxx>
61 #include <svx/clipfmtitem.hxx>
62 #include <svx/hlnkitem.hxx>
63 #include <svx/svxdlg.hxx>
64 #include <svx/svxids.hrc>
65 #include <sfx2/htmlmode.hxx>
66 #include <svl/slstitm.hxx>
67 #include <editeng/langitem.hxx>
68 #include <editeng/unolingu.hxx>
71 #include <editeng/eeitem.hxx>
72 #include <editeng/editeng.hxx>
73 #include <editeng/editdata.hxx>
74 #include <editeng/outliner.hxx>
75 #include <editeng/editview.hxx>
76 #include <vcl/outdev.hxx>
77 #include <vcl/unohelp2.hxx>
79 #include <tools/diagnose_ex.h>
80 
81 #include <cmdid.h>
82 #include <doc.hxx>
83 #include <docstat.hxx>
84 #include <drwtxtsh.hxx>
85 #include <edtwin.hxx>
86 #include <globals.hrc>
87 #include <hintids.hxx>
88 #include <initui.hxx>
89 #include <langhelper.hxx>
90 #include <chrdlgmodes.hxx>
91 #include <pardlg.hxx>
92 #include <string.h>
93 #include <swdtflvr.hxx>
94 #include <swmodule.hxx>
95 #include <swwait.hxx>
96 #include <uitool.hxx>
97 #include <viewopt.hxx>
98 #include <wrtsh.hxx>
99 #include <wview.hxx>
100 #include <svx/chrtitem.hxx>
101 
102 #include <swabstdlg.hxx>
103 #include <memory>
104 
105 using namespace ::com::sun::star;
106 
107 namespace
108 {
109  void lcl_convertStringArguments(sal_uInt16 nSlot, std::unique_ptr<SfxItemSet>& pArgs)
110  {
111  Color aColor;
112  OUString sColor;
113  const SfxPoolItem* pItem = nullptr;
114 
115  if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pItem))
116  {
117  sColor = static_cast<const SfxStringItem*>(pItem)->GetValue();
118 
119  if (sColor == "transparent")
120  aColor = COL_TRANSPARENT;
121  else
122  aColor = Color(sColor.toInt32(16));
123 
124  switch (nSlot)
125  {
126  case SID_ATTR_CHAR_COLOR:
127  {
128  SvxColorItem aColorItem(aColor, EE_CHAR_COLOR);
129  pArgs->Put(aColorItem);
130  break;
131  }
132 
133  case SID_ATTR_CHAR_BACK_COLOR:
134  {
135  SvxBackgroundColorItem pBackgroundItem(aColor, EE_CHAR_BKGCOLOR);
136  pArgs->Put(pBackgroundItem);
137  break;
138  }
139  }
140  }
141  }
142 }
143 
145 {
146  SwWrtShell &rSh = GetShell();
148  SfxItemSet aEditAttr(pOLV->GetAttribs());
149  SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
150 
151  const sal_uInt16 nSlot = rReq.GetSlot();
152 
153  const sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
154  const SfxItemSet *pNewAttrs = rReq.GetArgs();
155 
156  bool bRestoreSelection = false;
157  ESelection aOldSelection;
158 
159  sal_uInt16 nEEWhich = 0;
160  switch (nSlot)
161  {
162  case SID_LANGUAGE_STATUS:
163  {
164  aOldSelection = pOLV->GetSelection();
165  if (!pOLV->GetEditView().HasSelection())
166  {
167  pOLV->GetEditView().SelectCurrentWord();
168  }
169 
170  bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,GetView(),rSh);
171  break;
172  }
173 
174  case SID_THES:
175  {
176  OUString aReplaceText;
177  const SfxStringItem* pItem2 = rReq.GetArg<SfxStringItem>(SID_THES);
178  if (pItem2)
179  aReplaceText = pItem2->GetValue();
180  if (!aReplaceText.isEmpty())
181  ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
182  break;
183  }
184 
185  case SID_ATTR_CHAR_FONT:
186  case SID_ATTR_CHAR_FONTHEIGHT:
187  case SID_ATTR_CHAR_WEIGHT:
188  case SID_ATTR_CHAR_POSTURE:
189  {
190  SfxItemPool* pPool2 = aEditAttr.GetPool()->GetSecondaryPool();
191  if( !pPool2 )
192  pPool2 = aEditAttr.GetPool();
193  SvxScriptSetItem aSetItem( nSlot, *pPool2 );
194 
195  // #i78017 establish the same behaviour as in Writer
196  SvtScriptType nScriptTypes = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
197  if (nSlot == SID_ATTR_CHAR_FONT)
198  nScriptTypes = pOLV->GetSelectedScriptType();
199 
200  if (pNewAttrs)
201  {
202  aSetItem.PutItemForScriptType( nScriptTypes, pNewAttrs->Get( nWhich ) );
203  aNewAttr.Put( aSetItem.GetItemSet() );
204  }
205  }
206  break;
207 
208  case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
209  case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break;
210 
211  case SID_ATTR_CHAR_UNDERLINE:
212  {
213  if ( pNewAttrs )
214  {
215  const SvxTextLineItem& rTextLineItem = static_cast< const SvxTextLineItem& >( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich(nSlot) ) );
216  aNewAttr.Put( SvxUnderlineItem( rTextLineItem.GetLineStyle(), EE_CHAR_UNDERLINE ) );
217  }
218  else
219  {
220  FontLineStyle eFU = aEditAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle();
222  }
223  }
224  break;
225 
226  case SID_ATTR_CHAR_OVERLINE:
227  {
228  FontLineStyle eFO = aEditAttr.Get(EE_CHAR_OVERLINE).GetLineStyle();
230  }
231  break;
232 
233  case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
234  case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break;
235  case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
236  case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
237  case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
238  case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
239  case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
240  case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break;
241  case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
242  case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
243  case SID_ATTR_PARA_ADJUST_LEFT:
244  aNewAttr.Put(SvxAdjustItem(SvxAdjust::Left, EE_PARA_JUST));
245  break;
246  case SID_ATTR_PARA_ADJUST_CENTER:
247  aNewAttr.Put(SvxAdjustItem(SvxAdjust::Center, EE_PARA_JUST));
248  break;
249  case SID_ATTR_PARA_ADJUST_RIGHT:
250  aNewAttr.Put(SvxAdjustItem(SvxAdjust::Right, EE_PARA_JUST));
251  break;
252  case SID_ATTR_PARA_ADJUST_BLOCK:
253  aNewAttr.Put(SvxAdjustItem(SvxAdjust::Block, EE_PARA_JUST));
254  break;
255  case SID_ATTR_PARA_LRSPACE:
256  {
257  SvxLRSpaceItem aParaMargin(static_cast<const SvxLRSpaceItem&>(rReq.
258  GetArgs()->Get(nSlot)));
259  aParaMargin.SetWhich( EE_PARA_LRSPACE );
260  aNewAttr.Put(aParaMargin);
261  rReq.Done();
262  }
263  break;
264  case SID_HANGING_INDENT:
265  {
266  SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE );
267  if( eState >= SfxItemState::DEFAULT )
268  {
269  SvxLRSpaceItem aParaMargin = aEditAttr.Get( EE_PARA_LRSPACE );
270  aParaMargin.SetWhich( EE_PARA_LRSPACE );
271  short int nFirstLineOffset = aParaMargin.GetTextFirstLineOfst();
272  aParaMargin.SetTextLeft( aParaMargin.GetTextLeft() + nFirstLineOffset );
273  aParaMargin.SetRight( aParaMargin.GetRight() );
274  aParaMargin.SetTextFirstLineOfst( nFirstLineOffset * -1 );
275  aNewAttr.Put(aParaMargin);
276  rReq.Done();
277  }
278  }
279  break;
280  case SID_ATTR_PARA_LINESPACE:
281  {
282  SvxLineSpacingItem aLineSpace = static_cast<const SvxLineSpacingItem&>(pNewAttrs->Get(
283  GetPool().GetWhich(nSlot)));
284  aLineSpace.SetWhich( EE_PARA_SBL );
285  aNewAttr.Put( aLineSpace );
286  rReq.Done();
287  }
288  break;
289  case SID_ATTR_PARA_ULSPACE:
290  {
291  SvxULSpaceItem aULSpace = static_cast<const SvxULSpaceItem&>(pNewAttrs->Get(
292  GetPool().GetWhich(nSlot)));
293  aULSpace.SetWhich( EE_PARA_ULSPACE );
294  aNewAttr.Put( aULSpace );
295  rReq.Done();
296  }
297  break;
298  case SID_PARASPACE_INCREASE:
299  case SID_PARASPACE_DECREASE:
300  {
301  SvxULSpaceItem aULSpace( aEditAttr.Get( EE_PARA_ULSPACE ) );
302  sal_uInt16 nUpper = aULSpace.GetUpper();
303  sal_uInt16 nLower = aULSpace.GetLower();
304 
305  if ( nSlot == SID_PARASPACE_INCREASE )
306  {
307  nUpper = std::min< sal_uInt16 >( nUpper + 57, 5670 );
308  nLower = std::min< sal_uInt16 >( nLower + 57, 5670 );
309  }
310  else
311  {
312  nUpper = std::max< sal_Int16 >( nUpper - 57, 0 );
313  nLower = std::max< sal_Int16 >( nLower - 57, 0 );
314  }
315 
316  aULSpace.SetUpper( nUpper );
317  aULSpace.SetLower( nLower );
318  aNewAttr.Put( aULSpace );
319  rReq.Done();
320  }
321  break;
322  case SID_ATTR_PARA_LINESPACE_10:
323  {
325  aItem.SetPropLineSpace(100);
326  aNewAttr.Put(aItem);
327  }
328  break;
329  case SID_ATTR_PARA_LINESPACE_15:
330  {
332  aItem.SetPropLineSpace(150);
333  aNewAttr.Put(aItem);
334  }
335  break;
336  case SID_ATTR_PARA_LINESPACE_20:
337  {
339  aItem.SetPropLineSpace(200);
340  aNewAttr.Put(aItem);
341  }
342  break;
343 
344  case FN_SET_SUPER_SCRIPT:
345  {
347  SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
348 
349  if( eEsc == SvxEscapement::Superscript )
350  aItem.SetEscapement( SvxEscapement::Off );
351  else
352  aItem.SetEscapement( SvxEscapement::Superscript );
353  aNewAttr.Put( aItem );
354  }
355  break;
356  case FN_SET_SUB_SCRIPT:
357  {
359  SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
360 
361  if( eEsc == SvxEscapement::Subscript )
362  aItem.SetEscapement( SvxEscapement::Off );
363  else
364  aItem.SetEscapement( SvxEscapement::Subscript );
365  aNewAttr.Put( aItem );
366  }
367  break;
368 
369  case SID_CHAR_DLG_EFFECT:
370  case SID_CHAR_DLG:
371  case SID_CHAR_DLG_FOR_PARAGRAPH:
372  {
373  const SfxItemSet* pArgs = rReq.GetArgs();
374  const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
375 
376  if( !pArgs || pItem )
377  {
378  aOldSelection = pOLV->GetSelection();
379  if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
380  {
381  // select current paragraph (and restore selection later on...)
382  EditView & rEditView = pOLV->GetEditView();
383  SwLangHelper::SelectPara( rEditView, rEditView.GetSelection() );
384  bRestoreSelection = true;
385  }
386 
387  SwView* pView = &GetView();
388  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
389  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
391 
392  // util::Language does not exists in the EditEngine! That is why not in set.
393 
394  aDlgAttr.Put( aEditAttr );
395  aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
396 
399  if (nSlot == SID_CHAR_DLG_EFFECT)
400  {
401  pDlg->SetCurPageId("fonteffects");
402  }
403  else if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
404  {
405  pDlg->SetCurPageId("font");
406  }
407  else if (pItem)
408  {
409  pDlg->SetCurPageId(OUStringToOString(pItem->GetValue(), RTL_TEXTENCODING_UTF8));
410  }
411 
412  sal_uInt16 nRet = pDlg->Execute();
413  if(RET_OK == nRet )
414  {
415  rReq.Done( *( pDlg->GetOutputItemSet() ) );
416  aNewAttr.Put(*pDlg->GetOutputItemSet());
417  }
418  if(RET_OK != nRet)
419  return ;
420  }
421  else
422  aNewAttr.Put(*pArgs);
423  }
424  break;
426  {
428  break;
429  }
431  {
433  rReq.Done();
434  }
435  break;
436  case SID_OPEN_XML_FILTERSETTINGS:
437  {
439  }
440  break;
441  case FN_WORDCOUNT_DIALOG:
442  {
443  GetView().UpdateWordCount(this, nSlot);
444  }
445  break;
446  case SID_PARA_DLG:
447  {
448  const SfxItemSet* pArgs = rReq.GetArgs();
449 
450  if (!pArgs)
451  {
452  SwView* pView = &GetView();
453  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
454  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
455  SfxItemSet aDlgAttr(
456  GetPool(),
457  svl::Items<
459  SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_WIDOWS>{});
460 
461  aDlgAttr.Put(aEditAttr);
462 
463  aDlgAttr.Put( SvxHyphenZoneItem( false, RES_PARATR_HYPHENZONE) );
464  aDlgAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, RES_BREAK ) );
465  aDlgAttr.Put( SvxFormatSplitItem( true, RES_PARATR_SPLIT ) );
466  aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
467  aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
468 
471  sal_uInt16 nRet = pDlg->Execute();
472  if(RET_OK == nRet)
473  {
474  rReq.Done( *( pDlg->GetOutputItemSet() ) );
475  aNewAttr.Put(*pDlg->GetOutputItemSet());
476  }
477  if(RET_OK != nRet)
478  return;
479  }
480  else
481  aNewAttr.Put(*pArgs);
482  }
483  break;
484  case SID_AUTOSPELL_CHECK:
485  {
488  SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
489  EEControlBits nCtrl = pOutliner->GetControlWord();
490 
491  bool bSet = static_cast<const SfxBoolItem&>(rReq.GetArgs()->Get(
492  nSlot)).GetValue();
493  if(bSet)
494  nCtrl |= EEControlBits::ONLINESPELLING|EEControlBits::ALLOWBIGOBJS;
495  else
496  nCtrl &= ~EEControlBits::ONLINESPELLING;
497  pOutliner->SetControlWord(nCtrl);
498 
499  rView.ExecuteSlot(rReq);
500  }
501  break;
502  case SID_HYPERLINK_SETLINK:
503  {
504  const SfxPoolItem* pItem = nullptr;
505  if(pNewAttrs)
506  pNewAttrs->GetItemState(nSlot, false, &pItem);
507 
508  if(pItem)
509  {
510  const SvxHyperlinkItem& rHLinkItem = *static_cast<const SvxHyperlinkItem *>(pItem);
511  SvxURLField aField(rHLinkItem.GetURL(), rHLinkItem.GetName(), SvxURLFormat::AppDefault);
512  aField.SetTargetFrame(rHLinkItem.GetTargetFrame());
513 
514  const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
515 
516  if (pFieldItem && dynamic_cast< const SvxURLField *>( pFieldItem->GetField() ) != nullptr )
517  {
518  // Select field so that it will be deleted during insert
519  ESelection aSel = pOLV->GetSelection();
520  aSel.nEndPos++;
521  pOLV->SetSelection(aSel);
522  }
523  pOLV->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD));
524  }
525  }
526  break;
527 
528  case SID_EDIT_HYPERLINK:
529  {
530  // Ensure the field is selected first
531  pOLV->SelectFieldAtCursor();
532  GetView().GetViewFrame()->GetDispatcher()->Execute(SID_HYPERLINK_DIALOG);
533  }
534  break;
535 
536  case SID_REMOVE_HYPERLINK:
537  {
538  // Ensure the field is selected first
539  pOLV->SelectFieldAtCursor();
541  pOLV);
542  }
543  break;
544 
545  case SID_OPEN_HYPERLINK:
546  {
547  const SvxFieldData* pField = pOLV->GetFieldAtCursor();
548  if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
549  {
550  SfxStringItem aUrl(SID_FILE_NAME, pURLField->GetURL());
551  SfxStringItem aTarget(SID_TARGETNAME, pURLField->GetTargetFrame());
552  SfxBoolItem aNewView(SID_OPEN_NEW_VIEW, false);
553  SfxBoolItem aBrowsing(SID_BROWSE, true);
555  SID_OPENDOC, SfxCallMode::SYNCHRON, { &aUrl, &aTarget, &aNewView, &aBrowsing });
556  }
557  }
558  break;
559 
560  case SID_COPY_HYPERLINK_LOCATION:
561  {
562  const SvxFieldData* pField = pOLV->GetFieldAtCursor();
563  if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
564  {
565  uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
567  vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
568  }
569  }
570  break;
571 
572  case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
573  case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
574  // Shell switch!
575  {
577  SdrPageView* pTmpPV = pSdrView->GetSdrPageView();
578  SdrView* pTmpView = pSdrView;
579 
580  pSdrView->SdrEndTextEdit(true);
581 
582  SfxItemSet aAttr( *aNewAttr.GetPool(),
584  SDRATTR_TEXTDIRECTION>{} );
585 
586  aAttr.Put( SvxWritingModeItem(
587  nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
588  text::WritingMode_LR_TB
589  : text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION ) );
590  pTmpView->SetAttributes( aAttr );
591 
592  rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin());
593  rSh.GetView().AttrChangedNotify(nullptr);
594  }
595  return;
596 
597  case SID_ATTR_PARA_LEFT_TO_RIGHT:
598  case SID_ATTR_PARA_RIGHT_TO_LEFT:
599  {
601  SdrPageView* pTmpPV = pSdrView->GetSdrPageView();
602  SdrView* pTmpView = pSdrView;
603 
604  pSdrView->SdrEndTextEdit(true);
605  bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
606 
607  const SfxPoolItem* pPoolItem;
608  if( pNewAttrs && SfxItemState::SET == pNewAttrs->GetItemState( nSlot, true, &pPoolItem ) )
609  {
610  if( !static_cast<const SfxBoolItem*>(pPoolItem)->GetValue() )
611  bLeftToRight = !bLeftToRight;
612  }
613  SfxItemSet aAttr(
614  *aNewAttr.GetPool(),
615  svl::Items<
616  EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
617  EE_PARA_JUST, EE_PARA_JUST>{});
618 
619  SvxAdjust nAdjust = SvxAdjust::Left;
620  if( SfxItemState::SET == aEditAttr.GetItemState(EE_PARA_JUST, true, &pPoolItem ) )
621  nAdjust = static_cast<const SvxAdjustItem*>(pPoolItem)->GetAdjust();
622 
623  if( bLeftToRight )
624  {
625  aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) );
626  if( nAdjust == SvxAdjust::Right )
627  aAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
628  }
629  else
630  {
631  aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) );
632  if( nAdjust == SvxAdjust::Left )
633  aAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
634  }
635  pTmpView->SetAttributes( aAttr );
636  rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin() );
637  rSh.GetView().AttrChangedNotify(nullptr);
638  }
639  return;
640 
641  case FN_GROW_FONT_SIZE:
642  case FN_SHRINK_FONT_SIZE:
643  {
644  const SvxFontListItem* pFontListItem = static_cast< const SvxFontListItem* >
645  ( SfxObjectShell::Current()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
646  const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
647  pOLV->GetEditView().ChangeFontSize( nSlot == FN_GROW_FONT_SIZE, pFontList );
648  }
649  break;
650 
651  default:
652  assert(false && "wrong dispatcher");
653  return;
654  }
655 
656  std::unique_ptr<SfxItemSet> pNewArgs = pNewAttrs ? pNewAttrs->Clone() : nullptr;
657  if (pNewArgs)
658  {
659  lcl_convertStringArguments(nSlot, pNewArgs);
660 
661  if (nEEWhich)
662  {
663  std::unique_ptr<SfxPoolItem> pNewItem(pNewArgs->Get(nWhich).CloneSetWhich(nEEWhich));
664  pNewArgs->Put(*pNewItem);
665  }
666 
667  SetAttrToMarked(*pNewArgs);
668  }
669 
671 
672  if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
673  rSh.SetModified();
674 
675  if (bRestoreSelection)
676  {
677  // restore selection
678  pOLV->GetEditView().SetSelection( aOldSelection );
679  }
680 }
681 
683 {
684  if (!IsTextEdit()) // Otherwise sometimes crash!
685  return;
686 
688  SfxWhichIter aIter(rSet);
689  sal_uInt16 nWhich = aIter.FirstWhich();
690 
691  SfxItemSet aEditAttr(pOLV->GetAttribs());
692  const SfxPoolItem *pAdjust = nullptr, *pLSpace = nullptr, *pEscItem = nullptr;
693  SvxAdjust eAdjust;
694  int nLSpace;
695  SvxEscapement nEsc;
696 
697  while (nWhich)
698  {
699  sal_uInt16 nSlotId = GetPool().GetSlotId(nWhich);
700  bool bFlag = false;
701  switch (nSlotId)
702  {
703  case SID_LANGUAGE_STATUS: //20412:
704  {
706  nSlotId = 0;
707  break;
708  }
709 
710  case SID_THES:
711  {
712  OUString aStatusVal;
714  bool bIsLookUpWord
715  = GetStatusValueForThesaurusFromContext(aStatusVal, nLang, pOLV->GetEditView());
716  rSet.Put(SfxStringItem(SID_THES, aStatusVal));
717 
718  // disable "Thesaurus" context menu entry if there is nothing to look up
719  uno::Reference<linguistic2::XThesaurus> xThes(::GetThesaurus());
720  if (!bIsLookUpWord || !xThes.is() || nLang == LANGUAGE_NONE
721  || !xThes->hasLocale(LanguageTag::convertToLocale(nLang)))
722  rSet.DisableItem(SID_THES);
723 
725  nSlotId = 0;
726  break;
727  }
728 
729  case SID_ATTR_PARA_ADJUST_LEFT:
730  eAdjust = SvxAdjust::Left;
731  goto ASK_ADJUST;
732  case SID_ATTR_PARA_ADJUST_RIGHT:
733  eAdjust = SvxAdjust::Right;
734  goto ASK_ADJUST;
735  case SID_ATTR_PARA_ADJUST_CENTER:
736  eAdjust = SvxAdjust::Center;
737  goto ASK_ADJUST;
738  case SID_ATTR_PARA_ADJUST_BLOCK:
739  eAdjust = SvxAdjust::Block;
740  goto ASK_ADJUST;
741  ASK_ADJUST:
742  {
743  if (!pAdjust)
744  aEditAttr.GetItemState(EE_PARA_JUST, false, &pAdjust);
745 
746  if (!pAdjust || IsInvalidItem(pAdjust))
747  {
748  rSet.InvalidateItem(nSlotId);
749  nSlotId = 0;
750  }
751  else
752  bFlag = eAdjust == static_cast<const SvxAdjustItem*>(pAdjust)->GetAdjust();
753  }
754  break;
755 
756  case SID_ATTR_PARA_LRSPACE:
757  case SID_ATTR_PARA_LEFTSPACE:
758  case SID_ATTR_PARA_RIGHTSPACE:
759  case SID_ATTR_PARA_FIRSTLINESPACE:
760  {
761  SfxItemState eState = aEditAttr.GetItemState(EE_PARA_LRSPACE);
762  if (eState >= SfxItemState::DEFAULT)
763  {
764  SvxLRSpaceItem aLR = aEditAttr.Get(EE_PARA_LRSPACE);
765  aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
766  rSet.Put(aLR);
767  }
768  else
769  rSet.InvalidateItem(nSlotId);
770  nSlotId = 0;
771  }
772  break;
773  case SID_ATTR_PARA_LINESPACE:
774  {
775  SfxItemState eState = aEditAttr.GetItemState(EE_PARA_SBL);
776  if (eState >= SfxItemState::DEFAULT)
777  {
778  const SvxLineSpacingItem& aLR = aEditAttr.Get(EE_PARA_SBL);
779  rSet.Put(aLR);
780  }
781  else
782  rSet.InvalidateItem(nSlotId);
783  nSlotId = 0;
784  }
785  break;
786  case SID_ATTR_PARA_ULSPACE:
787  case SID_ATTR_PARA_BELOWSPACE:
788  case SID_ATTR_PARA_ABOVESPACE:
789  case SID_PARASPACE_INCREASE:
790  case SID_PARASPACE_DECREASE:
791  {
792  SfxItemState eState = aEditAttr.GetItemState(EE_PARA_ULSPACE);
793  if (eState >= SfxItemState::DEFAULT)
794  {
795  SvxULSpaceItem aULSpace = aEditAttr.Get(EE_PARA_ULSPACE);
796  if (!aULSpace.GetUpper() && !aULSpace.GetLower())
797  rSet.DisableItem(SID_PARASPACE_DECREASE);
798  else if (aULSpace.GetUpper() >= 5670 && aULSpace.GetLower() >= 5670)
799  rSet.DisableItem(SID_PARASPACE_INCREASE);
800  if (nSlotId == SID_ATTR_PARA_ULSPACE || nSlotId == SID_ATTR_PARA_ABOVESPACE
801  || nSlotId == SID_ATTR_PARA_BELOWSPACE)
802  {
803  aULSpace.SetWhich(nSlotId);
804  rSet.Put(aULSpace);
805  }
806  }
807  else
808  {
809  rSet.DisableItem(SID_PARASPACE_INCREASE);
810  rSet.DisableItem(SID_PARASPACE_DECREASE);
811  rSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
812  rSet.InvalidateItem(SID_ATTR_PARA_ABOVESPACE);
813  rSet.InvalidateItem(SID_ATTR_PARA_BELOWSPACE);
814  }
815  nSlotId = 0;
816  }
817  break;
818 
819  case SID_ATTR_PARA_LINESPACE_10:
820  nLSpace = 100;
821  goto ASK_LINESPACE;
822  case SID_ATTR_PARA_LINESPACE_15:
823  nLSpace = 150;
824  goto ASK_LINESPACE;
825  case SID_ATTR_PARA_LINESPACE_20:
826  nLSpace = 200;
827  goto ASK_LINESPACE;
828  ASK_LINESPACE:
829  {
830  if (!pLSpace)
831  aEditAttr.GetItemState(EE_PARA_SBL, false, &pLSpace);
832 
833  if (!pLSpace || IsInvalidItem(pLSpace))
834  {
835  rSet.InvalidateItem(nSlotId);
836  nSlotId = 0;
837  }
838  else if (nLSpace
839  == static_cast<const SvxLineSpacingItem*>(pLSpace)->GetPropLineSpace())
840  bFlag = true;
841  else
842  nSlotId = 0;
843  }
844  break;
845 
846  case FN_SET_SUPER_SCRIPT:
847  nEsc = SvxEscapement::Superscript;
848  goto ASK_ESCAPE;
849  case FN_SET_SUB_SCRIPT:
850  nEsc = SvxEscapement::Subscript;
851  goto ASK_ESCAPE;
852  ASK_ESCAPE:
853  {
854  if (!pEscItem)
855  pEscItem = &aEditAttr.Get(EE_CHAR_ESCAPEMENT);
856 
857  if (nEsc == static_cast<const SvxEscapementItem*>(pEscItem)->GetEscapement())
858  bFlag = true;
859  else
860  nSlotId = 0;
861  }
862  break;
863 
864  case SID_THESAURUS:
865  {
866  // disable "Thesaurus" if the language is not supported
870  LanguageType nLang = static_cast<const SvxLanguageItem&>(rItem).GetLanguage();
871 
872  uno::Reference<linguistic2::XThesaurus> xThes(::GetThesaurus());
873  if (!xThes.is() || nLang == LANGUAGE_NONE
874  || !xThes->hasLocale(LanguageTag::convertToLocale(nLang)))
875  rSet.DisableItem(SID_THESAURUS);
876  nSlotId = 0;
877  }
878  break;
879  case SID_HANGUL_HANJA_CONVERSION:
880  case SID_CHINESE_CONVERSION:
881  {
882  if (!SvtCJKOptions().IsAnyEnabled())
883  {
884  GetView().GetViewFrame()->GetBindings().SetVisibleState(nWhich, false);
885  rSet.DisableItem(nWhich);
886  }
887  else
888  GetView().GetViewFrame()->GetBindings().SetVisibleState(nWhich, true);
889  }
890  break;
891 
892  case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
893  case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
894  if (!SvtLanguageOptions().IsVerticalTextEnabled())
895  {
896  rSet.DisableItem(nSlotId);
897  nSlotId = 0;
898  }
899  else
900  {
901  SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
902  if (pOutliner)
903  bFlag = pOutliner->IsVertical()
904  == (SID_TEXTDIRECTION_TOP_TO_BOTTOM == nSlotId);
905  else
906  {
907  text::WritingMode eMode = aEditAttr.Get(SDRATTR_TEXTDIRECTION).GetValue();
908 
909  if (nSlotId == SID_TEXTDIRECTION_LEFT_TO_RIGHT)
910  {
911  bFlag = eMode == text::WritingMode_LR_TB;
912  }
913  else
914  {
915  bFlag = eMode != text::WritingMode_TB_RL;
916  }
917  }
918  }
919  break;
920  case SID_ATTR_PARA_LEFT_TO_RIGHT:
921  case SID_ATTR_PARA_RIGHT_TO_LEFT:
922  {
923  if (!SvtLanguageOptions().IsCTLFontEnabled())
924  {
925  rSet.DisableItem(nWhich);
926  nSlotId = 0;
927  }
928  else
929  {
930  SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
931  if (pOutliner && pOutliner->IsVertical())
932  {
933  rSet.DisableItem(nWhich);
934  nSlotId = 0;
935  }
936  else
937  {
938  switch (aEditAttr.Get(EE_PARA_WRITINGDIR).GetValue())
939  {
940  case SvxFrameDirection::Horizontal_LR_TB:
941  bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
942  break;
943 
944  case SvxFrameDirection::Horizontal_RL_TB:
945  bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
946  break;
947  default:
948  break;
949  }
950  }
951  }
952  }
953  break;
954  case SID_TRANSLITERATE_HALFWIDTH:
955  case SID_TRANSLITERATE_FULLWIDTH:
956  case SID_TRANSLITERATE_HIRAGANA:
957  case SID_TRANSLITERATE_KATAKANA:
958  {
959  SvtCJKOptions aCJKOptions;
960  if (!aCJKOptions.IsChangeCaseMapEnabled())
961  {
962  rSet.DisableItem(nWhich);
963  GetView().GetViewFrame()->GetBindings().SetVisibleState(nWhich, false);
964  }
965  else
966  GetView().GetViewFrame()->GetBindings().SetVisibleState(nWhich, true);
967  }
968  break;
969  case SID_INSERT_RLM:
970  case SID_INSERT_LRM:
971  {
972  SvtCTLOptions aCTLOptions;
973  bool bEnabled = aCTLOptions.IsCTLFontEnabled();
974  GetView().GetViewFrame()->GetBindings().SetVisibleState(nWhich, bEnabled);
975  if (!bEnabled)
976  rSet.DisableItem(nWhich);
977  }
978  break;
979  case SID_REMOVE_HYPERLINK:
980  case SID_EDIT_HYPERLINK:
981  case SID_OPEN_HYPERLINK:
982  case SID_COPY_HYPERLINK_LOCATION:
983  {
985  rSet.DisableItem(nWhich);
986  }
987  break;
988  default:
989  nSlotId = 0; // don't know this slot
990  break;
991  }
992 
993  if (nSlotId && bFlag)
994  rSet.Put(SfxBoolItem(nWhich, bFlag));
995 
996  nWhich = aIter.NextWhich();
997  }
998 }
999 
1001 {
1002  if (!IsTextEdit()) // Otherwise crash!
1003  return;
1004 
1006  SfxItemSet aEditAttr(pOLV->GetAttribs());
1007 
1008  SfxWhichIter aIter(rSet);
1009  sal_uInt16 nWhich = aIter.FirstWhich();
1010  SvtScriptType nScriptType = pOLV->GetSelectedScriptType();
1011  while(nWhich)
1012  {
1013  sal_uInt16 nEEWhich = 0;
1014  sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
1015  switch( nSlotId )
1016  {
1017  case SID_ATTR_CHAR_FONT:
1018  case SID_ATTR_CHAR_FONTHEIGHT:
1019  case SID_ATTR_CHAR_WEIGHT:
1020  case SID_ATTR_CHAR_POSTURE:
1021  {
1022  SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool();
1023  if( !pEditPool )
1024  pEditPool = aEditAttr.GetPool();
1025  SvxScriptSetItem aSetItem( nSlotId, *pEditPool );
1026  aSetItem.GetItemSet().Put( aEditAttr, false );
1027  const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
1028  if( pI )
1029  {
1030  rSet.Put(pI->CloneSetWhich(nWhich));
1031  }
1032  else
1033  rSet.InvalidateItem( nWhich );
1034  }
1035  break;
1036  case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
1037  case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break;
1038  case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
1039  case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
1040  case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
1041  case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break;
1042  case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
1043  case SID_AUTOSPELL_CHECK:
1044  {
1045  const SfxPoolItem* pState = rView.GetSlotState(nWhich);
1046  if (pState)
1047  rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(pState)->GetValue()));
1048  else
1049  rSet.DisableItem( nWhich );
1050  break;
1051  }
1052  case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
1053  case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
1054  case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
1055  case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
1056  case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH;break;
1057  case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
1058  case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
1059  case FN_GROW_FONT_SIZE:
1060  case FN_SHRINK_FONT_SIZE:
1061  {
1062  SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool();
1063  if( !pEditPool )
1064  pEditPool = aEditAttr.GetPool();
1065 
1066  SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, *pEditPool );
1067  aSetItem.GetItemSet().Put( aEditAttr, false );
1068  const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptType ) ) );
1069 
1070  if( pSize )
1071  {
1072  sal_uInt32 nSize = pSize->GetHeight();
1073  if( nSize >= 19998 )
1075  else if( nSize <= 40 )
1077  }
1078  }
1079  }
1080  if(nEEWhich)
1081  {
1082  rSet.Put(aEditAttr.Get(nEEWhich).CloneSetWhich(nWhich));
1083  }
1084 
1085  nWhich = aIter.NextWhich();
1086  }
1087 }
1088 
1090 {
1091  if (!IsTextEdit()) // Otherwise crash!
1092  return;
1093 
1095 
1096  ESelection aSel(pOLV->GetSelection());
1097  const bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos);
1098  sal_uInt16 nId = rReq.GetSlot();
1099  switch( nId )
1100  {
1101  case SID_CUT:
1102  if (bCopy)
1103  pOLV->Cut();
1104  return;
1105 
1106  case SID_COPY:
1107  if (bCopy)
1108  pOLV->Copy();
1109  return;
1110 
1111  case SID_PASTE:
1112  pOLV->PasteSpecial();
1113  break;
1114 
1115  case SID_PASTE_UNFORMATTED:
1116  pOLV->Paste();
1117  break;
1118 
1119  case SID_PASTE_SPECIAL:
1120  {
1122  ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(GetView().GetEditWin().GetFrameWeld()));
1123 
1124  pDlg->Insert(SotClipboardFormatId::STRING, OUString());
1125  pDlg->Insert(SotClipboardFormatId::RTF, OUString());
1126  pDlg->Insert(SotClipboardFormatId::RICHTEXT, OUString());
1127 
1129  SotClipboardFormatId nFormat = pDlg->GetFormat(aDataHelper.GetTransferable());
1130 
1131  if (nFormat != SotClipboardFormatId::NONE)
1132  {
1133  if (nFormat == SotClipboardFormatId::STRING)
1134  pOLV->Paste();
1135  else
1136  pOLV->PasteSpecial();
1137  }
1138 
1139  break;
1140  }
1141 
1142  case SID_CLIPBOARD_FORMAT_ITEMS:
1143  {
1144  SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
1145  const SfxPoolItem* pItem;
1146  if (rReq.GetArgs() && rReq.GetArgs()->GetItemState(nId, true, &pItem) == SfxItemState::SET)
1147  {
1148  if (const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item *>(pItem))
1149  nFormat = static_cast<SotClipboardFormatId>(pUInt32Item->GetValue());
1150  }
1151 
1152  if (nFormat != SotClipboardFormatId::NONE)
1153  {
1154  if (nFormat == SotClipboardFormatId::STRING)
1155  pOLV->Paste();
1156  else
1157  pOLV->PasteSpecial();
1158  }
1159 
1160  break;
1161  }
1162 
1163  default:
1164  OSL_FAIL("wrong dispatcher");
1165  return;
1166  }
1167 }
1168 
1170 {
1171  if (!IsTextEdit()) // Otherwise crash!
1172  return;
1173 
1175  ESelection aSel(pOLV->GetSelection());
1176  const bool bCopy = (aSel.nStartPara != aSel.nEndPara) ||
1177  (aSel.nStartPos != aSel.nEndPos);
1178 
1180  const bool bPaste = aDataHelper.HasFormat( SotClipboardFormatId::STRING ) ||
1181  aDataHelper.HasFormat( SotClipboardFormatId::RTF ) ||
1182  aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT );
1183 
1184  SfxWhichIter aIter(rSet);
1185  sal_uInt16 nWhich = aIter.FirstWhich();
1186 
1187  while(nWhich)
1188  {
1189  switch(nWhich)
1190  {
1191  case SID_CUT:
1192  case SID_COPY:
1193  if( !bCopy || GetView().isContentExtractionLocked())
1194  rSet.DisableItem( nWhich );
1195  break;
1196 
1197  case SID_PASTE:
1198  case SID_PASTE_UNFORMATTED:
1199  case SID_PASTE_SPECIAL:
1200  if( !bPaste )
1201  rSet.DisableItem( nWhich );
1202  break;
1203 
1204  case SID_CLIPBOARD_FORMAT_ITEMS:
1205  if( bPaste )
1206  {
1207  SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
1208 
1209  if ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) )
1210  aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
1211  if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
1212  aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
1213  if ( aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) )
1214  aFormats.AddClipbrdFormat( SotClipboardFormatId::RICHTEXT );
1215 
1216  rSet.Put( aFormats );
1217  }
1218  else
1219  rSet.DisableItem( nWhich );
1220  break;
1221  }
1222 
1223  nWhich = aIter.NextWhich();
1224  }
1225 }
1226 
1227 // Hyperlink status
1228 
1230 {
1231  if (!IsTextEdit()) // Otherwise crash!
1232  return;
1233 
1235  SfxWhichIter aIter(rSet);
1236  sal_uInt16 nWhich = aIter.FirstWhich();
1237 
1238  while(nWhich)
1239  {
1240  switch(nWhich)
1241  {
1242  case SID_HYPERLINK_GETLINK:
1243  {
1244  SvxHyperlinkItem aHLinkItem;
1245  aHLinkItem.SetInsertMode(HLINK_FIELD);
1246 
1247  const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
1248 
1249  if (pFieldItem)
1250  {
1251  const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pFieldItem->GetField());
1252 
1253  if (pURLField)
1254  {
1255  aHLinkItem.SetName(pURLField->GetRepresentation());
1256  aHLinkItem.SetURL(pURLField->GetURL());
1257  aHLinkItem.SetTargetFrame(pURLField->GetTargetFrame());
1258  }
1259  }
1260  else
1261  {
1262  OUString sSel(pOLV->GetSelected());
1263  sSel = sSel.copy(0, std::min<sal_Int32>(255, sSel.getLength()));
1264  aHLinkItem.SetName(comphelper::string::stripEnd(sSel, ' '));
1265  }
1266 
1267  sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1268  aHLinkItem.SetInsertMode(static_cast<SvxLinkInsertMode>(aHLinkItem.GetInsertMode() |
1269  ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
1270 
1271  rSet.Put(aHLinkItem);
1272  }
1273  break;
1274  }
1275  nWhich = aIter.NextWhich();
1276  }
1277 }
1278 
1279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
void SetURL(const OUString &rURL)
SfxViewFrame * GetViewFrame() const
#define LANGUAGE_NONE
#define EE_CHAR_ESCAPEMENT
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
void SetTargetFrame(const OUString &rFrm)
#define EE_ITEMS_START
FieldUnit
OString stripEnd(const OString &rIn, sal_Char c)
void PasteSpecial()
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
void PutItemForScriptType(SvtScriptType nScriptType, const SfxPoolItem &rItem)
sal_uInt16 GetLower() const
#define LINE_SPACE_DEFAULT_HEIGHT
void SetEscapement(const SvxEscapement eNew)
#define FN_SET_SUPER_SCRIPT
Definition: cmdid.h:290
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:79
bool BeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, bool bSetSelectionToStart=false)
Definition: viewdraw.cxx:507
SdrView * pSdrView
Definition: drwtxtsh.hxx:35
void SelectPara(EditView &rEditView, const ESelection &rCurSel)
Definition: langhelper.cxx:567
void SelectFieldAtCursor()
#define EE_CHAR_LANGUAGE
virtual const SfxItemSet * GetOutputItemSet() const =0
std::string GetValue
short GetTextFirstLineOfst() const
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard()
const OUString & GetTargetFrame() const
static void HandleOpenXmlFilterSettings(SfxRequest &)
SfxDispatcher * GetDispatcher()
static SvxAbstractDialogFactory * Create()
#define EE_CHAR_KERNING
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:402
void GetState(SfxItemSet &)
Definition: drwtxtex.cxx:682
static bool IsCursorAtURLField(const OutlinerView *pOLV)
bool HasSelection() const
void InvalidateItem(sal_uInt16 nWhich)
#define EE_PARA_JUST
sal_Int16 nId
sal_uInt16 FirstWhich()
void SetTextLeft(const long nL, const sal_uInt16 nProp=100)
SwEditWin & GetEditWin()
Definition: view.hxx:403
void Execute(SfxRequest &)
Definition: drwtxtex.cxx:144
void Done(bool bRemove=false)
SdrMark * GetMark(size_t nNum) const
void ChangeFontSize(bool bGrow, const FontList *pList)
static SfxObjectShell * Current()
void SetModified()
Definition: edws.cxx:69
const SfxItemSet * GetArgs() const
void SelectCurrentWord(sal_Int16 nWordType=css::i18n::WordType::ANYWORD_IGNOREWHITESPACES)
void ExecClpbrd(SfxRequest const &rReq)
Definition: drwtxtex.cxx:1089
#define RES_PARATR_SPLIT
Definition: hintids.hxx:164
bool IsCTLFontEnabled() const
void StateInsert(SfxItemSet &rSet)
Definition: drwtxtex.cxx:1229
bool HasFormat(SotClipboardFormatId nFormat) const
EEControlBits
const OUString & GetTargetFrame() const
sal_uInt16 NextWhich()
static LanguageType nLang
Definition: srtdlg.cxx:60
#define EE_CHAR_FONTWIDTH
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
void GetDrawTextCtrlState(SfxItemSet &)
Definition: drwtxtex.cxx:1000
#define EE_PARA_ULSPACE
void StateClpbrd(SfxItemSet &rSet)
Definition: drwtxtex.cxx:1169
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
void UpdateWordCount(SfxShell *, sal_uInt16)
Definition: view1.cxx:208
void SetTargetFrame(const OUString &rTarget)
const SwView & GetView() const
Definition: wrtsh.hxx:428
void SetPropLineSpace(const sal_uInt16 nProp)
LINESTYLE_NONE
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:650
static TransferableDataHelper CreateFromSystemClipboard(vcl::Window *pWindow)
HLINK_HTMLMODE
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
SotClipboardFormatId
sal_Int32 nEndPos
#define EE_CHAR_BKGCOLOR
#define EE_CHAR_OVERLINE
bool SetLanguageStatus(OutlinerView *pOLV, SfxRequest &rReq, SwView const &rView, SwWrtShell &rSh)
Definition: langhelper.cxx:102
SwView & rView
Definition: drwtxtsh.hxx:32
EditView & GetEditView() const
#define FN_SHRINK_FONT_SIZE
Definition: cmdid.h:288
SfxItemPool & GetPool() const
bool IsChangeCaseMapEnabled() const
SdrObject * GetMarkedSdrObj() const
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
#define EE_PARA_LRSPACE
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
void SetRight(const long nR, const sal_uInt16 nProp=100)
#define FN_SET_SUB_SCRIPT
Definition: cmdid.h:291
const SdrOutliner * GetTextEditOutliner() const
SvtScriptType
#define FN_NUMBERING_OUTLINE_DLG
Definition: cmdid.h:473
const OUString & GetURL() const
#define SW_MOD()
Definition: swmodule.hxx:256
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:709
SvxAdjust
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
#define EE_PARA_WRITINGDIR
const SvxFieldItem * GetFieldAtSelection() const
#define EE_CHAR_UNDERLINE
#define EE_FEATURE_FIELD
SfxBindings & GetBindings()
const OUString & GetValue() const
const SdrMarkList & GetMarkedObjectList() const
#define RES_PARATR_HYPHENZONE
Definition: hintids.hxx:168
HTMLMODE_ON
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:340
#define RES_PARATR_ORPHANS
Definition: hintids.hxx:165
const T * GetArg(sal_uInt16 nSlotId) const
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
#define EE_CHAR_SHADOW
OUString GetSelected() const
void ExecFormatFootnote()
Definition: view0.cxx:630
static sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
LINESTYLE_SINGLE
SvtScriptType GetSelectedScriptType() const
static void RemoveURLField(Outliner *pOutl, const OutlinerView *pOLV)
virtual void SetCurPageId(const OString &rName)=0
void GetLanguageStatus(OutlinerView *pOLV, SfxItemSet &rSet)
Definition: langhelper.cxx:62
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
Definition: hints.cxx:195
bool IsModified() const
#define EE_CHAR_COLOR
#define SDRATTR_TEXTDIRECTION
void Paste(bool bUseSpecial=false)
const OutlinerView * GetTextEditOutlinerView() const
HLINK_FIELD
Outliner * GetOutliner() const
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
const OUString & GetRepresentation() const
#define FN_WORDCOUNT_DIALOG
Definition: cmdid.h:575
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
void SetName(const OUString &rName)
void InsertField(const SvxFieldItem &rFld)
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
SfxItemPool * GetPool() const
static void CopyStringTo(const OUString &rContent, const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rxClipboard)
const OUString & GetURL() const
#define RES_CHRATR_KERNING
Definition: hintids.hxx:78
ESelection GetSelection() const
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
FontLineStyle GetLineStyle() const
#define EE_PARA_SBL
#define EE_CHAR_PAIRKERNING
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwView & GetView()
Definition: drwtxtsh.hxx:49
sal_uInt16 GetSlot() const
void SetSelection(const ESelection &)
#define EE_CHAR_RELIEF
#define EE_CHAR_OUTLINE
sal_uInt32 GetHeight() const
bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext(OUString &rStatusVal, LanguageType &rLang, const EditView &rEditView)
bool IsTextEdit() const
Definition: drwtxtsh.cxx:176
SfxItemState
void DisableItem(sal_uInt16 nWhich)
void SetTextFirstLineOfst(const short nF, const sal_uInt16 nProp=100)
weld::Window * GetFrameWeld() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
void ExecNumberingOutline(SfxItemPool &)
Definition: view0.cxx:637
#define GetWhich(nSlot)
virtual std::unique_ptr< SfxItemSet > Clone(bool bItems=true, SfxItemPool *pToPool=nullptr) const
uno::Reference< linguistic2::XThesaurus > GetThesaurus()
Definition: swtypes.cxx:55
LanguageType GetAppLanguage()
Definition: init.cxx:729
RET_OK
const SvxFieldData * GetFieldAtCursor() const
SwWrtShell & GetShell()
Definition: drwtxtsh.cxx:146
void SetAttrToMarked(const SfxItemSet &rAttr)
Definition: drwtxtsh.cxx:165
#define FN_GROW_FONT_SIZE
Definition: cmdid.h:287
long GetRight() const
void SetInsertMode(SvxLinkInsertMode eNew)
SdrPageView * GetSdrPageView() const
#define FN_FORMAT_FOOTNOTE_DLG
Definition: cmdid.h:307
void SetSelection(const ESelection &rNewSel)
void AddClipbrdFormat(SotClipboardFormatId nId)
#define RES_PARATR_WIDOWS
Definition: hintids.hxx:166
SvxEscapement
void SetVisibleState(sal_uInt16 nId, bool bShow)
const OUString & GetName() const
SvxLinkInsertMode GetInsertMode() const
void InvalidateAll(bool bWithMsg)
SVX_DLLPUBLIC MSO_SPT Get(const OUString &)
SfxItemSet GetAttribs()
ESelection GetSelection() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const FontList * GetFontList() const
virtual VclPtr< SfxAbstractTabDialog > CreateSwCharDlg(weld::Window *pParent, SwView &pVw, const SfxItemSet &rCoreSet, SwCharDlgMode nDialogMode, const OUString *pFormatStr=nullptr)=0
bool IsInvalidItem(const SfxPoolItem *pItem)
#define RES_BREAK
Definition: hintids.hxx:201
FontLineStyle
const css::uno::Reference< css::datatransfer::XTransferable > & GetTransferable() const
long GetTextLeft() const
#define EE_CHAR_STRIKEOUT
virtual VclPtr< SfxAbstractTabDialog > CreateSwParaDlg(weld::Window *pParent, SwView &rVw, const SfxItemSet &rCoreSet, bool bDraw, const OString &sDefPage=OString())=0
const SfxPoolItem * GetItemOfScript(SvtScriptType nScript) const
void EDITENG_DLLPUBLIC ReplaceTextWithSynonym(EditView &rEditView, const OUString &rSynonmText)
Definition: view.hxx:146
sal_uInt16 GetUpper() const
const SvxFieldData * GetField() const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
#define EE_CHAR_WLM
#define EE_ITEMS_END