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: annotsh.cxx,v $
10 * $Revision: 1.7.82.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <hintids.hxx>
35 #include <tools/shl.hxx>
36 #include <com/sun/star/i18n/TransliterationModules.hpp>
37 #include <com/sun/star/i18n/TextConversionOption.hpp>
38 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <sfx2/objface.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <sfx2/bindings.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <sfx2/request.hxx>
45 #include <svx/spltitem.hxx>
46 #include <svx/orphitem.hxx>
47 #include <svx/brkitem.hxx>
48 #include <svx/widwitem.hxx>
49 #include <svx/kernitem.hxx>
50 #include <svx/escpitem.hxx>
51 #include <svx/lspcitem.hxx>
52 #include <svx/adjitem.hxx>
53 #include <svx/crsditem.hxx>
54 #include <svx/shdditem.hxx>
55 #include <svx/hyznitem.hxx>
56 #include <svx/udlnitem.hxx>
57 #include <svx/fontitem.hxx>
58 #include <svx/fhgtitem.hxx>
59 #include <svx/clipfmtitem.hxx>
60 #include <svtools/stritem.hxx>
61 #include <svtools/slstitm.hxx>
62 #include <svx/colritem.hxx>
63 #include <svx/wghtitem.hxx>
64 #include <svx/cntritem.hxx>
65 #include <svx/postitem.hxx>
66 #include <svx/frmdiritem.hxx>
67 #include <svx/svdoutl.hxx>
68 #include <svtools/whiter.hxx>
69 #include <svtools/cjkoptions.hxx>
70 #include <svtools/ctloptions.hxx>
71 #include <svtools/useroptions.hxx>
72 #include <vcl/msgbox.hxx>
73 #include <svx/flditem.hxx>
74 #include <svx/editstat.hxx>
75 #include <svx/hlnkitem.hxx>
76 #include <svx/htmlmode.hxx>
77 #include <svx/langitem.hxx>
78 #include <svx/unolingu.hxx>
79 #include <svx/scripttypeitem.hxx>
80 #include <svx/writingmodeitem.hxx>
83 #include <viewopt.hxx>
88 #include <swdtflvr.hxx>
89 #include <drwtxtsh.hxx>
90 #include <swmodule.hxx>
94 #include <docstat.hxx>
97 #include <globals.hrc>
99 #include <breakit.hxx>
100 #include "annotsh.hxx"
102 #include "PostItMgr.hxx"
103 #include "postit.hxx"
105 #include "swtypes.hxx"
107 #include <svx/svxdlg.hxx>
108 #include <svx/dialogs.hrc>
110 #include <svx/svxids.hrc>
111 #include <svtools/itempool.hxx>
112 #include <svx/outliner.hxx>
113 #include <svx/editeng.hxx>
114 #include <svx/editview.hxx>
116 #include <svtools/languageoptions.hxx>
117 #include <svx/langitem.hxx>
118 #include <svtools/langtab.hxx>
119 #include <svtools/slstitm.hxx>
122 #include <svtools/undo.hxx>
123 #include "swabstdlg.hxx" //CHINA001
124 #include "chrdlg.hrc" //CHINA001
128 #include <comphelper/processfactory.hxx>
130 #include <cppuhelper/bootstrap.hxx>
132 #include <langhelper.hxx>
134 using namespace ::com::sun::star
;
135 using namespace ::com::sun::star::uno
;
136 using namespace ::com::sun::star::beans
;
137 using namespace ::com::sun::star::i18n
;
139 #define SwAnnotationShell
141 #include <sfx2/msg.hxx>
142 #include <swslots.hxx>
144 SFX_IMPL_INTERFACE(SwAnnotationShell
, SfxShell
, SW_RES(STR_SHELLNAME_DRAW_TEXT
))
146 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_TEXT_TOOLBOX
));
147 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU
));
150 TYPEINIT1(SwAnnotationShell
,SfxShell
)
152 SwAnnotationShell::SwAnnotationShell( SwView
& r
)
155 SwWrtShell
&rSh
= rView
.GetWrtShell();
156 SetPool(rSh
.GetAttrPool().GetSecondaryPool());
159 SwAnnotationShell::~SwAnnotationShell()
163 SfxUndoManager
* SwAnnotationShell::GetUndoManager()
165 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
166 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
168 DBG_ASSERT(pPostItMgr
,"PostItMgr::Layout(): We are looping forever");
171 return &pPostItMgr
->GetActivePostIt()->Engine()->GetUndoManager();
174 void SwAnnotationShell::Exec( SfxRequest
&rReq
)
176 //TODO: clean this up!!!!
177 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
178 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
181 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
182 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
183 SfxItemSet
aNewAttr(*aEditAttr
.GetPool(), aEditAttr
.GetRanges());
185 sal_uInt16 nSlot
= rReq
.GetSlot();
186 sal_uInt16 nWhich
= GetPool().GetWhich(nSlot
);
187 const SfxItemSet
*pNewAttrs
= rReq
.GetArgs();
188 sal_uInt16 nEEWhich
= 0;
191 case SID_ATTR_CHAR_FONT
:
192 case SID_ATTR_CHAR_FONTHEIGHT
:
193 case SID_ATTR_CHAR_WEIGHT
:
194 case SID_ATTR_CHAR_POSTURE
:
196 SfxItemPool
* pSecondPool
= aEditAttr
.GetPool()->GetSecondaryPool();
198 pSecondPool
= aEditAttr
.GetPool();
199 SvxScriptSetItem
aSetItem( nSlot
, *pSecondPool
);
200 aSetItem
.PutItemForScriptType( pOLV
->GetSelectedScriptType(), pNewAttrs
->Get( nWhich
));
201 aNewAttr
.Put( aSetItem
.GetItemSet() );
205 case SID_ATTR_CHAR_COLOR
: nEEWhich
= EE_CHAR_COLOR
; break;
206 case SID_ATTR_CHAR_UNDERLINE
:
208 FontUnderline eFU
= ((const SvxUnderlineItem
&)aEditAttr
.Get(EE_CHAR_UNDERLINE
)).GetLineStyle();
209 aNewAttr
.Put(SvxUnderlineItem(eFU
== UNDERLINE_SINGLE
? UNDERLINE_NONE
: UNDERLINE_SINGLE
, EE_CHAR_UNDERLINE
));
212 case SID_ATTR_CHAR_OVERLINE
:
214 FontUnderline eFO
= ((const SvxOverlineItem
&)aEditAttr
.Get(EE_CHAR_OVERLINE
)).GetLineStyle();
215 aNewAttr
.Put(SvxOverlineItem(eFO
== UNDERLINE_SINGLE
? UNDERLINE_NONE
: UNDERLINE_SINGLE
, EE_CHAR_OVERLINE
));
218 case SID_ATTR_CHAR_CONTOUR
: nEEWhich
= EE_CHAR_OUTLINE
; break;
219 case SID_ATTR_CHAR_SHADOWED
: nEEWhich
= EE_CHAR_SHADOW
; break;
220 case SID_ATTR_CHAR_STRIKEOUT
: nEEWhich
= EE_CHAR_STRIKEOUT
; break;
221 case SID_ATTR_CHAR_WORDLINEMODE
: nEEWhich
= EE_CHAR_WLM
; break;
222 case SID_ATTR_CHAR_RELIEF
: nEEWhich
= EE_CHAR_RELIEF
; break;
223 case SID_ATTR_CHAR_LANGUAGE
: nEEWhich
= EE_CHAR_LANGUAGE
;break;
224 case SID_ATTR_CHAR_KERNING
: nEEWhich
= EE_CHAR_KERNING
; break;
225 case SID_ATTR_CHAR_SCALEWIDTH
: nEEWhich
= EE_CHAR_FONTWIDTH
; break;
226 case SID_ATTR_CHAR_AUTOKERN
: nEEWhich
= EE_CHAR_PAIRKERNING
; break;
227 case SID_ATTR_CHAR_ESCAPEMENT
: nEEWhich
= EE_CHAR_ESCAPEMENT
; break;
228 case SID_ATTR_PARA_ADJUST_LEFT
:
229 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_LEFT
, EE_PARA_JUST
));
231 case SID_ATTR_PARA_ADJUST_CENTER
:
232 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_CENTER
, EE_PARA_JUST
));
234 case SID_ATTR_PARA_ADJUST_RIGHT
:
235 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_RIGHT
, EE_PARA_JUST
));
237 case SID_ATTR_PARA_ADJUST_BLOCK
:
238 aNewAttr
.Put(SvxAdjustItem(SVX_ADJUST_BLOCK
, EE_PARA_JUST
));
241 case SID_ATTR_PARA_LINESPACE_10
:
243 SvxLineSpacingItem
aItem(SVX_LINESPACE_ONE_LINE
, EE_PARA_SBL
);
244 aItem
.SetPropLineSpace(100);
248 case SID_ATTR_PARA_LINESPACE_15
:
250 SvxLineSpacingItem
aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES
, EE_PARA_SBL
);
251 aItem
.SetPropLineSpace(150);
255 case SID_ATTR_PARA_LINESPACE_20
:
257 SvxLineSpacingItem
aItem(SVX_LINESPACE_TWO_LINES
, EE_PARA_SBL
);
258 aItem
.SetPropLineSpace(200);
264 Outliner
* pOutliner
= pOLV
->GetOutliner();
267 ULONG nParaCount
= pOutliner
->GetParagraphCount();
269 pOLV
->SelectRange(0L, USHORT(nParaCount
) );
273 case FN_FORMAT_RESET
:
275 pPostItMgr
->GetActivePostIt()->ResetAttributes();
279 case FN_SET_SUPER_SCRIPT
:
281 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
282 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
283 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
285 if( eEsc
== SVX_ESCAPEMENT_SUPERSCRIPT
)
286 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
288 aItem
.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT
);
289 aNewAttr
.Put( aItem
, EE_CHAR_ESCAPEMENT
);
292 case FN_SET_SUB_SCRIPT
:
294 SvxEscapementItem
aItem(EE_CHAR_ESCAPEMENT
);
295 SvxEscapement eEsc
= (SvxEscapement
) ( (const SvxEscapementItem
&)
296 aEditAttr
.Get( EE_CHAR_ESCAPEMENT
) ).GetEnumValue();
298 if( eEsc
== SVX_ESCAPEMENT_SUBSCRIPT
)
299 aItem
.SetEscapement( SVX_ESCAPEMENT_OFF
);
301 aItem
.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT
);
302 aNewAttr
.Put( aItem
, EE_CHAR_ESCAPEMENT
);
305 case SID_HYPERLINK_SETLINK
:
307 const SfxPoolItem
* pItem
= 0;
309 pNewAttrs
->GetItemState(nSlot
, sal_False
, &pItem
);
313 const SvxHyperlinkItem
& rHLinkItem
= *(const SvxHyperlinkItem
*)pItem
;
314 SvxURLField
aFld(rHLinkItem
.GetURL(), rHLinkItem
.GetName(), SVXURLFORMAT_APPDEFAULT
);
315 aFld
.SetTargetFrame(rHLinkItem
.GetTargetFrame());
317 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
319 if (pFieldItem
&& pFieldItem
->GetField()->ISA(SvxURLField
))
321 // Feld selektieren, so dass es beim Insert geloescht wird
322 ESelection aSel
= pOLV
->GetSelection();
324 pOLV
->SetSelection(aSel
);
326 if (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
)
327 pOLV
->InsertField(SvxFieldItem(aFld
, EE_FEATURE_FIELD
));
331 case FN_INSERT_SOFT_HYPHEN
:
332 case FN_INSERT_HARDHYPHEN
:
333 case FN_INSERT_HARD_SPACE
:
334 case SID_INSERT_RLM
:
335 case SID_INSERT_LRM
:
336 case SID_INSERT_ZWNBSP
:
337 case SID_INSERT_ZWSP
:
339 sal_Unicode cIns
= 0;
340 switch(rReq
.GetSlot())
342 case FN_INSERT_SOFT_HYPHEN
: cIns
= CHAR_SOFTHYPHEN
; break;
343 case FN_INSERT_HARDHYPHEN
: cIns
= CHAR_HARDHYPHEN
; break;
344 case FN_INSERT_HARD_SPACE
: cIns
= CHAR_HARDBLANK
; break;
345 case SID_INSERT_RLM
: cIns
= CHAR_RLM
; break;
346 case SID_INSERT_LRM
: cIns
= CHAR_LRM
; break;
347 case SID_INSERT_ZWSP
: cIns
= CHAR_ZWSP
; break;
348 case SID_INSERT_ZWNBSP
: cIns
= CHAR_ZWNBSP
; break;
350 pOLV
->InsertText( String(cIns
), TRUE
);
356 if (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
)
360 case FN_INSERT_STRING
:
362 const SfxPoolItem
* pItem
= 0;
364 pNewAttrs
->GetItemState(nSlot
, FALSE
, &pItem
);
365 if (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
)
366 pOLV
->InsertText(((const SfxStringItem
*)pItem
)->GetValue());
370 case FN_FORMAT_FOOTNOTE_DLG
:
372 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
373 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
375 VclAbstractDialog
* pDlg
= pFact
->CreateSwFootNoteOptionDlg( rView
.GetWindow(), rView
.GetWrtShell(), DLG_DOC_FOOTNOTE
);
376 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
381 case FN_NUMBERING_OUTLINE_DLG
:
383 SfxItemSet
aTmp(GetPool(), FN_PARAM_1
, FN_PARAM_1
);
384 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
385 DBG_ASSERT(pFact
, "Dialogdiet fail!");
386 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwTabDialog( DLG_TAB_OUTLINE
,
387 rView
.GetWindow(), &aTmp
, rView
.GetWrtShell());
388 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
394 case SID_OPEN_XML_FILTERSETTINGS
:
398 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY
);
404 catch( uno::Exception
& )
410 case FN_WORDCOUNT_DIALOG
:
412 SwWrtShell
&rSh
= rView
.GetWrtShell();
414 SwDocStat
aDocStat( rSh
.getIDocumentStatistics()->GetDocStat() );
416 SwWait
aWait( *rView
.GetDocShell(), TRUE
);
418 rSh
.CountWords( aCurr
);
419 rSh
.UpdateDocStat( aDocStat
);
423 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
424 DBG_ASSERT(pFact
, "Dialogdiet fail!");
425 AbstractSwWordCountDialog
* pDialog
= pFact
->CreateSwWordCountDialog( rView
.GetWindow() );
426 pDialog
->SetValues(aCurr
, aDocStat
);
433 const SfxItemSet
* pArgs
= rReq
.GetArgs();
438 SwView* pView = &GetView();
439 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
440 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
442 SfxItemSet
aDlgAttr(GetPool(), EE_ITEMS_START
, EE_ITEMS_END
);
444 // util::Language gibts an der EditEngine nicht! Daher nicht im Set.
446 aDlgAttr
.Put( aEditAttr
);
447 aDlgAttr
.Put( SvxKerningItem(0, RES_CHRATR_KERNING
) );
449 //CHINA001 SwCharDlg* pDlg = new SwCharDlg(pView->GetWindow(), *pView, aDlgAttr, 0, sal_True);
450 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();//CHINA001
451 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");//CHINA001
453 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwCharDlg( rView
.GetWindow(), rView
, aDlgAttr
, DLG_CHAR
,0, sal_True
);
454 DBG_ASSERT(pDlg
, "Dialogdiet fail!");//CHINA001
455 USHORT nRet
= pDlg
->Execute();
458 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
459 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
466 aNewAttr
.Put(*pArgs
);
471 const SfxItemSet
* pArgs
= rReq
.GetArgs();
476 SwView* pView = &GetView();
477 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
478 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
480 SfxItemSet
aDlgAttr(GetPool(),
481 EE_ITEMS_START
, EE_ITEMS_END
,
482 SID_ATTR_PARA_HYPHENZONE
, SID_ATTR_PARA_HYPHENZONE
,
483 SID_ATTR_PARA_SPLIT
, SID_ATTR_PARA_SPLIT
,
484 SID_ATTR_PARA_WIDOWS
, SID_ATTR_PARA_WIDOWS
,
485 SID_ATTR_PARA_ORPHANS
, SID_ATTR_PARA_ORPHANS
,
488 aDlgAttr
.Put(aEditAttr
);
491 aDlgAttr
.Put( SvxHyphenZoneItem( sal_False
, RES_PARATR_HYPHENZONE
) );
492 aDlgAttr
.Put( SvxFmtBreakItem( SVX_BREAK_NONE
, RES_BREAK
) );
493 aDlgAttr
.Put( SvxFmtSplitItem( sal_True
, RES_PARATR_SPLIT
) );
494 aDlgAttr
.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS
) );
495 aDlgAttr
.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS
) );
497 //CHINA001 SwParaDlg* pDlg = new SwParaDlg(GetView().GetWindow(), GetView(), aDlgAttr, DLG_STD, 0, sal_True);
499 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();//CHINA001
500 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");//CHINA001
502 SfxAbstractTabDialog
* pDlg
= pFact
->CreateSwParaDlg( rView
.GetWindow(), rView
, aDlgAttr
,DLG_STD
, DLG_PARA
, 0, sal_True
);
503 DBG_ASSERT(pDlg
, "Dialogdiet fail!");//CHINA001
504 USHORT nRet
= pDlg
->Execute();
507 rReq
.Done( *( pDlg
->GetOutputItemSet() ) );
508 aNewAttr
.Put(*pDlg
->GetOutputItemSet());
515 aNewAttr
.Put(*pArgs
);
519 case SID_AUTOSPELL_CHECK
:
521 rView
.ExecuteSlot(rReq
);
524 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
525 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
527 sal_Bool bLeftToRight
= nSlot
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
529 const SfxPoolItem
* pPoolItem
;
530 if( pNewAttrs
&& SFX_ITEM_SET
== pNewAttrs
->GetItemState( nSlot
, TRUE
, &pPoolItem
) )
532 if( !( (SfxBoolItem
*)pPoolItem
)->GetValue() )
533 bLeftToRight
= !bLeftToRight
;
535 SfxItemSet
aAttr( *aNewAttr
.GetPool(),
536 EE_PARA_JUST
, EE_PARA_JUST
,
537 EE_PARA_WRITINGDIR
, EE_PARA_WRITINGDIR
,
540 USHORT nAdjust
= SVX_ADJUST_LEFT
;
541 if( SFX_ITEM_ON
== aEditAttr
.GetItemState(EE_PARA_JUST
, TRUE
, &pPoolItem
) )
542 nAdjust
= ( (SvxAdjustItem
*)pPoolItem
)->GetEnumValue();
546 aAttr
.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP
, EE_PARA_WRITINGDIR
) );
547 if( nAdjust
== SVX_ADJUST_RIGHT
)
548 aAttr
.Put( SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
) );
552 aAttr
.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP
, EE_PARA_WRITINGDIR
) );
553 if( nAdjust
== SVX_ADJUST_LEFT
)
554 aAttr
.Put( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
556 pOLV
->SetAttribs(aAttr
);
561 if(nEEWhich
&& pNewAttrs
)
562 aNewAttr
.Put(pNewAttrs
->Get(nWhich
), nEEWhich
);
565 Rectangle aOutRect
= pOLV
->GetOutputArea();
566 if (aNullRect
!= aOutRect
)
567 pOLV
->SetAttribs(aNewAttr
);
569 rView
.GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
570 if ( pOLV
->GetOutliner()->IsModified() )
571 rView
.GetWrtShell().SetModified();
575 void SwAnnotationShell::GetState(SfxItemSet
& rSet
)
577 //TODO: clean this up!!!
578 // FN_SET_SUPER_SCRIPT
579 //SID_ATTR_PARA_ADJUST
580 //SID_ATTR_PARA_ADJUST_BLOCK
582 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
583 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
586 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
587 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
589 SfxWhichIter
aIter(rSet
);
590 sal_uInt16 nWhich
= aIter
.FirstWhich();
593 sal_uInt16 nEEWhich
= 0;
594 USHORT nSlotId
= GetPool().GetSlotId( nWhich
);
597 case SID_ATTR_CHAR_FONT
:
598 case SID_ATTR_CHAR_FONTHEIGHT
:
599 case SID_ATTR_CHAR_WEIGHT
:
600 case SID_ATTR_CHAR_POSTURE
:
604 USHORT nScriptType
= pOLV
->GetSelectedScriptType();
605 SfxItemPool
* pSecondPool
= aEditAttr
.GetPool()->GetSecondaryPool();
607 pSecondPool
= aEditAttr
.GetPool();
608 SvxScriptSetItem
aSetItem( nSlotId
, *pSecondPool
);
609 aSetItem
.GetItemSet().Put( aEditAttr
, FALSE
);
610 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScriptType
);
612 rSet
.Put( *pI
, nWhich
);
614 rSet
.InvalidateItem( nWhich
);
617 rSet
.InvalidateItem( nWhich
);
620 case SID_ATTR_CHAR_COLOR
: nEEWhich
= EE_CHAR_COLOR
; break;
621 case SID_ATTR_CHAR_UNDERLINE
: nEEWhich
= EE_CHAR_UNDERLINE
;break;
622 case SID_ATTR_CHAR_OVERLINE
: nEEWhich
= EE_CHAR_OVERLINE
;break;
623 case SID_ATTR_CHAR_CONTOUR
: nEEWhich
= EE_CHAR_OUTLINE
; break;
624 case SID_ATTR_CHAR_SHADOWED
: nEEWhich
= EE_CHAR_SHADOW
;break;
625 case SID_ATTR_CHAR_STRIKEOUT
: nEEWhich
= EE_CHAR_STRIKEOUT
;break;
626 case SID_ATTR_CHAR_LANGUAGE
: nEEWhich
= EE_CHAR_LANGUAGE
;break;
627 case FN_SET_SUPER_SCRIPT
:
628 case FN_SET_SUB_SCRIPT
:
631 const SfxPoolItem
*pEscItem
= 0;
632 if (nWhich
==FN_SET_SUPER_SCRIPT
)
633 nEsc
= SVX_ESCAPEMENT_SUPERSCRIPT
;
635 nEsc
= SVX_ESCAPEMENT_SUBSCRIPT
;
638 pEscItem
= &aEditAttr
.Get( EE_CHAR_ESCAPEMENT
);
640 if( nEsc
== ((const SvxEscapementItem
*)pEscItem
)->GetEnumValue() )
641 rSet
.Put( SfxBoolItem( nWhich
, sal_True
));
643 rSet
.InvalidateItem( nWhich
);
646 case SID_ATTR_PARA_ADJUST_LEFT
:
647 case SID_ATTR_PARA_ADJUST_RIGHT
:
648 case SID_ATTR_PARA_ADJUST_CENTER
:
649 case SID_ATTR_PARA_ADJUST_BLOCK
:
651 const SfxPoolItem
*pAdjust
= 0;
654 if (nWhich
==SID_ATTR_PARA_ADJUST_LEFT
)
655 eAdjust
= SVX_ADJUST_LEFT
;
657 if (nWhich
==SID_ATTR_PARA_ADJUST_RIGHT
)
658 eAdjust
= SVX_ADJUST_RIGHT
;
660 if (nWhich
==SID_ATTR_PARA_ADJUST_CENTER
)
661 eAdjust
= SVX_ADJUST_CENTER
;
663 if (nWhich
==SID_ATTR_PARA_ADJUST_BLOCK
)
664 eAdjust
= SVX_ADJUST_BLOCK
;
667 aEditAttr
.GetItemState( EE_PARA_JUST
, sal_False
, &pAdjust
);
669 if( !pAdjust
|| IsInvalidItem( pAdjust
))
670 rSet
.InvalidateItem( nSlotId
), nSlotId
= 0;
673 if ( eAdjust
== ((const SvxAdjustItem
*)pAdjust
)->GetAdjust())
674 rSet
.Put( SfxBoolItem( nWhich
, sal_True
));
676 rSet
.InvalidateItem( nWhich
);
680 case SID_ATTR_PARA_LINESPACE_10
:
681 case SID_ATTR_PARA_LINESPACE_15
:
682 case SID_ATTR_PARA_LINESPACE_20
:
684 const SfxPoolItem
*pLSpace
= 0;
687 if (nWhich
==SID_ATTR_PARA_LINESPACE_10
)
690 if (nWhich
==SID_ATTR_PARA_LINESPACE_15
)
693 if (nWhich
==SID_ATTR_PARA_LINESPACE_20
)
697 aEditAttr
.GetItemState( EE_PARA_SBL
, sal_False
, &pLSpace
);
699 if( !pLSpace
|| IsInvalidItem( pLSpace
))
700 rSet
.InvalidateItem( nSlotId
), nSlotId
= 0;
703 if( nLSpace
== ((const SvxLineSpacingItem
*)pLSpace
)->GetPropLineSpace() )
704 rSet
.Put( SfxBoolItem( nWhich
, sal_True
));
706 rSet
.InvalidateItem( nWhich
);
710 case SID_AUTOSPELL_CHECK
:
712 const SfxPoolItem
* pState
= rView
.GetSlotState(nWhich
);
714 rSet
.Put(SfxBoolItem(nWhich
, ((const SfxBoolItem
*)pState
)->GetValue()));
716 rSet
.DisableItem( nWhich
);
719 case SID_ATTR_PARA_LEFT_TO_RIGHT
:
720 case SID_ATTR_PARA_RIGHT_TO_LEFT
:
722 if ( !SvtLanguageOptions().IsCTLFontEnabled() )
723 rSet
.DisableItem( nWhich
);
726 if(pOLV
->GetOutliner() && pOLV
->GetOutliner()->IsVertical())
727 rSet
.DisableItem( nWhich
);
731 switch( ( ( (SvxFrameDirectionItem
&) aEditAttr
.Get( EE_PARA_WRITINGDIR
) ) ).GetValue() )
733 case FRMDIR_HORI_LEFT_TOP
:
735 bFlag
= nWhich
== SID_ATTR_PARA_LEFT_TO_RIGHT
;
736 rSet
.Put( SfxBoolItem( nWhich
, bFlag
));
739 case FRMDIR_HORI_RIGHT_TOP
:
741 bFlag
= nWhich
!= SID_ATTR_PARA_LEFT_TO_RIGHT
;
742 rSet
.Put( SfxBoolItem( nWhich
, bFlag
));
750 case SID_INSERT_RLM
:
751 case SID_INSERT_LRM
:
752 case SID_INSERT_ZWNBSP
:
753 case SID_INSERT_ZWSP
:
755 SvtCTLOptions aCTLOptions
;
756 sal_Bool bEnabled
= aCTLOptions
.IsCTLFontEnabled();
757 rView
.GetViewFrame()->GetBindings().SetVisibleState( nWhich
, bEnabled
);
759 rSet
.DisableItem(nWhich
);
763 rSet
.InvalidateItem( nWhich
);
768 rSet
.Put(aEditAttr
.Get(nEEWhich
, sal_True
), nWhich
);
770 if (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
)
771 rSet
.DisableItem( nWhich
);
773 nWhich
= aIter
.NextWhich();
777 void SwAnnotationShell::ExecSearch(SfxRequest
& rReq
, BOOL bNoMessage
)
779 rView
.ExecSearch(rReq
,bNoMessage
);
782 void SwAnnotationShell::StateSearch(SfxItemSet
&rSet
)
784 rView
.StateSearch(rSet
);
787 void SwAnnotationShell::ExecClpbrd(SfxRequest
&rReq
)
789 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
790 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
793 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
794 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
795 SfxItemSet
aNewAttr(*aEditAttr
.GetPool(), aEditAttr
.GetRanges());
797 long aOldHeight
= pPostItMgr
->GetActivePostIt()->GetPostItTextHeight();
798 sal_uInt16 nSlot
= rReq
.GetSlot();
808 if (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
)
811 case FN_PASTESPECIAL
:
813 if (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
)
815 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
816 SfxAbstractPasteDialog
* pDlg
= pFact
->CreatePasteDialog( &rView
.GetEditWin() );
818 pDlg
->Insert( SOT_FORMAT_STRING
, aEmptyStr
);
819 pDlg
->Insert( SOT_FORMAT_RTF
, aEmptyStr
);
821 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView
.GetEditWin() ) );
823 ULONG nFormat
= pDlg
->GetFormat( aDataHelper
.GetTransferable() );
827 if (nFormat
== SOT_FORMAT_STRING
)
830 pOLV
->PasteSpecial();
836 case SID_CLIPBOARD_FORMAT_ITEMS
:
839 const SfxPoolItem
* pItem
;
840 if ( rReq
.GetArgs() && rReq
.GetArgs()->GetItemState(nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
&&
841 pItem
->ISA(SfxUInt32Item
) )
843 nFormat
= ((const SfxUInt32Item
*)pItem
)->GetValue();
848 if (SOT_FORMAT_STRING
== nFormat
)
851 pOLV
->PasteSpecial();
856 pPostItMgr
->GetActivePostIt()->ResizeIfNeccessary(aOldHeight
,pPostItMgr
->GetActivePostIt()->GetPostItTextHeight());
859 void SwAnnotationShell::StateClpbrd(SfxItemSet
&rSet
)
861 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
862 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
864 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
866 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView
.GetEditWin() ) );
867 bool bPastePossible
= ( aDataHelper
.HasFormat( SOT_FORMAT_STRING
) || aDataHelper
.HasFormat( SOT_FORMAT_RTF
) );
868 bPastePossible
= bPastePossible
&& (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
);
870 SfxWhichIter
aIter(rSet
);
871 sal_uInt16 nWhich
= aIter
.FirstWhich();
879 if ( (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
) || !pOLV
->HasSelection() )
880 rSet
.DisableItem( nWhich
);
884 if( !pOLV
->HasSelection() )
885 rSet
.DisableItem( nWhich
);
889 case FN_PASTESPECIAL
:
891 if( !bPastePossible
)
892 rSet
.DisableItem( nWhich
);
895 case SID_CLIPBOARD_FORMAT_ITEMS
:
897 if ( bPastePossible
)
899 SvxClipboardFmtItem
aFormats( SID_CLIPBOARD_FORMAT_ITEMS
);
900 if ( aDataHelper
.HasFormat( SOT_FORMAT_RTF
) )
901 aFormats
.AddClipbrdFormat( SOT_FORMAT_RTF
);
902 //if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
903 aFormats
.AddClipbrdFormat( SOT_FORMAT_STRING
);
904 rSet
.Put( aFormats
);
907 rSet
.DisableItem( nWhich
);
911 nWhich
= aIter
.NextWhich();
915 void SwAnnotationShell::StateStatusLine(SfxItemSet
&rSet
)
917 SfxWhichIter
aIter( rSet
);
918 USHORT nWhich
= aIter
.FirstWhich();
924 case FN_STAT_SELMODE
:
926 rSet
.Put(SfxUInt16Item(FN_STAT_SELMODE
, 0));
927 rSet
.DisableItem( nWhich
);
930 case FN_STAT_TEMPLATE
:
932 rSet
.DisableItem( nWhich
);
936 nWhich
= aIter
.NextWhich();
940 void SwAnnotationShell::StateInsert(SfxItemSet
&rSet
)
942 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
943 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
946 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
947 SfxWhichIter
aIter(rSet
);
948 sal_uInt16 nWhich
= aIter
.FirstWhich();
954 case SID_HYPERLINK_GETLINK
:
956 SvxHyperlinkItem aHLinkItem
;
957 aHLinkItem
.SetInsertMode(HLINK_FIELD
);
959 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
963 const SvxFieldData
* pField
= pFieldItem
->GetField();
965 if (pField
->ISA(SvxURLField
))
967 aHLinkItem
.SetName(((const SvxURLField
*) pField
)->GetRepresentation());
968 aHLinkItem
.SetURL(((const SvxURLField
*) pField
)->GetURL());
969 aHLinkItem
.SetTargetFrame(((const SvxURLField
*) pField
)->GetTargetFrame());
974 String
sSel(pOLV
->GetSelected());
976 sSel
.EraseTrailingChars();
977 aHLinkItem
.SetName(sSel
);
980 sal_uInt16 nHtmlMode
= ::GetHtmlMode(rView
.GetDocShell());
981 aHLinkItem
.SetInsertMode((SvxLinkInsertMode
)(aHLinkItem
.GetInsertMode() |
982 ((nHtmlMode
& HTMLMODE_ON
) != 0 ? HLINK_HTMLMODE
: 0)));
984 rSet
.Put(aHLinkItem
);
989 if (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
)
990 rSet
.DisableItem( nWhich
);
992 nWhich
= aIter
.NextWhich();
997 void SwAnnotationShell::NoteExec(SfxRequest
&rReq
)
999 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1003 sal_uInt16 nSlot
= rReq
.GetSlot();
1008 case FN_DELETE_COMMENT
:
1009 case FN_DELETE_NOTE
:
1010 if ( pPostItMgr
->GetActivePostIt() )
1011 pPostItMgr
->GetActivePostIt()->ExecuteCommand(nSlot
);
1013 case FN_DELETE_ALL_NOTES
:
1014 pPostItMgr
->Delete();
1016 case FN_DELETE_NOTE_AUTHOR
:
1018 SFX_REQUEST_ARG( rReq
, pItem
, SfxStringItem
, nSlot
, FALSE
);
1020 pPostItMgr
->Delete( pItem
->GetValue() );
1025 if ( Mgr()->GetActivePostIt() == this )
1027 Mgr()->SetActivePostIt(0);
1028 // put the cursor back into the document
1034 case FN_HIDE_ALL_NOTES
:
1037 case FN_HIDE_NOTE_AUTHOR
:
1039 SFX_REQUEST_ARG( rReq
, pItem
, SfxStringItem
, nSlot
, FALSE
);
1041 pPostItMgr
->Hide( pItem
->GetValue() );
1046 void SwAnnotationShell::GetNoteState(SfxItemSet
&rSet
)
1048 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1049 SfxWhichIter
aIter(rSet
);
1050 sal_uInt16 nWhich
= aIter
.FirstWhich();
1053 USHORT nSlotId
= GetPool().GetSlotId( nWhich
);
1057 case FN_DELETE_NOTE
:
1058 case FN_DELETE_NOTE_AUTHOR
:
1059 case FN_DELETE_ALL_NOTES
:
1061 case FN_HIDE_NOTE_AUTHOR
:
1062 case FN_HIDE_ALL_NOTES
:
1064 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() || !pPostItMgr
->GetActivePostIt()->ISA(SwPostIt
))
1065 rSet
.DisableItem(nWhich
);
1068 case FN_DELETE_COMMENT
:
1070 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() ) //|| !pPostItMgr->GetActivePostIt()->ISA(SwRedComment))
1071 rSet
.DisableItem(nWhich
);
1076 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() || !pPostItMgr
->GetActivePostIt()->ISA(SwPostIt
))
1077 rSet
.DisableItem(nWhich
);
1080 SvtUserOptions aUserOpt
;
1082 if( !(sAuthor
= aUserOpt
.GetFullName()).Len())
1083 if( !(sAuthor
= aUserOpt
.GetID()).Len() )
1084 sAuthor
= String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR
));
1085 if (sAuthor
== pPostItMgr
->GetActivePostIt()->GetAuthor())
1086 rSet
.DisableItem(nWhich
);
1091 rSet
.InvalidateItem( nWhich
);
1095 if (pPostItMgr
->GetActivePostIt())
1097 if ( (pPostItMgr
->GetActivePostIt()->IsProtected()) &&
1098 ( (nSlotId
==FN_DELETE_NOTE
) || (nSlotId
==FN_REPLY
) ) )
1099 rSet
.DisableItem( nWhich
);
1101 nWhich
= aIter
.NextWhich();
1105 void SwAnnotationShell::ExecLingu(SfxRequest
&rReq
)
1107 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1108 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1111 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
1112 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
1113 sal_uInt16 nSlot
= rReq
.GetSlot();
1114 SwWrtShell
&rSh
= rView
.GetWrtShell();
1115 bool bRestoreSelection
= false;
1116 ESelection aOldSelection
;
1120 case SID_LANGUAGE_STATUS
:
1122 aOldSelection
= pOLV
->GetSelection();
1123 if (!pOLV
->GetEditView().HasSelection())
1125 bRestoreSelection
= true;
1126 pOLV
->GetEditView().SelectCurrentWord();
1129 bRestoreSelection
= SwLangHelper::SetLanguageStatus(pOLV
,rReq
,rView
,rSh
);
1132 case FN_THESAURUS_DLG
:
1134 pOLV
->StartThesaurus();
1137 case SID_HANGUL_HANJA_CONVERSION
:
1138 pOLV
->StartTextConversion( LANGUAGE_KOREAN
, LANGUAGE_KOREAN
, NULL
,
1139 i18n::TextConversionOption::CHARACTER_BY_CHARACTER
, sal_True
, sal_False
);
1142 case SID_CHINESE_CONVERSION
:
1144 //open ChineseTranslationDialog
1145 Reference
< XComponentContext
> xContext(
1146 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1149 Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager() );
1152 Reference
< ui::dialogs::XExecutableDialog
> xDialog(
1153 xMCF
->createInstanceWithContext(
1154 rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
1155 , xContext
), UNO_QUERY
);
1156 Reference
< lang::XInitialization
> xInit( xDialog
, UNO_QUERY
);
1159 // initialize dialog
1160 Reference
< awt::XWindow
> xDialogParentWindow(0);
1161 Sequence
<Any
> aSeq(1);
1162 Any
* pArray
= aSeq
.getArray();
1163 PropertyValue aParam
;
1164 aParam
.Name
= rtl::OUString::createFromAscii("ParentWindow");
1165 aParam
.Value
<<= makeAny(xDialogParentWindow
);
1166 pArray
[0] <<= makeAny(aParam
);
1167 xInit
->initialize( aSeq
);
1170 sal_Int16 nDialogRet
= xDialog
->execute();
1171 if( RET_OK
== nDialogRet
)
1173 //get some parameters from the dialog
1174 sal_Bool bToSimplified
= sal_True
;
1175 sal_Bool bUseVariants
= sal_True
;
1176 sal_Bool bCommonTerms
= sal_True
;
1177 Reference
< beans::XPropertySet
> xProp( xDialog
, UNO_QUERY
);
1182 xProp
->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified
;
1183 xProp
->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants
;
1184 xProp
->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms
;
1191 //execute translation
1192 sal_Int16 nSourceLang
= bToSimplified
? LANGUAGE_CHINESE_TRADITIONAL
: LANGUAGE_CHINESE_SIMPLIFIED
;
1193 sal_Int16 nTargetLang
= bToSimplified
? LANGUAGE_CHINESE_SIMPLIFIED
: LANGUAGE_CHINESE_TRADITIONAL
;
1194 sal_Int32 nOptions
= bUseVariants
? i18n::TextConversionOption::USE_CHARACTER_VARIANTS
: 0;
1196 nOptions
= nOptions
| i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
1198 Font aTargetFont
= pOLV
->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT
,
1199 nTargetLang
, DEFAULTFONT_FLAGS_ONLYONE
);
1201 pOLV
->StartTextConversion( nSourceLang
, nTargetLang
, &aTargetFont
, nOptions
, sal_False
, sal_False
);
1204 Reference
< lang::XComponent
> xComponent( xDialog
, UNO_QUERY
);
1205 if( xComponent
.is() )
1206 xComponent
->dispose();
1213 if (bRestoreSelection
)
1215 // restore selection
1216 pOLV
->GetEditView().SetSelection( aOldSelection
);
1220 void SwAnnotationShell::GetLinguState(SfxItemSet
&rSet
)
1222 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1223 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1226 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
1227 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
1229 SfxWhichIter
aIter(rSet
);
1230 sal_uInt16 nWhich
= aIter
.FirstWhich();
1235 case SID_LANGUAGE_STATUS
:
1237 SwLangHelper::GetLanguageStatus(pOLV
,rSet
);
1240 // disable "Thesaurus" if the language is not supported
1241 case FN_THESAURUS_DLG
:
1243 const SfxPoolItem
&rItem
= rView
.GetWrtShell().GetDoc()->GetDefault(
1244 GetWhichOfScript( RES_CHRATR_LANGUAGE
,
1245 GetI18NScriptTypeOfLanguage( (USHORT
)GetAppLanguage())) );
1246 LanguageType nLang
= ((const SvxLanguageItem
&)
1247 rItem
).GetLanguage();
1248 uno::Reference
< linguistic2::XThesaurus
> xThes( ::GetThesaurus() );
1249 if (!xThes
.is() || nLang
== LANGUAGE_NONE
||
1250 !xThes
->hasLocale( SvxCreateLocale( nLang
) ))
1251 rSet
.DisableItem( FN_THESAURUS_DLG
);
1254 case SID_HANGUL_HANJA_CONVERSION
:
1255 case SID_CHINESE_CONVERSION
:
1257 if (!SvtCJKOptions().IsAnyEnabled())
1259 rView
.GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
1260 rSet
.DisableItem(nWhich
);
1263 rView
.GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
1268 if (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
)
1269 rSet
.DisableItem( nWhich
);
1271 nWhich
= aIter
.NextWhich();
1275 void SwAnnotationShell::ExecTransliteration(SfxRequest
&rReq
)
1277 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1278 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1281 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
1283 using namespace ::com::sun::star::i18n
;
1285 sal_uInt32 nMode
= 0;
1287 switch( rReq
.GetSlot() )
1289 case SID_TRANSLITERATE_UPPER
:
1290 nMode
= TransliterationModules_LOWERCASE_UPPERCASE
;
1292 case SID_TRANSLITERATE_LOWER
:
1293 nMode
= TransliterationModules_UPPERCASE_LOWERCASE
;
1295 case SID_TRANSLITERATE_HALFWIDTH
:
1296 nMode
= TransliterationModules_FULLWIDTH_HALFWIDTH
;
1298 case SID_TRANSLITERATE_FULLWIDTH
:
1299 nMode
= TransliterationModules_HALFWIDTH_FULLWIDTH
;
1301 case SID_TRANSLITERATE_HIRAGANA
:
1302 nMode
= TransliterationModules_KATAKANA_HIRAGANA
;
1304 case SID_TRANSLITERATE_KATAGANA
:
1305 nMode
= TransliterationModules_HIRAGANA_KATAKANA
;
1309 ASSERT(!this, "falscher Dispatcher");
1314 pOLV
->TransliterateText( nMode
);
1319 void SwAnnotationShell::ExecUndo(SfxRequest
&rReq
)
1321 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1322 SfxUndoManager
* pUndoManager
= GetUndoManager();
1323 SwWrtShell
&rSh
= rView
.GetWrtShell();
1325 long aOldHeight
= rView
.GetPostItMgr()->GetActivePostIt() ? rView
.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight() : 0;
1327 USHORT nId
= rReq
.GetSlot();
1328 sal_uInt16 nCnt
= 1;
1329 const SfxPoolItem
* pItem
=0;
1330 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nId
, FALSE
, &pItem
) )
1331 nCnt
= ((SfxUInt16Item
*)pItem
)->GetValue();
1338 sal_uInt16 nCount
= pUndoManager
->GetUndoActionCount();
1339 sal_uInt16 nSteps
= nCnt
;
1340 if ( nCount
< nCnt
)
1342 nCnt
= nCnt
- nCount
;
1349 pUndoManager
->Undo(0);
1353 rSh
.Do( SwWrtShell::UNDO
, nCnt
);
1362 sal_uInt16 nCount
= pUndoManager
->GetRedoActionCount();
1363 sal_uInt16 nSteps
= nCnt
;
1364 if ( nCount
< nCnt
)
1366 nCnt
= nCnt
- nCount
;
1373 pUndoManager
->Redo(0);
1377 rSh
.Do( SwWrtShell::REDO
, nCnt
);
1383 if (rView
.GetPostItMgr()->GetActivePostIt())
1384 rView
.GetPostItMgr()->GetActivePostIt()->ResizeIfNeccessary(aOldHeight
,rView
.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight());
1387 void SwAnnotationShell::StateUndo(SfxItemSet
&rSet
)
1389 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1390 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1393 SfxWhichIter
aIter(rSet
);
1394 USHORT nWhich
= aIter
.FirstWhich();
1395 SfxUndoManager
* pUndoManager
= GetUndoManager();
1396 SfxViewFrame
*pSfxViewFrame
= rView
.GetViewFrame();
1397 SwWrtShell
&rSh
= rView
.GetWrtShell();
1405 sal_uInt16 nCount
= pUndoManager
->GetUndoActionCount();
1407 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1408 else if( rSh
.GetUndoIds() )
1409 rSet
.Put( SfxStringItem( nWhich
, rSh
.GetDoString(SwWrtShell::UNDO
)) );
1411 rSet
.DisableItem(nWhich
);
1416 sal_uInt16 nCount
= pUndoManager
->GetRedoActionCount();
1418 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1419 else if(rSh
.GetRedoIds())
1420 rSet
.Put(SfxStringItem( nWhich
, rSh
.GetDoString(SwWrtShell::REDO
)) );
1422 rSet
.DisableItem(nWhich
);
1425 case SID_GETUNDOSTRINGS
:
1426 case SID_GETREDOSTRINGS
:
1430 UniString (SfxUndoManager:: *fnGetComment
)( USHORT
) const;
1433 if( SID_GETUNDOSTRINGS
== nWhich
)
1435 nCount
= pUndoManager
->GetUndoActionCount();
1436 fnGetComment
= &SfxUndoManager::GetUndoActionComment
;
1440 nCount
= pUndoManager
->GetRedoActionCount();
1441 fnGetComment
= &SfxUndoManager::GetRedoActionComment
;
1447 for( sal_uInt16 n
= 0; n
< nCount
; ++n
)
1448 ( sList
+= (pUndoManager
->*fnGetComment
)( n
) )
1452 SfxStringListItem
aItem( nWhich
);
1453 if( nWhich
== SID_GETUNDOSTRINGS
&& rSh
.GetUndoIds() )
1455 rSh
.GetDoStrings( SwWrtShell::UNDO
, aItem
);
1457 else if( nWhich
== SID_GETREDOSTRINGS
&& rSh
.GetRedoIds() )
1459 rSh
.GetDoStrings( SwWrtShell::UNDO
, aItem
);
1462 sList
+= aItem
.GetString();
1463 aItem
.SetString( sList
);
1467 rSet
.DisableItem( nWhich
);
1473 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1479 if (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
)
1480 rSet
.DisableItem( nWhich
);
1482 nWhich
= aIter
.NextWhich();
1486 void SwAnnotationShell::StateDisableItems( SfxItemSet
&rSet
)
1488 SfxWhichIter
aIter(rSet
);
1489 USHORT nWhich
= aIter
.FirstWhich();
1492 rSet
.DisableItem( nWhich
);
1493 nWhich
= aIter
.NextWhich();
1497 void SwAnnotationShell::InsertSymbol(SfxRequest
& rReq
)
1499 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1500 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1503 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
1505 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1506 const SfxPoolItem
* pItem
= 0;
1508 pArgs
->GetItemState(GetPool().GetWhich(SID_CHARMAP
), FALSE
, &pItem
);
1514 sSym
= ((const SfxStringItem
*)pItem
)->GetValue();
1515 const SfxPoolItem
* pFtItem
= NULL
;
1516 pArgs
->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR
), FALSE
, &pFtItem
);
1517 const SfxStringItem
* pFontItem
= PTR_CAST( SfxStringItem
, pFtItem
);
1519 sFontName
= pFontItem
->GetValue();
1522 SfxItemSet
aSet(pOLV
->GetAttribs());
1523 USHORT nScript
= pOLV
->GetSelectedScriptType();
1524 SvxFontItem
aSetDlgFont( RES_CHRATR_FONT
);
1526 SvxScriptSetItem
aSetItem( SID_ATTR_CHAR_FONT
, *aSet
.GetPool() );
1527 aSetItem
.GetItemSet().Put( aSet
, FALSE
);
1528 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScript
);
1530 aSetDlgFont
= *(SvxFontItem
*)pI
;
1532 aSetDlgFont
= (SvxFontItem
&)aSet
.Get( GetWhichOfScript(
1534 GetI18NScriptTypeOfLanguage( (USHORT
)GetAppLanguage() ) ));
1535 if (!sFontName
.Len())
1536 sFontName
= aSetDlgFont
.GetFamilyName();
1539 Font
aFont(sFontName
, Size(1,1));
1542 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1544 SfxAllItemSet
aAllSet( GetPool() );
1545 aAllSet
.Put( SfxBoolItem( FN_PARAM_1
, FALSE
) );
1547 SwViewOption
aOpt(*rView
.GetWrtShell().GetViewOptions());
1548 String sSymbolFont
= aOpt
.GetSymbolFont();
1549 if( sSymbolFont
.Len() )
1550 aAllSet
.Put( SfxStringItem( SID_FONT_NAME
, sSymbolFont
) );
1552 aAllSet
.Put( SfxStringItem( SID_FONT_NAME
, aSetDlgFont
.GetFamilyName() ) );
1554 // Wenn Zeichen selektiert ist kann es angezeigt werden
1555 SfxAbstractDialog
* pDlg
= pFact
->CreateSfxDialog( rView
.GetWindow(), aAllSet
,
1556 rView
.GetViewFrame()->GetFrame()->GetFrameInterface(), RID_SVXDLG_CHARMAP
);
1558 USHORT nResult
= pDlg
->Execute();
1559 if( nResult
== RET_OK
)
1561 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pCItem
, SfxStringItem
, SID_CHARMAP
, FALSE
);
1562 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pFontItem
, SvxFontItem
, SID_ATTR_CHAR_FONT
, FALSE
);
1565 aFont
.SetName( pFontItem
->GetFamilyName() );
1566 aFont
.SetStyleName( pFontItem
->GetStyleName() );
1567 aFont
.SetCharSet( pFontItem
->GetCharSet() );
1568 aFont
.SetPitch( pFontItem
->GetPitch() );
1573 sSym
= pCItem
->GetValue();
1574 aOpt
.SetSymbolFont(aFont
.GetName());
1575 SW_MOD()->ApplyUsrPref(aOpt
, &rView
);
1586 Outliner
* pOutliner
= pOLV
->GetOutliner();
1587 pOutliner
->SetUpdateMode(FALSE
);
1589 SfxItemSet
aOldSet( pOLV
->GetAttribs() );
1590 SfxItemSet
aFontSet( *aOldSet
.GetPool(),
1591 EE_CHAR_FONTINFO
, EE_CHAR_FONTINFO
,
1592 EE_CHAR_FONTINFO_CJK
, EE_CHAR_FONTINFO_CJK
,
1593 EE_CHAR_FONTINFO_CTL
, EE_CHAR_FONTINFO_CTL
,
1595 aFontSet
.Set( aOldSet
);
1598 pOLV
->InsertText( sSym
, TRUE
);
1600 // attributieren (Font setzen)
1601 SfxItemSet
aSetFont( *aFontSet
.GetPool(), aFontSet
.GetRanges() );
1602 SvxFontItem
aFontItem (aFont
.GetFamily(), aFont
.GetName(),
1603 aFont
.GetStyleName(), aFont
.GetPitch(),
1606 USHORT nScriptBreak
= pBreakIt
->GetAllScriptsOfText( sSym
);
1607 if( SCRIPTTYPE_LATIN
& nScriptBreak
)
1608 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO
);
1609 if( SCRIPTTYPE_ASIAN
& nScriptBreak
)
1610 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO_CJK
);
1611 if( SCRIPTTYPE_COMPLEX
& nScriptBreak
)
1612 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO_CTL
);
1613 pOLV
->SetAttribs(aSetFont
);
1615 // Selektion loeschen
1616 ESelection
aSel(pOLV
->GetSelection());
1617 aSel
.nStartPara
= aSel
.nEndPara
;
1618 aSel
.nStartPos
= aSel
.nEndPos
;
1619 pOLV
->SetSelection(aSel
);
1621 // Alten Font restaurieren
1622 pOLV
->SetAttribs( aFontSet
);
1624 // ab jetzt wieder anzeigen
1625 pOutliner
->SetUpdateMode(TRUE
);
1628 rReq
.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP
), sSym
) );
1629 if(aFont
.GetName().Len())
1630 rReq
.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR
, aFont
.GetName() ) );