update dev300-m58
[ooovba.git] / sw / source / ui / shells / drwtxtex.cxx
blobfc15241d12e48b550ab3e9a085ff1ecadb3511a0
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>
45 #endif
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>
57 #endif
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>
77 #include <doc.hxx>
78 #include <wview.hxx>
79 #include <viewopt.hxx>
80 #include <wrtsh.hxx>
81 #include <uitool.hxx>
82 #include <pardlg.hxx>
83 #include <swdtflvr.hxx>
84 #include <drwtxtsh.hxx>
85 #include <swmodule.hxx>
86 #include <initui.hxx> // fuer SpellPointer
87 #include <edtwin.hxx>
88 #include <swwait.hxx>
89 #include <docstat.hxx>
91 #include <comphelper/processfactory.hxx>
92 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
94 #include <cmdid.h>
95 #include <globals.hrc>
96 #include <shells.hrc>
97 #include "swabstdlg.hxx"
98 #include "chrdlg.hrc"
99 #include "misc.hrc"
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>
106 #include <string.h>
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 /*--------------------------------------------------------------------
121 Beschreibung:
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;
140 switch (nSlot)
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);
152 break;
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();
160 if( !pPool2 )
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() );
172 break;
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));
181 break;
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));
188 break;
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));
202 break;
203 case SID_ATTR_PARA_ADJUST_CENTER:
204 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
205 break;
206 case SID_ATTR_PARA_ADJUST_RIGHT:
207 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST));
208 break;
209 case SID_ATTR_PARA_ADJUST_BLOCK:
210 aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST));
211 break;
213 case SID_ATTR_PARA_LINESPACE_10:
215 SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL);
216 aItem.SetPropLineSpace(100);
217 aNewAttr.Put(aItem);
219 break;
220 case SID_ATTR_PARA_LINESPACE_15:
222 SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL);
223 aItem.SetPropLineSpace(150);
224 aNewAttr.Put(aItem);
226 break;
227 case SID_ATTR_PARA_LINESPACE_20:
229 SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL);
230 aItem.SetPropLineSpace(200);
231 aNewAttr.Put(aItem);
233 break;
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 );
243 else
244 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
245 aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
247 break;
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 );
256 else
257 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
258 aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
260 break;
262 case SID_CHAR_DLG:
263 case SID_CHAR_DLG_FOR_PARAGRAPH:
265 const SfxItemSet* pArgs = rReq.GetArgs();
267 if( !pArgs )
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();
294 if(RET_OK == nRet )
296 rReq.Done( *( pDlg->GetOutputItemSet() ) );
297 aNewAttr.Put(*pDlg->GetOutputItemSet());
299 delete( pDlg );
300 if(RET_OK != nRet)
301 return ;
303 else
304 aNewAttr.Put(*pArgs);
306 break;
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!");
314 pDlg->Execute();
315 delete pDlg;
316 break;
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!");
326 pDlg->Execute();
327 delete pDlg;
328 rReq.Done();
330 break;
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);
336 if( xDialog.is() )
338 xDialog->execute();
341 catch( uno::Exception& )
344 rReq.Ignore ();
346 break;
347 case FN_WORDCOUNT_DIALOG:
349 SwDocStat aCurr;
350 SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
352 SwWait aWait( *GetView().GetDocShell(), TRUE );
353 rSh.StartAction();
354 rSh.CountWords( aCurr );
355 rSh.UpdateDocStat( aDocStat );
356 rSh.EndAction();
359 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
360 DBG_ASSERT(pFact, "Dialogdiet fail!");
361 AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() );
362 pDialog->SetValues(aCurr, aDocStat );
363 pDialog->Execute();
364 delete pDialog;
366 break;
367 case SID_PARA_DLG:
369 const SfxItemSet* pArgs = rReq.GetArgs();
371 if (!pArgs)
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();
402 if(RET_OK == nRet)
404 rReq.Done( *( pDlg->GetOutputItemSet() ) );
405 aNewAttr.Put(*pDlg->GetOutputItemSet());
407 delete( pDlg );
408 if(RET_OK != nRet)
409 return;
411 else
412 aNewAttr.Put(*pArgs);
414 break;
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(
423 nSlot)).GetValue();
424 if(bSet)
425 nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS;
426 else
427 nCtrl &= ~EE_CNTRL_ONLINESPELLING;
428 pOutliner->SetControlWord(nCtrl);
430 rView.ExecuteSlot(rReq);
432 break;
433 case SID_HYPERLINK_SETLINK:
435 const SfxPoolItem* pItem = 0;
436 if(pNewAttrs)
437 pNewAttrs->GetItemState(nSlot, sal_False, &pItem);
439 if(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();
451 aSel.nEndPos++;
452 pOLV->SetSelection(aSel);
454 pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD));
457 break;
459 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
460 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
461 // Shellwechsel!
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 );
482 return;
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,
503 0 );
505 USHORT nAdjust = SVX_ADJUST_LEFT;
506 if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, TRUE, &pPoolItem ) )
507 nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
509 if( bLeftToRight )
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 ) );
515 else
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 );
525 return;
526 default:
527 ASSERT(!this, falscher Dispatcher);
528 return;
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())
538 rSh.SetModified();
540 if (bRestoreSelection)
542 // restore selection
543 pOLV->GetEditView().SetSelection( aOldSelection );
547 /*--------------------------------------------------------------------
548 Beschreibung:
549 --------------------------------------------------------------------*/
551 void SwDrawTextShell::GetState(SfxItemSet& rSet)
553 if (!IsTextEdit()) // Sonst manchmal Absturz!
554 return;
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;
564 while(nWhich)
566 USHORT nSlotId = GetPool().GetSlotId( nWhich );
567 BOOL bFlag = FALSE;
568 switch( nSlotId )
570 case SID_LANGUAGE_STATUS://20412:
572 nSlotId = SwLangHelper::GetLanguageStatus(pOLV,rSet);;
573 break;
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;
579 ASK_ADJUST:
581 if( !pAdjust )
582 aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust);
584 if( !pAdjust || IsInvalidItem( pAdjust ))
585 rSet.InvalidateItem( nSlotId ), nSlotId = 0;
586 else
587 bFlag = eAdjust == ((SvxAdjustItem*)pAdjust)->GetAdjust();
589 break;
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;
594 ASK_LINESPACE:
596 if( !pLSpace )
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)->
602 GetPropLineSpace() )
603 bFlag = sal_True;
604 else
605 nSlotId = 0;
607 break;
609 case FN_SET_SUPER_SCRIPT: nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
610 goto ASK_ESCAPE;
611 case FN_SET_SUB_SCRIPT: nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
612 goto ASK_ESCAPE;
613 ASK_ESCAPE:
615 if( !pEscItem )
616 pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
618 if( nEsc == ((const SvxEscapementItem*)
619 pEscItem)->GetEnumValue() )
620 bFlag = sal_True;
621 else
622 nSlotId = 0;
624 break;
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 );
639 nSlotId = 0;
641 break;
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);
650 else
651 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
653 break;
655 case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
656 case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
657 if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
659 rSet.DisableItem( nSlotId );
660 nSlotId = 0;
662 else
664 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
665 if( pOutliner )
666 bFlag = pOutliner->IsVertical() ==
667 (SID_TEXTDIRECTION_TOP_TO_BOTTOM == nSlotId);
668 else
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;
677 else
679 bFlag = eMode != text::WritingMode_TB_RL;
683 break;
684 case SID_ATTR_PARA_LEFT_TO_RIGHT:
685 case SID_ATTR_PARA_RIGHT_TO_LEFT:
687 if ( !SvtLanguageOptions().IsCTLFontEnabled() )
689 rSet.DisableItem( nWhich );
690 nSlotId = 0;
692 else
694 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
695 if(pOutliner && pOutliner->IsVertical())
697 rSet.DisableItem( nWhich );
698 nSlotId = 0;
700 else
702 switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
704 case FRMDIR_HORI_LEFT_TOP:
705 bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
706 break;
708 case FRMDIR_HORI_RIGHT_TOP:
709 bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
710 break;
715 break;
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 );
727 else
728 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
730 break;
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 );
739 if(!bEnabled)
740 rSet.DisableItem(nWhich);
742 break;
743 default:
744 nSlotId = 0; // don't know this slot
745 break;
748 if( nSlotId )
749 rSet.Put( SfxBoolItem( nWhich, bFlag ));
751 nWhich = aIter.NextWhich();
755 /*--------------------------------------------------------------------
756 Beschreibung:
757 --------------------------------------------------------------------*/
758 void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet& rSet)
760 if (!IsTextEdit()) // Sonst Absturz!
761 return;
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();
769 while(nWhich)
771 sal_uInt16 nEEWhich = 0;
772 USHORT nSlotId = GetPool().GetSlotId( nWhich );
773 switch( nSlotId )
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();
781 if( !pEditPool )
782 pEditPool = aEditAttr.GetPool();
783 SvxScriptSetItem aSetItem( nSlotId, *pEditPool );
784 aSetItem.GetItemSet().Put( aEditAttr, FALSE );
785 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
786 if( pI )
787 rSet.Put( *pI, nWhich );
788 else
789 rSet.InvalidateItem( nWhich );
791 break;
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);
801 if (pState)
802 rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue()));
803 else
804 rSet.DisableItem( nWhich );
805 break;
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;
815 if(nEEWhich)
816 rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich);
818 nWhich = aIter.NextWhich();
822 /*--------------------------------------------------------------------
823 Beschreibung:
824 --------------------------------------------------------------------*/
825 void SwDrawTextShell::ExecClpbrd(SfxRequest &rReq)
827 if (!IsTextEdit()) // Sonst Absturz!
828 return;
830 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
831 sal_uInt16 nId = rReq.GetSlot();
832 switch( nId )
834 case SID_CUT:
835 pOLV->Cut();
836 return;
838 case SID_COPY:
839 pOLV->Copy();
840 return;
842 case SID_PASTE:
843 pOLV->PasteSpecial();
844 break;
846 default:
847 DBG_ERROR("falscher Dispatcher");
848 return;
852 /*--------------------------------------------------------------------
853 Beschreibung: ClipBoard-Status
854 --------------------------------------------------------------------*/
855 void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet)
857 if (!IsTextEdit()) // Sonst Absturz!
858 return;
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();
869 while(nWhich)
871 switch(nWhich)
873 case SID_CUT:
874 case SID_COPY:
875 if( !bCopy )
876 rSet.DisableItem( nWhich );
877 break;
879 case SID_PASTE:
881 TransferableDataHelper aDataHelper(
882 TransferableDataHelper::CreateFromSystemClipboard(
883 &GetView().GetEditWin() ) );
885 if( !aDataHelper.GetXTransferable().is() ||
886 !SwTransferable::IsPaste( GetShell(), aDataHelper ))
887 rSet.DisableItem( SID_PASTE );
889 break;
891 case FN_PASTESPECIAL:
892 rSet.DisableItem( FN_PASTESPECIAL );
893 break;
894 // --> OD 2008-06-20 #151110#
895 case SID_CLIPBOARD_FORMAT_ITEMS:
896 rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
897 break;
898 // <--
900 nWhich = aIter.NextWhich();
904 /*--------------------------------------------------------------------
905 Beschreibung: Hyperlink-Status
906 --------------------------------------------------------------------*/
908 void SwDrawTextShell::StateInsert(SfxItemSet &rSet)
910 if (!IsTextEdit()) // Sonst Absturz!
911 return;
913 OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
914 SfxWhichIter aIter(rSet);
915 sal_uInt16 nWhich = aIter.FirstWhich();
917 while(nWhich)
919 switch(nWhich)
921 case SID_HYPERLINK_GETLINK:
923 SvxHyperlinkItem aHLinkItem;
924 aHLinkItem.SetInsertMode(HLINK_FIELD);
926 const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
928 if (pFieldItem)
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());
939 else
941 String sSel(pOLV->GetSelected());
942 sSel.Erase(255);
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);
953 break;
955 nWhich = aIter.NextWhich();