xref: /aoo42x/main/sw/source/ui/shells/drwtxtex.cxx (revision 870262e3)
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 
Execute(SfxRequest & rReq)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     const sal_uInt16 nSlot = rReq.GetSlot();
149 
150     const 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             if ( pNewAttrs )
208             {
209                 const SvxTextLineItem& rTextLineItem = static_cast< const SvxTextLineItem& >( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich(nSlot) ) );
210                 aNewAttr.Put( SvxUnderlineItem( rTextLineItem.GetLineStyle(), EE_CHAR_UNDERLINE ) );
211             }
212             else
213             {
214                 FontUnderline eFU = ((const SvxUnderlineItem&)aEditAttr.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
215                 aNewAttr.Put( SvxUnderlineItem(eFU == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_UNDERLINE) );
216             }
217         }
218         break;
219 
220 		case SID_ATTR_CHAR_OVERLINE:
221 		{
222 		 	FontUnderline eFO = ((const SvxOverlineItem&)aEditAttr.Get(EE_CHAR_OVERLINE)).GetLineStyle();
223 			aNewAttr.Put(SvxOverlineItem(eFO == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, EE_CHAR_OVERLINE));
224 		}
225 		break;
226 
227         case SID_ATTR_CHAR_CONTOUR:     nEEWhich = EE_CHAR_OUTLINE; break;
228         case SID_ATTR_CHAR_SHADOWED:    nEEWhich = EE_CHAR_SHADOW; break;
229         case SID_ATTR_CHAR_STRIKEOUT:   nEEWhich = EE_CHAR_STRIKEOUT; break;
230         case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
231         case SID_ATTR_CHAR_RELIEF      : nEEWhich = EE_CHAR_RELIEF;  break;
232         case SID_ATTR_CHAR_LANGUAGE    : nEEWhich = EE_CHAR_LANGUAGE;break;
233         case SID_ATTR_CHAR_KERNING     : nEEWhich = EE_CHAR_KERNING; break;
234         case SID_ATTR_CHAR_SCALEWIDTH:   nEEWhich = EE_CHAR_FONTWIDTH; break;
235         case SID_ATTR_CHAR_AUTOKERN  :   nEEWhich = EE_CHAR_PAIRKERNING; break;
236         case SID_ATTR_CHAR_ESCAPEMENT:   nEEWhich = EE_CHAR_ESCAPEMENT; break;
237         case SID_ATTR_PARA_ADJUST_LEFT:
238 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_LEFT, EE_PARA_JUST));
239         break;
240 		case SID_ATTR_PARA_ADJUST_CENTER:
241 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
242         break;
243 		case SID_ATTR_PARA_ADJUST_RIGHT:
244 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_RIGHT, EE_PARA_JUST));
245         break;
246 		case SID_ATTR_PARA_ADJUST_BLOCK:
247 			aNewAttr.Put(SvxAdjustItem(SVX_ADJUST_BLOCK, EE_PARA_JUST));
248         break;
249 		case SID_ATTR_PARA_LRSPACE:
250 			{
251 				SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
252 										GetArgs()->Get(nSlot));
253 				aParaMargin.SetWhich( EE_PARA_LRSPACE );
254 				aNewAttr.Put(aParaMargin);
255 				rReq.Done();
256 			}
257 			break;
258 		case SID_ATTR_PARA_LINESPACE:
259 			{
260 				SvxLineSpacingItem aLineSpace = (const SvxLineSpacingItem&)pNewAttrs->Get(
261 															GetPool().GetWhich(nSlot));
262 				aLineSpace.SetWhich( EE_PARA_SBL );
263 				aNewAttr.Put( aLineSpace );
264 				rReq.Done();
265 			}
266 			break;
267 		case SID_ATTR_PARA_ULSPACE:
268 			{
269 				SvxULSpaceItem aULSpace = (const SvxULSpaceItem&)pNewAttrs->Get(
270 					GetPool().GetWhich(nSlot));
271 				aULSpace.SetWhich( EE_PARA_ULSPACE );
272 				aNewAttr.Put( aULSpace );
273 				rReq.Done();
274 			}
275 			break;
276 
277 		case SID_ATTR_PARA_LINESPACE_10:
278 		{
279 			SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_LINE, EE_PARA_SBL);
280 			aItem.SetPropLineSpace(100);
281 			aNewAttr.Put(aItem);
282 		}
283 		break;
284 		case SID_ATTR_PARA_LINESPACE_15:
285 		{
286 			SvxLineSpacingItem aItem(SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL);
287 			aItem.SetPropLineSpace(150);
288 			aNewAttr.Put(aItem);
289 		}
290 		break;
291 		case SID_ATTR_PARA_LINESPACE_20:
292 		{
293 			SvxLineSpacingItem aItem(SVX_LINESPACE_TWO_LINES, EE_PARA_SBL);
294 			aItem.SetPropLineSpace(200);
295 			aNewAttr.Put(aItem);
296 		}
297 		break;
298 
299 		case FN_SET_SUPER_SCRIPT:
300 		{
301 			SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
302 			SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
303 							aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
304 
305 			if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
306 				aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
307 			else
308 				aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
309 			aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
310 		}
311 		break;
312 		case FN_SET_SUB_SCRIPT:
313 		{
314 			SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
315 			SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
316 							aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
317 
318 			if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
319 				aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
320 			else
321 				aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
322 			aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
323 		}
324 		break;
325 
326 		case SID_CHAR_DLG_EFFECT:
327 		case SID_CHAR_DLG:
328 		case SID_CHAR_DLG_FOR_PARAGRAPH:
329 		{
330 			const SfxItemSet* pArgs = rReq.GetArgs();
331 
332 			if( !pArgs )
333 			{
334 				aOldSelection = pOLV->GetSelection();
335 				if (nSlot == SID_CHAR_DLG_FOR_PARAGRAPH)
336 				{
337 					// select current paragraph (and restore selection later on...)
338 					EditView & rEditView = pOLV->GetEditView();
339 					SwLangHelper::SelectPara( rEditView, rEditView.GetSelection() );
340 					bRestoreSelection = true;
341 				}
342 
343 				SwView* pView = &GetView();
344 				FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
345                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
346 				SfxItemSet aDlgAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END);
347 
348 				// util::Language gibts an der EditEngine nicht! Daher nicht im Set.
349 
350 				aDlgAttr.Put( aEditAttr );
351                 aDlgAttr.Put( SvxKerningItem(0, RES_CHRATR_KERNING) );
352 
353                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
354                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
355 
356                 SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( pView->GetWindow(), *pView, aDlgAttr, DLG_CHAR,0, sal_True );
357                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
358 				if (nSlot == SID_CHAR_DLG_EFFECT)
359 				{
360 					pDlg->SetCurPageId(TP_CHAR_EXT);
361 				}
362 				sal_uInt16 nRet = pDlg->Execute();
363 				if(RET_OK == nRet )
364                 {
365                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
366                     aNewAttr.Put(*pDlg->GetOutputItemSet());
367                 }
368 				delete( pDlg );
369 				if(RET_OK != nRet)
370 					return ;
371 			}
372 			else
373 				aNewAttr.Put(*pArgs);
374 		}
375 		break;
376 		case FN_FORMAT_FOOTNOTE_DLG:
377 		{
378             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
379             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
380 
381             VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), rView.GetWrtShell(), DLG_DOC_FOOTNOTE );
382             DBG_ASSERT(pDlg, "Dialogdiet fail!");
383 			pDlg->Execute();
384 			delete pDlg;
385 			break;
386 		}
387 		case FN_NUMBERING_OUTLINE_DLG:
388 		{
389 			SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
390 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
391             DBG_ASSERT(pFact, "Dialogdiet fail!");
392             SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
393 														GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
394             DBG_ASSERT(pDlg, "Dialogdiet fail!");
395 			pDlg->Execute();
396 			delete pDlg;
397 			rReq.Done();
398 		}
399 		break;
400 		case SID_OPEN_XML_FILTERSETTINGS:
401 		{
402 			try
403 			{
404 				uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY);
405 				if( xDialog.is() )
406 				{
407 					xDialog->execute();
408 				}
409 			}
410 			catch( uno::Exception& )
411 			{
412 			}
413 			rReq.Ignore ();
414 		}
415 		break;
416 		case FN_WORDCOUNT_DIALOG:
417 		{
418 			SwDocStat aCurr;
419 			SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() );
420 			{
421 				SwWait aWait( *GetView().GetDocShell(), true );
422 				rSh.StartAction();
423 				rSh.CountWords( aCurr );
424 				rSh.UpdateDocStat( aDocStat );
425 				rSh.EndAction();
426 			}
427 
428 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
429 			DBG_ASSERT(pFact, "Dialogdiet fail!");
430 			AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() );
431 			pDialog->SetValues(aCurr, aDocStat );
432 			pDialog->Execute();
433 			delete pDialog;
434 		}
435 		break;
436 		case SID_PARA_DLG:
437 		{
438 			const SfxItemSet* pArgs = rReq.GetArgs();
439 
440 			if (!pArgs)
441 			{
442 				SwView* pView = &GetView();
443 				FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
444                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
445 				SfxItemSet aDlgAttr(GetPool(),
446 									EE_ITEMS_START, EE_ITEMS_END,
447 									SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
448 									SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
449 									SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
450 									SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
451 									0);
452 
453 				aDlgAttr.Put(aEditAttr);
454 
455 				// Die Werte sind erst einmal uebernommen worden, um den Dialog anzuzeigen.
456 				// Muss natuerlich noch geaendert werden
457 				// aDlgAttr.Put( SvxParaDlgLimitsItem( 567 * 50, 5670) );
458 
459                 aDlgAttr.Put( SvxHyphenZoneItem( sal_False, RES_PARATR_HYPHENZONE) );
460                 aDlgAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, RES_BREAK ) );
461                 aDlgAttr.Put( SvxFmtSplitItem( sal_True, RES_PARATR_SPLIT ) );
462                 aDlgAttr.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) );
463                 aDlgAttr.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) );
464 
465                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
466                 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
467 
468                 SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr,DLG_STD, DLG_PARA, 0, sal_True );
469                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
470 				sal_uInt16 nRet = pDlg->Execute();
471 				if(RET_OK == nRet)
472                 {
473                     rReq.Done( *( pDlg->GetOutputItemSet() ) );
474                     aNewAttr.Put(*pDlg->GetOutputItemSet());
475                 }
476 				delete( pDlg );
477 				if(RET_OK != nRet)
478 					return;
479 			}
480 			else
481 				aNewAttr.Put(*pArgs);
482 		}
483 		break;
484 		case SID_AUTOSPELL_CHECK:
485 		{
486 //!! JP 16.03.2001: why??			pSdrView = rSh.GetDrawView();
487 //!! JP 16.03.2001: why??			pOutliner = pSdrView->GetTextEditOutliner();
488             SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
489             sal_uInt32 nCtrl = pOutliner->GetControlWord();
490 
491 			sal_Bool bSet = ((const SfxBoolItem&)rReq.GetArgs()->Get(
492 													nSlot)).GetValue();
493             if(bSet)
494                 nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS;
495             else
496                 nCtrl &= ~EE_CNTRL_ONLINESPELLING;
497 			pOutliner->SetControlWord(nCtrl);
498 
499             rView.ExecuteSlot(rReq);
500 		}
501 		break;
502 		case SID_HYPERLINK_SETLINK:
503 		{
504 			const SfxPoolItem* pItem = 0;
505 			if(pNewAttrs)
506 				pNewAttrs->GetItemState(nSlot, sal_False, &pItem);
507 
508 			if(pItem)
509 			{
510 				const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem;
511 				SvxURLField aFld(rHLinkItem.GetURL(), rHLinkItem.GetName(), SVXURLFORMAT_APPDEFAULT);
512 				aFld.SetTargetFrame(rHLinkItem.GetTargetFrame());
513 
514 				const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
515 
516 				if (pFieldItem && pFieldItem->GetField()->ISA(SvxURLField))
517 				{
518 					// Feld selektieren, so dass es beim Insert geloescht wird
519 					ESelection aSel = pOLV->GetSelection();
520 					aSel.nEndPos++;
521 					pOLV->SetSelection(aSel);
522 				}
523                 pOLV->InsertField(SvxFieldItem(aFld, EE_FEATURE_FIELD));
524 			}
525 		}
526 		break;
527 
528 		case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
529     	case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
530 			// Shellwechsel!
531 			{
532 				SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
533 				SdrPageView* pTmpPV = pSdrView->GetSdrPageView();
534 				SdrView* pTmpView = pSdrView;
535 
536                 pSdrView->SdrEndTextEdit(sal_True);
537 
538 				SfxItemSet aAttr( *aNewAttr.GetPool(),
539 							SDRATTR_TEXTDIRECTION,
540 							SDRATTR_TEXTDIRECTION );
541 
542 				aAttr.Put( SvxWritingModeItem(
543 					nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
544                         text::WritingMode_LR_TB
545                         : text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION ) );
546 				pTmpView->SetAttributes( aAttr );
547 
548 				rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), sal_False);
549 				rSh.GetView().AttrChangedNotify( &rSh );
550 			}
551 			return;
552 
553         case SID_ATTR_PARA_LEFT_TO_RIGHT:
554         case SID_ATTR_PARA_RIGHT_TO_LEFT:
555         {
556             SdrObject* pTmpObj = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
557             SdrPageView* pTmpPV = pSdrView->GetSdrPageView();
558             SdrView* pTmpView = pSdrView;
559 
560             pSdrView->SdrEndTextEdit(sal_True);
561             sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
562 
563             const SfxPoolItem* pPoolItem;
564             if( pNewAttrs && SFX_ITEM_SET == pNewAttrs->GetItemState( nSlot, sal_True, &pPoolItem ) )
565             {
566                 if( !( (SfxBoolItem*)pPoolItem)->GetValue() )
567                     bLeftToRight = !bLeftToRight;
568             }
569             SfxItemSet aAttr( *aNewAttr.GetPool(),
570                         EE_PARA_JUST, EE_PARA_JUST,
571                         EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
572                         0 );
573 
574             sal_uInt16 nAdjust = SVX_ADJUST_LEFT;
575             if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, sal_True, &pPoolItem ) )
576                 nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
577 
578             if( bLeftToRight )
579             {
580                 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
581                 if( nAdjust == SVX_ADJUST_RIGHT )
582                     aAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
583             }
584             else
585             {
586                 aAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
587                 if( nAdjust == SVX_ADJUST_LEFT )
588                     aAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
589             }
590             pTmpView->SetAttributes( aAttr );
591             rSh.GetView().BeginTextEdit( pTmpObj, pTmpPV, &rSh.GetView().GetEditWin(), sal_False );
592             rSh.GetView().AttrChangedNotify( &rSh );
593         }
594         return;
595 		default:
596 			ASSERT(sal_False, "wrong dispatcher");
597 			return;
598 	}
599     if(nEEWhich && pNewAttrs)
600         aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
601 
602 	SetAttrToMarked(aNewAttr);
603 
604 	GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False);
605 
606 	if (IsTextEdit() && pOLV->GetOutliner()->IsModified())
607 		rSh.SetModified();
608 
609 	if (bRestoreSelection)
610 	{
611 		// restore selection
612 		pOLV->GetEditView().SetSelection( aOldSelection );
613 	}
614 }
615 
616 /*--------------------------------------------------------------------
617 	Beschreibung:
618  --------------------------------------------------------------------*/
619 
GetState(SfxItemSet & rSet)620 void SwDrawTextShell::GetState(SfxItemSet& rSet)
621 {
622 	if (!IsTextEdit())	// Sonst manchmal Absturz!
623 		return;
624 
625 	OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
626     SfxWhichIter aIter(rSet);
627 	sal_uInt16 nWhich = aIter.FirstWhich();
628 
629     SfxItemSet aEditAttr( pOLV->GetAttribs() );
630 	const SfxPoolItem *pAdjust = 0, *pLSpace = 0, *pEscItem = 0;
631 	int eAdjust, nLSpace, nEsc;
632 
633 	while(nWhich)
634 	{
635 		sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
636 		sal_Bool bFlag = sal_False;
637 		switch( nSlotId )
638 		{
639 		    case SID_LANGUAGE_STATUS://20412:
640             {
641 				nSlotId = SwLangHelper::GetLanguageStatus(pOLV,rSet);;
642 				break;
643 			}
644 
645             case SID_THES:
646             {
647                 String          aStatusVal;
648                 LanguageType    nLang = LANGUAGE_NONE;
649                 bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() );
650                 rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
651 
652                 // disable "Thesaurus" context menu entry if there is nothing to look up
653                 uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
654                 lang::Locale aLocale( SvxCreateLocale( nLang ) );
655                 if (!bIsLookUpWord ||
656                     !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale ))
657                     rSet.DisableItem( SID_THES );
658 
659                 //! avoid putting the same item as SfxBoolItem at the end of this function
660                 nSlotId = 0;
661                 break;
662             }
663 
664         case SID_ATTR_PARA_ADJUST_LEFT:     eAdjust = SVX_ADJUST_LEFT; goto ASK_ADJUST;
665 		case SID_ATTR_PARA_ADJUST_RIGHT:	eAdjust = SVX_ADJUST_RIGHT; goto ASK_ADJUST;
666 		case SID_ATTR_PARA_ADJUST_CENTER:	eAdjust = SVX_ADJUST_CENTER; goto ASK_ADJUST;
667 		case SID_ATTR_PARA_ADJUST_BLOCK:	eAdjust = SVX_ADJUST_BLOCK; goto ASK_ADJUST;
668 ASK_ADJUST:
669 			{
670 				if( !pAdjust )
671 					aEditAttr.GetItemState( EE_PARA_JUST, sal_False, &pAdjust);
672 
673 				if( !pAdjust || IsInvalidItem( pAdjust ))
674 					rSet.InvalidateItem( nSlotId ), nSlotId = 0;
675 				else
676 					bFlag = eAdjust == ((SvxAdjustItem*)pAdjust)->GetAdjust();
677 			}
678 			break;
679 
680 		case SID_ATTR_PARA_LRSPACE:
681 			{
682 				SfxItemState eState = aEditAttr.GetItemState(EE_PARA_LRSPACE);
683 				if( eState >= SFX_ITEM_DEFAULT )
684 				{
685 					SvxLRSpaceItem aLR = (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE );
686 					aLR.SetWhich(SID_ATTR_PARA_LRSPACE);
687 					rSet.Put(aLR);
688 				}
689 				else
690 					rSet.InvalidateItem(nSlotId);
691 				nSlotId = 0;
692 			}
693 			break;
694 		case SID_ATTR_PARA_LINESPACE:
695 			{
696 				SfxItemState eState = aEditAttr.GetItemState(EE_PARA_SBL);
697 				if( eState >= SFX_ITEM_DEFAULT )
698 				{
699 					SvxLineSpacingItem aLR = (const SvxLineSpacingItem&) aEditAttr.Get( EE_PARA_SBL );
700 					rSet.Put(aLR);
701 				}
702 				else
703 					rSet.InvalidateItem(nSlotId);
704 				nSlotId = 0;
705 			}
706 			break;
707 		case SID_ATTR_PARA_ULSPACE:
708 			{
709 				SfxItemState eState = aEditAttr.GetItemState(EE_PARA_ULSPACE);
710 				if( eState >= SFX_ITEM_DEFAULT )
711 				{
712 					SvxULSpaceItem aULSpace = (const SvxULSpaceItem&) aEditAttr.Get( EE_PARA_ULSPACE );
713 					aULSpace.SetWhich(SID_ATTR_PARA_ULSPACE);
714 					rSet.Put(aULSpace);
715 				}
716 				else
717 					rSet.InvalidateItem(nSlotId);
718 				nSlotId = 0;
719 			}
720 			break;
721 
722 		case SID_ATTR_PARA_LINESPACE_10:	nLSpace = 100;	goto ASK_LINESPACE;
723 		case SID_ATTR_PARA_LINESPACE_15:	nLSpace = 150;	goto ASK_LINESPACE;
724 		case SID_ATTR_PARA_LINESPACE_20:	nLSpace = 200;	goto ASK_LINESPACE;
725 ASK_LINESPACE:
726 			{
727 				if( !pLSpace )
728 					aEditAttr.GetItemState( EE_PARA_SBL, sal_False, &pLSpace );
729 
730 				if( !pLSpace || IsInvalidItem( pLSpace ))
731 					rSet.InvalidateItem( nSlotId ), nSlotId = 0;
732 				else if( nLSpace == ((const SvxLineSpacingItem*)pLSpace)->
733 												GetPropLineSpace() )
734 					bFlag = sal_True;
735 				else
736 					nSlotId = 0;
737 			}
738 			break;
739 
740 		case FN_SET_SUPER_SCRIPT:	nEsc = SVX_ESCAPEMENT_SUPERSCRIPT;
741 									goto ASK_ESCAPE;
742 		case FN_SET_SUB_SCRIPT:		nEsc = SVX_ESCAPEMENT_SUBSCRIPT;
743 									goto ASK_ESCAPE;
744 ASK_ESCAPE:
745 			{
746 				if( !pEscItem )
747 					pEscItem = &aEditAttr.Get( EE_CHAR_ESCAPEMENT );
748 
749 				if( nEsc == ((const SvxEscapementItem*)
750 												pEscItem)->GetEnumValue() )
751 					bFlag = sal_True;
752 				else
753 					nSlotId = 0;
754 			}
755 			break;
756 
757         case SID_THESAURUS:
758         {
759             // disable "Thesaurus" if the language is not supported
760             const SfxPoolItem &rItem = GetShell().GetDoc()->GetDefault(
761                             GetWhichOfScript( RES_CHRATR_LANGUAGE,
762                             GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage())) );
763             LanguageType nLang = ((const SvxLanguageItem &) rItem).GetLanguage();
764 
765             uno::Reference< linguistic2::XThesaurus >  xThes( ::GetThesaurus() );
766             if (!xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( SvxCreateLocale( nLang ) ))
767                 rSet.DisableItem( SID_THESAURUS );
768             nSlotId = 0;
769         }
770         break;
771         case SID_HANGUL_HANJA_CONVERSION:
772         case SID_CHINESE_CONVERSION:
773         {
774             if (!SvtCJKOptions().IsAnyEnabled())
775             {
776                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
777                 rSet.DisableItem(nWhich);
778             }
779             else
780                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
781         }
782         break;
783 
784         case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
785         case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
786 			if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
787 			{
788 				rSet.DisableItem( nSlotId );
789 				nSlotId = 0;
790 			}
791 			else
792 			{
793                 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
794                 if( pOutliner )
795 					bFlag = pOutliner->IsVertical() ==
796 							(SID_TEXTDIRECTION_TOP_TO_BOTTOM == nSlotId);
797 				else
798 				{
799                     text::WritingMode eMode = (text::WritingMode)
800 									( (const SvxWritingModeItem&) aEditAttr.Get( SDRATTR_TEXTDIRECTION ) ).GetValue();
801 
802 					if( nSlotId == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
803 					{
804                         bFlag = eMode == text::WritingMode_LR_TB;
805 					}
806 					else
807 					{
808                         bFlag = eMode != text::WritingMode_TB_RL;
809 					}
810 				}
811 			}
812 			break;
813         case SID_ATTR_PARA_LEFT_TO_RIGHT:
814         case SID_ATTR_PARA_RIGHT_TO_LEFT:
815         {
816             if ( !SvtLanguageOptions().IsCTLFontEnabled() )
817             {
818 				rSet.DisableItem( nWhich );
819 				nSlotId = 0;
820             }
821             else
822             {
823                 SdrOutliner * pOutliner = pSdrView->GetTextEditOutliner();
824                 if(pOutliner && pOutliner->IsVertical())
825 				{
826 					rSet.DisableItem( nWhich );
827 					nSlotId = 0;
828 				}
829 				else
830 				{
831 					switch( ( ( (SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
832 					{
833 						case FRMDIR_HORI_LEFT_TOP:
834 							bFlag = nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT;
835 						break;
836 
837 						case FRMDIR_HORI_RIGHT_TOP:
838 							bFlag = nWhich != SID_ATTR_PARA_LEFT_TO_RIGHT;
839 						break;
840 					}
841 				}
842 			}
843         }
844         break;
845         case SID_TRANSLITERATE_HALFWIDTH:
846         case SID_TRANSLITERATE_FULLWIDTH:
847         case SID_TRANSLITERATE_HIRAGANA:
848         case SID_TRANSLITERATE_KATAGANA:
849         {
850             SvtCJKOptions aCJKOptions;
851             if(!aCJKOptions.IsChangeCaseMapEnabled())
852             {
853                 rSet.DisableItem(nWhich);
854                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_False );
855             }
856             else
857                 GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, sal_True );
858         }
859         break;
860 		case SID_INSERT_RLM :
861 		case SID_INSERT_LRM :
862 		case SID_INSERT_ZWNBSP :
863 		case SID_INSERT_ZWSP:
864         {
865 			SvtCTLOptions aCTLOptions;
866 			sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled();
867 			GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled );
868 			if(!bEnabled)
869 				rSet.DisableItem(nWhich);
870 		}
871 		break;
872 		default:
873 			nSlotId = 0;			    // don't know this slot
874 			break;
875 		}
876 
877 		if( nSlotId )
878 			rSet.Put( SfxBoolItem( nWhich, bFlag ));
879 
880 		nWhich = aIter.NextWhich();
881 	}
882 }
883 
884 /*--------------------------------------------------------------------
885 	Beschreibung:
886  --------------------------------------------------------------------*/
GetDrawTxtCtrlState(SfxItemSet & rSet)887 void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet& rSet)
888 {
889 	if (!IsTextEdit())	// Sonst Absturz!
890 		return;
891 
892     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
893     SfxItemSet aEditAttr(pOLV->GetAttribs());
894 
895 	SfxWhichIter aIter(rSet);
896 	sal_uInt16 nWhich = aIter.FirstWhich();
897 	sal_uInt16 nScriptType = pOLV->GetSelectedScriptType();
898     while(nWhich)
899 	{
900         sal_uInt16 nEEWhich = 0;
901         sal_uInt16 nSlotId = GetPool().GetSlotId( nWhich );
902 		switch( nSlotId )
903 		{
904             case SID_ATTR_CHAR_FONT:
905             case SID_ATTR_CHAR_FONTHEIGHT:
906             case SID_ATTR_CHAR_WEIGHT:
907             case SID_ATTR_CHAR_POSTURE:
908 			{
909                 SfxItemPool* pEditPool = aEditAttr.GetPool()->GetSecondaryPool();
910                 if( !pEditPool )
911                     pEditPool = aEditAttr.GetPool();
912                 SvxScriptSetItem aSetItem( nSlotId, *pEditPool );
913 				aSetItem.GetItemSet().Put( aEditAttr, sal_False );
914 				const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
915 				if( pI )
916 					rSet.Put( *pI, nWhich );
917 				else
918 					rSet.InvalidateItem( nWhich );
919 			}
920 			break;
921             case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
922             case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
923             case SID_ATTR_CHAR_OVERLINE: nEEWhich = EE_CHAR_OVERLINE;break;
924             case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break;
925             case SID_ATTR_CHAR_SHADOWED:  nEEWhich = EE_CHAR_SHADOW;break;
926             case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break;
927             case SID_AUTOSPELL_CHECK:
928             {
929                 const SfxPoolItem* pState = rView.GetSlotState(nWhich);
930                 if (pState)
931                     rSet.Put(SfxBoolItem(nWhich, ((const SfxBoolItem*)pState)->GetValue()));
932                 else
933                     rSet.DisableItem( nWhich );
934                 break;
935             }
936             case SID_ATTR_CHAR_WORDLINEMODE: nEEWhich = EE_CHAR_WLM; break;
937             case SID_ATTR_CHAR_RELIEF      : nEEWhich = EE_CHAR_RELIEF;  break;
938             case SID_ATTR_CHAR_LANGUAGE    : nEEWhich = EE_CHAR_LANGUAGE;break;
939             case SID_ATTR_CHAR_KERNING     : nEEWhich = EE_CHAR_KERNING; break;
940             case SID_ATTR_CHAR_SCALEWIDTH:   nEEWhich = EE_CHAR_FONTWIDTH;break;
941             case SID_ATTR_CHAR_AUTOKERN  :   nEEWhich = EE_CHAR_PAIRKERNING; break;
942             case SID_ATTR_CHAR_ESCAPEMENT:   nEEWhich = EE_CHAR_ESCAPEMENT; break;
943         }
944         if(nEEWhich)
945             rSet.Put(aEditAttr.Get(nEEWhich, sal_True), nWhich);
946 
947         nWhich = aIter.NextWhich();
948 	}
949 }
950 
951 /*--------------------------------------------------------------------
952 	Beschreibung:
953  --------------------------------------------------------------------*/
ExecClpbrd(SfxRequest & rReq)954 void SwDrawTextShell::ExecClpbrd(SfxRequest &rReq)
955 {
956 	if (!IsTextEdit())	// Sonst Absturz!
957 		return;
958 
959     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
960 
961     ESelection aSel(pOLV->GetSelection());
962 	const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos);
963     sal_uInt16 nId = rReq.GetSlot();
964 	switch( nId )
965 	{
966 		case SID_CUT:
967 			if (bCopy)
968 				pOLV->Cut();
969 			return;
970 
971 		case SID_COPY:
972 			if (bCopy)
973 				pOLV->Copy();
974 			return;
975 
976 		case SID_PASTE:
977 			pOLV->PasteSpecial();
978 			break;
979 
980 		default:
981 			DBG_ERROR("falscher Dispatcher");
982 			return;
983 	}
984 }
985 
986 /*--------------------------------------------------------------------
987 	Beschreibung:	ClipBoard-Status
988  --------------------------------------------------------------------*/
StateClpbrd(SfxItemSet & rSet)989 void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet)
990 {
991     if (!IsTextEdit())	// Sonst Absturz!
992         return;
993 
994     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
995     ESelection aSel(pOLV->GetSelection());
996     const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) ||
997         (aSel.nStartPos != aSel.nEndPos);
998 
999 
1000     SfxWhichIter aIter(rSet);
1001     sal_uInt16 nWhich = aIter.FirstWhich();
1002 
1003     while(nWhich)
1004     {
1005         switch(nWhich)
1006         {
1007         case SID_CUT:
1008         case SID_COPY:
1009             if( !bCopy )
1010                 rSet.DisableItem( nWhich );
1011             break;
1012 
1013         case SID_PASTE:
1014             {
1015                 TransferableDataHelper aDataHelper(
1016                     TransferableDataHelper::CreateFromSystemClipboard( &GetView().GetEditWin() ) );
1017 
1018                 if( !aDataHelper.GetXTransferable().is()
1019                     || !SwTransferable::IsPaste( GetShell(), aDataHelper ) )
1020                 {
1021                     rSet.DisableItem( nWhich );
1022                 }
1023             }
1024             break;
1025 
1026         case SID_PASTE_SPECIAL:
1027         case SID_CLIPBOARD_FORMAT_ITEMS:
1028             rSet.DisableItem( nWhich );
1029             break;
1030         }
1031 
1032         nWhich = aIter.NextWhich();
1033     }
1034 }
1035 
1036 /*--------------------------------------------------------------------
1037 	Beschreibung:	Hyperlink-Status
1038  --------------------------------------------------------------------*/
1039 
StateInsert(SfxItemSet & rSet)1040 void SwDrawTextShell::StateInsert(SfxItemSet &rSet)
1041 {
1042 	if (!IsTextEdit())	// Sonst Absturz!
1043 		return;
1044 
1045     OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
1046     SfxWhichIter aIter(rSet);
1047 	sal_uInt16 nWhich = aIter.FirstWhich();
1048 
1049 	while(nWhich)
1050 	{
1051 		switch(nWhich)
1052 		{
1053 			case SID_HYPERLINK_GETLINK:
1054 				{
1055 					SvxHyperlinkItem aHLinkItem;
1056 					aHLinkItem.SetInsertMode(HLINK_FIELD);
1057 
1058 					const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
1059 
1060 					if (pFieldItem)
1061 					{
1062 						const SvxFieldData* pField = pFieldItem->GetField();
1063 
1064 						if (pField->ISA(SvxURLField))
1065 						{
1066 							aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
1067 							aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
1068 							aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
1069 						}
1070 					}
1071 					else
1072 					{
1073 						String sSel(pOLV->GetSelected());
1074 						sSel.Erase(255);
1075 						sSel.EraseTrailingChars();
1076 						aHLinkItem.SetName(sSel);
1077 					}
1078 
1079 					sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
1080 					aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
1081 						((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
1082 
1083 					rSet.Put(aHLinkItem);
1084 				}
1085 				break;
1086 		}
1087 		nWhich = aIter.NextWhich();
1088 	}
1089 }
1090 
1091