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