Update ooo320-m1
[ooovba.git] / sw / source / ui / shells / textsh.cxx
blob965b0f5d328fc6b2a9f6de18ea8ebfd6ddfa441d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textsh.cxx,v $
10 * $Revision: 1.63 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #define _SW_FRMVALID_HXX
36 #include <hintids.hxx>
38 #include <svtools/globalnameitem.hxx>
39 #include <sfx2/objface.hxx>
40 #include <sfx2/lnkbase.hxx>
42 #ifndef __RSC //autogen
43 #include <tools/errinf.hxx>
44 #endif
45 #include <svx/svdview.hxx>
46 #include <svtools/ptitem.hxx>
47 #include <svtools/stritem.hxx>
48 #include <svtools/moduleoptions.hxx>
49 #include <vcl/msgbox.hxx>
50 #include <sfx2/fcontnr.hxx>
51 #include <svx/hlnkitem.hxx>
52 #include <svx/srchitem.hxx>
53 #include <sfx2/dispatch.hxx>
54 #include <sfx2/docfile.hxx>
55 #include <svtools/urihelper.hxx>
56 #include <basic/sbxvar.hxx>
57 #include <svtools/whiter.hxx>
58 #include <sfx2/request.hxx>
59 #include <svx/opaqitem.hxx>
60 #include <svx/fontitem.hxx>
61 #include <svx/adjitem.hxx>
62 #include <svx/boxitem.hxx>
63 #include <svx/sizeitem.hxx>
64 #include <svx/svxacorr.hxx>
65 #include <svx/scripttypeitem.hxx>
66 #include <svtools/filter.hxx>
67 #include <svx/htmlmode.hxx>
68 #include <svx/pfiledlg.hxx>
69 #include <svx/htmlcfg.hxx>
70 #include <com/sun/star/i18n/TransliterationModules.hdl>
72 #include <sot/clsids.hxx>
73 #include <svx/acorrcfg.hxx>
74 #include <wdocsh.hxx>
75 #include <fmtinfmt.hxx>
76 #include <fmtclds.hxx>
77 #include <fmtsrnd.hxx>
78 #include <fmtfsize.hxx>
79 #include <swmodule.hxx>
80 #include <wrtsh.hxx>
81 #include <view.hxx>
82 #include <docsh.hxx>
83 #include <doc.hxx>
84 #include <uitool.hxx>
85 #ifndef _CMDID_H
86 #include <cmdid.h>
87 #endif
88 #ifndef _GLOBALS_HRC
89 #include <globals.hrc>
90 #endif
91 #include <frmmgr.hxx>
92 #include <textsh.hxx>
93 #include <frmfmt.hxx>
94 #include <tablemgr.hxx>
95 #include <swundo.hxx> // fuer Undo-IDs
96 #include <shellio.hxx>
97 #include <frmdlg.hxx>
98 #include <usrpref.hxx>
99 #include <swtable.hxx>
100 #include <tblafmt.hxx>
101 #include <caption.hxx>
102 #include <idxmrk.hxx>
103 #include <poolfmt.hxx>
104 #include <breakit.hxx>
105 #include <crsskip.hxx>
106 #include <modcfg.hxx>
107 #include <column.hxx>
108 #include <edtwin.hxx>
109 #ifndef _SHELLS_HRC
110 #include <shells.hrc>
111 #endif
112 #ifndef _POPUP_HRC
113 #include <popup.hrc>
114 #endif
115 #ifndef _SWERROR_H
116 #include <swerror.h>
117 #endif
118 #include <SwAppletImpl.hxx>
119 #include <unochart.hxx>
121 #include <chartins.hxx>
123 #define SwTextShell
124 #define Paragraph
125 #define HyphenZone
126 #define TextFont
127 #define DropCap
128 #include <sfx2/msg.hxx>
129 #include <swslots.hxx>
130 #include <SwRewriter.hxx>
131 #include <undobj.hxx>
132 #ifndef _COMCORE_HRC
133 #include <comcore.hrc>
134 #endif
136 using namespace ::com::sun::star;
137 using ::rtl::OUString;
139 #include <svx/svxdlg.hxx>
140 #include <svx/dialogs.hrc>
141 #include "swabstdlg.hxx"
142 #include <misc.hrc>
143 #include <table.hrc>
144 #include <frmui.hrc>
145 #include <unomid.h>
149 /*--------------------------------------------------------------------
150 Beschreibung:
151 --------------------------------------------------------------------*/
153 SFX_IMPL_INTERFACE(SwTextShell, SwBaseShell, SW_RES(STR_SHELLNAME_TEXT))
155 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TEXT_POPUPMENU));
156 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TEXT_TOOLBOX));
157 SFX_CHILDWINDOW_REGISTRATION(FN_EDIT_FORMULA);
158 SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD);
159 SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_IDX_ENTRY_DLG);
160 SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_AUTH_ENTRY_DLG);
161 SFX_CHILDWINDOW_REGISTRATION(SID_RUBY_DIALOG);
166 TYPEINIT1(SwTextShell,SwBaseShell)
170 void SwTextShell::ExecInsert(SfxRequest &rReq)
172 SwWrtShell &rSh = GetShell();
174 ASSERT( !rSh.IsObjSelected() && !rSh.IsFrmSelected(),
175 "Falsche Shell auf dem Dispatcher" );
177 const SfxItemSet *pArgs = rReq.GetArgs();
178 const SfxPoolItem* pItem = 0;
179 USHORT nSlot = rReq.GetSlot();
180 if(pArgs)
181 pArgs->GetItemState(nSlot, FALSE, &pItem );
183 switch( nSlot )
185 case FN_INSERT_STRING:
186 if( pItem )
187 rSh.InsertByWord(((const SfxStringItem *)pItem)->GetValue());
188 break;
189 case FN_INSERT_SOFT_HYPHEN:
190 if( CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( TRUE, 0 ) &&
191 CHAR_SOFTHYPHEN != rSh.SwCrsrShell::GetChar( TRUE, -1 ))
192 rSh.Insert( String( CHAR_SOFTHYPHEN ) );
193 break;
195 case FN_INSERT_HARDHYPHEN:
196 case FN_INSERT_HARD_SPACE:
198 sal_Unicode cIns = FN_INSERT_HARD_SPACE == nSlot ? CHAR_HARDBLANK
199 : CHAR_HARDHYPHEN;
201 SvxAutoCorrCfg* pACfg = SvxAutoCorrCfg::Get();
202 SvxAutoCorrect* pACorr = pACfg->GetAutoCorrect();
203 if( pACorr && pACfg->IsAutoFmtByInput() &&
204 pACorr->IsAutoCorrFlag( CptlSttSntnc | CptlSttWrd |
205 ChgFractionSymbol | ChgOrdinalNumber |
206 ChgToEnEmDash | SetINetAttr | Autocorrect ))
207 rSh.AutoCorrect( *pACorr, cIns );
208 else
209 rSh.Insert( String( cIns ) );
211 break;
212 case SID_INSERT_RLM :
213 case SID_INSERT_LRM :
214 case SID_INSERT_ZWNBSP :
215 case SID_INSERT_ZWSP:
217 sal_Unicode cIns = 0;
218 switch(nSlot)
220 case SID_INSERT_RLM : cIns = CHAR_RLM ; break;
221 case SID_INSERT_LRM : cIns = CHAR_LRM ; break;
222 case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break;
223 case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break;
225 rSh.Insert( String( cIns ) );
227 break;
228 case FN_INSERT_BREAK:
229 rSh.SplitNode();
230 rReq.Done();
231 break;
232 case FN_INSERT_PAGEBREAK:
233 rSh.InsertPageBreak();
234 rReq.Done();
235 break;
236 case FN_INSERT_LINEBREAK:
237 rSh.InsertLineBreak();
238 rReq.Done();
239 break;
240 case FN_INSERT_COLUMN_BREAK:
241 rSh.InsertColumnBreak();
242 rReq.Done();
243 break;
244 case SID_HYPERLINK_SETLINK:
245 if (pItem)
246 InsertHyperlink(*((const SvxHyperlinkItem *)pItem));
247 rReq.Done();
248 break;
249 case SID_INSERT_AVMEDIA:
250 rReq.SetReturnValue(SfxBoolItem(nSlot, InsertMediaDlg( rReq )));
251 break;
252 case SID_INSERT_SOUND:
253 case SID_INSERT_VIDEO:
255 SvxPluginFileDlg aDlg( &GetView().GetViewFrame()->GetWindow(), nSlot );
256 aDlg.SetContext( nSlot == SID_INSERT_SOUND? sfx2::FileDialogHelper::SW_INSERT_SOUND : sfx2::FileDialogHelper::SW_INSERT_VIDEO );
258 if ( ERRCODE_NONE == aDlg.Execute() )
260 // URL ermitteln
261 String aStrURL( aDlg.GetPath() );
262 aStrURL = URIHelper::SmartRel2Abs(
263 INetURLObject(), aStrURL, URIHelper::GetMaybeFileHdl() );
265 INetURLObject* pURL = new INetURLObject();
266 pURL->SetSmartProtocol( INET_PROT_FILE );
268 if ( pURL->SetURL( aStrURL, INetURLObject::WAS_ENCODED ) )
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() )
275 svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
277 // set properties from dialog
278 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
279 if ( xSet.is() )
281 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
282 uno::makeAny( ::rtl::OUString( pURL->GetMainURL( INetURLObject::NO_DECODE ) ) ) );
286 rSh.InsertObject( xObj, 0, TRUE, nSlot);
290 break;
291 case SID_INSERT_OBJECT:
292 case SID_INSERT_PLUGIN:
293 case SID_INSERT_APPLET:
295 SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False );
296 SvGlobalName *pName = NULL;
297 SvGlobalName aName;
298 if ( pNameItem )
300 aName = pNameItem->GetValue();
301 pName = &aName;
304 SFX_REQUEST_ARG( rReq, pClassItem, SfxStringItem, FN_PARAM_1, sal_False );
305 SFX_REQUEST_ARG( rReq, pClassLocationItem, SfxStringItem, FN_PARAM_2, sal_False );
306 SFX_REQUEST_ARG( rReq, pCommandsItem, SfxStringItem, FN_PARAM_3, sal_False );
307 //TODO/LATER: recording currently not working, need code for Commandlist
308 svt::EmbeddedObjectRef xObj;
309 if((SID_INSERT_APPLET == nSlot || SID_INSERT_PLUGIN)
310 && (pClassItem || pClassLocationItem || pCommandsItem))
312 String sClass;
313 String sClassLocation;
314 if(pClassItem)
315 sClass = pClassItem->GetValue();
316 if(pClassLocationItem)
317 sClassLocation = pClassLocationItem->GetValue();
319 SvCommandList aCommandList;
320 if(pCommandsItem)
322 USHORT nTemp;
323 aCommandList.AppendCommands( pCommandsItem->GetValue(), &nTemp );
326 if(SID_INSERT_APPLET == nSlot)
328 SwApplet_Impl aApplImpl( rSh.GetAttrPool(),
329 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
330 String sBaseURL;
331 SfxMedium* pMedium = GetView().GetDocShell()->GetMedium();
332 if(pMedium)
333 sBaseURL = pMedium->GetURLObject().GetMainURL(INetURLObject::NO_DECODE);
335 aApplImpl.CreateApplet(sClass, aEmptyStr, FALSE, sClassLocation, sBaseURL );
336 aApplImpl.FinishApplet();
337 xObj.Assign( aApplImpl.GetApplet(), embed::Aspects::MSOLE_CONTENT );
338 if( aCommandList.Count() )
340 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
341 if ( xSet.is() )
343 uno::Sequence < beans::PropertyValue > aSeq;
344 aCommandList.FillSequence( aSeq );
347 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands"), uno::makeAny( aSeq ) );
349 catch ( uno::Exception& )
355 else
357 comphelper::EmbeddedObjectContainer aCnt;
358 ::rtl::OUString sName;
359 xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), sName ),
360 embed::Aspects::MSOLE_CONTENT );
361 svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
362 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
363 if ( xSet.is() )
367 if ( sClassLocation.Len() )
368 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
369 uno::makeAny(
370 ::rtl::OUString(
371 URIHelper::SmartRel2Abs(
372 INetURLObject(), sClassLocation,
373 URIHelper::GetMaybeFileHdl()) ) ) );
374 uno::Sequence< beans::PropertyValue > aSeq;
375 if ( aCommandList.Count() )
377 aCommandList.FillSequence( aSeq );
378 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands"), uno::makeAny( aSeq ) );
381 catch ( uno::Exception& )
387 if(xObj.is())
388 rSh.InsertOleObject( xObj );
390 else
392 DBG_ASSERT( !pNameItem || nSlot == SID_INSERT_OBJECT, "Superfluous argument!" );
393 rSh.InsertObject( xObj, pName, TRUE, nSlot);
394 rReq.Done();
396 break;
398 case SID_INSERT_FLOATINGFRAME:
400 svt::EmbeddedObjectRef xObj;
401 SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, FN_PARAM_1, sal_False );
402 SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, FN_PARAM_2, sal_False );
403 SFX_REQUEST_ARG( rReq, pMarginItem, SvxSizeItem, FN_PARAM_3, sal_False );
404 SFX_REQUEST_ARG( rReq, pScrollingItem, SfxByteItem, FN_PARAM_4, sal_False );
405 SFX_REQUEST_ARG( rReq, pBorderItem, SfxBoolItem, FN_PARAM_5, sal_False );
407 if(pURLItem) // URL is a _must_
409 comphelper::EmbeddedObjectContainer aCnt;
410 ::rtl::OUString aName;
411 xObj.Assign( aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aName ),
412 embed::Aspects::MSOLE_CONTENT );
413 svt::EmbeddedObjectRef::TryRunningState( xObj.GetObject() );
414 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
415 if ( xSet.is() )
419 ScrollingMode eScroll = ScrollingAuto;
420 if( pScrollingItem && pScrollingItem->GetValue() <= ScrollingAuto )
421 eScroll = (ScrollingMode) pScrollingItem->GetValue();
423 Size aMargin;
424 if ( pMarginItem )
425 aMargin = pMarginItem->GetSize();
427 if ( pURLItem )
428 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameURL"), uno::makeAny( ::rtl::OUString( pURLItem->GetValue() ) ) );
429 if ( pNameItem )
430 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameName"), uno::makeAny( ::rtl::OUString( pNameItem->GetValue() ) ) );
432 if ( eScroll == ScrollingAuto )
433 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll"),
434 uno::makeAny( sal_True ) );
435 else
436 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode"),
437 uno::makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
439 //if ( aFrmDescr.IsFrameBorderSet() )
440 if ( pBorderItem )
441 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder"),
442 uno::makeAny( (sal_Bool) pBorderItem->GetValue() ) );
443 /*else
444 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder"),
445 makeAny( sal_True ) );*/
447 if ( pMarginItem )
449 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth"),
450 uno::makeAny( sal_Int32( aMargin.Width() ) ) );
452 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight"),
453 uno::makeAny( sal_Int32( aMargin.Height() ) ) );
456 catch ( uno::Exception& )
461 rSh.InsertOleObject( xObj );
463 else
465 rSh.InsertObject( xObj, 0, TRUE, nSlot);
466 rReq.Done();
469 break;
470 case SID_INSERT_DIAGRAM:
472 SvtModuleOptions aMOpt;
473 if ( !aMOpt.IsChart() )
474 break;
475 if(!rReq.IsAPI())
477 SfxViewFrame* pVFrame = GetView().GetViewFrame();
478 SwInsertChart( &GetView().GetEditWin(), &pVFrame->GetBindings() );
480 else
482 uno::Reference< chart2::data::XDataProvider > xDataProvider;
483 sal_Bool bFillWithData = sal_True;
484 OUString aRangeString;
485 if (!GetShell().IsTblComplexForChart())
487 SwFrmFmt* pTblFmt = GetShell().GetTableFmt();
488 String aCurrentTblName = pTblFmt->GetName();
489 // String aText( String::CreateFromAscii("<.>") ); // was used for UI
490 // aText.Insert( rWrtShell.GetBoxNms(), 2);
491 // aText.Insert( aCurrentTblName, 1 );
492 aRangeString = aCurrentTblName;
493 aRangeString += OUString::valueOf( sal_Unicode('.') );
494 aRangeString += GetShell().GetBoxNms();
496 // get table data provider
497 xDataProvider.set( GetView().GetDocShell()->getIDocumentChartDataProviderAccess()->GetChartDataProvider() );
499 else
500 bFillWithData = sal_False; // will create chart with only it's default image
502 SwTableFUNC( &rSh, FALSE ).InsertChart( xDataProvider, bFillWithData, aRangeString );
503 rSh.LaunchOLEObj();
505 svt::EmbeddedObjectRef& xObj = rSh.GetOLEObject();
506 if(pItem && xObj.is())
508 Size aSize(((SvxSizeItem*)pItem)->GetSize());
509 aSize = OutputDevice::LogicToLogic
510 ( aSize, MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM ) );
512 if(aSize.Width() > MINLAY&& aSize.Height()> MINLAY)
514 awt::Size aSz;
515 aSz.Width = aSize.Width();
516 aSz.Height = aSize.Height();
517 xObj->setVisualAreaSize( xObj.GetViewAspect(), aSz );
522 break;
524 case FN_INSERT_SMA:
526 // #i34343# Inserting a math object into an autocompletion crashes
527 // the suggestion has to be removed before
528 GetView().GetEditWin().StopQuickHelp();
529 SvGlobalName aGlobalName( SO3_SM_CLASSID );
530 rSh.InsertObject( svt::EmbeddedObjectRef(), &aGlobalName, TRUE, 0 );
532 break;
534 case FN_INSERT_TABLE:
535 InsertTable( rReq );
536 break;
538 case FN_INSERT_FRAME_INTERACT_NOCOL:
539 case FN_INSERT_FRAME_INTERACT:
541 USHORT nCols = 1;
542 BOOL bModifier1 = rReq.GetModifier() == KEY_MOD1;
543 if(pArgs)
545 if(FN_INSERT_FRAME_INTERACT_NOCOL != nSlot &&
546 pArgs->GetItemState(SID_ATTR_COLUMNS, FALSE, &pItem) == SFX_ITEM_SET)
547 nCols = ((SfxUInt16Item *)pItem)->GetValue();
548 if(pArgs->GetItemState(SID_MODIFIER, FALSE, &pItem) == SFX_ITEM_SET)
549 bModifier1 |= KEY_MOD1 == ((SfxUInt16Item *)pItem)->GetValue();
551 if(bModifier1 )
553 SwEditWin& rEdtWin = GetView().GetEditWin();
554 Size aWinSize = rEdtWin.GetSizePixel();
555 Point aStartPos(aWinSize.Width()/2, aWinSize.Height() / 2);
556 aStartPos = rEdtWin.PixelToLogic(aStartPos);
557 aStartPos.X() -= 8 * MM50;
558 aStartPos.Y() -= 4 * MM50;
559 Size aSize(16 * MM50, 8 * MM50);
560 GetShell().LockPaint();
561 GetShell().StartAllAction();
562 SwFlyFrmAttrMgr aMgr( TRUE, GetShellPtr(), FRMMGR_TYPE_TEXT );
563 if(nCols > 1)
565 SwFmtCol aCol;
566 aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
567 aMgr.SetCol( aCol );
569 aMgr.InsertFlyFrm(FLY_AT_CNTNT, aStartPos, aSize);
570 GetShell().EndAllAction();
571 GetShell().UnlockPaint();
573 else
575 GetView().InsFrmMode(nCols);
577 rReq.Ignore();
579 break;
580 case FN_INSERT_FRAME:
582 BOOL bSingleCol = FALSE;
583 if( 0!= dynamic_cast< SwWebDocShell*>( GetView().GetDocShell()) )
585 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
586 USHORT nExport = pHtmlOpt->GetExportMode();
587 if( HTML_CFG_MSIE == nExport ||
588 HTML_CFG_HTML32 == nExport ||
589 HTML_CFG_MSIE_40 == nExport ||
590 HTML_CFG_HTML32 == nExport )
592 bSingleCol = TRUE;
596 // Rahmen neu anlegen
597 SwFlyFrmAttrMgr aMgr( TRUE, GetShellPtr(), FRMMGR_TYPE_TEXT );
598 if(pArgs)
600 Size aSize(aMgr.GetSize());
601 aSize.Width() = GetShell().GetAnyCurRect(RECT_PAGE_PRT).Width();
602 Point aPos = aMgr.GetPos();
603 RndStdIds eAnchor = FLY_AT_CNTNT;
604 if(pArgs->GetItemState(nSlot, FALSE, &pItem) == SFX_ITEM_SET)
605 eAnchor = (RndStdIds)((SfxUInt16Item *)pItem)->GetValue();
606 if(pArgs->GetItemState(FN_PARAM_1, FALSE, &pItem) == SFX_ITEM_SET)
607 aPos = ((SfxPointItem *)pItem)->GetValue();
608 if(pArgs->GetItemState(FN_PARAM_2, FALSE, &pItem) == SFX_ITEM_SET)
609 aSize = ((SvxSizeItem *)pItem)->GetSize();
610 if(pArgs->GetItemState(SID_ATTR_COLUMNS, FALSE, &pItem) == SFX_ITEM_SET)
612 USHORT nCols = ((SfxUInt16Item *)pItem)->GetValue();
613 if( !bSingleCol && 1 < nCols )
615 SwFmtCol aFmtCol;
616 aFmtCol.Init( nCols , (rReq.IsAPI() ? 0
617 : DEF_GUTTER_WIDTH), USHRT_MAX );
618 aMgr.SetCol(aFmtCol);
622 GetShell().LockPaint();
623 GetShell().StartAllAction();
625 aMgr.InsertFlyFrm(eAnchor, aPos, aSize);
627 GetShell().EndAllAction();
628 GetShell().UnlockPaint();
630 else
632 static USHORT __READONLY_DATA aFrmAttrRange[] =
634 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
635 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
636 FN_GET_PRINT_AREA, FN_GET_PRINT_AREA,
637 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
638 FN_SET_FRM_NAME, FN_SET_FRM_NAME,
639 SID_HTML_MODE, SID_HTML_MODE,
643 SfxItemSet aSet(GetPool(), aFrmAttrRange );
644 aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
645 const SwRect &rPg = GetShell().GetAnyCurRect(RECT_PAGE);
646 SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height());
647 aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE));
648 aSet.Put(aFrmSize);
650 const SwRect &rPr = GetShell().GetAnyCurRect(RECT_PAGE_PRT);
651 SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height());
652 aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA));
653 aSet.Put(aPrtSize);
655 aSet.Put(aMgr.GetAttrSet());
656 aSet.SetParent( aMgr.GetAttrSet().GetParent() );
658 // Minimalgroesse in Spalten loeschen
659 SvxBoxInfoItem aBoxInfo((SvxBoxInfoItem &)aSet.Get(SID_ATTR_BORDER_INNER));
660 const SvxBoxItem& rBox = (const SvxBoxItem&)aSet.Get(RES_BOX);
661 aBoxInfo.SetMinDist(FALSE);
662 aBoxInfo.SetDefDist(rBox.GetDistance(BOX_LINE_LEFT));
663 aSet.Put(aBoxInfo);
665 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebDocShell, GetView().GetDocShell()));
666 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< UINT16 >(eMetric)));
667 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
668 DBG_ASSERT(pFact, "Dialogdiet fail!");
669 SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_STD,
670 GetView().GetViewFrame(), &GetView().GetViewFrame()->GetWindow(), aSet, TRUE);
671 DBG_ASSERT(pDlg, "Dialogdiet fail!");
672 if(pDlg->Execute() && pDlg->GetOutputItemSet())
674 GetShell().LockPaint();
675 GetShell().StartAllAction();
676 GetShell().StartUndo(UNDO_INSERT);
678 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
679 aMgr.SetAttrSet(*pOutSet);
681 // beim ClickToEditFeld erst die Selektion loeschen
682 if( GetShell().IsInClickToEdit() )
683 GetShell().DelRight();
685 aMgr.InsertFlyFrm();
687 uno::Reference< frame::XDispatchRecorder > xRecorder =
688 GetView().GetViewFrame()->GetBindings().GetRecorder();
689 if ( xRecorder.is() )
691 //FN_INSERT_FRAME
692 USHORT nAnchor = (USHORT)aMgr.GetAnchor();
693 rReq.AppendItem(SfxUInt16Item(nSlot, nAnchor));
694 rReq.AppendItem(SfxPointItem(FN_PARAM_1, GetShell().GetObjAbsPos()));
695 rReq.AppendItem(SvxSizeItem(FN_PARAM_2, GetShell().GetObjSize()));
696 rReq.Done();
699 GetView().AutoCaption(FRAME_CAP);
702 SwRewriter aRewriter;
704 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_FRAME));
706 GetShell().EndUndo(UNDO_INSERT, &aRewriter);
708 GetShell().EndAllAction();
709 GetShell().UnlockPaint();
712 DELETEZ(pDlg);
714 break;
716 case FN_INSERT_HRULER:
718 String sPath;
719 BOOL bSimpleLine = FALSE;
720 BOOL bRet = FALSE;
721 Window* pParent = GetView().GetWindow();
722 if ( pItem )
724 sPath = ((SfxStringItem*)pItem)->GetValue();
725 SFX_REQUEST_ARG( rReq, pSimple, SfxBoolItem, FN_PARAM_1 , sal_False );
726 if ( pSimple )
727 bSimpleLine = pSimple->GetValue();
729 else
731 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
732 DBG_ASSERT(pFact, "Dialogdiet fail!");
733 AbstractInsertGrfRulerDlg* pDlg = pFact->CreateInsertGrfRulerDlg( DLG_INSERT_RULER,
734 pParent );
735 DBG_ASSERT(pDlg, "Dialogdiet fail!");
736 // MessageBox fuer fehlende Grafiken
737 if(!pDlg->HasImages())
738 InfoBox( pParent, SW_RES(MSG_NO_RULER)).Execute();
739 if(RET_OK == pDlg->Execute())
741 sPath = pDlg->GetGraphicName();
742 bSimpleLine = pDlg->IsSimpleLine();
745 delete pDlg;
746 rReq.AppendItem( SfxStringItem( FN_INSERT_HRULER, sPath ) );
747 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bSimpleLine ) );
750 rSh.StartAllAction();
751 rSh.StartUndo(UNDO_UI_INSERT_RULER);
752 if(bSimpleLine)
754 if(!(rSh.IsSttOfPara() && rSh.IsEndOfPara())) // kein leerer Absatz?
755 rSh.SplitNode( FALSE, FALSE ); // dann Platz schaffen
756 rSh.SplitNode( FALSE, FALSE );
757 rSh.Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE );
758 rSh.SetTxtFmtColl( rSh.GetTxtCollFromPool( RES_POOLCOLL_HTML_HR ));
759 rSh.Right(CRSR_SKIP_CHARS, FALSE, 1, FALSE );
760 bRet = TRUE;
762 else if(sPath.Len())
764 SwFlyFrmAttrMgr aFrmMgr( TRUE, &rSh, FRMMGR_TYPE_GRF );
765 // am FrmMgr muessen die richtigen Parameter eingestellt werden
767 aFrmMgr.SetAnchor(FLY_IN_CNTNT);
769 rSh.SplitNode( FALSE, FALSE );
770 rSh.SplitNode( FALSE, FALSE );
771 rSh.Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE );
772 rSh.SetAttr(SvxAdjustItem(SVX_ADJUST_CENTER,RES_PARATR_ADJUST ));
773 if(GRFILTER_OK == GetView().InsertGraphic(sPath, aEmptyStr, TRUE, 0, 0 ))
774 bRet = TRUE;
775 rSh.EnterStdMode();
776 rSh.Right(CRSR_SKIP_CHARS, FALSE, 1, FALSE );
778 rSh.EndAllAction();
779 rSh.EndUndo(UNDO_UI_INSERT_RULER);
780 rReq.SetReturnValue(SfxBoolItem(nSlot, bRet));
781 rReq.Done();
783 break;
784 case FN_FORMAT_COLUMN :
786 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
787 DBG_ASSERT(pFact, "Dialogdiet fail!");
788 VclAbstractDialog* pColDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_COLUMN);
789 DBG_ASSERT(pColDlg, "Dialogdiet fail!");
790 pColDlg->Execute();
791 delete pColDlg;
793 break;
795 default:
796 ASSERT( !this, "falscher Dispatcher" );
797 return;
801 bool lcl_IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect )
803 rWrtSh.SwapPam();
804 bool bRet = pSect == rWrtSh.GetCurrSection();
805 rWrtSh.SwapPam();
806 return bRet;
810 void SwTextShell::StateInsert( SfxItemSet &rSet )
812 USHORT nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
813 SfxWhichIter aIter( rSet );
814 SwWrtShell &rSh = GetShell();
815 USHORT nWhich = aIter.FirstWhich();
816 SvtModuleOptions aMOpt;
817 SfxObjectCreateMode eCreateMode =
818 GetView().GetDocShell()->GetCreateMode();
820 rSh.Push();
821 const BOOL bCrsrInHidden = rSh.SelectHiddenRange();
822 // --> OD 2009-08-05 #i103839#, #b6855246#
823 // Do not call method <SwCrsrShell::Pop(..)> with 1st parameter = <FALSE>
824 // in order to avoid that the view jumps to the visible cursor.
825 rSh.Pop();
826 // <--
828 while ( nWhich )
830 switch ( nWhich )
832 case SID_INSERT_SOUND:
833 case SID_INSERT_VIDEO:
834 /*!SvxPluginFileDlg::IsAvailable( nWhich ) ||
836 discussed with mba: for performance reasons we skip the IsAvailable call here
838 if ( GetShell().IsSelFrmMode() ||
839 SFX_CREATE_MODE_EMBEDDED == eCreateMode || bCrsrInHidden )
841 rSet.DisableItem( nWhich );
843 break;
845 case SID_INSERT_DIAGRAM:
846 if( !aMOpt.IsChart() || eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden )
848 rSet.DisableItem( nWhich );
850 break;
852 case FN_INSERT_SMA:
853 if( !aMOpt.IsMath() || eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden )
855 rSet.DisableItem( nWhich );
857 break;
859 case SID_INSERT_FLOATINGFRAME:
860 case SID_INSERT_OBJECT:
861 case SID_INSERT_PLUGIN:
862 case SID_INSERT_APPLET:
865 #ifndef SOLAR_JAVA
866 nWhich == SID_INSERT_APPLET ||
867 #endif
868 eCreateMode == SFX_CREATE_MODE_EMBEDDED || bCrsrInHidden )
870 rSet.DisableItem( nWhich );
872 else if( GetShell().IsSelFrmMode())
873 rSet.DisableItem( nWhich );
874 else if(SID_INSERT_FLOATINGFRAME == nWhich && nHtmlMode&HTMLMODE_ON)
876 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get();
877 USHORT nExport = pHtmlOpt->GetExportMode();
878 if(HTML_CFG_MSIE_40 != nExport && HTML_CFG_WRITER != nExport )
879 rSet.DisableItem(nWhich);
882 break;
883 case FN_INSERT_FRAME_INTERACT_NOCOL :
884 case FN_INSERT_FRAME_INTERACT:
886 if ( GetShell().IsSelFrmMode() ||
887 (0 != (nHtmlMode & HTMLMODE_ON) && 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS)) || bCrsrInHidden )
888 rSet.DisableItem(nWhich);
890 break;
891 case SID_HYPERLINK_GETLINK:
893 SfxItemSet aSet(GetPool(), RES_TXTATR_INETFMT, RES_TXTATR_INETFMT);
894 rSh.GetCurAttr( aSet );
896 SvxHyperlinkItem aHLinkItem;
897 const SfxPoolItem* pItem;
898 if(SFX_ITEM_SET == aSet.GetItemState(RES_TXTATR_INETFMT, FALSE, &pItem))
900 const SwFmtINetFmt* pINetFmt = (const SwFmtINetFmt*)pItem;
901 aHLinkItem.SetURL(pINetFmt->GetValue());
902 aHLinkItem.SetTargetFrame(pINetFmt->GetTargetFrame());
903 aHLinkItem.SetIntName(pINetFmt->GetName());
904 const SvxMacro *pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOVER_OBJECT );
905 if( pMacro )
906 aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOVER_OBJECT, *pMacro);
908 pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSECLICK_OBJECT );
909 if( pMacro )
910 aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSECLICK_OBJECT, *pMacro);
912 pMacro = pINetFmt->GetMacro( SFX_EVENT_MOUSEOUT_OBJECT );
913 if( pMacro )
914 aHLinkItem.SetMacro(HYPERDLG_EVENT_MOUSEOUT_OBJECT, *pMacro);
916 // Text des Links besorgen
917 rSh.StartAction();
918 rSh.CreateCrsr();
919 rSh.SwCrsrShell::SelectTxtAttr(RES_TXTATR_INETFMT,TRUE);
920 String sLinkName = rSh.GetSelTxt();
921 aHLinkItem.SetName(sLinkName);
922 aHLinkItem.SetInsertMode(HLINK_FIELD);
923 rSh.DestroyCrsr();
924 rSh.EndAction();
926 else
928 String sReturn = rSh.GetSelTxt();
929 sReturn.Erase(255);
930 sReturn.EraseTrailingChars();
931 aHLinkItem.SetName(sReturn);
934 aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() |
935 ((nHtmlMode & HTMLMODE_ON) != 0 ? HLINK_HTMLMODE : 0)));
936 aHLinkItem.SetMacroEvents ( HYPERDLG_EVENT_MOUSEOVER_OBJECT|
937 HYPERDLG_EVENT_MOUSECLICK_OBJECT | HYPERDLG_EVENT_MOUSEOUT_OBJECT );
939 rSet.Put(aHLinkItem);
941 break;
943 case FN_INSERT_FRAME:
944 if(rSh.IsSelFrmMode())
946 const int nSel = rSh.GetSelectionType();
947 if( ((nsSelectionType::SEL_GRF | nsSelectionType::SEL_OLE ) & nSel ) || bCrsrInHidden )
948 rSet.DisableItem(nWhich);
950 break;
951 case FN_INSERT_HRULER :
952 if(rSh.IsReadOnlyAvailable() && rSh.HasReadonlySel() || bCrsrInHidden )
953 rSet.DisableItem(nWhich);
954 break;
955 case FN_FORMAT_COLUMN :
957 //#i80458# column dialog cannot work if the selection contains different page styles and different sections
958 bool bDisable = true;
959 if( rSh.GetFlyFrmFmt() || rSh.GetSelectedPageDescs() )
960 bDisable = false;
961 if( bDisable )
963 const SwSection* pCurrSection = rSh.GetCurrSection();
964 USHORT nFullSectCnt = rSh.GetFullSelectedSectionCount();
965 if( pCurrSection && ( !rSh.HasSelection() || 0 != nFullSectCnt ))
966 bDisable = false;
967 else if(
968 rSh.HasSelection() && rSh.IsInsRegionAvailable() &&
969 ( !pCurrSection || ( 1 != nFullSectCnt &&
970 lcl_IsMarkInSameSection( rSh, pCurrSection ) )))
971 bDisable = false;
973 if(bDisable)
974 rSet.DisableItem(nWhich);
976 break;
978 nWhich = aIter.NextWhich();
982 /*--------------------------------------------------------------------
983 Beschreibung:
984 --------------------------------------------------------------------*/
986 void SwTextShell::ExecDelete(SfxRequest &rReq)
988 SwWrtShell &rSh = GetShell();
989 switch( rReq.GetSlot() )
991 case FN_DELETE_SENT:
992 if( rSh.IsTableMode() )
994 rSh.DeleteRow();
995 rSh.EnterStdMode();
997 else
998 rSh.DelToEndOfSentence();
999 break;
1000 case FN_DELETE_BACK_SENT:
1001 rSh.DelToStartOfSentence();
1002 break;
1003 case FN_DELETE_WORD:
1004 rSh.DelNxtWord();
1005 break;
1006 case FN_DELETE_BACK_WORD:
1007 rSh.DelPrvWord();
1008 break;
1009 case FN_DELETE_LINE:
1010 rSh.DelToEndOfLine();
1011 break;
1012 case FN_DELETE_BACK_LINE:
1013 rSh.DelToStartOfLine();
1014 break;
1015 case FN_DELETE_PARA:
1016 rSh.DelToEndOfPara();
1017 break;
1018 case FN_DELETE_BACK_PARA:
1019 rSh.DelToStartOfPara();
1020 break;
1021 case FN_DELETE_WHOLE_LINE:
1022 rSh.DelLine();
1023 break;
1024 default:
1025 ASSERT(!this, "falscher Dispatcher");
1026 return;
1028 rReq.Done();
1031 void SwTextShell::ExecTransliteration( SfxRequest & rReq )
1033 using namespace ::com::sun::star::i18n;
1035 sal_uInt32 nMode = 0;
1037 switch( rReq.GetSlot() )
1039 case SID_TRANSLITERATE_UPPER:
1040 nMode = TransliterationModules_LOWERCASE_UPPERCASE;
1041 break;
1042 case SID_TRANSLITERATE_LOWER:
1043 nMode = TransliterationModules_UPPERCASE_LOWERCASE;
1044 break;
1046 case SID_TRANSLITERATE_HALFWIDTH:
1047 nMode = TransliterationModules_FULLWIDTH_HALFWIDTH;
1048 break;
1049 case SID_TRANSLITERATE_FULLWIDTH:
1050 nMode = TransliterationModules_HALFWIDTH_FULLWIDTH;
1051 break;
1053 case SID_TRANSLITERATE_HIRAGANA:
1054 nMode = TransliterationModules_KATAKANA_HIRAGANA;
1055 break;
1056 case SID_TRANSLITERATE_KATAGANA:
1057 nMode = TransliterationModules_HIRAGANA_KATAKANA;
1058 break;
1060 default:
1061 ASSERT(!this, "falscher Dispatcher");
1064 if( nMode )
1065 GetShell().TransliterateText( nMode );
1070 /*--------------------------------------------------------------------
1071 Beschreibung:
1072 --------------------------------------------------------------------*/
1076 SwTextShell::SwTextShell(SwView &_rView) :
1077 SwBaseShell(_rView), pPostItFldMgr( 0 )
1079 SetName(String::CreateFromAscii("Text"));
1080 SetHelpId(SW_TEXTSHELL);
1083 /*--------------------------------------------------------------------
1084 Beschreibung:
1085 --------------------------------------------------------------------*/
1087 SwTextShell::~SwTextShell()
1091 /*--------------------------------------------------------------------
1092 Beschreibung:
1093 --------------------------------------------------------------------*/
1095 void SwTextShell::InsertSymbol( SfxRequest& rReq )
1097 const SfxItemSet *pArgs = rReq.GetArgs();
1098 const SfxPoolItem* pItem = 0;
1099 if( pArgs )
1100 pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem);
1102 String aChars, aFontName;
1103 if ( pItem )
1105 aChars = ((const SfxStringItem*)pItem)->GetValue();
1106 const SfxPoolItem* pFtItem = NULL;
1107 pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem);
1108 const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
1109 if ( pFontItem )
1110 aFontName = pFontItem->GetValue();
1113 SwWrtShell &rSh = GetShell();
1114 SfxItemSet aSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT,
1115 RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
1116 RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT,
1117 0 );
1118 rSh.GetCurAttr( aSet );
1119 USHORT nScript = rSh.GetScriptType();
1121 SvxFontItem aFont( RES_CHRATR_FONT );
1123 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
1124 aSetItem.GetItemSet().Put( aSet, FALSE );
1125 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
1126 if( pI )
1127 aFont = *(SvxFontItem*)pI;
1128 else
1129 aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
1130 RES_CHRATR_FONT,
1131 GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ) ));
1132 if (!aFontName.Len())
1133 aFontName = aFont.GetFamilyName();
1136 Font aNewFont(aFontName, Size(1,1)); // Size nur wg. CTOR
1137 if( !aChars.Len() )
1139 // Eingestellten Font als Default
1140 SfxAllItemSet aAllSet( rSh.GetAttrPool() );
1141 aAllSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) );
1143 SwViewOption aOpt(*GetShell().GetViewOptions());
1144 String sSymbolFont = aOpt.GetSymbolFont();
1145 if( !aFontName.Len() && sSymbolFont.Len() )
1146 aAllSet.Put( SfxStringItem( SID_FONT_NAME, sSymbolFont ) );
1147 else
1148 aAllSet.Put( SfxStringItem( SID_FONT_NAME, aFont.GetFamilyName() ) );
1150 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1151 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(), aAllSet,
1152 GetView().GetViewFrame()->GetFrame()->GetFrameInterface(), RID_SVXDLG_CHARMAP );
1153 if( RET_OK == pDlg->Execute() )
1155 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pCItem, SfxStringItem, SID_CHARMAP, FALSE );
1156 SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, FALSE );
1157 if ( pFontItem )
1159 aNewFont.SetName( pFontItem->GetFamilyName() );
1160 aNewFont.SetStyleName( pFontItem->GetStyleName() );
1161 aNewFont.SetCharSet( pFontItem->GetCharSet() );
1162 aNewFont.SetPitch( pFontItem->GetPitch() );
1165 if ( pCItem )
1167 aChars = pCItem->GetValue();
1168 aOpt.SetSymbolFont(aNewFont.GetName());
1169 SW_MOD()->ApplyUsrPref(aOpt, &GetView());
1173 delete pDlg;
1176 BOOL bFontChanged = FALSE;
1177 if( aChars.Len() )
1179 rSh.StartAllAction();
1181 // Selektierten Inhalt loeschen
1182 SwRewriter aRewriter;
1183 aRewriter.AddRule(UNDO_ARG1, SW_RES(STR_SPECIALCHAR));
1185 rSh.StartUndo( UNDO_INSERT, &aRewriter );
1186 if ( rSh.HasSelection() )
1188 rSh.DelRight();
1189 aSet.ClearItem();
1190 rSh.GetCurAttr( aSet );
1192 SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() );
1193 aSetItem.GetItemSet().Put( aSet, FALSE );
1194 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
1195 if( pI )
1196 aFont = *(SvxFontItem*)pI;
1197 else
1198 aFont = (SvxFontItem&)aSet.Get( GetWhichOfScript(
1199 RES_CHRATR_FONT,
1200 GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ) ));
1203 // Zeichen einfuegen
1204 rSh.Insert( aChars );
1206 // #108876# a font attribute has to be set always due to a guessed script type
1207 if( aNewFont.GetName().Len() )
1209 bFontChanged = TRUE;
1210 SvxFontItem aNewFontItem( aFont );
1211 aNewFontItem.GetFamilyName() = aNewFont.GetName();
1212 aNewFontItem.GetFamily() = aNewFont.GetFamily();
1213 aNewFontItem.GetPitch() = aNewFont.GetPitch();
1214 aNewFontItem.GetCharSet() = aNewFont.GetCharSet();
1216 SfxItemSet aRestoreSet( GetPool(), RES_CHRATR_FONT, RES_CHRATR_FONT,
1217 RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
1218 RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT, 0 );
1220 nScript = pBreakIt->GetAllScriptsOfText( aChars );
1221 if( SCRIPTTYPE_LATIN & nScript )
1223 aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT, TRUE ) );
1224 aSet.Put( aNewFontItem, RES_CHRATR_FONT);
1226 if( SCRIPTTYPE_ASIAN & nScript )
1228 aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT, TRUE ) );
1229 aSet.Put( aNewFontItem, RES_CHRATR_CJK_FONT );
1231 if( SCRIPTTYPE_COMPLEX & nScript )
1233 aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT, TRUE ) );
1234 aSet.Put( aNewFontItem, RES_CHRATR_CTL_FONT );
1237 rSh.SetMark();
1238 rSh.ExtendSelection( FALSE, aChars.Len() );
1239 rSh.SetAttr( aSet, nsSetAttrMode::SETATTR_DONTEXPAND | nsSetAttrMode::SETATTR_NOFORMATATTR );
1240 if( !rSh.IsCrsrPtAtEnd() )
1241 rSh.SwapPam();
1243 rSh.ClearMark();
1245 // --> FME 2007-07-09 #i75891#
1246 // SETATTR_DONTEXPAND does not work if there are already hard attributes.
1247 // Therefore we have to restore the font attributes.
1248 rSh.SetMark();
1249 rSh.SetAttr( aRestoreSet );
1250 rSh.ClearMark();
1251 // <--
1253 rSh.UpdateAttr();
1254 aFont = aNewFontItem;
1257 rSh.EndAllAction();
1258 rSh.EndUndo( UNDO_INSERT );
1260 if ( aChars.Len() )
1262 rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) );
1263 rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetName() ) );
1264 rReq.Done();