xref: /aoo42x/main/sw/source/ui/shells/drwtxtex.cxx (revision 766ce4d0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
28 
29 #include <comphelper/processfactory.hxx>
30 #include <i18npool/mslangid.hxx>
31 #include <sfx2/bindings.hxx>
32 #include <sfx2/dispatch.hxx>
33 #include <sfx2/request.hxx>
34 #include <tools/shl.hxx>
35 #include <svx/svdview.hxx>
36 #include <editeng/spltitem.hxx>
37 #include <editeng/lrspitem.hxx>
38 #include <editeng/ulspitem.hxx>
39 #include <editeng/orphitem.hxx>
40 #include <editeng/brkitem.hxx>
41 #include <editeng/widwitem.hxx>
42 #include <editeng/kernitem.hxx>
43 #include <editeng/escpitem.hxx>
44 #include <editeng/lspcitem.hxx>
45 #include <editeng/adjitem.hxx>
46 #include <editeng/crsditem.hxx>
47 #include <editeng/shdditem.hxx>
48 #include <editeng/hyznitem.hxx>
49 #include <editeng/udlnitem.hxx>
50 #include <editeng/fontitem.hxx>
51 #include <editeng/fhgtitem.hxx>
52 #include <editeng/colritem.hxx>
53 #include <editeng/wghtitem.hxx>
54 #include <editeng/cntritem.hxx>
55 #include <editeng/postitem.hxx>
56 #include <editeng/frmdiritem.hxx>
57 #include <svx/svdoutl.hxx>
58 #include <sfx2/viewfrm.hxx>
59 #include <svl/whiter.hxx>
60 #include <svl/cjkoptions.hxx>
61 #include <svl/ctloptions.hxx>
62 #include <svtools/langtab.hxx>
63 #include <svl/languageoptions.hxx>
64 #include <sfx2/bindings.hxx>
65 #include <vcl/msgbox.hxx>
66 #include <sfx2/dispatch.hxx>
67 #include <sfx2/request.hxx>
68 #include <editeng/flditem.hxx>
69 #include <editeng/editstat.hxx>
70 #include <svx/hlnkitem.hxx>
71 #include <svx/htmlmode.hxx>
72 #include <svl/languageoptions.hxx>
73 #include <svl/slstitm.hxx>
74 #include <editeng/langitem.hxx>
75 #include <svtools/langtab.hxx>
76 #include <editeng/unolingu.hxx>
77 #include <editeng/scripttypeitem.hxx>
78 #include <editeng/writingmodeitem.hxx>
79 #include <editeng/eeitem.hxx>
80 #include <editeng/editeng.hxx>
81 #include <editeng/editdata.hxx>
82 #include <editeng/outliner.hxx>
83 #include <vcl/window.hxx>
84 #include <editeng/editview.hxx>
85 #include <vcl/outdev.hxx>
86 #include <editeng/hyznitem.hxx>
87 #include <editeng/kernitem.hxx>
88 #include <editeng/langitem.hxx>
89 #include <editeng/lspcitem.hxx>
90 #include <editeng/orphitem.hxx>
91 #include <editeng/outliner.hxx>
92 #include <editeng/postitem.hxx>
93 #include <editeng/scripttypeitem.hxx>
94 #include <editeng/shdditem.hxx>
95 #include <editeng/spltitem.hxx>
96 #include <svx/svdoutl.hxx>
97 #include <svx/svdview.hxx>
98 #include <editeng/udlnitem.hxx>
99 #include <editeng/unolingu.hxx>
100 #include <editeng/wghtitem.hxx>
101 #include <editeng/widwitem.hxx>
102 #include <editeng/writingmodeitem.hxx>
103 #include <tools/shl.hxx>
104 #include <vcl/msgbox.hxx>
105 #include <vcl/outdev.hxx>
106 #include <vcl/window.hxx>
107 
108 #include <cmdid.h>
109 #include <doc.hxx>
110 #include <docstat.hxx>
111 #include <drwtxtsh.hxx>
112 #include <edtwin.hxx>
113 #include <globals.hrc>
114 #include <hintids.hxx>
115 #include <initui.hxx>               // fuer SpellPointer
116 #include <langhelper.hxx>
117 #include <pardlg.hxx>
118 #include <shells.hrc>
119 #include <string.h>
120 #include <swdtflvr.hxx>
121 #include <swmodule.hxx>
122 #include <swwait.hxx>
123 #include <uitool.hxx>
124 #include <viewopt.hxx>
125 #include <wrtsh.hxx>
126 #include <wview.hxx>
127 
128 #include "swabstdlg.hxx"
129 #include "chrdlg.hrc"
130 #include "misc.hrc"
131 
132 
133 #include <langhelper.hxx>
134 
135 using namespace ::com::sun::star;
136 
137 /*--------------------------------------------------------------------
138 	Beschreibung:
139  --------------------------------------------------------------------*/
140 
141 void SwDrawTextShell::Execute( SfxRequest &rReq )
142 {
143 	SwWrtShell &rSh = GetShell();
144     	OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
145     	SfxItemSet aEditAttr(pOLV->GetAttribs());
146 	SfxItemSet aNewAttr(*aEditAttr.GetPool(), aEditAttr.GetRanges());
147 
148 	sal_uInt16 nSlot = rReq.GetSlot();
149 
150 	sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
151 	const SfxItemSet *pNewAttrs = rReq.GetArgs();
152 
153 	bool bRestoreSelection = false;
154 	ESelection aOldSelection;
155 
156 	sal_uInt16 nEEWhich = 0;
157 	switch (nSlot)
158 	{
159 		case SID_LANGUAGE_STATUS:
160         {
161 			aOldSelection = pOLV->GetSelection();
162 			if (!pOLV->GetEditView().HasSelection())
163 			{
164 				bRestoreSelection	= true;
165 				pOLV->GetEditView().SelectCurrentWord();
166 			}
167 
168 			bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,GetView(),rSh);
169 			break;
170         }
171 
172         case SID_THES:
173         {
174             String aReplaceText;
175             SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False );
176             if (pItem2)
177                 aReplaceText = pItem2->GetValue();
178             if (aReplaceText.Len() > 0)
179                 ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
180             break;
181         }
182 
183         case SID_ATTR_CHAR_FONT:
184         case SID_ATTR_CHAR_FONTHEIGHT:
185         case SID_ATTR_CHAR_WEIGHT:
186         case SID_ATTR_CHAR_POSTURE:
187         {
188             SfxItemPool* pPool2 = aEditAttr.GetPool()->GetSecondaryPool();
189             if( !pPool2 )
190                 pPool2 = aEditAttr.GetPool();
191             SvxScriptSetItem aSetItem( nSlot, *pPool2 );
192 
193             // #i78017 establish the same behaviour as in Writer
194             sal_uInt16 nScriptTypes = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
195             if (nSlot == SID_ATTR_CHAR_FONT)
196                 nScriptTypes = pOLV->GetSelectedScriptType();
197 
198             aSetItem.PutItemForScriptType( nScriptTypes, pNewAttrs->Get( nWhich ) );
199             aNewAttr.Put( aSetItem.GetItemSet() );
200         }
201         break;
202 
203         case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
204 
205 		case SID_ATTR_CHAR_UNDERLINE:
206 		{
207 		 	FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
208 			aNewAttr.Put(SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE));
209 		}
210 		break;
211 
212 		case SID_ATTR_CHAR_OVERLINE:
213 		{
214 		 	FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle();
215 			aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE));
216 		}
217 		break;
218 
219         case SID_ATTR_CHAR_CONTOUR:     nEEWhich = EE_CHAR_OUTLINE; break;
220         case SID_ATTR_CHAR_SHADOWED:    nEEWhich = EE_CHAR_SHADOW; break;
221         case SID_ATTR_CHAR_STRIKEOUT:   nEEWhich = EE_CHAR_STRIKEOUT; break;
222         case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
223         case SID_ATTR_CHAR_RELIEF      : nEEWhich = EE_CHAR_RELIEF;  break;
224         case SID_ATTR_CHAR_LANGUAGE    : nEEWhich = EE_CHAR_LANGUAGE;break;
225         case SID_ATTR_CHAR_KERNING     : nEEWhich = EE_CHAR_KERNING; break;
226         case SID_ATTR_CHAR_SCALEWIDTH:   nEEWhich = EE_CHAR_FONTWIDTH; break;
227         case SID_ATTR_CHAR_AUTOKERN  :   nEEWhich = EE_CHAR_PAIRKERNING; break;
228         case SID_ATTR_CHAR_ESCAPEMENT:   nEEWhich = EE_CHAR_ESCAPEMENT; break;
229         case SID_ATTR_PARA_ADJUST_LEFT:
230 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST));
231         break;
232 		case SID_ATTR_PARA_ADJUST_CENTER:
233 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
234         break;
235 		case SID_ATTR_PARA_ADJUST_RIGHT:
236 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST));
237         break;
238 		case SID_ATTR_PARA_ADJUST_BLOCK:
239 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST));
240         break;
241 		case SID_ATTR_PARA_LRSPACE:
242 			{
243 				SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
244 										GetArgs()->Get(nSlot));
245 				aParaMargin.SetWhich( EE_PARA_LRSPACE );
246 				aNewAttr.Put(aParaMargin);
247 				rReq.Done();
248 			}
249 			break;
250 		case SID_ATTR_PARA_LINESPACE:
251 			{
252 				SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pNewAttrs->Get(
253 															GetPool().GetWhich(nSlot));
254 				aLineSpace.SetWhich( EE_PARA_SBL );
255 				aNewAttr.Put( aLineSpace );
256 				rReq.Done();
257 			}
258 			break;
259 		case SID_ATTR_PARA_ULSPACE:
260 			{
261 				SvxULSpaceItem aULSpace = (const SvxULSpaceItem&)pNewAttrs->Get(
262 					GetPool().GetWhich(nSlot));
263 				aULSpace.SetWhich( EE_PARA_ULSPACE );
264 				aNewAttr.Put( aULSpace );
265 				rReq.Done();
266 			}
267 			break;
268 
269 		case SID_ATTR_PARA_LINESPACE_10:
270 		{
271 			SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL);
272 			aItem.SetPropLineSpace(100);
273 			aNewAttr.Put(aItem);
274 		}
275 		break;
276 		case SID_ATTR_PARA_LINESPACE_15:
277 		{
278 			SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL);
279 			aItem.SetPropLineSpace(150);
280 			aNewAttr.Put(aItem);
281 		}
282 		break;
283 		case SID_ATTR_PARA_LINESPACE_20:
284 		{
285 			SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL);
286 			aItem.SetPropLineSpace(200);
287 			aNewAttr.Put(aItem);
288 		}
289 		break;
290 
291 		case FN_SET_SUPER_SCRIPT:
292 		{
293 			SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
294 			SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
295 							aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
296 
297 			if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
298 				aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
299 			else
300 				aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
301 			aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
302 		}
303 		break;
304 		case FN_SET_SUB_SCRIPT:
305 		{
306 			SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
307 			SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
308 							aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
309 
310 			if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
311 				aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
312 			else
313 				aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
314 			aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
315 		}
316 		break;
317 
318 		case SID_CHAR_DLG_EFFECT:
319 		case SID_CHAR_DLG:
320 		case SID_CHAR_DLG_FOR_PARAGRAPH:
321 		{
322 			const SfxItemSet* pArgs = rReq.GetArgs();
323 
324 			if( !pArgs )
325 			{
326 				aOldSelection = pOLV->GetSelection();
327 				if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
328 				{
329 					// select current paragraph (and restore selection later on...)
330 					EditView & rEditView = pOLV->GetEditView();
331 					SwLangHelper::SelectPara( rEditView, rEditView.GetSelection() );
332 					bRestoreSelection = true;
333 				}
334 
335 				SwView* pView = &GetView();
336 				FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
337                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
338 				SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END);
339 
340 				// util::Language gibts an der EditEngine nicht! Daher nicht im Set.
341 
342 				aDlgAttr.Put( aEditAttr );
343                 aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
344 
345                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
346                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
347 
348                 SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( pView->GetWindow(), *pView, aDlgAttr, DLG_CHAR,0, sal_True );
349                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
350 				if (nSlot == SID_CHAR_DLG_EFFECT)
351 				{
352 					pDlg->SetCurPageId(TP_CHAR_EXT);
353 				}
354 				sal_uInt16 nRet = pDlg->Execute();
355 				if(RET_OK == nRet )
356                 {
357                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
358                     aNewAttr.Put(*pDlg->GetOutputItemSet());
359                 }
360 				delete( pDlg );
361 				if(RET_OK != nRet)
362 					return ;
363 			}
364 			else
365 				aNewAttr.Put(*pArgs);
366 		}
367 		break;
368 		case FN_FORMAT_FOOTNOTE_DLG:
369 		{
370             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
371             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
372 
373             VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE );
374             DBG_ASSERT(pDlg, "Dialogdiet fail!");
375 			pDlg->Execute();
376 			delete pDlg;
377 			break;
378 		}
379 		case FN_NUMBERING_OUTLINE_DLG:
380 		{
381 			SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
382 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
383             DBG_ASSERT(pFact, "Dialogdiet fail!");
384             SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
385 														GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
386             DBG_ASSERT(pDlg, "Dialogdiet fail!");
387 			pDlg->Execute();
388 			delete pDlg;
389 			rReq.Done();
390 		}
391 		break;
392 		case SID_OPEN_XML_FILTERSETTINGS:
393 		{
394 			try
395 			{
396 				uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY);
397 				if( xDialog.is() )
398 				{
399 					xDialog->execute();
400 				}
401 			}
402 			catch( uno::Exception& )
403 			{
404 			}
405 			rReq.Ignore ();
406 		}
407 		break;
408 		case FN_WORDCOUNT_DIALOG:
409 		{
410 			SwDocStat aCurr;
411 			SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
412 			{
413 				SwWait aWait( *GetView().GetDocShell(), sal_True );
414 				rSh.StartAction();
415 				rSh.CountWords( aCurr );
416 				rSh.UpdateDocStat( aDocStat );
417 				rSh.EndAction();
418 			}
419 
420 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
421 			DBG_ASSERT(pFact, "Dialogdiet fail!");
422 			AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() );
423 			pDialog->SetValues(aCurr, aDocStat );
424 			pDialog->Execute();
425 			delete pDialog;
426 		}
427 		break;
428 		case SID_PARA_DLG:
429 		{
430 			const SfxItemSet* pArgs = rReq.GetArgs();
431 
432 			if (!pArgs)
433 			{
434 				SwView* pView = &GetView();
435 				FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
436                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
437 				SfxItemSet aDlgAttr(GetPool(),
438 									EE_ITEMS_START, EE_ITEMS_END,
439 									SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
440 									SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
441 									SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
442 									SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
443 									0);
444 
445 				aDlgAttr.Put(aEditAttr);
446 
447 				// Die Werte sind erst einmal uebernommen worden, um den Dialog anzuzeigen.
448 				// Muss natuerlich noch geaendert werden
449 				// aDlgAttr.Put( SvxParaDlgLimitsItem( 567 * 50, 5670) );
450 
451                 aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) );
452                 aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
453                 aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) );
454                 aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
455                 aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
456 
457                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
458                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
459 
460                 SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True );
461                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
462 				sal_uInt16 nRet = pDlg->Execute();
463 				if(RET_OK == nRet)
464                 {
465                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
466                     aNewAttr.Put(*pDlg->GetOutputItemSet());
467                 }
468 				delete( pDlg );
469 				if(RET_OK != nRet)
470 					return;
471 			}
472 			else
473 				aNewAttr.Put(*pArgs);
474 		}
475 		break;
476 		case SID_AUTOSPELL_CHECK:
477 		{
478 //!! JP 16.03.2001: why??			pSdrView = rSh.GetDrawView();
479 //!! JP 16.03.2001: why??			pOutliner = pSdrView->GetTextEditOutliner();
480             SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
481             sal_uInt32 nCtrl = pOutliner->GetControlWord();
482 
483 			sal_Bool bSet = ((const SfxBoolItem&)rReq.GetArgs()->Get(
484 													nSlot)).GetValue();
485             if(bSet)
486                 nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS;
487             else
488                 nCtrl &= ~EE_CNTRL_ONLINESPELLING;
489 			pOutliner->SetControlWord(nCtrl);
490 
491             rView.ExecuteSlot(rReq);
492 		}
493 		break;
494 		case SID_HYPERLINK_SETLINK:
495 		{
496 			const SfxPoolItem* pItem = 0;
497 			if(pNewAttrs)
498 				pNewAttrs->GetItemState(nSlot, sal_False, &pItem);
499 
500 			if(pItem)
501 			{
502 				const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
503 				SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT);
504 				aFld.SetTargetFrame(rHLinkItem.GetTargetFrame());
505 
506 				const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
507 
508 				if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField))
509 				{
510 					// Feld selektieren, so dass es beim Insert geloescht wird
511 					ESelection aSel = pOLV->GetSelection();
512 					aSel.nEndPos++;
513 					pOLV->SetSelection(aSel);
514 				}
515                 pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD));
516 			}
517 		}
518 		break;
519 
520 		case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
521     	case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
522 			// Shellwechsel!
523 			{
524 				SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
525 				SdrPageView* pTmpPV = pSdrView->GetSdrPageView();
526 				SdrView* pTmpView = pSdrView;
527 
528                 pSdrView->SdrEndTextEdit(sal_True);
529 
530 				SfxItemSet aAttr( *aNewAttr.GetPool(),
531 							SDRATTR_TEXTDIRECTION,
532 							SDRATTR_TEXTDIRECTION );
533 
534 				aAttr.Put( SvxWritingModeItem(
535 					nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
536                         text::WritingMode_LR_TB
537                         : text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION ) );
538 				pTmpView->SetAttributes( aAttr );
539 
540 				rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), sal_False);
541 				rSh.GetView().AttrChangedNotify( &rSh );
542 			}
543 			return;
544 
545         case SID_ATTR_PARA_LEFT_TO_RIGHT:
546         case SID_ATTR_PARA_RIGHT_TO_LEFT:
547         {
548             SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
549             SdrPageView* pTmpPV = pSdrView->GetSdrPageView();
550             SdrView* pTmpView = pSdrView;
551 
552             pSdrView->SdrEndTextEdit(sal_True);
553             sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
554 
555             const SfxPoolItem* pPoolItem;
556             if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, sal_True, &pPoolItem ) )
557             {
558                 if( !( (SfxBoolItem*)pPoolItem)->GetValue() )
559                     bLeftToRight = !bLeftToRight;
560             }
561             SfxItemSet aAttr( *aNewAttr.GetPool(),
562                         EE_PARA_JUST, EE_PARA_JUST,
563                         EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
564                         0 );
565 
566             sal_uInt16 nAdjust = SVX_ADJUST_LEFT;
567             if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, sal_True, &pPoolItem ) )
568                 nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
569 
570             if( bLeftToRight )
571             {
572                 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
573                 if( nAdjust == SVX_ADJUST_RIGHT )
574                     aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
575             }
576             else
577             {
578                 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
579                 if( nAdjust == SVX_ADJUST_LEFT )
580                     aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
581             }
582             pTmpView->SetAttributes( aAttr );
583             rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), sal_False );
584             rSh.GetView().AttrChangedNotify( &rSh );
585         }
586         return;
587 		default:
588 			ASSERT(!this, falscher Dispatcher);
589 			return;
590 	}
591     if(nEEWhich && pNewAttrs)
592         aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
593 
594 	SetAttrToMarked(aNewAttr);
595 
596 	GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
597 
598 	if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
599 		rSh.SetModified();
600 
601 	if (bRestoreSelection)
602 	{
603 		// restore selection
604 		pOLV->GetEditView().SetSelection( aOldSelection );
605 	}
606 }
607 
608 /*--------------------------------------------------------------------
609 	Beschreibung:
610  --------------------------------------------------------------------*/
611 
612 void SwDrawTextShell::GetState(SfxItemSet& rSet)
613 {
614 	if (!IsTextEdit())	// Sonst manchmal Absturz!
615 		return;
616 
617 	OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
618     SfxWhichIter aIter(rSet);
619 	sal_uInt16 nWhich = aIter.FirstWhich();
620 
621     SfxItemSet aEditAttr( pOLV->GetAttribs() );
622 	const SfxPoolItem *pAdjust = 0, *pLSpace = 0, *pEscItem = 0;
623 	int eAdjust, nLSpace, nEsc;
624 
625 	while(nWhich)
626 	{
627 		sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
628 		sal_Bool bFlag = sal_False;
629 		switch( nSlotId )
630 		{
631 		    case SID_LANGUAGE_STATUS://20412:
632             {
633 				nSlotId = SwLangHelper::GetLanguageStatus(pOLV,rSet);;
634 				break;
635 			}
636 
637             case SID_THES:
638             {
639                 String          aStatusVal;
640                 LanguageType    nLang = LANGUAGE_NONE;
641                 bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() );
642                 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
643 
644                 // disable "Thesaurus" context menu entry if there is nothing to look up
645                 uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
646                 lang::Locale aLocale( SvxCreateLocale( nLang ) );
647                 if (!bIsLookUpWord ||
648                     !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale ))
649                     rSet.DisableItem( SID_THES );
650 
651                 //! avoid puting the same item as SfxBoolItem at the end of this function
652                 nSlotId = 0;
653                 break;
654             }
655 
656         case SID_ATTR_PARA_ADJUST_LEFT:     eAdjust = SVX_ADJUST_LEFT; goto ASK_ADJUST;
657 		case SID_ATTR_PARA_ADJUST_RIGHT:	eAdjust = SVX_ADJUST_RIGHT; goto ASK_ADJUST;
658 		case SID_ATTR_PARA_ADJUST_CENTER:	eAdjust = SVX_ADJUST_CENTER; goto ASK_ADJUST;
659 		case SID_ATTR_PARA_ADJUST_BLOCK:	eAdjust = SVX_ADJUST_BLOCK; goto ASK_ADJUST;
660 ASK_ADJUST:
661 			{
662 				if( !pAdjust )
663 					aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust);
664 
665 				if( !pAdjust || IsInvalidItem( pAdjust ))
666 					rSet.InvalidateItem( nSlotId ), nSlotId = 0;
667 				else
668 					bFlag = eAdjust == ((SvxAdjustItem*)pAdjust)->GetAdjust();
669 			}
670 			break;
671 
672 		case SID_ATTR_PARA_LRSPACE:
673 			{
674 				SfxItemState eState = aEditAttr.GetItemState(EE_PARA_LRSPACE);
675 				if( eState >= SFX_ITEM_DEFAULT )
676 				{
677 					SvxLRSpaceItem aLR = (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE );
678 					aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
679 					rSet.Put(aLR);
680 				}
681 				else
682 					rSet.InvalidateItem(nSlotId);
683 				nSlotId = 0;
684 			}
685 			break;
686 		case SID_ATTR_PARA_LINESPACE:
687 			{
688 				SfxItemState eState = aEditAttr.GetItemState(EE_PARA_SBL);
689 				if( eState >= SFX_ITEM_DEFAULT )
690 				{
691 					SvxLineSpacingItem aLR = (const SvxLineSpacingItem&) aEditAttr.Get( EE_PARA_SBL );
692 					rSet.Put(aLR);
693 				}
694 				else
695 					rSet.InvalidateItem(nSlotId);
696 				nSlotId = 0;
697 			}
698 			break;
699 		case SID_ATTR_PARA_ULSPACE:
700 			{
701 				SfxItemState eState = aEditAttr.GetItemState(EE_PARA_ULSPACE);
702 				if( eState >= SFX_ITEM_DEFAULT )
703 				{
704 					SvxULSpaceItem aULSpace = (const SvxULSpaceItem&) aEditAttr.Get( EE_PARA_ULSPACE );
705 					aULSpace.SetWhich(SID_ATTR_PARA_ULSPACE);
706 					rSet.Put(aULSpace);
707 				}
708 				else
709 					rSet.InvalidateItem(nSlotId);
710 				Invalidate(SID_ATTR_PARA_ULSPACE);
711 				nSlotId = 0;
712 			}
713 			break;
714 
715 		case SID_ATTR_PARA_LINESPACE_10:	nLSpace = 100;	goto ASK_LINESPACE;
716 		case SID_ATTR_PARA_LINESPACE_15:	nLSpace = 150;	goto ASK_LINESPACE;
717 		case SID_ATTR_PARA_LINESPACE_20:	nLSpace = 200;	goto ASK_LINESPACE;
718 ASK_LINESPACE:
719 			{
720 				if( !pLSpace )
721 					aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace );
722 
723 				if( !pLSpace || IsInvalidItem( pLSpace ))
724 					rSet.InvalidateItem( nSlotId ), nSlotId = 0;
725 				else if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->
726 												GetPropLineSpace() )
727 					bFlag = sal_True;
728 				else
729 					nSlotId = 0;
730 			}
731 			break;
732 
733 		case FN_SET_SUPER_SCRIPT:	nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
734 									goto ASK_ESCAPE;
735 		case FN_SET_SUB_SCRIPT:		nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
736 									goto ASK_ESCAPE;
737 ASK_ESCAPE:
738 			{
739 				if( !pEscItem )
740 					pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
741 
742 				if( nEsc == ((const SvxEscapementItem*)
743 												pEscItem)->GetEnumValue() )
744 					bFlag = sal_True;
745 				else
746 					nSlotId = 0;
747 			}
748 			break;
749 
750         case SID_THESAURUS:
751         {
752             // disable "Thesaurus" if the language is not supported
753             const SfxPoolItem &rItem = GetShell().GetDoc()->GetDefault(
754                             GetWhichOfScript( RES_CHRATR_LANGUAGE,
755                             GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage())) );
756             LanguageType nLang = ((const SvxLanguageItem &) rItem).GetLanguage();
757 
758             uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
759             if (!xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( SvxCreateLocale( nLang ) ))
760                 rSet.DisableItem( SID_THESAURUS );
761             nSlotId = 0;
762         }
763         break;
764         case SID_HANGUL_HANJA_CONVERSION:
765         case SID_CHINESE_CONVERSION:
766         {
767             if (!SvtCJKOptions().IsAnyEnabled())
768             {
769                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
770                 rSet.DisableItem(nWhich);
771             }
772             else
773                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
774         }
775         break;
776 
777         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
778         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
779 			if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
780 			{
781 				rSet.DisableItem( nSlotId );
782 				nSlotId = 0;
783 			}
784 			else
785 			{
786                 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
787                 if( pOutliner )
788 					bFlag = pOutliner->IsVertical() ==
789 							(SID_TEXTDIRECTION_TOP_TO_BOTTOM == nSlotId);
790 				else
791 				{
792                     text::WritingMode eMode = (text::WritingMode)
793 									( (const SvxWritingModeItem&) aEditAttr.Get( SDRATTR_TEXTDIRECTION ) ).GetValue();
794 
795 					if( nSlotId == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
796 					{
797                         bFlag = eMode == text::WritingMode_LR_TB;
798 					}
799 					else
800 					{
801                         bFlag = eMode != text::WritingMode_TB_RL;
802 					}
803 				}
804 			}
805 			break;
806         case SID_ATTR_PARA_LEFT_TO_RIGHT:
807         case SID_ATTR_PARA_RIGHT_TO_LEFT:
808         {
809             if ( !SvtLanguageOptions().IsCTLFontEnabled() )
810             {
811 				rSet.DisableItem( nWhich );
812 				nSlotId = 0;
813             }
814             else
815             {
816                 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
817                 if(pOutliner && pOutliner->IsVertical())
818 				{
819 					rSet.DisableItem( nWhich );
820 					nSlotId = 0;
821 				}
822 				else
823 				{
824 					switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
825 					{
826 						case FRMDIR_HORI_LEFT_TOP:
827 							bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
828 						break;
829 
830 						case FRMDIR_HORI_RIGHT_TOP:
831 							bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
832 						break;
833 					}
834 				}
835 			}
836         }
837         break;
838         case SID_TRANSLITERATE_HALFWIDTH:
839         case SID_TRANSLITERATE_FULLWIDTH:
840         case SID_TRANSLITERATE_HIRAGANA:
841         case SID_TRANSLITERATE_KATAGANA:
842         {
843             SvtCJKOptions aCJKOptions;
844             if(!aCJKOptions.IsChangeCaseMapEnabled())
845             {
846                 rSet.DisableItem(nWhich);
847                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
848             }
849             else
850                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
851         }
852         break;
853 		case SID_INSERT_RLM :
854 		case SID_INSERT_LRM :
855 		case SID_INSERT_ZWNBSP :
856 		case SID_INSERT_ZWSP:
857         {
858 			SvtCTLOptions aCTLOptions;
859 			sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
860 			GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
861 			if(!bEnabled)
862 				rSet.DisableItem(nWhich);
863 		}
864 		break;
865 		default:
866 			nSlotId = 0;			    // don't know this slot
867 			break;
868 		}
869 
870 		if( nSlotId )
871 			rSet.Put( SfxBoolItem( nWhich, bFlag ));
872 
873 		nWhich = aIter.NextWhich();
874 	}
875 }
876 
877 /*--------------------------------------------------------------------
878 	Beschreibung:
879  --------------------------------------------------------------------*/
880 void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet& rSet)
881 {
882 	if (!IsTextEdit())	// Sonst Absturz!
883 		return;
884 
885     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
886     SfxItemSet aEditAttr(pOLV->GetAttribs());
887 
888 	SfxWhichIter aIter(rSet);
889 	sal_uInt16 nWhich = aIter.FirstWhich();
890 	sal_uInt16 nScriptType = pOLV->GetSelectedScriptType();
891     while(nWhich)
892 	{
893         sal_uInt16 nEEWhich = 0;
894         sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
895 		switch( nSlotId )
896 		{
897             case SID_ATTR_CHAR_FONT:
898             case SID_ATTR_CHAR_FONTHEIGHT:
899             case SID_ATTR_CHAR_WEIGHT:
900             case SID_ATTR_CHAR_POSTURE:
901 			{
902                 SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool();
903                 if( !pEditPool )
904                     pEditPool = aEditAttr.GetPool();
905                 SvxScriptSetItem aSetItem( nSlotId, *pEditPool );
906 				aSetItem.GetItemSet().Put( aEditAttr, sal_False );
907 				const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
908 				if( pI )
909 					rSet.Put( *pI, nWhich );
910 				else
911 					rSet.InvalidateItem( nWhich );
912 			}
913 			break;
914             case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
915             case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
916             case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
917             case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
918             case SID_ATTR_CHAR_SHADOWED:  nEEWhich = EE_CHAR_SHADOW;break;
919             case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
920             case SID_AUTOSPELL_CHECK:
921             {
922                 const SfxPoolItem* pState = rView.GetSlotState(nWhich);
923                 if (pState)
924                     rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue()));
925                 else
926                     rSet.DisableItem( nWhich );
927                 break;
928             }
929             case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
930             case SID_ATTR_CHAR_RELIEF      : nEEWhich = EE_CHAR_RELIEF;  break;
931             case SID_ATTR_CHAR_LANGUAGE    : nEEWhich = EE_CHAR_LANGUAGE;break;
932             case SID_ATTR_CHAR_KERNING     : nEEWhich = EE_CHAR_KERNING; break;
933             case SID_ATTR_CHAR_SCALEWIDTH:   nEEWhich = EE_CHAR_FONTWIDTH;break;
934             case SID_ATTR_CHAR_AUTOKERN  :   nEEWhich = EE_CHAR_PAIRKERNING; break;
935             case SID_ATTR_CHAR_ESCAPEMENT:   nEEWhich = EE_CHAR_ESCAPEMENT; break;
936         }
937         if(nEEWhich)
938             rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich);
939 
940         nWhich = aIter.NextWhich();
941 	}
942 }
943 
944 /*--------------------------------------------------------------------
945 	Beschreibung:
946  --------------------------------------------------------------------*/
947 void SwDrawTextShell::ExecClpbrd(SfxRequest &rReq)
948 {
949 	if (!IsTextEdit())	// Sonst Absturz!
950 		return;
951 
952     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
953 
954     ESelection aSel(pOLV->GetSelection());
955 	const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos);
956     sal_uInt16 nId = rReq.GetSlot();
957 	switch( nId )
958 	{
959 		case SID_CUT:
960 			if (bCopy)
961 				pOLV->Cut();
962 			return;
963 
964 		case SID_COPY:
965 			if (bCopy)
966 				pOLV->Copy();
967 			return;
968 
969 		case SID_PASTE:
970 			pOLV->PasteSpecial();
971 			break;
972 
973 		default:
974 			DBG_ERROR("falscher Dispatcher");
975 			return;
976 	}
977 }
978 
979 /*--------------------------------------------------------------------
980 	Beschreibung:	ClipBoard-Status
981  --------------------------------------------------------------------*/
982 void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet)
983 {
984 	if (!IsTextEdit())	// Sonst Absturz!
985 		return;
986 
987     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
988     ESelection aSel(pOLV->GetSelection());
989 	const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) ||
990 						   (aSel.nStartPos != aSel.nEndPos);
991 
992 
993 	SfxWhichIter aIter(rSet);
994 	sal_uInt16 nWhich = aIter.FirstWhich();
995 
996 	while(nWhich)
997 	{
998 		switch(nWhich)
999 		{
1000 			case SID_CUT:
1001 			case SID_COPY:
1002 				if( !bCopy )
1003 					rSet.DisableItem( nWhich );
1004 				break;
1005 
1006 			case SID_PASTE:
1007 				{
1008 					TransferableDataHelper aDataHelper(
1009 						TransferableDataHelper::CreateFromSystemClipboard(
1010 								&GetView().GetEditWin() ) );
1011 
1012 					if( !aDataHelper.GetXTransferable().is() ||
1013 						!SwTransferable::IsPaste( GetShell(), aDataHelper ))
1014 						rSet.DisableItem( SID_PASTE );
1015 				}
1016 				break;
1017 
1018             case SID_PASTE_SPECIAL:
1019                 rSet.DisableItem( SID_PASTE_SPECIAL );
1020 				break;
1021             // --> OD 2008-06-20 #151110#
1022             case SID_CLIPBOARD_FORMAT_ITEMS:
1023                 rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
1024                 break;
1025             // <--
1026 		}
1027 		nWhich = aIter.NextWhich();
1028 	}
1029 }
1030 
1031 /*--------------------------------------------------------------------
1032 	Beschreibung:	Hyperlink-Status
1033  --------------------------------------------------------------------*/
1034 
1035 void SwDrawTextShell::StateInsert(SfxItemSet &rSet)
1036 {
1037 	if (!IsTextEdit())	// Sonst Absturz!
1038 		return;
1039 
1040     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
1041     SfxWhichIter aIter(rSet);
1042 	sal_uInt16 nWhich = aIter.FirstWhich();
1043 
1044 	while(nWhich)
1045 	{
1046 		switch(nWhich)
1047 		{
1048 			case SID_HYPERLINK_GETLINK:
1049 				{
1050 					SvxHyperlinkItem aHLinkItem;
1051 					aHLinkItem.SetInsertMode(HLINK_FIELD);
1052 
1053 					const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
1054 
1055 					if (pFieldItem)
1056 					{
1057 						const SvxFieldData* pField = pFieldItem->GetField();
1058 
1059 						if (pField->ISA(SvxURLField))
1060 						{
1061 							aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
1062 							aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
1063 							aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
1064 						}
1065 					}
1066 					else
1067 					{
1068 						String sSel(pOLV->GetSelected());
1069 						sSel.Erase(255);
1070 						sSel.EraseTrailingChars();
1071 						aHLinkItem.SetName(sSel);
1072 					}
1073 
1074 					sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1075 					aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
1076 						((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
1077 
1078 					rSet.Put(aHLinkItem);
1079 				}
1080 				break;
1081 		}
1082 		nWhich = aIter.NextWhich();
1083 	}
1084 }
1085 
1086