Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / shells / drwtxtex.cxx
blob44ad4bd820582d87fd05bc4e2a0821cbf3e6d423
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <com/sun/star/linguistic2/XThesaurus.hpp>
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>
32 #include <editeng/formatbreakitem.hxx>
33 #include <editeng/widwitem.hxx>
34 #include <editeng/kernitem.hxx>
35 #include <editeng/escapementitem.hxx>
36 #include <editeng/lspcitem.hxx>
37 #include <editeng/flstitem.hxx>
38 #include <editeng/adjustitem.hxx>
39 #include <editeng/udlnitem.hxx>
40 #include <editeng/fhgtitem.hxx>
41 #include <editeng/colritem.hxx>
42 #include <editeng/frmdiritem.hxx>
43 #include <editeng/urlfieldhelper.hxx>
44 #include <svx/svdoutl.hxx>
45 #include <sfx2/viewfrm.hxx>
46 #include <svl/stritem.hxx>
47 #include <svl/whiter.hxx>
48 #include <svl/cjkoptions.hxx>
49 #include <svl/ctloptions.hxx>
50 #include <svl/languageoptions.hxx>
51 #include <editeng/flditem.hxx>
52 #include <editeng/editstat.hxx>
53 #include <svx/clipfmtitem.hxx>
54 #include <svx/hlnkitem.hxx>
55 #include <svx/svxdlg.hxx>
56 #include <sfx2/htmlmode.hxx>
57 #include <editeng/langitem.hxx>
58 #include <editeng/scripttypeitem.hxx>
59 #include <editeng/writingmodeitem.hxx>
60 #include <editeng/eeitem.hxx>
61 #include <editeng/editdata.hxx>
62 #include <editeng/outliner.hxx>
63 #include <editeng/editview.hxx>
64 #include <vcl/unohelp2.hxx>
65 #include <editeng/hyphenzoneitem.hxx>
66 #include <osl/diagnose.h>
68 #include <cmdid.h>
69 #include <doc.hxx>
70 #include <drwtxtsh.hxx>
71 #include <edtwin.hxx>
72 #include <hintids.hxx>
73 #include <langhelper.hxx>
74 #include <chrdlgmodes.hxx>
75 #include <swmodule.hxx>
76 #include <uitool.hxx>
77 #include <viewopt.hxx>
78 #include <wrtsh.hxx>
79 #include <wview.hxx>
81 #include <swabstdlg.hxx>
83 using namespace ::com::sun::star;
85 void SwDrawTextShell::Execute( SfxRequest &rReq )
87 SwWrtShell &rSh = GetShell();
88 OutlinerView* pOLV = m_pSdrView->GetTextEditOutlinerView();
89 SfxItemSet aEditAttr(pOLV->GetAttribs());
90 SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
92 const sal_uInt16 nSlot = rReq.GetSlot();
94 const sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
95 std::unique_ptr<SfxItemSet> pNewAttrs(rReq.GetArgs() ? rReq.GetArgs()->Clone() : nullptr);
97 bool bRestoreSelection = false;
98 ESelection aOldSelection;
100 sal_uInt16 nEEWhich = 0;
101 switch (nSlot)
103 case SID_LANGUAGE_STATUS:
105 aOldSelection = pOLV->GetSelection();
106 if (!pOLV->GetEditView().HasSelection())
108 pOLV->GetEditView().SelectCurrentWord();
111 bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,GetView(),rSh);
112 break;
115 case SID_THES:
117 OUString aReplaceText;
118 const SfxStringItem* pItem2 = rReq.GetArg(FN_PARAM_THES_WORD_REPLACE);
119 if (pItem2)
120 aReplaceText = pItem2->GetValue();
121 if (!aReplaceText.isEmpty())
122 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
123 break;
126 case SID_ATTR_CHAR_FONT:
127 case SID_ATTR_CHAR_FONTHEIGHT:
128 case SID_ATTR_CHAR_WEIGHT:
129 case SID_ATTR_CHAR_POSTURE:
131 SfxItemPool* pPool2 = aEditAttr.GetPool()->GetSecondaryPool();
132 if( !pPool2 )
133 pPool2 = aEditAttr.GetPool();
134 SvxScriptSetItem aSetItem( nSlot, *pPool2 );
136 // #i78017 establish the same behaviour as in Writer
137 SvtScriptType nScriptTypes = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
138 if (nSlot == SID_ATTR_CHAR_FONT)
139 nScriptTypes = pOLV->GetSelectedScriptType();
141 if (pNewAttrs)
143 aSetItem.PutItemForScriptType( nScriptTypes, pNewAttrs->Get( nWhich ) );
144 aNewAttr.Put( aSetItem.GetItemSet() );
147 break;
149 case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
150 case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break;
152 case SID_ATTR_CHAR_UNDERLINE:
154 if ( pNewAttrs )
156 const SvxTextLineItem& rTextLineItem = static_cast< const SvxTextLineItem& >( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich(nSlot) ) );
157 aNewAttr.Put( SvxUnderlineItem( rTextLineItem.GetLineStyle(), EE_CHAR_UNDERLINE ) );
159 else
161 FontLineStyle eFU = aEditAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle();
162 aNewAttr.Put( SvxUnderlineItem(eFU == LINESTYLE_SINGLE ? LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_UNDERLINE) );
165 break;
167 case SID_ATTR_CHAR_OVERLINE:
169 FontLineStyle eFO = aEditAttr.Get(EE_CHAR_OVERLINE).GetLineStyle();
170 aNewAttr.Put(SvxOverlineItem(eFO == LINESTYLE_SINGLE ? LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_OVERLINE));
172 break;
174 case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
175 case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW; break;
176 case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
177 case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
178 case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
179 case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
180 case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
181 case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH; break;
182 case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
183 case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
184 case SID_ATTR_PARA_ADJUST_LEFT:
185 aNewAttr.Put(SvxAdjustItem(SvxAdjust::Left, EE_PARA_JUST));
186 break;
187 case SID_ATTR_PARA_ADJUST_CENTER:
188 aNewAttr.Put(SvxAdjustItem(SvxAdjust::Center, EE_PARA_JUST));
189 break;
190 case SID_ATTR_PARA_ADJUST_RIGHT:
191 aNewAttr.Put(SvxAdjustItem(SvxAdjust::Right, EE_PARA_JUST));
192 break;
193 case SID_ATTR_PARA_ADJUST_BLOCK:
194 aNewAttr.Put(SvxAdjustItem(SvxAdjust::Block, EE_PARA_JUST));
195 break;
196 case SID_ATTR_PARA_LRSPACE:
198 SvxLRSpaceItem aParaMargin(static_cast<const SvxLRSpaceItem&>(rReq.
199 GetArgs()->Get(nSlot)));
200 aParaMargin.SetWhich( EE_PARA_LRSPACE );
201 aNewAttr.Put(aParaMargin);
202 rReq.Done();
204 break;
205 case SID_HANGING_INDENT:
207 SfxItemState eState = aEditAttr.GetItemState( EE_PARA_LRSPACE );
208 if( eState >= SfxItemState::DEFAULT )
210 SvxLRSpaceItem aParaMargin = aEditAttr.Get( EE_PARA_LRSPACE );
211 aParaMargin.SetWhich( EE_PARA_LRSPACE );
212 short int nFirstLineOffset = aParaMargin.GetTextFirstLineOffset();
213 aParaMargin.SetTextLeft( aParaMargin.GetTextLeft() + nFirstLineOffset );
214 aParaMargin.SetRight( aParaMargin.GetRight() );
215 aParaMargin.SetTextFirstLineOffset( nFirstLineOffset * -1 );
216 aNewAttr.Put(aParaMargin);
217 rReq.Done();
220 break;
221 case SID_ATTR_PARA_LINESPACE:
222 if (pNewAttrs)
224 SvxLineSpacingItem aLineSpace = static_cast<const SvxLineSpacingItem&>(pNewAttrs->Get(
225 GetPool().GetWhich(nSlot)));
226 aLineSpace.SetWhich( EE_PARA_SBL );
227 aNewAttr.Put( aLineSpace );
228 rReq.Done();
230 break;
231 case SID_ATTR_PARA_ULSPACE:
232 if (pNewAttrs)
234 SvxULSpaceItem aULSpace = static_cast<const SvxULSpaceItem&>(pNewAttrs->Get(
235 GetPool().GetWhich(nSlot)));
236 aULSpace.SetWhich( EE_PARA_ULSPACE );
237 aNewAttr.Put( aULSpace );
238 rReq.Done();
240 break;
241 case SID_PARASPACE_INCREASE:
242 case SID_PARASPACE_DECREASE:
244 SvxULSpaceItem aULSpace( aEditAttr.Get( EE_PARA_ULSPACE ) );
245 sal_uInt16 nUpper = aULSpace.GetUpper();
246 sal_uInt16 nLower = aULSpace.GetLower();
248 if ( nSlot == SID_PARASPACE_INCREASE )
250 nUpper = std::min< sal_uInt16 >( nUpper + 57, 5670 );
251 nLower = std::min< sal_uInt16 >( nLower + 57, 5670 );
253 else
255 nUpper = std::max< sal_Int16 >( nUpper - 57, 0 );
256 nLower = std::max< sal_Int16 >( nLower - 57, 0 );
259 aULSpace.SetUpper( nUpper );
260 aULSpace.SetLower( nLower );
261 aNewAttr.Put( aULSpace );
262 rReq.Done();
264 break;
265 case SID_ATTR_PARA_LINESPACE_10:
267 SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
268 aItem.SetPropLineSpace(100);
269 aNewAttr.Put(aItem);
271 break;
272 case SID_ATTR_PARA_LINESPACE_115:
274 SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
275 aItem.SetPropLineSpace(115);
276 aNewAttr.Put(aItem);
278 break;
279 case SID_ATTR_PARA_LINESPACE_15:
281 SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
282 aItem.SetPropLineSpace(150);
283 aNewAttr.Put(aItem);
285 break;
286 case SID_ATTR_PARA_LINESPACE_20:
288 SvxLineSpacingItem aItem(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
289 aItem.SetPropLineSpace(200);
290 aNewAttr.Put(aItem);
292 break;
294 case FN_SET_SUPER_SCRIPT:
296 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
297 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
299 if( eEsc == SvxEscapement::Superscript )
300 aItem.SetEscapement( SvxEscapement::Off );
301 else
302 aItem.SetEscapement( SvxEscapement::Superscript );
303 aNewAttr.Put( aItem );
305 break;
306 case FN_SET_SUB_SCRIPT:
308 SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
309 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
311 if( eEsc == SvxEscapement::Subscript )
312 aItem.SetEscapement( SvxEscapement::Off );
313 else
314 aItem.SetEscapement( SvxEscapement::Subscript );
315 aNewAttr.Put( aItem );
317 break;
319 case SID_CHAR_DLG_EFFECT:
320 case SID_CHAR_DLG_POSITION:
321 case SID_CHAR_DLG:
322 case SID_CHAR_DLG_FOR_PARAGRAPH:
324 const SfxItemSet* pArgs = rReq.GetArgs();
325 const SfxStringItem* pItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
327 if( !pArgs || pItem )
329 aOldSelection = pOLV->GetSelection();
330 if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
332 // select current paragraph (and restore selection later on...)
333 EditView & rEditView = pOLV->GetEditView();
334 SwLangHelper::SelectPara( rEditView, rEditView.GetSelection() );
335 bRestoreSelection = true;
338 SwView* pView = &GetView();
339 FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
340 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
341 SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLCOLOR, EE_ITEMS_START, EE_ITEMS_END> aDlgAttr(GetPool());
343 // util::Language does not exists in the EditEngine! That is why not in set.
345 aDlgAttr.Put( aEditAttr );
346 aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
348 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
349 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(pView->GetFrameWeld(), *pView, aDlgAttr, SwCharDlgMode::Draw));
350 if (nSlot == SID_CHAR_DLG_EFFECT)
352 pDlg->SetCurPageId("fonteffects");
354 else if (nSlot == SID_CHAR_DLG_POSITION)
356 pDlg->SetCurPageId("position");
358 else if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
360 pDlg->SetCurPageId("font");
362 else if (pItem)
364 pDlg->SetCurPageId(pItem->GetValue());
367 sal_uInt16 nRet = pDlg->Execute();
368 if(RET_OK == nRet )
370 rReq.Done( *( pDlg->GetOutputItemSet() ) );
371 aNewAttr.Put(*pDlg->GetOutputItemSet());
373 if(RET_OK != nRet)
374 return ;
376 else
377 aNewAttr.Put(*pArgs);
379 break;
380 case FN_FORMAT_FOOTNOTE_DLG:
382 GetView().ExecFormatFootnote();
383 break;
385 case FN_NUMBERING_OUTLINE_DLG:
387 GetView().ExecNumberingOutline(GetPool());
388 rReq.Done();
390 break;
391 case SID_OPEN_XML_FILTERSETTINGS:
393 HandleOpenXmlFilterSettings(rReq);
395 break;
396 case FN_WORDCOUNT_DIALOG:
398 GetView().UpdateWordCount(this, nSlot);
400 break;
401 case SID_PARA_DLG:
403 const SfxItemSet* pArgs = rReq.GetArgs();
405 if (!pArgs)
407 SwView* pView = &GetView();
408 FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
409 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
410 SfxItemSetFixed<
411 EE_ITEMS_START, EE_ITEMS_END,
412 SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_WIDOWS> aDlgAttr( GetPool() );
414 aDlgAttr.Put(aEditAttr);
416 aDlgAttr.Put( SvxHyphenZoneItem( false, RES_PARATR_HYPHENZONE) );
417 aDlgAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, RES_BREAK ) );
418 aDlgAttr.Put( SvxFormatSplitItem( true, RES_PARATR_SPLIT ) );
419 aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
420 aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
422 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
423 ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwParaDlg(GetView().GetFrameWeld(), GetView(), aDlgAttr, true));
424 sal_uInt16 nRet = pDlg->Execute();
425 if(RET_OK == nRet)
427 rReq.Done( *( pDlg->GetOutputItemSet() ) );
428 aNewAttr.Put(*pDlg->GetOutputItemSet());
430 if(RET_OK != nRet)
431 return;
433 else
434 aNewAttr.Put(*pArgs);
436 break;
437 case SID_AUTOSPELL_CHECK:
439 //!! JP 16.03.2001: why?? pSdrView = rSh.GetDrawView();
440 //!! JP 16.03.2001: why?? pOutliner = pSdrView->GetTextEditOutliner();
441 SdrOutliner * pOutliner = m_pSdrView->GetTextEditOutliner();
442 EEControlBits nCtrl = pOutliner->GetControlWord();
444 bool bSet = static_cast<const SfxBoolItem&>(rReq.GetArgs()->Get(
445 nSlot)).GetValue();
446 if(bSet)
447 nCtrl |= EEControlBits::ONLINESPELLING|EEControlBits::ALLOWBIGOBJS;
448 else
449 nCtrl &= ~EEControlBits::ONLINESPELLING;
450 pOutliner->SetControlWord(nCtrl);
452 m_rView.ExecuteSlot(rReq);
454 break;
455 case SID_HYPERLINK_SETLINK:
457 const SfxPoolItem* pItem = nullptr;
458 if(pNewAttrs)
459 pNewAttrs->GetItemState(nSlot, false, &pItem);
461 if(pItem)
463 const SvxHyperlinkItem& rHLinkItem = *static_cast<const SvxHyperlinkItem *>(pItem);
464 SvxURLField aField(rHLinkItem.GetURL(), rHLinkItem.GetName(), SvxURLFormat::AppDefault);
465 aField.SetTargetFrame(rHLinkItem.GetTargetFrame());
467 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
469 if (pFieldItem && dynamic_cast< const SvxURLField *>( pFieldItem->GetField() ) != nullptr )
471 // Select field so that it will be deleted during insert
472 ESelection aSel = pOLV->GetSelection();
473 aSel.nEndPos++;
474 pOLV->SetSelection(aSel);
476 pOLV->InsertField(SvxFieldItem(aField, EE_FEATURE_FIELD));
479 break;
481 case SID_EDIT_HYPERLINK:
483 // Ensure the field is selected first
484 pOLV->SelectFieldAtCursor();
485 GetView().GetViewFrame().GetDispatcher()->Execute(SID_HYPERLINK_DIALOG);
487 break;
489 case SID_REMOVE_HYPERLINK:
491 URLFieldHelper::RemoveURLField(pOLV->GetEditView());
493 break;
495 case SID_OPEN_HYPERLINK:
497 const SvxFieldData* pField = pOLV->GetFieldAtCursor();
498 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
500 SfxStringItem aUrl(SID_FILE_NAME, pURLField->GetURL());
501 SfxStringItem aTarget(SID_TARGETNAME, pURLField->GetTargetFrame());
502 SfxBoolItem aNewView(SID_OPEN_NEW_VIEW, false);
503 SfxBoolItem aBrowsing(SID_BROWSE, true);
504 GetView().GetViewFrame().GetDispatcher()->ExecuteList(
505 SID_OPENDOC, SfxCallMode::SYNCHRON, { &aUrl, &aTarget, &aNewView, &aBrowsing });
508 break;
510 case SID_COPY_HYPERLINK_LOCATION:
512 const SvxFieldData* pField = pOLV->GetFieldAtCursor();
513 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
515 uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
516 = GetView().GetEditWin().GetClipboard();
517 vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard);
520 break;
522 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
523 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
524 // Shell switch!
526 SdrObject* pTmpObj = m_pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
527 SdrPageView* pTmpPV = m_pSdrView->GetSdrPageView();
528 SdrView* pTmpView = m_pSdrView;
530 m_pSdrView->SdrEndTextEdit(true);
532 SfxItemSetFixed<SDRATTR_TEXTDIRECTION,
533 SDRATTR_TEXTDIRECTION> aAttr( *aNewAttr.GetPool() );
535 aAttr.Put( SvxWritingModeItem(
536 nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
537 text::WritingMode_LR_TB
538 : text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION ) );
539 pTmpView->SetAttributes( aAttr );
541 rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin());
542 rSh.GetView().AttrChangedNotify(nullptr);
544 return;
546 case SID_ATTR_PARA_LEFT_TO_RIGHT:
547 case SID_ATTR_PARA_RIGHT_TO_LEFT:
549 SdrObject* pTmpObj = m_pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
550 SdrPageView* pTmpPV = m_pSdrView->GetSdrPageView();
551 SdrView* pTmpView = m_pSdrView;
553 m_pSdrView->SdrEndTextEdit(true);
554 bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
556 const SfxPoolItem* pPoolItem;
557 if( pNewAttrs && SfxItemState::SET == pNewAttrs->GetItemState( nSlot, true, &pPoolItem ) )
559 if( !static_cast<const SfxBoolItem*>(pPoolItem)->GetValue() )
560 bLeftToRight = !bLeftToRight;
562 SfxItemSetFixed<
563 EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
564 EE_PARA_JUST, EE_PARA_JUST> aAttr( *aNewAttr.GetPool() );
566 SvxAdjust nAdjust = SvxAdjust::Left;
567 if( const SvxAdjustItem* pAdjustItem = aEditAttr.GetItemIfSet(EE_PARA_JUST) )
568 nAdjust = pAdjustItem->GetAdjust();
570 if( bLeftToRight )
572 aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_LR_TB, EE_PARA_WRITINGDIR ) );
573 if( nAdjust == SvxAdjust::Right )
574 aAttr.Put( SvxAdjustItem( SvxAdjust::Left, EE_PARA_JUST ) );
576 else
578 aAttr.Put( SvxFrameDirectionItem( SvxFrameDirection::Horizontal_RL_TB, EE_PARA_WRITINGDIR ) );
579 if( nAdjust == SvxAdjust::Left )
580 aAttr.Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
582 pTmpView->SetAttributes( aAttr );
583 rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin() );
584 rSh.GetView().AttrChangedNotify(nullptr);
586 return;
588 case FN_GROW_FONT_SIZE:
589 case FN_SHRINK_FONT_SIZE:
591 const SfxObjectShell* pObjSh = SfxObjectShell::Current();
592 const SvxFontListItem* pFontListItem = static_cast< const SvxFontListItem* >
593 (pObjSh ? pObjSh->GetItem(SID_ATTR_CHAR_FONTLIST) : nullptr);
594 const FontList* pFontList = pFontListItem ? pFontListItem->GetFontList() : nullptr;
595 pOLV->GetEditView().ChangeFontSize( nSlot == FN_GROW_FONT_SIZE, pFontList );
597 break;
599 default:
600 assert(false && "wrong dispatcher");
601 return;
603 if (nEEWhich && pNewAttrs)
605 aNewAttr.Put(pNewAttrs->Get(nWhich).CloneSetWhich(nEEWhich));
607 else if (nEEWhich == EE_CHAR_COLOR)
609 GetView().GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG_EFFECT);
611 else if (nEEWhich == EE_CHAR_KERNING)
613 GetView().GetViewFrame().GetDispatcher()->Execute(SID_CHAR_DLG_POSITION);
617 SetAttrToMarked(aNewAttr);
619 GetView().GetViewFrame().GetBindings().InvalidateAll(false);
621 if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
622 rSh.SetModified();
624 if (bRestoreSelection)
626 // restore selection
627 pOLV->GetEditView().SetSelection( aOldSelection );
631 void SwDrawTextShell::GetState(SfxItemSet& rSet)
633 if (!IsTextEdit()) // Otherwise sometimes crash!
634 return;
636 OutlinerView* pOLV = m_pSdrView->GetTextEditOutlinerView();
637 SfxWhichIter aIter(rSet);
638 sal_uInt16 nWhich = aIter.FirstWhich();
640 SfxItemSet aEditAttr(pOLV->GetAttribs());
641 const SvxAdjustItem *pAdjust = nullptr;
642 const SvxLineSpacingItem *pLSpace = nullptr;
643 const SfxPoolItem *pEscItem = nullptr;
644 SvxAdjust eAdjust;
645 int nLSpace;
646 SvxEscapement nEsc;
648 while (nWhich)
650 sal_uInt16 nSlotId = GetPool().GetSlotId(nWhich);
651 bool bFlag = false;
652 switch (nSlotId)
654 case SID_LANGUAGE_STATUS: //20412:
656 SwLangHelper::GetLanguageStatus(pOLV, rSet);
657 nSlotId = 0;
658 break;
661 case SID_THES:
663 OUString aStatusVal;
664 LanguageType nLang = LANGUAGE_NONE;
665 bool bIsLookUpWord
666 = GetStatusValueForThesaurusFromContext(aStatusVal, nLang, pOLV->GetEditView());
667 rSet.Put(SfxStringItem(SID_THES, aStatusVal));
669 // disable "Thesaurus" context menu entry if there is nothing to look up
670 uno::Reference<linguistic2::XThesaurus> xThes(::GetThesaurus());
671 if (!bIsLookUpWord || !xThes.is() || nLang == LANGUAGE_NONE
672 || !xThes->hasLocale(LanguageTag::convertToLocale(nLang)))
673 rSet.DisableItem(SID_THES);
675 //! avoid putting the same item as SfxBoolItem at the end of this function
676 nSlotId = 0;
677 break;
680 case SID_ATTR_PARA_ADJUST_LEFT:
681 eAdjust = SvxAdjust::Left;
682 goto ASK_ADJUST;
683 case SID_ATTR_PARA_ADJUST_RIGHT:
684 eAdjust = SvxAdjust::Right;
685 goto ASK_ADJUST;
686 case SID_ATTR_PARA_ADJUST_CENTER:
687 eAdjust = SvxAdjust::Center;
688 goto ASK_ADJUST;
689 case SID_ATTR_PARA_ADJUST_BLOCK:
690 eAdjust = SvxAdjust::Block;
691 goto ASK_ADJUST;
692 ASK_ADJUST:
694 if (!pAdjust)
695 pAdjust = aEditAttr.GetItemIfSet(EE_PARA_JUST, false);
697 if (!pAdjust || IsInvalidItem(pAdjust))
699 rSet.InvalidateItem(nSlotId);
700 nSlotId = 0;
702 else
703 bFlag = eAdjust == pAdjust->GetAdjust();
705 break;
707 case SID_ATTR_PARA_LRSPACE:
708 case SID_ATTR_PARA_LEFTSPACE:
709 case SID_ATTR_PARA_RIGHTSPACE:
710 case SID_ATTR_PARA_FIRSTLINESPACE:
712 SfxItemState eState = aEditAttr.GetItemState(EE_PARA_LRSPACE);
713 if (eState >= SfxItemState::DEFAULT)
715 SvxLRSpaceItem aLR = aEditAttr.Get(EE_PARA_LRSPACE);
716 aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
717 rSet.Put(aLR);
719 else
720 rSet.InvalidateItem(nSlotId);
721 nSlotId = 0;
723 break;
724 case SID_ATTR_PARA_LINESPACE:
726 SfxItemState eState = aEditAttr.GetItemState(EE_PARA_SBL);
727 if (eState >= SfxItemState::DEFAULT)
729 const SvxLineSpacingItem& aLR = aEditAttr.Get(EE_PARA_SBL);
730 rSet.Put(aLR);
732 else
733 rSet.InvalidateItem(nSlotId);
734 nSlotId = 0;
736 break;
737 case SID_ATTR_PARA_ULSPACE:
738 case SID_ATTR_PARA_BELOWSPACE:
739 case SID_ATTR_PARA_ABOVESPACE:
740 case SID_PARASPACE_INCREASE:
741 case SID_PARASPACE_DECREASE:
743 SfxItemState eState = aEditAttr.GetItemState(EE_PARA_ULSPACE);
744 if (eState >= SfxItemState::DEFAULT)
746 SvxULSpaceItem aULSpace = aEditAttr.Get(EE_PARA_ULSPACE);
747 if (!aULSpace.GetUpper() && !aULSpace.GetLower())
748 rSet.DisableItem(SID_PARASPACE_DECREASE);
749 else if (aULSpace.GetUpper() >= 5670 && aULSpace.GetLower() >= 5670)
750 rSet.DisableItem(SID_PARASPACE_INCREASE);
751 if (nSlotId == SID_ATTR_PARA_ULSPACE || nSlotId == SID_ATTR_PARA_ABOVESPACE
752 || nSlotId == SID_ATTR_PARA_BELOWSPACE)
754 aULSpace.SetWhich(nSlotId);
755 rSet.Put(aULSpace);
758 else
760 rSet.DisableItem(SID_PARASPACE_INCREASE);
761 rSet.DisableItem(SID_PARASPACE_DECREASE);
762 rSet.InvalidateItem(SID_ATTR_PARA_ULSPACE);
763 rSet.InvalidateItem(SID_ATTR_PARA_ABOVESPACE);
764 rSet.InvalidateItem(SID_ATTR_PARA_BELOWSPACE);
766 nSlotId = 0;
768 break;
770 case SID_ATTR_PARA_LINESPACE_10:
771 nLSpace = 100;
772 goto ASK_LINESPACE;
773 case SID_ATTR_PARA_LINESPACE_115:
774 nLSpace = 115;
775 goto ASK_LINESPACE;
776 case SID_ATTR_PARA_LINESPACE_15:
777 nLSpace = 150;
778 goto ASK_LINESPACE;
779 case SID_ATTR_PARA_LINESPACE_20:
780 nLSpace = 200;
781 goto ASK_LINESPACE;
782 ASK_LINESPACE:
784 if (!pLSpace)
785 pLSpace = aEditAttr.GetItemIfSet(EE_PARA_SBL, false);
787 if (!pLSpace || IsInvalidItem(pLSpace))
789 rSet.InvalidateItem(nSlotId);
790 nSlotId = 0;
792 else if (nLSpace
793 == pLSpace->GetPropLineSpace())
794 bFlag = true;
795 else
797 // tdf#114631 - disable non selected line spacing
798 rSet.Put(SfxBoolItem(nWhich, false));
799 nSlotId = 0;
802 break;
804 case FN_SET_SUPER_SCRIPT:
805 nEsc = SvxEscapement::Superscript;
806 goto ASK_ESCAPE;
807 case FN_SET_SUB_SCRIPT:
808 nEsc = SvxEscapement::Subscript;
809 goto ASK_ESCAPE;
810 ASK_ESCAPE:
812 if (!pEscItem)
813 pEscItem = &aEditAttr.Get(EE_CHAR_ESCAPEMENT);
815 if (nEsc == static_cast<const SvxEscapementItem*>(pEscItem)->GetEscapement())
816 bFlag = true;
817 else
818 nSlotId = 0;
820 break;
822 case SID_THESAURUS:
824 // disable "Thesaurus" if the language is not supported
825 const SfxPoolItem& rItem = GetShell().GetDoc()->GetDefault(GetWhichOfScript(
826 RES_CHRATR_LANGUAGE,
827 SvtLanguageOptions::GetI18NScriptTypeOfLanguage(GetAppLanguage())));
828 LanguageType nLang = static_cast<const SvxLanguageItem&>(rItem).GetLanguage();
830 uno::Reference<linguistic2::XThesaurus> xThes(::GetThesaurus());
831 if (!xThes.is() || nLang == LANGUAGE_NONE
832 || !xThes->hasLocale(LanguageTag::convertToLocale(nLang)))
833 rSet.DisableItem(SID_THESAURUS);
834 nSlotId = 0;
836 break;
837 case SID_HANGUL_HANJA_CONVERSION:
838 case SID_CHINESE_CONVERSION:
840 if (!SvtCJKOptions::IsAnyEnabled())
842 GetView().GetViewFrame().GetBindings().SetVisibleState(nWhich, false);
843 rSet.DisableItem(nWhich);
845 else
846 GetView().GetViewFrame().GetBindings().SetVisibleState(nWhich, true);
848 break;
850 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
851 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
852 if (!SvtCJKOptions::IsVerticalTextEnabled())
854 rSet.DisableItem(nSlotId);
855 nSlotId = 0;
857 else
859 SdrOutliner* pOutliner = m_pSdrView->GetTextEditOutliner();
860 if (pOutliner)
861 bFlag = pOutliner->IsVertical()
862 == (SID_TEXTDIRECTION_TOP_TO_BOTTOM == nSlotId);
863 else
865 text::WritingMode eMode = aEditAttr.Get(SDRATTR_TEXTDIRECTION).GetValue();
867 if (nSlotId == SID_TEXTDIRECTION_LEFT_TO_RIGHT)
869 bFlag = eMode == text::WritingMode_LR_TB;
871 else
873 bFlag = eMode != text::WritingMode_TB_RL;
877 break;
878 case SID_ATTR_PARA_LEFT_TO_RIGHT:
879 case SID_ATTR_PARA_RIGHT_TO_LEFT:
881 if (!SvtCTLOptions::IsCTLFontEnabled())
883 rSet.DisableItem(nWhich);
884 nSlotId = 0;
886 else
888 SdrOutliner* pOutliner = m_pSdrView->GetTextEditOutliner();
889 if (pOutliner && pOutliner->IsVertical())
891 rSet.DisableItem(nWhich);
892 nSlotId = 0;
894 else
896 switch (aEditAttr.Get(EE_PARA_WRITINGDIR).GetValue())
898 case SvxFrameDirection::Horizontal_LR_TB:
899 bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
900 break;
902 case SvxFrameDirection::Horizontal_RL_TB:
903 bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
904 break;
905 default:
906 break;
911 break;
912 case SID_TRANSLITERATE_HALFWIDTH:
913 case SID_TRANSLITERATE_FULLWIDTH:
914 case SID_TRANSLITERATE_HIRAGANA:
915 case SID_TRANSLITERATE_KATAKANA:
917 if (!SvtCJKOptions::IsChangeCaseMapEnabled())
919 rSet.DisableItem(nWhich);
920 GetView().GetViewFrame().GetBindings().SetVisibleState(nWhich, false);
922 else
923 GetView().GetViewFrame().GetBindings().SetVisibleState(nWhich, true);
925 break;
926 case SID_INSERT_RLM:
927 case SID_INSERT_LRM:
929 bool bEnabled = SvtCTLOptions::IsCTLFontEnabled();
930 GetView().GetViewFrame().GetBindings().SetVisibleState(nWhich, bEnabled);
931 if (!bEnabled)
932 rSet.DisableItem(nWhich);
934 break;
935 case SID_REMOVE_HYPERLINK:
936 case SID_EDIT_HYPERLINK:
937 case SID_OPEN_HYPERLINK:
938 case SID_COPY_HYPERLINK_LOCATION:
940 if (!URLFieldHelper::IsCursorAtURLField(pOLV))
941 rSet.DisableItem(nWhich);
942 nSlotId = 0;
944 break;
945 default:
946 nSlotId = 0; // don't know this slot
947 break;
950 if (nSlotId)
951 rSet.Put(SfxBoolItem(nWhich, bFlag));
953 nWhich = aIter.NextWhich();
957 void SwDrawTextShell::GetDrawTextCtrlState(SfxItemSet& rSet)
959 if (!IsTextEdit()) // Otherwise crash!
960 return;
962 OutlinerView* pOLV = m_pSdrView->GetTextEditOutlinerView();
963 SfxItemSet aEditAttr(pOLV->GetAttribs());
965 SfxWhichIter aIter(rSet);
966 sal_uInt16 nWhich = aIter.FirstWhich();
967 SvtScriptType nScriptType = pOLV->GetSelectedScriptType();
968 while(nWhich)
970 sal_uInt16 nEEWhich = 0;
971 sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
972 switch( nSlotId )
974 case SID_ATTR_CHAR_FONT:
975 case SID_ATTR_CHAR_FONTHEIGHT:
976 case SID_ATTR_CHAR_WEIGHT:
977 case SID_ATTR_CHAR_POSTURE:
979 SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool();
980 if( !pEditPool )
981 pEditPool = aEditAttr.GetPool();
982 SvxScriptSetItem aSetItem( nSlotId, *pEditPool );
983 aSetItem.GetItemSet().Put( aEditAttr, false );
984 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
985 if( pI )
987 rSet.Put(pI->CloneSetWhich(nWhich));
989 else
990 rSet.InvalidateItem( nWhich );
992 break;
993 case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
994 case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break;
995 case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
996 case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
997 case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
998 case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break;
999 case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
1000 case SID_AUTOSPELL_CHECK:
1002 const SfxPoolItem* pState = m_rView.GetSlotState(nWhich);
1003 if (pState)
1004 rSet.Put(SfxBoolItem(nWhich, static_cast<const SfxBoolItem*>(pState)->GetValue()));
1005 else
1006 rSet.DisableItem( nWhich );
1007 break;
1009 case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
1010 case SID_ATTR_CHAR_RELIEF : nEEWhich = EE_CHAR_RELIEF; break;
1011 case SID_ATTR_CHAR_LANGUAGE : nEEWhich = EE_CHAR_LANGUAGE;break;
1012 case SID_ATTR_CHAR_KERNING : nEEWhich = EE_CHAR_KERNING; break;
1013 case SID_ATTR_CHAR_SCALEWIDTH: nEEWhich = EE_CHAR_FONTWIDTH;break;
1014 case SID_ATTR_CHAR_AUTOKERN : nEEWhich = EE_CHAR_PAIRKERNING; break;
1015 case SID_ATTR_CHAR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
1016 case FN_GROW_FONT_SIZE:
1017 case FN_SHRINK_FONT_SIZE:
1019 SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool();
1020 if( !pEditPool )
1021 pEditPool = aEditAttr.GetPool();
1023 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, *pEditPool );
1024 aSetItem.GetItemSet().Put( aEditAttr, false );
1025 const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptType ) ) );
1027 if( pSize )
1029 sal_uInt32 nSize = pSize->GetHeight();
1030 if( nSize >= 19998 )
1031 rSet.DisableItem( FN_GROW_FONT_SIZE );
1032 else if( nSize <= 40 )
1033 rSet.DisableItem( FN_SHRINK_FONT_SIZE );
1037 if(nEEWhich)
1039 rSet.Put(aEditAttr.Get(nEEWhich).CloneSetWhich(nWhich));
1042 nWhich = aIter.NextWhich();
1046 void SwDrawTextShell::ExecClpbrd(SfxRequest const &rReq)
1048 if (!IsTextEdit()) // Otherwise crash!
1049 return;
1051 OutlinerView* pOLV = m_pSdrView->GetTextEditOutlinerView();
1053 ESelection aSel(pOLV->GetSelection());
1054 const bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos);
1055 sal_uInt16 nId = rReq.GetSlot();
1056 switch( nId )
1058 case SID_CUT:
1059 if (bCopy)
1060 pOLV->Cut();
1061 return;
1063 case SID_COPY:
1064 if (bCopy)
1065 pOLV->Copy();
1066 return;
1068 case SID_PASTE:
1069 pOLV->PasteSpecial();
1070 break;
1072 case SID_PASTE_UNFORMATTED:
1073 pOLV->Paste();
1074 break;
1076 case SID_PASTE_SPECIAL:
1078 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1079 ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(GetView().GetEditWin().GetFrameWeld()));
1081 pDlg->Insert(SotClipboardFormatId::STRING, OUString());
1082 pDlg->Insert(SotClipboardFormatId::RTF, OUString());
1083 pDlg->Insert(SotClipboardFormatId::RICHTEXT, OUString());
1085 TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(&GetView().GetEditWin()));
1086 SotClipboardFormatId nFormat = pDlg->GetFormat(aDataHelper.GetTransferable());
1088 if (nFormat != SotClipboardFormatId::NONE)
1090 if (nFormat == SotClipboardFormatId::STRING)
1091 pOLV->Paste();
1092 else
1093 pOLV->PasteSpecial();
1096 break;
1099 case SID_CLIPBOARD_FORMAT_ITEMS:
1101 SotClipboardFormatId nFormat = SotClipboardFormatId::NONE;
1102 const SfxPoolItem* pItem;
1103 if (rReq.GetArgs() && rReq.GetArgs()->GetItemState(nId, true, &pItem) == SfxItemState::SET)
1105 if (const SfxUInt32Item* pUInt32Item = dynamic_cast<const SfxUInt32Item *>(pItem))
1106 nFormat = static_cast<SotClipboardFormatId>(pUInt32Item->GetValue());
1109 if (nFormat != SotClipboardFormatId::NONE)
1111 if (nFormat == SotClipboardFormatId::STRING)
1112 pOLV->Paste();
1113 else
1114 pOLV->PasteSpecial();
1117 break;
1120 default:
1121 OSL_FAIL("wrong dispatcher");
1122 return;
1126 void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet)
1128 if (!IsTextEdit()) // Otherwise crash!
1129 return;
1131 OutlinerView* pOLV = m_pSdrView->GetTextEditOutlinerView();
1132 ESelection aSel(pOLV->GetSelection());
1133 const bool bCopy = (aSel.nStartPara != aSel.nEndPara) ||
1134 (aSel.nStartPos != aSel.nEndPos);
1136 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &GetView().GetEditWin() ) );
1137 const bool bPaste = aDataHelper.HasFormat( SotClipboardFormatId::STRING ) ||
1138 aDataHelper.HasFormat( SotClipboardFormatId::RTF ) ||
1139 aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT );
1141 SfxWhichIter aIter(rSet);
1142 sal_uInt16 nWhich = aIter.FirstWhich();
1144 while(nWhich)
1146 switch(nWhich)
1148 case SID_CUT:
1149 case SID_COPY:
1150 if( !bCopy || GetObjectShell()->isContentExtractionLocked())
1151 rSet.DisableItem( nWhich );
1152 break;
1154 case SID_PASTE:
1155 case SID_PASTE_UNFORMATTED:
1156 case SID_PASTE_SPECIAL:
1157 if( !bPaste )
1158 rSet.DisableItem( nWhich );
1159 break;
1161 case SID_CLIPBOARD_FORMAT_ITEMS:
1162 if( bPaste )
1164 SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
1166 if ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) )
1167 aFormats.AddClipbrdFormat( SotClipboardFormatId::STRING );
1168 if ( aDataHelper.HasFormat( SotClipboardFormatId::RTF ) )
1169 aFormats.AddClipbrdFormat( SotClipboardFormatId::RTF );
1170 if ( aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) )
1171 aFormats.AddClipbrdFormat( SotClipboardFormatId::RICHTEXT );
1173 rSet.Put( aFormats );
1175 else
1176 rSet.DisableItem( nWhich );
1177 break;
1180 nWhich = aIter.NextWhich();
1184 // Hyperlink status
1186 void SwDrawTextShell::StateInsert(SfxItemSet &rSet)
1188 if (!IsTextEdit()) // Otherwise crash!
1189 return;
1191 OutlinerView* pOLV = m_pSdrView->GetTextEditOutlinerView();
1192 SfxWhichIter aIter(rSet);
1193 sal_uInt16 nWhich = aIter.FirstWhich();
1195 while(nWhich)
1197 switch(nWhich)
1199 case SID_HYPERLINK_GETLINK:
1201 SvxHyperlinkItem aHLinkItem;
1202 aHLinkItem.SetInsertMode(HLINK_FIELD);
1204 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
1206 if (pFieldItem)
1208 const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pFieldItem->GetField());
1210 if (pURLField)
1212 aHLinkItem.SetName(pURLField->GetRepresentation());
1213 aHLinkItem.SetURL(pURLField->GetURL());
1214 aHLinkItem.SetTargetFrame(pURLField->GetTargetFrame());
1217 else
1219 OUString sSel(pOLV->GetSelected());
1220 sSel = sSel.copy(0, std::min<sal_Int32>(255, sSel.getLength()));
1221 aHLinkItem.SetName(comphelper::string::stripEnd(sSel, ' '));
1224 sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1225 aHLinkItem.SetInsertMode(static_cast<SvxLinkInsertMode>(aHLinkItem.GetInsertMode() |
1226 ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
1228 rSet.Put(aHLinkItem);
1230 break;
1232 nWhich = aIter.NextWhich();
1236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */