xref: /aoo42x/main/sw/source/ui/shells/annotsh.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #include <hintids.hxx>
32 
33 #include <com/sun/star/i18n/TransliterationModules.hpp>
34 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
35 #include <com/sun/star/i18n/TextConversionOption.hpp>
36 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
37 #include <com/sun/star/lang/XInitialization.hpp>
38 
39 #include <tools/shl.hxx>
40 #include <i18npool/mslangid.hxx>
41 #include <sfx2/objface.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <sfx2/bindings.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/request.hxx>
46 #include <editeng/spltitem.hxx>
47 #include <editeng/orphitem.hxx>
48 #include <editeng/brkitem.hxx>
49 #include <editeng/widwitem.hxx>
50 #include <editeng/kernitem.hxx>
51 #include <editeng/escpitem.hxx>
52 #include <editeng/lspcitem.hxx>
53 #include <editeng/adjitem.hxx>
54 #include <editeng/crsditem.hxx>
55 #include <editeng/shdditem.hxx>
56 #include <editeng/hyznitem.hxx>
57 #include <editeng/udlnitem.hxx>
58 #include <editeng/fontitem.hxx>
59 #include <editeng/fhgtitem.hxx>
60 #include <svx/clipfmtitem.hxx>
61 #include <svl/stritem.hxx>
62 #include <svl/slstitm.hxx>
63 #include <editeng/colritem.hxx>
64 #include <editeng/wghtitem.hxx>
65 #include <editeng/cntritem.hxx>
66 #include <editeng/postitem.hxx>
67 #include <editeng/frmdiritem.hxx>
68 #include <svx/svdoutl.hxx>
69 #include <svl/whiter.hxx>
70 #include <svl/cjkoptions.hxx>
71 #include <svl/ctloptions.hxx>
72 #include <unotools/useroptions.hxx>
73 #include <vcl/msgbox.hxx>
74 #include <editeng/flditem.hxx>
75 #include <editeng/editstat.hxx>
76 #include <svx/hlnkitem.hxx>
77 #include <svx/htmlmode.hxx>
78 #include <editeng/langitem.hxx>
79 #include <editeng/unolingu.hxx>
80 #include <editeng/scripttypeitem.hxx>
81 #include <editeng/writingmodeitem.hxx>
82 #include <swundo.hxx>
83 #include <doc.hxx>
84 #include <viewopt.hxx>
85 #include <wrtsh.hxx>
86 #include <uitool.hxx>
87 #include <popup.hrc>
88 #include <pardlg.hxx>
89 #include <swdtflvr.hxx>
90 #include <drwtxtsh.hxx>
91 #include <swmodule.hxx>
92 #include <initui.hxx>
93 #include <edtwin.hxx>
94 #include <swwait.hxx>
95 #include <docstat.hxx>
96 
97 #include <cmdid.h>
98 #include <globals.hrc>
99 #include <shells.hrc>
100 #include <breakit.hxx>
101 #include "annotsh.hxx"
102 #include "view.hxx"
103 #include <PostItMgr.hxx>
104 #include <SidebarWin.hxx>
105 
106 #include "swtypes.hxx"
107 
108 #include <svx/svxdlg.hxx>
109 #include <svx/dialogs.hrc>
110 
111 #include <svx/svxids.hrc>
112 #include <svl/itempool.hxx>
113 #include <editeng/outliner.hxx>
114 #include <editeng/editeng.hxx>
115 #include <editeng/editview.hxx>
116 
117 #include <svl/languageoptions.hxx>
118 #include <editeng/langitem.hxx>
119 #include <svtools/langtab.hxx>
120 #include <svl/slstitm.hxx>
121 
122 #include <docsh.hxx>
123 #include <svl/undo.hxx>
124 #include "swabstdlg.hxx"
125 #include "chrdlg.hrc"
126 #include "misc.hrc"
127 #include <app.hrc>
128 
129 #include <comphelper/processfactory.hxx>
130 
131 #include <cppuhelper/bootstrap.hxx>
132 
133 #include <langhelper.hxx>
134 
135 using namespace ::com::sun::star;
136 using namespace ::com::sun::star::uno;
137 using namespace ::com::sun::star::beans;
138 using namespace ::com::sun::star::i18n;
139 
140 #define SwAnnotationShell
141 
142 #include <sfx2/msg.hxx>
143 #include <swslots.hxx>
144 
145 SFX_IMPL_INTERFACE(SwAnnotationShell, SfxShell, SW_RES(STR_SHELLNAME_DRAW_TEXT))
146 {
147 	SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
148 	SFX_POPUPMENU_REGISTRATION(SW_RES(MN_ANNOTATION_POPUPMENU));
149 }
150 
151 TYPEINIT1(SwAnnotationShell,SfxShell)
152 
153 SwAnnotationShell::SwAnnotationShell( SwView& r )
154 : rView(r)
155 {
156 	SwWrtShell &rSh = rView.GetWrtShell();
157 	SetPool(rSh.GetAttrPool().GetSecondaryPool());
158 }
159 
160 SwAnnotationShell::~SwAnnotationShell()
161 {
162 }
163 
164 ::svl::IUndoManager* SwAnnotationShell::GetUndoManager()
165 {
166 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
167     if ( !pPostItMgr ||
168          !pPostItMgr->HasActiveSidebarWin() )
169 	{
170 		DBG_ASSERT(pPostItMgr,"PostItMgr::Layout(): We are looping forever");
171 		return 0;
172 	}
173     return &pPostItMgr->GetActiveSidebarWin()->GetOutlinerView()->GetOutliner()->GetUndoManager();
174 }
175 
176 void SwAnnotationShell::Exec( SfxRequest &rReq )
177 {
178 	//TODO: clean this up!!!!
179 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
180     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
181 		return;
182 
183     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
184     SfxItemSet aEditAttr(pOLV->GetAttribs());
185 	SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
186 
187 	sal_uInt16 nSlot = rReq.GetSlot();
188 	sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
189 	const SfxItemSet *pNewAttrs = rReq.GetArgs();
190     sal_uInt16 nEEWhich = 0;
191 	switch (nSlot)
192 	{
193 		case SID_ATTR_CHAR_FONT:
194 		case SID_ATTR_CHAR_FONTHEIGHT:
195 		case SID_ATTR_CHAR_WEIGHT:
196 		case SID_ATTR_CHAR_POSTURE:
197 			{
198 				SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
199 				if( !pSecondPool )
200 					pSecondPool = aEditAttr.GetPool();
201 				SvxScriptSetItem aSetItem( nSlot, *pSecondPool );
202 				aSetItem.PutItemForScriptType( pOLV->GetSelectedScriptType(), pNewAttrs->Get( nWhich ));
203 				aNewAttr.Put( aSetItem.GetItemSet() );
204 				rReq.Done();
205 				break;
206 			}
207 		case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
208 		case SID_ATTR_CHAR_UNDERLINE:
209 		{
210 		 	FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
211 			aNewAttr.Put(SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE));
212 			break;
213 		}
214 		case SID_ATTR_CHAR_OVERLINE:
215 		{
216 		 	FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle();
217 			aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE));
218 			break;
219 		}
220 		case SID_ATTR_CHAR_CONTOUR:     nEEWhich = EE_CHAR_OUTLINE; break;
221         case SID_ATTR_CHAR_SHADOWED:    nEEWhich = EE_CHAR_SHADOW; break;
222         case SID_ATTR_CHAR_STRIKEOUT:   nEEWhich = EE_CHAR_STRIKEOUT; break;
223 		case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
224         case SID_ATTR_CHAR_RELIEF      : nEEWhich = EE_CHAR_RELIEF;  break;
225         case SID_ATTR_CHAR_LANGUAGE    : nEEWhich = EE_CHAR_LANGUAGE;break;
226         case SID_ATTR_CHAR_KERNING     : nEEWhich = EE_CHAR_KERNING; break;
227         case SID_ATTR_CHAR_SCALEWIDTH:   nEEWhich = EE_CHAR_FONTWIDTH; break;
228         case SID_ATTR_CHAR_AUTOKERN  :   nEEWhich = EE_CHAR_PAIRKERNING; break;
229         case SID_ATTR_CHAR_ESCAPEMENT:   nEEWhich = EE_CHAR_ESCAPEMENT; break;
230         case SID_ATTR_PARA_ADJUST_LEFT:
231 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST));
232         break;
233 		case SID_ATTR_PARA_ADJUST_CENTER:
234 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
235         break;
236 		case SID_ATTR_PARA_ADJUST_RIGHT:
237 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST));
238         break;
239 		case SID_ATTR_PARA_ADJUST_BLOCK:
240 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST));
241         break;
242 
243 		case SID_ATTR_PARA_LINESPACE_10:
244 		{
245 			SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL);
246 			aItem.SetPropLineSpace(100);
247 			aNewAttr.Put(aItem);
248 		}
249 		break;
250 		case SID_ATTR_PARA_LINESPACE_15:
251 		{
252 			SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL);
253 			aItem.SetPropLineSpace(150);
254 			aNewAttr.Put(aItem);
255 		}
256 		break;
257 		case SID_ATTR_PARA_LINESPACE_20:
258 		{
259 			SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL);
260 			aItem.SetPropLineSpace(200);
261 			aNewAttr.Put(aItem);
262 		}
263 		break;
264 		case SID_SELECTALL:
265 		{
266             Outliner * pOutliner = pOLV->GetOutliner();
267             if(pOutliner)
268             {
269                 sal_uLong nParaCount = pOutliner->GetParagraphCount();
270                 if (nParaCount > 0)
271                     pOLV->SelectRange(0L, sal_uInt16(nParaCount) );
272             }
273 			break;
274 		}
275 		case FN_FORMAT_RESET:
276 		{
277             pPostItMgr->GetActiveSidebarWin()->ResetAttributes();
278 			rReq.Done();
279 			break;
280 		}
281 		case FN_SET_SUPER_SCRIPT:
282 		{
283 			SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
284 			SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
285 							aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
286 
287 			if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
288 				aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
289 			else
290 				aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
291 			aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
292 		}
293 		break;
294 		case FN_SET_SUB_SCRIPT:
295 		{
296 			SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
297 			SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
298 							aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
299 
300 			if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
301 				aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
302 			else
303 				aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
304 			aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
305 		}
306 		break;
307 		case SID_HYPERLINK_SETLINK:
308 		{
309 			const SfxPoolItem* pItem = 0;
310 			if(pNewAttrs)
311 				pNewAttrs->GetItemState(nSlot, sal_False, &pItem);
312 
313 			if(pItem)
314 			{
315 				const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
316 				SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT);
317 				aFld.SetTargetFrame(rHLinkItem.GetTargetFrame());
318 
319 				const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
320 
321 				if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField))
322 				{
323 					// Feld selektieren, so dass es beim Insert geloescht wird
324 					ESelection aSel = pOLV->GetSelection();
325 					aSel.nEndPos++;
326 					pOLV->SetSelection(aSel);
327 				}
328                 if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
329 					pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD));
330 			}
331 			break;
332 		}
333 		case FN_INSERT_SOFT_HYPHEN:
334         case FN_INSERT_HARDHYPHEN:
335         case FN_INSERT_HARD_SPACE:
336         case SID_INSERT_RLM :
337         case SID_INSERT_LRM :
338         case SID_INSERT_ZWNBSP :
339         case SID_INSERT_ZWSP:
340         {
341             sal_Unicode cIns = 0;
342             switch(rReq.GetSlot())
343             {
344                 case FN_INSERT_SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
345                 case FN_INSERT_HARDHYPHEN: cIns = CHAR_HARDHYPHEN; break;
346                 case FN_INSERT_HARD_SPACE: cIns = CHAR_HARDBLANK; break;
347                 case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
348                 case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
349                 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
350                 case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
351             }
352             pOLV->InsertText( String(cIns));
353             rReq.Done();
354 			break;
355         }
356 		case SID_CHARMAP:
357 		{
358             if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
359 				InsertSymbol(rReq);
360 			break;
361 		}
362 	        case FN_INSERT_STRING:
363                 {
364 			const SfxPoolItem* pItem = 0;
365 			if(pNewAttrs)
366 				pNewAttrs->GetItemState(nSlot, sal_False, &pItem );
367                         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
368                                 pOLV->InsertText(((const SfxStringItem *)pItem)->GetValue());
369                         break;
370                 }
371 
372 		case FN_FORMAT_FOOTNOTE_DLG:
373 		{
374             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
375             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
376 
377             VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( rView.GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE );
378             DBG_ASSERT(pDlg, "Dialogdiet fail!");
379 			pDlg->Execute();
380 			delete pDlg;
381 			break;
382 		}
383 		case FN_NUMBERING_OUTLINE_DLG:
384 		{
385 			SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
386 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
387             DBG_ASSERT(pFact, "Dialogdiet fail!");
388             SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
389 														rView.GetWindow(), &aTmp, rView.GetWrtShell());
390             DBG_ASSERT(pDlg, "Dialogdiet fail!");
391 			pDlg->Execute();
392 			delete pDlg;
393 			rReq.Done();
394 		}
395 		break;
396 		case SID_OPEN_XML_FILTERSETTINGS:
397 		{
398 			try
399 			{
400 				uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY);
401 				if( xDialog.is() )
402 				{
403 					xDialog->execute();
404 				}
405 			}
406 			catch( uno::Exception& )
407 			{
408 			}
409 			rReq.Ignore ();
410 		}
411 		break;
412 		case FN_WORDCOUNT_DIALOG:
413 		{
414 			SwWrtShell &rSh = rView.GetWrtShell();
415 			SwDocStat aCurr;
416 			SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
417 			{
418 				SwWait aWait( *rView.GetDocShell(), sal_True );
419 				rSh.StartAction();
420 				rSh.CountWords( aCurr );
421 				rSh.UpdateDocStat( aDocStat );
422 				rSh.EndAction();
423 			}
424 
425 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
426 			DBG_ASSERT(pFact, "Dialogdiet fail!");
427 			AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( rView.GetWindow() );
428 			pDialog->SetValues(aCurr, aDocStat );
429 			pDialog->Execute();
430 			delete pDialog;
431 		}
432 		break;
433 		case SID_CHAR_DLG:
434 		{
435 			const SfxItemSet* pArgs = rReq.GetArgs();
436 
437 			if( !pArgs )
438 			{
439 				/* mod
440 				SwView* pView = &GetView();
441 				FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
442 				SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
443 				*/
444 				SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END);
445 
446 				// util::Language gibts an der EditEngine nicht! Daher nicht im Set.
447 
448 				aDlgAttr.Put( aEditAttr );
449                 aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
450 
451 				//CHINA001 SwCharDlg* pDlg = new SwCharDlg(pView->GetWindow(), *pView, aDlgAttr, 0, sal_True);
452 				SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();//CHINA001
453 				DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001
454 
455 				SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( rView.GetWindow(), rView, aDlgAttr, DLG_CHAR,0, sal_True );
456 				DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
457 				sal_uInt16 nRet = pDlg->Execute();
458 				if(RET_OK == nRet )
459                 {
460                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
461                     aNewAttr.Put(*pDlg->GetOutputItemSet());
462                 }
463 				delete( pDlg );
464 				if(RET_OK != nRet)
465 					return ;
466 			}
467 			else
468 				aNewAttr.Put(*pArgs);
469 		break;
470 		}
471 		case SID_PARA_DLG:
472 		{
473 			const SfxItemSet* pArgs = rReq.GetArgs();
474 
475 			if (!pArgs)
476 			{
477 				/* mod todo ???
478 				SwView* pView = &GetView();
479 				FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
480 				SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, eMetric));
481 				*/
482 				SfxItemSet aDlgAttr(GetPool(),
483 									EE_ITEMS_START, EE_ITEMS_END,
484 									SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
485 									SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
486 									SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
487 									SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
488 									0);
489 
490 				aDlgAttr.Put(aEditAttr);
491 
492 
493                 aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) );
494                 aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
495                 aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) );
496                 aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
497                 aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
498 
499 				//CHINA001 SwParaDlg* pDlg = new SwParaDlg(GetView().GetWindow(), GetView(), aDlgAttr, DLG_STD, 0, sal_True);
500 
501 				SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();//CHINA001
502 				DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");//CHINA001
503 
504 				SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( rView.GetWindow(), rView, aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True );
505 				DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
506 				sal_uInt16 nRet = pDlg->Execute();
507 				if(RET_OK == nRet)
508                 {
509                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
510                     aNewAttr.Put(*pDlg->GetOutputItemSet());
511                 }
512 				delete( pDlg );
513 				if(RET_OK != nRet)
514 					return;
515 			}
516 			else
517 				aNewAttr.Put(*pArgs);
518 			break;
519 		}
520 
521 		case SID_AUTOSPELL_CHECK:
522 		{
523 			rView.ExecuteSlot(rReq);
524 			break;
525 		}
526 		case SID_ATTR_PARA_LEFT_TO_RIGHT:
527         case SID_ATTR_PARA_RIGHT_TO_LEFT:
528         {
529             sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
530 
531             const SfxPoolItem* pPoolItem;
532             if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, sal_True, &pPoolItem ) )
533             {
534                 if( !( (SfxBoolItem*)pPoolItem)->GetValue() )
535                     bLeftToRight = !bLeftToRight;
536             }
537             SfxItemSet aAttr( *aNewAttr.GetPool(),
538                         EE_PARA_JUST, EE_PARA_JUST,
539                         EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
540                         0 );
541 
542             sal_uInt16 nAdjust = SVX_ADJUST_LEFT;
543             if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, sal_True, &pPoolItem ) )
544                 nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
545 
546             if( bLeftToRight )
547             {
548                 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
549                 if( nAdjust == SVX_ADJUST_RIGHT )
550                     aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
551             }
552             else
553             {
554                 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
555                 if( nAdjust == SVX_ADJUST_LEFT )
556                     aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
557             }
558             pOLV->SetAttribs(aAttr);
559 			break;
560         }
561 	}
562 
563     if(nEEWhich && pNewAttrs)
564         aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
565 
566 	Rectangle aNullRect;
567     Rectangle aOutRect = pOLV->GetOutputArea();
568 	if (aNullRect != aOutRect)
569 		pOLV->SetAttribs(aNewAttr);
570 
571 	rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
572 	if ( pOLV->GetOutliner()->IsModified() )
573 		rView.GetWrtShell().SetModified();
574 
575 }
576 
577 void SwAnnotationShell::GetState(SfxItemSet& rSet)
578 {
579 	//TODO: clean this up!!!
580 	// FN_SET_SUPER_SCRIPT
581 	//SID_ATTR_PARA_ADJUST
582 	//SID_ATTR_PARA_ADJUST_BLOCK
583 
584 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
585     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
586 		return;
587 
588     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
589 	SfxItemSet aEditAttr(pOLV->GetAttribs());
590 
591 	SfxWhichIter aIter(rSet);
592 	sal_uInt16 nWhich = aIter.FirstWhich();
593     while(nWhich)
594 	{
595         sal_uInt16 nEEWhich = 0;
596         sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
597 		switch( nSlotId )
598 		{
599 			case SID_ATTR_CHAR_FONT:
600 			case SID_ATTR_CHAR_FONTHEIGHT:
601 			case SID_ATTR_CHAR_WEIGHT:
602 			case SID_ATTR_CHAR_POSTURE:
603 				{
604 					if ( pOLV )
605 					{
606 						sal_uInt16 nScriptType = pOLV->GetSelectedScriptType();
607 						SfxItemPool* pSecondPool = aEditAttr.GetPool()->GetSecondaryPool();
608 						if( !pSecondPool )
609 							pSecondPool = aEditAttr.GetPool();
610 						SvxScriptSetItem aSetItem( nSlotId, *pSecondPool );
611 						aSetItem.GetItemSet().Put( aEditAttr, sal_False );
612 						const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
613 						if( pI )
614 							rSet.Put( *pI, nWhich );
615 						else
616 							rSet.InvalidateItem( nWhich );
617 					}
618 					else
619 						rSet.InvalidateItem( nWhich );
620 				}
621 				break;
622             case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
623             case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
624             case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
625             case SID_ATTR_CHAR_CONTOUR:	nEEWhich = EE_CHAR_OUTLINE; break;
626             case SID_ATTR_CHAR_SHADOWED:  nEEWhich = EE_CHAR_SHADOW;break;
627             case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
628 			case SID_ATTR_CHAR_LANGUAGE    : nEEWhich = EE_CHAR_LANGUAGE;break;
629 			case FN_SET_SUPER_SCRIPT:
630 			case FN_SET_SUB_SCRIPT:
631 			{
632 				sal_uInt16 nEsc = 0;
633 				const SfxPoolItem *pEscItem = 0;
634 				if (nWhich==FN_SET_SUPER_SCRIPT)
635 					nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
636 				else
637 					nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
638 
639 				if( !pEscItem )
640 					pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
641 
642 				if( nEsc == ((const SvxEscapementItem*)pEscItem)->GetEnumValue() )
643 					rSet.Put( SfxBoolItem( nWhich, sal_True ));
644 				else
645 					rSet.InvalidateItem( nWhich );
646 				break;
647 			}
648 			case SID_ATTR_PARA_ADJUST_LEFT:
649 			case SID_ATTR_PARA_ADJUST_RIGHT:
650 			case SID_ATTR_PARA_ADJUST_CENTER:
651 			case SID_ATTR_PARA_ADJUST_BLOCK:
652 				{
653 					const SfxPoolItem *pAdjust = 0;
654 					int eAdjust = 0;
655 
656 					if (nWhich==SID_ATTR_PARA_ADJUST_LEFT)
657 						eAdjust = SVX_ADJUST_LEFT;
658 					else
659 					if (nWhich==SID_ATTR_PARA_ADJUST_RIGHT)
660 						eAdjust = SVX_ADJUST_RIGHT;
661 					else
662 					if (nWhich==SID_ATTR_PARA_ADJUST_CENTER)
663 						eAdjust = SVX_ADJUST_CENTER;
664 					else
665 					if (nWhich==SID_ATTR_PARA_ADJUST_BLOCK)
666 						eAdjust = SVX_ADJUST_BLOCK;
667 
668 					if( !pAdjust )
669 						aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust);
670 
671 					if( !pAdjust || IsInvalidItem( pAdjust ))
672 						rSet.InvalidateItem( nSlotId ), nSlotId = 0;
673 					else
674 					{
675 						if ( eAdjust == ((const SvxAdjustItem*)pAdjust)->GetAdjust())
676 							rSet.Put( SfxBoolItem( nWhich, sal_True ));
677 						else
678 							rSet.InvalidateItem( nWhich );
679 					}
680 					break;
681 				}
682 			case SID_ATTR_PARA_LINESPACE_10:
683 			case SID_ATTR_PARA_LINESPACE_15:
684 			case SID_ATTR_PARA_LINESPACE_20:
685 				{
686 					const SfxPoolItem *pLSpace = 0;
687 					int nLSpace = 0;
688 
689 					if (nWhich==SID_ATTR_PARA_LINESPACE_10)
690 						nLSpace = 100;
691 					else
692 					if (nWhich==SID_ATTR_PARA_LINESPACE_15)
693 						nLSpace = 150;
694 					else
695 					if (nWhich==SID_ATTR_PARA_LINESPACE_20)
696 						nLSpace = 200;
697 
698 					if( !pLSpace )
699 						aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace );
700 
701 					if( !pLSpace || IsInvalidItem( pLSpace ))
702 						rSet.InvalidateItem( nSlotId ), nSlotId = 0;
703 					else
704 					{
705 						if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->GetPropLineSpace() )
706 							rSet.Put( SfxBoolItem( nWhich, sal_True ));
707 						else
708 							rSet.InvalidateItem( nWhich );
709 					}
710 					break;
711 				}
712             case SID_AUTOSPELL_CHECK:
713             {
714 				const SfxPoolItem* pState = rView.GetSlotState(nWhich);
715                 if (pState)
716                     rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue()));
717                 else
718                     rSet.DisableItem( nWhich );
719                 break;
720             }
721 			case SID_ATTR_PARA_LEFT_TO_RIGHT:
722 			case SID_ATTR_PARA_RIGHT_TO_LEFT:
723 			{
724 				if ( !SvtLanguageOptions().IsCTLFontEnabled() )
725 					rSet.DisableItem( nWhich );
726 				else
727 				{
728 					if(pOLV->GetOutliner() && pOLV->GetOutliner()->IsVertical())
729 						rSet.DisableItem( nWhich );
730 					else
731 					{
732 						sal_Bool bFlag = sal_False;
733 						switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
734 						{
735 							case FRMDIR_HORI_LEFT_TOP:
736 							{
737 								bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
738 								rSet.Put( SfxBoolItem( nWhich, bFlag ));
739 								break;
740 							}
741 							case FRMDIR_HORI_RIGHT_TOP:
742 							{
743 								bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
744 								rSet.Put( SfxBoolItem( nWhich, bFlag ));
745 								break;
746 							}
747 						}
748 					}
749 				}
750 			}
751 			break;
752 			case SID_INSERT_RLM :
753             case SID_INSERT_LRM :
754             case SID_INSERT_ZWNBSP :
755             case SID_INSERT_ZWSP:
756             {
757                 SvtCTLOptions aCTLOptions;
758                 sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
759                 rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
760                 if(!bEnabled)
761                     rSet.DisableItem(nWhich);
762             }
763             break;
764 			default:
765 				rSet.InvalidateItem( nWhich );
766 				break;
767 		}
768 
769         if(nEEWhich)
770             rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich);
771 
772         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
773 			rSet.DisableItem( nWhich );
774 
775 		nWhich = aIter.NextWhich();
776 	}
777 }
778 
779 void SwAnnotationShell::ExecSearch(SfxRequest& rReq, sal_Bool bNoMessage)
780 {
781 	rView.ExecSearch(rReq,bNoMessage);
782 }
783 
784 void SwAnnotationShell::StateSearch(SfxItemSet &rSet)
785 {
786 	rView.StateSearch(rSet);
787 }
788 
789 void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq)
790 {
791 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
792     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
793 		return;
794 
795     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
796     SfxItemSet aEditAttr(pOLV->GetAttribs());
797 	SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
798 
799     long aOldHeight = pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight();
800 	sal_uInt16 nSlot = rReq.GetSlot();
801 	switch (nSlot)
802 	{
803 		case SID_CUT:
804             if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() )
805 				pOLV->Cut();
806 			break;
807 		case SID_COPY:
808 			if( pOLV->HasSelection() )
809 				pOLV->Copy();
810 			break;
811 		case SID_PASTE:
812             if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
813 				pOLV->Paste();
814 			break;
815         case SID_PASTE_SPECIAL:
816 		{
817             if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED)
818 			{
819 				SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
820 				SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rView.GetEditWin() );
821 
822 				pDlg->Insert( SOT_FORMAT_STRING, aEmptyStr );
823 				pDlg->Insert( SOT_FORMAT_RTF,	 aEmptyStr );
824 
825 				TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) );
826 
827 				sal_uLong nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
828 
829 				if (nFormat > 0)
830 				{
831 					if (nFormat == SOT_FORMAT_STRING)
832 						pOLV->Paste();
833 					else
834 						pOLV->PasteSpecial();
835 				}
836 				delete pDlg;
837 			}
838 			break;
839 		}
840 		case SID_CLIPBOARD_FORMAT_ITEMS:
841 		{
842 			sal_uLong nFormat = 0;
843 			const SfxPoolItem* pItem;
844 			if ( rReq.GetArgs() && rReq.GetArgs()->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET &&
845 									pItem->ISA(SfxUInt32Item) )
846 			{
847 				nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
848 			}
849 
850 			if ( nFormat )
851 			{
852 				if (SOT_FORMAT_STRING == nFormat)
853 					pOLV->Paste();
854 				else
855 					pOLV->PasteSpecial();
856 			}
857 			break;
858 		}
859 	}
860     pPostItMgr->GetActiveSidebarWin()->ResizeIfNeccessary(aOldHeight,pPostItMgr->GetActiveSidebarWin()->GetPostItTextHeight());
861 }
862 
863 void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet)
864 {
865 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
866     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
867 		return;
868     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
869 
870 	TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( &rView.GetEditWin() ) );
871 	bool bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
872     bPastePossible = bPastePossible &&  (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED);
873 
874 	SfxWhichIter aIter(rSet);
875 	sal_uInt16 nWhich = aIter.FirstWhich();
876 
877 	while(nWhich)
878 	{
879 		switch(nWhich)
880 		{
881 			case SID_CUT:
882 			{
883                 if ( (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED) || !pOLV->HasSelection() )
884 					rSet.DisableItem( nWhich );
885 			}
886 			case SID_COPY:
887 			{
888 				if( !pOLV->HasSelection() )
889 					rSet.DisableItem( nWhich );
890 				break;
891 			}
892 			case SID_PASTE:
893             case SID_PASTE_SPECIAL:
894 				{
895 					if( !bPastePossible )
896 						rSet.DisableItem( nWhich );
897 					break;
898 				}
899 			case SID_CLIPBOARD_FORMAT_ITEMS:
900 				{
901 					if ( bPastePossible )
902 					{
903 						SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
904 						if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
905 							aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
906 						//if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
907 							aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
908 						rSet.Put( aFormats );
909 					}
910 					else
911 						rSet.DisableItem( nWhich );
912 					break;
913 				}
914 		}
915 		nWhich = aIter.NextWhich();
916 	}
917 }
918 
919 void SwAnnotationShell::StateStatusLine(SfxItemSet &rSet)
920 {
921 	SfxWhichIter aIter( rSet );
922 	sal_uInt16 nWhich = aIter.FirstWhich();
923 
924 	while( nWhich )
925 	{
926 		switch( nWhich )
927 		{
928 			case FN_STAT_SELMODE:
929 			{
930 				rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
931 				rSet.DisableItem( nWhich );
932 				break;
933 			}
934 			case FN_STAT_TEMPLATE:
935 			{
936 				rSet.DisableItem( nWhich );
937 				break;
938 			}
939 		}
940 		nWhich = aIter.NextWhich();
941 	}
942 }
943 
944 void SwAnnotationShell::StateInsert(SfxItemSet &rSet)
945 {
946 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
947     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
948 		return;
949 
950     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
951     SfxWhichIter aIter(rSet);
952 	sal_uInt16 nWhich = aIter.FirstWhich();
953 
954 	while(nWhich)
955 	{
956 		switch(nWhich)
957 		{
958 			case SID_HYPERLINK_GETLINK:
959 				{
960 					SvxHyperlinkItem aHLinkItem;
961 					aHLinkItem.SetInsertMode(HLINK_FIELD);
962 
963 					const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
964 
965 					if (pFieldItem)
966 					{
967 						const SvxFieldData* pField = pFieldItem->GetField();
968 
969 						if (pField->ISA(SvxURLField))
970 						{
971 							aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
972 							aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
973 							aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
974 						}
975 					}
976 					else
977 					{
978 						String sSel(pOLV->GetSelected());
979 						sSel.Erase(255);
980 						sSel.EraseTrailingChars();
981 						aHLinkItem.SetName(sSel);
982 					}
983 
984 					sal_uInt16 nHtmlMode = ::GetHtmlMode(rView.GetDocShell());
985 					aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
986 						((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
987 
988 					rSet.Put(aHLinkItem);
989 				}
990 				break;
991 		}
992 
993         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
994 			rSet.DisableItem( nWhich );
995 
996 		nWhich = aIter.NextWhich();
997 	}
998 }
999 
1000 
1001 void SwAnnotationShell::NoteExec(SfxRequest &rReq)
1002 {
1003 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
1004 	if ( !pPostItMgr )
1005 		return;
1006 
1007 	sal_uInt16 nSlot = rReq.GetSlot();
1008 	switch (nSlot)
1009 	{
1010 		case FN_REPLY:
1011 		case FN_POSTIT:
1012 		case FN_DELETE_COMMENT:
1013             if ( pPostItMgr->HasActiveSidebarWin() )
1014                 pPostItMgr->GetActiveSidebarWin()->ExecuteCommand(nSlot);
1015 			break;
1016 		case FN_DELETE_ALL_NOTES:
1017 			pPostItMgr->Delete();
1018 			break;
1019 		case FN_DELETE_NOTE_AUTHOR:
1020 		{
1021 			SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, sal_False);
1022 			if ( pItem )
1023 				pPostItMgr->Delete( pItem->GetValue() );
1024 			break;
1025 		}
1026 		case FN_HIDE_NOTE:
1027 			/*
1028             if ( Mgr()->GetActiveSidebarWin() == this )
1029             {
1030                 Mgr()->SetActivePostIt(0);
1031                 // put the cursor back into the document
1032                 SwitchToFieldPos();
1033             }
1034             Mgr()->Hide(mpFld);
1035 			*/
1036 			break;
1037 		case FN_HIDE_ALL_NOTES:
1038 			pPostItMgr->Hide();
1039 			break;
1040 		case FN_HIDE_NOTE_AUTHOR:
1041 		{
1042 			SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, nSlot, sal_False);
1043 			if ( pItem )
1044 				pPostItMgr->Hide( pItem->GetValue() );
1045 		}
1046 	}
1047 }
1048 
1049 void SwAnnotationShell::GetNoteState(SfxItemSet &rSet)
1050 {
1051 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
1052 	SfxWhichIter aIter(rSet);
1053 	sal_uInt16 nWhich = aIter.FirstWhich();
1054     while(nWhich)
1055 	{
1056         sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
1057 		switch( nSlotId )
1058 		{
1059 			case FN_POSTIT:
1060 			case FN_DELETE_NOTE_AUTHOR:
1061 			case FN_DELETE_ALL_NOTES:
1062 			case FN_HIDE_NOTE:
1063 			case FN_HIDE_NOTE_AUTHOR:
1064 			case FN_HIDE_ALL_NOTES:
1065             case FN_DELETE_COMMENT:
1066 			{
1067                 if ( !pPostItMgr ||
1068                      !pPostItMgr->HasActiveAnnotationWin() )
1069                 {
1070 					rSet.DisableItem(nWhich);
1071                 }
1072 				break;
1073 			}
1074 			case FN_REPLY:
1075 			{
1076                 if ( !pPostItMgr ||
1077                      !pPostItMgr->HasActiveAnnotationWin() )
1078                 {
1079 					rSet.DisableItem(nWhich);
1080                 }
1081 				else
1082 				{
1083 					SvtUserOptions aUserOpt;
1084 					String sAuthor;
1085 					if( !(sAuthor = aUserOpt.GetFullName()).Len())
1086 							if( !(sAuthor = aUserOpt.GetID()).Len() )
1087 						sAuthor = String( SW_RES( STR_REDLINE_UNKNOWN_AUTHOR ));
1088                     if (sAuthor == pPostItMgr->GetActiveSidebarWin()->GetAuthor())
1089 						rSet.DisableItem(nWhich);
1090 				}
1091 				break;
1092 			}
1093 			default:
1094 				rSet.InvalidateItem( nWhich );
1095 				break;
1096 		}
1097 
1098         if (pPostItMgr->HasActiveSidebarWin())
1099 		{
1100             if ( (pPostItMgr->GetActiveSidebarWin()->IsProtected()) &&
1101                     ( (nSlotId==FN_DELETE_COMMENT) || (nSlotId==FN_REPLY) ) )
1102 				rSet.DisableItem( nWhich );
1103 		}
1104 		nWhich = aIter.NextWhich();
1105 	}
1106 }
1107 
1108 void SwAnnotationShell::ExecLingu(SfxRequest &rReq)
1109 {
1110 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
1111     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1112 		return;
1113 
1114     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1115 	SfxItemSet aEditAttr(pOLV->GetAttribs());
1116 	sal_uInt16 nSlot = rReq.GetSlot();
1117 	SwWrtShell &rSh = rView.GetWrtShell();
1118 	bool bRestoreSelection = false;
1119 	ESelection aOldSelection;
1120 
1121 	switch (nSlot)
1122 	{
1123 		case SID_LANGUAGE_STATUS:
1124         {
1125 			aOldSelection = pOLV->GetSelection();
1126 			if (!pOLV->GetEditView().HasSelection())
1127 			{
1128 				bRestoreSelection	= true;
1129 				pOLV->GetEditView().SelectCurrentWord();
1130 			}
1131 
1132 			bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,rView,rSh);
1133 			break;
1134 		}
1135         case SID_THES:
1136         {
1137             String aReplaceText;
1138             SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False );
1139             if (pItem2)
1140                 aReplaceText = pItem2->GetValue();
1141             if (aReplaceText.Len() > 0)
1142                 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
1143             break;
1144         }
1145         case SID_THESAURUS:
1146 		{
1147             pOLV->StartThesaurus();
1148 			break;
1149 		}
1150 		case SID_HANGUL_HANJA_CONVERSION:
1151             pOLV->StartTextConversion( LANGUAGE_KOREAN, LANGUAGE_KOREAN, NULL,
1152                     i18n::TextConversionOption::CHARACTER_BY_CHARACTER, sal_True, sal_False );
1153             break;
1154 
1155         case SID_CHINESE_CONVERSION:
1156 		{
1157                 //open ChineseTranslationDialog
1158                 Reference< XComponentContext > xContext(
1159                     ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
1160                 if(xContext.is())
1161                 {
1162                     Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
1163                     if(xMCF.is())
1164                     {
1165                         Reference< ui::dialogs::XExecutableDialog > xDialog(
1166                                 xMCF->createInstanceWithContext(
1167                                     rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
1168                                     , xContext), UNO_QUERY);
1169                         Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
1170                         if( xInit.is() )
1171                         {
1172                             //  initialize dialog
1173                             Reference< awt::XWindow > xDialogParentWindow(0);
1174                             Sequence<Any> aSeq(1);
1175                             Any* pArray = aSeq.getArray();
1176                             PropertyValue aParam;
1177                             aParam.Name = rtl::OUString::createFromAscii("ParentWindow");
1178                             aParam.Value <<= makeAny(xDialogParentWindow);
1179                             pArray[0] <<= makeAny(aParam);
1180                             xInit->initialize( aSeq );
1181 
1182                             //execute dialog
1183                             sal_Int16 nDialogRet = xDialog->execute();
1184                             if( RET_OK == nDialogRet )
1185                             {
1186                                 //get some parameters from the dialog
1187                                 sal_Bool bToSimplified = sal_True;
1188                                 sal_Bool bUseVariants = sal_True;
1189                                 sal_Bool bCommonTerms = sal_True;
1190                                 Reference< beans::XPropertySet >  xProp( xDialog, UNO_QUERY );
1191                                 if( xProp.is() )
1192                                 {
1193                                     try
1194                                     {
1195                                         xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
1196                                         xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
1197                                         xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
1198                                     }
1199                                     catch( Exception& )
1200                                     {
1201                                     }
1202                                 }
1203 
1204                                 //execute translation
1205                                 sal_Int16 nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
1206                                 sal_Int16 nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
1207                                 sal_Int32 nOptions    = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
1208                                 if( !bCommonTerms )
1209                                     nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
1210 
1211                                 Font aTargetFont = pOLV->GetWindow()->GetDefaultFont( DEFAULTFONT_CJK_TEXT,
1212                                             nTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
1213 
1214                                 pOLV->StartTextConversion( nSourceLang, nTargetLang, &aTargetFont, nOptions, sal_False, sal_False );
1215                             }
1216                         }
1217                         Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
1218                         if( xComponent.is() )
1219                             xComponent->dispose();
1220                     }
1221                 }
1222             }
1223             break;
1224 	}
1225 
1226 	if (bRestoreSelection)
1227 	{
1228 		// restore selection
1229 		pOLV->GetEditView().SetSelection( aOldSelection );
1230 	}
1231 }
1232 
1233 void SwAnnotationShell::GetLinguState(SfxItemSet &rSet)
1234 {
1235 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
1236     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1237 		return;
1238 
1239     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1240 	SfxItemSet aEditAttr(pOLV->GetAttribs());
1241 
1242 	SfxWhichIter aIter(rSet);
1243 	sal_uInt16 nWhich = aIter.FirstWhich();
1244     while(nWhich)
1245 	{
1246 		switch (nWhich)
1247 		{
1248 			case SID_LANGUAGE_STATUS:
1249             {
1250 				SwLangHelper::GetLanguageStatus(pOLV,rSet);
1251 				break;
1252 			}
1253 
1254             case SID_THES:
1255             {
1256                 String          aStatusVal;
1257                 LanguageType    nLang = LANGUAGE_NONE;
1258                 bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() );
1259                 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
1260 
1261                 // disable "Thesaurus" context menu entry if there is nothing to look up
1262                 uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
1263                 lang::Locale aLocale( SvxCreateLocale( nLang ) );
1264                 if (!bIsLookUpWord ||
1265                     !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale ))
1266                     rSet.DisableItem( SID_THES );
1267                 break;
1268             }
1269 
1270             // disable "Thesaurus" if the language is not supported
1271             case SID_THESAURUS:
1272 			{
1273 				const SfxPoolItem &rItem = rView.GetWrtShell().GetDoc()->GetDefault(
1274                             GetWhichOfScript( RES_CHRATR_LANGUAGE,
1275                             GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage())) );
1276 				LanguageType nLang = ((const SvxLanguageItem &)
1277 														rItem).GetLanguage();
1278 				uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
1279 				if (!xThes.is() || nLang == LANGUAGE_NONE ||
1280 					!xThes->hasLocale( SvxCreateLocale( nLang ) ))
1281                     rSet.DisableItem( SID_THESAURUS );
1282 			}
1283 			break;
1284 			case SID_HANGUL_HANJA_CONVERSION:
1285 			case SID_CHINESE_CONVERSION:
1286 			{
1287 				if (!SvtCJKOptions().IsAnyEnabled())
1288 				{
1289 					rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
1290 					rSet.DisableItem(nWhich);
1291 				}
1292 				else
1293 					rView.GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
1294 			}
1295 			break;
1296 		}
1297 
1298         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
1299 			rSet.DisableItem( nWhich );
1300 
1301 		nWhich = aIter.NextWhich();
1302 	}
1303 }
1304 
1305 void SwAnnotationShell::ExecTransliteration(SfxRequest &rReq)
1306 {
1307 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
1308     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1309 		return;
1310 
1311     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1312 
1313 	using namespace ::com::sun::star::i18n;
1314 	{
1315 		sal_uInt32 nMode = 0;
1316 
1317 		switch( rReq.GetSlot() )
1318 		{
1319             case SID_TRANSLITERATE_SENTENCE_CASE:
1320                 nMode = TransliterationModulesExtra::SENTENCE_CASE;
1321                 break;
1322             case SID_TRANSLITERATE_TITLE_CASE:
1323                 nMode = TransliterationModulesExtra::TITLE_CASE;
1324                 break;
1325             case SID_TRANSLITERATE_TOGGLE_CASE:
1326                 nMode = TransliterationModulesExtra::TOGGLE_CASE;
1327                 break;
1328 			case SID_TRANSLITERATE_UPPER:
1329 				nMode = TransliterationModules_LOWERCASE_UPPERCASE;
1330 				break;
1331 			case SID_TRANSLITERATE_LOWER:
1332 				nMode = TransliterationModules_UPPERCASE_LOWERCASE;
1333 				break;
1334 			case SID_TRANSLITERATE_HALFWIDTH:
1335 				nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
1336 				break;
1337 			case SID_TRANSLITERATE_FULLWIDTH:
1338 				nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
1339 				break;
1340 			case SID_TRANSLITERATE_HIRAGANA:
1341 				nMode = TransliterationModules_KATAKANA_HIRAGANA;
1342 				break;
1343 			case SID_TRANSLITERATE_KATAGANA:
1344 				nMode = TransliterationModules_HIRAGANA_KATAKANA;
1345 				break;
1346 
1347 			default:
1348 				ASSERT(!this, "falscher Dispatcher");
1349 		}
1350 
1351 		if( nMode )
1352         {
1353             pOLV->TransliterateText( nMode );
1354         }
1355 	}
1356 }
1357 
1358 void SwAnnotationShell::ExecUndo(SfxRequest &rReq)
1359 {
1360 	const SfxItemSet* pArgs = rReq.GetArgs();
1361 	::svl::IUndoManager* pUndoManager = GetUndoManager();
1362 	SwWrtShell &rSh = rView.GetWrtShell();
1363 
1364     long aOldHeight = rView.GetPostItMgr()->HasActiveSidebarWin()
1365                       ? rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight()
1366                       : 0;
1367 
1368 	sal_uInt16 nId = rReq.GetSlot();
1369 	sal_uInt16 nCnt = 1;
1370 	const SfxPoolItem* pItem=0;
1371 	if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, sal_False, &pItem ) )
1372 		nCnt = ((SfxUInt16Item*)pItem)->GetValue();
1373 	switch( nId )
1374 	{
1375 		case SID_UNDO:
1376 		{
1377 			if ( pUndoManager )
1378 			{
1379 				sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
1380 				sal_uInt16 nSteps = nCnt;
1381 				if ( nCount < nCnt )
1382 				{
1383 					nCnt = nCnt - nCount;
1384 					nSteps = nCount;
1385 				}
1386 				else
1387 					nCnt = 0;
1388 
1389 				while( nSteps-- )
1390 					pUndoManager->Undo();
1391 			}
1392 
1393 			if ( nCnt )
1394 				rSh.Do( SwWrtShell::UNDO, nCnt );
1395 
1396 			break;
1397 		}
1398 
1399 		case SID_REDO:
1400 		{
1401 			if ( pUndoManager )
1402 			{
1403 				sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
1404 				sal_uInt16 nSteps = nCnt;
1405 				if ( nCount < nCnt )
1406 				{
1407 					nCnt = nCnt - nCount;
1408 					nSteps = nCount;
1409 				}
1410 				else
1411 					nCnt = 0;
1412 
1413 				while( nSteps-- )
1414                     pUndoManager->Redo();
1415 			}
1416 
1417 			if ( nCnt )
1418 				rSh.Do( SwWrtShell::REDO, nCnt );
1419 
1420 			break;
1421 		}
1422 	}
1423 
1424 	rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False);
1425 
1426     if (rView.GetPostItMgr()->HasActiveSidebarWin())
1427         rView.GetPostItMgr()->GetActiveSidebarWin()->ResizeIfNeccessary(aOldHeight,rView.GetPostItMgr()->GetActiveSidebarWin()->GetPostItTextHeight());
1428 }
1429 
1430 void SwAnnotationShell::StateUndo(SfxItemSet &rSet)
1431 {
1432 	SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
1433     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1434 		return;
1435 
1436 	SfxWhichIter aIter(rSet);
1437 	sal_uInt16 nWhich = aIter.FirstWhich();
1438 	::svl::IUndoManager* pUndoManager = GetUndoManager();
1439 	SfxViewFrame *pSfxViewFrame = rView.GetViewFrame();
1440 	SwWrtShell &rSh = rView.GetWrtShell();
1441 
1442 	while( nWhich )
1443 	{
1444 		switch ( nWhich )
1445 		{
1446 		case SID_UNDO:
1447 			{
1448 				sal_uInt16 nCount = pUndoManager->GetUndoActionCount();
1449 				if ( nCount )
1450 					pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
1451                 else if (rSh.GetLastUndoInfo(0, 0))
1452                 {
1453 					rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) );
1454                 }
1455 				else
1456 					rSet.DisableItem(nWhich);
1457 				break;
1458 			}
1459 		case SID_REDO:
1460 			{
1461 				sal_uInt16 nCount = pUndoManager->GetRedoActionCount();
1462 				if ( nCount )
1463 					pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
1464                 else if (rSh.GetFirstRedoInfo(0))
1465                 {
1466 					rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) );
1467                 }
1468 				else
1469 					rSet.DisableItem(nWhich);
1470 				break;
1471 			}
1472 		case SID_GETUNDOSTRINGS:
1473 		case SID_GETREDOSTRINGS:
1474 			{
1475 				if( pUndoManager )
1476 				{
1477 					UniString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const;
1478 
1479 					sal_uInt16 nCount;
1480 					if( SID_GETUNDOSTRINGS == nWhich )
1481 					{
1482 						nCount = pUndoManager->GetUndoActionCount();
1483 						fnGetComment = &::svl::IUndoManager::GetUndoActionComment;
1484 					}
1485 					else
1486 					{
1487 						nCount = pUndoManager->GetRedoActionCount();
1488 						fnGetComment = &::svl::IUndoManager::GetRedoActionComment;
1489 					}
1490 
1491 					String sList;
1492 					if( nCount )
1493 					{
1494 						for( sal_uInt16 n = 0; n < nCount; ++n )
1495                             ( sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) )
1496 									+= '\n';
1497 					}
1498 
1499 					SfxStringListItem aItem( nWhich );
1500                     if ((nWhich == SID_GETUNDOSTRINGS) &&
1501                         rSh.GetLastUndoInfo(0, 0))
1502                     {
1503 						rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
1504                     }
1505                     else if ((nWhich == SID_GETREDOSTRINGS) &&
1506                              (rSh.GetFirstRedoInfo(0)))
1507                     {
1508 						rSh.GetDoStrings( SwWrtShell::UNDO, aItem );
1509 					}
1510 
1511 					sList += aItem.GetString();
1512 					aItem.SetString( sList );
1513 					rSet.Put( aItem );
1514 				}
1515 				else
1516 					rSet.DisableItem( nWhich );
1517 			}
1518 			break;
1519 
1520 		default:
1521 			{
1522 				pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet );
1523 				break;
1524 			}
1525 
1526 		}
1527 
1528         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
1529 			rSet.DisableItem( nWhich );
1530 
1531 		nWhich = aIter.NextWhich();
1532 	}
1533 }
1534 
1535 void SwAnnotationShell::StateDisableItems( SfxItemSet &rSet )
1536 {
1537 	SfxWhichIter aIter(rSet);
1538 	sal_uInt16 nWhich = aIter.FirstWhich();
1539 	while (nWhich)
1540 	{
1541 		rSet.DisableItem( nWhich );
1542 		nWhich = aIter.NextWhich();
1543 	}
1544 }
1545 
1546 void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
1547 {
1548     SwPostItMgr* pPostItMgr = rView.GetPostItMgr();
1549     if ( !pPostItMgr || !pPostItMgr->HasActiveSidebarWin() )
1550 		return;
1551 
1552     OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView();
1553 
1554     const SfxItemSet *pArgs = rReq.GetArgs();
1555     const SfxPoolItem* pItem = 0;
1556     if( pArgs )
1557         pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
1558 
1559     String sSym;
1560     String sFontName;
1561     if ( pItem )
1562     {
1563         sSym = ((const SfxStringItem*)pItem)->GetValue();
1564         const SfxPoolItem* pFtItem = NULL;
1565         pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
1566         const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
1567         if ( pFontItem )
1568             sFontName = pFontItem->GetValue();
1569     }
1570 
1571     SfxItemSet aSet(pOLV->GetAttribs());
1572     sal_uInt16 nScript = pOLV->GetSelectedScriptType();
1573     SvxFontItem aSetDlgFont( RES_CHRATR_FONT );
1574     {
1575         SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
1576         aSetItem.GetItemSet().Put( aSet, sal_False );
1577         const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
1578         if( pI )
1579             aSetDlgFont = *(SvxFontItem*)pI;
1580         else
1581             aSetDlgFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
1582                         SID_ATTR_CHAR_FONT,
1583                         GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
1584 		if (!sFontName.Len())
1585 			sFontName = aSetDlgFont.GetFamilyName();
1586     }
1587 
1588 	Font aFont(sFontName, Size(1,1));
1589     if( !sSym.Len() )
1590     {
1591 		SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1592 
1593         SfxAllItemSet aAllSet( GetPool() );
1594         aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
1595 
1596         SwViewOption aOpt(*rView.GetWrtShell().GetViewOptions());
1597         String sSymbolFont = aOpt.GetSymbolFont();
1598         if( sSymbolFont.Len() )
1599             aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
1600         else
1601             aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) );
1602 
1603         // Wenn Zeichen selektiert ist kann es angezeigt werden
1604         SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
1605 			rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
1606 
1607         sal_uInt16 nResult = pDlg->Execute();
1608         if( nResult == RET_OK )
1609         {
1610             SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, sal_False );
1611 			SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
1612 			if ( pFontItem )
1613 			{
1614 				aFont.SetName( pFontItem->GetFamilyName() );
1615 				aFont.SetStyleName( pFontItem->GetStyleName() );
1616 				aFont.SetCharSet( pFontItem->GetCharSet() );
1617 				aFont.SetPitch( pFontItem->GetPitch() );
1618 			}
1619 
1620             if ( pCItem )
1621 			{
1622                 sSym  = pCItem->GetValue();
1623 				aOpt.SetSymbolFont(aFont.GetName());
1624 				SW_MOD()->ApplyUsrPref(aOpt, &rView);
1625 			}
1626         }
1627 
1628 		delete( pDlg );
1629     }
1630 
1631     if( sSym.Len() )
1632 	{
1633 		// nicht flackern
1634 		pOLV->HideCursor();
1635         Outliner * pOutliner = pOLV->GetOutliner();
1636         pOutliner->SetUpdateMode(sal_False);
1637 
1638 		SfxItemSet aOldSet( pOLV->GetAttribs() );
1639 		SfxItemSet aFontSet( *aOldSet.GetPool(),
1640 							EE_CHAR_FONTINFO, EE_CHAR_FONTINFO,
1641 							EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CJK,
1642 							EE_CHAR_FONTINFO_CTL, EE_CHAR_FONTINFO_CTL,
1643 							0 );
1644 		aFontSet.Set( aOldSet );
1645 
1646 		// String einfuegen
1647         pOLV->InsertText( sSym);
1648 
1649 		// attributieren (Font setzen)
1650 		SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() );
1651 		SvxFontItem aFontItem (aFont.GetFamily(),	 aFont.GetName(),
1652 								aFont.GetStyleName(), aFont.GetPitch(),
1653 								aFont.GetCharSet(),
1654 								EE_CHAR_FONTINFO );
1655 		sal_uInt16 nScriptBreak = pBreakIt->GetAllScriptsOfText( sSym );
1656 		if( SCRIPTTYPE_LATIN & nScriptBreak )
1657 			aSetFont.Put( aFontItem, EE_CHAR_FONTINFO );
1658 		if( SCRIPTTYPE_ASIAN & nScriptBreak )
1659 			aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
1660 		if( SCRIPTTYPE_COMPLEX & nScriptBreak )
1661 			aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
1662 		pOLV->SetAttribs(aSetFont);
1663 
1664 		// Selektion loeschen
1665 		ESelection aSel(pOLV->GetSelection());
1666 		aSel.nStartPara = aSel.nEndPara;
1667 		aSel.nStartPos = aSel.nEndPos;
1668 		pOLV->SetSelection(aSel);
1669 
1670 		// Alten Font restaurieren
1671 		pOLV->SetAttribs( aFontSet );
1672 
1673 		// ab jetzt wieder anzeigen
1674 		pOutliner->SetUpdateMode(sal_True);
1675 		pOLV->ShowCursor();
1676 
1677 		rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), sSym ) );
1678         if(aFont.GetName().Len())
1679             rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aFont.GetName() ) );
1680         rReq.Done();
1681 	}
1682 }
1683