xref: /aoo42x/main/sw/source/ui/shells/textsh.cxx (revision 69a74367)
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 
28 #define _SW_FRMVALID_HXX
29 #include <hintids.hxx>
30 
31 #include <svl/globalnameitem.hxx>
32 #include <sfx2/objface.hxx>
33 #include <sfx2/lnkbase.hxx>
34 
35 #include <tools/errinf.hxx>
36 #include <svx/svdview.hxx>
37 #include <svl/ptitem.hxx>
38 #include <svl/stritem.hxx>
39 #include <unotools/moduleoptions.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <sfx2/fcontnr.hxx>
42 #include <svx/hlnkitem.hxx>
43 #include <svl/srchitem.hxx>
44 #include <sfx2/dispatch.hxx>
45 #include <sfx2/docfile.hxx>
46 #include <svl/urihelper.hxx>
47 #include <basic/sbxvar.hxx>
48 #include <svl/whiter.hxx>
49 #include <sfx2/request.hxx>
50 #include <editeng/opaqitem.hxx>
51 #include <editeng/fontitem.hxx>
52 #include <editeng/adjitem.hxx>
53 #include <editeng/boxitem.hxx>
54 #include <editeng/sizeitem.hxx>
55 #include <editeng/svxacorr.hxx>
56 #include <editeng/scripttypeitem.hxx>
57 #include <svtools/filter.hxx>
58 #include <svx/htmlmode.hxx>
59 #include <svx/pfiledlg.hxx>
60 #include <svtools/htmlcfg.hxx>
61 #include <com/sun/star/i18n/TransliterationModules.hpp>
62 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
63 
64 #include <sot/clsids.hxx>
65 #include <editeng/acorrcfg.hxx>
66 #include <wdocsh.hxx>
67 #include <fmtinfmt.hxx>
68 #include <fmtclds.hxx>
69 #include <fmtsrnd.hxx>
70 #include <fmtfsize.hxx>
71 #include <swmodule.hxx>
72 #include <wrtsh.hxx>
73 #include <view.hxx>
74 #include <docsh.hxx>
75 #include <doc.hxx>
76 #include <uitool.hxx>
77 #include <cmdid.h>
78 #include <globals.hrc>
79 #include <frmmgr.hxx>
80 #include <textsh.hxx>
81 #include <frmfmt.hxx>
82 #include <tablemgr.hxx>
83 #include <swundo.hxx>		// fuer Undo-IDs
84 #include <shellio.hxx>
85 #include <frmdlg.hxx>
86 #include <usrpref.hxx>
87 #include <swtable.hxx>
88 #include <tblafmt.hxx>
89 #include <caption.hxx>
90 #include <idxmrk.hxx>
91 #include <poolfmt.hxx>
92 #include <breakit.hxx>
93 #include <crsskip.hxx>
94 #include <modcfg.hxx>
95 #include <column.hxx>
96 #include <edtwin.hxx>
97 #include <shells.hrc>
98 #include <popup.hrc>
99 #include <swerror.h>
100 #include <SwAppletImpl.hxx>
101 #include <unochart.hxx>
102 
103 #include <chartins.hxx>
104 
105 #define SwTextShell
106 #define Paragraph
107 #define HyphenZone
108 #define TextFont
109 #define DropCap
110 #include <sfx2/msg.hxx>
111 #include <sfx2/sidebar/EnumContext.hxx>
112 #include <swslots.hxx>
113 #include <SwRewriter.hxx>
114 #include <comcore.hrc>
115 
116 using namespace ::com::sun::star;
117 using ::rtl::OUString;
118 
119 #include <svx/svxdlg.hxx>
120 #include <svx/dialogs.hrc>
121 #include "swabstdlg.hxx"
122 #include <misc.hrc>
123 #include <table.hrc>
124 #include <frmui.hrc>
125 #include <unomid.h>
126 
127 
128 
129 /*--------------------------------------------------------------------
130 	Beschreibung:
131  --------------------------------------------------------------------*/
132 
133 SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_TEXT))
134 {
135 	SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TEXT_POPUPMENU));
136 	SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
137 	SFX_CHILDWINDOW_REGISTRATION(FN_EDIT_FORMULA);
138 	SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD);
139 	SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_IDX_ENTRY_DLG);
140 	SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_AUTH_ENTRY_DLG);
141     SFX_CHILDWINDOW_REGISTRATION(SID_RUBY_DIALOG);
142 }
143 
144 
145 
146 TYPEINIT1(SwTextShell,SwBaseShell)
147 
148 
149 
150 void SwTextShell::ExecInsert(SfxRequest &rReq)
151 {
152 	SwWrtShell &rSh = GetShell();
153 
154 	ASSERT( !rSh.IsObjSelected() && !rSh.IsFrmSelected(),
155 			"Falsche Shell auf dem Dispatcher" );
156 
157 	const SfxItemSet *pArgs = rReq.GetArgs();
158 	const SfxPoolItem* pItem = 0;
159 	sal_uInt16 nSlot = rReq.GetSlot();
160 	if(pArgs)
161 		pArgs->GetItemState(nSlot, sal_False, &pItem );
162 
163     switch( nSlot )
164     {
165     case FN_INSERT_STRING:
166         if( pItem )
167             rSh.InsertByWord(((const SfxStringItem *)pItem)->GetValue());
168         break;
169 
170     case FN_INSERT_SOFT_HYPHEN:
171         if( CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( sal_True, 0 ) &&
172             CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( sal_True, -1 ))
173             rSh.Insert( String( CHAR_SOFTHYPHEN ) );
174         break;
175 
176     case FN_INSERT_HARDHYPHEN:
177     case FN_INSERT_HARD_SPACE:
178         {
179             const sal_Unicode cIns = FN_INSERT_HARD_SPACE == nSlot ? CHAR_HARDBLANK : CHAR_HARDHYPHEN;
180 
181             SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get();
182             SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect();
183             if( pACorr && pACfg->IsAutoFmtByInput()
184                 && pACorr->IsAutoCorrFlag(
185                     CptlSttSntnc | CptlSttWrd | AddNonBrkSpace | ChgOrdinalNumber | ChgToEnEmDash | SetINetAttr | Autocorrect ) )
186             {
187                 rSh.AutoCorrect( *pACorr, cIns );
188             }
189             else
190             {
191                 rSh.Insert( String( cIns ) );
192             }
193         }
194         break;
195 
196     case SID_INSERT_RLM :
197     case SID_INSERT_LRM :
198     case SID_INSERT_ZWNBSP :
199     case SID_INSERT_ZWSP:
200     {
201         sal_Unicode cIns = 0;
202         switch(nSlot)
203         {
204             case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
205             case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
206             case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
207             case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
208         }
209         rSh.Insert( String( cIns ) );
210     }
211     break;
212 
213     case FN_INSERT_BREAK:
214         {
215             if( !rSh.CrsrInsideInputFld() )
216             {
217                 rSh.SplitNode();
218             }
219             else
220             {
221                 rSh.InsertLineBreak();
222             }
223         }
224         rReq.Done();
225         break;
226 
227     case FN_INSERT_PAGEBREAK:
228         rSh.InsertPageBreak();
229         rReq.Done();
230         break;
231 
232     case FN_INSERT_LINEBREAK:
233         rSh.InsertLineBreak();
234         rReq.Done();
235         break;
236 
237     case FN_INSERT_COLUMN_BREAK:
238         rSh.InsertColumnBreak();
239         rReq.Done();
240         break;
241 
242     case SID_HYPERLINK_SETLINK:
243         if (pItem)
244             InsertHyperlink(*((const SvxHyperlinkItem *)pItem));
245         rReq.Done();
246         break;
247 
248     case SID_INSERT_AVMEDIA:
249         rReq.SetReturnValue(SfxBoolItem(nSlot, InsertMediaDlg( rReq )));
250         break;
251 
252 	case  SID_INSERT_SOUND:
253 	case  SID_INSERT_VIDEO:
254 	{
255 		SvxPluginFileDlg aDlg( &GetView().GetViewFrame()->GetWindow(), nSlot );
256 		aDlg.SetContext( nSlot == SID_INSERT_SOUND? sfx2::FileDialogHelper::SW_INSERT_SOUND : sfx2::FileDialogHelper::SW_INSERT_VIDEO );
257 
258 		if ( ERRCODE_NONE == aDlg.Execute() )
259 		{
260 			// URL ermitteln
261 			String aStrURL( aDlg.GetPath() );
262             aStrURL = URIHelper::SmartRel2Abs(
263                 INetURLObject(), aStrURL, URIHelper::GetMaybeFileHdl() );
264 
265 			INetURLObject* pURL = new INetURLObject();
266 			pURL->SetSmartProtocol( INET_PROT_FILE );
267 
268 			if ( pURL->SetURL( aStrURL, INetURLObject::WAS_ENCODED ) )
269 			{
270                 ::rtl::OUString aName;
271                 comphelper::EmbeddedObjectContainer aCnt;
272                 svt::EmbeddedObjectRef xObj( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aName ), embed::Aspects::MSOLE_CONTENT );
273                 if ( xObj.is() )
274                 {
275                 	svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
276 
277                     // set properties from dialog
278                     uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
279                     if ( xSet.is() )
280                     {
281                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
282                                 uno::makeAny( ::rtl::OUString( pURL->GetMainURL( INetURLObject::NO_DECODE ) ) ) );
283                     }
284                 }
285 
286                 rSh.InsertObject( xObj, 0, sal_True, nSlot);
287 			}
288 		}
289 	}
290 	break;
291 
292 	case SID_INSERT_OBJECT:
293 	case SID_INSERT_PLUGIN:
294     {
295         SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False );
296 		SvGlobalName *pName = NULL;
297 		SvGlobalName aName;
298 		if ( pNameItem )
299 		{
300 			aName = pNameItem->GetValue();
301 			pName = &aName;
302 		}
303 
304         SFX_REQUEST_ARG( rReq, pClassLocationItem,  SfxStringItem, FN_PARAM_2, sal_False );
305         SFX_REQUEST_ARG( rReq, pCommandsItem,       SfxStringItem, FN_PARAM_3, sal_False );
306         //TODO/LATER: recording currently not working, need code for Commandlist
307         svt::EmbeddedObjectRef xObj;
308         if( nSlot == SID_INSERT_PLUGIN && ( pClassLocationItem || pCommandsItem ) )
309         {
310             String sClassLocation;
311             if(pClassLocationItem)
312                 sClassLocation = pClassLocationItem->GetValue();
313 
314             SvCommandList aCommandList;
315             if(pCommandsItem)
316             {
317                 sal_uInt16 nTemp;
318                 aCommandList.AppendCommands( pCommandsItem->GetValue(), &nTemp );
319             }
320 
321             {
322                 comphelper::EmbeddedObjectContainer aCnt;
323                 ::rtl::OUString sName;
324                 xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), sName ),
325 							embed::Aspects::MSOLE_CONTENT );
326                 svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
327                 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
328                 if ( xSet.is() )
329                 {
330                     try
331                     {
332                         if ( sClassLocation.Len() )
333                             xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
334                                 uno::makeAny(
335                                     ::rtl::OUString(
336                                         URIHelper::SmartRel2Abs(
337                                             INetURLObject(), sClassLocation,
338                                             URIHelper::GetMaybeFileHdl()) ) ) );
339                         uno::Sequence< beans::PropertyValue > aSeq;
340                         if ( aCommandList.Count() )
341                         {
342                             aCommandList.FillSequence( aSeq );
343                             xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands"), uno::makeAny( aSeq ) );
344                         }
345                     }
346                     catch ( uno::Exception& )
347                     {
348                     }
349                 }
350             }
351 
352             if(xObj.is())
353                 rSh.InsertOleObject( xObj );
354         }
355         else
356         {
357             DBG_ASSERT( !pNameItem || nSlot == SID_INSERT_OBJECT, "Superfluous argument!" );
358             rSh.InsertObject( xObj, pName, sal_True, nSlot);
359             rReq.Done();
360         }
361 		break;
362 	}
363     case SID_INSERT_FLOATINGFRAME:
364     {
365         svt::EmbeddedObjectRef xObj;
366         SFX_REQUEST_ARG( rReq, pNameItem,   SfxStringItem, FN_PARAM_1, sal_False );
367         SFX_REQUEST_ARG( rReq, pURLItem,    SfxStringItem, FN_PARAM_2, sal_False );
368         SFX_REQUEST_ARG( rReq, pMarginItem, SvxSizeItem, FN_PARAM_3, sal_False );
369         SFX_REQUEST_ARG( rReq, pScrollingItem, SfxByteItem, FN_PARAM_4, sal_False );
370         SFX_REQUEST_ARG( rReq, pBorderItem, SfxBoolItem, FN_PARAM_5, sal_False );
371 
372         if(pURLItem) // URL is a _must_
373         {
374             comphelper::EmbeddedObjectContainer aCnt;
375             ::rtl::OUString aName;
376             xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aName ),
377 						embed::Aspects::MSOLE_CONTENT );
378             svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
379             uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
380             if ( xSet.is() )
381             {
382                 try
383                 {
384                     ScrollingMode eScroll = ScrollingAuto;
385                     if( pScrollingItem && pScrollingItem->GetValue() <= ScrollingAuto )
386                         eScroll = (ScrollingMode) pScrollingItem->GetValue();
387 
388                     Size aMargin;
389                     if ( pMarginItem )
390                         aMargin = pMarginItem->GetSize();
391 
392                     if ( pURLItem )
393                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameURL"), uno::makeAny( ::rtl::OUString( pURLItem->GetValue() ) ) );
394                     if ( pNameItem )
395                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameName"), uno::makeAny( ::rtl::OUString( pNameItem->GetValue() ) ) );
396 
397                     if ( eScroll == ScrollingAuto )
398                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll"),
399                             uno::makeAny( sal_True ) );
400                     else
401                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode"),
402                             uno::makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
403 
404                     //if ( aFrmDescr.IsFrameBorderSet() )
405                     if ( pBorderItem )
406                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder"),
407                             uno::makeAny( (sal_Bool) pBorderItem->GetValue() ) );
408                     /*else
409                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder"),
410                             makeAny( sal_True ) );*/
411 
412                     if ( pMarginItem )
413                     {
414                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth"),
415                             uno::makeAny( sal_Int32( aMargin.Width() ) ) );
416 
417                         xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight"),
418                             uno::makeAny( sal_Int32( aMargin.Height() ) ) );
419                     }
420                 }
421                 catch ( uno::Exception& )
422                 {
423                 }
424             }
425 
426             rSh.InsertOleObject( xObj );
427         }
428         else
429         {
430             rSh.InsertObject( xObj, 0, sal_True, nSlot);
431             rReq.Done();
432         }
433     }
434     break;
435 	case SID_INSERT_DIAGRAM:
436 		{
437 			SvtModuleOptions aMOpt;
438 			if ( !aMOpt.IsChart() )
439 				break;
440 			if(!rReq.IsAPI())
441 			{
442 				SfxViewFrame* pVFrame = GetView().GetViewFrame();
443                 SwInsertChart( &GetView().GetEditWin(), &pVFrame->GetBindings() );
444 			}
445 			else
446 			{
447                 uno::Reference< chart2::data::XDataProvider > xDataProvider;
448                 sal_Bool bFillWithData = sal_True;
449                 OUString aRangeString;
450                 if (!GetShell().IsTblComplexForChart())
451                 {
452                     SwFrmFmt* pTblFmt = GetShell().GetTableFmt();
453                     String aCurrentTblName = pTblFmt->GetName();
454         //             String aText( String::CreateFromAscii("<.>") );   // was used for UI
455         //             aText.Insert( rWrtShell.GetBoxNms(), 2);
456         //             aText.Insert( aCurrentTblName, 1 );
457                     aRangeString = aCurrentTblName;
458                     aRangeString += OUString::valueOf( sal_Unicode('.') );
459                     aRangeString += GetShell().GetBoxNms();
460 
461                     // get table data provider
462                     xDataProvider.set( GetView().GetDocShell()->getIDocumentChartDataProviderAccess()->GetChartDataProvider() );
463                 }
464                 else
465                     bFillWithData = sal_False;  // will create chart with only it's default image
466 
467                 SwTableFUNC( &rSh, sal_False ).InsertChart( xDataProvider, bFillWithData, aRangeString );
468 				rSh.LaunchOLEObj();
469 
470                 svt::EmbeddedObjectRef& xObj = rSh.GetOLEObject();
471                 if(pItem && xObj.is())
472 				{
473 					Size aSize(((SvxSizeItem*)pItem)->GetSize());
474 					aSize = OutputDevice::LogicToLogic
475 									( aSize, MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ) );
476 
477 					if(aSize.Width() > MINLAY&& aSize.Height()> MINLAY)
478 					{
479                         awt::Size aSz;
480                         aSz.Width = aSize.Width();
481                         aSz.Height = aSize.Height();
482                         xObj->setVisualAreaSize( xObj.GetViewAspect(), aSz );
483 					}
484 				}
485 			}
486 		}
487 		break;
488 
489 	case FN_INSERT_SMA:
490 		{
491             // #i34343# Inserting a math object into an autocompletion crashes
492             // the suggestion has to be removed before
493             GetView().GetEditWin().StopQuickHelp();
494             SvGlobalName aGlobalName( SO3_SM_CLASSID );
495             rSh.InsertObject( svt::EmbeddedObjectRef(), &aGlobalName, sal_True, 0 );
496 		}
497 		break;
498 
499 	case FN_INSERT_TABLE:
500         InsertTable( rReq );
501         break;
502 
503 	case FN_INSERT_FRAME_INTERACT_NOCOL:
504 	case FN_INSERT_FRAME_INTERACT:
505 	{
506         sal_uInt16 nCols = 1;
507         sal_Bool bModifier1 = rReq.GetModifier() == KEY_MOD1;
508         if(pArgs)
509         {
510             if(FN_INSERT_FRAME_INTERACT_NOCOL != nSlot &&
511                 pArgs->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem) == SFX_ITEM_SET)
512                 nCols = ((SfxUInt16Item *)pItem)->GetValue();
513             if(pArgs->GetItemState(SID_MODIFIER, sal_False, &pItem) == SFX_ITEM_SET)
514                 bModifier1 |= KEY_MOD1 == ((SfxUInt16Item *)pItem)->GetValue();
515         }
516         if(bModifier1 )
517         {
518             SwEditWin& rEdtWin = GetView().GetEditWin();
519             Size aWinSize = rEdtWin.GetSizePixel();
520             Point aStartPos(aWinSize.Width()/2, aWinSize.Height() / 2);
521             aStartPos = rEdtWin.PixelToLogic(aStartPos);
522             aStartPos.X() -= 8 * MM50;
523             aStartPos.Y() -= 4 * MM50;
524             Size aSize(16 * MM50, 8 * MM50);
525             GetShell().LockPaint();
526             GetShell().StartAllAction();
527             SwFlyFrmAttrMgr aMgr( sal_True, GetShellPtr(), FRMMGR_TYPE_TEXT );
528             if(nCols > 1)
529             {
530                 SwFmtCol aCol;
531                 aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
532                 aMgr.SetCol( aCol );
533             }
534             aMgr.InsertFlyFrm(FLY_AT_PARA, aStartPos, aSize);
535             GetShell().EndAllAction();
536             GetShell().UnlockPaint();
537         }
538         else
539         {
540             GetView().InsFrmMode(nCols);
541         }
542         rReq.Ignore();
543     }
544 	break;
545 	case FN_INSERT_FRAME:
546 	{
547 		sal_Bool bSingleCol = sal_False;
548         if( 0!= dynamic_cast< SwWebDocShell*>( GetView().GetDocShell()) )
549 		{
550 			SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
551 			sal_uInt16 nExport = pHtmlOpt->GetExportMode();
552 			if( HTML_CFG_MSIE == nExport ||
553 				HTML_CFG_HTML32 == nExport ||
554 				HTML_CFG_MSIE_40 == nExport ||
555 				HTML_CFG_HTML32 == nExport )
556 			{
557 				bSingleCol = sal_True;
558 			}
559 
560 		}
561 		// Rahmen neu anlegen
562 		SwFlyFrmAttrMgr aMgr( sal_True, GetShellPtr(), FRMMGR_TYPE_TEXT );
563         if(pArgs)
564         {
565             Size aSize(aMgr.GetSize());
566             aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width();
567             Point aPos = aMgr.GetPos();
568             RndStdIds eAnchor = FLY_AT_PARA;
569             if(pArgs->GetItemState(nSlot, sal_False, &pItem) == SFX_ITEM_SET)
570                 eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue();
571             if(pArgs->GetItemState(FN_PARAM_1, sal_False, &pItem)  == SFX_ITEM_SET)
572                 aPos = ((SfxPointItem *)pItem)->GetValue();
573             if(pArgs->GetItemState(FN_PARAM_2, sal_False, &pItem)  == SFX_ITEM_SET)
574                 aSize = ((SvxSizeItem *)pItem)->GetSize();
575             if(pArgs->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem)  == SFX_ITEM_SET)
576             {
577                 sal_uInt16 nCols = ((SfxUInt16Item *)pItem)->GetValue();
578                 if( !bSingleCol && 1 < nCols )
579                 {
580                     SwFmtCol aFmtCol;
581                     aFmtCol.Init( nCols , (rReq.IsAPI() ? 0
582                                         : DEF_GUTTER_WIDTH), USHRT_MAX );
583                     aMgr.SetCol(aFmtCol);
584                 }
585             }
586 
587             GetShell().LockPaint();
588             GetShell().StartAllAction();
589 
590             aMgr.InsertFlyFrm(eAnchor, aPos, aSize);
591 
592             GetShell().EndAllAction();
593             GetShell().UnlockPaint();
594         }
595         else
596         {
597             static sal_uInt16 __READONLY_DATA aFrmAttrRange[] =
598             {
599                 RES_FRMATR_BEGIN,       RES_FRMATR_END-1,
600                 SID_ATTR_BORDER_INNER,  SID_ATTR_BORDER_INNER,
601                 FN_GET_PRINT_AREA,      FN_GET_PRINT_AREA,
602                 SID_ATTR_PAGE_SIZE,     SID_ATTR_PAGE_SIZE,
603                 FN_SET_FRM_NAME,        FN_SET_FRM_NAME,
604                 SID_HTML_MODE,          SID_HTML_MODE,
605                 0
606             };
607 
608             SfxItemSet aSet(GetPool(), aFrmAttrRange );
609             aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
610             const SwRect &rPg = GetShell().GetAnyCurRect(RECT_PAGE);
611             SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height());
612             aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE));
613             aSet.Put(aFrmSize);
614 
615             const SwRect &rPr = GetShell().GetAnyCurRect(RECT_PAGE_PRT);
616             SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height());
617             aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA));
618             aSet.Put(aPrtSize);
619 
620             aSet.Put(aMgr.GetAttrSet());
621             aSet.SetParent( aMgr.GetAttrSet().GetParent() );
622 
623             // Minimalgroesse in Spalten loeschen
624             SvxBoxInfoItem aBoxInfo((SvxBoxInfoItem &)aSet.Get(SID_ATTR_BORDER_INNER));
625             const SvxBoxItem& rBox = (const SvxBoxItem&)aSet.Get(RES_BOX);
626             aBoxInfo.SetMinDist(sal_False);
627             aBoxInfo.SetDefDist(rBox.GetDistance(BOX_LINE_LEFT));
628             aSet.Put(aBoxInfo);
629 
630             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, GetView().GetDocShell()));
631             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
632 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
633             DBG_ASSERT(pFact, "Dialogdiet fail!");
634             SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_STD,
635 													GetView().GetViewFrame(), &GetView().GetViewFrame()->GetWindow(), aSet, sal_True);
636             DBG_ASSERT(pDlg, "Dialogdiet fail!");
637             if(pDlg->Execute() && pDlg->GetOutputItemSet())
638             {
639                 //local variable necessary at least after call of .AutoCaption() because this could be deleted at this point
640                 SwWrtShell& rShell = GetShell();
641                 rShell.LockPaint();
642                 rShell.StartAllAction();
643                 rShell.StartUndo(UNDO_INSERT);
644 
645                 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
646                 aMgr.SetAttrSet(*pOutSet);
647 
648                 // beim ClickToEditFeld erst die Selektion loeschen
649                 if( rShell.IsInClickToEdit() )
650                     rShell.DelRight();
651 
652                 aMgr.InsertFlyFrm();
653 
654                 uno::Reference< frame::XDispatchRecorder > xRecorder =
655                         GetView().GetViewFrame()->GetBindings().GetRecorder();
656                 if ( xRecorder.is() )
657                 {
658                     //FN_INSERT_FRAME
659                     sal_uInt16 nAnchor = (sal_uInt16)aMgr.GetAnchor();
660                         rReq.AppendItem(SfxUInt16Item(nSlot, nAnchor));
661                         rReq.AppendItem(SfxPointItem(FN_PARAM_1, rShell.GetObjAbsPos()));
662                         rReq.AppendItem(SvxSizeItem(FN_PARAM_2, rShell.GetObjSize()));
663                     rReq.Done();
664                 }
665 
666                 GetView().AutoCaption(FRAME_CAP);
667 
668                 {
669                     SwRewriter aRewriter;
670 
671                     aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_FRAME));
672 
673                     rShell.EndUndo(UNDO_INSERT, &aRewriter);
674                 }
675                 rShell.EndAllAction();
676                 rShell.UnlockPaint();
677             }
678 
679             DELETEZ(pDlg);
680         }
681 		break;
682 	}
683 	case FN_INSERT_HRULER:
684 	{
685 		String sPath;
686 		sal_Bool bSimpleLine = sal_False;
687 		sal_Bool bRet = sal_False;
688 		Window* pParent = GetView().GetWindow();
689         if ( pItem )
690         {
691             sPath = ((SfxStringItem*)pItem)->GetValue();
692             SFX_REQUEST_ARG( rReq, pSimple, SfxBoolItem, FN_PARAM_1 , sal_False );
693             if ( pSimple )
694                 bSimpleLine = pSimple->GetValue();
695         }
696         else
697         {
698             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
699             DBG_ASSERT(pFact, "Dialogdiet fail!");
700             AbstractInsertGrfRulerDlg* pDlg = pFact->CreateInsertGrfRulerDlg( DLG_INSERT_RULER,
701 														pParent );
702             DBG_ASSERT(pDlg, "Dialogdiet fail!");
703 			// MessageBox fuer fehlende Grafiken
704             if(!pDlg->HasImages())
705                 InfoBox( pParent, SW_RES(MSG_NO_RULER)).Execute();
706             if(RET_OK == pDlg->Execute())
707             {
708                 sPath = pDlg->GetGraphicName();
709                 bSimpleLine = pDlg->IsSimpleLine();
710             }
711 
712             delete pDlg;
713             rReq.AppendItem( SfxStringItem( FN_INSERT_HRULER, sPath ) );
714             rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bSimpleLine ) );
715         }
716 
717 		rSh.StartAllAction();
718         rSh.StartUndo(UNDO_UI_INSERT_RULER);
719 		if(bSimpleLine)
720 		{
721 			if(!(rSh.IsSttOfPara() && rSh.IsEndOfPara())) // kein leerer Absatz?
722 				rSh.SplitNode( sal_False, sal_False ); // dann Platz schaffen
723 			rSh.SplitNode( sal_False, sal_False );
724 			rSh.Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
725 			rSh.SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_HTML_HR ));
726 			rSh.Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
727 			bRet = sal_True;
728 		}
729 		else if(sPath.Len())
730 		{
731             SwFlyFrmAttrMgr aFrmMgr( sal_True, &rSh, FRMMGR_TYPE_GRF );
732 			// am FrmMgr muessen die richtigen Parameter eingestellt werden
733 
734             aFrmMgr.SetAnchor(FLY_AS_CHAR);
735 
736 			rSh.SplitNode( sal_False, sal_False );
737 			rSh.SplitNode( sal_False, sal_False );
738 			rSh.Left(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
739 			rSh.SetAttrItem(SvxAdjustItem(SVX_ADJUST_CENTER,RES_PARATR_ADJUST ));
740             if(GRFILTER_OK == GetView().InsertGraphic(sPath, aEmptyStr, sal_True, 0, 0 ))
741 				bRet = sal_True;
742 			rSh.EnterStdMode();
743 			rSh.Right(CRSR_SKIP_CHARS, sal_False, 1, sal_False );
744 		}
745 		rSh.EndAllAction();
746         rSh.EndUndo(UNDO_UI_INSERT_RULER);
747 		rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
748         rReq.Done();
749 	}
750 	break;
751 	case FN_FORMAT_COLUMN :
752 	{
753 		SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
754         DBG_ASSERT(pFact, "Dialogdiet fail!");
755         VclAbstractDialog* pColDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_COLUMN);
756         DBG_ASSERT(pColDlg, "Dialogdiet fail!");
757 		pColDlg->Execute();
758 		delete pColDlg;
759 	}
760 	break;
761 
762 	default:
763 		ASSERT( !this, "falscher Dispatcher" );
764 		return;
765 	}
766 }
767 
768 bool lcl_IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect )
769 {
770     rWrtSh.SwapPam();
771     bool bRet = pSect == rWrtSh.GetCurrSection();
772     rWrtSh.SwapPam();
773     return bRet;
774 }
775 
776 
777 void SwTextShell::StateInsert( SfxItemSet &rSet )
778 {
779     sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
780     SfxWhichIter aIter( rSet );
781     SwWrtShell &rSh = GetShell();
782     sal_uInt16 nWhich = aIter.FirstWhich();
783     SvtModuleOptions aMOpt;
784     SfxObjectCreateMode eCreateMode =
785                         GetView().GetDocShell()->GetCreateMode();
786 
787     rSh.Push();
788     const sal_Bool bCrsrInHidden = rSh.SelectHiddenRange();
789     rSh.Pop();
790 
791     while ( nWhich )
792     {
793         switch ( nWhich )
794         {
795         case SID_INSERT_AVMEDIA:
796         case SID_INSERT_SOUND:
797         case SID_INSERT_VIDEO:
798             if ( GetShell().IsSelFrmMode()
799                  || GetShell().CrsrInsideInputFld()
800                  || SFX_CREATE_MODE_EMBEDDED == eCreateMode
801                  || bCrsrInHidden )
802             {
803                 rSet.DisableItem( nWhich );
804             }
805             break;
806 
807         case SID_INSERT_DIAGRAM:
808             if( !aMOpt.IsChart()
809                 || GetShell().CrsrInsideInputFld()
810                 || eCreateMode == SFX_CREATE_MODE_EMBEDDED
811                 || bCrsrInHidden )
812             {
813                 rSet.DisableItem( nWhich );
814             }
815             break;
816 
817             case FN_INSERT_SMA:
818                 if( !aMOpt.IsMath()
819                     || eCreateMode == SFX_CREATE_MODE_EMBEDDED
820                     || bCrsrInHidden
821                     || rSh.CrsrInsideInputFld() )
822                 {
823                     rSet.DisableItem( nWhich );
824                 }
825                 break;
826 
827             case SID_INSERT_FLOATINGFRAME:
828             case SID_INSERT_OBJECT:
829             case SID_INSERT_PLUGIN:
830                 {
831                     if( eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden )
832                     {
833                         rSet.DisableItem( nWhich );
834                     }
835                     else if( GetShell().IsSelFrmMode()
836                              || GetShell().CrsrInsideInputFld() )
837                     {
838                         rSet.DisableItem( nWhich );
839                     }
840                     else if(SID_INSERT_FLOATINGFRAME == nWhich && nHtmlMode&HTMLMODE_ON)
841                     {
842                         SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
843                         sal_uInt16 nExport = pHtmlOpt->GetExportMode();
844                         if(HTML_CFG_MSIE_40 != nExport && HTML_CFG_WRITER != nExport )
845                             rSet.DisableItem(nWhich);
846                     }
847                 }
848                 break;
849 
850             case FN_INSERT_FRAME_INTERACT_NOCOL :
851             case FN_INSERT_FRAME_INTERACT:
852                 {
853                     if( GetShell().IsSelFrmMode()
854                         || GetShell().CrsrInsideInputFld()
855                         || ( 0 != (nHtmlMode & HTMLMODE_ON)
856                              && 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS) )
857                         || bCrsrInHidden )
858                         rSet.DisableItem(nWhich);
859                 }
860                 break;
861 
862             case SID_HYPERLINK_GETLINK:
863                 {
864                     SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
865                     rSh.GetCurAttr( aSet );
866 
867                     SvxHyperlinkItem aHLinkItem;
868                     const SfxPoolItem* pItem;
869                     if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, sal_False, &pItem))
870                     {
871                         const SwFmtINetFmt* pINetFmt = (const SwFmtINetFmt*)pItem;
872                         aHLinkItem.SetURL(pINetFmt->GetValue());
873                         aHLinkItem.SetTargetFrame(pINetFmt->GetTargetFrame());
874                         aHLinkItem.SetIntName(pINetFmt->GetName());
875                         const SvxMacro *pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOVER_OBJECT );
876                         if( pMacro )
877                             aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOVER_OBJECT, *pMacro);
878 
879                         pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
880                         if( pMacro )
881                             aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSECLICK_OBJECT, *pMacro);
882 
883                         pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOUT_OBJECT );
884                         if( pMacro )
885                             aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOUT_OBJECT, *pMacro);
886 
887                         // Text des Links besorgen
888                         rSh.StartAction();
889                         rSh.CreateCrsr();
890                         rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT,sal_True);
891                         String sLinkName = rSh.GetSelTxt();
892                         aHLinkItem.SetName(sLinkName);
893                         aHLinkItem.SetInsertMode(HLINK_FIELD);
894                         rSh.DestroyCrsr();
895                         rSh.EndAction();
896                     }
897                     else
898                     {
899                         String sReturn = rSh.GetSelTxt();
900                         sReturn.Erase(255);
901                         sReturn.EraseTrailingChars();
902                         aHLinkItem.SetName(sReturn);
903                     }
904 
905                     aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
906                         ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
907                     aHLinkItem.SetMacroEvents (	HYPERDLG_EVENT_MOUSEOVER_OBJECT|
908                         HYPERDLG_EVENT_MOUSECLICK_OBJECT | HYPERDLG_EVENT_MOUSEOUT_OBJECT );
909 
910                     rSet.Put(aHLinkItem);
911                 }
912                 break;
913 
914             case FN_INSERT_FRAME:
915                 if (rSh.IsSelFrmMode() )
916                 {
917                     const int nSel = rSh.GetSelectionType();
918                     if( ((nsSelectionType::SEL_GRF | nsSelectionType::SEL_OLE ) & nSel ) || bCrsrInHidden )
919                         rSet.DisableItem(nWhich);
920                 }
921                 else if ( rSh.CrsrInsideInputFld() )
922                 {
923                     rSet.DisableItem(nWhich);
924                 }
925                 break;
926 
927             case FN_INSERT_HRULER :
928                 if( (rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel())
929                     || bCrsrInHidden
930                     || rSh.CrsrInsideInputFld() )
931                 {
932                     rSet.DisableItem(nWhich);
933                 }
934                 break;
935 
936             case FN_FORMAT_COLUMN :
937             {
938                 //#i80458# column dialog cannot work if the selection contains different page styles and different sections
939                 bool bDisable = true;
940                 if( rSh.GetFlyFrmFmt() || rSh.GetSelectedPageDescs() )
941                     bDisable = false;
942                 if( bDisable )
943                 {
944                     const SwSection* pCurrSection = rSh.GetCurrSection();
945                     sal_uInt16 nFullSectCnt = rSh.GetFullSelectedSectionCount();
946                     if( pCurrSection && ( !rSh.HasSelection() || 0 != nFullSectCnt ))
947                         bDisable = false;
948                     else if(
949                         rSh.HasSelection() && rSh.IsInsRegionAvailable() &&
950                             ( !pCurrSection || ( 1 != nFullSectCnt &&
951                                 lcl_IsMarkInSameSection( rSh, pCurrSection ) )))
952                         bDisable = false;
953                 }
954                 if(bDisable)
955                     rSet.DisableItem(nWhich);
956             }
957             break;
958 		}
959 		nWhich = aIter.NextWhich();
960 	}
961 }
962 
963 /*--------------------------------------------------------------------
964 	Beschreibung:
965  --------------------------------------------------------------------*/
966 
967 void  SwTextShell::ExecDelete(SfxRequest &rReq)
968 {
969 	SwWrtShell &rSh = GetShell();
970 	switch( rReq.GetSlot() )
971 	{
972 		case FN_DELETE_SENT:
973 			if( rSh.IsTableMode() )
974 			{
975 				rSh.DeleteRow();
976 				rSh.EnterStdMode();
977 			}
978 			else
979 				rSh.DelToEndOfSentence();
980 			break;
981 		case FN_DELETE_BACK_SENT:
982 			rSh.DelToStartOfSentence();
983 			break;
984 		case FN_DELETE_WORD:
985 			rSh.DelNxtWord();
986 			break;
987 		case FN_DELETE_BACK_WORD:
988 			rSh.DelPrvWord();
989 			break;
990 		case FN_DELETE_LINE:
991 			rSh.DelToEndOfLine();
992 			break;
993 		case FN_DELETE_BACK_LINE:
994 			rSh.DelToStartOfLine();
995 			break;
996 		case FN_DELETE_PARA:
997 			rSh.DelToEndOfPara();
998 			break;
999 		case FN_DELETE_BACK_PARA:
1000 			rSh.DelToStartOfPara();
1001 			break;
1002 		case FN_DELETE_WHOLE_LINE:
1003 			rSh.DelLine();
1004 			break;
1005 		default:
1006 			ASSERT(!this, "falscher Dispatcher");
1007 			return;
1008 	}
1009     rReq.Done();
1010 }
1011 
1012 void SwTextShell::ExecTransliteration( SfxRequest & rReq )
1013 {
1014     using namespace ::com::sun::star::i18n;
1015 	{
1016 		sal_uInt32 nMode = 0;
1017 
1018 		switch( rReq.GetSlot() )
1019 		{
1020         case SID_TRANSLITERATE_SENTENCE_CASE:
1021             nMode = TransliterationModulesExtra::SENTENCE_CASE;
1022             break;
1023         case SID_TRANSLITERATE_TITLE_CASE:
1024             nMode = TransliterationModulesExtra::TITLE_CASE;
1025             break;
1026         case SID_TRANSLITERATE_TOGGLE_CASE:
1027             nMode = TransliterationModulesExtra::TOGGLE_CASE;
1028             break;
1029 		case SID_TRANSLITERATE_UPPER:
1030 			nMode = TransliterationModules_LOWERCASE_UPPERCASE;
1031 			break;
1032 		case SID_TRANSLITERATE_LOWER:
1033 			nMode = TransliterationModules_UPPERCASE_LOWERCASE;
1034 			break;
1035 
1036 		case SID_TRANSLITERATE_HALFWIDTH:
1037 			nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
1038 			break;
1039 		case SID_TRANSLITERATE_FULLWIDTH:
1040 			nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
1041 			break;
1042 
1043 		case SID_TRANSLITERATE_HIRAGANA:
1044 			nMode = TransliterationModules_KATAKANA_HIRAGANA;
1045 			break;
1046 		case SID_TRANSLITERATE_KATAGANA:
1047 			nMode = TransliterationModules_HIRAGANA_KATAKANA;
1048 			break;
1049 
1050 		default:
1051 			ASSERT(!this, "falscher Dispatcher");
1052 		}
1053 
1054 		if( nMode )
1055 			GetShell().TransliterateText( nMode );
1056 	}
1057 }
1058 
1059 
1060 /*--------------------------------------------------------------------
1061 	Beschreibung:
1062  --------------------------------------------------------------------*/
1063 
1064 
1065 
1066 SwTextShell::SwTextShell(SwView &_rView) :
1067     SwBaseShell(_rView), pPostItFldMgr( 0 )
1068 {
1069 	SetName(String::CreateFromAscii("Text"));
1070 	SetHelpId(SW_TEXTSHELL);
1071     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Text));
1072 }
1073 
1074 /*--------------------------------------------------------------------
1075 	Beschreibung:
1076  --------------------------------------------------------------------*/
1077 
1078 SwTextShell::~SwTextShell()
1079 {
1080 }
1081 
1082 /*--------------------------------------------------------------------
1083 	Beschreibung:
1084  --------------------------------------------------------------------*/
1085 
1086 void SwTextShell::InsertSymbol( SfxRequest& rReq )
1087 {
1088 	const SfxItemSet *pArgs = rReq.GetArgs();
1089 	const SfxPoolItem* pItem = 0;
1090     if( pArgs )
1091         pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), sal_False, &pItem);
1092 
1093     String aChars, aFontName;
1094     if ( pItem )
1095     {
1096         aChars = ((const SfxStringItem*)pItem)->GetValue();
1097         const SfxPoolItem* pFtItem = NULL;
1098         pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), sal_False, &pFtItem);
1099         const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
1100         if ( pFontItem )
1101             aFontName = pFontItem->GetValue();
1102     }
1103 
1104 	SwWrtShell &rSh = GetShell();
1105 	SfxItemSet aSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT,
1106 								RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
1107 								RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT,
1108 								0 );
1109     rSh.GetCurAttr( aSet );
1110 	sal_uInt16 nScript = rSh.GetScriptType();
1111 
1112     SvxFontItem aFont( RES_CHRATR_FONT );
1113 	{
1114 		SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
1115 		aSetItem.GetItemSet().Put( aSet, sal_False );
1116 		const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
1117 		if( pI )
1118 			aFont = *(SvxFontItem*)pI;
1119 		else
1120 			aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
1121 						RES_CHRATR_FONT,
1122                         GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
1123 		if (!aFontName.Len())
1124 			aFontName = aFont.GetFamilyName();
1125 	}
1126 
1127     Font aNewFont(aFontName, Size(1,1)); // Size nur wg. CTOR
1128     if( !aChars.Len() )
1129 	{
1130 		// Eingestellten Font als Default
1131         SfxAllItemSet aAllSet( rSh.GetAttrPool() );
1132         aAllSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
1133 
1134         SwViewOption aOpt(*GetShell().GetViewOptions());
1135         String sSymbolFont = aOpt.GetSymbolFont();
1136         if( !aFontName.Len() && sSymbolFont.Len() )
1137             aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
1138         else
1139             aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont.GetFamilyName() ) );
1140 
1141 		SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1142         SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aAllSet,
1143 			GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
1144 		if( RET_OK == pDlg->Execute() )
1145 		{
1146             SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, sal_False );
1147 			SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
1148 			if ( pFontItem )
1149 			{
1150 				aNewFont.SetName( pFontItem->GetFamilyName() );
1151 				aNewFont.SetStyleName( pFontItem->GetStyleName() );
1152 				aNewFont.SetCharSet( pFontItem->GetCharSet() );
1153 				aNewFont.SetPitch( pFontItem->GetPitch() );
1154 			}
1155 
1156             if ( pCItem )
1157 			{
1158                 aChars  = pCItem->GetValue();
1159 				aOpt.SetSymbolFont(aNewFont.GetName());
1160 				SW_MOD()->ApplyUsrPref(aOpt, &GetView());
1161 			}
1162 		}
1163 
1164 		delete pDlg;
1165 	}
1166 
1167 	sal_Bool bFontChanged = sal_False;
1168 	if( aChars.Len() )
1169 	{
1170 		rSh.StartAllAction();
1171 
1172 		// Selektierten Inhalt loeschen
1173         SwRewriter aRewriter;
1174         aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_SPECIALCHAR));
1175 
1176 		rSh.StartUndo( UNDO_INSERT, &aRewriter );
1177 		if ( rSh.HasSelection() )
1178 		{
1179 			rSh.DelRight();
1180 			aSet.ClearItem();
1181             rSh.GetCurAttr( aSet );
1182 
1183 			SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
1184 			aSetItem.GetItemSet().Put( aSet, sal_False );
1185 			const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
1186 			if( pI )
1187 				aFont = *(SvxFontItem*)pI;
1188 			else
1189 				aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
1190 							RES_CHRATR_FONT,
1191                             GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() ) ));
1192 		}
1193 
1194 		// Zeichen einfuegen
1195 		rSh.Insert( aChars );
1196 
1197         // #108876# a font attribute has to be set always due to a guessed script type
1198         if( aNewFont.GetName().Len() )
1199         {
1200 			bFontChanged = sal_True;
1201 			SvxFontItem aNewFontItem( aFont );
1202             aNewFontItem.SetFamilyName( aNewFont.GetName());
1203             aNewFontItem.SetFamily(  aNewFont.GetFamily());
1204             aNewFontItem.SetPitch(   aNewFont.GetPitch());
1205             aNewFontItem.SetCharSet( aNewFont.GetCharSet() );
1206 
1207             SfxItemSet aRestoreSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT,
1208 								               RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
1209 								               RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT, 0 );
1210 
1211             nScript = pBreakIt->GetAllScriptsOfText( aChars );
1212 			if( SCRIPTTYPE_LATIN & nScript )
1213             {
1214                 aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT, sal_True ) );
1215 				aSet.Put( aNewFontItem, RES_CHRATR_FONT);
1216             }
1217 			if( SCRIPTTYPE_ASIAN & nScript )
1218             {
1219                 aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT, sal_True ) );
1220 				aSet.Put( aNewFontItem, RES_CHRATR_CJK_FONT );
1221             }
1222 			if( SCRIPTTYPE_COMPLEX & nScript )
1223             {
1224                 aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT, sal_True ) );
1225 				aSet.Put( aNewFontItem, RES_CHRATR_CTL_FONT );
1226             }
1227 
1228 			rSh.SetMark();
1229 			rSh.ExtendSelection( sal_False, aChars.Len() );
1230 			rSh.SetAttrSet( aSet, nsSetAttrMode::SETATTR_DONTEXPAND | nsSetAttrMode::SETATTR_NOFORMATATTR );
1231 			if( !rSh.IsCrsrPtAtEnd() )
1232 				rSh.SwapPam();
1233 
1234             rSh.ClearMark();
1235 
1236             // --> FME 2007-07-09 #i75891#
1237             // SETATTR_DONTEXPAND does not work if there are already hard attributes.
1238             // Therefore we have to restore the font attributes.
1239             rSh.SetMark();
1240             rSh.SetAttrSet( aRestoreSet );
1241             rSh.ClearMark();
1242             // <--
1243 
1244 			rSh.UpdateAttr();
1245             aFont = aNewFontItem;
1246 		}
1247 
1248 		rSh.EndAllAction();
1249         rSh.EndUndo();
1250 
1251         if ( aChars.Len() )
1252         {
1253             rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) );
1254             rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetName() ) );
1255             rReq.Done();
1256         }
1257     }
1258 }
1259