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