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
));
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();
802 if ( (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
) && pOLV
->HasSelection() )
806 if( pOLV
->HasSelection() )
810 if (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
)
813 case SID_PASTE_SPECIAL
:
815 if (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
)
817 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
818 SfxAbstractPasteDialog
* pDlg
= pFact
->CreatePasteDialog( &rView
.GetEditWin() );
820 pDlg
->Insert( SOT_FORMAT_STRING
, aEmptyStr
);
821 pDlg
->Insert( SOT_FORMAT_RTF
, aEmptyStr
);
823 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView
.GetEditWin() ) );
825 ULONG nFormat
= pDlg
->GetFormat( aDataHelper
.GetTransferable() );
829 if (nFormat
== SOT_FORMAT_STRING
)
832 pOLV
->PasteSpecial();
838 case SID_CLIPBOARD_FORMAT_ITEMS
:
841 const SfxPoolItem
* pItem
;
842 if ( rReq
.GetArgs() && rReq
.GetArgs()->GetItemState(nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
&&
843 pItem
->ISA(SfxUInt32Item
) )
845 nFormat
= ((const SfxUInt32Item
*)pItem
)->GetValue();
850 if (SOT_FORMAT_STRING
== nFormat
)
853 pOLV
->PasteSpecial();
858 pPostItMgr
->GetActivePostIt()->ResizeIfNeccessary(aOldHeight
,pPostItMgr
->GetActivePostIt()->GetPostItTextHeight());
861 void SwAnnotationShell::StateClpbrd(SfxItemSet
&rSet
)
863 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
864 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
866 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
868 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView
.GetEditWin() ) );
869 bool bPastePossible
= ( aDataHelper
.HasFormat( SOT_FORMAT_STRING
) || aDataHelper
.HasFormat( SOT_FORMAT_RTF
) );
870 bPastePossible
= bPastePossible
&& (pPostItMgr
->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED
);
872 SfxWhichIter
aIter(rSet
);
873 sal_uInt16 nWhich
= aIter
.FirstWhich();
881 if ( (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
) || !pOLV
->HasSelection() )
882 rSet
.DisableItem( nWhich
);
886 if( !pOLV
->HasSelection() )
887 rSet
.DisableItem( nWhich
);
891 case SID_PASTE_SPECIAL
:
893 if( !bPastePossible
)
894 rSet
.DisableItem( nWhich
);
897 case SID_CLIPBOARD_FORMAT_ITEMS
:
899 if ( bPastePossible
)
901 SvxClipboardFmtItem
aFormats( SID_CLIPBOARD_FORMAT_ITEMS
);
902 if ( aDataHelper
.HasFormat( SOT_FORMAT_RTF
) )
903 aFormats
.AddClipbrdFormat( SOT_FORMAT_RTF
);
904 //if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
905 aFormats
.AddClipbrdFormat( SOT_FORMAT_STRING
);
906 rSet
.Put( aFormats
);
909 rSet
.DisableItem( nWhich
);
913 nWhich
= aIter
.NextWhich();
917 void SwAnnotationShell::StateStatusLine(SfxItemSet
&rSet
)
919 SfxWhichIter
aIter( rSet
);
920 USHORT nWhich
= aIter
.FirstWhich();
926 case FN_STAT_SELMODE
:
928 rSet
.Put(SfxUInt16Item(FN_STAT_SELMODE
, 0));
929 rSet
.DisableItem( nWhich
);
932 case FN_STAT_TEMPLATE
:
934 rSet
.DisableItem( nWhich
);
938 nWhich
= aIter
.NextWhich();
942 void SwAnnotationShell::StateInsert(SfxItemSet
&rSet
)
944 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
945 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
948 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
949 SfxWhichIter
aIter(rSet
);
950 sal_uInt16 nWhich
= aIter
.FirstWhich();
956 case SID_HYPERLINK_GETLINK
:
958 SvxHyperlinkItem aHLinkItem
;
959 aHLinkItem
.SetInsertMode(HLINK_FIELD
);
961 const SvxFieldItem
* pFieldItem
= pOLV
->GetFieldAtSelection();
965 const SvxFieldData
* pField
= pFieldItem
->GetField();
967 if (pField
->ISA(SvxURLField
))
969 aHLinkItem
.SetName(((const SvxURLField
*) pField
)->GetRepresentation());
970 aHLinkItem
.SetURL(((const SvxURLField
*) pField
)->GetURL());
971 aHLinkItem
.SetTargetFrame(((const SvxURLField
*) pField
)->GetTargetFrame());
976 String
sSel(pOLV
->GetSelected());
978 sSel
.EraseTrailingChars();
979 aHLinkItem
.SetName(sSel
);
982 sal_uInt16 nHtmlMode
= ::GetHtmlMode(rView
.GetDocShell());
983 aHLinkItem
.SetInsertMode((SvxLinkInsertMode
)(aHLinkItem
.GetInsertMode() |
984 ((nHtmlMode
& HTMLMODE_ON
) != 0 ? HLINK_HTMLMODE
: 0)));
986 rSet
.Put(aHLinkItem
);
991 if (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
)
992 rSet
.DisableItem( nWhich
);
994 nWhich
= aIter
.NextWhich();
999 void SwAnnotationShell::NoteExec(SfxRequest
&rReq
)
1001 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1005 sal_uInt16 nSlot
= rReq
.GetSlot();
1010 case FN_DELETE_COMMENT
:
1011 case FN_DELETE_NOTE
:
1012 if ( pPostItMgr
->GetActivePostIt() )
1013 pPostItMgr
->GetActivePostIt()->ExecuteCommand(nSlot
);
1015 case FN_DELETE_ALL_NOTES
:
1016 pPostItMgr
->Delete();
1018 case FN_DELETE_NOTE_AUTHOR
:
1020 SFX_REQUEST_ARG( rReq
, pItem
, SfxStringItem
, nSlot
, FALSE
);
1022 pPostItMgr
->Delete( pItem
->GetValue() );
1027 if ( Mgr()->GetActivePostIt() == this )
1029 Mgr()->SetActivePostIt(0);
1030 // put the cursor back into the document
1036 case FN_HIDE_ALL_NOTES
:
1039 case FN_HIDE_NOTE_AUTHOR
:
1041 SFX_REQUEST_ARG( rReq
, pItem
, SfxStringItem
, nSlot
, FALSE
);
1043 pPostItMgr
->Hide( pItem
->GetValue() );
1048 void SwAnnotationShell::GetNoteState(SfxItemSet
&rSet
)
1050 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1051 SfxWhichIter
aIter(rSet
);
1052 sal_uInt16 nWhich
= aIter
.FirstWhich();
1055 USHORT nSlotId
= GetPool().GetSlotId( nWhich
);
1059 case FN_DELETE_NOTE
:
1060 case FN_DELETE_NOTE_AUTHOR
:
1061 case FN_DELETE_ALL_NOTES
:
1063 case FN_HIDE_NOTE_AUTHOR
:
1064 case FN_HIDE_ALL_NOTES
:
1066 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() || !pPostItMgr
->GetActivePostIt()->ISA(SwPostIt
))
1067 rSet
.DisableItem(nWhich
);
1070 case FN_DELETE_COMMENT
:
1072 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() ) //|| !pPostItMgr->GetActivePostIt()->ISA(SwRedComment))
1073 rSet
.DisableItem(nWhich
);
1078 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() || !pPostItMgr
->GetActivePostIt()->ISA(SwPostIt
))
1079 rSet
.DisableItem(nWhich
);
1082 SvtUserOptions aUserOpt
;
1084 if( !(sAuthor
= aUserOpt
.GetFullName()).Len())
1085 if( !(sAuthor
= aUserOpt
.GetID()).Len() )
1086 sAuthor
= String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR
));
1087 if (sAuthor
== pPostItMgr
->GetActivePostIt()->GetAuthor())
1088 rSet
.DisableItem(nWhich
);
1093 rSet
.InvalidateItem( nWhich
);
1097 if (pPostItMgr
->GetActivePostIt())
1099 if ( (pPostItMgr
->GetActivePostIt()->IsProtected()) &&
1100 ( (nSlotId
==FN_DELETE_NOTE
) || (nSlotId
==FN_REPLY
) ) )
1101 rSet
.DisableItem( nWhich
);
1103 nWhich
= aIter
.NextWhich();
1107 void SwAnnotationShell::ExecLingu(SfxRequest
&rReq
)
1109 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1110 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1113 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
1114 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
1115 sal_uInt16 nSlot
= rReq
.GetSlot();
1116 SwWrtShell
&rSh
= rView
.GetWrtShell();
1117 bool bRestoreSelection
= false;
1118 ESelection aOldSelection
;
1122 case SID_LANGUAGE_STATUS
:
1124 aOldSelection
= pOLV
->GetSelection();
1125 if (!pOLV
->GetEditView().HasSelection())
1127 bRestoreSelection
= true;
1128 pOLV
->GetEditView().SelectCurrentWord();
1131 bRestoreSelection
= SwLangHelper::SetLanguageStatus(pOLV
,rReq
,rView
,rSh
);
1134 case FN_THESAURUS_DLG
:
1136 pOLV
->StartThesaurus();
1139 case SID_HANGUL_HANJA_CONVERSION
:
1140 pOLV
->StartTextConversion( LANGUAGE_KOREAN
, LANGUAGE_KOREAN
, NULL
,
1141 i18n::TextConversionOption::CHARACTER_BY_CHARACTER
, sal_True
, sal_False
);
1144 case SID_CHINESE_CONVERSION
:
1146 //open ChineseTranslationDialog
1147 Reference
< XComponentContext
> xContext(
1148 ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1151 Reference
< lang::XMultiComponentFactory
> xMCF( xContext
->getServiceManager() );
1154 Reference
< ui::dialogs::XExecutableDialog
> xDialog(
1155 xMCF
->createInstanceWithContext(
1156 rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
1157 , xContext
), UNO_QUERY
);
1158 Reference
< lang::XInitialization
> xInit( xDialog
, UNO_QUERY
);
1161 // initialize dialog
1162 Reference
< awt::XWindow
> xDialogParentWindow(0);
1163 Sequence
<Any
> aSeq(1);
1164 Any
* pArray
= aSeq
.getArray();
1165 PropertyValue aParam
;
1166 aParam
.Name
= rtl::OUString::createFromAscii("ParentWindow");
1167 aParam
.Value
<<= makeAny(xDialogParentWindow
);
1168 pArray
[0] <<= makeAny(aParam
);
1169 xInit
->initialize( aSeq
);
1172 sal_Int16 nDialogRet
= xDialog
->execute();
1173 if( RET_OK
== nDialogRet
)
1175 //get some parameters from the dialog
1176 sal_Bool bToSimplified
= sal_True
;
1177 sal_Bool bUseVariants
= sal_True
;
1178 sal_Bool bCommonTerms
= sal_True
;
1179 Reference
< beans::XPropertySet
> xProp( xDialog
, UNO_QUERY
);
1184 xProp
->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified
;
1185 xProp
->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants
;
1186 xProp
->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms
;
1193 //execute translation
1194 sal_Int16 nSourceLang
= bToSimplified
? LANGUAGE_CHINESE_TRADITIONAL
: LANGUAGE_CHINESE_SIMPLIFIED
;
1195 sal_Int16 nTargetLang
= bToSimplified
? LANGUAGE_CHINESE_SIMPLIFIED
: LANGUAGE_CHINESE_TRADITIONAL
;
1196 sal_Int32 nOptions
= bUseVariants
? i18n::TextConversionOption::USE_CHARACTER_VARIANTS
: 0;
1198 nOptions
= nOptions
| i18n::TextConversionOption::CHARACTER_BY_CHARACTER
;
1200 Font aTargetFont
= pOLV
->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT
,
1201 nTargetLang
, DEFAULTFONT_FLAGS_ONLYONE
);
1203 pOLV
->StartTextConversion( nSourceLang
, nTargetLang
, &aTargetFont
, nOptions
, sal_False
, sal_False
);
1206 Reference
< lang::XComponent
> xComponent( xDialog
, UNO_QUERY
);
1207 if( xComponent
.is() )
1208 xComponent
->dispose();
1215 if (bRestoreSelection
)
1217 // restore selection
1218 pOLV
->GetEditView().SetSelection( aOldSelection
);
1222 void SwAnnotationShell::GetLinguState(SfxItemSet
&rSet
)
1224 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1225 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1228 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
1229 SfxItemSet
aEditAttr(pOLV
->GetAttribs());
1231 SfxWhichIter
aIter(rSet
);
1232 sal_uInt16 nWhich
= aIter
.FirstWhich();
1237 case SID_LANGUAGE_STATUS
:
1239 SwLangHelper::GetLanguageStatus(pOLV
,rSet
);
1242 // disable "Thesaurus" if the language is not supported
1243 case FN_THESAURUS_DLG
:
1245 const SfxPoolItem
&rItem
= rView
.GetWrtShell().GetDoc()->GetDefault(
1246 GetWhichOfScript( RES_CHRATR_LANGUAGE
,
1247 GetI18NScriptTypeOfLanguage( (USHORT
)GetAppLanguage())) );
1248 LanguageType nLang
= ((const SvxLanguageItem
&)
1249 rItem
).GetLanguage();
1250 uno::Reference
< linguistic2::XThesaurus
> xThes( ::GetThesaurus() );
1251 if (!xThes
.is() || nLang
== LANGUAGE_NONE
||
1252 !xThes
->hasLocale( SvxCreateLocale( nLang
) ))
1253 rSet
.DisableItem( FN_THESAURUS_DLG
);
1256 case SID_HANGUL_HANJA_CONVERSION
:
1257 case SID_CHINESE_CONVERSION
:
1259 if (!SvtCJKOptions().IsAnyEnabled())
1261 rView
.GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_False
);
1262 rSet
.DisableItem(nWhich
);
1265 rView
.GetViewFrame()->GetBindings().SetVisibleState( nWhich
, sal_True
);
1270 if (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
)
1271 rSet
.DisableItem( nWhich
);
1273 nWhich
= aIter
.NextWhich();
1277 void SwAnnotationShell::ExecTransliteration(SfxRequest
&rReq
)
1279 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1280 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1283 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
1285 using namespace ::com::sun::star::i18n
;
1287 sal_uInt32 nMode
= 0;
1289 switch( rReq
.GetSlot() )
1291 case SID_TRANSLITERATE_UPPER
:
1292 nMode
= TransliterationModules_LOWERCASE_UPPERCASE
;
1294 case SID_TRANSLITERATE_LOWER
:
1295 nMode
= TransliterationModules_UPPERCASE_LOWERCASE
;
1297 case SID_TRANSLITERATE_HALFWIDTH
:
1298 nMode
= TransliterationModules_FULLWIDTH_HALFWIDTH
;
1300 case SID_TRANSLITERATE_FULLWIDTH
:
1301 nMode
= TransliterationModules_HALFWIDTH_FULLWIDTH
;
1303 case SID_TRANSLITERATE_HIRAGANA
:
1304 nMode
= TransliterationModules_KATAKANA_HIRAGANA
;
1306 case SID_TRANSLITERATE_KATAGANA
:
1307 nMode
= TransliterationModules_HIRAGANA_KATAKANA
;
1311 ASSERT(!this, "falscher Dispatcher");
1316 pOLV
->TransliterateText( nMode
);
1321 void SwAnnotationShell::ExecUndo(SfxRequest
&rReq
)
1323 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1324 SfxUndoManager
* pUndoManager
= GetUndoManager();
1325 SwWrtShell
&rSh
= rView
.GetWrtShell();
1327 long aOldHeight
= rView
.GetPostItMgr()->GetActivePostIt() ? rView
.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight() : 0;
1329 USHORT nId
= rReq
.GetSlot();
1330 sal_uInt16 nCnt
= 1;
1331 const SfxPoolItem
* pItem
=0;
1332 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nId
, FALSE
, &pItem
) )
1333 nCnt
= ((SfxUInt16Item
*)pItem
)->GetValue();
1340 sal_uInt16 nCount
= pUndoManager
->GetUndoActionCount();
1341 sal_uInt16 nSteps
= nCnt
;
1342 if ( nCount
< nCnt
)
1344 nCnt
= nCnt
- nCount
;
1351 pUndoManager
->Undo(0);
1355 rSh
.Do( SwWrtShell::UNDO
, nCnt
);
1364 sal_uInt16 nCount
= pUndoManager
->GetRedoActionCount();
1365 sal_uInt16 nSteps
= nCnt
;
1366 if ( nCount
< nCnt
)
1368 nCnt
= nCnt
- nCount
;
1375 pUndoManager
->Redo(0);
1379 rSh
.Do( SwWrtShell::REDO
, nCnt
);
1385 rView
.GetViewFrame()->GetBindings().InvalidateAll(sal_False
);
1387 if (rView
.GetPostItMgr()->GetActivePostIt())
1388 rView
.GetPostItMgr()->GetActivePostIt()->ResizeIfNeccessary(aOldHeight
,rView
.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight());
1391 void SwAnnotationShell::StateUndo(SfxItemSet
&rSet
)
1393 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1394 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1397 SfxWhichIter
aIter(rSet
);
1398 USHORT nWhich
= aIter
.FirstWhich();
1399 SfxUndoManager
* pUndoManager
= GetUndoManager();
1400 SfxViewFrame
*pSfxViewFrame
= rView
.GetViewFrame();
1401 SwWrtShell
&rSh
= rView
.GetWrtShell();
1409 sal_uInt16 nCount
= pUndoManager
->GetUndoActionCount();
1411 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1412 else if( rSh
.GetUndoIds() )
1413 rSet
.Put( SfxStringItem( nWhich
, rSh
.GetDoString(SwWrtShell::UNDO
)) );
1415 rSet
.DisableItem(nWhich
);
1420 sal_uInt16 nCount
= pUndoManager
->GetRedoActionCount();
1422 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1423 else if(rSh
.GetRedoIds())
1424 rSet
.Put(SfxStringItem( nWhich
, rSh
.GetDoString(SwWrtShell::REDO
)) );
1426 rSet
.DisableItem(nWhich
);
1429 case SID_GETUNDOSTRINGS
:
1430 case SID_GETREDOSTRINGS
:
1434 UniString (SfxUndoManager:: *fnGetComment
)( USHORT
) const;
1437 if( SID_GETUNDOSTRINGS
== nWhich
)
1439 nCount
= pUndoManager
->GetUndoActionCount();
1440 fnGetComment
= &SfxUndoManager::GetUndoActionComment
;
1444 nCount
= pUndoManager
->GetRedoActionCount();
1445 fnGetComment
= &SfxUndoManager::GetRedoActionComment
;
1451 for( sal_uInt16 n
= 0; n
< nCount
; ++n
)
1452 ( sList
+= (pUndoManager
->*fnGetComment
)( n
) )
1456 SfxStringListItem
aItem( nWhich
);
1457 if( nWhich
== SID_GETUNDOSTRINGS
&& rSh
.GetUndoIds() )
1459 rSh
.GetDoStrings( SwWrtShell::UNDO
, aItem
);
1461 else if( nWhich
== SID_GETREDOSTRINGS
&& rSh
.GetRedoIds() )
1463 rSh
.GetDoStrings( SwWrtShell::UNDO
, aItem
);
1466 sList
+= aItem
.GetString();
1467 aItem
.SetString( sList
);
1471 rSet
.DisableItem( nWhich
);
1477 pSfxViewFrame
->GetSlotState( nWhich
, pSfxViewFrame
->GetInterface(), &rSet
);
1483 if (pPostItMgr
->GetActivePostIt()->GetStatus()==SwPostItHelper::DELETED
)
1484 rSet
.DisableItem( nWhich
);
1486 nWhich
= aIter
.NextWhich();
1490 void SwAnnotationShell::StateDisableItems( SfxItemSet
&rSet
)
1492 SfxWhichIter
aIter(rSet
);
1493 USHORT nWhich
= aIter
.FirstWhich();
1496 rSet
.DisableItem( nWhich
);
1497 nWhich
= aIter
.NextWhich();
1501 void SwAnnotationShell::InsertSymbol(SfxRequest
& rReq
)
1503 SwPostItMgr
* pPostItMgr
= rView
.GetPostItMgr();
1504 if ( !pPostItMgr
|| !pPostItMgr
->GetActivePostIt() )
1507 OutlinerView
* pOLV
= pPostItMgr
->GetActivePostIt()->View();
1509 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1510 const SfxPoolItem
* pItem
= 0;
1512 pArgs
->GetItemState(GetPool().GetWhich(SID_CHARMAP
), FALSE
, &pItem
);
1518 sSym
= ((const SfxStringItem
*)pItem
)->GetValue();
1519 const SfxPoolItem
* pFtItem
= NULL
;
1520 pArgs
->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR
), FALSE
, &pFtItem
);
1521 const SfxStringItem
* pFontItem
= PTR_CAST( SfxStringItem
, pFtItem
);
1523 sFontName
= pFontItem
->GetValue();
1526 SfxItemSet
aSet(pOLV
->GetAttribs());
1527 USHORT nScript
= pOLV
->GetSelectedScriptType();
1528 SvxFontItem
aSetDlgFont( RES_CHRATR_FONT
);
1530 SvxScriptSetItem
aSetItem( SID_ATTR_CHAR_FONT
, *aSet
.GetPool() );
1531 aSetItem
.GetItemSet().Put( aSet
, FALSE
);
1532 const SfxPoolItem
* pI
= aSetItem
.GetItemOfScript( nScript
);
1534 aSetDlgFont
= *(SvxFontItem
*)pI
;
1536 aSetDlgFont
= (SvxFontItem
&)aSet
.Get( GetWhichOfScript(
1538 GetI18NScriptTypeOfLanguage( (USHORT
)GetAppLanguage() ) ));
1539 if (!sFontName
.Len())
1540 sFontName
= aSetDlgFont
.GetFamilyName();
1543 Font
aFont(sFontName
, Size(1,1));
1546 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1548 SfxAllItemSet
aAllSet( GetPool() );
1549 aAllSet
.Put( SfxBoolItem( FN_PARAM_1
, FALSE
) );
1551 SwViewOption
aOpt(*rView
.GetWrtShell().GetViewOptions());
1552 String sSymbolFont
= aOpt
.GetSymbolFont();
1553 if( sSymbolFont
.Len() )
1554 aAllSet
.Put( SfxStringItem( SID_FONT_NAME
, sSymbolFont
) );
1556 aAllSet
.Put( SfxStringItem( SID_FONT_NAME
, aSetDlgFont
.GetFamilyName() ) );
1558 // Wenn Zeichen selektiert ist kann es angezeigt werden
1559 SfxAbstractDialog
* pDlg
= pFact
->CreateSfxDialog( rView
.GetWindow(), aAllSet
,
1560 rView
.GetViewFrame()->GetFrame()->GetFrameInterface(), RID_SVXDLG_CHARMAP
);
1562 USHORT nResult
= pDlg
->Execute();
1563 if( nResult
== RET_OK
)
1565 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pCItem
, SfxStringItem
, SID_CHARMAP
, FALSE
);
1566 SFX_ITEMSET_ARG( pDlg
->GetOutputItemSet(), pFontItem
, SvxFontItem
, SID_ATTR_CHAR_FONT
, FALSE
);
1569 aFont
.SetName( pFontItem
->GetFamilyName() );
1570 aFont
.SetStyleName( pFontItem
->GetStyleName() );
1571 aFont
.SetCharSet( pFontItem
->GetCharSet() );
1572 aFont
.SetPitch( pFontItem
->GetPitch() );
1577 sSym
= pCItem
->GetValue();
1578 aOpt
.SetSymbolFont(aFont
.GetName());
1579 SW_MOD()->ApplyUsrPref(aOpt
, &rView
);
1590 Outliner
* pOutliner
= pOLV
->GetOutliner();
1591 pOutliner
->SetUpdateMode(FALSE
);
1593 SfxItemSet
aOldSet( pOLV
->GetAttribs() );
1594 SfxItemSet
aFontSet( *aOldSet
.GetPool(),
1595 EE_CHAR_FONTINFO
, EE_CHAR_FONTINFO
,
1596 EE_CHAR_FONTINFO_CJK
, EE_CHAR_FONTINFO_CJK
,
1597 EE_CHAR_FONTINFO_CTL
, EE_CHAR_FONTINFO_CTL
,
1599 aFontSet
.Set( aOldSet
);
1602 pOLV
->InsertText( sSym
);
1604 // attributieren (Font setzen)
1605 SfxItemSet
aSetFont( *aFontSet
.GetPool(), aFontSet
.GetRanges() );
1606 SvxFontItem
aFontItem (aFont
.GetFamily(), aFont
.GetName(),
1607 aFont
.GetStyleName(), aFont
.GetPitch(),
1610 USHORT nScriptBreak
= pBreakIt
->GetAllScriptsOfText( sSym
);
1611 if( SCRIPTTYPE_LATIN
& nScriptBreak
)
1612 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO
);
1613 if( SCRIPTTYPE_ASIAN
& nScriptBreak
)
1614 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO_CJK
);
1615 if( SCRIPTTYPE_COMPLEX
& nScriptBreak
)
1616 aSetFont
.Put( aFontItem
, EE_CHAR_FONTINFO_CTL
);
1617 pOLV
->SetAttribs(aSetFont
);
1619 // Selektion loeschen
1620 ESelection
aSel(pOLV
->GetSelection());
1621 aSel
.nStartPara
= aSel
.nEndPara
;
1622 aSel
.nStartPos
= aSel
.nEndPos
;
1623 pOLV
->SetSelection(aSel
);
1625 // Alten Font restaurieren
1626 pOLV
->SetAttribs( aFontSet
);
1628 // ab jetzt wieder anzeigen
1629 pOutliner
->SetUpdateMode(TRUE
);
1632 rReq
.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP
), sSym
) );
1633 if(aFont
.GetName().Len())
1634 rReq
.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR
, aFont
.GetName() ) );