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 <hintids.hxx>
23 #include <com/sun/star/i18n/TransliterationModules.hpp>
24 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
25 #include <com/sun/star/i18n/TextConversionOption.hpp>
26 #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
29 #include <tools/shl.hxx>
30 #include <i18nlangtag/mslangid.hxx>
31 #include <sfx2/objface.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include <sfx2/bindings.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/request.hxx>
36 #include <editeng/spltitem.hxx>
37 #include <editeng/lrspitem.hxx>
38 #include <editeng/ulspitem.hxx>
39 #include <editeng/orphitem.hxx>
40 #include <editeng/formatbreakitem.hxx>
41 #include <editeng/widwitem.hxx>
42 #include <editeng/kernitem.hxx>
43 #include <editeng/escapementitem.hxx>
44 #include <editeng/lspcitem.hxx>
45 #include <editeng/adjustitem.hxx>
46 #include <editeng/crossedoutitem.hxx>
47 #include <editeng/shdditem.hxx>
48 #include <editeng/hyphenzoneitem.hxx>
49 #include <editeng/udlnitem.hxx>
50 #include <editeng/fontitem.hxx>
51 #include <editeng/fhgtitem.hxx>
52 #include <svx/clipfmtitem.hxx>
53 #include <svl/stritem.hxx>
54 #include <svl/slstitm.hxx>
55 #include <editeng/colritem.hxx>
56 #include <editeng/wghtitem.hxx>
57 #include <editeng/contouritem.hxx>
58 #include <editeng/postitem.hxx>
59 #include <editeng/frmdiritem.hxx>
60 #include <svx/svdoutl.hxx>
61 #include <svl/whiter.hxx>
62 #include <svl/cjkoptions.hxx>
63 #include <svl/ctloptions.hxx>
64 #include <unotools/useroptions.hxx>
65 #include <vcl/msgbox.hxx>
66 #include <editeng/flditem.hxx>
67 #include <editeng/editstat.hxx>
68 #include <svx/hlnkitem.hxx>
69 #include <sfx2/htmlmode.hxx>
70 #include <editeng/langitem.hxx>
71 #include <editeng/unolingu.hxx>
72 #include <editeng/scripttypeitem.hxx>
73 #include <editeng/writingmodeitem.hxx>
76 #include <viewopt.hxx>
81 #include <swdtflvr.hxx>
82 #include <drwtxtsh.hxx>
83 #include <swmodule.hxx>
87 #include <docstat.hxx>
90 #include <globals.hrc>
92 #include <breakit.hxx>
93 #include "annotsh.hxx"
95 #include <PostItMgr.hxx>
96 #include <SidebarWin.hxx>
98 #include "swtypes.hxx"
100 #include <svx/svxdlg.hxx>
101 #include <svx/dialogs.hrc>
103 #include <svx/svxids.hrc>
104 #include <sfx2/sidebar/EnumContext.hxx>
105 #include <svl/itempool.hxx>
106 #include <editeng/outliner.hxx>
107 #include <editeng/editeng.hxx>
108 #include <editeng/editview.hxx>
110 #include <svl/languageoptions.hxx>
111 #include <svtools/langtab.hxx>
114 #include <svl/undo.hxx>
115 #include "swabstdlg.hxx"
116 #include "chrdlg.hrc"
120 #include <comphelper/processfactory.hxx>
121 #include <comphelper/string.hxx>
122 #include <cppuhelper/bootstrap.hxx>
124 #include <langhelper.hxx>
126 #include <wordcountdialog.hxx>
127 #include <tools/diagnose_ex.h>
129 using namespace ::com::sun::star
;
130 using namespace ::com::sun::star::uno
;
131 using namespace ::com::sun::star::beans
;
132 using namespace ::com::sun::star::i18n
;
134 #define SwAnnotationShell
136 #include <sfx2/msg.hxx>
137 #include <swslots.hxx>
139 SFX_IMPL_INTERFACE(SwAnnotationShell
, SfxShell
, SW_RES(STR_SHELLNAME_DRAW_TEXT
))
141 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_TEXT_TOOLBOX
));
142 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU
));
145 TYPEINIT1(SwAnnotationShell
,SfxShell
)
147 SwAnnotationShell::SwAnnotationShell( SwView
& r
)
150 SwWrtShell
&rSh
= rView
.GetWrtShell();
151 SetPool(rSh
.GetAttrPool().GetSecondaryPool());
152 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Annotation
));
155 SwAnnotationShell::~SwAnnotationShell()
159 ::svl::IUndoManager
* SwAnnotationShell::GetUndoManager()
161 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
163 !pPostItMgr
->HasActiveSidebarWin() )
165 OSL_ENSURE(pPostItMgr
,"PostItMgr::Layout(): We are looping forever");
168 return &pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView()->GetOutliner()->GetUndoManager();
171 void SwAnnotationShell::Exec( SfxRequest
&rReq
)
173 //TODO: clean this up!!!!
174 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
175 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
178 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
179 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
180 SfxItemSet
aNewAttr(*aEditAttr
.GetPool(), aEditAttr
.GetRanges());
182 sal_uInt16 nSlot
= rReq
.GetSlot();
183 sal_uInt16 nWhich
= GetPool().GetWhich(nSlot
);
184 const SfxItemSet
*pNewAttrs
= rReq
.GetArgs();
185 sal_uInt16 nEEWhich
= 0;
188 case SID_ATTR_PARA_LRSPACE
:
190 SvxLRSpaceItem
aParaMargin((const SvxLRSpaceItem
&)rReq
.
191 GetArgs()->Get(nSlot
));
192 aParaMargin
.SetWhich( EE_PARA_LRSPACE
);
194 aNewAttr
.Put(aParaMargin
);
198 case SID_ATTR_PARA_LINESPACE
:
200 SvxLineSpacingItem aParaMargin
= (const SvxLineSpacingItem
&)pNewAttrs
->Get(
201 GetPool().GetWhich(nSlot
));
202 aParaMargin
.SetWhich( EE_PARA_SBL
);
204 aNewAttr
.Put(aParaMargin
);
208 case SID_ATTR_PARA_ULSPACE
:
210 SvxULSpaceItem aULSpace
= (const SvxULSpaceItem
&)pNewAttrs
->Get(
211 GetPool().GetWhich(nSlot
));
212 aULSpace
.SetWhich( EE_PARA_ULSPACE
);
213 aNewAttr
.Put( aULSpace
);
217 case SID_ATTR_CHAR_FONT
:
218 case SID_ATTR_CHAR_FONTHEIGHT
:
219 case SID_ATTR_CHAR_WEIGHT
:
220 case SID_ATTR_CHAR_POSTURE
:
222 SfxItemPool
* pSecondPool
= aEditAttr
.GetPool()->GetSecondaryPool();
224 pSecondPool
= aEditAttr
.GetPool();
225 SvxScriptSetItem
aSetItem( nSlot
, *pSecondPool
);
226 aSetItem
.PutItemForScriptType( pOLV
->GetSelectedScriptType(), pNewAttrs
->Get( nWhich
));
227 aNewAttr
.Put( aSetItem
.GetItemSet() );
231 case SID_ATTR_CHAR_COLOR
: nEEWhich
= EE_CHAR_COLOR
; break;
232 case SID_ATTR_CHAR_UNDERLINE
:
236 SFX_REQUEST_ARG( rReq
, pItem
, SvxUnderlineItem
, SID_ATTR_CHAR_UNDERLINE
, sal_False
);
239 aNewAttr
.Put(*pItem
);
243 FontUnderline eFU
= ( (const SvxUnderlineItem
&) aEditAttr
.Get( EE_CHAR_UNDERLINE
) ).GetLineStyle();
244 aNewAttr
.Put( SvxUnderlineItem( eFU
!= UNDERLINE_NONE
?UNDERLINE_NONE
: UNDERLINE_SINGLE
, EE_CHAR_UNDERLINE
) );
249 case SID_ATTR_CHAR_OVERLINE
:
251 FontUnderline eFO
= ((const SvxOverlineItem
&)aEditAttr
.Get(EE_CHAR_OVERLINE
)).GetLineStyle();
252 aNewAttr
.Put(SvxOverlineItem(eFO
== UNDERLINE_SINGLE
? UNDERLINE_NONE
: UNDERLINE_SINGLE
, EE_CHAR_OVERLINE
));
255 case SID_ATTR_CHAR_CONTOUR
: nEEWhich
= EE_CHAR_OUTLINE
; break;
256 case SID_ATTR_CHAR_SHADOWED
: nEEWhich
= EE_CHAR_SHADOW
; break;
257 case SID_ATTR_CHAR_STRIKEOUT
: nEEWhich
= EE_CHAR_STRIKEOUT
; break;
258 case SID_ATTR_CHAR_WORDLINEMODE
: nEEWhich
= EE_CHAR_WLM
; break;
259 case SID_ATTR_CHAR_RELIEF
: nEEWhich
= EE_CHAR_RELIEF
; break;
260 case SID_ATTR_CHAR_LANGUAGE
: nEEWhich
= EE_CHAR_LANGUAGE
;break;
261 case SID_ATTR_CHAR_KERNING
: nEEWhich
= EE_CHAR_KERNING
; break;
262 case SID_ATTR_CHAR_SCALEWIDTH
: nEEWhich
= EE_CHAR_FONTWIDTH
; break;
263 case SID_ATTR_CHAR_AUTOKERN
: nEEWhich
= EE_CHAR_PAIRKERNING
; break;
264 case SID_ATTR_CHAR_ESCAPEMENT
: nEEWhich
= EE_CHAR_ESCAPEMENT
; break;
265 case SID_ATTR_PARA_ADJUST_LEFT
:
266 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_LEFT
, EE_PARA_JUST
));
268 case SID_ATTR_PARA_ADJUST_CENTER
:
269 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_CENTER
, EE_PARA_JUST
));
271 case SID_ATTR_PARA_ADJUST_RIGHT
:
272 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_RIGHT
, EE_PARA_JUST
));
274 case SID_ATTR_PARA_ADJUST_BLOCK
:
275 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_BLOCK
, EE_PARA_JUST
));
278 case SID_ATTR_PARA_LINESPACE_10
:
280 SvxLineSpacingItem
aItem(SVX_LINESPACE_ONE_LINE
, EE_PARA_SBL
);
281 aItem
.SetPropLineSpace(100);
285 case SID_ATTR_PARA_LINESPACE_15
:
287 SvxLineSpacingItem
aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES
, EE_PARA_SBL
);
288 aItem
.SetPropLineSpace(150);
292 case SID_ATTR_PARA_LINESPACE_20
:
294 SvxLineSpacingItem
aItem(SVX_LINESPACE_TWO_LINES
, EE_PARA_SBL
);
295 aItem
.SetPropLineSpace(200);
301 Outliner
* pOutliner
= pOLV
->GetOutliner();
304 sal_Int32 nParaCount
= pOutliner
->GetParagraphCount();
306 pOLV
->SelectRange(0L, nParaCount
);
310 case FN_FORMAT_RESET
:
312 pPostItMgr
->GetActiveSidebarWin()->ResetAttributes();
316 case FN_SET_SUPER_SCRIPT
:
318 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
319 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
320 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
322 if( eEsc
== SVX_ESCAPEMENT_SUPERSCRIPT
)
323 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
325 aItem
.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT
);
326 aNewAttr
.Put( aItem
, EE_CHAR_ESCAPEMENT
);
329 case FN_SET_SUB_SCRIPT
:
331 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
332 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
333 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
335 if( eEsc
== SVX_ESCAPEMENT_SUBSCRIPT
)
336 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
338 aItem
.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT
);
339 aNewAttr
.Put( aItem
, EE_CHAR_ESCAPEMENT
);
342 case SID_HYPERLINK_SETLINK
:
344 const SfxPoolItem
* pItem
= 0;
346 pNewAttrs
->GetItemState(nSlot
, sal_False
, &pItem
);
350 const SvxHyperlinkItem
& rHLinkItem
= *(const SvxHyperlinkItem
*)pItem
;
351 SvxURLField
aFld(rHLinkItem
.GetURL(), rHLinkItem
.GetName(), SVXURLFORMAT_APPDEFAULT
);
352 aFld
.SetTargetFrame(rHLinkItem
.GetTargetFrame());
354 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
356 if (pFieldItem
&& pFieldItem
->GetField()->ISA(SvxURLField
))
358 // Select the field so that it will be deleted during insert
359 ESelection aSel
= pOLV
->GetSelection();
361 pOLV
->SetSelection(aSel
);
363 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED
)
364 pOLV
->InsertField(SvxFieldItem(aFld
, EE_FEATURE_FIELD
));
368 case FN_INSERT_SOFT_HYPHEN
:
369 case FN_INSERT_HARDHYPHEN
:
370 case FN_INSERT_HARD_SPACE
:
371 case SID_INSERT_RLM
:
372 case SID_INSERT_LRM
:
373 case SID_INSERT_ZWNBSP
:
374 case SID_INSERT_ZWSP
:
376 sal_Unicode cIns
= 0;
377 switch(rReq
.GetSlot())
379 case FN_INSERT_SOFT_HYPHEN
: cIns
= CHAR_SOFTHYPHEN
; break;
380 case FN_INSERT_HARDHYPHEN
: cIns
= CHAR_HARDHYPHEN
; break;
381 case FN_INSERT_HARD_SPACE
: cIns
= CHAR_HARDBLANK
; break;
382 case SID_INSERT_RLM
: cIns
= CHAR_RLM
; break;
383 case SID_INSERT_LRM
: cIns
= CHAR_LRM
; break;
384 case SID_INSERT_ZWSP
: cIns
= CHAR_ZWSP
; break;
385 case SID_INSERT_ZWNBSP
: cIns
= CHAR_ZWNBSP
; break;
387 pOLV
->InsertText( OUString(cIns
));
393 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED
)
397 case FN_INSERT_STRING
:
399 const SfxPoolItem
* pItem
= 0;
401 pNewAttrs
->GetItemState(nSlot
, sal_False
, &pItem
);
402 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED
)
403 pOLV
->InsertText(((const SfxStringItem
*)pItem
)->GetValue());
407 case FN_FORMAT_FOOTNOTE_DLG
:
409 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
410 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
412 VclAbstractDialog
* pDlg
= pFact
->CreateSwFootNoteOptionDlg( rView
.GetWindow(), rView
.GetWrtShell(), DLG_DOC_FOOTNOTE
);
413 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
418 case FN_NUMBERING_OUTLINE_DLG
:
420 SfxItemSet
aTmp(GetPool(), FN_PARAM_1
, FN_PARAM_1
);
421 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
422 OSL_ENSURE(pFact
, "Dialogdiet fail!");
423 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTabDialog( DLG_TAB_OUTLINE
,
424 rView
.GetWindow(), &aTmp
, rView
.GetWrtShell());
425 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
431 case SID_OPEN_XML_FILTERSETTINGS
:
435 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog
= ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
438 catch (const uno::Exception
&)
440 DBG_UNHANDLED_EXCEPTION();
445 case FN_WORDCOUNT_DIALOG
:
447 SfxViewFrame
* pVFrame
= rView
.GetViewFrame();
450 pVFrame
->ToggleChildWindow(FN_WORDCOUNT_DIALOG
);
451 Invalidate(rReq
.GetSlot());
453 SwWordCountWrapper
*pWrdCnt
= (SwWordCountWrapper
*)pVFrame
->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
455 pWrdCnt
->UpdateCounts();
459 case SID_CHAR_DLG_EFFECT
:
462 const SfxItemSet
* pArgs
= rReq
.GetArgs();
467 SwView* pView = &GetView();
468 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
469 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
471 SfxItemSet
aDlgAttr(GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
473 // util::Language does not exist in the EditEngine! Therefore not included in the set.
475 aDlgAttr
.Put( aEditAttr
);
476 aDlgAttr
.Put( SvxKerningItem(0, RES_CHRATR_KERNING
) );
478 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
479 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
481 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwCharDlg( rView
.GetWindow(), rView
, aDlgAttr
, 0, sal_True
);
482 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
483 if (nSlot
== SID_CHAR_DLG_EFFECT
)
485 pDlg
->SetCurPageId(TP_CHAR_EXT
);
487 sal_uInt16 nRet
= pDlg
->Execute();
490 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
491 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
498 aNewAttr
.Put(*pArgs
);
503 const SfxItemSet
* pArgs
= rReq
.GetArgs();
508 SwView* pView = &GetView();
509 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
510 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
512 SfxItemSet
aDlgAttr(GetPool(),
513 EE_ITEMS_START
, EE_ITEMS_END
,
514 SID_ATTR_PARA_HYPHENZONE
, SID_ATTR_PARA_HYPHENZONE
,
515 SID_ATTR_PARA_SPLIT
, SID_ATTR_PARA_SPLIT
,
516 SID_ATTR_PARA_WIDOWS
, SID_ATTR_PARA_WIDOWS
,
517 SID_ATTR_PARA_ORPHANS
, SID_ATTR_PARA_ORPHANS
,
520 aDlgAttr
.Put(aEditAttr
);
523 aDlgAttr
.Put( SvxHyphenZoneItem( sal_False
, RES_PARATR_HYPHENZONE
) );
524 aDlgAttr
.Put( SvxFmtBreakItem( SVX_BREAK_NONE
, RES_BREAK
) );
525 aDlgAttr
.Put( SvxFmtSplitItem( sal_True
, RES_PARATR_SPLIT
) );
526 aDlgAttr
.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS
) );
527 aDlgAttr
.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS
) );
530 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
531 OSL_ENSURE(pFact
, "SwAbstractDialogFactory fail!");
533 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwParaDlg( rView
.GetWindow(), rView
, aDlgAttr
,DLG_STD
, DLG_PARA
, 0, sal_True
);
534 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
535 sal_uInt16 nRet
= pDlg
->Execute();
538 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
539 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
546 aNewAttr
.Put(*pArgs
);
550 case SID_AUTOSPELL_CHECK
:
552 rView
.ExecuteSlot(rReq
);
555 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
556 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
558 bool bLeftToRight
= nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
560 const SfxPoolItem
* pPoolItem
;
561 if( pNewAttrs
&& SFX_ITEM_SET
== pNewAttrs
->GetItemState( nSlot
, sal_True
, &pPoolItem
) )
563 if( !( (SfxBoolItem
*)pPoolItem
)->GetValue() )
564 bLeftToRight
= !bLeftToRight
;
566 SfxItemSet
aAttr( *aNewAttr
.GetPool(),
567 EE_PARA_JUST
, EE_PARA_JUST
,
568 EE_PARA_WRITINGDIR
, EE_PARA_WRITINGDIR
,
571 sal_uInt16 nAdjust
= SVX_ADJUST_LEFT
;
572 if( SFX_ITEM_ON
== aEditAttr
.GetItemState(EE_PARA_JUST
, sal_True
, &pPoolItem
) )
573 nAdjust
= ( (SvxAdjustItem
*)pPoolItem
)->GetEnumValue();
577 aAttr
.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP
, EE_PARA_WRITINGDIR
) );
578 if( nAdjust
== SVX_ADJUST_RIGHT
)
579 aAttr
.Put( SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
) );
583 aAttr
.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP
, EE_PARA_WRITINGDIR
) );
584 if( nAdjust
== SVX_ADJUST_LEFT
)
585 aAttr
.Put( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
587 pOLV
->SetAttribs(aAttr
);
592 if(nEEWhich
&& pNewAttrs
)
593 aNewAttr
.Put(pNewAttrs
->Get(nWhich
), nEEWhich
);
596 Rectangle aOutRect
= pOLV
->GetOutputArea();
597 if (aNullRect
!= aOutRect
)
598 pOLV
->SetAttribs(aNewAttr
);
600 rView
.GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
601 if ( pOLV
->GetOutliner()->IsModified() )
602 rView
.GetWrtShell().SetModified();
606 void SwAnnotationShell::GetState(SfxItemSet
& rSet
)
608 //TODO: clean this up!!!
609 // FN_SET_SUPER_SCRIPT
610 //SID_ATTR_PARA_ADJUST
611 //SID_ATTR_PARA_ADJUST_BLOCK
613 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
614 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
617 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
618 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
620 SfxWhichIter
aIter(rSet
);
621 sal_uInt16 nWhich
= aIter
.FirstWhich();
624 sal_uInt16 nEEWhich
= 0;
625 sal_uInt16 nSlotId
= GetPool().GetSlotId( nWhich
);
628 case SID_ATTR_PARA_LRSPACE
:
630 SfxItemState eState
= aEditAttr
.GetItemState( EE_PARA_LRSPACE
);
631 if( eState
>= SFX_ITEM_DEFAULT
)
633 SvxLRSpaceItem aLR
= ( (const SvxLRSpaceItem
&) aEditAttr
.Get( EE_PARA_LRSPACE
) );
634 aLR
.SetWhich(SID_ATTR_PARA_LRSPACE
);
638 rSet
.InvalidateItem(nSlotId
);
641 case SID_ATTR_PARA_LINESPACE
:
643 SfxItemState eState
= aEditAttr
.GetItemState( EE_PARA_SBL
);
644 if( eState
>= SFX_ITEM_DEFAULT
)
646 SvxLineSpacingItem aLR
= ( (const SvxLineSpacingItem
&) aEditAttr
.Get( EE_PARA_SBL
) );
650 rSet
.InvalidateItem(nSlotId
);
653 case SID_ATTR_PARA_ULSPACE
:
655 SfxItemState eState
= aEditAttr
.GetItemState( EE_PARA_ULSPACE
);
656 if( eState
>= SFX_ITEM_DEFAULT
)
658 SvxULSpaceItem aULSpace
= (const SvxULSpaceItem
&) aEditAttr
.Get( EE_PARA_ULSPACE
);
659 aULSpace
.SetWhich(SID_ATTR_PARA_ULSPACE
);
663 rSet
.InvalidateItem(nSlotId
);
666 case SID_ATTR_CHAR_FONT
:
667 case SID_ATTR_CHAR_FONTHEIGHT
:
668 case SID_ATTR_CHAR_WEIGHT
:
669 case SID_ATTR_CHAR_POSTURE
:
673 sal_uInt16 nScriptType
= pOLV
->GetSelectedScriptType();
674 SfxItemPool
* pSecondPool
= aEditAttr
.GetPool()->GetSecondaryPool();
676 pSecondPool
= aEditAttr
.GetPool();
677 SvxScriptSetItem
aSetItem( nSlotId
, *pSecondPool
);
678 aSetItem
.GetItemSet().Put( aEditAttr
, sal_False
);
679 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScriptType
);
681 rSet
.Put( *pI
, nWhich
);
683 rSet
.InvalidateItem( nWhich
);
686 rSet
.InvalidateItem( nWhich
);
689 case SID_ATTR_CHAR_COLOR
: nEEWhich
= EE_CHAR_COLOR
; break;
690 case SID_ATTR_CHAR_UNDERLINE
: nEEWhich
= EE_CHAR_UNDERLINE
;break;
691 case SID_ATTR_CHAR_OVERLINE
: nEEWhich
= EE_CHAR_OVERLINE
;break;
692 case SID_ATTR_CHAR_CONTOUR
: nEEWhich
= EE_CHAR_OUTLINE
; break;
693 case SID_ATTR_CHAR_SHADOWED
: nEEWhich
= EE_CHAR_SHADOW
;break;
694 case SID_ATTR_CHAR_STRIKEOUT
: nEEWhich
= EE_CHAR_STRIKEOUT
;break;
695 case SID_ATTR_CHAR_LANGUAGE
: nEEWhich
= EE_CHAR_LANGUAGE
;break;
696 case SID_ATTR_CHAR_ESCAPEMENT
: nEEWhich
= EE_CHAR_ESCAPEMENT
;break;
697 case SID_ATTR_CHAR_KERNING
: nEEWhich
= EE_CHAR_KERNING
;break;
698 case FN_SET_SUPER_SCRIPT
:
699 case FN_SET_SUB_SCRIPT
:
702 const SfxPoolItem
*pEscItem
= 0;
703 if (nWhich
==FN_SET_SUPER_SCRIPT
)
704 nEsc
= SVX_ESCAPEMENT_SUPERSCRIPT
;
706 nEsc
= SVX_ESCAPEMENT_SUBSCRIPT
;
709 pEscItem
= &aEditAttr
.Get( EE_CHAR_ESCAPEMENT
);
711 if( nEsc
== ((const SvxEscapementItem
*)pEscItem
)->GetEnumValue() )
712 rSet
.Put( SfxBoolItem( nWhich
, sal_True
));
714 rSet
.InvalidateItem( nWhich
);
717 case SID_ATTR_PARA_ADJUST_LEFT
:
718 case SID_ATTR_PARA_ADJUST_RIGHT
:
719 case SID_ATTR_PARA_ADJUST_CENTER
:
720 case SID_ATTR_PARA_ADJUST_BLOCK
:
722 const SfxPoolItem
*pAdjust
= 0;
725 if (nWhich
==SID_ATTR_PARA_ADJUST_LEFT
)
726 eAdjust
= SVX_ADJUST_LEFT
;
727 else if (nWhich
==SID_ATTR_PARA_ADJUST_RIGHT
)
728 eAdjust
= SVX_ADJUST_RIGHT
;
729 else if (nWhich
==SID_ATTR_PARA_ADJUST_CENTER
)
730 eAdjust
= SVX_ADJUST_CENTER
;
731 else if (nWhich
==SID_ATTR_PARA_ADJUST_BLOCK
)
732 eAdjust
= SVX_ADJUST_BLOCK
;
735 aEditAttr
.GetItemState( EE_PARA_JUST
, sal_False
, &pAdjust
);
737 if( !pAdjust
|| IsInvalidItem( pAdjust
))
738 rSet
.InvalidateItem( nSlotId
), nSlotId
= 0;
741 if ( eAdjust
== ((const SvxAdjustItem
*)pAdjust
)->GetAdjust())
742 rSet
.Put( SfxBoolItem( nWhich
, sal_True
));
744 rSet
.InvalidateItem( nWhich
);
748 case SID_ATTR_PARA_LINESPACE_10
:
749 case SID_ATTR_PARA_LINESPACE_15
:
750 case SID_ATTR_PARA_LINESPACE_20
:
752 const SfxPoolItem
*pLSpace
= 0;
755 if (nWhich
==SID_ATTR_PARA_LINESPACE_10
)
757 else if (nWhich
==SID_ATTR_PARA_LINESPACE_15
)
759 else if (nWhich
==SID_ATTR_PARA_LINESPACE_20
)
763 aEditAttr
.GetItemState( EE_PARA_SBL
, sal_False
, &pLSpace
);
765 if( !pLSpace
|| IsInvalidItem( pLSpace
))
766 rSet
.InvalidateItem( nSlotId
), nSlotId
= 0;
769 if( nLSpace
== ((const SvxLineSpacingItem
*)pLSpace
)->GetPropLineSpace() )
770 rSet
.Put( SfxBoolItem( nWhich
, sal_True
));
772 rSet
.InvalidateItem( nWhich
);
776 case SID_AUTOSPELL_CHECK
:
778 const SfxPoolItem
* pState
= rView
.GetSlotState(nWhich
);
780 rSet
.Put(SfxBoolItem(nWhich
, ((const SfxBoolItem
*)pState
)->GetValue()));
782 rSet
.DisableItem( nWhich
);
785 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
786 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
788 if ( !SvtLanguageOptions().IsCTLFontEnabled() )
789 rSet
.DisableItem( nWhich
);
792 if(pOLV
->GetOutliner() && pOLV
->GetOutliner()->IsVertical())
793 rSet
.DisableItem( nWhich
);
796 sal_Bool bFlag
= sal_False
;
797 switch( ( ( (SvxFrameDirectionItem
&) aEditAttr
.Get( EE_PARA_WRITINGDIR
) ) ).GetValue() )
799 case FRMDIR_HORI_LEFT_TOP
:
801 bFlag
= nWhich
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
802 rSet
.Put( SfxBoolItem( nWhich
, bFlag
));
805 case FRMDIR_HORI_RIGHT_TOP
:
807 bFlag
= nWhich
!= SID_ATTR_PARA_LEFT_TO_RIGHT
;
808 rSet
.Put( SfxBoolItem( nWhich
, bFlag
));
816 case SID_INSERT_RLM
:
817 case SID_INSERT_LRM
:
818 case SID_INSERT_ZWNBSP
:
819 case SID_INSERT_ZWSP
:
821 SvtCTLOptions aCTLOptions
;
822 sal_Bool bEnabled
= aCTLOptions
.IsCTLFontEnabled();
823 rView
.GetViewFrame()->GetBindings().SetVisibleState( nWhich
, bEnabled
);
825 rSet
.DisableItem(nWhich
);
829 rSet
.InvalidateItem( nWhich
);
835 rSet
.Put(aEditAttr
.Get(nEEWhich
, sal_True
), nWhich
);
836 if(nEEWhich
== EE_CHAR_KERNING
)
838 SfxItemState eState
= aEditAttr
.GetItemState( EE_CHAR_KERNING
, sal_True
);
839 if ( eState
== SFX_ITEM_DONTCARE
)
841 rSet
.InvalidateItem(EE_CHAR_KERNING
);
846 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED
)
847 rSet
.DisableItem( nWhich
);
849 nWhich
= aIter
.NextWhich();
853 void SwAnnotationShell::ExecSearch(SfxRequest
& rReq
, sal_Bool bNoMessage
)
855 rView
.ExecSearch(rReq
,bNoMessage
);
858 void SwAnnotationShell::StateSearch(SfxItemSet
&rSet
)
860 rView
.StateSearch(rSet
);
863 void SwAnnotationShell::ExecClpbrd(SfxRequest
&rReq
)
865 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
866 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
869 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
870 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
871 SfxItemSet
aNewAttr(*aEditAttr
.GetPool(), aEditAttr
.GetRanges());
873 long aOldHeight
= pPostItMgr
->GetActiveSidebarWin()->GetPostItTextHeight();
874 sal_uInt16 nSlot
= rReq
.GetSlot();
878 if ( (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED
) && pOLV
->HasSelection() )
882 if( pOLV
->HasSelection() )
886 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED
)
889 case SID_PASTE_SPECIAL
:
891 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED
)
893 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
894 SfxAbstractPasteDialog
* pDlg
= pFact
->CreatePasteDialog( &rView
.GetEditWin() );
896 pDlg
->Insert( SOT_FORMAT_STRING
, aEmptyStr
);
897 pDlg
->Insert( SOT_FORMAT_RTF
, aEmptyStr
);
899 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView
.GetEditWin() ) );
901 sal_uLong nFormat
= pDlg
->GetFormat( aDataHelper
.GetTransferable() );
905 if (nFormat
== SOT_FORMAT_STRING
)
908 pOLV
->PasteSpecial();
914 case SID_CLIPBOARD_FORMAT_ITEMS
:
916 sal_uLong nFormat
= 0;
917 const SfxPoolItem
* pItem
;
918 if ( rReq
.GetArgs() && rReq
.GetArgs()->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
&&
919 pItem
->ISA(SfxUInt32Item
) )
921 nFormat
= ((const SfxUInt32Item
*)pItem
)->GetValue();
926 if (SOT_FORMAT_STRING
== nFormat
)
929 pOLV
->PasteSpecial();
934 pPostItMgr
->GetActiveSidebarWin()->ResizeIfNeccessary(aOldHeight
,pPostItMgr
->GetActiveSidebarWin()->GetPostItTextHeight());
937 void SwAnnotationShell::StateClpbrd(SfxItemSet
&rSet
)
939 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
940 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
942 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
944 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView
.GetEditWin() ) );
945 bool bPastePossible
= ( aDataHelper
.HasFormat( SOT_FORMAT_STRING
) || aDataHelper
.HasFormat( SOT_FORMAT_RTF
) );
946 bPastePossible
= bPastePossible
&& (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED
);
948 SfxWhichIter
aIter(rSet
);
949 sal_uInt16 nWhich
= aIter
.FirstWhich();
957 if ( (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED
) || !pOLV
->HasSelection() )
958 rSet
.DisableItem( nWhich
);
962 if( !pOLV
->HasSelection() )
963 rSet
.DisableItem( nWhich
);
967 case SID_PASTE_SPECIAL
:
969 if( !bPastePossible
)
970 rSet
.DisableItem( nWhich
);
973 case SID_CLIPBOARD_FORMAT_ITEMS
:
975 if ( bPastePossible
)
977 SvxClipboardFmtItem
aFormats( SID_CLIPBOARD_FORMAT_ITEMS
);
978 if ( aDataHelper
.HasFormat( SOT_FORMAT_RTF
) )
979 aFormats
.AddClipbrdFormat( SOT_FORMAT_RTF
);
980 aFormats
.AddClipbrdFormat( SOT_FORMAT_STRING
);
981 rSet
.Put( aFormats
);
984 rSet
.DisableItem( nWhich
);
988 nWhich
= aIter
.NextWhich();
992 void SwAnnotationShell::StateStatusLine(SfxItemSet
&rSet
)
994 SfxWhichIter
aIter( rSet
);
995 sal_uInt16 nWhich
= aIter
.FirstWhich();
1001 case FN_STAT_SELMODE
:
1003 rSet
.Put(SfxUInt16Item(FN_STAT_SELMODE
, 0));
1004 rSet
.DisableItem( nWhich
);
1007 case FN_STAT_TEMPLATE
:
1009 rSet
.DisableItem( nWhich
);
1013 nWhich
= aIter
.NextWhich();
1017 void SwAnnotationShell::StateInsert(SfxItemSet
&rSet
)
1019 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1020 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
1023 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
1024 SfxWhichIter
aIter(rSet
);
1025 sal_uInt16 nWhich
= aIter
.FirstWhich();
1031 case SID_HYPERLINK_GETLINK
:
1033 SvxHyperlinkItem aHLinkItem
;
1034 aHLinkItem
.SetInsertMode(HLINK_FIELD
);
1036 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
1040 const SvxFieldData
* pField
= pFieldItem
->GetField();
1042 if (pField
->ISA(SvxURLField
))
1044 aHLinkItem
.SetName(((const SvxURLField
*) pField
)->GetRepresentation());
1045 aHLinkItem
.SetURL(((const SvxURLField
*) pField
)->GetURL());
1046 aHLinkItem
.SetTargetFrame(((const SvxURLField
*) pField
)->GetTargetFrame());
1051 String
sSel(pOLV
->GetSelected());
1053 aHLinkItem
.SetName(comphelper::string::stripEnd(sSel
, ' '));
1056 sal_uInt16 nHtmlMode
= ::GetHtmlMode(rView
.GetDocShell());
1057 aHLinkItem
.SetInsertMode((SvxLinkInsertMode
)(aHLinkItem
.GetInsertMode() |
1058 ((nHtmlMode
& HTMLMODE_ON
) != 0 ? HLINK_HTMLMODE
: 0)));
1060 rSet
.Put(aHLinkItem
);
1065 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED
)
1066 rSet
.DisableItem( nWhich
);
1068 nWhich
= aIter
.NextWhich();
1073 void SwAnnotationShell::NoteExec(SfxRequest
&rReq
)
1075 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1079 sal_uInt16 nSlot
= rReq
.GetSlot();
1084 case FN_DELETE_COMMENT
:
1085 if ( pPostItMgr
->HasActiveSidebarWin() )
1086 pPostItMgr
->GetActiveSidebarWin()->ExecuteCommand(nSlot
);
1088 case FN_DELETE_ALL_NOTES
:
1089 pPostItMgr
->Delete();
1091 case FN_DELETE_NOTE_AUTHOR
:
1093 SFX_REQUEST_ARG( rReq
, pItem
, SfxStringItem
, nSlot
, sal_False
);
1095 pPostItMgr
->Delete( pItem
->GetValue() );
1100 case FN_HIDE_ALL_NOTES
:
1103 case FN_HIDE_NOTE_AUTHOR
:
1105 SFX_REQUEST_ARG( rReq
, pItem
, SfxStringItem
, nSlot
, sal_False
);
1107 pPostItMgr
->Hide( pItem
->GetValue() );
1112 void SwAnnotationShell::GetNoteState(SfxItemSet
&rSet
)
1114 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1115 SfxWhichIter
aIter(rSet
);
1116 sal_uInt16 nWhich
= aIter
.FirstWhich();
1119 sal_uInt16 nSlotId
= GetPool().GetSlotId( nWhich
);
1123 case FN_DELETE_NOTE_AUTHOR
:
1124 case FN_DELETE_ALL_NOTES
:
1126 case FN_HIDE_NOTE_AUTHOR
:
1127 case FN_HIDE_ALL_NOTES
:
1128 case FN_DELETE_COMMENT
:
1131 !pPostItMgr
->HasActiveAnnotationWin() )
1133 rSet
.DisableItem(nWhich
);
1140 !pPostItMgr
->HasActiveAnnotationWin() )
1142 rSet
.DisableItem(nWhich
);
1146 SvtUserOptions aUserOpt
;
1148 if( !(sAuthor
= aUserOpt
.GetFullName()).Len())
1149 if( !(sAuthor
= aUserOpt
.GetID()).Len() )
1150 sAuthor
= String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR
));
1151 if (sAuthor
== pPostItMgr
->GetActiveSidebarWin()->GetAuthor())
1152 rSet
.DisableItem(nWhich
);
1157 rSet
.InvalidateItem( nWhich
);
1161 if (pPostItMgr
->HasActiveSidebarWin())
1163 if ( (pPostItMgr
->GetActiveSidebarWin()->IsProtected()) &&
1164 ( (nSlotId
==FN_DELETE_COMMENT
) || (nSlotId
==FN_REPLY
) ) )
1165 rSet
.DisableItem( nWhich
);
1167 nWhich
= aIter
.NextWhich();
1171 void SwAnnotationShell::ExecLingu(SfxRequest
&rReq
)
1173 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1174 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
1177 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
1178 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
1179 sal_uInt16 nSlot
= rReq
.GetSlot();
1180 SwWrtShell
&rSh
= rView
.GetWrtShell();
1181 bool bRestoreSelection
= false;
1182 ESelection aOldSelection
;
1186 case SID_LANGUAGE_STATUS
:
1188 aOldSelection
= pOLV
->GetSelection();
1189 if (!pOLV
->GetEditView().HasSelection())
1191 bRestoreSelection
= true;
1192 pOLV
->GetEditView().SelectCurrentWord();
1195 bRestoreSelection
= SwLangHelper::SetLanguageStatus(pOLV
,rReq
,rView
,rSh
);
1200 String aReplaceText
;
1201 SFX_REQUEST_ARG( rReq
, pItem2
, SfxStringItem
, SID_THES
, sal_False
);
1203 aReplaceText
= pItem2
->GetValue();
1204 if (aReplaceText
.Len() > 0)
1205 ReplaceTextWithSynonym( pOLV
->GetEditView(), aReplaceText
);
1210 pOLV
->StartThesaurus();
1213 case SID_HANGUL_HANJA_CONVERSION
:
1214 pOLV
->StartTextConversion( LANGUAGE_KOREAN
, LANGUAGE_KOREAN
, NULL
,
1215 i18n::TextConversionOption::CHARACTER_BY_CHARACTER
, sal_True
, sal_False
);
1218 case SID_CHINESE_CONVERSION
:
1220 //open ChineseTranslationDialog
1221 Reference
< XComponentContext
> xContext(
1222 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1225 Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager() );
1228 Reference
< ui::dialogs::XExecutableDialog
> xDialog(
1229 xMCF
->createInstanceWithContext(
1230 OUString("com.sun.star.linguistic2.ChineseTranslationDialog")
1231 , xContext
), UNO_QUERY
);
1232 Reference
< lang::XInitialization
> xInit( xDialog
, UNO_QUERY
);
1235 // initialize dialog
1236 Reference
< awt::XWindow
> xDialogParentWindow(0);
1237 Sequence
<Any
> aSeq(1);
1238 Any
* pArray
= aSeq
.getArray();
1239 PropertyValue aParam
;
1240 aParam
.Name
= OUString("ParentWindow");
1241 aParam
.Value
<<= makeAny(xDialogParentWindow
);
1242 pArray
[0] <<= makeAny(aParam
);
1243 xInit
->initialize( aSeq
);
1246 sal_Int16 nDialogRet
= xDialog
->execute();
1247 if( RET_OK
== nDialogRet
)
1249 //get some parameters from the dialog
1250 sal_Bool bToSimplified
= sal_True
;
1251 sal_Bool bUseVariants
= sal_True
;
1252 sal_Bool bCommonTerms
= sal_True
;
1253 Reference
< beans::XPropertySet
> xProp( xDialog
, UNO_QUERY
);
1258 xProp
->getPropertyValue( "IsDirectionToSimplified" ) >>= bToSimplified
;
1259 xProp
->getPropertyValue( "IsUseCharacterVariants" ) >>= bUseVariants
;
1260 xProp
->getPropertyValue( "IsTranslateCommonTerms" ) >>= bCommonTerms
;
1262 catch (const Exception
&)
1267 //execute translation
1268 sal_Int16 nSourceLang
= bToSimplified
? LANGUAGE_CHINESE_TRADITIONAL
: LANGUAGE_CHINESE_SIMPLIFIED
;
1269 sal_Int16 nTargetLang
= bToSimplified
? LANGUAGE_CHINESE_SIMPLIFIED
: LANGUAGE_CHINESE_TRADITIONAL
;
1270 sal_Int32 nOptions
= bUseVariants
? i18n::TextConversionOption::USE_CHARACTER_VARIANTS
: 0;
1272 nOptions
= nOptions
| i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
1274 Font aTargetFont
= pOLV
->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT
,
1275 nTargetLang
, DEFAULTFONT_FLAGS_ONLYONE
);
1277 pOLV
->StartTextConversion( nSourceLang
, nTargetLang
, &aTargetFont
, nOptions
, sal_False
, sal_False
);
1280 Reference
< lang::XComponent
> xComponent( xDialog
, UNO_QUERY
);
1281 if( xComponent
.is() )
1282 xComponent
->dispose();
1289 if (bRestoreSelection
)
1291 // restore selection
1292 pOLV
->GetEditView().SetSelection( aOldSelection
);
1296 void SwAnnotationShell::GetLinguState(SfxItemSet
&rSet
)
1298 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1299 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
1302 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
1303 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
1305 SfxWhichIter
aIter(rSet
);
1306 sal_uInt16 nWhich
= aIter
.FirstWhich();
1311 case SID_LANGUAGE_STATUS
:
1313 SwLangHelper::GetLanguageStatus(pOLV
,rSet
);
1320 LanguageType nLang
= LANGUAGE_NONE
;
1321 bool bIsLookUpWord
= GetStatusValueForThesaurusFromContext( aStatusVal
, nLang
, pOLV
->GetEditView() );
1322 rSet
.Put( SfxStringItem( SID_THES
, aStatusVal
) );
1324 // disable "Thesaurus" context menu entry if there is nothing to look up
1325 uno::Reference
< linguistic2::XThesaurus
> xThes( ::GetThesaurus() );
1326 if (!bIsLookUpWord
||
1327 !xThes
.is() || nLang
== LANGUAGE_NONE
|| !xThes
->hasLocale( LanguageTag( nLang
).getLocale() ))
1328 rSet
.DisableItem( SID_THES
);
1332 // disable "Thesaurus" if the language is not supported
1335 const SfxPoolItem
&rItem
= rView
.GetWrtShell().GetDoc()->GetDefault(
1336 GetWhichOfScript( RES_CHRATR_LANGUAGE
,
1337 GetI18NScriptTypeOfLanguage( (sal_uInt16
)GetAppLanguage())) );
1338 LanguageType nLang
= ((const SvxLanguageItem
&)
1339 rItem
).GetLanguage();
1340 uno::Reference
< linguistic2::XThesaurus
> xThes( ::GetThesaurus() );
1341 if (!xThes
.is() || nLang
== LANGUAGE_NONE
||
1342 !xThes
->hasLocale( LanguageTag( nLang
).getLocale() ))
1343 rSet
.DisableItem( SID_THESAURUS
);
1346 case SID_HANGUL_HANJA_CONVERSION
:
1347 case SID_CHINESE_CONVERSION
:
1349 if (!SvtCJKOptions().IsAnyEnabled())
1351 rView
.GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
1352 rSet
.DisableItem(nWhich
);
1355 rView
.GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
1360 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED
)
1361 rSet
.DisableItem( nWhich
);
1363 nWhich
= aIter
.NextWhich();
1367 void SwAnnotationShell::ExecTransliteration(SfxRequest
&rReq
)
1369 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1370 if (!pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin())
1373 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
1378 using namespace ::com::sun::star::i18n
;
1380 sal_uInt32 nMode
= 0;
1382 switch( rReq
.GetSlot() )
1384 case SID_TRANSLITERATE_SENTENCE_CASE
:
1385 nMode
= TransliterationModulesExtra::SENTENCE_CASE
;
1387 case SID_TRANSLITERATE_TITLE_CASE
:
1388 nMode
= TransliterationModulesExtra::TITLE_CASE
;
1390 case SID_TRANSLITERATE_TOGGLE_CASE
:
1391 nMode
= TransliterationModulesExtra::TOGGLE_CASE
;
1393 case SID_TRANSLITERATE_UPPER
:
1394 nMode
= TransliterationModules_LOWERCASE_UPPERCASE
;
1396 case SID_TRANSLITERATE_LOWER
:
1397 nMode
= TransliterationModules_UPPERCASE_LOWERCASE
;
1399 case SID_TRANSLITERATE_HALFWIDTH
:
1400 nMode
= TransliterationModules_FULLWIDTH_HALFWIDTH
;
1402 case SID_TRANSLITERATE_FULLWIDTH
:
1403 nMode
= TransliterationModules_HALFWIDTH_FULLWIDTH
;
1405 case SID_TRANSLITERATE_HIRAGANA
:
1406 nMode
= TransliterationModules_KATAKANA_HIRAGANA
;
1408 case SID_TRANSLITERATE_KATAGANA
:
1409 nMode
= TransliterationModules_HIRAGANA_KATAKANA
;
1413 OSL_ENSURE(!this, "wrong dispatcher");
1417 pOLV
->TransliterateText( nMode
);
1420 void SwAnnotationShell::ExecRotateTransliteration( SfxRequest
& rReq
)
1422 if( rReq
.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE
)
1424 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1425 if (!pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin())
1428 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
1433 pOLV
->TransliterateText(m_aRotateCase
.getNextMode());
1437 void SwAnnotationShell::ExecUndo(SfxRequest
&rReq
)
1439 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1440 ::svl::IUndoManager
* pUndoManager
= GetUndoManager();
1441 SwWrtShell
&rSh
= rView
.GetWrtShell();
1443 long aOldHeight
= rView
.GetPostItMgr()->HasActiveSidebarWin()
1444 ? rView
.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight()
1447 sal_uInt16 nId
= rReq
.GetSlot();
1448 sal_uInt16 nCnt
= 1;
1449 const SfxPoolItem
* pItem
=0;
1450 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nId
, sal_False
, &pItem
) )
1451 nCnt
= ((SfxUInt16Item
*)pItem
)->GetValue();
1458 sal_uInt16 nCount
= pUndoManager
->GetUndoActionCount();
1459 sal_uInt16 nSteps
= nCnt
;
1460 if ( nCount
< nCnt
)
1462 nCnt
= nCnt
- nCount
;
1469 pUndoManager
->Undo();
1473 rSh
.Do( SwWrtShell::UNDO
, nCnt
);
1482 sal_uInt16 nCount
= pUndoManager
->GetRedoActionCount();
1483 sal_uInt16 nSteps
= nCnt
;
1484 if ( nCount
< nCnt
)
1486 nCnt
= nCnt
- nCount
;
1493 pUndoManager
->Redo();
1497 rSh
.Do( SwWrtShell::REDO
, nCnt
);
1503 rView
.GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
1505 if (rView
.GetPostItMgr()->HasActiveSidebarWin())
1506 rView
.GetPostItMgr()->GetActiveSidebarWin()->ResizeIfNeccessary(aOldHeight
,rView
.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight());
1509 void SwAnnotationShell::StateUndo(SfxItemSet
&rSet
)
1511 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1512 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
1515 SfxWhichIter
aIter(rSet
);
1516 sal_uInt16 nWhich
= aIter
.FirstWhich();
1517 ::svl::IUndoManager
* pUndoManager
= GetUndoManager();
1518 SfxViewFrame
*pSfxViewFrame
= rView
.GetViewFrame();
1519 SwWrtShell
&rSh
= rView
.GetWrtShell();
1527 sal_uInt16 nCount
= pUndoManager
->GetUndoActionCount();
1529 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1530 else if (rSh
.GetLastUndoInfo(0, 0))
1532 rSet
.Put( SfxStringItem( nWhich
, rSh
.GetDoString(SwWrtShell::UNDO
)) );
1535 rSet
.DisableItem(nWhich
);
1540 sal_uInt16 nCount
= pUndoManager
->GetRedoActionCount();
1542 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1543 else if (rSh
.GetFirstRedoInfo(0))
1545 rSet
.Put(SfxStringItem( nWhich
, rSh
.GetDoString(SwWrtShell::REDO
)) );
1548 rSet
.DisableItem(nWhich
);
1551 case SID_GETUNDOSTRINGS
:
1552 case SID_GETREDOSTRINGS
:
1556 OUString (::svl::IUndoManager:: *fnGetComment
)( size_t, bool const ) const;
1559 if( SID_GETUNDOSTRINGS
== nWhich
)
1561 nCount
= pUndoManager
->GetUndoActionCount();
1562 fnGetComment
= &::svl::IUndoManager::GetUndoActionComment
;
1566 nCount
= pUndoManager
->GetRedoActionCount();
1567 fnGetComment
= &::svl::IUndoManager::GetRedoActionComment
;
1573 for( sal_uInt16 n
= 0; n
< nCount
; ++n
)
1574 ( sList
+= (pUndoManager
->*fnGetComment
)( n
, ::svl::IUndoManager::TopLevel
) )
1578 SfxStringListItem
aItem( nWhich
);
1579 if ((nWhich
== SID_GETUNDOSTRINGS
) &&
1580 rSh
.GetLastUndoInfo(0, 0))
1582 rSh
.GetDoStrings( SwWrtShell::UNDO
, aItem
);
1584 else if ((nWhich
== SID_GETREDOSTRINGS
) &&
1585 (rSh
.GetFirstRedoInfo(0)))
1587 rSh
.GetDoStrings( SwWrtShell::UNDO
, aItem
);
1590 sList
+= aItem
.GetString();
1591 aItem
.SetString( sList
);
1595 rSet
.DisableItem( nWhich
);
1601 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1607 if (pPostItMgr
->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED
)
1608 rSet
.DisableItem( nWhich
);
1610 nWhich
= aIter
.NextWhich();
1614 void SwAnnotationShell::StateDisableItems( SfxItemSet
&rSet
)
1616 SfxWhichIter
aIter(rSet
);
1617 sal_uInt16 nWhich
= aIter
.FirstWhich();
1620 rSet
.DisableItem( nWhich
);
1621 nWhich
= aIter
.NextWhich();
1625 void SwAnnotationShell::InsertSymbol(SfxRequest
& rReq
)
1627 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1628 if ( !pPostItMgr
|| !pPostItMgr
->HasActiveSidebarWin() )
1631 OutlinerView
* pOLV
= pPostItMgr
->GetActiveSidebarWin()->GetOutlinerView();
1633 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1634 const SfxPoolItem
* pItem
= 0;
1636 pArgs
->GetItemState(GetPool().GetWhich(SID_CHARMAP
), sal_False
, &pItem
);
1642 sSym
= ((const SfxStringItem
*)pItem
)->GetValue();
1643 const SfxPoolItem
* pFtItem
= NULL
;
1644 pArgs
->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR
), sal_False
, &pFtItem
);
1645 const SfxStringItem
* pFontItem
= PTR_CAST( SfxStringItem
, pFtItem
);
1647 sFontName
= pFontItem
->GetValue();
1650 SfxItemSet
aSet(pOLV
->GetAttribs());
1651 sal_uInt16 nScript
= pOLV
->GetSelectedScriptType();
1652 SvxFontItem
aSetDlgFont( RES_CHRATR_FONT
);
1654 SvxScriptSetItem
aSetItem( SID_ATTR_CHAR_FONT
, *aSet
.GetPool() );
1655 aSetItem
.GetItemSet().Put( aSet
, sal_False
);
1656 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScript
);
1658 aSetDlgFont
= *(SvxFontItem
*)pI
;
1660 aSetDlgFont
= (SvxFontItem
&)aSet
.Get( GetWhichOfScript(
1662 GetI18NScriptTypeOfLanguage( (sal_uInt16
)GetAppLanguage() ) ));
1663 if (!sFontName
.Len())
1664 sFontName
= aSetDlgFont
.GetFamilyName();
1667 Font
aFont(sFontName
, Size(1,1));
1670 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1672 SfxAllItemSet
aAllSet( GetPool() );
1673 aAllSet
.Put( SfxBoolItem( FN_PARAM_1
, sal_False
) );
1675 SwViewOption
aOpt(*rView
.GetWrtShell().GetViewOptions());
1676 String sSymbolFont
= aOpt
.GetSymbolFont();
1677 if( sSymbolFont
.Len() )
1678 aAllSet
.Put( SfxStringItem( SID_FONT_NAME
, sSymbolFont
) );
1680 aAllSet
.Put( SfxStringItem( SID_FONT_NAME
, aSetDlgFont
.GetFamilyName() ) );
1682 // If character is selected then it can be shown.
1683 SfxAbstractDialog
* pDlg
= pFact
->CreateSfxDialog( rView
.GetWindow(), aAllSet
,
1684 rView
.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP
);
1686 sal_uInt16 nResult
= pDlg
->Execute();
1687 if( nResult
== RET_OK
)
1689 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pCItem
, SfxStringItem
, SID_CHARMAP
, sal_False
);
1690 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pFontItem
, SvxFontItem
, SID_ATTR_CHAR_FONT
, sal_False
);
1693 aFont
.SetName( pFontItem
->GetFamilyName() );
1694 aFont
.SetStyleName( pFontItem
->GetStyleName() );
1695 aFont
.SetCharSet( pFontItem
->GetCharSet() );
1696 aFont
.SetPitch( pFontItem
->GetPitch() );
1701 sSym
= pCItem
->GetValue();
1702 aOpt
.SetSymbolFont(aFont
.GetName());
1703 SW_MOD()->ApplyUsrPref(aOpt
, &rView
);
1714 Outliner
* pOutliner
= pOLV
->GetOutliner();
1715 pOutliner
->SetUpdateMode(sal_False
);
1717 SfxItemSet
aOldSet( pOLV
->GetAttribs() );
1718 SfxItemSet
aFontSet( *aOldSet
.GetPool(),
1719 EE_CHAR_FONTINFO
, EE_CHAR_FONTINFO
,
1720 EE_CHAR_FONTINFO_CJK
, EE_CHAR_FONTINFO_CJK
,
1721 EE_CHAR_FONTINFO_CTL
, EE_CHAR_FONTINFO_CTL
,
1723 aFontSet
.Set( aOldSet
);
1726 pOLV
->InsertText( sSym
);
1728 // Attributing (set font)
1729 SfxItemSet
aSetFont( *aFontSet
.GetPool(), aFontSet
.GetRanges() );
1730 SvxFontItem
aFontItem (aFont
.GetFamily(), aFont
.GetName(),
1731 aFont
.GetStyleName(), aFont
.GetPitch(),
1734 sal_uInt16 nScriptBreak
= g_pBreakIt
->GetAllScriptsOfText( sSym
);
1735 if( SCRIPTTYPE_LATIN
& nScriptBreak
)
1736 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO
);
1737 if( SCRIPTTYPE_ASIAN
& nScriptBreak
)
1738 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO_CJK
);
1739 if( SCRIPTTYPE_COMPLEX
& nScriptBreak
)
1740 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO_CTL
);
1741 pOLV
->SetAttribs(aSetFont
);
1744 ESelection
aSel(pOLV
->GetSelection());
1745 aSel
.nStartPara
= aSel
.nEndPara
;
1746 aSel
.nStartPos
= aSel
.nEndPos
;
1747 pOLV
->SetSelection(aSel
);
1750 pOLV
->SetAttribs( aFontSet
);
1752 // From now on show it again
1753 pOutliner
->SetUpdateMode(sal_True
);
1756 rReq
.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP
), sSym
) );
1757 if(aFont
.GetName().Len())
1758 rReq
.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR
, aFont
.GetName() ) );
1763 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */