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: textsh1.cxx,v $
10 * $Revision: 1.70.84.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 <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
34 #include <comphelper/processfactory.hxx>
35 #include <svx/dialogs.hrc>
36 #include <hintids.hxx>
40 #include <i18npool/mslangid.hxx>
41 #include <svtools/languageoptions.hxx>
42 #include <svx/langitem.hxx>
43 #include <svtools/langtab.hxx>
44 #include <svtools/slstitm.hxx>
46 #include <svtools/stritem.hxx>
47 #include <svx/htmlmode.hxx>
48 #include <svtools/whiter.hxx>
49 #include <sfx2/bindings.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <sfx2/objitem.hxx>
52 #include <vcl/msgbox.hxx>
53 #include <vcl/unohelp2.hxx>
54 #include <sfx2/request.hxx>
55 #include <svtools/eitem.hxx>
56 #include <svtools/macitem.hxx>
57 #include <svx/lrspitem.hxx>
58 #include <svx/ulspitem.hxx>
59 #include <svx/colritem.hxx>
60 #include <svx/tstpitem.hxx>
61 #include <svx/brshitem.hxx>
62 #include <svx/svxacorr.hxx>
63 #include <svtools/cjkoptions.hxx>
64 #include <svtools/ctloptions.hxx>
65 #include <IDocumentSettingAccess.hxx>
66 #include <charfmt.hxx>
67 #include <svx/fontitem.hxx>
68 #include <svx/SmartTagItem.hxx>
69 #include <svx/dialmgr.hxx>
70 #include <fmtinfmt.hxx>
74 #include <swmodule.hxx>
75 #include <viewopt.hxx>
77 #include <swevent.hxx>
78 #include <fmthdft.hxx>
79 #include <pagedesc.hxx>
82 #include <swdtflvr.hxx>
83 #include <docstat.hxx>
84 #include <outline.hxx>
85 #include <tablemgr.hxx>
86 #include <swundo.hxx> // fuer Undo-IDs
90 #include <inputwin.hxx>
94 #include <cellatr.hxx>
96 #include <redlndlg.hxx>
99 #include <globals.hrc>
100 #include <shells.hrc>
103 #include "paratr.hxx"
104 #include <crsskip.hxx>
105 #include <docstat.hxx>
106 #include <vcl/svapp.hxx>
107 #include <sfx2/app.hxx>
108 #include <breakit.hxx>
110 #include <SwSmartTagMgr.hxx>
112 #include <svx/acorrcfg.hxx>
113 #include "swabstdlg.hxx"
115 #include "chrdlg.hrc"
116 #include <IDocumentStatistics.hxx>
118 #include <sfx2/sfxdlg.hxx>
119 #include <svtools/languageoptions.hxx>
120 #include <svtools/lingucfg.hxx>
121 #include <com/sun/star/beans/XPropertySet.hpp>
122 #include <com/sun/star/util/XChangesBatch.hpp>
123 #include <com/sun/star/uno/Any.hxx>
124 #include <svx/unolingu.hxx>
125 #include <svtools/syslocaleoptions.hxx>
131 #include <langhelper.hxx>
133 using namespace ::com::sun::star
;
136 void lcl_CharDialog( SwWrtShell
&rWrtSh
, BOOL bUseDialog
, USHORT nSlot
,const SfxItemSet
*pArgs
, SfxRequest
*pReq
)
138 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, &rWrtSh
.GetView()));
139 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< UINT16
>(eMetric
)));
140 SfxItemSet
aCoreSet( rWrtSh
.GetView().GetPool(),
141 RES_CHRATR_BEGIN
, RES_CHRATR_END
-1,
142 RES_TXTATR_INETFMT
, RES_TXTATR_INETFMT
,
143 RES_BACKGROUND
, RES_BACKGROUND
,
144 FN_PARAM_SELECTION
, FN_PARAM_SELECTION
,
145 SID_HTML_MODE
, SID_HTML_MODE
,
146 SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
,
148 rWrtSh
.GetCurAttr( aCoreSet
);
149 BOOL bSel
= rWrtSh
.HasSelection();
150 BOOL bSelectionPut
= FALSE
;
151 if(bSel
|| rWrtSh
.IsInWord())
155 rWrtSh
.StartAction();
157 if(!rWrtSh
.SelectTxtAttr( RES_TXTATR_INETFMT
))
160 aCoreSet
.Put(SfxStringItem(FN_PARAM_SELECTION
, rWrtSh
.GetSelTxt()));
161 bSelectionPut
= TRUE
;
168 aCoreSet
.Put( SfxUInt16Item( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
,
169 rWrtSh
.GetScalingOfSelectedText() ) );
170 // Das CHRATR_BACKGROUND-Attribut wird fuer den Dialog in
171 // ein RES_BACKGROUND verwandelt und wieder zurueck ...
172 const SfxPoolItem
*pTmpBrush
;
173 if( SFX_ITEM_SET
== aCoreSet
.GetItemState( RES_CHRATR_BACKGROUND
, TRUE
, &pTmpBrush
) )
175 SvxBrushItem
aTmpBrush( *((SvxBrushItem
*)pTmpBrush
) );
176 aTmpBrush
.SetWhich( RES_BACKGROUND
);
177 aCoreSet
.Put( aTmpBrush
);
180 aCoreSet
.Put(SfxUInt16Item(SID_HTML_MODE
, ::GetHtmlMode(rWrtSh
.GetView().GetDocShell())));
181 SfxAbstractTabDialog
* pDlg
= NULL
;
182 if ( bUseDialog
&& GetActiveView() )
184 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
185 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
187 pDlg
= pFact
->CreateSwCharDlg( rWrtSh
.GetView().GetWindow(), rWrtSh
.GetView(), aCoreSet
, DLG_CHAR
);
188 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
189 if( FN_INSERT_HYPERLINK
== nSlot
)
190 pDlg
->SetCurPageId(TP_CHAR_URL
);
193 const SfxItemSet
* pSet
= NULL
;
196 else if ( NULL
!= pDlg
&& pDlg
->Execute() == RET_OK
) /* #110771# pDlg can be NULL */
198 pSet
= pDlg
->GetOutputItemSet();
203 SfxItemSet
aTmpSet( *pSet
);
204 if( SFX_ITEM_SET
== aTmpSet
.GetItemState( RES_BACKGROUND
, FALSE
, &pTmpBrush
) )
206 SvxBrushItem
aTmpBrush( *((SvxBrushItem
*)pTmpBrush
) );
207 aTmpBrush
.SetWhich( RES_CHRATR_BACKGROUND
);
208 aTmpSet
.Put( aTmpBrush
);
211 aTmpSet
.ClearItem( RES_BACKGROUND
);
213 const SfxPoolItem
* pSelectionItem
;
214 BOOL bInsert
= FALSE
;
215 xub_StrLen nInsert
= 0;
217 // aus ungeklaerter Ursache ist das alte Item wieder im Set
218 if( !bSelectionPut
&& SFX_ITEM_SET
== aTmpSet
.GetItemState(FN_PARAM_SELECTION
, FALSE
, &pSelectionItem
) )
220 String sInsert
= ((const SfxStringItem
*)pSelectionItem
)->GetValue();
221 bInsert
= sInsert
.Len() != 0;
224 nInsert
= sInsert
.Len();
225 rWrtSh
.StartAction();
226 rWrtSh
.Insert( sInsert
);
228 rWrtSh
.ExtendSelection(FALSE
, sInsert
.Len());
229 SfxRequest
aReq( rWrtSh
.GetView().GetViewFrame(), FN_INSERT_STRING
);
230 aReq
.AppendItem( SfxStringItem( FN_INSERT_STRING
, sInsert
) );
232 SfxRequest
aReq1( rWrtSh
.GetView().GetViewFrame(), FN_CHAR_LEFT
);
233 aReq1
.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT
, nInsert
) );
234 aReq1
.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION
, TRUE
) );
238 aTmpSet
.ClearItem(FN_PARAM_SELECTION
);
240 SwTxtFmtColl
* pColl
= rWrtSh
.GetCurTxtFmtColl();
241 if(bSel
&& rWrtSh
.IsSelFullPara() && pColl
&& pColl
->IsAutoUpdateFmt())
243 rWrtSh
.AutoUpdatePara(pColl
, aTmpSet
);
246 rWrtSh
.SetAttr( aTmpSet
);
251 SfxRequest
aReq1( rWrtSh
.GetView().GetViewFrame(), FN_CHAR_RIGHT
);
252 aReq1
.AppendItem( SfxInt16Item(FN_PARAM_MOVE_COUNT
, nInsert
) );
253 aReq1
.AppendItem( SfxBoolItem(FN_PARAM_MOVE_SELECTION
, FALSE
) );
257 rWrtSh
.DontExpandFmt();
265 /*--------------------------------------------------------------------
267 --------------------------------------------------------------------*/
269 short lcl_AskRedlineMode(Window
*pWin
)
271 MessBox
aQBox( pWin
, 0,
272 String( SW_RES( STR_REDLINE_TITLE
) ),
273 String( SW_RES( STR_REDLINE_MSG
) ) );
274 aQBox
.SetImage( QueryBox::GetStandardImage() );
275 USHORT nBtnFlags
= BUTTONDIALOG_DEFBUTTON
|
276 BUTTONDIALOG_OKBUTTON
|
277 BUTTONDIALOG_FOCUSBUTTON
;
279 aQBox
.AddButton(String(SW_RES(STR_REDLINE_ACCEPT_ALL
)), RET_OK
, nBtnFlags
);
280 aQBox
.GetPushButton( RET_OK
)->SetHelpId(HID_AUTOFORMAT_ACCEPT
);
281 aQBox
.AddButton(String(SW_RES(STR_REDLINE_REJECT_ALL
)), RET_CANCEL
, BUTTONDIALOG_CANCELBUTTON
);
282 aQBox
.GetPushButton( RET_CANCEL
)->SetHelpId(HID_AUTOFORMAT_REJECT
);
283 aQBox
.AddButton(String(SW_RES(STR_REDLINE_EDIT
)), 2, 0);
284 aQBox
.GetPushButton( 2 )->SetHelpId(HID_AUTOFORMAT_EDIT_CHG
);
285 aQBox
.SetButtonHelpText( RET_OK
, aEmptyStr
);
287 return aQBox
.Execute();
290 void SwTextShell::Execute(SfxRequest
&rReq
)
292 BOOL bUseDialog
= TRUE
;
293 const SfxItemSet
*pArgs
= rReq
.GetArgs();
294 SwWrtShell
& rWrtSh
= GetShell();
295 const SfxPoolItem
* pItem
= 0;
296 USHORT nSlot
= rReq
.GetSlot();
298 pArgs
->GetItemState(GetPool().GetWhich(nSlot
), FALSE
, &pItem
);
301 case SID_LANGUAGE_STATUS
:
305 SFX_REQUEST_ARG( rReq
, pItem2
, SfxStringItem
, SID_LANGUAGE_STATUS
, sal_False
);
307 aNewLangTxt
= pItem2
->GetValue();
309 //!! Remember the view frame right now...
310 //!! (call to GetView().GetViewFrame() will break if the
311 //!! SwTextShell got destroyed meanwhile.)
312 SfxViewFrame
*pViewFrame
= GetView().GetViewFrame();
314 if (aNewLangTxt
.EqualsAscii( "*" ))
316 // open the dialog "Tools/Options/Language Settings - Language"
317 // to set the documents default language
318 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
321 VclAbstractDialog
* pDlg
= pFact
->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS
);
328 //!! We have to use StartAction / EndAction bracketing in
329 //!! order to prevent possible destruction of the SwTextShell
330 //!! due to the selection changes coming below.
331 rWrtSh
.StartAction();
332 // prevent view from jumping because of (temporary) selection changes
333 rWrtSh
.LockView( TRUE
);
334 // save selection for later restoration
337 // setting the new language...
338 if (aNewLangTxt
.Len() > 0)
340 const String
aSelectionLangPrefix( String::CreateFromAscii("Current_") );
341 const String
aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") );
342 const String
aDocumentLangPrefix( String::CreateFromAscii("Default_") );
343 const String
aStrNone( String::CreateFromAscii("LANGUAGE_NONE") );
345 SfxItemSet
aCoreSet( GetPool(),
346 RES_CHRATR_LANGUAGE
, RES_CHRATR_LANGUAGE
,
347 RES_CHRATR_CJK_LANGUAGE
, RES_CHRATR_CJK_LANGUAGE
,
348 RES_CHRATR_CTL_LANGUAGE
, RES_CHRATR_CTL_LANGUAGE
,
352 bool bForSelection
= true;
353 bool bForParagraph
= false;
354 if (STRING_NOTFOUND
!= (nPos
= aNewLangTxt
.Search( aSelectionLangPrefix
, 0 )))
356 // ... for the current selection
357 aNewLangTxt
= aNewLangTxt
.Erase( nPos
, aSelectionLangPrefix
.Len() );
358 bForSelection
= true;
360 else if (STRING_NOTFOUND
!= (nPos
= aNewLangTxt
.Search( aParagraphLangPrefix
, 0 )))
362 // ... for the current paragraph language
363 aNewLangTxt
= aNewLangTxt
.Erase( nPos
, aParagraphLangPrefix
.Len() );
364 bForSelection
= true;
365 bForParagraph
= true;
367 else if (STRING_NOTFOUND
!= (nPos
= aNewLangTxt
.Search( aDocumentLangPrefix
, 0 )))
369 // ... as default document language
370 aNewLangTxt
= aNewLangTxt
.Erase( nPos
, aDocumentLangPrefix
.Len() );
371 bForSelection
= false;
375 SwLangHelper::SelectCurrentPara( rWrtSh
);
377 if (!bForSelection
) // document language to be changed...
380 rWrtSh
.ExtendedSelectAll();
382 if (aNewLangTxt
!= aStrNone
)
383 SwLangHelper::SetLanguage( rWrtSh
, aNewLangTxt
, bForSelection
, aCoreSet
);
385 SwLangHelper::SetLanguage_None( rWrtSh
, bForSelection
, aCoreSet
);
388 // restore selection...
391 rWrtSh
.LockView( FALSE
);
395 // invalidate slot to get the new language displayed
396 pViewFrame
->GetBindings().Invalidate( nSlot
);
404 InsertSymbol( rReq
);
407 case FN_INSERT_FOOTNOTE
:
408 case FN_INSERT_ENDNOTE
:
411 SFX_REQUEST_ARG( rReq
, pFont
, SfxStringItem
, FN_PARAM_1
, sal_False
);
412 // SFX_REQUEST_ARG( rReq, pCharset, SfxInt16Item, FN_PARAM_2 , sal_False );
413 SFX_REQUEST_ARG( rReq
, pNameItem
, SfxStringItem
, nSlot
, sal_False
);
415 aStr
= pNameItem
->GetValue();
416 BOOL bFont
= pFont
&& pFont
->GetValue().Len();
417 rWrtSh
.StartUndo( UNDO_UI_INSERT_FOOTNOTE
);
418 rWrtSh
.InsertFootnote( aStr
, nSlot
== FN_INSERT_ENDNOTE
, !bFont
);
421 rWrtSh
.Left( CRSR_SKIP_CHARS
, TRUE
, 1, FALSE
);
422 SfxItemSet
aSet( rWrtSh
.GetAttrPool(), RES_CHRATR_FONT
, RES_CHRATR_FONT
);
423 rWrtSh
.GetCurAttr( aSet
);
424 SvxFontItem
&rFont
= (SvxFontItem
&) aSet
.Get( RES_CHRATR_FONT
);
425 SvxFontItem
aFont( rFont
.GetFamily(), pFont
->GetValue(),
426 rFont
.GetStyleName(), rFont
.GetPitch(), RTL_TEXTENCODING_DONTKNOW
, RES_CHRATR_FONT
);
427 //pCharset ? (CharSet) pCharset->GetValue() : RTL_TEXTENCODING_DONTKNOW );
428 rWrtSh
.SetAttr( aSet
, nsSetAttrMode::SETATTR_DONTEXPAND
);
429 rWrtSh
.ResetSelect(0, FALSE
);
433 rWrtSh
.EndUndo( UNDO_UI_INSERT_FOOTNOTE
);
437 case FN_INSERT_FOOTNOTE_DLG
:
439 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
440 DBG_ASSERT(pFact
, "Dialogdiet fail!");
441 AbstractInsFootNoteDlg
* pDlg
= pFact
->CreateInsFootNoteDlg( DLG_INS_FOOTNOTE
,
442 GetView().GetWindow(), rWrtSh
, FALSE
);
443 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
444 pDlg
->SetHelpId(nSlot
);
445 if ( pDlg
->Execute() == RET_OK
)
447 USHORT nId
= pDlg
->IsEndNote() ? FN_INSERT_ENDNOTE
: FN_INSERT_FOOTNOTE
;
448 SfxRequest
aReq( GetView().GetViewFrame(), nId
);
449 if ( pDlg
->GetStr().Len() )
450 aReq
.AppendItem( SfxStringItem( nId
, pDlg
->GetStr() ) );
451 if ( pDlg
->GetFontName().Len() )
452 aReq
.AppendItem( SfxStringItem( FN_PARAM_1
, pDlg
->GetFontName() ) );
453 //aReq.AppendItem( SfxStringItem( FN_PARAM_2, pDlg->GetCharSet() ) );
461 case FN_FORMAT_FOOTNOTE_DLG
:
463 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
464 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
466 VclAbstractDialog
* pDlg
= pFact
->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rWrtSh
, DLG_DOC_FOOTNOTE
);
467 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
474 GetView().ExecuteInsertDoc( rReq
, pItem
);
477 case FN_FORMAT_RESET
:
479 // #i78856, reset all attributes but not the language attributes
480 // (for this build an array of all relevant attributes and
481 // remove the languages from that)
482 SvUShortsSort aAttribs
;
484 USHORT __FAR_DATA aResetableSetRange
[] = {
485 RES_FRMATR_BEGIN
, RES_FRMATR_END
-1,
486 RES_CHRATR_BEGIN
, RES_CHRATR_LANGUAGE
- 1,
487 RES_CHRATR_LANGUAGE
+ 1, RES_CHRATR_CJK_LANGUAGE
- 1,
488 RES_CHRATR_CJK_LANGUAGE
+ 1, RES_CHRATR_CTL_LANGUAGE
- 1,
489 RES_CHRATR_CTL_LANGUAGE
+ 1, RES_CHRATR_END
-1,
490 RES_PARATR_BEGIN
, RES_PARATR_END
-1,
491 RES_TXTATR_CHARFMT
, RES_TXTATR_CHARFMT
,
492 RES_TXTATR_INETFMT
, RES_TXTATR_INETFMT
,
493 RES_TXTATR_CJK_RUBY
, RES_TXTATR_UNKNOWN_CONTAINER
,
494 RES_UNKNOWNATR_BEGIN
, RES_UNKNOWNATR_END
-1,
497 USHORT __FAR_DATA
*pUShorts
= aResetableSetRange
;
500 USHORT nL
= pUShorts
[1] - pUShorts
[0] + 1;
501 USHORT nE
= pUShorts
[0];
502 for (USHORT i
= 0; i
< nL
; ++i
)
503 aAttribs
.Insert( nE
++ );
507 rWrtSh
.ResetAttr( &aAttribs
);
511 case FN_INSERT_BREAK_DLG
:
513 USHORT nKind
=0, nPageNumber
=0;
514 String aTemplateName
;
517 nKind
= ((SfxInt16Item
*)pItem
)->GetValue();
518 SFX_REQUEST_ARG( rReq
, pTemplate
, SfxStringItem
, FN_PARAM_1
, sal_False
);
519 SFX_REQUEST_ARG( rReq
, pNumber
, SfxUInt16Item
, FN_PARAM_2
, sal_False
);
521 aTemplateName
= pTemplate
->GetValue();
523 nPageNumber
= pNumber
->GetValue();
527 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
528 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
530 AbstractSwBreakDlg
* pDlg
= pFact
->CreateSwBreakDlg( GetView().GetWindow(), rWrtSh
, DLG_BREAK
);
531 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
532 if ( pDlg
->Execute() == RET_OK
)
534 nKind
= pDlg
->GetKind();
535 aTemplateName
= pDlg
->GetTemplateName();
536 nPageNumber
= pDlg
->GetPageNumber();
537 rReq
.AppendItem( SfxInt16Item( FN_INSERT_BREAK_DLG
, nKind
) );
538 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_2
, nPageNumber
) );
539 rReq
.AppendItem( SfxStringItem( FN_PARAM_1
, aTemplateName
) );
550 rWrtSh
.InsertLineBreak(); break;
552 rWrtSh
.InsertColumnBreak(); break;
555 rWrtSh
.StartAllAction();
556 if( aTemplateName
.Len() )
557 rWrtSh
.InsertPageBreak( &aTemplateName
, nPageNumber
);
559 rWrtSh
.InsertPageBreak();
560 rWrtSh
.EndAllAction();
566 case FN_INSERT_BOOKMARK
:
570 ::rtl::OUString sName
= ((SfxStringItem
*)pItem
)->GetValue();
571 rWrtSh
.SetBookmark( KeyCode(), sName
, aEmptyStr
);
575 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
576 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
578 VclAbstractDialog
* pDlg
= pFact
->CreateSwInsertBookmarkDlg( GetView().GetWindow(), rWrtSh
, rReq
, DLG_INSERT_BOOKMARK
);
579 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
586 case FN_DELETE_BOOKMARK
:
590 IDocumentMarkAccess
* const pMarkAccess
= rWrtSh
.getIDocumentMarkAccess();
591 pMarkAccess
->deleteMark( pMarkAccess
->findMark(((SfxStringItem
*)pItem
)->GetValue()) );
595 case FN_AUTOFORMAT_REDLINE_APPLY
:
597 SvxSwAutoFmtFlags
aFlags(SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags());
598 // das muss fuer die Nachbearbeitung immer FALSE sein
599 aFlags
.bAFmtByInput
= FALSE
;
600 aFlags
.bWithRedlining
= TRUE
;
601 rWrtSh
.AutoFormat( &aFlags
);
602 aFlags
.bWithRedlining
= FALSE
;
604 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
605 if (pVFrame
->HasChildWindow(FN_REDLINE_ACCEPT
))
606 pVFrame
->ToggleChildWindow(FN_REDLINE_ACCEPT
);
608 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
609 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
611 AbstractSwModalRedlineAcceptDlg
* pDlg
= pFact
->CreateSwModalRedlineAcceptDlg( &GetView().GetEditWin(), DLG_MOD_REDLINE_ACCEPT
);
612 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
614 switch (lcl_AskRedlineMode(&GetView().GetEditWin()))
618 pDlg
->AcceptAll(TRUE
);
619 SfxRequest
aReq( pVFrame
, FN_AUTOFORMAT_APPLY
);
626 pDlg
->AcceptAll(FALSE
);
639 case FN_AUTOFORMAT_APPLY
:
641 SvxSwAutoFmtFlags
aFlags(SvxAutoCorrCfg::Get()->GetAutoCorrect()->GetSwFlags());
642 // das muss fuer die Nachbearbeitung immer FALSE sein
643 aFlags
.bAFmtByInput
= FALSE
;
644 rWrtSh
.AutoFormat( &aFlags
);
648 case FN_AUTOFORMAT_AUTO
:
650 SvxAutoCorrCfg
* pACfg
= SvxAutoCorrCfg::Get();
651 BOOL bSet
= pItem
? ((const SfxBoolItem
*)pItem
)->GetValue() : !pACfg
->IsAutoFmtByInput();
652 if( bSet
!= pACfg
->IsAutoFmtByInput() )
654 pACfg
->SetAutoFmtByInput( bSet
);
655 GetView().GetViewFrame()->GetBindings().Invalidate( nSlot
);
657 rReq
.AppendItem( SfxBoolItem( GetPool().GetWhich(nSlot
), bSet
) );
662 case FN_AUTO_CORRECT
:
664 // erstmal auf Blank defaulten
665 sal_Unicode cChar
= ' ';
666 rWrtSh
.AutoCorrect( *SvxAutoCorrCfg::Get()->GetAutoCorrect(), cChar
);
670 case FN_TABLE_SORT_DIALOG
:
673 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
674 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
676 VclAbstractDialog
* pDlg
= pFact
->CreateVclAbstractDialog( GetView().GetWindow(), rWrtSh
, DLG_SORTING
);
677 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
683 case FN_NUMBERING_OUTLINE_DLG
:
685 SfxItemSet
aTmp(GetPool(), FN_PARAM_1
, FN_PARAM_1
);
686 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
687 DBG_ASSERT(pFact
, "Dialogdiet fail!");
688 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTabDialog( DLG_TAB_OUTLINE
,
689 GetView().GetWindow(), &aTmp
, rWrtSh
);
690 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
698 SwTransferable
* pTransfer
= new SwTransferable( rWrtSh
);
699 /*??*/ uno::Reference
<
700 datatransfer::XTransferable
> xRef(
702 pTransfer
->CalculateAndCopy();
706 case FN_GOTO_REFERENCE
:
708 SwField
*pFld
= rWrtSh
.GetCurFld();
709 if(pFld
&& pFld
->GetTypeId() == TYP_GETREFFLD
)
711 rWrtSh
.StartAllAction();
712 rWrtSh
.SwCrsrShell::GotoRefMark( ((SwGetRefField
*)pFld
)->GetSetRefName(),
713 ((SwGetRefField
*)pFld
)->GetSubType(),
714 ((SwGetRefField
*)pFld
)->GetSeqNo() );
715 rWrtSh
.EndAllAction();
720 case FN_EDIT_FORMULA
:
722 const USHORT nId
= SwInputChild::GetChildWindowId();
723 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
726 //if the ChildWindow is active it has to be removed
727 if( pVFrame
->HasChildWindow( nId
) )
729 pVFrame
->ToggleChildWindow( nId
);
730 pVFrame
->GetBindings().InvalidateAll( TRUE
);
733 String
sFormula(((const SfxStringItem
*)pItem
)->GetValue());
735 rWrtSh
.StartAllAction();
737 if( 0 != (bDelSel
= rWrtSh
.HasSelection()) )
739 rWrtSh
.StartUndo( UNDO_START
);
744 rWrtSh
.EnterStdMode();
747 if( !bDelSel
&& aFldMgr
.GetCurFld() && TYP_FORMELFLD
== aFldMgr
.GetCurTypeId() )
748 aFldMgr
.UpdateCurFld( aFldMgr
.GetCurFld()->GetFormat(), aEmptyStr
, sFormula
);
749 else if( sFormula
.Len() )
751 if( rWrtSh
.IsCrsrInTbl() )
753 SfxItemSet
aSet( rWrtSh
.GetAttrPool(), RES_BOXATR_FORMULA
, RES_BOXATR_FORMULA
);
754 aSet
.Put( SwTblBoxFormula( sFormula
));
755 rWrtSh
.SetTblBoxFormulaAttrs( aSet
);
756 rWrtSh
.UpdateTable();
760 SvNumberFormatter
* pFormatter
= rWrtSh
.GetNumberFormatter();
761 ULONG nSysNumFmt
= pFormatter
->GetFormatIndex( NF_NUMBER_STANDARD
, LANGUAGE_SYSTEM
);
762 SwInsertFld_Data
aData(TYP_FORMELFLD
, nsSwGetSetExpType::GSE_FORMULA
, aEmptyStr
, sFormula
, nSysNumFmt
);
763 aFldMgr
.InsertFld(aData
);
768 rWrtSh
.EndUndo( UNDO_END
);
769 rWrtSh
.EndAllAction();
774 rWrtSh
.EndAllTblBoxEdit();
775 pVFrame
->ToggleChildWindow( nId
);
776 if( !pVFrame
->HasChildWindow( nId
) )
777 pVFrame
->GetBindings().InvalidateAll( TRUE
);
783 case FN_TABLE_UNSET_READ_ONLY
:
785 rWrtSh
.UnProtectTbls();
788 case FN_EDIT_HYPERLINK
:
789 GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG
);
791 case FN_REMOVE_HYPERLINK
:
793 BOOL bSel
= rWrtSh
.HasSelection();
796 rWrtSh
.StartAction();
798 if(!rWrtSh
.SelectTxtAttr( RES_TXTATR_INETFMT
))
801 //now remove the attribute
802 SvUShortsSort aAttribs
;
803 aAttribs
.Insert( RES_TXTATR_INETFMT
);
804 rWrtSh
.ResetAttr( &aAttribs
);
812 case SID_ATTR_BRUSH_CHAR
:
813 case SID_ATTR_CHAR_SCALEWIDTH
:
814 case SID_ATTR_CHAR_ROTATED
:
815 case FN_TXTATR_INET
:
816 case FN_INSERT_HYPERLINK
:
818 USHORT nWhich
= GetPool().GetWhich( nSlot
);
819 if ( pArgs
&& pArgs
->GetItemState( nWhich
) == SFX_ITEM_SET
)
821 // intentionally no break
825 lcl_CharDialog( rWrtSh
, bUseDialog
, nSlot
, pArgs
, &rReq
);
828 case SID_CHAR_DLG_FOR_PARAGRAPH
:
830 rWrtSh
.Push(); //save current cursor
831 SwLangHelper::SelectCurrentPara( rWrtSh
);
832 lcl_CharDialog( rWrtSh
, bUseDialog
, nSlot
, pArgs
, &rReq
);
833 rWrtSh
.Pop( FALSE
); //restore old cursor
836 case SID_ATTR_LRSPACE
:
837 case SID_ATTR_ULSPACE
:
838 case SID_ATTR_BRUSH
:
839 case SID_PARA_VERTALIGN
:
840 case SID_ATTR_PARA_NUMRULE
:
841 case SID_ATTR_PARA_REGISTER
:
842 case SID_ATTR_PARA_PAGENUM
:
843 case FN_FORMAT_LINENUMBER
:
844 case FN_NUMBER_NEWSTART
:
845 case FN_NUMBER_NEWSTART_AT
:
846 case FN_FORMAT_DROPCAPS
:
849 USHORT nWhich
= GetPool().GetWhich( nSlot
);
850 if ( pArgs
&& pArgs
->GetItemState( nWhich
) == SFX_ITEM_SET
)
852 // intentionally no break
857 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, &GetView()));
858 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< UINT16
>(eMetric
)));
860 BOOL bApplyCharUnit
= ::HasCharUnit(0 != PTR_CAST(SwWebView
, &GetView()));
861 SW_MOD()->PutItem(SfxBoolItem(SID_ATTR_APPLYCHARUNIT
, bApplyCharUnit
));
863 SfxItemSet
aCoreSet( GetPool(),
864 RES_PARATR_BEGIN
, RES_PARATR_END
- 1,
865 // --> OD 2008-02-25 #refactorlists#
866 RES_PARATR_LIST_BEGIN
, RES_PARATR_LIST_END
- 1,
868 RES_FRMATR_BEGIN
, RES_FRMATR_END
- 1,
869 SID_ATTR_TABSTOP_POS
, SID_ATTR_TABSTOP_POS
,
870 SID_ATTR_TABSTOP_DEFAULTS
, SID_ATTR_TABSTOP_DEFAULTS
,
871 SID_ATTR_TABSTOP_OFFSET
, SID_ATTR_TABSTOP_OFFSET
,
872 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
,
873 SID_ATTR_PARA_MODEL
, SID_ATTR_PARA_KEEP
,
874 SID_ATTR_PARA_PAGENUM
, SID_ATTR_PARA_PAGENUM
,
875 SID_HTML_MODE
, SID_HTML_MODE
,
876 FN_PARAM_1
, FN_PARAM_1
,
877 FN_NUMBER_NEWSTART
, FN_NUMBER_NEWSTART_AT
,
878 FN_DROP_TEXT
, FN_DROP_CHAR_STYLE_NAME
,
880 // --> OD 2008-01-16 #newlistlevelattrs#
881 // get also the list level indent values merged as LR-SPACE item, if needed.
882 rWrtSh
.GetCurAttr( aCoreSet
, true );
884 aCoreSet
.Put(SfxUInt16Item(SID_HTML_MODE
,
885 ::GetHtmlMode(GetView().GetDocShell())));
887 // Tabulatoren, DefaultTabs ins ItemSet Stecken
888 const SvxTabStopItem
& rDefTabs
= (const SvxTabStopItem
&)
889 GetPool().GetDefaultItem(RES_PARATR_TABSTOP
);
891 USHORT nDefDist
= ::GetTabDist( rDefTabs
);
892 SfxUInt16Item
aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS
, nDefDist
);
893 aCoreSet
.Put( aDefDistItem
);
896 SfxUInt16Item
aTabPos( SID_ATTR_TABSTOP_POS
, 0 );
897 aCoreSet
.Put( aTabPos
);
899 // linker Rand als Offset
900 //#i24363# tab stops relative to indent
901 const long nOff
= rWrtSh
.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT
) ?
902 ((SvxLRSpaceItem
&)aCoreSet
.Get( RES_LR_SPACE
)).GetTxtLeft() : 0;
903 SfxInt32Item
aOff( SID_ATTR_TABSTOP_OFFSET
, nOff
);
904 aCoreSet
.Put( aOff
);
907 ::PrepareBoxInfo( aCoreSet
, rWrtSh
);
909 //aktuelles Seitenformat
910 ::SwToSfxPageDescAttr( aCoreSet
);
914 nDefPage
= ((SfxUInt16Item
*)pItem
)->GetValue();
916 // Numerierungseigenschaften
917 if(rWrtSh
.GetCurNumRule())
919 SfxBoolItem
aStart( FN_NUMBER_NEWSTART
, rWrtSh
.IsNumRuleStart() );
920 aCoreSet
.Put(aStart
);
921 // --> OD 2008-02-29 #refactorlists#
922 // SfxUInt16Item aStartAt(FN_NUMBER_NEWSTART_AT,
923 // rWrtSh.IsNodeNumStart());
924 SfxUInt16Item
aStartAt( FN_NUMBER_NEWSTART_AT
,
925 rWrtSh
.GetNodeNumStart() );
927 aCoreSet
.Put(aStartAt
);
929 SfxAbstractTabDialog
* pDlg
= NULL
;
931 if ( bUseDialog
&& GetActiveView() )
933 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
934 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
936 pDlg
= pFact
->CreateSwParaDlg( GetView().GetWindow(),GetView(), aCoreSet
,DLG_STD
, DLG_PARA
,NULL
, FALSE
, nDefPage
);
937 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
939 SfxItemSet
* pSet
= NULL
;
942 pSet
= (SfxItemSet
*) pArgs
;
945 else if ( NULL
!= pDlg
&& pDlg
->Execute() == RET_OK
)
947 // Defaults evtl umsetzen
948 pSet
= (SfxItemSet
*)pDlg
->GetOutputItemSet();
950 if( SFX_ITEM_SET
== pSet
->GetItemState( SID_ATTR_TABSTOP_DEFAULTS
, FALSE
, &pItem
) &&
951 nDefDist
!= (nNewDist
= ((SfxUInt16Item
*)pItem
)->GetValue()) )
953 SvxTabStopItem
aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT
, RES_PARATR_TABSTOP
);
954 MakeDefTabs( nNewDist
, aDefTabs
);
955 rWrtSh
.SetDefault( aDefTabs
);
956 pSet
->ClearItem( SID_ATTR_TABSTOP_DEFAULTS
);
959 if ( SFX_ITEM_SET
== pSet
->GetItemState(FN_PARAM_1
,FALSE
,&pItem
) )
961 pSet
->Put(SfxStringItem(FN_DROP_TEXT
, ((const SfxStringItem
*)pItem
)->GetValue()));
962 pSet
->ClearItem(FN_PARAM_1
);
965 if( SFX_ITEM_SET
== pSet
->GetItemState( RES_PARATR_DROP
, FALSE
, &pItem
))
967 String sCharStyleName
;
968 if(((const SwFmtDrop
*)pItem
)->GetCharFmt())
969 sCharStyleName
= ((const SwFmtDrop
*)pItem
)->GetCharFmt()->GetName();
970 pSet
->Put(SfxStringItem(FN_DROP_CHAR_STYLE_NAME
, sCharStyleName
));
977 ::SfxToSwPageDescAttr( rWrtSh
, *pSet
);
978 // --> OD 2006-12-06 #i56253#
979 // enclose all undos.
980 // Thus, check conditions, if actions will be performed.
981 const bool bUndoNeeded( pSet
->Count() ||
982 SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART
) ||
983 SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART_AT
) );
986 rWrtSh
.StartUndo( UNDO_INSATTR
);
991 rWrtSh
.StartAction();
992 // rWrtSh.StartUndo( UNDO_START );
993 if ( SFX_ITEM_SET
== pSet
->GetItemState(FN_DROP_TEXT
, FALSE
, &pItem
) )
995 if ( ((SfxStringItem
*)pItem
)->GetValue().Len() )
996 rWrtSh
.ReplaceDropTxt(((SfxStringItem
*)pItem
)->GetValue());
998 rWrtSh
.SetAttr( *pSet
);
999 // rWrtSh.EndUndo( UNDO_END );
1001 SwTxtFmtColl
* pColl
= rWrtSh
.GetCurTxtFmtColl();
1002 if(pColl
&& pColl
->IsAutoUpdateFmt())
1004 rWrtSh
.AutoUpdatePara(pColl
, *pSet
);
1008 if( SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART
) )
1010 //SetNumRuleStart(TRUE) restarts the numbering at the value
1011 //that is defined at the starting point of the numbering level
1012 //otherwise the SetNodeNumStart() value determines the start
1013 //if it's set to something different than USHRT_MAX
1015 BOOL bStart
= ((SfxBoolItem
&)pSet
->Get(FN_NUMBER_NEWSTART
)).GetValue();
1016 // --> OD 2007-06-11 #b6560525#
1017 // Default value for restart value has to be USHRT_MAX
1018 // in order to indicate that the restart value of the list
1019 // style has to be used on restart.
1020 USHORT nNumStart
= USHRT_MAX
;
1022 if( SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART_AT
) )
1024 nNumStart
= ((SfxUInt16Item
&)pSet
->Get(FN_NUMBER_NEWSTART_AT
)).GetValue();
1026 rWrtSh
.SetNumRuleStart(bStart
);
1027 rWrtSh
.SetNodeNumStart(nNumStart
);
1029 else if( SFX_ITEM_SET
== pSet
->GetItemState(FN_NUMBER_NEWSTART_AT
) )
1031 USHORT nNumStart
= ((SfxUInt16Item
&)pSet
->Get(FN_NUMBER_NEWSTART_AT
)).GetValue();
1032 rWrtSh
.SetNodeNumStart(nNumStart
);
1033 rWrtSh
.SetNumRuleStart(FALSE
);
1035 // --> OD 2006-12-06 #i56253#
1038 rWrtSh
.EndUndo( UNDO_INSATTR
);
1046 case FN_NUM_CONTINUE
:
1048 // --> OD 2008-03-18 #refactorlists#
1049 String sContinuedListId
;
1050 const SwNumRule
* pRule
=
1051 rWrtSh
.SearchNumRule( false, true, false, -1, sContinuedListId
);
1052 // --> OD 2009-08-26 #i86492#
1053 // Search also for bullet list
1056 pRule
= rWrtSh
.SearchNumRule( false, false, false, -1, sContinuedListId
);
1061 rWrtSh
.SetCurNumRule( *pRule
, false, sContinuedListId
);
1066 case FN_SELECT_PARA
:
1068 if(!rWrtSh
.IsSttOfPara())
1069 rWrtSh
.SttPara(FALSE
);
1071 rWrtSh
.EnterStdMode();
1072 rWrtSh
.EndPara(TRUE
);
1076 case SID_DEC_INDENT
:
1077 case SID_INC_INDENT
:
1078 rWrtSh
.MoveLeftMargin( SID_INC_INDENT
== nSlot
,
1079 rReq
.GetModifier() != KEY_MOD1
);
1082 case FN_DEC_INDENT_OFFSET
:
1083 case FN_INC_INDENT_OFFSET
:
1084 rWrtSh
.MoveLeftMargin( FN_INC_INDENT_OFFSET
== nSlot
,
1085 rReq
.GetModifier() == KEY_MOD1
);
1089 case SID_ATTR_CHAR_COLOR2
:
1093 Color aSet
= ((const SvxColorItem
*)pItem
)->GetValue();
1094 SwEditWin
& rEditWin
= GetView().GetEditWin();
1095 rEditWin
.SetTextColor(aSet
);
1096 SwApplyTemplate
* pApply
= rEditWin
.GetApplyTemplate();
1097 SvxColorItem
aItem(aSet
, RES_CHRATR_COLOR
);
1099 // besteht eine Selektion, wird sie gleich gefaerbt
1100 if(!pApply
&& rWrtSh
.HasSelection())
1102 rWrtSh
.SetAttr(SvxColorItem (aSet
, RES_CHRATR_COLOR
));
1104 else if(!pApply
|| pApply
->nColor
!= SID_ATTR_CHAR_COLOR_EXT
)
1106 GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_EXT
);
1110 /* OS 22.02.97 18:40 Das alte Verhalten ist unerwuenscht
1111 SwEditWin& rEdtWin = GetView().GetEditWin();
1113 SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
1114 SvxColorItem aItem(aSet, RES_CHRATR_COLOR);
1116 if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_EXT)
1118 GetShell().SetAttr(aItem);
1124 case SID_ATTR_CHAR_COLOR_BACKGROUND
:
1126 SwEditWin
& rEdtWin
= GetView().GetEditWin();
1127 SwApplyTemplate
* pApply
= rEdtWin
.GetApplyTemplate();
1128 rEdtWin
.SetTextBackColorTransparent(0 == pItem
);
1132 aSet
= ((const SvxColorItem
*)pItem
)->GetValue();
1133 rEdtWin
.SetTextBackColor(aSet
);
1135 if(!pApply
&& (rWrtSh
.HasSelection() || rReq
.IsAPI()))
1137 SvxBrushItem
aBrushItem(RES_CHRATR_BACKGROUND
);
1139 aBrushItem
.SetColor(aSet
);
1141 aBrushItem
.SetColor(Color(COL_TRANSPARENT
));
1142 rWrtSh
.SetAttr( aBrushItem
);
1144 else if(!pApply
|| pApply
->nColor
!= SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
)
1146 GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
);
1151 /* OS 22.02.97 18:40 Das alte Verhalten ist unerwuenscht
1152 if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
1154 Brush aBrush(pItem ? BRUSH_SOLID : BRUSH_NULL);
1156 aBrush.SetColor( aSet );
1157 GetShell().SetAttr( SvxBrushItem(aBrush, RES_CHRATR_BACKGROUND) );
1162 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
:
1163 case SID_ATTR_CHAR_COLOR_EXT
:
1165 SwEditWin
& rEdtWin
= GetView().GetEditWin();
1166 SwApplyTemplate
* pApply
= rEdtWin
.GetApplyTemplate();
1167 SwApplyTemplate aTempl
;
1168 BOOL bSelection
= rWrtSh
.HasSelection();
1172 if(nSlot
== SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
)
1174 rWrtSh
.SetAttr( SvxBrushItem(
1175 rEdtWin
.GetTextBackColor(), RES_CHRATR_BACKGROUND
) );
1178 rWrtSh
.SetAttr( SvxColorItem( rEdtWin
.GetTextColor(),
1179 RES_CHRATR_COLOR
) );
1183 if(!pApply
|| pApply
->nColor
!= nSlot
)
1184 aTempl
.nColor
= nSlot
;
1185 rEdtWin
.SetApplyTemplate(aTempl
);
1192 case FN_NUM_BULLET_MOVEDOWN
:
1193 if (!rWrtSh
.IsAddMode())
1194 rWrtSh
.MoveParagraph(1);
1198 case FN_NUM_BULLET_MOVEUP
:
1199 if (!rWrtSh
.IsAddMode())
1200 rWrtSh
.MoveParagraph(-1);
1203 case SID_RUBY_DIALOG
:
1204 case SID_HYPERLINK_DIALOG
:
1206 SfxRequest
aReq(nSlot
, SFX_CALLMODE_SLOT
, SFX_APP()->GetPool());
1207 GetView().GetViewFrame()->ExecuteSlot( aReq
);
1211 case FN_INSERT_PAGEHEADER
:
1212 case FN_INSERT_PAGEFOOTER
:
1213 if(pArgs
&& pArgs
->Count())
1217 sStyleName
= ((const SfxStringItem
*)pItem
)->GetValue();
1219 if( SFX_ITEM_SET
== pArgs
->GetItemState(FN_PARAM_1
, FALSE
, &pItem
))
1220 bOn
= ((const SfxBoolItem
*)pItem
)->GetValue();
1221 ChangeHeaderOrFooter(sStyleName
, FN_INSERT_PAGEHEADER
== nSlot
, bOn
, !rReq
.IsAPI());
1225 case FN_READONLY_SELECTION_MODE
:
1226 if(GetView().GetDocShell()->IsReadOnly())
1228 rWrtSh
.SetReadonlySelectionOption(
1229 !rWrtSh
.GetViewOptions()->IsSelectionInReadonly());
1233 case FN_SELECTION_MODE_DEFAULT
:
1234 case FN_SELECTION_MODE_BLOCK
:
1236 bool bSetBlockMode
= !rWrtSh
.IsBlockMode();
1237 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(nSlot
, FALSE
, &pItem
))
1238 bSetBlockMode
= ((const SfxBoolItem
*)pItem
)->GetValue();
1239 if( ( nSlot
== FN_SELECTION_MODE_DEFAULT
) ^ bSetBlockMode
)
1240 rWrtSh
.EnterBlockMode();
1242 rWrtSh
.EnterStdMode();
1243 SfxBindings
&rBnd
= GetView().GetViewFrame()->GetBindings();
1244 rBnd
.Invalidate(FN_STAT_SELMODE
);
1245 rBnd
.Update(FN_STAT_SELMODE
);
1248 case SID_OPEN_HYPERLINK
:
1249 case FN_COPY_HYPERLINK_LOCATION
:
1251 SfxItemSet
aSet(GetPool(),
1253 RES_TXTATR_INETFMT
);
1254 rWrtSh
.GetCurAttr(aSet
);
1255 if(SFX_ITEM_SET
<= aSet
.GetItemState( RES_TXTATR_INETFMT
, TRUE
))
1257 const SwFmtINetFmt
& rINetFmt
= dynamic_cast<const SwFmtINetFmt
&>( aSet
.Get(RES_TXTATR_INETFMT
, TRUE
) );
1258 if( nSlot
== FN_COPY_HYPERLINK_LOCATION
)
1260 ::uno::Reference
< datatransfer::clipboard::XClipboard
> xClipboard
= GetView().GetEditWin().GetClipboard();
1261 vcl::unohelper::TextDataObject::CopyStringTo(
1262 rINetFmt
.GetValue(),
1266 rWrtSh
.ClickToINetAttr(rINetFmt
, URLLOAD_NOFILTER
);
1270 case SID_OPEN_XML_FILTERSETTINGS
:
1274 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY
);
1280 catch( uno::Exception
& )
1286 case FN_FORMAT_APPLY_HEAD1
:
1290 case FN_FORMAT_APPLY_HEAD2
:
1294 case FN_FORMAT_APPLY_HEAD3
:
1298 case FN_FORMAT_APPLY_DEFAULT
:
1302 case FN_FORMAT_APPLY_TEXTBODY
:
1306 case FN_WORDCOUNT_DIALOG
:
1308 SwWrtShell
&rSh
= GetShell();
1310 SwDocStat
aDocStat( rSh
.getIDocumentStatistics()->GetDocStat() );
1312 SwWait
aWait( *GetView().GetDocShell(), TRUE
);
1314 rSh
.CountWords( aCurr
);
1315 rSh
.UpdateDocStat( aDocStat
);
1319 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
1320 DBG_ASSERT(pFact
, "Dialogdiet fail!");
1321 AbstractSwWordCountDialog
* pDialog
= pFact
->CreateSwWordCountDialog( GetView().GetWindow() );
1322 pDialog
->SetValues(aCurr
, aDocStat
);
1328 ASSERT(!this, falscher Dispatcher
);
1334 /*--------------------------------------------------------------------
1336 --------------------------------------------------------------------*/
1339 void SwTextShell::GetState( SfxItemSet
&rSet
)
1341 SwWrtShell
&rSh
= GetShell();
1342 SfxWhichIter
aIter( rSet
);
1343 USHORT nWhich
= aIter
.FirstWhich();
1348 case SID_LANGUAGE_STATUS
:
1350 // the value of used script types
1351 String
aScriptTypesInUse( String::CreateFromInt32( rSh
.GetScriptType() ) );
1353 SvtLanguageTable aLangTable
;
1355 // get keyboard language
1356 String aKeyboardLang
;
1357 LanguageType nLang
= LANGUAGE_DONTKNOW
;
1358 SwEditWin
& rEditWin
= GetView().GetEditWin();
1359 nLang
= rEditWin
.GetInputLanguage();
1360 if (nLang
!= LANGUAGE_DONTKNOW
&& nLang
!= LANGUAGE_SYSTEM
)
1361 aKeyboardLang
= aLangTable
.GetString( nLang
);
1363 // get the language that is in use
1364 const String aMultipleLanguages
= String::CreateFromAscii("*");
1365 String aCurrentLang
= aMultipleLanguages
;
1366 nLang
= SwLangHelper::GetCurrentLanguage( rSh
);
1367 if (nLang
!= LANGUAGE_DONTKNOW
)
1368 aCurrentLang
= aLangTable
.GetString( nLang
);
1370 // build sequence for status value
1371 uno::Sequence
< ::rtl::OUString
> aSeq( 4 );
1372 aSeq
[0] = aCurrentLang
;
1373 aSeq
[1] = aScriptTypesInUse
;
1374 aSeq
[2] = aKeyboardLang
;
1375 aSeq
[3] = SwLangHelper::GetTextForLanguageGuessing( rSh
);
1377 // set sequence as status value
1378 SfxStringListItem
aItem( SID_LANGUAGE_STATUS
);
1379 aItem
.SetStringList( aSeq
);
1380 rSet
.Put( aItem
, SID_LANGUAGE_STATUS
);
1384 case FN_NUMBER_NEWSTART
:
1385 if(!rSh
.GetCurNumRule())
1386 rSet
.DisableItem(nWhich
);
1388 rSet
.Put(SfxBoolItem(FN_NUMBER_NEWSTART
,
1389 rSh
.IsNumRuleStart()));
1391 case FN_EDIT_FORMULA
:
1394 const int nType
= rSh
.GetSelectionType();
1395 if (!(nType
& nsSelectionType::SEL_TXT
) &&
1396 !(nType
& nsSelectionType::SEL_TBL
) &&
1397 !(nType
& nsSelectionType::SEL_NUM
))
1398 rSet
.DisableItem(nWhich
);
1402 case FN_INSERT_ENDNOTE
:
1403 case FN_INSERT_FOOTNOTE
:
1404 case FN_INSERT_FOOTNOTE_DLG
:
1406 const USHORT nNoType
= FRMTYPE_FLY_ANY
| FRMTYPE_HEADER
|
1407 FRMTYPE_FOOTER
| FRMTYPE_FOOTNOTE
;
1408 if ( (rSh
.GetFrmType(0,TRUE
) & nNoType
) )
1409 rSet
.DisableItem(nWhich
);
1412 case FN_INSERT_TABLE
:
1413 if ( rSh
.GetTableFmt() ||
1414 (rSh
.GetFrmType(0,TRUE
) & FRMTYPE_FOOTNOTE
) )
1415 rSet
.DisableItem( nWhich
);
1419 if ( !rSh
.IsSelection() )
1420 rSet
.DisableItem(nWhich
);
1422 case FN_GOTO_REFERENCE
:
1424 SwField
*pFld
= rSh
.GetCurFld();
1425 if ( !pFld
|| (pFld
&& pFld
->GetTypeId() != TYP_GETREFFLD
) )
1426 rSet
.DisableItem(nWhich
);
1429 case FN_AUTOFORMAT_AUTO
:
1431 rSet
.Put( SfxBoolItem( nWhich
, SvxAutoCorrCfg::Get()->IsAutoFmtByInput() ));
1434 case FN_GLOSSARY_DLG
:
1436 rSet
.Put(SfxBoolItem(nWhich
), TRUE
);
1440 case SID_DEC_INDENT
:
1441 case SID_INC_INDENT
:
1443 USHORT nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
1444 nHtmlMode
&= HTMLMODE_ON
|HTMLMODE_SOME_STYLES
;
1445 if( (nHtmlMode
== HTMLMODE_ON
) || !rSh
.IsMoveLeftMargin(
1446 SID_INC_INDENT
== nWhich
, TRUE
))
1447 rSet
.DisableItem( nWhich
);
1451 case FN_DEC_INDENT_OFFSET
:
1452 case FN_INC_INDENT_OFFSET
:
1454 USHORT nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
1455 nHtmlMode
&= HTMLMODE_ON
|HTMLMODE_SOME_STYLES
;
1456 if( (nHtmlMode
== HTMLMODE_ON
) ||
1457 !rSh
.IsMoveLeftMargin( FN_INC_INDENT_OFFSET
== nWhich
,
1459 rSet
.DisableItem( nWhich
);
1463 case SID_ATTR_CHAR_COLOR2
:
1465 rSet
.Put(SvxColorItem(GetView().GetEditWin().GetTextColor(), SID_ATTR_CHAR_COLOR2
));
1468 case SID_ATTR_CHAR_COLOR_BACKGROUND
:
1470 if(GetView().GetEditWin().IsTextBackColorTransparent())
1471 rSet
.Put(SvxColorItem(Color(COL_TRANSPARENT
), SID_ATTR_CHAR_COLOR_BACKGROUND
));
1473 rSet
.Put(SvxColorItem(GetView().GetEditWin().GetTextBackColor(), SID_ATTR_CHAR_COLOR_BACKGROUND
));
1476 case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
:
1477 case SID_ATTR_CHAR_COLOR_EXT
:
1479 SwEditWin
& rEdtWin
= GetView().GetEditWin();
1480 SwApplyTemplate
* pApply
= rEdtWin
.GetApplyTemplate();
1481 rSet
.Put(SfxBoolItem(nWhich
, pApply
&& pApply
->nColor
== nWhich
));
1484 case FN_INSERT_BOOKMARK
:
1485 if( rSh
.IsTableMode() )
1486 rSet
.DisableItem( nWhich
);
1489 case FN_INSERT_PAGEHEADER
:
1490 case FN_INSERT_PAGEFOOTER
:
1493 rSet
.Put( SfxObjectShellItem( nWhich
, GetView().GetDocShell() ));
1495 // Seitenvorlagen besorgen
1496 BOOL bFound
= FALSE
;
1497 USHORT n
, nCnt
= rSh
.GetPageDescCnt();
1498 for( n
= 0; n
< nCnt
; ++n
)
1500 const SwPageDesc
& rDesc
= rSh
.GetPageDesc( n
);
1501 if( FN_INSERT_PAGEHEADER
== nWhich
1502 ? !rDesc
.GetMaster().GetHeader().IsActive()
1503 : !rDesc
.GetMaster().GetFooter().IsActive() )
1511 rSet
.Put( SfxObjectShellItem( nWhich
, GetView().GetDocShell() ));
1513 rSet
.DisableItem( nWhich
);
1517 case FN_TABLE_SORT_DIALOG
:
1518 case FN_SORTING_DLG
:
1519 if(!rSh
.HasSelection() ||
1520 (FN_TABLE_SORT_DIALOG
== nWhich
&& !rSh
.GetTableFmt()))
1521 rSet
.DisableItem( nWhich
);
1523 case SID_RUBY_DIALOG
:
1525 SvtCJKOptions aCJKOptions
;
1526 if(!aCJKOptions
.IsRubyEnabled())
1528 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
1529 rSet
.DisableItem(nWhich
);
1532 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
1536 case SID_HYPERLINK_DIALOG
:
1537 if( GetView().GetDocShell()->IsReadOnly() ||
1538 (!GetView().GetViewFrame()->HasChildWindow(nWhich
) &&
1539 rSh
.HasReadonlySel()) )
1540 rSet
.DisableItem(nWhich
);
1542 rSet
.Put(SfxBoolItem( nWhich
, 0 != GetView().
1543 GetViewFrame()->GetChildWindow( nWhich
) ));
1545 case FN_EDIT_HYPERLINK
:
1546 case FN_REMOVE_HYPERLINK
:
1547 case FN_COPY_HYPERLINK_LOCATION
:
1549 SfxItemSet
aSet(GetPool(),
1551 RES_TXTATR_INETFMT
);
1552 rSh
.GetCurAttr(aSet
);
1553 if(SFX_ITEM_SET
> aSet
.GetItemState( RES_TXTATR_INETFMT
, TRUE
) || rSh
.HasReadonlySel())
1555 rSet
.DisableItem(nWhich
);
1559 case SID_TRANSLITERATE_HALFWIDTH
:
1560 case SID_TRANSLITERATE_FULLWIDTH
:
1561 case SID_TRANSLITERATE_HIRAGANA
:
1562 case SID_TRANSLITERATE_KATAGANA
:
1564 SvtCJKOptions aCJKOptions
;
1565 if(!aCJKOptions
.IsChangeCaseMapEnabled())
1567 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
1568 rSet
.DisableItem(nWhich
);
1571 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
1574 case FN_READONLY_SELECTION_MODE
:
1575 if(!GetView().GetDocShell()->IsReadOnly())
1576 rSet
.DisableItem( nWhich
);
1579 rSet
.Put(SfxBoolItem(nWhich
, rSh
.GetViewOptions()->IsSelectionInReadonly()));
1582 case FN_SELECTION_MODE_DEFAULT
:
1583 case FN_SELECTION_MODE_BLOCK
:
1584 rSet
.Put(SfxBoolItem(nWhich
, (nWhich
== FN_SELECTION_MODE_DEFAULT
) != rSh
.IsBlockMode()));
1586 case SID_OPEN_HYPERLINK
:
1588 SfxItemSet
aSet(GetPool(),
1590 RES_TXTATR_INETFMT
);
1591 rSh
.GetCurAttr(aSet
);
1592 if(SFX_ITEM_SET
> aSet
.GetItemState( RES_TXTATR_INETFMT
, FALSE
))
1593 rSet
.DisableItem(nWhich
);
1596 case SID_OPEN_SMARTTAGMENU
:
1598 uno::Sequence
< rtl::OUString
> aSmartTagTypes
;
1599 uno::Sequence
< uno::Reference
< container::XStringKeyMap
> > aStringKeyMaps
;
1600 uno::Reference
<text::XTextRange
> xRange
;
1602 rSh
.GetSmartTagTerm( aSmartTagTypes
, aStringKeyMaps
, xRange
);
1604 if ( xRange
.is() && aSmartTagTypes
.getLength() )
1606 uno::Sequence
< uno::Sequence
< uno::Reference
< smarttags::XSmartTagAction
> > > aActionComponentsSequence
;
1607 uno::Sequence
< uno::Sequence
< sal_Int32
> > aActionIndicesSequence
;
1609 const SmartTagMgr
& rSmartTagMgr
= SwSmartTagMgr::Get();
1610 rSmartTagMgr
.GetActionSequences( aSmartTagTypes
,
1611 aActionComponentsSequence
,
1612 aActionIndicesSequence
);
1614 uno::Reference
<frame::XController
> xController
= GetView().GetController();
1615 const lang::Locale
aLocale( SW_BREAKITER()->GetLocale( (LanguageType
)GetAppLanguage() ) );
1616 const rtl::OUString
aApplicationName( rSmartTagMgr
.GetApplicationName() );
1617 const rtl::OUString aRangeText
= xRange
->getString();
1619 const SvxSmartTagItem
aItem( nWhich
,
1620 aActionComponentsSequence
,
1621 aActionIndicesSequence
,
1632 rSet
.DisableItem(nWhich
);
1635 case FN_NUM_CONTINUE
:
1637 // --> OD 2009-08-26 #i86492#
1638 // Allow continuation of previous list, even if at current cursor
1639 // a list is active.
1640 // if ( rSh.GetCurNumRule() )
1641 // rSet.DisableItem(nWhich);
1645 // --> OD 2009-08-26 #i86492#
1646 // Search also for bullet list
1648 const SwNumRule
* pRule
=
1649 rSh
.SearchNumRule( false, true, false, -1, aDummy
);
1652 pRule
= rSh
.SearchNumRule( false, false, false, -1, aDummy
);
1656 rSet
.DisableItem(nWhich
);
1660 case SID_INSERT_RLM
:
1661 case SID_INSERT_LRM
:
1662 case SID_INSERT_ZWNBSP
:
1663 case SID_INSERT_ZWSP
:
1665 SvtCTLOptions aCTLOptions
;
1666 sal_Bool bEnabled
= aCTLOptions
.IsCTLFontEnabled();
1667 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich
, bEnabled
);
1669 rSet
.DisableItem(nWhich
);
1673 nWhich
= aIter
.NextWhich();
1676 /* -----------------------------2002/07/05 10:31------------------------------
1677 Switch on/off header of footer of a page style - if an empty name is
1678 given all styles are changed
1679 ---------------------------------------------------------------------------*/
1680 void SwTextShell::ChangeHeaderOrFooter(
1681 const String
& rStyleName
, BOOL bHeader
, BOOL bOn
, BOOL bShowWarning
)
1683 SwWrtShell
& rSh
= GetShell();
1684 rSh
.StartAllAction();
1685 rSh
.StartUndo( UNDO_HEADER_FOOTER
); // #i7983#
1686 BOOL bExecute
= TRUE
;
1687 BOOL bCrsrSet
= FALSE
;
1688 for( USHORT nFrom
= 0, nTo
= rSh
.GetPageDescCnt();
1689 nFrom
< nTo
; ++nFrom
)
1692 SwPageDesc
aDesc( rSh
.GetPageDesc( nFrom
));
1693 String
sTmp(aDesc
.GetName());
1694 if( !rStyleName
.Len() || rStyleName
== sTmp
)
1696 if( bShowWarning
&& !bOn
&& GetActiveView() && GetActiveView() == &GetView() &&
1697 (bHeader
&& aDesc
.GetMaster().GetHeader().IsActive() ||
1698 !bHeader
&& aDesc
.GetMaster().GetFooter().IsActive()))
1700 bShowWarning
= FALSE
;
1701 //Actions have to be closed while the dialog is showing
1704 Window
* pParent
= &GetView().GetViewFrame()->GetWindow();
1705 BOOL bRet
= RET_YES
== QueryBox( pParent
, ResId( RID_SVXQBX_DELETE_HEADFOOT
,
1706 DIALOG_MGR() ) ).Execute();
1708 rSh
.StartAllAction();
1713 SwFrmFmt
&rMaster
= aDesc
.GetMaster();
1715 rMaster
.SetFmtAttr( SwFmtHeader( bOn
));
1717 rMaster
.SetFmtAttr( SwFmtFooter( bOn
));
1720 SvxULSpaceItem
aUL(bHeader
? 0 : MM50
, bHeader
? MM50
: 0, RES_UL_SPACE
);
1721 SwFrmFmt
* pFmt
= bHeader
?
1722 (SwFrmFmt
*)rMaster
.GetHeader().GetHeaderFmt() :
1723 (SwFrmFmt
*)rMaster
.GetFooter().GetFooterFmt();
1724 pFmt
->SetFmtAttr( aUL
);
1729 rSh
.ChgPageDesc( nFrom
, aDesc
);
1731 if( !bCrsrSet
&& bOn
)
1732 bCrsrSet
= rSh
.SetCrsrInHdFt(
1733 !rStyleName
.Len() ? USHRT_MAX
: nFrom
,
1738 rSh
.EndUndo( UNDO_HEADER_FOOTER
); // #i7983#