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