1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drwtxtex.cxx,v $
10 * $Revision: 1.46.82.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <hintids.hxx>
35 #include <tools/shl.hxx>
36 #include <svx/svdview.hxx>
37 #include <svx/spltitem.hxx>
38 #include <svx/orphitem.hxx>
39 #include <svx/brkitem.hxx>
40 #include <svx/widwitem.hxx>
41 #include <svx/kernitem.hxx>
42 #include <svx/escpitem.hxx>
43 #ifndef _SVX_PARAITEM_HXX //autogen
44 #include <svx/lspcitem.hxx>
46 #include <svx/adjitem.hxx>
47 #include <svx/crsditem.hxx>
48 #include <svx/shdditem.hxx>
49 #include <svx/hyznitem.hxx>
50 #include <svx/udlnitem.hxx>
51 #include <svx/fontitem.hxx>
52 #include <svx/fhgtitem.hxx>
53 #include <svx/colritem.hxx>
54 #include <svx/wghtitem.hxx>
55 #ifndef _SVX_CNTRITEM_HXX //autogen
56 #include <svx/cntritem.hxx>
58 #include <svx/postitem.hxx>
59 #include <svx/frmdiritem.hxx>
60 #include <svx/svdoutl.hxx>
61 #include <sfx2/viewfrm.hxx>
62 #include <svtools/whiter.hxx>
63 #include <svtools/cjkoptions.hxx>
64 #include <svtools/ctloptions.hxx>
65 #include <sfx2/bindings.hxx>
66 #include <vcl/msgbox.hxx>
67 #include <sfx2/dispatch.hxx>
68 #include <sfx2/request.hxx>
69 #include <svx/flditem.hxx>
70 #include <svx/editstat.hxx>
71 #include <svx/hlnkitem.hxx>
72 #include <svx/htmlmode.hxx>
73 #include <svx/langitem.hxx>
74 #include <svx/unolingu.hxx>
75 #include <svx/scripttypeitem.hxx>
76 #include <svx/writingmodeitem.hxx>
79 #include <viewopt.hxx>
83 #include <swdtflvr.hxx>
84 #include <drwtxtsh.hxx>
85 #include <swmodule.hxx>
86 #include <initui.hxx> // fuer SpellPointer
89 #include <docstat.hxx>
91 #include <comphelper/processfactory.hxx>
92 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
95 #include <globals.hrc>
97 #include "swabstdlg.hxx"
101 //modified on Jul. 30th
102 #include <svtools/languageoptions.hxx>
103 #include <svx/langitem.hxx>
104 #include <svtools/langtab.hxx>
105 #include <svtools/slstitm.hxx>
108 #include <svx/eeitem.hxx>
109 #include <svx/editeng.hxx>
110 #include <svx/editdata.hxx>
111 #include <svx/outliner.hxx>
112 #include <vcl/window.hxx>
113 #include <svx/editview.hxx>
114 #include <vcl/outdev.hxx>
116 #include <langhelper.hxx>
118 using namespace ::com::sun::star
;
120 /*--------------------------------------------------------------------
122 --------------------------------------------------------------------*/
124 void SwDrawTextShell::Execute( SfxRequest
&rReq
)
126 SwWrtShell
&rSh
= GetShell();
127 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
128 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
129 SfxItemSet
aNewAttr(*aEditAttr
.GetPool(), aEditAttr
.GetRanges());
131 sal_uInt16 nSlot
= rReq
.GetSlot();
133 sal_uInt16 nWhich
= GetPool().GetWhich(nSlot
);
134 const SfxItemSet
*pNewAttrs
= rReq
.GetArgs();
136 bool bRestoreSelection
= false;
137 ESelection aOldSelection
;
139 sal_uInt16 nEEWhich
= 0;
142 case SID_LANGUAGE_STATUS
:
144 aOldSelection
= pOLV
->GetSelection();
145 if (!pOLV
->GetEditView().HasSelection())
147 bRestoreSelection
= true;
148 pOLV
->GetEditView().SelectCurrentWord();
151 bRestoreSelection
= SwLangHelper::SetLanguageStatus(pOLV
,rReq
,GetView(),rSh
);
154 case SID_ATTR_CHAR_FONT
:
155 case SID_ATTR_CHAR_FONTHEIGHT
:
156 case SID_ATTR_CHAR_WEIGHT
:
157 case SID_ATTR_CHAR_POSTURE
:
159 SfxItemPool
* pPool2
= aEditAttr
.GetPool()->GetSecondaryPool();
161 pPool2
= aEditAttr
.GetPool();
162 SvxScriptSetItem
aSetItem( nSlot
, *pPool2
);
164 // #i78017 establish the same behaviour as in Writer
165 USHORT nScriptTypes
= SCRIPTTYPE_LATIN
| SCRIPTTYPE_ASIAN
| SCRIPTTYPE_COMPLEX
;
166 if (nSlot
== SID_ATTR_CHAR_FONT
)
167 nScriptTypes
= pOLV
->GetSelectedScriptType();
169 aSetItem
.PutItemForScriptType( nScriptTypes
, pNewAttrs
->Get( nWhich
) );
170 aNewAttr
.Put( aSetItem
.GetItemSet() );
174 case SID_ATTR_CHAR_COLOR
: nEEWhich
= EE_CHAR_COLOR
; break;
176 case SID_ATTR_CHAR_UNDERLINE
:
178 FontUnderline eFU
= ((const SvxUnderlineItem
&)aEditAttr
.Get(EE_CHAR_UNDERLINE
)).GetLineStyle();
179 aNewAttr
.Put(SvxUnderlineItem(eFU
== UNDERLINE_SINGLE
? UNDERLINE_NONE
: UNDERLINE_SINGLE
, EE_CHAR_UNDERLINE
));
183 case SID_ATTR_CHAR_OVERLINE
:
185 FontUnderline eFO
= ((const SvxOverlineItem
&)aEditAttr
.Get(EE_CHAR_OVERLINE
)).GetLineStyle();
186 aNewAttr
.Put(SvxOverlineItem(eFO
== UNDERLINE_SINGLE
? UNDERLINE_NONE
: UNDERLINE_SINGLE
, EE_CHAR_OVERLINE
));
190 case SID_ATTR_CHAR_CONTOUR
: nEEWhich
= EE_CHAR_OUTLINE
; break;
191 case SID_ATTR_CHAR_SHADOWED
: nEEWhich
= EE_CHAR_SHADOW
; break;
192 case SID_ATTR_CHAR_STRIKEOUT
: nEEWhich
= EE_CHAR_STRIKEOUT
; break;
193 case SID_ATTR_CHAR_WORDLINEMODE
: nEEWhich
= EE_CHAR_WLM
; break;
194 case SID_ATTR_CHAR_RELIEF
: nEEWhich
= EE_CHAR_RELIEF
; break;
195 case SID_ATTR_CHAR_LANGUAGE
: nEEWhich
= EE_CHAR_LANGUAGE
;break;
196 case SID_ATTR_CHAR_KERNING
: nEEWhich
= EE_CHAR_KERNING
; break;
197 case SID_ATTR_CHAR_SCALEWIDTH
: nEEWhich
= EE_CHAR_FONTWIDTH
; break;
198 case SID_ATTR_CHAR_AUTOKERN
: nEEWhich
= EE_CHAR_PAIRKERNING
; break;
199 case SID_ATTR_CHAR_ESCAPEMENT
: nEEWhich
= EE_CHAR_ESCAPEMENT
; break;
200 case SID_ATTR_PARA_ADJUST_LEFT
:
201 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_LEFT
, EE_PARA_JUST
));
203 case SID_ATTR_PARA_ADJUST_CENTER
:
204 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_CENTER
, EE_PARA_JUST
));
206 case SID_ATTR_PARA_ADJUST_RIGHT
:
207 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_RIGHT
, EE_PARA_JUST
));
209 case SID_ATTR_PARA_ADJUST_BLOCK
:
210 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_BLOCK
, EE_PARA_JUST
));
213 case SID_ATTR_PARA_LINESPACE_10
:
215 SvxLineSpacingItem
aItem(SVX_LINESPACE_ONE_LINE
, EE_PARA_SBL
);
216 aItem
.SetPropLineSpace(100);
220 case SID_ATTR_PARA_LINESPACE_15
:
222 SvxLineSpacingItem
aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES
, EE_PARA_SBL
);
223 aItem
.SetPropLineSpace(150);
227 case SID_ATTR_PARA_LINESPACE_20
:
229 SvxLineSpacingItem
aItem(SVX_LINESPACE_TWO_LINES
, EE_PARA_SBL
);
230 aItem
.SetPropLineSpace(200);
235 case FN_SET_SUPER_SCRIPT
:
237 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
238 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
239 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
241 if( eEsc
== SVX_ESCAPEMENT_SUPERSCRIPT
)
242 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
244 aItem
.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT
);
245 aNewAttr
.Put( aItem
, EE_CHAR_ESCAPEMENT
);
248 case FN_SET_SUB_SCRIPT
:
250 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
251 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
252 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
254 if( eEsc
== SVX_ESCAPEMENT_SUBSCRIPT
)
255 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
257 aItem
.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT
);
258 aNewAttr
.Put( aItem
, EE_CHAR_ESCAPEMENT
);
263 case SID_CHAR_DLG_FOR_PARAGRAPH
:
265 const SfxItemSet
* pArgs
= rReq
.GetArgs();
269 aOldSelection
= pOLV
->GetSelection();
270 if (nSlot
== SID_CHAR_DLG_FOR_PARAGRAPH
)
272 // select current paragraph (and restore selection later on...)
273 EditView
& rEditView
= pOLV
->GetEditView();
274 SwLangHelper::SelectPara( rEditView
, rEditView
.GetSelection() );
275 bRestoreSelection
= true;
278 SwView
* pView
= &GetView();
279 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, pView
));
280 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< UINT16
>(eMetric
)) );
281 SfxItemSet
aDlgAttr(GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
283 // util::Language gibts an der EditEngine nicht! Daher nicht im Set.
285 aDlgAttr
.Put( aEditAttr
);
286 aDlgAttr
.Put( SvxKerningItem(0, RES_CHRATR_KERNING
) );
288 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
289 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
291 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwCharDlg( pView
->GetWindow(), *pView
, aDlgAttr
, DLG_CHAR
,0, sal_True
);
292 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
293 USHORT nRet
= pDlg
->Execute();
296 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
297 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
304 aNewAttr
.Put(*pArgs
);
307 case FN_FORMAT_FOOTNOTE_DLG
:
309 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
310 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
312 VclAbstractDialog
* pDlg
= pFact
->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rView
.GetWrtShell(), DLG_DOC_FOOTNOTE
);
313 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
318 case FN_NUMBERING_OUTLINE_DLG
:
320 SfxItemSet
aTmp(GetPool(), FN_PARAM_1
, FN_PARAM_1
);
321 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
322 DBG_ASSERT(pFact
, "Dialogdiet fail!");
323 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTabDialog( DLG_TAB_OUTLINE
,
324 GetView().GetWindow(), &aTmp
, GetView().GetWrtShell());
325 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
331 case SID_OPEN_XML_FILTERSETTINGS
:
335 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY
);
341 catch( uno::Exception
& )
347 case FN_WORDCOUNT_DIALOG
:
350 SwDocStat
aDocStat( rSh
.getIDocumentStatistics()->GetDocStat() );
352 SwWait
aWait( *GetView().GetDocShell(), TRUE
);
354 rSh
.CountWords( aCurr
);
355 rSh
.UpdateDocStat( aDocStat
);
359 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
360 DBG_ASSERT(pFact
, "Dialogdiet fail!");
361 AbstractSwWordCountDialog
* pDialog
= pFact
->CreateSwWordCountDialog( GetView().GetWindow() );
362 pDialog
->SetValues(aCurr
, aDocStat
);
369 const SfxItemSet
* pArgs
= rReq
.GetArgs();
373 SwView
* pView
= &GetView();
374 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, pView
));
375 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< UINT16
>(eMetric
)) );
376 SfxItemSet
aDlgAttr(GetPool(),
377 EE_ITEMS_START
, EE_ITEMS_END
,
378 SID_ATTR_PARA_HYPHENZONE
, SID_ATTR_PARA_HYPHENZONE
,
379 SID_ATTR_PARA_SPLIT
, SID_ATTR_PARA_SPLIT
,
380 SID_ATTR_PARA_WIDOWS
, SID_ATTR_PARA_WIDOWS
,
381 SID_ATTR_PARA_ORPHANS
, SID_ATTR_PARA_ORPHANS
,
384 aDlgAttr
.Put(aEditAttr
);
386 // Die Werte sind erst einmal uebernommen worden, um den Dialog anzuzeigen.
387 // Muss natuerlich noch geaendert werden
388 // aDlgAttr.Put( SvxParaDlgLimitsItem( 567 * 50, 5670) );
390 aDlgAttr
.Put( SvxHyphenZoneItem( sal_False
, RES_PARATR_HYPHENZONE
) );
391 aDlgAttr
.Put( SvxFmtBreakItem( SVX_BREAK_NONE
, RES_BREAK
) );
392 aDlgAttr
.Put( SvxFmtSplitItem( sal_True
, RES_PARATR_SPLIT
) );
393 aDlgAttr
.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS
) );
394 aDlgAttr
.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS
) );
396 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
397 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
399 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr
,DLG_STD
, DLG_PARA
, 0, sal_True
);
400 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
401 USHORT nRet
= pDlg
->Execute();
404 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
405 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
412 aNewAttr
.Put(*pArgs
);
415 case SID_AUTOSPELL_CHECK
:
417 //!! JP 16.03.2001: why?? pSdrView = rSh.GetDrawView();
418 //!! JP 16.03.2001: why?? pOutliner = pSdrView->GetTextEditOutliner();
419 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
420 sal_uInt32 nCtrl
= pOutliner
->GetControlWord();
422 sal_Bool bSet
= ((const SfxBoolItem
&)rReq
.GetArgs()->Get(
425 nCtrl
|= EE_CNTRL_ONLINESPELLING
|EE_CNTRL_ALLOWBIGOBJS
;
427 nCtrl
&= ~EE_CNTRL_ONLINESPELLING
;
428 pOutliner
->SetControlWord(nCtrl
);
430 rView
.ExecuteSlot(rReq
);
433 case SID_HYPERLINK_SETLINK
:
435 const SfxPoolItem
* pItem
= 0;
437 pNewAttrs
->GetItemState(nSlot
, sal_False
, &pItem
);
441 const SvxHyperlinkItem
& rHLinkItem
= *(const SvxHyperlinkItem
*)pItem
;
442 SvxURLField
aFld(rHLinkItem
.GetURL(), rHLinkItem
.GetName(), SVXURLFORMAT_APPDEFAULT
);
443 aFld
.SetTargetFrame(rHLinkItem
.GetTargetFrame());
445 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
447 if (pFieldItem
&& pFieldItem
->GetField()->ISA(SvxURLField
))
449 // Feld selektieren, so dass es beim Insert geloescht wird
450 ESelection aSel
= pOLV
->GetSelection();
452 pOLV
->SetSelection(aSel
);
454 pOLV
->InsertField(SvxFieldItem(aFld
, EE_FEATURE_FIELD
));
459 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
460 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
463 SdrObject
* pTmpObj
= pSdrView
->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
464 SdrPageView
* pTmpPV
= pSdrView
->GetSdrPageView();
465 SdrView
* pTmpView
= pSdrView
;
467 pSdrView
->SdrEndTextEdit(sal_True
);
469 SfxItemSet
aAttr( *aNewAttr
.GetPool(),
470 SDRATTR_TEXTDIRECTION
,
471 SDRATTR_TEXTDIRECTION
);
473 aAttr
.Put( SvxWritingModeItem(
474 nSlot
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
?
475 text::WritingMode_LR_TB
476 : text::WritingMode_TB_RL
, SDRATTR_TEXTDIRECTION
) );
477 pTmpView
->SetAttributes( aAttr
);
479 rSh
.GetView().BeginTextEdit( pTmpObj
, pTmpPV
, &rSh
.GetView().GetEditWin(), sal_False
);
480 rSh
.GetView().AttrChangedNotify( &rSh
);
484 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
485 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
487 SdrObject
* pTmpObj
= pSdrView
->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
488 SdrPageView
* pTmpPV
= pSdrView
->GetSdrPageView();
489 SdrView
* pTmpView
= pSdrView
;
491 pSdrView
->SdrEndTextEdit(sal_True
);
492 sal_Bool bLeftToRight
= nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
494 const SfxPoolItem
* pPoolItem
;
495 if( pNewAttrs
&& SFX_ITEM_SET
== pNewAttrs
->GetItemState( nSlot
, TRUE
, &pPoolItem
) )
497 if( !( (SfxBoolItem
*)pPoolItem
)->GetValue() )
498 bLeftToRight
= !bLeftToRight
;
500 SfxItemSet
aAttr( *aNewAttr
.GetPool(),
501 EE_PARA_JUST
, EE_PARA_JUST
,
502 EE_PARA_WRITINGDIR
, EE_PARA_WRITINGDIR
,
505 USHORT nAdjust
= SVX_ADJUST_LEFT
;
506 if( SFX_ITEM_ON
== aEditAttr
.GetItemState(EE_PARA_JUST
, TRUE
, &pPoolItem
) )
507 nAdjust
= ( (SvxAdjustItem
*)pPoolItem
)->GetEnumValue();
511 aAttr
.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP
, EE_PARA_WRITINGDIR
) );
512 if( nAdjust
== SVX_ADJUST_RIGHT
)
513 aAttr
.Put( SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
) );
517 aAttr
.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP
, EE_PARA_WRITINGDIR
) );
518 if( nAdjust
== SVX_ADJUST_LEFT
)
519 aAttr
.Put( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
521 pTmpView
->SetAttributes( aAttr
);
522 rSh
.GetView().BeginTextEdit( pTmpObj
, pTmpPV
, &rSh
.GetView().GetEditWin(), sal_False
);
523 rSh
.GetView().AttrChangedNotify( &rSh
);
527 ASSERT(!this, falscher Dispatcher
);
530 if(nEEWhich
&& pNewAttrs
)
531 aNewAttr
.Put(pNewAttrs
->Get(nWhich
), nEEWhich
);
533 SetAttrToMarked(aNewAttr
);
535 GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
537 if (IsTextEdit() && pOLV
->GetOutliner()->IsModified())
540 if (bRestoreSelection
)
543 pOLV
->GetEditView().SetSelection( aOldSelection
);
547 /*--------------------------------------------------------------------
549 --------------------------------------------------------------------*/
551 void SwDrawTextShell::GetState(SfxItemSet
& rSet
)
553 if (!IsTextEdit()) // Sonst manchmal Absturz!
556 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
557 SfxWhichIter
aIter(rSet
);
558 sal_uInt16 nWhich
= aIter
.FirstWhich();
560 SfxItemSet
aEditAttr( pOLV
->GetAttribs() );
561 const SfxPoolItem
*pAdjust
= 0, *pLSpace
= 0, *pEscItem
= 0;
562 int eAdjust
, nLSpace
, nEsc
;
566 USHORT nSlotId
= GetPool().GetSlotId( nWhich
);
570 case SID_LANGUAGE_STATUS
://20412:
572 nSlotId
= SwLangHelper::GetLanguageStatus(pOLV
,rSet
);;
575 case SID_ATTR_PARA_ADJUST_LEFT
: eAdjust
= SVX_ADJUST_LEFT
; goto ASK_ADJUST
;
576 case SID_ATTR_PARA_ADJUST_RIGHT
: eAdjust
= SVX_ADJUST_RIGHT
; goto ASK_ADJUST
;
577 case SID_ATTR_PARA_ADJUST_CENTER
: eAdjust
= SVX_ADJUST_CENTER
; goto ASK_ADJUST
;
578 case SID_ATTR_PARA_ADJUST_BLOCK
: eAdjust
= SVX_ADJUST_BLOCK
; goto ASK_ADJUST
;
582 aEditAttr
.GetItemState( EE_PARA_JUST
, sal_False
, &pAdjust
);
584 if( !pAdjust
|| IsInvalidItem( pAdjust
))
585 rSet
.InvalidateItem( nSlotId
), nSlotId
= 0;
587 bFlag
= eAdjust
== ((SvxAdjustItem
*)pAdjust
)->GetAdjust();
591 case SID_ATTR_PARA_LINESPACE_10
: nLSpace
= 100; goto ASK_LINESPACE
;
592 case SID_ATTR_PARA_LINESPACE_15
: nLSpace
= 150; goto ASK_LINESPACE
;
593 case SID_ATTR_PARA_LINESPACE_20
: nLSpace
= 200; goto ASK_LINESPACE
;
597 aEditAttr
.GetItemState( EE_PARA_SBL
, sal_False
, &pLSpace
);
599 if( !pLSpace
|| IsInvalidItem( pLSpace
))
600 rSet
.InvalidateItem( nSlotId
), nSlotId
= 0;
601 else if( nLSpace
== ((const SvxLineSpacingItem
*)pLSpace
)->
609 case FN_SET_SUPER_SCRIPT
: nEsc
= SVX_ESCAPEMENT_SUPERSCRIPT
;
611 case FN_SET_SUB_SCRIPT
: nEsc
= SVX_ESCAPEMENT_SUBSCRIPT
;
616 pEscItem
= &aEditAttr
.Get( EE_CHAR_ESCAPEMENT
);
618 if( nEsc
== ((const SvxEscapementItem
*)
619 pEscItem
)->GetEnumValue() )
626 case FN_THESAURUS_DLG
:
628 // disable "Thesaurus" if the language is not supported
629 const SfxPoolItem
&rItem
= GetShell().GetDoc()->GetDefault(
630 GetWhichOfScript( RES_CHRATR_LANGUAGE
,
631 GetI18NScriptTypeOfLanguage( (USHORT
)GetAppLanguage())) );
632 LanguageType nLang
= ((const SvxLanguageItem
&)
633 rItem
).GetLanguage();
635 uno::Reference
< linguistic2::XThesaurus
> xThes( ::GetThesaurus() );
636 if (!xThes
.is() || nLang
== LANGUAGE_NONE
||
637 !xThes
->hasLocale( SvxCreateLocale( nLang
) ))
638 rSet
.DisableItem( FN_THESAURUS_DLG
);
642 case SID_HANGUL_HANJA_CONVERSION
:
643 case SID_CHINESE_CONVERSION
:
645 if (!SvtCJKOptions().IsAnyEnabled())
647 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
648 rSet
.DisableItem(nWhich
);
651 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
655 case SID_TEXTDIRECTION_LEFT_TO_RIGHT
:
656 case SID_TEXTDIRECTION_TOP_TO_BOTTOM
:
657 if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
659 rSet
.DisableItem( nSlotId
);
664 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
666 bFlag
= pOutliner
->IsVertical() ==
667 (SID_TEXTDIRECTION_TOP_TO_BOTTOM
== nSlotId
);
670 text::WritingMode eMode
= (text::WritingMode
)
671 ( (const SvxWritingModeItem
&) aEditAttr
.Get( SDRATTR_TEXTDIRECTION
) ).GetValue();
673 if( nSlotId
== SID_TEXTDIRECTION_LEFT_TO_RIGHT
)
675 bFlag
= eMode
== text::WritingMode_LR_TB
;
679 bFlag
= eMode
!= text::WritingMode_TB_RL
;
684 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
685 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
687 if ( !SvtLanguageOptions().IsCTLFontEnabled() )
689 rSet
.DisableItem( nWhich
);
694 SdrOutliner
* pOutliner
= pSdrView
->GetTextEditOutliner();
695 if(pOutliner
&& pOutliner
->IsVertical())
697 rSet
.DisableItem( nWhich
);
702 switch( ( ( (SvxFrameDirectionItem
&) aEditAttr
.Get( EE_PARA_WRITINGDIR
) ) ).GetValue() )
704 case FRMDIR_HORI_LEFT_TOP
:
705 bFlag
= nWhich
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
708 case FRMDIR_HORI_RIGHT_TOP
:
709 bFlag
= nWhich
!= SID_ATTR_PARA_LEFT_TO_RIGHT
;
716 case SID_TRANSLITERATE_HALFWIDTH
:
717 case SID_TRANSLITERATE_FULLWIDTH
:
718 case SID_TRANSLITERATE_HIRAGANA
:
719 case SID_TRANSLITERATE_KATAGANA
:
721 SvtCJKOptions aCJKOptions
;
722 if(!aCJKOptions
.IsChangeCaseMapEnabled())
724 rSet
.DisableItem(nWhich
);
725 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
728 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
731 case SID_INSERT_RLM
:
732 case SID_INSERT_LRM
:
733 case SID_INSERT_ZWNBSP
:
734 case SID_INSERT_ZWSP
:
736 SvtCTLOptions aCTLOptions
;
737 sal_Bool bEnabled
= aCTLOptions
.IsCTLFontEnabled();
738 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, bEnabled
);
740 rSet
.DisableItem(nWhich
);
744 nSlotId
= 0; // don't know this slot
749 rSet
.Put( SfxBoolItem( nWhich
, bFlag
));
751 nWhich
= aIter
.NextWhich();
755 /*--------------------------------------------------------------------
757 --------------------------------------------------------------------*/
758 void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet
& rSet
)
760 if (!IsTextEdit()) // Sonst Absturz!
763 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
764 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
766 SfxWhichIter
aIter(rSet
);
767 sal_uInt16 nWhich
= aIter
.FirstWhich();
768 USHORT nScriptType
= pOLV
->GetSelectedScriptType();
771 sal_uInt16 nEEWhich
= 0;
772 USHORT nSlotId
= GetPool().GetSlotId( nWhich
);
775 case SID_ATTR_CHAR_FONT
:
776 case SID_ATTR_CHAR_FONTHEIGHT
:
777 case SID_ATTR_CHAR_WEIGHT
:
778 case SID_ATTR_CHAR_POSTURE
:
780 SfxItemPool
* pEditPool
= aEditAttr
.GetPool()->GetSecondaryPool();
782 pEditPool
= aEditAttr
.GetPool();
783 SvxScriptSetItem
aSetItem( nSlotId
, *pEditPool
);
784 aSetItem
.GetItemSet().Put( aEditAttr
, FALSE
);
785 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScriptType
);
787 rSet
.Put( *pI
, nWhich
);
789 rSet
.InvalidateItem( nWhich
);
792 case SID_ATTR_CHAR_COLOR
: nEEWhich
= EE_CHAR_COLOR
; break;
793 case SID_ATTR_CHAR_UNDERLINE
: nEEWhich
= EE_CHAR_UNDERLINE
;break;
794 case SID_ATTR_CHAR_OVERLINE
: nEEWhich
= EE_CHAR_OVERLINE
;break;
795 case SID_ATTR_CHAR_CONTOUR
: nEEWhich
= EE_CHAR_OUTLINE
; break;
796 case SID_ATTR_CHAR_SHADOWED
: nEEWhich
= EE_CHAR_SHADOW
;break;
797 case SID_ATTR_CHAR_STRIKEOUT
: nEEWhich
= EE_CHAR_STRIKEOUT
;break;
798 case SID_AUTOSPELL_CHECK
:
800 const SfxPoolItem
* pState
= rView
.GetSlotState(nWhich
);
802 rSet
.Put(SfxBoolItem(nWhich
, ((const SfxBoolItem
*)pState
)->GetValue()));
804 rSet
.DisableItem( nWhich
);
807 case SID_ATTR_CHAR_WORDLINEMODE
: nEEWhich
= EE_CHAR_WLM
; break;
808 case SID_ATTR_CHAR_RELIEF
: nEEWhich
= EE_CHAR_RELIEF
; break;
809 case SID_ATTR_CHAR_LANGUAGE
: nEEWhich
= EE_CHAR_LANGUAGE
;break;
810 case SID_ATTR_CHAR_KERNING
: nEEWhich
= EE_CHAR_KERNING
; break;
811 case SID_ATTR_CHAR_SCALEWIDTH
: nEEWhich
= EE_CHAR_FONTWIDTH
;break;
812 case SID_ATTR_CHAR_AUTOKERN
: nEEWhich
= EE_CHAR_PAIRKERNING
; break;
813 case SID_ATTR_CHAR_ESCAPEMENT
: nEEWhich
= EE_CHAR_ESCAPEMENT
; break;
816 rSet
.Put(aEditAttr
.Get(nEEWhich
, sal_True
), nWhich
);
818 nWhich
= aIter
.NextWhich();
822 /*--------------------------------------------------------------------
824 --------------------------------------------------------------------*/
825 void SwDrawTextShell::ExecClpbrd(SfxRequest
&rReq
)
827 if (!IsTextEdit()) // Sonst Absturz!
830 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
831 sal_uInt16 nId
= rReq
.GetSlot();
843 pOLV
->PasteSpecial();
847 DBG_ERROR("falscher Dispatcher");
852 /*--------------------------------------------------------------------
853 Beschreibung: ClipBoard-Status
854 --------------------------------------------------------------------*/
855 void SwDrawTextShell::StateClpbrd(SfxItemSet
&rSet
)
857 if (!IsTextEdit()) // Sonst Absturz!
860 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
861 ESelection
aSel(pOLV
->GetSelection());
862 const sal_Bool bCopy
= (aSel
.nStartPara
!= aSel
.nEndPara
) ||
863 (aSel
.nStartPos
!= aSel
.nEndPos
);
866 SfxWhichIter
aIter(rSet
);
867 sal_uInt16 nWhich
= aIter
.FirstWhich();
876 rSet
.DisableItem( nWhich
);
881 TransferableDataHelper
aDataHelper(
882 TransferableDataHelper::CreateFromSystemClipboard(
883 &GetView().GetEditWin() ) );
885 if( !aDataHelper
.GetXTransferable().is() ||
886 !SwTransferable::IsPaste( GetShell(), aDataHelper
))
887 rSet
.DisableItem( SID_PASTE
);
891 case FN_PASTESPECIAL
:
892 rSet
.DisableItem( FN_PASTESPECIAL
);
894 // --> OD 2008-06-20 #151110#
895 case SID_CLIPBOARD_FORMAT_ITEMS
:
896 rSet
.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS
);
900 nWhich
= aIter
.NextWhich();
904 /*--------------------------------------------------------------------
905 Beschreibung: Hyperlink-Status
906 --------------------------------------------------------------------*/
908 void SwDrawTextShell::StateInsert(SfxItemSet
&rSet
)
910 if (!IsTextEdit()) // Sonst Absturz!
913 OutlinerView
* pOLV
= pSdrView
->GetTextEditOutlinerView();
914 SfxWhichIter
aIter(rSet
);
915 sal_uInt16 nWhich
= aIter
.FirstWhich();
921 case SID_HYPERLINK_GETLINK
:
923 SvxHyperlinkItem aHLinkItem
;
924 aHLinkItem
.SetInsertMode(HLINK_FIELD
);
926 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
930 const SvxFieldData
* pField
= pFieldItem
->GetField();
932 if (pField
->ISA(SvxURLField
))
934 aHLinkItem
.SetName(((const SvxURLField
*) pField
)->GetRepresentation());
935 aHLinkItem
.SetURL(((const SvxURLField
*) pField
)->GetURL());
936 aHLinkItem
.SetTargetFrame(((const SvxURLField
*) pField
)->GetTargetFrame());
941 String
sSel(pOLV
->GetSelected());
943 sSel
.EraseTrailingChars();
944 aHLinkItem
.SetName(sSel
);
947 sal_uInt16 nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
948 aHLinkItem
.SetInsertMode((SvxLinkInsertMode
)(aHLinkItem
.GetInsertMode() |
949 ((nHtmlMode
& HTMLMODE_ON
) != 0 ? HLINK_HTMLMODE
: 0)));
951 rSet
.Put(aHLinkItem
);
955 nWhich
= aIter
.NextWhich();