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