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