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