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/i18n/WordType.hpp>
22 #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
24 #include <comphelper/processfactory.hxx>
25 #include <hintids.hxx>
29 #include <i18nlangtag/languagetag.hxx>
30 #include <svl/languageoptions.hxx>
31 #include <editeng/langitem.hxx>
32 #include <svtools/langtab.hxx>
33 #include <svl/slstitm.hxx>
35 #include <svl/stritem.hxx>
36 #include <sfx2/htmlmode.hxx>
37 #include <svl/whiter.hxx>
38 #include <sfx2/bindings.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <sfx2/objitem.hxx>
41 #include <vcl/unohelp2.hxx>
42 #include <sfx2/request.hxx>
43 #include <svl/eitem.hxx>
44 #include <svl/macitem.hxx>
45 #include <editeng/lrspitem.hxx>
46 #include <editeng/colritem.hxx>
47 #include <editeng/tstpitem.hxx>
48 #include <editeng/brushitem.hxx>
49 #include <editeng/svxacorr.hxx>
50 #include <svl/cjkoptions.hxx>
51 #include <svl/ctloptions.hxx>
52 #include <IDocumentSettingAccess.hxx>
53 #include <charfmt.hxx>
54 #include <editeng/fontitem.hxx>
55 #include <svx/SmartTagItem.hxx>
56 #include <fmtinfmt.hxx>
60 #include <swmodule.hxx>
61 #include <viewopt.hxx>
63 #include <swevent.hxx>
64 #include <pagedesc.hxx>
67 #include <swdtflvr.hxx>
68 #include <docstat.hxx>
69 #include <outline.hxx>
70 #include <tablemgr.hxx>
71 #include <swundo.hxx> // for Undo-IDs
75 #include <inputwin.hxx>
79 #include <cellatr.hxx>
81 #include <redlndlg.hxx>
84 #include <globals.hrc>
89 #include <crsskip.hxx>
90 #include <vcl/svapp.hxx>
91 #include <sfx2/app.hxx>
92 #include <breakit.hxx>
94 #include <SwSmartTagMgr.hxx>
96 #include <editeng/acorrcfg.hxx>
97 #include "swabstdlg.hxx"
100 #include <IDocumentStatistics.hxx>
102 #include <sfx2/sfxdlg.hxx>
103 #include <unotools/lingucfg.hxx>
104 #include <com/sun/star/beans/XPropertySet.hpp>
105 #include <com/sun/star/util/XChangesBatch.hpp>
106 #include <com/sun/star/uno/Any.hxx>
107 #include <editeng/unolingu.hxx>
108 #include <unotools/syslocaleoptions.hxx>
113 #include <sfx2/objface.hxx>
114 #include <langhelper.hxx>
115 #include <uiitems.hxx>
116 #include <wordcountdialog.hxx>
117 #include <tools/diagnose_ex.h>
119 #ifndef _NBDTMGFACT_HXX
120 #include <svx/nbdtmgfact.hxx>
123 #include <svx/nbdtmg.hxx>
127 #include <numrule.hxx>
130 using namespace ::com::sun::star
;
131 using namespace svx::sidebar
;
133 void sw_CharDialog( SwWrtShell
&rWrtSh
, bool bUseDialog
, sal_uInt16 nSlot
,const SfxItemSet
*pArgs
, SfxRequest
*pReq
)
135 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, &rWrtSh
.GetView()));
136 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
)));
137 SfxItemSet
aCoreSet( rWrtSh
.GetView().GetPool(),
138 RES_CHRATR_BEGIN
, RES_CHRATR_END
-1,
139 RES_TXTATR_INETFMT
, RES_TXTATR_INETFMT
,
140 RES_BACKGROUND
, RES_BACKGROUND
,
141 FN_PARAM_SELECTION
, FN_PARAM_SELECTION
,
142 SID_HTML_MODE
, SID_HTML_MODE
,
143 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
,
145 rWrtSh
.GetCurAttr( aCoreSet
);
146 sal_Bool bSel
= rWrtSh
.HasSelection();
147 sal_Bool bSelectionPut
= sal_False
;
148 if(bSel
|| rWrtSh
.IsInWord())
152 rWrtSh
.StartAction();
154 if(!rWrtSh
.SelectTxtAttr( RES_TXTATR_INETFMT
))
157 aCoreSet
.Put(SfxStringItem(FN_PARAM_SELECTION
, rWrtSh
.GetSelTxt()));
158 bSelectionPut
= sal_True
;
161 rWrtSh
.Pop(sal_False
);
165 aCoreSet
.Put( SfxUInt16Item( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
,
166 rWrtSh
.GetScalingOfSelectedText() ) );
167 // The CHRATR_BACKGROUND attribute will be converted for the
168 // dialogue in a RES_BACKGROUND and back again ...
169 const SfxPoolItem
*pTmpBrush
;
170 if( SFX_ITEM_SET
== aCoreSet
.GetItemState( RES_CHRATR_BACKGROUND
, sal_True
, &pTmpBrush
) )
172 SvxBrushItem
aTmpBrush( *((SvxBrushItem
*)pTmpBrush
) );
173 aTmpBrush
.SetWhich( RES_BACKGROUND
);
174 aCoreSet
.Put( aTmpBrush
);
177 aCoreSet
.Put(SfxUInt16Item(SID_HTML_MODE
, ::GetHtmlMode(rWrtSh
.GetView().GetDocShell())));
178 SfxAbstractTabDialog
* pDlg
= NULL
;
179 if ( bUseDialog
&& GetActiveView() )
181 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
182 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
184 pDlg
= pFact
->CreateSwCharDlg(rWrtSh
.GetView().GetWindow(), rWrtSh
.GetView(), aCoreSet
);
185 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
186 if( FN_INSERT_HYPERLINK
== nSlot
)
187 pDlg
->SetCurPageId("hyperlink");
189 if (nSlot
== SID_CHAR_DLG_EFFECT
)
191 pDlg
->SetCurPageId(TP_CHAR_EXT
);
194 const SfxItemSet
* pSet
= NULL
;
197 else if ( NULL
!= pDlg
&& pDlg
->Execute() == RET_OK
) /* #110771# pDlg can be NULL */
199 pSet
= pDlg
->GetOutputItemSet();
204 SfxItemSet
aTmpSet( *pSet
);
205 if( SFX_ITEM_SET
== aTmpSet
.GetItemState( RES_BACKGROUND
, sal_False
, &pTmpBrush
) )
207 SvxBrushItem
aTmpBrush( *((SvxBrushItem
*)pTmpBrush
) );
208 aTmpBrush
.SetWhich( RES_CHRATR_BACKGROUND
);
209 aTmpSet
.Put( aTmpBrush
);
212 aTmpSet
.ClearItem( RES_BACKGROUND
);
214 const SfxPoolItem
* pSelectionItem
;
215 sal_Bool bInsert
= sal_False
;
216 xub_StrLen nInsert
= 0;
218 // The old item is for unknown reasons back in the set again.
219 if( !bSelectionPut
&& SFX_ITEM_SET
== aTmpSet
.GetItemState(FN_PARAM_SELECTION
, sal_False
, &pSelectionItem
) )
221 String sInsert
= ((const SfxStringItem
*)pSelectionItem
)->GetValue();
222 bInsert
= sInsert
.Len() != 0;
225 nInsert
= sInsert
.Len();
226 rWrtSh
.StartAction();
227 rWrtSh
.Insert( sInsert
);
229 rWrtSh
.ExtendSelection(sal_False
, sInsert
.Len());
230 SfxRequest
aReq( rWrtSh
.GetView().GetViewFrame(), FN_INSERT_STRING
);
231 aReq
.AppendItem( SfxStringItem( FN_INSERT_STRING
, sInsert
) );
233 SfxRequest
aReq1( rWrtSh
.GetView().GetViewFrame(), FN_CHAR_LEFT
);
234 aReq1
.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT
, nInsert
) );
235 aReq1
.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION
, sal_True
) );
239 aTmpSet
.ClearItem(FN_PARAM_SELECTION
);
241 SwTxtFmtColl
* pColl
= rWrtSh
.GetCurTxtFmtColl();
242 if(bSel
&& rWrtSh
.IsSelFullPara() && pColl
&& pColl
->IsAutoUpdateFmt())
244 rWrtSh
.AutoUpdatePara(pColl
, aTmpSet
);
247 rWrtSh
.SetAttr( aTmpSet
);
252 SfxRequest
aReq1( rWrtSh
.GetView().GetViewFrame(), FN_CHAR_RIGHT
);
253 aReq1
.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT
, nInsert
) );
254 aReq1
.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION
, sal_False
) );
258 rWrtSh
.DontExpandFmt();
266 static short lcl_AskRedlineMode(Window
*pWin
)
268 MessBox
aQBox( pWin
, 0,
269 String( SW_RES( STR_REDLINE_TITLE
) ),
270 String( SW_RES( STR_REDLINE_MSG
) ) );
271 aQBox
.SetImage( QueryBox::GetStandardImage() );
272 sal_uInt16 nBtnFlags
= BUTTONDIALOG_DEFBUTTON
|
273 BUTTONDIALOG_OKBUTTON
|
274 BUTTONDIALOG_FOCUSBUTTON
;
276 aQBox
.AddButton(String(SW_RES(STR_REDLINE_ACCEPT_ALL
)), RET_OK
, nBtnFlags
);
277 aQBox
.GetPushButton( RET_OK
)->SetHelpId(HID_AUTOFORMAT_ACCEPT
);
278 aQBox
.AddButton(String(SW_RES(STR_REDLINE_REJECT_ALL
)), RET_CANCEL
, BUTTONDIALOG_CANCELBUTTON
);
279 aQBox
.GetPushButton( RET_CANCEL
)->SetHelpId(HID_AUTOFORMAT_REJECT
);
280 aQBox
.AddButton(String(SW_RES(STR_REDLINE_EDIT
)), 2, 0);
281 aQBox
.GetPushButton( 2 )->SetHelpId(HID_AUTOFORMAT_EDIT_CHG
);
282 aQBox
.SetButtonHelpText( RET_OK
, aEmptyStr
);
284 return aQBox
.Execute();
287 void SwTextShell::Execute(SfxRequest
&rReq
)
289 bool bUseDialog
= true;
290 const SfxItemSet
*pArgs
= rReq
.GetArgs();
291 SwWrtShell
& rWrtSh
= GetShell();
292 const SfxPoolItem
* pItem
= 0;
293 sal_uInt16 nSlot
= rReq
.GetSlot();
295 pArgs
->GetItemState(GetPool().GetWhich(nSlot
), sal_False
, &pItem
);
298 case SID_LANGUAGE_STATUS
:
302 SFX_REQUEST_ARG( rReq
, pItem2
, SfxStringItem
, SID_LANGUAGE_STATUS
, sal_False
);
304 aNewLangTxt
= pItem2
->GetValue();
306 //!! Remember the view frame right now...
307 //!! (call to GetView().GetViewFrame() will break if the
308 //!! SwTextShell got destroyed meanwhile.)
309 SfxViewFrame
*pViewFrame
= GetView().GetViewFrame();
311 if (aNewLangTxt
.EqualsAscii( "*" ))
313 // open the dialog "Tools/Options/Language Settings - Language"
314 // to set the documents default language
315 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
318 VclAbstractDialog
* pDlg
= pFact
->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS
);
325 //!! We have to use StartAction / EndAction bracketing in
326 //!! order to prevent possible destruction of the SwTextShell
327 //!! due to the selection changes coming below.
328 rWrtSh
.StartAction();
329 // prevent view from jumping because of (temporary) selection changes
330 rWrtSh
.LockView( sal_True
);
332 // setting the new language...
333 if (aNewLangTxt
.Len() > 0)
335 const OUString
aSelectionLangPrefix("Current_");
336 const OUString
aParagraphLangPrefix("Paragraph_");
337 const OUString
aDocumentLangPrefix("Default_");
338 const String
aStrNone( OUString("LANGUAGE_NONE") );
339 const String
aStrResetLangs( OUString("RESET_LANGUAGES") );
341 SfxItemSet
aCoreSet( GetPool(),
342 RES_CHRATR_LANGUAGE
, RES_CHRATR_LANGUAGE
,
343 RES_CHRATR_CJK_LANGUAGE
, RES_CHRATR_CJK_LANGUAGE
,
344 RES_CHRATR_CTL_LANGUAGE
, RES_CHRATR_CTL_LANGUAGE
,
348 bool bForSelection
= true;
349 bool bForParagraph
= false;
350 if (STRING_NOTFOUND
!= (nPos
= aNewLangTxt
.Search( aSelectionLangPrefix
, 0 )))
352 // ... for the current selection
353 aNewLangTxt
= aNewLangTxt
.Erase( nPos
, aSelectionLangPrefix
.getLength() );
354 bForSelection
= true;
356 else if (STRING_NOTFOUND
!= (nPos
= aNewLangTxt
.Search( aParagraphLangPrefix
, 0 )))
358 // ... for the current paragraph language
359 aNewLangTxt
= aNewLangTxt
.Erase( nPos
, aParagraphLangPrefix
.getLength() );
360 bForSelection
= true;
361 bForParagraph
= true;
363 else if (STRING_NOTFOUND
!= (nPos
= aNewLangTxt
.Search( aDocumentLangPrefix
, 0 )))
365 // ... as default document language
366 aNewLangTxt
= aNewLangTxt
.Erase( nPos
, aDocumentLangPrefix
.getLength() );
367 bForSelection
= false;
370 if (bForParagraph
|| !bForSelection
)
372 rWrtSh
.Push(); // save selection for later restoration
373 rWrtSh
.ClearMark(); // fdo#67796: invalidate table crsr
377 SwLangHelper::SelectCurrentPara( rWrtSh
);
379 if (!bForSelection
) // document language to be changed...
382 rWrtSh
.ExtendedSelectAll();
384 if (aNewLangTxt
== aStrNone
)
385 SwLangHelper::SetLanguage_None( rWrtSh
, bForSelection
, aCoreSet
);
386 else if (aNewLangTxt
== aStrResetLangs
)
387 SwLangHelper::ResetLanguages( rWrtSh
, bForSelection
);
389 SwLangHelper::SetLanguage( rWrtSh
, aNewLangTxt
, bForSelection
, aCoreSet
);
391 if (bForParagraph
|| !bForSelection
)
393 rWrtSh
.Pop(false); // restore selection...
397 rWrtSh
.LockView( sal_False
);
401 // invalidate slot to get the new language displayed
402 pViewFrame
->GetBindings().Invalidate( nSlot
);
410 // replace word/selection with text from selected sub menu entry
412 SFX_REQUEST_ARG( rReq
, pItem2
, SfxStringItem
, SID_THES
, sal_False
);
414 aReplaceText
= pItem2
->GetValue();
415 if (aReplaceText
.Len() > 0)
417 SwView
&rView2
= rWrtSh
.GetView();
418 const bool bSelection
= rWrtSh
.HasSelection();
419 const String aLookUpText
= rView2
.GetThesaurusLookUpText( bSelection
);
420 rView2
.InsertThesaurusSynonym( aReplaceText
, aLookUpText
, bSelection
);
427 InsertSymbol( rReq
);
430 case FN_INSERT_FOOTNOTE
:
431 case FN_INSERT_ENDNOTE
:
434 SFX_REQUEST_ARG( rReq
, pFont
, SfxStringItem
, FN_PARAM_1
, sal_False
);
435 SFX_REQUEST_ARG( rReq
, pNameItem
, SfxStringItem
, nSlot
, sal_False
);
437 aStr
= pNameItem
->GetValue();
438 bool bFont
= pFont
&& !pFont
->GetValue().isEmpty();
439 rWrtSh
.StartUndo( UNDO_UI_INSERT_FOOTNOTE
);
440 rWrtSh
.InsertFootnote( aStr
, nSlot
== FN_INSERT_ENDNOTE
, !bFont
);
443 rWrtSh
.Left( CRSR_SKIP_CHARS
, sal_True
, 1, sal_False
);
444 SfxItemSet
aSet( rWrtSh
.GetAttrPool(), RES_CHRATR_FONT
, RES_CHRATR_FONT
);
445 rWrtSh
.GetCurAttr( aSet
);
446 SvxFontItem
&rFont
= (SvxFontItem
&) aSet
.Get( RES_CHRATR_FONT
);
447 SvxFontItem
aFont( rFont
.GetFamily(), pFont
->GetValue(),
448 rFont
.GetStyleName(), rFont
.GetPitch(), RTL_TEXTENCODING_DONTKNOW
, RES_CHRATR_FONT
);
449 rWrtSh
.SetAttr( aSet
, nsSetAttrMode::SETATTR_DONTEXPAND
);
450 rWrtSh
.ResetSelect(0, sal_False
);
454 rWrtSh
.EndUndo( UNDO_UI_INSERT_FOOTNOTE
);
458 case FN_INSERT_FOOTNOTE_DLG
:
460 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
461 OSL_ENSURE(pFact
, "Dialogdiet fail!");
462 AbstractInsFootNoteDlg
* pDlg
= pFact
->CreateInsFootNoteDlg(
463 GetView().GetWindow(), rWrtSh
, sal_False
);
464 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
465 pDlg
->SetHelpId(GetStaticInterface()->GetSlot(nSlot
)->GetCommand());
466 if ( pDlg
->Execute() == RET_OK
)
468 sal_uInt16 nId
= pDlg
->IsEndNote() ? FN_INSERT_ENDNOTE
: FN_INSERT_FOOTNOTE
;
469 SfxRequest
aReq( GetView().GetViewFrame(), nId
);
470 if ( pDlg
->GetStr().Len() )
471 aReq
.AppendItem( SfxStringItem( nId
, pDlg
->GetStr() ) );
472 if ( pDlg
->GetFontName().Len() )
473 aReq
.AppendItem( SfxStringItem( FN_PARAM_1
, pDlg
->GetFontName() ) );
481 case FN_FORMAT_FOOTNOTE_DLG
:
483 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
484 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
486 VclAbstractDialog
* pDlg
= pFact
->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rWrtSh
, DLG_DOC_FOOTNOTE
);
487 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
494 GetView().ExecuteInsertDoc( rReq
, pItem
);
497 case FN_FORMAT_RESET
:
499 // #i78856, reset all attributes but not the language attributes
500 // (for this build an array of all relevant attributes and
501 // remove the languages from that)
502 std::set
<sal_uInt16
> aAttribs
;
504 sal_uInt16 aResetableSetRange
[] = {
505 RES_FRMATR_BEGIN
, RES_FRMATR_END
-1,
506 RES_CHRATR_BEGIN
, RES_CHRATR_LANGUAGE
- 1,
507 RES_CHRATR_LANGUAGE
+ 1, RES_CHRATR_CJK_LANGUAGE
- 1,
508 RES_CHRATR_CJK_LANGUAGE
+ 1, RES_CHRATR_CTL_LANGUAGE
- 1,
509 RES_CHRATR_CTL_LANGUAGE
+ 1, RES_CHRATR_END
-1,
510 RES_PARATR_BEGIN
, RES_PARATR_END
-1,
511 RES_TXTATR_UNKNOWN_CONTAINER
, RES_TXTATR_UNKNOWN_CONTAINER
,
512 RES_UNKNOWNATR_BEGIN
, RES_UNKNOWNATR_END
-1,
515 sal_uInt16
*pUShorts
= aResetableSetRange
;
518 sal_uInt16 nL
= pUShorts
[1] - pUShorts
[0] + 1;
519 sal_uInt16 nE
= pUShorts
[0];
520 for (sal_uInt16 i
= 0; i
< nL
; ++i
)
521 aAttribs
.insert( aAttribs
.end(), nE
++ );
524 // we don't want to change writing direction.
525 aAttribs
.erase( RES_FRAMEDIR
);
526 rWrtSh
.ResetAttr( aAttribs
);
530 case FN_INSERT_BREAK_DLG
:
532 sal_uInt16 nKind
=0, nPageNumber
=0;
533 String aTemplateName
;
536 nKind
= ((SfxInt16Item
*)pItem
)->GetValue();
537 SFX_REQUEST_ARG( rReq
, pTemplate
, SfxStringItem
, FN_PARAM_1
, sal_False
);
538 SFX_REQUEST_ARG( rReq
, pNumber
, SfxUInt16Item
, FN_PARAM_2
, sal_False
);
540 aTemplateName
= pTemplate
->GetValue();
542 nPageNumber
= pNumber
->GetValue();
546 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
547 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
549 AbstractSwBreakDlg
* pDlg
= pFact
->CreateSwBreakDlg(GetView().GetWindow(), rWrtSh
);
550 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
551 if ( pDlg
->Execute() == RET_OK
)
553 nKind
= pDlg
->GetKind();
554 aTemplateName
= pDlg
->GetTemplateName();
555 nPageNumber
= pDlg
->GetPageNumber();
556 rReq
.AppendItem( SfxInt16Item( FN_INSERT_BREAK_DLG
, nKind
) );
557 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_2
, nPageNumber
) );
558 rReq
.AppendItem( SfxStringItem( FN_PARAM_1
, aTemplateName
) );
569 rWrtSh
.InsertLineBreak(); break;
571 rWrtSh
.InsertColumnBreak(); break;
574 rWrtSh
.StartAllAction();
575 if( aTemplateName
.Len() )
576 rWrtSh
.InsertPageBreak( &aTemplateName
, nPageNumber
);
578 rWrtSh
.InsertPageBreak();
579 rWrtSh
.EndAllAction();
585 case FN_INSERT_BOOKMARK
:
589 OUString sName
= ((SfxStringItem
*)pItem
)->GetValue();
590 rWrtSh
.SetBookmark( KeyCode(), sName
, aEmptyStr
);
594 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
595 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
597 VclAbstractDialog
* pDlg
= pFact
->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh
, rReq
, DLG_INSERT_BOOKMARK
);
598 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
605 case FN_DELETE_BOOKMARK
:
609 IDocumentMarkAccess
* const pMarkAccess
= rWrtSh
.getIDocumentMarkAccess();
610 pMarkAccess
->deleteMark( pMarkAccess
->findMark(((SfxStringItem
*)pItem
)->GetValue()) );
614 case FN_AUTOFORMAT_REDLINE_APPLY
:
616 SvxSwAutoFmtFlags
aFlags(SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags());
617 // This must always be sal_False for the postprocessing.
618 aFlags
.bAFmtByInput
= sal_False
;
619 aFlags
.bWithRedlining
= sal_True
;
620 rWrtSh
.AutoFormat( &aFlags
);
621 aFlags
.bWithRedlining
= sal_False
;
623 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
624 if (pVFrame
->HasChildWindow(FN_REDLINE_ACCEPT
))
625 pVFrame
->ToggleChildWindow(FN_REDLINE_ACCEPT
);
627 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
628 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
630 AbstractSwModalRedlineAcceptDlg
* pDlg
= pFact
->CreateSwModalRedlineAcceptDlg(&GetView().GetEditWin());
631 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
633 switch (lcl_AskRedlineMode(&GetView().GetEditWin()))
637 pDlg
->AcceptAll(sal_True
);
638 SfxRequest
aReq( pVFrame
, FN_AUTOFORMAT_APPLY
);
645 pDlg
->AcceptAll(sal_False
);
658 case FN_AUTOFORMAT_APPLY
:
660 SvxSwAutoFmtFlags
aFlags(SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags());
661 // This must always be sal_False for the postprocessing.
662 aFlags
.bAFmtByInput
= sal_False
;
663 rWrtSh
.AutoFormat( &aFlags
);
667 case FN_AUTOFORMAT_AUTO
:
669 SvxAutoCorrCfg
& rACfg
= SvxAutoCorrCfg::Get();
670 sal_Bool bSet
= pItem
? ((const SfxBoolItem
*)pItem
)->GetValue() : !rACfg
.IsAutoFmtByInput();
671 if( bSet
!= rACfg
.IsAutoFmtByInput() )
673 rACfg
.SetAutoFmtByInput( bSet
);
674 GetView().GetViewFrame()->GetBindings().Invalidate( nSlot
);
676 rReq
.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot
), bSet
) );
681 case FN_AUTO_CORRECT
:
683 // At first set to blank as default.
684 sal_Unicode cChar
= ' ';
685 rWrtSh
.AutoCorrect( *SvxAutoCorrCfg::Get().GetAutoCorrect(), cChar
);
689 case FN_TABLE_SORT_DIALOG
:
692 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
693 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
695 VclAbstractDialog
* pDlg
= pFact
->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh
, DLG_SORTING
);
696 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
702 case FN_NUMBERING_OUTLINE_DLG
:
704 SfxItemSet
aTmp(GetPool(), FN_PARAM_1
, FN_PARAM_1
);
705 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
706 OSL_ENSURE(pFact
, "Dialogdiet fail!");
707 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTabDialog( DLG_TAB_OUTLINE
,
708 GetView().GetWindow(), &aTmp
, rWrtSh
);
709 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
717 SwTransferable
* pTransfer
= new SwTransferable( rWrtSh
);
718 /*??*/ uno::Reference
<
719 datatransfer::XTransferable
> xRef(
721 pTransfer
->CalculateAndCopy();
725 case FN_GOTO_REFERENCE
:
727 SwField
*pFld
= rWrtSh
.GetCurFld();
728 if(pFld
&& pFld
->GetTypeId() == TYP_GETREFFLD
)
730 rWrtSh
.StartAllAction();
731 rWrtSh
.SwCrsrShell::GotoRefMark( ((SwGetRefField
*)pFld
)->GetSetRefName(),
732 ((SwGetRefField
*)pFld
)->GetSubType(),
733 ((SwGetRefField
*)pFld
)->GetSeqNo() );
734 rWrtSh
.EndAllAction();
739 case FN_EDIT_FORMULA
:
741 const sal_uInt16 nId
= SwInputChild::GetChildWindowId();
742 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
745 //if the ChildWindow is active it has to be removed
746 if( pVFrame
->HasChildWindow( nId
) )
748 pVFrame
->ToggleChildWindow( nId
);
749 pVFrame
->GetBindings().InvalidateAll( sal_True
);
752 String
sFormula(((const SfxStringItem
*)pItem
)->GetValue());
754 rWrtSh
.StartAllAction();
756 if( 0 != (bDelSel
= rWrtSh
.HasSelection()) )
758 rWrtSh
.StartUndo( UNDO_START
);
763 rWrtSh
.EnterStdMode();
766 if( !bDelSel
&& aFldMgr
.GetCurFld() && TYP_FORMELFLD
== aFldMgr
.GetCurTypeId() )
767 aFldMgr
.UpdateCurFld( aFldMgr
.GetCurFld()->GetFormat(), aEmptyStr
, sFormula
);
768 else if( sFormula
.Len() )
770 if( rWrtSh
.IsCrsrInTbl() )
772 SfxItemSet
aSet( rWrtSh
.GetAttrPool(), RES_BOXATR_FORMULA
, RES_BOXATR_FORMULA
);
773 aSet
.Put( SwTblBoxFormula( sFormula
));
774 rWrtSh
.SetTblBoxFormulaAttrs( aSet
);
775 rWrtSh
.UpdateTable();
779 SvNumberFormatter
* pFormatter
= rWrtSh
.GetNumberFormatter();
780 sal_uLong nSysNumFmt
= pFormatter
->GetFormatIndex( NF_NUMBER_STANDARD
, LANGUAGE_SYSTEM
);
781 SwInsertFld_Data
aData(TYP_FORMELFLD
, nsSwGetSetExpType::GSE_FORMULA
, aEmptyStr
, sFormula
, nSysNumFmt
);
782 aFldMgr
.InsertFld(aData
);
787 rWrtSh
.EndUndo( UNDO_END
);
788 rWrtSh
.EndAllAction();
793 rWrtSh
.EndAllTblBoxEdit();
794 pVFrame
->ToggleChildWindow( nId
);
795 if( !pVFrame
->HasChildWindow( nId
) )
796 pVFrame
->GetBindings().InvalidateAll( sal_True
);
802 case FN_TABLE_UNSET_READ_ONLY
:
804 rWrtSh
.UnProtectTbls();
807 case FN_EDIT_HYPERLINK
:
808 GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG
);
810 case FN_REMOVE_HYPERLINK
:
812 sal_Bool bSel
= rWrtSh
.HasSelection();
815 rWrtSh
.StartAction();
817 if(!rWrtSh
.SelectTxtAttr( RES_TXTATR_INETFMT
))
820 //now remove the attribute
821 std::set
<sal_uInt16
> aAttribs
;
822 aAttribs
.insert( RES_TXTATR_INETFMT
);
823 rWrtSh
.ResetAttr( aAttribs
);
826 rWrtSh
.Pop(sal_False
);
831 case SID_ATTR_BRUSH_CHAR
:
832 case SID_ATTR_CHAR_SCALEWIDTH
:
833 case SID_ATTR_CHAR_ROTATED
:
834 case FN_TXTATR_INET
:
835 case FN_INSERT_HYPERLINK
:
837 sal_uInt16 nWhich
= GetPool().GetWhich( nSlot
);
838 if ( pArgs
&& pArgs
->GetItemState( nWhich
) == SFX_ITEM_SET
)
840 // intentionally no break
843 case SID_CHAR_DLG_EFFECT
:
845 sw_CharDialog( rWrtSh
, bUseDialog
, nSlot
, pArgs
, &rReq
);
848 case SID_CHAR_DLG_FOR_PARAGRAPH
:
850 rWrtSh
.Push(); //save current cursor
851 SwLangHelper::SelectCurrentPara( rWrtSh
);
852 sw_CharDialog( rWrtSh
, bUseDialog
, nSlot
, pArgs
, &rReq
);
853 rWrtSh
.Pop( sal_False
); //restore old cursor
856 case SID_ATTR_LRSPACE
:
857 case SID_ATTR_ULSPACE
:
858 case SID_ATTR_BRUSH
:
859 case SID_PARA_VERTALIGN
:
860 case SID_ATTR_PARA_NUMRULE
:
861 case SID_ATTR_PARA_REGISTER
:
862 case SID_ATTR_PARA_PAGENUM
:
863 case FN_FORMAT_LINENUMBER
:
864 case FN_NUMBER_NEWSTART
:
865 case FN_NUMBER_NEWSTART_AT
:
866 case FN_FORMAT_DROPCAPS
:
868 case SID_ATTR_PARA_LRSPACE
:
870 sal_uInt16 nWhich
= GetPool().GetWhich( nSlot
);
871 if ( pArgs
&& pArgs
->GetItemState( nWhich
) == SFX_ITEM_SET
)
873 // intentionally no break
882 const SfxPoolItem
* pPaMItem
= 0;
883 pArgs
->GetItemState( GetPool().GetWhich( FN_PARAM_PAM
), sal_False
, &pPaMItem
);
885 pPaM
= static_cast< const SwPaMItem
* >( pPaMItem
)->GetValue( );
889 pPaM
= rWrtSh
.GetCrsr();
891 bool bUseCurCrsr
= true;
893 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, &GetView()));
894 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
)));
896 sal_Bool bApplyCharUnit
= ::HasCharUnit(0 != PTR_CAST(SwWebView
, &GetView()));
897 SW_MOD()->PutItem(SfxBoolItem(SID_ATTR_APPLYCHARUNIT
, bApplyCharUnit
));
899 SfxItemSet
aCoreSet( GetPool(),
900 RES_PARATR_BEGIN
, RES_PARATR_END
- 1,
901 RES_PARATR_LIST_BEGIN
, RES_PARATR_LIST_END
- 1,
902 RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1,
903 SID_ATTR_TABSTOP_POS
, SID_ATTR_TABSTOP_POS
,
904 SID_ATTR_TABSTOP_DEFAULTS
, SID_ATTR_TABSTOP_DEFAULTS
,
905 SID_ATTR_TABSTOP_OFFSET
, SID_ATTR_TABSTOP_OFFSET
,
906 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
,
907 SID_ATTR_PARA_MODEL
, SID_ATTR_PARA_KEEP
,
908 SID_ATTR_PARA_PAGENUM
, SID_ATTR_PARA_PAGENUM
,
909 SID_HTML_MODE
, SID_HTML_MODE
,
910 FN_PARAM_1
, FN_PARAM_1
,
911 FN_NUMBER_NEWSTART
, FN_NUMBER_NEWSTART_AT
,
912 FN_DROP_TEXT
, FN_DROP_CHAR_STYLE_NAME
,
914 // get also the list level indent values merged as LR-SPACE item, if needed.
915 rWrtSh
.GetPaMAttr( pPaM
, aCoreSet
, true );
916 aCoreSet
.Put(SfxUInt16Item(SID_HTML_MODE
,
917 ::GetHtmlMode(GetView().GetDocShell())));
919 // Tabulators: Put DefaultTabs into ItemSet
920 const SvxTabStopItem
& rDefTabs
= (const SvxTabStopItem
&)
921 GetPool().GetDefaultItem(RES_PARATR_TABSTOP
);
923 sal_uInt16 nDefDist
= ::GetTabDist( rDefTabs
);
924 SfxUInt16Item
aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS
, nDefDist
);
925 aCoreSet
.Put( aDefDistItem
);
928 SfxUInt16Item
aTabPos( SID_ATTR_TABSTOP_POS
, 0 );
929 aCoreSet
.Put( aTabPos
);
931 // Left border as offset
932 //#i24363# tab stops relative to indent
933 const long nOff
= rWrtSh
.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT
) ?
934 ((SvxLRSpaceItem
&)aCoreSet
.Get( RES_LR_SPACE
)).GetTxtLeft() : 0;
935 SfxInt32Item
aOff( SID_ATTR_TABSTOP_OFFSET
, nOff
);
936 aCoreSet
.Put( aOff
);
938 // Setting the BoxInfo if based on the current cursor
940 ::PrepareBoxInfo( aCoreSet
, rWrtSh
);
942 // Current page format
943 ::SwToSfxPageDescAttr( aCoreSet
);
945 sal_uInt16 nDefPage
= 0;
947 nDefPage
= ((SfxUInt16Item
*)pItem
)->GetValue();
949 // Properties of numbering
950 if( rWrtSh
.GetDoc()->GetCurrNumRule( *pPaM
->GetPoint() ) )
952 SfxBoolItem
aStart( FN_NUMBER_NEWSTART
, rWrtSh
.IsNumRuleStart( pPaM
) );
953 aCoreSet
.Put(aStart
);
954 SfxUInt16Item
aStartAt( FN_NUMBER_NEWSTART_AT
,
955 rWrtSh
.GetNodeNumStart( pPaM
) );
956 aCoreSet
.Put(aStartAt
);
958 SfxAbstractTabDialog
* pDlg
= NULL
;
960 if ( bUseDialog
&& GetActiveView() )
962 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
963 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
965 pDlg
= pFact
->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet
,DLG_STD
, DLG_PARA
,NULL
, sal_False
, nDefPage
);
966 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
968 SfxItemSet
* pSet
= NULL
;
971 if ( nSlot
== SID_ATTR_PARA_LRSPACE
)
973 SvxLRSpaceItem
aParaMargin((const SvxLRSpaceItem
&)pArgs
->Get(nSlot
));
974 aParaMargin
.SetWhich( RES_LR_SPACE
);
975 aCoreSet
.Put(aParaMargin
);
979 pSet
= (SfxItemSet
*) pArgs
;
982 else if ( NULL
!= pDlg
&& pDlg
->Execute() == RET_OK
)
984 // Apply defaults if nessecary.
985 pSet
= (SfxItemSet
*)pDlg
->GetOutputItemSet();
987 if( SFX_ITEM_SET
== pSet
->GetItemState( SID_ATTR_TABSTOP_DEFAULTS
, sal_False
, &pItem
) &&
988 nDefDist
!= (nNewDist
= ((SfxUInt16Item
*)pItem
)->GetValue()) )
990 SvxTabStopItem
aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT
, RES_PARATR_TABSTOP
);
991 MakeDefTabs( nNewDist
, aDefTabs
);
992 rWrtSh
.SetDefault( aDefTabs
);
993 pSet
->ClearItem( SID_ATTR_TABSTOP_DEFAULTS
);
996 if ( SFX_ITEM_SET
== pSet
->GetItemState(FN_PARAM_1
,sal_False
,&pItem
) )
998 pSet
->Put(SfxStringItem(FN_DROP_TEXT
, ((const SfxStringItem
*)pItem
)->GetValue()));
999 pSet
->ClearItem(FN_PARAM_1
);
1002 if( SFX_ITEM_SET
== pSet
->GetItemState( RES_PARATR_DROP
, sal_False
, &pItem
))
1004 String sCharStyleName
;
1005 if(((const SwFmtDrop
*)pItem
)->GetCharFmt())
1006 sCharStyleName
= ((const SwFmtDrop
*)pItem
)->GetCharFmt()->GetName();
1007 pSet
->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME
, sCharStyleName
));
1014 ::SfxToSwPageDescAttr( rWrtSh
, *pSet
);
1016 // enclose all undos.
1017 // Thus, check conditions, if actions will be performed.
1018 const bool bUndoNeeded( pSet
->Count() ||
1019 SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART
) ||
1020 SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART_AT
) );
1023 rWrtSh
.StartUndo( UNDO_INSATTR
);
1027 rWrtSh
.StartAction();
1028 if ( SFX_ITEM_SET
== pSet
->GetItemState(FN_DROP_TEXT
, sal_False
, &pItem
) )
1030 if ( !((SfxStringItem
*)pItem
)->GetValue().isEmpty() )
1031 rWrtSh
.ReplaceDropTxt(((SfxStringItem
*)pItem
)->GetValue(), pPaM
);
1033 rWrtSh
.SetAttr( *pSet
, 0, pPaM
);
1035 SwTxtFmtColl
* pColl
= rWrtSh
.GetPaMTxtFmtColl( pPaM
);
1036 if(pColl
&& pColl
->IsAutoUpdateFmt())
1038 rWrtSh
.AutoUpdatePara(pColl
, *pSet
, pPaM
);
1042 if( SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART
) )
1044 //SetNumRuleStart(sal_True) restarts the numbering at the value
1045 //that is defined at the starting point of the numbering level
1046 //otherwise the SetNodeNumStart() value determines the start
1047 //if it's set to something different than (sal_uInt16)0xFFFF
1049 sal_Bool bStart
= ((SfxBoolItem
&)pSet
->Get(FN_NUMBER_NEWSTART
)).GetValue();
1051 // Default value for restart value has to be (sal_uInt16)0xFFFF
1052 // in order to indicate that the restart value of the list
1053 // style has to be used on restart.
1054 sal_uInt16 nNumStart
= (sal_uInt16
)0xFFFF;
1055 if( SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART_AT
) )
1057 nNumStart
= ((SfxUInt16Item
&)pSet
->Get(FN_NUMBER_NEWSTART_AT
)).GetValue();
1059 rWrtSh
.SetNumRuleStart(bStart
, pPaM
);
1060 rWrtSh
.SetNodeNumStart(nNumStart
);
1062 else if( SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART_AT
) )
1064 sal_uInt16 nNumStart
= ((SfxUInt16Item
&)pSet
->Get(FN_NUMBER_NEWSTART_AT
)).GetValue();
1065 rWrtSh
.SetNodeNumStart(nNumStart
);
1066 rWrtSh
.SetNumRuleStart(sal_False
, pPaM
);
1071 rWrtSh
.EndUndo( UNDO_INSATTR
);
1078 case FN_NUM_CONTINUE
:
1080 String sContinuedListId
;
1081 const SwNumRule
* pRule
=
1082 rWrtSh
.SearchNumRule( false, true, false, -1, sContinuedListId
);
1084 // Search also for bullet list
1087 pRule
= rWrtSh
.SearchNumRule( false, false, false, -1, sContinuedListId
);
1091 rWrtSh
.SetCurNumRule( *pRule
, false, sContinuedListId
);
1095 case FN_SELECT_PARA
:
1097 if(!rWrtSh
.IsSttOfPara())
1098 rWrtSh
.SttPara(sal_False
);
1100 rWrtSh
.EnterStdMode();
1101 rWrtSh
.EndPara(sal_True
);
1105 case SID_DEC_INDENT
:
1106 case SID_INC_INDENT
:
1107 rWrtSh
.MoveLeftMargin( SID_INC_INDENT
== nSlot
,
1108 rReq
.GetModifier() != KEY_MOD1
);
1111 case FN_DEC_INDENT_OFFSET
:
1112 case FN_INC_INDENT_OFFSET
:
1113 rWrtSh
.MoveLeftMargin( FN_INC_INDENT_OFFSET
== nSlot
,
1114 rReq
.GetModifier() == KEY_MOD1
);
1118 case SID_ATTR_CHAR_COLOR2
:
1122 Color aSet
= ((const SvxColorItem
*)pItem
)->GetValue();
1123 SwEditWin
& rEditWin
= GetView().GetEditWin();
1124 rEditWin
.SetTextColor(aSet
);
1125 SwApplyTemplate
* pApply
= rEditWin
.GetApplyTemplate();
1127 // If there is a selection, then set the color on it
1128 // otherwise, it'll be the color for the next text to be typed
1129 if(!pApply
|| pApply
->nColor
!= SID_ATTR_CHAR_COLOR_EXT
)
1131 rWrtSh
.SetAttr(SvxColorItem (aSet
, RES_CHRATR_COLOR
));
1138 case SID_ATTR_CHAR_COLOR_BACKGROUND
:
1140 SwEditWin
& rEdtWin
= GetView().GetEditWin();
1141 SwApplyTemplate
* pApply
= rEdtWin
.GetApplyTemplate();
1142 rEdtWin
.SetTextBackColorTransparent(0 == pItem
);
1146 aSet
= ((const SvxColorItem
*)pItem
)->GetValue();
1147 rEdtWin
.SetTextBackColor(aSet
); //select last color
1150 rEdtWin
.SetTextBackColor(Color(COL_TRANSPARENT
)); //if last was "no fill"
1151 if(!pApply
&& (rWrtSh
.HasSelection() || rReq
.IsAPI()))
1153 SvxBrushItem
aBrushItem(RES_CHRATR_BACKGROUND
);
1155 aBrushItem
.SetColor(aSet
); //set the selected color
1157 aBrushItem
.SetColor(Color(COL_TRANSPARENT
));//set "no fill" color
1158 rWrtSh
.SetAttr( aBrushItem
);
1160 else if(!pApply
|| pApply
->nColor
!= SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
)
1162 GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
);
1169 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
:
1170 case SID_ATTR_CHAR_COLOR_EXT
:
1172 SwEditWin
& rEdtWin
= GetView().GetEditWin();
1173 SwApplyTemplate
* pApply
= rEdtWin
.GetApplyTemplate();
1174 SwApplyTemplate aTempl
;
1175 sal_Bool bSelection
= rWrtSh
.HasSelection();
1179 if(nSlot
== SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
)
1181 rWrtSh
.SetAttr( SvxBrushItem(
1182 rEdtWin
.GetTextBackColor(), RES_CHRATR_BACKGROUND
) );
1185 rWrtSh
.SetAttr( SvxColorItem( rEdtWin
.GetTextColor(),
1186 RES_CHRATR_COLOR
) );
1190 if(!pApply
|| pApply
->nColor
!= nSlot
)
1191 aTempl
.nColor
= nSlot
;
1192 rEdtWin
.SetApplyTemplate(aTempl
);
1199 case FN_NUM_BULLET_MOVEDOWN
:
1200 if (!rWrtSh
.IsAddMode())
1201 rWrtSh
.MoveParagraph(1);
1205 case FN_NUM_BULLET_MOVEUP
:
1206 if (!rWrtSh
.IsAddMode())
1207 rWrtSh
.MoveParagraph(-1);
1210 case SID_RUBY_DIALOG
:
1211 case SID_HYPERLINK_DIALOG
:
1213 SfxRequest
aReq(nSlot
, SFX_CALLMODE_SLOT
, SFX_APP()->GetPool());
1214 GetView().GetViewFrame()->ExecuteSlot( aReq
);
1218 case FN_INSERT_PAGEHEADER
:
1219 case FN_INSERT_PAGEFOOTER
:
1220 if(pArgs
&& pArgs
->Count())
1224 sStyleName
= ((const SfxStringItem
*)pItem
)->GetValue();
1225 sal_Bool bOn
= sal_True
;
1226 if( SFX_ITEM_SET
== pArgs
->GetItemState(FN_PARAM_1
, sal_False
, &pItem
))
1227 bOn
= ((const SfxBoolItem
*)pItem
)->GetValue();
1228 rWrtSh
.ChangeHeaderOrFooter(sStyleName
, FN_INSERT_PAGEHEADER
== nSlot
, bOn
, !rReq
.IsAPI());
1232 case FN_READONLY_SELECTION_MODE
:
1233 if(GetView().GetDocShell()->IsReadOnly())
1235 rWrtSh
.SetReadonlySelectionOption(
1236 !rWrtSh
.GetViewOptions()->IsSelectionInReadonly());
1240 case FN_SELECTION_MODE_DEFAULT
:
1241 case FN_SELECTION_MODE_BLOCK
:
1243 bool bSetBlockMode
= !rWrtSh
.IsBlockMode();
1244 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(nSlot
, sal_False
, &pItem
))
1245 bSetBlockMode
= ((const SfxBoolItem
*)pItem
)->GetValue();
1246 if( ( nSlot
== FN_SELECTION_MODE_DEFAULT
) ^ bSetBlockMode
)
1247 rWrtSh
.EnterBlockMode();
1249 rWrtSh
.EnterStdMode();
1250 SfxBindings
&rBnd
= GetView().GetViewFrame()->GetBindings();
1251 rBnd
.Invalidate(FN_STAT_SELMODE
);
1252 rBnd
.Update(FN_STAT_SELMODE
);
1255 case SID_OPEN_HYPERLINK
:
1256 case FN_COPY_HYPERLINK_LOCATION
:
1258 SfxItemSet
aSet(GetPool(),
1260 RES_TXTATR_INETFMT
);
1261 rWrtSh
.GetCurAttr(aSet
);
1262 if(SFX_ITEM_SET
<= aSet
.GetItemState( RES_TXTATR_INETFMT
, sal_True
))
1264 const SwFmtINetFmt
& rINetFmt
= dynamic_cast<const SwFmtINetFmt
&>( aSet
.Get(RES_TXTATR_INETFMT
, sal_True
) );
1265 if( nSlot
== FN_COPY_HYPERLINK_LOCATION
)
1267 ::uno::Reference
< datatransfer::clipboard::XClipboard
> xClipboard
= GetView().GetEditWin().GetClipboard();
1268 vcl::unohelper::TextDataObject::CopyStringTo(
1269 rINetFmt
.GetValue(),
1273 rWrtSh
.ClickToINetAttr(rINetFmt
, URLLOAD_NOFILTER
);
1277 case SID_OPEN_XML_FILTERSETTINGS
:
1281 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog
= ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
1284 catch (const uno::Exception
&)
1286 DBG_UNHANDLED_EXCEPTION();
1291 case FN_FORMAT_APPLY_HEAD1
:
1295 case FN_FORMAT_APPLY_HEAD2
:
1299 case FN_FORMAT_APPLY_HEAD3
:
1303 case FN_FORMAT_APPLY_DEFAULT
:
1307 case FN_FORMAT_APPLY_TEXTBODY
:
1311 case FN_WORDCOUNT_DIALOG
:
1313 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
1314 if (pVFrame
!= NULL
)
1316 pVFrame
->ToggleChildWindow(FN_WORDCOUNT_DIALOG
);
1317 Invalidate(rReq
.GetSlot());
1319 SwWordCountWrapper
*pWrdCnt
= (SwWordCountWrapper
*)pVFrame
->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
1321 pWrdCnt
->UpdateCounts();
1326 OSL_ENSURE(!this, "wrong dispatcher");
1331 void SwTextShell::GetState( SfxItemSet
&rSet
)
1333 SwWrtShell
&rSh
= GetShell();
1334 SfxWhichIter
aIter( rSet
);
1335 sal_uInt16 nWhich
= aIter
.FirstWhich();
1340 case SID_LANGUAGE_STATUS
:
1342 // the value of used script types
1343 String
aScriptTypesInUse( OUString::number( rSh
.GetScriptType() ) );
1345 SvtLanguageTable aLangTable
;
1347 // get keyboard language
1348 String aKeyboardLang
;
1349 SwEditWin
& rEditWin
= GetView().GetEditWin();
1350 LanguageType nLang
= rEditWin
.GetInputLanguage();
1351 if (nLang
!= LANGUAGE_DONTKNOW
&& nLang
!= LANGUAGE_SYSTEM
)
1352 aKeyboardLang
= aLangTable
.GetString( nLang
);
1354 // get the language that is in use
1355 String aCurrentLang
= OUString("*");
1356 nLang
= SwLangHelper::GetCurrentLanguage( rSh
);
1357 if (nLang
!= LANGUAGE_DONTKNOW
)
1358 aCurrentLang
= aLangTable
.GetString( nLang
);
1360 // build sequence for status value
1361 uno::Sequence
< OUString
> aSeq( 4 );
1362 aSeq
[0] = aCurrentLang
;
1363 aSeq
[1] = aScriptTypesInUse
;
1364 aSeq
[2] = aKeyboardLang
;
1365 aSeq
[3] = SwLangHelper::GetTextForLanguageGuessing( rSh
);
1367 // set sequence as status value
1368 SfxStringListItem
aItem( SID_LANGUAGE_STATUS
);
1369 aItem
.SetStringList( aSeq
);
1370 rSet
.Put( aItem
, SID_LANGUAGE_STATUS
);
1376 // is there a valid selection to get text from?
1378 bool bValid
= !rSh
.HasSelection() ||
1379 (rSh
.IsSelOnePara() && !rSh
.IsMultiSelection());
1380 // prevent context menu from showing when cursor is not in or at the end of a word
1381 // (GetCurWord will return the next word if there is none at the current position...)
1382 const sal_Int16 nWordType
= ::i18n::WordType::DICTIONARY_WORD
;
1383 bool bWord
= rSh
.IsInWord( nWordType
) || rSh
.IsStartWord( nWordType
) || rSh
.IsEndWord( nWordType
);
1384 if (bValid
&& bWord
)
1385 aText
= rSh
.HasSelection()? rSh
.GetSelTxt() : rSh
.GetCurWord();
1387 LanguageType nLang
= rSh
.GetCurLang();
1388 LanguageTag
aLanguageTag( nLang
);
1389 lang::Locale
aLocale( aLanguageTag
.getLocale());
1390 String
aLangText( aLanguageTag
.getBcp47() );
1392 // set word and locale to look up as status value
1393 String
aStatusVal( aText
);
1394 aStatusVal
.AppendAscii( "#" );
1395 aStatusVal
+= aLangText
;
1397 rSet
.Put( SfxStringItem( SID_THES
, aStatusVal
) );
1399 // disable "Thesaurus" context menu entry if there is nothing to look up
1400 uno::Reference
< linguistic2::XThesaurus
> xThes( ::GetThesaurus() );
1401 if (aText
.Len() == 0 ||
1402 !xThes
.is() || nLang
== LANGUAGE_NONE
|| !xThes
->hasLocale( aLocale
))
1403 rSet
.DisableItem( SID_THES
);
1407 case FN_NUMBER_NEWSTART
:
1408 if(!rSh
.GetCurNumRule())
1409 rSet
.DisableItem(nWhich
);
1411 rSet
.Put(SfxBoolItem(FN_NUMBER_NEWSTART
,
1412 rSh
.IsNumRuleStart()));
1414 case FN_EDIT_FORMULA
:
1417 const int nType
= rSh
.GetSelectionType();
1418 if (!(nType
& nsSelectionType::SEL_TXT
) &&
1419 !(nType
& nsSelectionType::SEL_TBL
) &&
1420 !(nType
& nsSelectionType::SEL_NUM
))
1421 rSet
.DisableItem(nWhich
);
1425 case FN_INSERT_ENDNOTE
:
1426 case FN_INSERT_FOOTNOTE
:
1427 case FN_INSERT_FOOTNOTE_DLG
:
1429 const sal_uInt16 nNoType
= FRMTYPE_FLY_ANY
| FRMTYPE_HEADER
|
1430 FRMTYPE_FOOTER
| FRMTYPE_FOOTNOTE
;
1431 if ( (rSh
.GetFrmType(0,sal_True
) & nNoType
) )
1432 rSet
.DisableItem(nWhich
);
1435 case FN_INSERT_TABLE
:
1436 if ( rSh
.GetTableFmt() ||
1437 (rSh
.GetFrmType(0,sal_True
) & FRMTYPE_FOOTNOTE
) )
1438 rSet
.DisableItem( nWhich
);
1442 if ( !rSh
.IsSelection() )
1443 rSet
.DisableItem(nWhich
);
1445 case FN_GOTO_REFERENCE
:
1447 SwField
*pFld
= rSh
.GetCurFld();
1448 if ( !pFld
|| (pFld
&& pFld
->GetTypeId() != TYP_GETREFFLD
) )
1449 rSet
.DisableItem(nWhich
);
1452 case FN_AUTOFORMAT_AUTO
:
1454 rSet
.Put( SfxBoolItem( nWhich
, SvxAutoCorrCfg::Get().IsAutoFmtByInput() ));
1458 case SID_DEC_INDENT
:
1459 case SID_INC_INDENT
:
1461 sal_uInt16 nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
1462 nHtmlMode
&= HTMLMODE_ON
|HTMLMODE_SOME_STYLES
;
1463 if( (nHtmlMode
== HTMLMODE_ON
) || !rSh
.IsMoveLeftMargin(
1464 SID_INC_INDENT
== nWhich
, true ))
1465 rSet
.DisableItem( nWhich
);
1469 case FN_DEC_INDENT_OFFSET
:
1470 case FN_INC_INDENT_OFFSET
:
1472 sal_uInt16 nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
1473 nHtmlMode
&= HTMLMODE_ON
|HTMLMODE_SOME_STYLES
;
1474 if( (nHtmlMode
== HTMLMODE_ON
) ||
1475 !rSh
.IsMoveLeftMargin( FN_INC_INDENT_OFFSET
== nWhich
,
1477 rSet
.DisableItem( nWhich
);
1481 case SID_ATTR_CHAR_COLOR2
:
1483 rSet
.Put(SvxColorItem(GetView().GetEditWin().GetTextColor(), SID_ATTR_CHAR_COLOR2
));
1486 case SID_ATTR_CHAR_COLOR_BACKGROUND
:
1488 if(GetView().GetEditWin().IsTextBackColorTransparent())
1489 rSet
.Put(SvxColorItem(Color(COL_TRANSPARENT
), SID_ATTR_CHAR_COLOR_BACKGROUND
));
1491 rSet
.Put(SvxColorItem(GetView().GetEditWin().GetTextBackColor(), SID_ATTR_CHAR_COLOR_BACKGROUND
));
1494 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
:
1495 case SID_ATTR_CHAR_COLOR_EXT
:
1497 SwEditWin
& rEdtWin
= GetView().GetEditWin();
1498 SwApplyTemplate
* pApply
= rEdtWin
.GetApplyTemplate();
1499 rSet
.Put(SfxBoolItem(nWhich
, pApply
&& pApply
->nColor
== nWhich
));
1502 case FN_INSERT_BOOKMARK
:
1503 if( rSh
.IsTableMode() )
1504 rSet
.DisableItem( nWhich
);
1507 case FN_INSERT_PAGEHEADER
:
1508 case FN_INSERT_PAGEFOOTER
:
1510 rSet
.Put( SfxObjectShellItem( nWhich
, GetView().GetDocShell() ));
1513 case FN_TABLE_SORT_DIALOG
:
1514 case FN_SORTING_DLG
:
1515 if(!rSh
.HasSelection() ||
1516 (FN_TABLE_SORT_DIALOG
== nWhich
&& !rSh
.GetTableFmt()))
1517 rSet
.DisableItem( nWhich
);
1519 case SID_RUBY_DIALOG
:
1521 SvtCJKOptions aCJKOptions
;
1522 if(!aCJKOptions
.IsRubyEnabled())
1524 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
1525 rSet
.DisableItem(nWhich
);
1528 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
1532 case SID_HYPERLINK_DIALOG
:
1533 if( GetView().GetDocShell()->IsReadOnly() ||
1534 (!GetView().GetViewFrame()->HasChildWindow(nWhich
) &&
1535 rSh
.HasReadonlySel()) )
1536 rSet
.DisableItem(nWhich
);
1538 rSet
.Put(SfxBoolItem( nWhich
, 0 != GetView().
1539 GetViewFrame()->GetChildWindow( nWhich
) ));
1541 case FN_EDIT_HYPERLINK
:
1542 case FN_COPY_HYPERLINK_LOCATION
:
1544 SfxItemSet
aSet(GetPool(),
1546 RES_TXTATR_INETFMT
);
1547 rSh
.GetCurAttr(aSet
);
1548 if(SFX_ITEM_SET
> aSet
.GetItemState( RES_TXTATR_INETFMT
, sal_True
) || rSh
.HasReadonlySel())
1550 rSet
.DisableItem(nWhich
);
1554 case FN_REMOVE_HYPERLINK
:
1556 SfxItemSet
aSet(GetPool(),
1558 RES_TXTATR_INETFMT
);
1559 rSh
.GetCurAttr(aSet
);
1561 // If a hyperlink is selected, either alone or along with other text...
1562 if( ((SFX_ITEM_DONTCARE
& aSet
.GetItemState( RES_TXTATR_INETFMT
, sal_True
)) == 0) || rSh
.HasReadonlySel())
1564 rSet
.DisableItem(nWhich
);
1568 case SID_TRANSLITERATE_HALFWIDTH
:
1569 case SID_TRANSLITERATE_FULLWIDTH
:
1570 case SID_TRANSLITERATE_HIRAGANA
:
1571 case SID_TRANSLITERATE_KATAGANA
:
1573 SvtCJKOptions aCJKOptions
;
1574 if(!aCJKOptions
.IsChangeCaseMapEnabled())
1576 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
1577 rSet
.DisableItem(nWhich
);
1580 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
1583 case FN_READONLY_SELECTION_MODE
:
1584 if(!GetView().GetDocShell()->IsReadOnly())
1585 rSet
.DisableItem( nWhich
);
1588 rSet
.Put(SfxBoolItem(nWhich
, rSh
.GetViewOptions()->IsSelectionInReadonly()));
1591 case FN_SELECTION_MODE_DEFAULT
:
1592 case FN_SELECTION_MODE_BLOCK
:
1593 rSet
.Put(SfxBoolItem(nWhich
, (nWhich
== FN_SELECTION_MODE_DEFAULT
) != rSh
.IsBlockMode()));
1595 case SID_OPEN_HYPERLINK
:
1597 SfxItemSet
aSet(GetPool(),
1599 RES_TXTATR_INETFMT
);
1600 rSh
.GetCurAttr(aSet
);
1601 if(SFX_ITEM_SET
> aSet
.GetItemState( RES_TXTATR_INETFMT
, sal_False
))
1602 rSet
.DisableItem(nWhich
);
1605 case SID_OPEN_SMARTTAGMENU
:
1607 uno::Sequence
< OUString
> aSmartTagTypes
;
1608 uno::Sequence
< uno::Reference
< container::XStringKeyMap
> > aStringKeyMaps
;
1609 uno::Reference
<text::XTextRange
> xRange
;
1611 rSh
.GetSmartTagTerm( aSmartTagTypes
, aStringKeyMaps
, xRange
);
1613 if ( xRange
.is() && aSmartTagTypes
.getLength() )
1615 uno::Sequence
< uno::Sequence
< uno::Reference
< smarttags::XSmartTagAction
> > > aActionComponentsSequence
;
1616 uno::Sequence
< uno::Sequence
< sal_Int32
> > aActionIndicesSequence
;
1618 const SmartTagMgr
& rSmartTagMgr
= SwSmartTagMgr::Get();
1619 rSmartTagMgr
.GetActionSequences( aSmartTagTypes
,
1620 aActionComponentsSequence
,
1621 aActionIndicesSequence
);
1623 uno::Reference
<frame::XController
> xController
= GetView().GetController();
1624 const lang::Locale
aLocale( SW_BREAKITER()->GetLocale( GetAppLanguageTag() ) );
1625 const OUString
aApplicationName( rSmartTagMgr
.GetApplicationName() );
1626 const OUString aRangeText
= xRange
->getString();
1628 const SvxSmartTagItem
aItem( nWhich
,
1629 aActionComponentsSequence
,
1630 aActionIndicesSequence
,
1641 rSet
.DisableItem(nWhich
);
1644 case FN_NUM_NUMBERING_ON
:
1645 rSet
.Put(SfxBoolItem(FN_NUM_NUMBERING_ON
,rSh
.SelectionHasNumber()));
1647 case FN_NUM_BULLET_ON
:
1648 rSet
.Put(SfxBoolItem(FN_NUM_BULLET_ON
,rSh
.SelectionHasBullet()));
1650 case FN_BUL_NUM_RULE_INDEX
:
1651 case FN_NUM_NUM_RULE_INDEX
:
1653 SwNumRule
* pCurRule
= (SwNumRule
*)(GetShell().GetCurNumRule());
1654 sal_uInt16 nActNumLvl
= (sal_uInt16
)0xFFFF;
1655 rSet
.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX
,DEFAULT_NONE
));
1656 rSet
.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX
,DEFAULT_NONE
));
1659 nActNumLvl
= GetShell().GetNumLevel();
1660 if( nActNumLvl
< MAXLEVEL
)
1662 nActNumLvl
= 1<<nActNumLvl
;
1664 SvxNumRule aSvxRule
= pCurRule
->MakeSvxNumRule();
1665 if ( GetShell().HasBullet())
1667 rSet
.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX
,(sal_uInt16
)0xFFFF));
1668 rSet
.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX
,(sal_uInt16
)0xFFFF));
1669 NBOTypeMgrBase
* pBullets
= NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS
);
1672 sal_uInt16 nBulIndex
= pBullets
->GetNBOIndexForNumRule(aSvxRule
,nActNumLvl
);
1673 rSet
.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX
,nBulIndex
));
1675 }else if ( GetShell().HasNumber() )
1677 rSet
.Put(SfxUInt16Item(FN_BUL_NUM_RULE_INDEX
,(sal_uInt16
)0xFFFF));
1678 rSet
.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX
,(sal_uInt16
)0xFFFF));
1679 NBOTypeMgrBase
* pNumbering
= NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING
);
1682 sal_uInt16 nBulIndex
= pNumbering
->GetNBOIndexForNumRule(aSvxRule
,nActNumLvl
);
1683 rSet
.Put(SfxUInt16Item(FN_NUM_NUM_RULE_INDEX
,nBulIndex
));
1689 case FN_NUM_CONTINUE
:
1693 // Search also for bullet list
1695 const SwNumRule
* pRule
=
1696 rSh
.SearchNumRule( false, true, false, -1, aDummy
);
1699 pRule
= rSh
.SearchNumRule( false, false, false, -1, aDummy
);
1702 rSet
.DisableItem(nWhich
);
1706 case SID_INSERT_RLM
:
1707 case SID_INSERT_LRM
:
1708 case SID_INSERT_ZWNBSP
:
1709 case SID_INSERT_ZWSP
:
1711 SvtCTLOptions aCTLOptions
;
1712 sal_Bool bEnabled
= aCTLOptions
.IsCTLFontEnabled();
1713 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, bEnabled
);
1715 rSet
.DisableItem(nWhich
);
1719 nWhich
= aIter
.NextWhich();
1723 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */