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