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/ui/dialogs/XSLTFilterDialog.hpp>
23 #include <comphelper/processfactory.hxx>
24 #include <comphelper/string.hxx>
25 #include <i18nlangtag/mslangid.hxx>
26 #include <sfx2/bindings.hxx>
27 #include <sfx2/dispatch.hxx>
28 #include <sfx2/request.hxx>
29 #include <tools/shl.hxx>
30 #include <svx/svdview.hxx>
31 #include <editeng/spltitem.hxx>
32 #include <editeng/lrspitem.hxx>
33 #include <editeng/ulspitem.hxx>
34 #include <editeng/orphitem.hxx>
35 #include <editeng/formatbreakitem.hxx>
36 #include <editeng/widwitem.hxx>
37 #include <editeng/kernitem.hxx>
38 #include <editeng/escapementitem.hxx>
39 #include <editeng/lspcitem.hxx>
40 #include <editeng/adjustitem.hxx>
41 #include <editeng/crossedoutitem.hxx>
42 #include <editeng/shdditem.hxx>
43 #include <editeng/udlnitem.hxx>
44 #include <editeng/fontitem.hxx>
45 #include <editeng/fhgtitem.hxx>
46 #include <editeng/colritem.hxx>
47 #include <editeng/wghtitem.hxx>
48 #include <editeng/contouritem.hxx>
49 #include <editeng/postitem.hxx>
50 #include <editeng/frmdiritem.hxx>
51 #include <svx/svdoutl.hxx>
52 #include <sfx2/viewfrm.hxx>
53 #include <svl/whiter.hxx>
54 #include <svl/cjkoptions.hxx>
55 #include <svl/ctloptions.hxx>
56 #include <svtools/langtab.hxx>
57 #include <svl/languageoptions.hxx>
58 #include <vcl/msgbox.hxx>
59 #include <editeng/flditem.hxx>
60 #include <editeng/editstat.hxx>
61 #include <svx/hlnkitem.hxx>
62 #include <sfx2/htmlmode.hxx>
63 #include <svl/slstitm.hxx>
64 #include <editeng/langitem.hxx>
65 #include <editeng/unolingu.hxx>
66 #include <editeng/scripttypeitem.hxx>
67 #include <editeng/writingmodeitem.hxx>
68 #include <editeng/eeitem.hxx>
69 #include <editeng/editeng.hxx>
70 #include <editeng/editdata.hxx>
71 #include <editeng/outliner.hxx>
72 #include <vcl/window.hxx>
73 #include <editeng/editview.hxx>
74 #include <vcl/outdev.hxx>
75 #include <editeng/hyphenzoneitem.hxx>
76 #include <tools/diagnose_ex.h>
80 #include <docstat.hxx>
81 #include <drwtxtsh.hxx>
83 #include <globals.hrc>
84 #include <hintids.hxx>
85 #include <initui.hxx> // for SpellPointer
86 #include <langhelper.hxx>
90 #include <swdtflvr.hxx>
91 #include <swmodule.hxx>
94 #include <viewopt.hxx>
97 #include <wordcountdialog.hxx>
99 #include "swabstdlg.hxx"
100 #include "chrdlg.hrc"
104 using namespace ::com::sun::star
;
106 void SwDrawTextShell::Execute( SfxRequest
&rReq
)
108 SwWrtShell
&rSh
= GetShell();
109 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
110 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
111 SfxItemSet
aNewAttr(*aEditAttr
.GetPool(), aEditAttr
.GetRanges());
113 const sal_uInt16 nSlot
= rReq
.GetSlot();
115 const sal_uInt16 nWhich
= GetPool().GetWhich(nSlot
);
116 const SfxItemSet
*pNewAttrs
= rReq
.GetArgs();
118 bool bRestoreSelection
= false;
119 ESelection aOldSelection
;
121 sal_uInt16 nEEWhich
= 0;
124 case SID_LANGUAGE_STATUS
:
126 aOldSelection
= pOLV
->GetSelection();
127 if (!pOLV
->GetEditView().HasSelection())
129 bRestoreSelection
= true;
130 pOLV
->GetEditView().SelectCurrentWord();
133 bRestoreSelection
= SwLangHelper::SetLanguageStatus(pOLV
,rReq
,GetView(),rSh
);
140 SFX_REQUEST_ARG( rReq
, pItem2
, SfxStringItem
, SID_THES
, sal_False
);
142 aReplaceText
= pItem2
->GetValue();
143 if (aReplaceText
.Len() > 0)
144 ReplaceTextWithSynonym( pOLV
->GetEditView(), aReplaceText
);
148 case SID_ATTR_CHAR_FONT
:
149 case SID_ATTR_CHAR_FONTHEIGHT
:
150 case SID_ATTR_CHAR_WEIGHT
:
151 case SID_ATTR_CHAR_POSTURE
:
153 SfxItemPool
* pPool2
= aEditAttr
.GetPool()->GetSecondaryPool();
155 pPool2
= aEditAttr
.GetPool();
156 SvxScriptSetItem
aSetItem( nSlot
, *pPool2
);
158 // #i78017 establish the same behaviour as in Writer
159 sal_uInt16 nScriptTypes
= SCRIPTTYPE_LATIN
| SCRIPTTYPE_ASIAN
| SCRIPTTYPE_COMPLEX
;
160 if (nSlot
== SID_ATTR_CHAR_FONT
)
161 nScriptTypes
= pOLV
->GetSelectedScriptType();
165 aSetItem
.PutItemForScriptType( nScriptTypes
, pNewAttrs
->Get( nWhich
) );
166 aNewAttr
.Put( aSetItem
.GetItemSet() );
171 case SID_ATTR_CHAR_COLOR
: nEEWhich
= EE_CHAR_COLOR
; break;
173 case SID_ATTR_CHAR_UNDERLINE
:
177 const SvxTextLineItem
& rTextLineItem
= static_cast< const SvxTextLineItem
& >( pNewAttrs
->Get( pNewAttrs
->GetPool()->GetWhich(nSlot
) ) );
178 aNewAttr
.Put( SvxUnderlineItem( rTextLineItem
.GetLineStyle(), EE_CHAR_UNDERLINE
) );
182 FontUnderline eFU
= ((const SvxUnderlineItem
&)aEditAttr
.Get(EE_CHAR_UNDERLINE
)).GetLineStyle();
183 aNewAttr
.Put( SvxUnderlineItem(eFU
== UNDERLINE_SINGLE
? UNDERLINE_NONE
: UNDERLINE_SINGLE
, EE_CHAR_UNDERLINE
) );
188 case SID_ATTR_CHAR_OVERLINE
:
190 FontUnderline eFO
= ((const SvxOverlineItem
&)aEditAttr
.Get(EE_CHAR_OVERLINE
)).GetLineStyle();
191 aNewAttr
.Put(SvxOverlineItem(eFO
== UNDERLINE_SINGLE
? UNDERLINE_NONE
: UNDERLINE_SINGLE
, EE_CHAR_OVERLINE
));
195 case SID_ATTR_CHAR_CONTOUR
: nEEWhich
= EE_CHAR_OUTLINE
; break;
196 case SID_ATTR_CHAR_SHADOWED
: nEEWhich
= EE_CHAR_SHADOW
; break;
197 case SID_ATTR_CHAR_STRIKEOUT
: nEEWhich
= EE_CHAR_STRIKEOUT
; break;
198 case SID_ATTR_CHAR_WORDLINEMODE
: nEEWhich
= EE_CHAR_WLM
; break;
199 case SID_ATTR_CHAR_RELIEF
: nEEWhich
= EE_CHAR_RELIEF
; break;
200 case SID_ATTR_CHAR_LANGUAGE
: nEEWhich
= EE_CHAR_LANGUAGE
;break;
201 case SID_ATTR_CHAR_KERNING
: nEEWhich
= EE_CHAR_KERNING
; break;
202 case SID_ATTR_CHAR_SCALEWIDTH
: nEEWhich
= EE_CHAR_FONTWIDTH
; break;
203 case SID_ATTR_CHAR_AUTOKERN
: nEEWhich
= EE_CHAR_PAIRKERNING
; break;
204 case SID_ATTR_CHAR_ESCAPEMENT
: nEEWhich
= EE_CHAR_ESCAPEMENT
; break;
205 case SID_ATTR_PARA_ADJUST_LEFT
:
206 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_LEFT
, EE_PARA_JUST
));
208 case SID_ATTR_PARA_ADJUST_CENTER
:
209 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_CENTER
, EE_PARA_JUST
));
211 case SID_ATTR_PARA_ADJUST_RIGHT
:
212 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_RIGHT
, EE_PARA_JUST
));
214 case SID_ATTR_PARA_ADJUST_BLOCK
:
215 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_BLOCK
, EE_PARA_JUST
));
217 case SID_ATTR_PARA_LRSPACE
:
219 SvxLRSpaceItem
aParaMargin((const SvxLRSpaceItem
&)rReq
.
220 GetArgs()->Get(nSlot
));
221 aParaMargin
.SetWhich( EE_PARA_LRSPACE
);
222 aNewAttr
.Put(aParaMargin
);
226 case SID_ATTR_PARA_LINESPACE
:
228 SvxLineSpacingItem aLineSpace
= (const SvxLineSpacingItem
&)pNewAttrs
->Get(
229 GetPool().GetWhich(nSlot
));
230 aLineSpace
.SetWhich( EE_PARA_SBL
);
231 aNewAttr
.Put( aLineSpace
);
235 case SID_ATTR_PARA_ULSPACE
:
237 SvxULSpaceItem aULSpace
= (const SvxULSpaceItem
&)pNewAttrs
->Get(
238 GetPool().GetWhich(nSlot
));
239 aULSpace
.SetWhich( EE_PARA_ULSPACE
);
240 aNewAttr
.Put( aULSpace
);
245 case SID_ATTR_PARA_LINESPACE_10
:
247 SvxLineSpacingItem
aItem(SVX_LINESPACE_ONE_LINE
, EE_PARA_SBL
);
248 aItem
.SetPropLineSpace(100);
252 case SID_ATTR_PARA_LINESPACE_15
:
254 SvxLineSpacingItem
aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES
, EE_PARA_SBL
);
255 aItem
.SetPropLineSpace(150);
259 case SID_ATTR_PARA_LINESPACE_20
:
261 SvxLineSpacingItem
aItem(SVX_LINESPACE_TWO_LINES
, EE_PARA_SBL
);
262 aItem
.SetPropLineSpace(200);
267 case FN_SET_SUPER_SCRIPT
:
269 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
270 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
271 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
273 if( eEsc
== SVX_ESCAPEMENT_SUPERSCRIPT
)
274 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
276 aItem
.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT
);
277 aNewAttr
.Put( aItem
, EE_CHAR_ESCAPEMENT
);
280 case FN_SET_SUB_SCRIPT
:
282 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
283 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
284 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
286 if( eEsc
== SVX_ESCAPEMENT_SUBSCRIPT
)
287 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
289 aItem
.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT
);
290 aNewAttr
.Put( aItem
, EE_CHAR_ESCAPEMENT
);
294 case SID_CHAR_DLG_EFFECT
:
296 case SID_CHAR_DLG_FOR_PARAGRAPH
:
298 const SfxItemSet
* pArgs
= rReq
.GetArgs();
302 aOldSelection
= pOLV
->GetSelection();
303 if (nSlot
== SID_CHAR_DLG_FOR_PARAGRAPH
)
305 // select current paragraph (and restore selection later on...)
306 EditView
& rEditView
= pOLV
->GetEditView();
307 SwLangHelper::SelectPara( rEditView
, rEditView
.GetSelection() );
308 bRestoreSelection
= true;
311 SwView
* pView
= &GetView();
312 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, pView
));
313 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
)) );
314 SfxItemSet
aDlgAttr(GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
316 // util::Language does not exists in the EditEngine! That is why not in set.
318 aDlgAttr
.Put( aEditAttr
);
319 aDlgAttr
.Put( SvxKerningItem(0, RES_CHRATR_KERNING
) );
321 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
322 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
324 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwCharDlg(pView
->GetWindow(), *pView
, aDlgAttr
, 0, sal_True
);
325 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
326 if (nSlot
== SID_CHAR_DLG_EFFECT
)
328 pDlg
->SetCurPageId(TP_CHAR_EXT
);
330 sal_uInt16 nRet
= pDlg
->Execute();
333 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
334 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
341 aNewAttr
.Put(*pArgs
);
344 case FN_FORMAT_FOOTNOTE_DLG
:
346 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
347 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
349 VclAbstractDialog
* pDlg
= pFact
->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rView
.GetWrtShell(), DLG_DOC_FOOTNOTE
);
350 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
355 case FN_NUMBERING_OUTLINE_DLG
:
357 SfxItemSet
aTmp(GetPool(), FN_PARAM_1
, FN_PARAM_1
);
358 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
359 OSL_ENSURE(pFact
, "Dialogdiet fail!");
360 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTabDialog( DLG_TAB_OUTLINE
,
361 GetView().GetWindow(), &aTmp
, GetView().GetWrtShell());
362 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
368 case SID_OPEN_XML_FILTERSETTINGS
:
372 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog
= ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
375 catch (const uno::Exception
&)
377 DBG_UNHANDLED_EXCEPTION();
382 case FN_WORDCOUNT_DIALOG
:
384 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
387 pVFrame
->ToggleChildWindow(FN_WORDCOUNT_DIALOG
);
388 Invalidate(rReq
.GetSlot());
390 SwWordCountWrapper
*pWrdCnt
= (SwWordCountWrapper
*)pVFrame
->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
392 pWrdCnt
->UpdateCounts();
398 const SfxItemSet
* pArgs
= rReq
.GetArgs();
402 SwView
* pView
= &GetView();
403 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, pView
));
404 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
)) );
405 SfxItemSet
aDlgAttr(GetPool(),
406 EE_ITEMS_START
, EE_ITEMS_END
,
407 SID_ATTR_PARA_HYPHENZONE
, SID_ATTR_PARA_HYPHENZONE
,
408 SID_ATTR_PARA_SPLIT
, SID_ATTR_PARA_SPLIT
,
409 SID_ATTR_PARA_WIDOWS
, SID_ATTR_PARA_WIDOWS
,
410 SID_ATTR_PARA_ORPHANS
, SID_ATTR_PARA_ORPHANS
,
413 aDlgAttr
.Put(aEditAttr
);
415 aDlgAttr
.Put( SvxHyphenZoneItem( sal_False
, RES_PARATR_HYPHENZONE
) );
416 aDlgAttr
.Put( SvxFmtBreakItem( SVX_BREAK_NONE
, RES_BREAK
) );
417 aDlgAttr
.Put( SvxFmtSplitItem( sal_True
, RES_PARATR_SPLIT
) );
418 aDlgAttr
.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS
) );
419 aDlgAttr
.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS
) );
421 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
422 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
424 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr
,DLG_STD
, DLG_PARA
, 0, sal_True
);
425 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
426 sal_uInt16 nRet
= pDlg
->Execute();
429 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
430 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
437 aNewAttr
.Put(*pArgs
);
440 case SID_AUTOSPELL_CHECK
:
442 //!! JP 16.03.2001: why?? pSdrView = rSh.GetDrawView();
443 //!! JP 16.03.2001: why?? pOutliner = pSdrView->GetTextEditOutliner();
444 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
445 sal_uInt32 nCtrl
= pOutliner
->GetControlWord();
447 sal_Bool bSet
= ((const SfxBoolItem
&)rReq
.GetArgs()->Get(
450 nCtrl
|= EE_CNTRL_ONLINESPELLING
|EE_CNTRL_ALLOWBIGOBJS
;
452 nCtrl
&= ~EE_CNTRL_ONLINESPELLING
;
453 pOutliner
->SetControlWord(nCtrl
);
455 rView
.ExecuteSlot(rReq
);
458 case SID_HYPERLINK_SETLINK
:
460 const SfxPoolItem
* pItem
= 0;
462 pNewAttrs
->GetItemState(nSlot
, sal_False
, &pItem
);
466 const SvxHyperlinkItem
& rHLinkItem
= *(const SvxHyperlinkItem
*)pItem
;
467 SvxURLField
aFld(rHLinkItem
.GetURL(), rHLinkItem
.GetName(), SVXURLFORMAT_APPDEFAULT
);
468 aFld
.SetTargetFrame(rHLinkItem
.GetTargetFrame());
470 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
472 if (pFieldItem
&& pFieldItem
->GetField()->ISA(SvxURLField
))
474 // Select field so that it will be deleted during insert
475 ESelection aSel
= pOLV
->GetSelection();
477 pOLV
->SetSelection(aSel
);
479 pOLV
->InsertField(SvxFieldItem(aFld
, EE_FEATURE_FIELD
));
484 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
485 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
488 SdrObject
* pTmpObj
= pSdrView
->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
489 SdrPageView
* pTmpPV
= pSdrView
->GetSdrPageView();
490 SdrView
* pTmpView
= pSdrView
;
492 pSdrView
->SdrEndTextEdit(sal_True
);
494 SfxItemSet
aAttr( *aNewAttr
.GetPool(),
495 SDRATTR_TEXTDIRECTION
,
496 SDRATTR_TEXTDIRECTION
);
498 aAttr
.Put( SvxWritingModeItem(
499 nSlot
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
?
500 text::WritingMode_LR_TB
501 : text::WritingMode_TB_RL
, SDRATTR_TEXTDIRECTION
) );
502 pTmpView
->SetAttributes( aAttr
);
504 rSh
.GetView().BeginTextEdit( pTmpObj
, pTmpPV
, &rSh
.GetView().GetEditWin(), sal_False
);
505 rSh
.GetView().AttrChangedNotify( &rSh
);
509 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
510 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
512 SdrObject
* pTmpObj
= pSdrView
->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
513 SdrPageView
* pTmpPV
= pSdrView
->GetSdrPageView();
514 SdrView
* pTmpView
= pSdrView
;
516 pSdrView
->SdrEndTextEdit(sal_True
);
517 bool bLeftToRight
= nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
519 const SfxPoolItem
* pPoolItem
;
520 if( pNewAttrs
&& SFX_ITEM_SET
== pNewAttrs
->GetItemState( nSlot
, sal_True
, &pPoolItem
) )
522 if( !( (SfxBoolItem
*)pPoolItem
)->GetValue() )
523 bLeftToRight
= !bLeftToRight
;
525 SfxItemSet
aAttr( *aNewAttr
.GetPool(),
526 EE_PARA_JUST
, EE_PARA_JUST
,
527 EE_PARA_WRITINGDIR
, EE_PARA_WRITINGDIR
,
530 sal_uInt16 nAdjust
= SVX_ADJUST_LEFT
;
531 if( SFX_ITEM_ON
== aEditAttr
.GetItemState(EE_PARA_JUST
, sal_True
, &pPoolItem
) )
532 nAdjust
= ( (SvxAdjustItem
*)pPoolItem
)->GetEnumValue();
536 aAttr
.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP
, EE_PARA_WRITINGDIR
) );
537 if( nAdjust
== SVX_ADJUST_RIGHT
)
538 aAttr
.Put( SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
) );
542 aAttr
.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP
, EE_PARA_WRITINGDIR
) );
543 if( nAdjust
== SVX_ADJUST_LEFT
)
544 aAttr
.Put( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
546 pTmpView
->SetAttributes( aAttr
);
547 rSh
.GetView().BeginTextEdit( pTmpObj
, pTmpPV
, &rSh
.GetView().GetEditWin(), sal_False
);
548 rSh
.GetView().AttrChangedNotify( &rSh
);
552 OSL_ENSURE(!this, "wrong dispatcher");
555 if(nEEWhich
&& pNewAttrs
)
556 aNewAttr
.Put(pNewAttrs
->Get(nWhich
), nEEWhich
);
558 SetAttrToMarked(aNewAttr
);
560 GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
562 if (IsTextEdit() && pOLV
->GetOutliner()->IsModified())
565 if (bRestoreSelection
)
568 pOLV
->GetEditView().SetSelection( aOldSelection
);
572 void SwDrawTextShell::GetState(SfxItemSet
& rSet
)
574 if (!IsTextEdit()) // Otherwise sometimes crash!
577 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
578 SfxWhichIter
aIter(rSet
);
579 sal_uInt16 nWhich
= aIter
.FirstWhich();
581 SfxItemSet
aEditAttr( pOLV
->GetAttribs() );
582 const SfxPoolItem
*pAdjust
= 0, *pLSpace
= 0, *pEscItem
= 0;
583 int eAdjust
, nLSpace
, nEsc
;
587 sal_uInt16 nSlotId
= GetPool().GetSlotId( nWhich
);
588 sal_Bool bFlag
= sal_False
;
591 case SID_LANGUAGE_STATUS
://20412:
593 nSlotId
= SwLangHelper::GetLanguageStatus(pOLV
,rSet
);
600 LanguageType nLang
= LANGUAGE_NONE
;
601 bool bIsLookUpWord
= GetStatusValueForThesaurusFromContext( aStatusVal
, nLang
, pOLV
->GetEditView() );
602 rSet
.Put( SfxStringItem( SID_THES
, aStatusVal
) );
604 // disable "Thesaurus" context menu entry if there is nothing to look up
605 uno::Reference
< linguistic2::XThesaurus
> xThes( ::GetThesaurus() );
606 if (!bIsLookUpWord
||
607 !xThes
.is() || nLang
== LANGUAGE_NONE
|| !xThes
->hasLocale( LanguageTag( nLang
).getLocale() ))
608 rSet
.DisableItem( SID_THES
);
610 //! avoid putting the same item as SfxBoolItem at the end of this function
615 case SID_ATTR_PARA_ADJUST_LEFT
: eAdjust
= SVX_ADJUST_LEFT
; goto ASK_ADJUST
;
616 case SID_ATTR_PARA_ADJUST_RIGHT
: eAdjust
= SVX_ADJUST_RIGHT
; goto ASK_ADJUST
;
617 case SID_ATTR_PARA_ADJUST_CENTER
: eAdjust
= SVX_ADJUST_CENTER
; goto ASK_ADJUST
;
618 case SID_ATTR_PARA_ADJUST_BLOCK
: eAdjust
= SVX_ADJUST_BLOCK
; goto ASK_ADJUST
;
622 aEditAttr
.GetItemState( EE_PARA_JUST
, sal_False
, &pAdjust
);
624 if( !pAdjust
|| IsInvalidItem( pAdjust
))
625 rSet
.InvalidateItem( nSlotId
), nSlotId
= 0;
627 bFlag
= eAdjust
== ((SvxAdjustItem
*)pAdjust
)->GetAdjust();
631 case SID_ATTR_PARA_LRSPACE
:
633 SfxItemState eState
= aEditAttr
.GetItemState(EE_PARA_LRSPACE
);
634 if( eState
>= SFX_ITEM_DEFAULT
)
636 SvxLRSpaceItem aLR
= (const SvxLRSpaceItem
&) aEditAttr
.Get( EE_PARA_LRSPACE
);
637 aLR
.SetWhich(SID_ATTR_PARA_LRSPACE
);
641 rSet
.InvalidateItem(nSlotId
);
645 case SID_ATTR_PARA_LINESPACE
:
647 SfxItemState eState
= aEditAttr
.GetItemState(EE_PARA_SBL
);
648 if( eState
>= SFX_ITEM_DEFAULT
)
650 SvxLineSpacingItem aLR
= (const SvxLineSpacingItem
&) aEditAttr
.Get( EE_PARA_SBL
);
654 rSet
.InvalidateItem(nSlotId
);
658 case SID_ATTR_PARA_ULSPACE
:
660 SfxItemState eState
= aEditAttr
.GetItemState(EE_PARA_ULSPACE
);
661 if( eState
>= SFX_ITEM_DEFAULT
)
663 SvxULSpaceItem aULSpace
= (const SvxULSpaceItem
&) aEditAttr
.Get( EE_PARA_ULSPACE
);
664 aULSpace
.SetWhich(SID_ATTR_PARA_ULSPACE
);
668 rSet
.InvalidateItem(nSlotId
);
669 Invalidate(SID_ATTR_PARA_ULSPACE
);
674 case SID_ATTR_PARA_LINESPACE_10
: nLSpace
= 100; goto ASK_LINESPACE
;
675 case SID_ATTR_PARA_LINESPACE_15
: nLSpace
= 150; goto ASK_LINESPACE
;
676 case SID_ATTR_PARA_LINESPACE_20
: nLSpace
= 200; goto ASK_LINESPACE
;
680 aEditAttr
.GetItemState( EE_PARA_SBL
, sal_False
, &pLSpace
);
682 if( !pLSpace
|| IsInvalidItem( pLSpace
))
683 rSet
.InvalidateItem( nSlotId
), nSlotId
= 0;
684 else if( nLSpace
== ((const SvxLineSpacingItem
*)pLSpace
)->
692 case FN_SET_SUPER_SCRIPT
: nEsc
= SVX_ESCAPEMENT_SUPERSCRIPT
;
694 case FN_SET_SUB_SCRIPT
: nEsc
= SVX_ESCAPEMENT_SUBSCRIPT
;
699 pEscItem
= &aEditAttr
.Get( EE_CHAR_ESCAPEMENT
);
701 if( nEsc
== ((const SvxEscapementItem
*)
702 pEscItem
)->GetEnumValue() )
711 // disable "Thesaurus" if the language is not supported
712 const SfxPoolItem
&rItem
= GetShell().GetDoc()->GetDefault(
713 GetWhichOfScript( RES_CHRATR_LANGUAGE
,
714 GetI18NScriptTypeOfLanguage( (sal_uInt16
)GetAppLanguage())) );
715 LanguageType nLang
= ((const SvxLanguageItem
&) rItem
).GetLanguage();
717 uno::Reference
< linguistic2::XThesaurus
> xThes( ::GetThesaurus() );
718 if (!xThes
.is() || nLang
== LANGUAGE_NONE
|| !xThes
->hasLocale( LanguageTag( nLang
).getLocale() ))
719 rSet
.DisableItem( SID_THESAURUS
);
723 case SID_HANGUL_HANJA_CONVERSION
:
724 case SID_CHINESE_CONVERSION
:
726 if (!SvtCJKOptions().IsAnyEnabled())
728 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
729 rSet
.DisableItem(nWhich
);
732 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
736 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
737 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
738 if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
740 rSet
.DisableItem( nSlotId
);
745 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
747 bFlag
= pOutliner
->IsVertical() ==
748 (SID_TEXTDIRECTION_TOP_TO_BOTTOM
== nSlotId
);
751 text::WritingMode eMode
= (text::WritingMode
)
752 ( (const SvxWritingModeItem
&) aEditAttr
.Get( SDRATTR_TEXTDIRECTION
) ).GetValue();
754 if( nSlotId
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
)
756 bFlag
= eMode
== text::WritingMode_LR_TB
;
760 bFlag
= eMode
!= text::WritingMode_TB_RL
;
765 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
766 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
768 if ( !SvtLanguageOptions().IsCTLFontEnabled() )
770 rSet
.DisableItem( nWhich
);
775 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
776 if(pOutliner
&& pOutliner
->IsVertical())
778 rSet
.DisableItem( nWhich
);
783 switch( ( ( (SvxFrameDirectionItem
&) aEditAttr
.Get( EE_PARA_WRITINGDIR
) ) ).GetValue() )
785 case FRMDIR_HORI_LEFT_TOP
:
786 bFlag
= nWhich
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
789 case FRMDIR_HORI_RIGHT_TOP
:
790 bFlag
= nWhich
!= SID_ATTR_PARA_LEFT_TO_RIGHT
;
797 case SID_TRANSLITERATE_HALFWIDTH
:
798 case SID_TRANSLITERATE_FULLWIDTH
:
799 case SID_TRANSLITERATE_HIRAGANA
:
800 case SID_TRANSLITERATE_KATAGANA
:
802 SvtCJKOptions aCJKOptions
;
803 if(!aCJKOptions
.IsChangeCaseMapEnabled())
805 rSet
.DisableItem(nWhich
);
806 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
809 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
812 case SID_INSERT_RLM
:
813 case SID_INSERT_LRM
:
814 case SID_INSERT_ZWNBSP
:
815 case SID_INSERT_ZWSP
:
817 SvtCTLOptions aCTLOptions
;
818 sal_Bool bEnabled
= aCTLOptions
.IsCTLFontEnabled();
819 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, bEnabled
);
821 rSet
.DisableItem(nWhich
);
825 nSlotId
= 0; // don't know this slot
830 rSet
.Put( SfxBoolItem( nWhich
, bFlag
));
832 nWhich
= aIter
.NextWhich();
836 void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet
& rSet
)
838 if (!IsTextEdit()) // Otherwise crash!
841 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
842 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
844 SfxWhichIter
aIter(rSet
);
845 sal_uInt16 nWhich
= aIter
.FirstWhich();
846 sal_uInt16 nScriptType
= pOLV
->GetSelectedScriptType();
849 sal_uInt16 nEEWhich
= 0;
850 sal_uInt16 nSlotId
= GetPool().GetSlotId( nWhich
);
853 case SID_ATTR_CHAR_FONT
:
854 case SID_ATTR_CHAR_FONTHEIGHT
:
855 case SID_ATTR_CHAR_WEIGHT
:
856 case SID_ATTR_CHAR_POSTURE
:
858 SfxItemPool
* pEditPool
= aEditAttr
.GetPool()->GetSecondaryPool();
860 pEditPool
= aEditAttr
.GetPool();
861 SvxScriptSetItem
aSetItem( nSlotId
, *pEditPool
);
862 aSetItem
.GetItemSet().Put( aEditAttr
, sal_False
);
863 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScriptType
);
865 rSet
.Put( *pI
, nWhich
);
867 rSet
.InvalidateItem( nWhich
);
870 case SID_ATTR_CHAR_COLOR
: nEEWhich
= EE_CHAR_COLOR
; break;
871 case SID_ATTR_CHAR_UNDERLINE
: nEEWhich
= EE_CHAR_UNDERLINE
;break;
872 case SID_ATTR_CHAR_OVERLINE
: nEEWhich
= EE_CHAR_OVERLINE
;break;
873 case SID_ATTR_CHAR_CONTOUR
: nEEWhich
= EE_CHAR_OUTLINE
; break;
874 case SID_ATTR_CHAR_SHADOWED
: nEEWhich
= EE_CHAR_SHADOW
;break;
875 case SID_ATTR_CHAR_STRIKEOUT
: nEEWhich
= EE_CHAR_STRIKEOUT
;break;
876 case SID_AUTOSPELL_CHECK
:
878 const SfxPoolItem
* pState
= rView
.GetSlotState(nWhich
);
880 rSet
.Put(SfxBoolItem(nWhich
, ((const SfxBoolItem
*)pState
)->GetValue()));
882 rSet
.DisableItem( nWhich
);
885 case SID_ATTR_CHAR_WORDLINEMODE
: nEEWhich
= EE_CHAR_WLM
; break;
886 case SID_ATTR_CHAR_RELIEF
: nEEWhich
= EE_CHAR_RELIEF
; break;
887 case SID_ATTR_CHAR_LANGUAGE
: nEEWhich
= EE_CHAR_LANGUAGE
;break;
888 case SID_ATTR_CHAR_KERNING
: nEEWhich
= EE_CHAR_KERNING
; break;
889 case SID_ATTR_CHAR_SCALEWIDTH
: nEEWhich
= EE_CHAR_FONTWIDTH
;break;
890 case SID_ATTR_CHAR_AUTOKERN
: nEEWhich
= EE_CHAR_PAIRKERNING
; break;
891 case SID_ATTR_CHAR_ESCAPEMENT
: nEEWhich
= EE_CHAR_ESCAPEMENT
; break;
894 rSet
.Put(aEditAttr
.Get(nEEWhich
, sal_True
), nWhich
);
896 nWhich
= aIter
.NextWhich();
900 void SwDrawTextShell::ExecClpbrd(SfxRequest
&rReq
)
902 if (!IsTextEdit()) // Otherwise crash!
905 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
907 ESelection
aSel(pOLV
->GetSelection());
908 const bool bCopy
= (aSel
.nStartPara
!= aSel
.nEndPara
) || (aSel
.nStartPos
!= aSel
.nEndPos
);
909 sal_uInt16 nId
= rReq
.GetSlot();
923 pOLV
->PasteSpecial();
927 OSL_FAIL("wrong dispatcher");
932 void SwDrawTextShell::StateClpbrd(SfxItemSet
&rSet
)
934 if (!IsTextEdit()) // Otherwise crash!
937 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
938 ESelection
aSel(pOLV
->GetSelection());
939 const bool bCopy
= (aSel
.nStartPara
!= aSel
.nEndPara
) ||
940 (aSel
.nStartPos
!= aSel
.nEndPos
);
943 SfxWhichIter
aIter(rSet
);
944 sal_uInt16 nWhich
= aIter
.FirstWhich();
953 rSet
.DisableItem( nWhich
);
958 TransferableDataHelper
aDataHelper(
959 TransferableDataHelper::CreateFromSystemClipboard(
960 &GetView().GetEditWin() ) );
962 if( !aDataHelper
.GetXTransferable().is() ||
963 !SwTransferable::IsPaste( GetShell(), aDataHelper
))
964 rSet
.DisableItem( SID_PASTE
);
968 case SID_PASTE_SPECIAL
:
969 rSet
.DisableItem( SID_PASTE_SPECIAL
);
972 case SID_CLIPBOARD_FORMAT_ITEMS
:
973 rSet
.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS
);
976 nWhich
= aIter
.NextWhich();
982 void SwDrawTextShell::StateInsert(SfxItemSet
&rSet
)
984 if (!IsTextEdit()) // Otherwise crash!
987 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
988 SfxWhichIter
aIter(rSet
);
989 sal_uInt16 nWhich
= aIter
.FirstWhich();
995 case SID_HYPERLINK_GETLINK
:
997 SvxHyperlinkItem aHLinkItem
;
998 aHLinkItem
.SetInsertMode(HLINK_FIELD
);
1000 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
1004 const SvxFieldData
* pField
= pFieldItem
->GetField();
1006 if (pField
->ISA(SvxURLField
))
1008 aHLinkItem
.SetName(((const SvxURLField
*) pField
)->GetRepresentation());
1009 aHLinkItem
.SetURL(((const SvxURLField
*) pField
)->GetURL());
1010 aHLinkItem
.SetTargetFrame(((const SvxURLField
*) pField
)->GetTargetFrame());
1015 String
sSel(pOLV
->GetSelected());
1017 aHLinkItem
.SetName(comphelper::string::stripEnd(sSel
, ' '));
1020 sal_uInt16 nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
1021 aHLinkItem
.SetInsertMode((SvxLinkInsertMode
)(aHLinkItem
.GetInsertMode() |
1022 ((nHtmlMode
& HTMLMODE_ON
) != 0 ? HLINK_HTMLMODE
: 0)));
1024 rSet
.Put(aHLinkItem
);
1028 nWhich
= aIter
.NextWhich();
1032 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */