1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
70 #include <drwtxtsh.hxx>
72 #include <hintids.hxx>
73 #include <langhelper.hxx>
74 #include <chrdlgmodes.hxx>
75 #include <swmodule.hxx>
77 #include <viewopt.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;
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
);
117 OUString aReplaceText
;
118 const SfxStringItem
* pItem2
= rReq
.GetArg(FN_PARAM_THES_WORD_REPLACE
);
120 aReplaceText
= pItem2
->GetValue();
121 if (!aReplaceText
.isEmpty())
122 ReplaceTextWithSynonym( pOLV
->GetEditView(), aReplaceText
);
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();
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();
143 aSetItem
.PutItemForScriptType( nScriptTypes
, pNewAttrs
->Get( nWhich
) );
144 aNewAttr
.Put( aSetItem
.GetItemSet() );
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
:
156 const SvxTextLineItem
& rTextLineItem
= static_cast< const SvxTextLineItem
& >( pNewAttrs
->Get( pNewAttrs
->GetPool()->GetWhich(nSlot
) ) );
157 aNewAttr
.Put( SvxUnderlineItem( rTextLineItem
.GetLineStyle(), EE_CHAR_UNDERLINE
) );
161 FontLineStyle eFU
= aEditAttr
.Get(EE_CHAR_UNDERLINE
).GetLineStyle();
162 aNewAttr
.Put( SvxUnderlineItem(eFU
== LINESTYLE_SINGLE
? LINESTYLE_NONE
: LINESTYLE_SINGLE
, EE_CHAR_UNDERLINE
) );
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
));
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
));
187 case SID_ATTR_PARA_ADJUST_CENTER
:
188 aNewAttr
.Put(SvxAdjustItem(SvxAdjust::Center
, EE_PARA_JUST
));
190 case SID_ATTR_PARA_ADJUST_RIGHT
:
191 aNewAttr
.Put(SvxAdjustItem(SvxAdjust::Right
, EE_PARA_JUST
));
193 case SID_ATTR_PARA_ADJUST_BLOCK
:
194 aNewAttr
.Put(SvxAdjustItem(SvxAdjust::Block
, EE_PARA_JUST
));
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
);
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
);
221 case SID_ATTR_PARA_LINESPACE
:
224 SvxLineSpacingItem aLineSpace
= static_cast<const SvxLineSpacingItem
&>(pNewAttrs
->Get(
225 GetPool().GetWhich(nSlot
)));
226 aLineSpace
.SetWhich( EE_PARA_SBL
);
227 aNewAttr
.Put( aLineSpace
);
231 case SID_ATTR_PARA_ULSPACE
:
234 SvxULSpaceItem aULSpace
= static_cast<const SvxULSpaceItem
&>(pNewAttrs
->Get(
235 GetPool().GetWhich(nSlot
)));
236 aULSpace
.SetWhich( EE_PARA_ULSPACE
);
237 aNewAttr
.Put( aULSpace
);
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 );
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
);
265 case SID_ATTR_PARA_LINESPACE_10
:
267 SvxLineSpacingItem
aItem(LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
);
268 aItem
.SetPropLineSpace(100);
272 case SID_ATTR_PARA_LINESPACE_115
:
274 SvxLineSpacingItem
aItem(LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
);
275 aItem
.SetPropLineSpace(115);
279 case SID_ATTR_PARA_LINESPACE_15
:
281 SvxLineSpacingItem
aItem(LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
);
282 aItem
.SetPropLineSpace(150);
286 case SID_ATTR_PARA_LINESPACE_20
:
288 SvxLineSpacingItem
aItem(LINE_SPACE_DEFAULT_HEIGHT
, EE_PARA_SBL
);
289 aItem
.SetPropLineSpace(200);
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
);
302 aItem
.SetEscapement( SvxEscapement::Superscript
);
303 aNewAttr
.Put( aItem
);
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
);
314 aItem
.SetEscapement( SvxEscapement::Subscript
);
315 aNewAttr
.Put( aItem
);
319 case SID_CHAR_DLG_EFFECT
:
320 case SID_CHAR_DLG_POSITION
:
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");
364 pDlg
->SetCurPageId(pItem
->GetValue());
367 sal_uInt16 nRet
= pDlg
->Execute();
370 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
371 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
377 aNewAttr
.Put(*pArgs
);
380 case FN_FORMAT_FOOTNOTE_DLG
:
382 GetView().ExecFormatFootnote();
385 case FN_NUMBERING_OUTLINE_DLG
:
387 GetView().ExecNumberingOutline(GetPool());
391 case SID_OPEN_XML_FILTERSETTINGS
:
393 HandleOpenXmlFilterSettings(rReq
);
396 case FN_WORDCOUNT_DIALOG
:
398 GetView().UpdateWordCount(this, nSlot
);
403 const SfxItemSet
* pArgs
= rReq
.GetArgs();
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
)) );
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();
427 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
428 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
434 aNewAttr
.Put(*pArgs
);
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(
447 nCtrl
|= EEControlBits::ONLINESPELLING
|EEControlBits::ALLOWBIGOBJS
;
449 nCtrl
&= ~EEControlBits::ONLINESPELLING
;
450 pOutliner
->SetControlWord(nCtrl
);
452 m_rView
.ExecuteSlot(rReq
);
455 case SID_HYPERLINK_SETLINK
:
457 const SfxPoolItem
* pItem
= nullptr;
459 pNewAttrs
->GetItemState(nSlot
, false, &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();
474 pOLV
->SetSelection(aSel
);
476 pOLV
->InsertField(SvxFieldItem(aField
, EE_FEATURE_FIELD
));
481 case SID_EDIT_HYPERLINK
:
483 // Ensure the field is selected first
484 pOLV
->SelectFieldAtCursor();
485 GetView().GetViewFrame().GetDispatcher()->Execute(SID_HYPERLINK_DIALOG
);
489 case SID_REMOVE_HYPERLINK
:
491 URLFieldHelper::RemoveURLField(pOLV
->GetEditView());
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
});
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
);
522 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
523 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
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);
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
;
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();
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
) );
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);
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
);
600 assert(false && "wrong dispatcher");
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())
624 if (bRestoreSelection
)
627 pOLV
->GetEditView().SetSelection( aOldSelection
);
631 void SwDrawTextShell::GetState(SfxItemSet
& rSet
)
633 if (!IsTextEdit()) // Otherwise sometimes crash!
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;
650 sal_uInt16 nSlotId
= GetPool().GetSlotId(nWhich
);
654 case SID_LANGUAGE_STATUS
: //20412:
656 SwLangHelper::GetLanguageStatus(pOLV
, rSet
);
664 LanguageType nLang
= LANGUAGE_NONE
;
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
680 case SID_ATTR_PARA_ADJUST_LEFT
:
681 eAdjust
= SvxAdjust::Left
;
683 case SID_ATTR_PARA_ADJUST_RIGHT
:
684 eAdjust
= SvxAdjust::Right
;
686 case SID_ATTR_PARA_ADJUST_CENTER
:
687 eAdjust
= SvxAdjust::Center
;
689 case SID_ATTR_PARA_ADJUST_BLOCK
:
690 eAdjust
= SvxAdjust::Block
;
695 pAdjust
= aEditAttr
.GetItemIfSet(EE_PARA_JUST
, false);
697 if (!pAdjust
|| IsInvalidItem(pAdjust
))
699 rSet
.InvalidateItem(nSlotId
);
703 bFlag
= eAdjust
== pAdjust
->GetAdjust();
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
);
720 rSet
.InvalidateItem(nSlotId
);
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
);
733 rSet
.InvalidateItem(nSlotId
);
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
);
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
);
770 case SID_ATTR_PARA_LINESPACE_10
:
773 case SID_ATTR_PARA_LINESPACE_115
:
776 case SID_ATTR_PARA_LINESPACE_15
:
779 case SID_ATTR_PARA_LINESPACE_20
:
785 pLSpace
= aEditAttr
.GetItemIfSet(EE_PARA_SBL
, false);
787 if (!pLSpace
|| IsInvalidItem(pLSpace
))
789 rSet
.InvalidateItem(nSlotId
);
793 == pLSpace
->GetPropLineSpace())
797 // tdf#114631 - disable non selected line spacing
798 rSet
.Put(SfxBoolItem(nWhich
, false));
804 case FN_SET_SUPER_SCRIPT
:
805 nEsc
= SvxEscapement::Superscript
;
807 case FN_SET_SUB_SCRIPT
:
808 nEsc
= SvxEscapement::Subscript
;
813 pEscItem
= &aEditAttr
.Get(EE_CHAR_ESCAPEMENT
);
815 if (nEsc
== static_cast<const SvxEscapementItem
*>(pEscItem
)->GetEscapement())
824 // disable "Thesaurus" if the language is not supported
825 const SfxPoolItem
& rItem
= GetShell().GetDoc()->GetDefault(GetWhichOfScript(
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
);
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
);
846 GetView().GetViewFrame().GetBindings().SetVisibleState(nWhich
, true);
850 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
851 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
852 if (!SvtCJKOptions::IsVerticalTextEnabled())
854 rSet
.DisableItem(nSlotId
);
859 SdrOutliner
* pOutliner
= m_pSdrView
->GetTextEditOutliner();
861 bFlag
= pOutliner
->IsVertical()
862 == (SID_TEXTDIRECTION_TOP_TO_BOTTOM
== nSlotId
);
865 text::WritingMode eMode
= aEditAttr
.Get(SDRATTR_TEXTDIRECTION
).GetValue();
867 if (nSlotId
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
)
869 bFlag
= eMode
== text::WritingMode_LR_TB
;
873 bFlag
= eMode
!= text::WritingMode_TB_RL
;
878 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
879 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
881 if (!SvtCTLOptions::IsCTLFontEnabled())
883 rSet
.DisableItem(nWhich
);
888 SdrOutliner
* pOutliner
= m_pSdrView
->GetTextEditOutliner();
889 if (pOutliner
&& pOutliner
->IsVertical())
891 rSet
.DisableItem(nWhich
);
896 switch (aEditAttr
.Get(EE_PARA_WRITINGDIR
).GetValue())
898 case SvxFrameDirection::Horizontal_LR_TB
:
899 bFlag
= nWhich
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
902 case SvxFrameDirection::Horizontal_RL_TB
:
903 bFlag
= nWhich
!= SID_ATTR_PARA_LEFT_TO_RIGHT
;
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);
923 GetView().GetViewFrame().GetBindings().SetVisibleState(nWhich
, true);
929 bool bEnabled
= SvtCTLOptions::IsCTLFontEnabled();
930 GetView().GetViewFrame().GetBindings().SetVisibleState(nWhich
, bEnabled
);
932 rSet
.DisableItem(nWhich
);
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
);
946 nSlotId
= 0; // don't know this slot
951 rSet
.Put(SfxBoolItem(nWhich
, bFlag
));
953 nWhich
= aIter
.NextWhich();
957 void SwDrawTextShell::GetDrawTextCtrlState(SfxItemSet
& rSet
)
959 if (!IsTextEdit()) // Otherwise crash!
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();
970 sal_uInt16 nEEWhich
= 0;
971 sal_uInt16 nSlotId
= GetPool().GetSlotId( nWhich
);
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();
981 pEditPool
= aEditAttr
.GetPool();
982 SvxScriptSetItem
aSetItem( nSlotId
, *pEditPool
);
983 aSetItem
.GetItemSet().Put( aEditAttr
, false );
984 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScriptType
);
987 rSet
.Put(pI
->CloneSetWhich(nWhich
));
990 rSet
.InvalidateItem( nWhich
);
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
);
1004 rSet
.Put(SfxBoolItem(nWhich
, static_cast<const SfxBoolItem
*>(pState
)->GetValue()));
1006 rSet
.DisableItem( nWhich
);
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();
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
) ) );
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
);
1039 rSet
.Put(aEditAttr
.Get(nEEWhich
).CloneSetWhich(nWhich
));
1042 nWhich
= aIter
.NextWhich();
1046 void SwDrawTextShell::ExecClpbrd(SfxRequest
const &rReq
)
1048 if (!IsTextEdit()) // Otherwise crash!
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();
1069 pOLV
->PasteSpecial();
1072 case SID_PASTE_UNFORMATTED
:
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
)
1093 pOLV
->PasteSpecial();
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
)
1114 pOLV
->PasteSpecial();
1121 OSL_FAIL("wrong dispatcher");
1126 void SwDrawTextShell::StateClpbrd(SfxItemSet
&rSet
)
1128 if (!IsTextEdit()) // Otherwise crash!
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();
1150 if( !bCopy
|| GetObjectShell()->isContentExtractionLocked())
1151 rSet
.DisableItem( nWhich
);
1155 case SID_PASTE_UNFORMATTED
:
1156 case SID_PASTE_SPECIAL
:
1158 rSet
.DisableItem( nWhich
);
1161 case SID_CLIPBOARD_FORMAT_ITEMS
:
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
);
1176 rSet
.DisableItem( nWhich
);
1180 nWhich
= aIter
.NextWhich();
1186 void SwDrawTextShell::StateInsert(SfxItemSet
&rSet
)
1188 if (!IsTextEdit()) // Otherwise crash!
1191 OutlinerView
* pOLV
= m_pSdrView
->GetTextEditOutlinerView();
1192 SfxWhichIter
aIter(rSet
);
1193 sal_uInt16 nWhich
= aIter
.FirstWhich();
1199 case SID_HYPERLINK_GETLINK
:
1201 SvxHyperlinkItem aHLinkItem
;
1202 aHLinkItem
.SetInsertMode(HLINK_FIELD
);
1204 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
1208 const SvxURLField
* pURLField
= dynamic_cast<const SvxURLField
*>(pFieldItem
->GetField());
1212 aHLinkItem
.SetName(pURLField
->GetRepresentation());
1213 aHLinkItem
.SetURL(pURLField
->GetURL());
1214 aHLinkItem
.SetTargetFrame(pURLField
->GetTargetFrame());
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
);
1232 nWhich
= aIter
.NextWhich();
1236 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */