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