1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 #include <com/sun/star/util/SearchOptions.hpp> 32 #include <com/sun/star/util/SearchFlags.hpp> 33 #include <com/sun/star/i18n/TransliterationModules.hpp> 34 #include <svtools/filter.hxx> 35 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> 36 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> 37 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> 38 39 #define _SVSTDARR_STRINGSSORTDTOR 40 #include <svl/svstdarr.hxx> 41 #include <svl/aeitem.hxx> 42 43 #include <SwStyleNameMapper.hxx> 44 #include <docary.hxx> 45 #include <hintids.hxx> 46 #include <SwRewriter.hxx> 47 #include <numrule.hxx> 48 #include <swundo.hxx> 49 #include <caption.hxx> 50 #include <svl/PasswordHelper.hxx> 51 #include <svl/urihelper.hxx> 52 #include <sfx2/passwd.hxx> 53 #include <sfx2/sfxdlg.hxx> 54 #include <sfx2/filedlghelper.hxx> 55 #include <sfx2/sfxhelp.hxx> 56 #include <editeng/langitem.hxx> 57 #include <svx/viewlayoutitem.hxx> 58 #include <svx/zoomslideritem.hxx> 59 #include <svtools/xwindowitem.hxx> 60 #include <svx/htmlmode.hxx> 61 #include <vcl/svapp.hxx> 62 #include <vcl/wrkwin.hxx> 63 #include <sfx2/app.hxx> 64 #include <sfx2/request.hxx> 65 #include <sfx2/bindings.hxx> 66 #include <editeng/lrspitem.hxx> 67 #include <svtools/txtcmp.hxx> 68 #include "editeng/unolingu.hxx" 69 #include <vcl/msgbox.hxx> 70 #include <editeng/tstpitem.hxx> 71 #include <sfx2/event.hxx> 72 #include <sfx2/docfile.hxx> 73 #include <sfx2/docfilt.hxx> 74 #include <sfx2/fcontnr.hxx> 75 #include <editeng/sizeitem.hxx> 76 #include <sfx2/dispatch.hxx> 77 #include <svl/whiter.hxx> 78 #include <svl/ptitem.hxx> 79 #include <sfx2/linkmgr.hxx> 80 #include <tools/errinf.hxx> 81 #include <tools/urlobj.hxx> 82 #include <svx/svdview.hxx> 83 #include <swtypes.hxx> 84 #include <swwait.hxx> 85 #include <redlndlg.hxx> 86 #include <view.hxx> 87 #include <uivwimp.hxx> 88 #include <docsh.hxx> 89 #include <doc.hxx> 90 #include <IDocumentUndoRedo.hxx> 91 #include <wrtsh.hxx> 92 #include <viewopt.hxx> 93 #include <basesh.hxx> 94 #include <swmodule.hxx> 95 #include <uitool.hxx> 96 #include <shellio.hxx> 97 #include <fmtinfmt.hxx> 98 #include <mdiexp.hxx> 99 #include <drawbase.hxx> 100 #include <frmmgr.hxx> 101 #include <pagedesc.hxx> 102 #include <section.hxx> 103 #include <usrpref.hxx> 104 #include <IMark.hxx> 105 #include <navipi.hxx> 106 #include <tox.hxx> 107 #include <workctrl.hxx> 108 #include <scroll.hxx> 109 #include <edtwin.hxx> 110 #include <wview.hxx> 111 #include <textsh.hxx> 112 #include <tabsh.hxx> 113 #include <listsh.hxx> 114 #include <cmdid.h> 115 #include <comcore.hrc> 116 #include <poolfmt.hrc> 117 #include <statstr.hrc> 118 #include <swerror.h> 119 #include <globals.hrc> 120 #include <shells.hrc> 121 #include <web.hrc> 122 #include <view.hrc> 123 #include <app.hrc> 124 #include <fmtclds.hxx> 125 #include <helpid.h> 126 #include <svtools/templdlg.hxx> 127 #include <dbconfig.hxx> 128 #include <dbmgr.hxx> 129 130 #include <PostItMgr.hxx> 131 132 #include <ndtxt.hxx> //#outline level,added by zhaojianwei 133 134 #include <comphelper/processfactory.hxx> 135 136 #include <svx/svxdlg.hxx> 137 #include <svx/dialogs.hrc> 138 #include "swabstdlg.hxx" 139 #include "globals.hrc" 140 #include <envelp.hrc> 141 #include <fmthdft.hxx> 142 #include <svx/ofaitem.hxx> 143 #include <unomid.h> 144 145 const char __FAR_DATA sStatusDelim[] = " : "; 146 const char __FAR_DATA sStatusComma[] = " , ";//#outlinelevel, define a Variable for "," add by zhaojianwei 147 148 using ::rtl::OUString; 149 using namespace sfx2; 150 using namespace ::com::sun::star; 151 using namespace ::com::sun::star::i18n; 152 using namespace ::com::sun::star::util; 153 using namespace ::com::sun::star::uno; 154 using namespace ::com::sun::star::lang; 155 using namespace ::com::sun::star::scanner; 156 using namespace ::com::sun::star::i18n; 157 using namespace ::com::sun::star::beans; 158 using namespace ::com::sun::star::container; 159 using namespace ::com::sun::star::ui::dialogs; 160 161 162 static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhichId ) 163 { 164 if (nWhichId == RES_CHRATR_LANGUAGE || 165 nWhichId == RES_CHRATR_CJK_LANGUAGE || 166 nWhichId == RES_CHRATR_CTL_LANGUAGE) 167 { 168 rWrtSh.StartAction(); 169 rWrtSh.LockView( sal_True ); 170 rWrtSh.Push(); 171 172 // prepare to apply new language to all text in document 173 rWrtSh.SelAll(); 174 rWrtSh.ExtendedSelectAll(); 175 176 // set language attribute to default for all text 177 SvUShortsSort aAttribs; 178 aAttribs.Insert( nWhichId ); 179 rWrtSh.ResetAttr( &aAttribs ); 180 181 rWrtSh.Pop( sal_False ); 182 rWrtSh.LockView( sal_False ); 183 rWrtSh.EndAction(); 184 } 185 } 186 187 /*--------------------------------------------------------------------------- 188 Beschreibung: String fuer die Seitenanzeige in der Statusbar basteln. 189 ----------------------------------------------------------------------------*/ 190 191 String SwView::GetPageStr( sal_uInt16 nPg, sal_uInt16 nLogPg, 192 const String& rDisplay ) 193 { 194 String aStr( aPageStr ); 195 if( rDisplay.Len() ) 196 aStr += rDisplay; 197 else 198 aStr += String::CreateFromInt32(nLogPg); 199 200 if( nLogPg && nLogPg != nPg ) 201 { 202 aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" ")); 203 aStr += String::CreateFromInt32(nPg); 204 } 205 aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / ")); 206 aStr += String::CreateFromInt32( GetWrtShell().GetPageCnt() ); 207 208 return aStr; 209 } 210 211 212 int SwView::InsertGraphic( const String &rPath, const String &rFilter, 213 sal_Bool bLink, GraphicFilter *pFlt, 214 Graphic* pPreviewGrf, sal_Bool bRule ) 215 { 216 SwWait aWait( *GetDocShell(), sal_True ); 217 218 Graphic aGrf; 219 int nRes = GRFILTER_OK; 220 if ( pPreviewGrf ) 221 aGrf = *pPreviewGrf; 222 else 223 { 224 if( !pFlt ) 225 pFlt = GraphicFilter::GetGraphicFilter(); 226 nRes = GraphicFilter::LoadGraphic( rPath, rFilter, aGrf, pFlt /*, nFilter*/ ); 227 } 228 229 if( GRFILTER_OK == nRes ) 230 { 231 SwFlyFrmAttrMgr aFrmMgr( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF ); 232 233 SwWrtShell &rSh = GetWrtShell(); 234 rSh.StartAction(); 235 if( bLink ) 236 { 237 SwDocShell* pDocSh = GetDocShell(); 238 INetURLObject aTemp( 239 pDocSh->HasName() ? 240 pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) : 241 rtl::OUString()); 242 243 String sURL = URIHelper::SmartRel2Abs( 244 aTemp, rPath, URIHelper::GetMaybeFileHdl() ); 245 246 rSh.Insert( sURL, 247 rFilter, aGrf, &aFrmMgr, bRule ); 248 } 249 else 250 rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr ); 251 // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann 252 rSh.EndAction(); 253 } 254 return nRes; 255 } 256 257 258 sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq ) 259 { 260 #ifndef ENABLE_PROP_WITHOUTLINK 261 #define ENABLE_PROP_WITHOUTLINK 0x08 262 #endif 263 264 sal_Bool bReturn = sal_False; 265 SwDocShell* pDocShell = GetDocShell(); 266 sal_uInt16 nHtmlMode = ::GetHtmlMode(pDocShell); 267 // im HTML-Mode nur verknuepft einfuegen 268 FileDialogHelper* pFileDlg = new FileDialogHelper( SFXWB_GRAPHIC | SFXWB_SHOWSTYLES ); 269 pFileDlg->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC )); 270 pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC ); 271 uno::Reference < XFilePicker > xFP = pFileDlg->GetFilePicker(); 272 uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY); 273 if(nHtmlMode & HTMLMODE_ON) 274 { 275 sal_Bool bTrue = sal_True; 276 Any aVal(&bTrue, ::getBooleanCppuType()); 277 xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aVal); 278 xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False); 279 } 280 281 SvStringsSortDtor aFormats; 282 SwDoc* pDoc = pDocShell->GetDoc(); 283 const sal_uInt16 nArrLen = pDoc->GetFrmFmts()->Count(); 284 sal_uInt16 i; 285 for( i = 0; i < nArrLen; i++ ) 286 { 287 SwFrmFmt* pFmt = (*pDoc->GetFrmFmts())[ i ]; 288 if(pFmt->IsDefault() || pFmt->IsAuto()) 289 continue; 290 String *pFormat = new String(pFmt->GetName()); 291 aFormats.Insert(pFormat); 292 } 293 294 // pool formats 295 // 296 const SvStringsDtor& rFrmPoolArr = SwStyleNameMapper::GetFrmFmtUINameArray(); 297 for( i = 0; i < rFrmPoolArr.Count(); i++ ) 298 { 299 String *pFormat = new String(*rFrmPoolArr[i]); 300 if (!aFormats.Insert(pFormat)) 301 delete pFormat; 302 } 303 304 Sequence<OUString> aListBoxEntries(aFormats.Count()); 305 OUString* pEntries = aListBoxEntries.getArray(); 306 sal_Int16 nSelect = 0; 307 String sGraphicFormat = SW_RESSTR(STR_POOLFRM_GRAPHIC); 308 for(i = 0; i < aFormats.Count(); ++i) 309 { 310 pEntries[i] = *aFormats[i]; 311 if(pEntries[i].equals(sGraphicFormat)) 312 nSelect = i; 313 } 314 try 315 { 316 Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries)); 317 318 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, 319 ListboxControlActions::ADD_ITEMS , aTemplates ); 320 321 Any aSelectPos(&nSelect, ::getCppuType(&nSelect)); 322 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, 323 ListboxControlActions::SET_SELECT_ITEM, aSelectPos ); 324 } 325 catch(Exception& ) 326 { 327 DBG_ERROR("control acces failed"); 328 } 329 330 SFX_REQUEST_ARG( rReq, pName, SfxStringItem, SID_INSERT_GRAPHIC , sal_False ); 331 sal_Bool bShowError = !pName; 332 if( pName || ERRCODE_NONE == pFileDlg->Execute() ) 333 { 334 335 String aFileName, aFilterName; 336 if ( pName ) 337 { 338 aFileName = pName->GetValue(); 339 SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, FN_PARAM_FILTER , sal_False ); 340 if ( pFilter ) 341 aFilterName = pFilter->GetValue(); 342 } 343 else 344 { 345 aFileName = pFileDlg->GetPath(); 346 aFilterName = pFileDlg->GetCurrentFilter(); 347 rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) ); 348 rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) ); 349 350 sal_Bool bAsLink = sal_False; 351 if(nHtmlMode & HTMLMODE_ON) 352 bAsLink = sal_True; 353 else 354 { 355 try 356 { 357 Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0); 358 DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found"); 359 bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True; 360 Any aTemplateValue = xCtrlAcc->getValue( 361 ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, 362 ListboxControlActions::GET_SELECTED_ITEM ); 363 OUString sTmpl; 364 aTemplateValue >>= sTmpl; 365 rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) ); 366 } 367 catch(Exception& ) 368 { 369 DBG_ERROR("control acces failed"); 370 } 371 } 372 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) ); 373 } 374 375 SFX_REQUEST_ARG( rReq, pAsLink, SfxBoolItem, FN_PARAM_1 , sal_False ); 376 SFX_REQUEST_ARG( rReq, pStyle, SfxStringItem, FN_PARAM_2 , sal_False ); 377 378 sal_Bool bAsLink = sal_False; 379 if( nHtmlMode & HTMLMODE_ON ) 380 bAsLink = sal_True; 381 else 382 { 383 if ( rReq.GetArgs() ) 384 { 385 if ( pAsLink ) 386 bAsLink = pAsLink->GetValue(); 387 if ( pStyle && pStyle->GetValue().Len() ) 388 sGraphicFormat = pStyle->GetValue(); 389 } 390 else 391 { 392 Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0); 393 DBG_ASSERT(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found"); 394 bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True; 395 Any aTemplateValue = xCtrlAcc->getValue( 396 ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, 397 ListboxControlActions::GET_SELECTED_ITEM ); 398 OUString sTmpl; 399 aTemplateValue >>= sTmpl; 400 if( sTmpl.getLength() ) 401 sGraphicFormat = sTmpl; 402 rReq.AppendItem( SfxStringItem( FN_PARAM_2, sGraphicFormat ) ); 403 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) ); 404 } 405 } 406 407 SwWrtShell& rSh = GetWrtShell(); 408 rSh.LockPaint(); 409 rSh.StartAction(); 410 411 /// #111827# 412 SwRewriter aRewriter; 413 aRewriter.AddRule(UNDO_ARG1, String(SW_RES(STR_GRAPHIC_DEFNAME))); 414 415 rSh.StartUndo(UNDO_INSERT, &aRewriter); 416 417 int nError = InsertGraphic( aFileName, aFilterName, bAsLink, GraphicFilter::GetGraphicFilter() ); 418 419 // Format ist ungleich Current Filter, jetzt mit auto. detection 420 if( nError == GRFILTER_FORMATERROR ) 421 nError = InsertGraphic( aFileName, aEmptyStr, bAsLink, GraphicFilter::GetGraphicFilter() ); 422 if ( rSh.IsFrmSelected() ) 423 { 424 SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat ); 425 if(!pFmt) 426 pFmt = pDoc->MakeFrmFmt(sGraphicFormat, 427 pDocShell->GetDoc()->GetDfltFrmFmt(), 428 sal_True, sal_False); 429 rSh.SetFrmFmt( pFmt ); 430 } 431 432 RESOURCE_TYPE nResId = 0; 433 switch( nError ) 434 { 435 case GRFILTER_OPENERROR: 436 nResId = STR_GRFILTER_OPENERROR; 437 break; 438 case GRFILTER_IOERROR: 439 nResId = STR_GRFILTER_IOERROR; 440 break; 441 case GRFILTER_FORMATERROR: 442 nResId = STR_GRFILTER_FORMATERROR; 443 break; 444 case GRFILTER_VERSIONERROR: 445 nResId = STR_GRFILTER_VERSIONERROR; 446 break; 447 case GRFILTER_FILTERERROR: 448 nResId = STR_GRFILTER_FILTERERROR; 449 break; 450 case GRFILTER_TOOBIG: 451 nResId = STR_GRFILTER_TOOBIG; 452 break; 453 } 454 455 rSh.EndAction(); 456 rSh.UnlockPaint(); 457 if( nResId ) 458 { 459 if( bShowError ) 460 { 461 InfoBox aInfoBox( GetWindow(), SW_RESSTR( nResId )); 462 aInfoBox.Execute(); 463 } 464 rReq.Ignore(); 465 } 466 else 467 { 468 // set the specific graphic attrbutes to the graphic 469 bReturn = sal_True; 470 AutoCaption( GRAPHIC_CAP ); 471 rReq.Done(); 472 } 473 474 rSh.EndUndo(); // due to possible change of Shell 475 } 476 477 delete pFileDlg; 478 479 return bReturn; 480 } 481 482 483 void __EXPORT SwView::Execute(SfxRequest &rReq) 484 { 485 sal_uInt16 nSlot = rReq.GetSlot(); 486 const SfxItemSet* pArgs = rReq.GetArgs(); 487 const SfxPoolItem* pItem; 488 sal_Bool bIgnore = sal_False; 489 switch( nSlot ) 490 { 491 case SID_CREATE_SW_DRAWVIEW: 492 // --> OD 2005-08-08 #i52858# - method name changed 493 pWrtShell->getIDocumentDrawModelAccess()->GetOrCreateDrawModel(); 494 // <-- 495 break; 496 497 case FN_LINE_NUMBERING_DLG: 498 { 499 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 500 DBG_ASSERT(pFact, "Dialogdiet fail!"); 501 VclAbstractDialog* pDlg = pFact->CreateVclSwViewDialog( DLG_LINE_NUMBERING, *this); 502 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 503 pDlg->Execute(); 504 delete pDlg; 505 break; 506 } 507 case FN_EDIT_LINK_DLG: 508 EditLinkDlg(); 509 break; 510 case FN_REFRESH_VIEW: 511 GetEditWin().Invalidate(); 512 break; 513 case FN_PAGEUP: 514 case FN_PAGEUP_SEL: 515 case FN_PAGEDOWN: 516 case FN_PAGEDOWN_SEL: 517 { 518 Rectangle aVis( GetVisArea() ); 519 SwEditWin& rTmpWin = GetEditWin(); 520 if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot ) 521 PageUpCrsr(FN_PAGEUP_SEL == nSlot); 522 else 523 PageDownCrsr(FN_PAGEDOWN_SEL == nSlot); 524 525 rReq.SetReturnValue(SfxBoolItem(nSlot, 526 aVis != GetVisArea())); 527 //#i42732# - notify the edit window that from now on we do not use the input language 528 rTmpWin.SetUseInputLanguage( sal_False ); 529 } 530 break; 531 case FN_REDLINE_ON: 532 { 533 if( pArgs && 534 SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem )) 535 { 536 IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess(); 537 Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword(); 538 if( aPasswd.getLength() ) 539 { 540 DBG_ASSERT( !((const SfxBoolItem*)pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" ); 541 // xmlsec05: new password dialog 542 Window* pParent; 543 const SfxPoolItem* pParentItem; 544 if( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, sal_False, &pParentItem ) ) 545 pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr(); 546 else 547 pParent = &GetViewFrame()->GetWindow(); 548 SfxPasswordDialog aPasswdDlg( pParent ); 549 aPasswdDlg.SetMinLen( 1 ); 550 //#i69751# the result of Execute() can be ignored 551 aPasswdDlg.Execute(); 552 String sNewPasswd( aPasswdDlg.GetPassword() ); 553 Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword(); 554 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); 555 if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd)) 556 pIDRA->SetRedlinePassword(Sequence <sal_Int8> ()); 557 else 558 { // xmlsec05: message box for wrong password 559 break; 560 } 561 } 562 563 sal_uInt16 nOn = ((const SfxBoolItem*)pItem)->GetValue() ? nsRedlineMode_t::REDLINE_ON : 0; 564 sal_uInt16 nMode = pWrtShell->GetRedlineMode(); 565 pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); 566 } 567 } 568 break; 569 case FN_REDLINE_PROTECT : 570 { 571 IDocumentRedlineAccess* pIDRA = pWrtShell->getIDocumentRedlineAccess(); 572 Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword(); 573 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem ) 574 && ((SfxBoolItem*)pItem)->GetValue() == ( aPasswd.getLength() != 0 ) ) 575 break; 576 577 // xmlsec05: new password dialog 578 // message box for wrong password 579 Window* pParent; 580 const SfxPoolItem* pParentItem; 581 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, sal_False, &pParentItem ) ) 582 pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr(); 583 else 584 pParent = &GetViewFrame()->GetWindow(); 585 SfxPasswordDialog aPasswdDlg( pParent ); 586 aPasswdDlg.SetMinLen( 1 ); 587 if(!aPasswd.getLength()) 588 aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM); 589 if (aPasswdDlg.Execute()) 590 { 591 sal_uInt16 nOn = nsRedlineMode_t::REDLINE_ON; 592 String sNewPasswd( aPasswdDlg.GetPassword() ); 593 Sequence <sal_Int8> aNewPasswd = 594 pIDRA->GetRedlinePassword(); 595 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); 596 if(!aPasswd.getLength()) 597 { 598 pIDRA->SetRedlinePassword(aNewPasswd); 599 } 600 else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd)) 601 { 602 pIDRA->SetRedlinePassword(Sequence <sal_Int8> ()); 603 nOn = 0; 604 } 605 sal_uInt16 nMode = pIDRA->GetRedlineMode(); 606 pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn); 607 rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, ((nMode&nsRedlineMode_t::REDLINE_ON)==0) ) ); 608 } 609 else 610 bIgnore = sal_True; 611 } 612 break; 613 case FN_REDLINE_SHOW: 614 615 if( pArgs && 616 SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem)) 617 { 618 sal_uInt16 nMode = ( ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) 619 & pWrtShell->GetRedlineMode() ) | nsRedlineMode_t::REDLINE_SHOW_INSERT; 620 if( ((const SfxBoolItem*)pItem)->GetValue() ) 621 nMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; 622 623 pWrtShell->SetRedlineModeAndCheckInsMode( nMode ); 624 } 625 break; 626 case FN_MAILMERGE_SENDMAIL_CHILDWINDOW: 627 case FN_REDLINE_ACCEPT: 628 GetViewFrame()->ToggleChildWindow(nSlot); 629 break; 630 case FN_REDLINE_ACCEPT_DIRECT: 631 case FN_REDLINE_REJECT_DIRECT: 632 { 633 SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE ); 634 Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True ); 635 if( pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) ) 636 { 637 sal_uInt16 nCount = pWrtShell->GetRedlineCount(); 638 for( sal_uInt16 nRedline = 0; nRedline < nCount; ++nRedline ) 639 { 640 const SwRedline& rRedline = pWrtShell->GetRedline( nRedline ); 641 if( *aCntntAtPos.aFnd.pRedl == rRedline ) 642 { 643 if( FN_REDLINE_ACCEPT_DIRECT == nSlot ) 644 pWrtShell->AcceptRedline( nRedline ); 645 else 646 pWrtShell->RejectRedline( nRedline ); 647 break; 648 } 649 } 650 } 651 } 652 break; 653 case SID_DOCUMENT_COMPARE: 654 case SID_DOCUMENT_MERGE: 655 { 656 String sFileName, sFilterName; 657 sal_Int16 nVersion = 0; 658 bool bHasFileName = false; 659 pViewImpl->SetParam( 0 ); 660 661 if( pArgs ) 662 { 663 if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILE_NAME, sal_False, &pItem )) 664 sFileName = ((const SfxStringItem*)pItem)->GetValue(); 665 bHasFileName = ( sFileName.Len() > 0 ); 666 667 if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILTER_NAME, sal_False, &pItem )) 668 sFilterName = ((const SfxStringItem*)pItem)->GetValue(); 669 670 if( SFX_ITEM_SET == pArgs->GetItemState( SID_VERSION, sal_False, &pItem )) 671 { 672 nVersion = ((const SfxInt16Item *)pItem)->GetValue(); 673 pViewImpl->SetParam( nVersion ); 674 } 675 } 676 677 pViewImpl->InitRequest( rReq ); 678 long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion ); 679 680 if ( bHasFileName ) 681 { 682 rReq.SetReturnValue( SfxInt32Item( nSlot, nFound )); 683 684 if (nFound > 0) // Redline-Browser anzeigen 685 { 686 SfxViewFrame* pVFrame = GetViewFrame(); 687 pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT); 688 689 // RedlineDlg neu initialisieren 690 sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId(); 691 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*) 692 pVFrame->GetChildWindow(nId); 693 if (pRed) 694 pRed->ReInitDlg(GetDocShell()); 695 } 696 } 697 else 698 bIgnore = sal_True; 699 } 700 break; 701 case FN_SYNC_LABELS: 702 case FN_MAILMERGE_CHILDWINDOW: 703 GetViewFrame()->ShowChildWindow(nSlot, sal_True); 704 break; 705 case FN_ESCAPE: 706 { 707 if ( pWrtShell->HasDrawView() && pWrtShell->GetDrawView()->IsDragObj() ) 708 { 709 pWrtShell->BreakDrag(); 710 pWrtShell->EnterSelFrmMode(); 711 } 712 else if ( pWrtShell->IsDrawCreate() ) 713 { 714 GetDrawFuncPtr()->BreakCreate(); 715 AttrChangedNotify(pWrtShell); // ggf Shellwechsel... 716 } 717 else if ( pWrtShell->HasSelection() || IsDrawMode() ) 718 { 719 SdrView *pSdrView = pWrtShell->HasDrawView() ? pWrtShell->GetDrawView() : 0; 720 if(pSdrView && pSdrView->AreObjectsMarked() && 721 pSdrView->GetHdlList().GetFocusHdl()) 722 { 723 ((SdrHdlList&)pSdrView->GetHdlList()).ResetFocusHdl(); 724 } 725 else 726 { 727 if(pSdrView) 728 { 729 LeaveDrawCreate(); 730 Point aPt(LONG_MIN, LONG_MIN); 731 //go out of the frame 732 pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME); 733 SfxBindings& rBind = GetViewFrame()->GetBindings(); 734 rBind.Invalidate( SID_ATTR_SIZE ); 735 } 736 pWrtShell->EnterStdMode(); 737 AttrChangedNotify(pWrtShell); // ggf Shellwechsel... 738 } 739 } 740 else if ( GetEditWin().GetApplyTemplate() ) 741 { 742 GetEditWin().SetApplyTemplate(SwApplyTemplate()); 743 } 744 else if( ((SfxObjectShell*)GetDocShell())->IsInPlaceActive() ) 745 { 746 Escape(); 747 } 748 else if ( GetEditWin().IsChainMode() ) 749 { 750 GetEditWin().SetChainMode( sal_False ); 751 } 752 else if( pWrtShell->GetFlyFrmFmt() ) 753 { 754 const SwFrmFmt* pFmt = pWrtShell->GetFlyFrmFmt(); 755 if(pWrtShell->GotoFly( pFmt->GetName(), FLYCNTTYPE_FRM )) 756 { 757 pWrtShell->HideCrsr(); 758 pWrtShell->EnterSelFrmMode(); 759 } 760 } 761 else 762 { 763 SfxBoolItem aItem( SID_WIN_FULLSCREEN, sal_False ); 764 GetViewFrame()->GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SFX_CALLMODE_RECORD, &aItem, 0L ); 765 bIgnore = sal_True; 766 } 767 } 768 break; 769 case SID_ATTR_BORDER_INNER: 770 case SID_ATTR_BORDER_OUTER: 771 case SID_ATTR_BORDER_SHADOW: 772 if(pArgs) 773 pWrtShell->SetAttr(*pArgs); 774 break; 775 776 case SID_ATTR_PAGE: 777 case SID_ATTR_PAGE_SIZE: 778 case SID_ATTR_PAGE_MAXSIZE: 779 case SID_ATTR_PAGE_PAPERBIN: 780 case SID_ATTR_PAGE_EXT1: 781 case FN_PARAM_FTN_INFO: 782 { 783 if(pArgs) 784 { 785 const sal_uInt16 nCurIdx = pWrtShell->GetCurPageDesc(); 786 SwPageDesc aPageDesc( pWrtShell->GetPageDesc( nCurIdx ) ); 787 ::ItemSetToPageDesc( *pArgs, aPageDesc ); 788 // Den Descriptor der Core veraendern. 789 pWrtShell->ChgPageDesc( nCurIdx, aPageDesc ); 790 } 791 } 792 break; 793 case FN_NAVIGATION_PI_GOTO_PAGE: 794 { 795 SfxViewFrame* pVFrame = GetViewFrame(); 796 SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR ); 797 if(!pCh) 798 { 799 pVFrame->ToggleChildWindow( SID_NAVIGATOR ); 800 pCh = pVFrame->GetChildWindow( SID_NAVIGATOR ); 801 802 } 803 ((SwNavigationPI*) pCh->GetContextWindow(SW_MOD()))->GotoPage(); 804 } 805 break; 806 case FN_EDIT_CURRENT_TOX: 807 { 808 GetViewFrame()->GetDispatcher()->Execute( 809 FN_INSERT_MULTI_TOX, SFX_CALLMODE_ASYNCHRON); 810 } 811 break; 812 case FN_UPDATE_CUR_TOX: 813 { 814 const SwTOXBase* pBase = pWrtShell->GetCurTOX(); 815 if(pBase) 816 { 817 pWrtShell->StartAction(); 818 if(TOX_INDEX == pBase->GetType()) 819 pWrtShell->ApplyAutoMark(); 820 pWrtShell->UpdateTableOf( *pBase ); 821 pWrtShell->EndAction(); 822 } 823 } 824 break; 825 case FN_UPDATE_TOX: 826 { 827 pWrtShell->StartAction(); 828 pWrtShell->EnterStdMode(); 829 sal_Bool bOldCrsrInReadOnly = pWrtShell->IsReadOnlyAvailable(); 830 pWrtShell->SetReadOnlyAvailable( sal_True ); 831 832 for( sal_uInt16 i = 0; i < 2; ++i ) 833 { 834 sal_uInt16 nCount = pWrtShell->GetTOXCount(); 835 if( 1 == nCount ) 836 ++i; 837 838 while( pWrtShell->GotoPrevTOXBase() ) 839 ; // aufs erste Verzeichnis springen 840 841 // falls wir nicht mehr in einem stehen, dann zum naechsten 842 // springen. 843 const SwTOXBase* pBase = pWrtShell->GetCurTOX(); 844 if( !pBase ) 845 { 846 pWrtShell->GotoNextTOXBase(); 847 pBase = pWrtShell->GetCurTOX(); 848 } 849 850 sal_Bool bAutoMarkApplied = sal_False; 851 while( pBase ) 852 { 853 if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied) 854 { 855 pWrtShell->ApplyAutoMark(); 856 bAutoMarkApplied = sal_True; 857 } 858 // JP 15.07.96: das pBase wird nur fuer die Schnittstelle 859 // benoetigt. Muss mal umgetstellt werden!!! 860 pWrtShell->UpdateTableOf( *pBase ); 861 862 if( pWrtShell->GotoNextTOXBase() ) 863 pBase = pWrtShell->GetCurTOX(); 864 else 865 pBase = 0; 866 } 867 } 868 pWrtShell->SetReadOnlyAvailable( bOldCrsrInReadOnly ); 869 pWrtShell->EndAction(); 870 } 871 break; 872 case SID_ATTR_BRUSH: 873 { 874 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_BACKGROUND, sal_False, &pItem)) 875 { 876 const sal_uInt16 nCurIdx = pWrtShell->GetCurPageDesc(); 877 SwPageDesc aDesc( pWrtShell->GetPageDesc( nCurIdx )); 878 SwFrmFmt& rMaster = aDesc.GetMaster(); 879 rMaster.SetFmtAttr(*pItem); 880 pWrtShell->ChgPageDesc( nCurIdx, aDesc); 881 } 882 } 883 break; 884 case SID_CLEARHISTORY: 885 { 886 pWrtShell->DelAllUndoObj(); 887 } 888 break; 889 case SID_UNDO: 890 { 891 pShell->ExecuteSlot(rReq); 892 } 893 break; 894 case FN_INSERT_CTRL: 895 case FN_INSERT_OBJ_CTRL: 896 { 897 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem)) 898 { 899 sal_uInt16 nValue = ((SfxUInt16Item*)pItem)->GetValue(); 900 switch ( nSlot ) 901 { 902 case FN_INSERT_CTRL: 903 { 904 sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this); 905 if(bWeb) 906 SwView::nWebInsertCtrlState = nValue; 907 else 908 SwView::nInsertCtrlState = nValue; 909 } 910 break; 911 case FN_INSERT_OBJ_CTRL: SwView::nInsertObjectCtrlState = nValue ;break; 912 } 913 914 } 915 GetViewFrame()->GetBindings().Invalidate( nSlot ); 916 } 917 break; 918 #if defined WNT || defined UNX 919 case SID_TWAIN_SELECT: 920 case SID_TWAIN_TRANSFER: 921 GetViewImpl()->ExecuteScan( rReq ); 922 break; 923 #endif 924 925 case SID_ATTR_DEFTABSTOP: 926 { 927 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, sal_False, &pItem)) 928 { 929 SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ); 930 sal_uInt16 nTab = ((const SfxUInt16Item*)pItem)->GetValue(); 931 MakeDefTabs( nTab, aDefTabs ); 932 pWrtShell->SetDefault( aDefTabs ); 933 } 934 } 935 break; 936 case SID_ATTR_LANGUAGE : 937 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, sal_False, &pItem)) 938 { 939 SvxLanguageItem aLang(((SvxLanguageItem*)pItem)->GetLanguage(), RES_CHRATR_LANGUAGE); 940 pWrtShell->SetDefault( aLang ); 941 lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_LANGUAGE ); 942 } 943 break; 944 case SID_ATTR_CHAR_CTL_LANGUAGE: 945 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, sal_False, &pItem)) 946 { 947 pWrtShell->SetDefault( *pItem ); 948 lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_CTL_LANGUAGE ); 949 } 950 break; 951 case SID_ATTR_CHAR_CJK_LANGUAGE: 952 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, sal_False, &pItem)) 953 { 954 pWrtShell->SetDefault( *pItem ); 955 lcl_SetAllTextToDefaultLanguage( *pWrtShell, RES_CHRATR_CJK_LANGUAGE ); 956 } 957 break; 958 case FN_SCROLL_NEXT_PREV: 959 if(pArgs && pArgs->GetItemState(FN_SCROLL_NEXT_PREV, sal_False, &pItem)) 960 { 961 // call the handlers of PageUp/DownButtons, only 962 bool* pbNext = new bool ( ((const SfxBoolItem*)pItem)->GetValue() ); 963 // #i75416# move the execution of the search to an asynchronously called static link 964 Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext ); 965 } 966 break; 967 case SID_JUMPTOMARK: 968 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_JUMPTOMARK, sal_False, &pItem)) 969 JumpToSwMark( (( const SfxStringItem*)pItem)->GetValue() ); 970 break; 971 case SID_GALLERY : 972 GetViewFrame()->ChildWindowExecute(rReq);//ToggleChildWindow(SID_GALLERY); 973 break; 974 case SID_AVMEDIA_PLAYER : 975 GetViewFrame()->ChildWindowExecute(rReq);//ToggleChildWindow(SID_AVMEDIA_PLAYER); 976 break; 977 case SID_VIEW_DATA_SOURCE_BROWSER: 978 { 979 SfxViewFrame* pVFrame = GetViewFrame(); 980 pVFrame->ChildWindowExecute(rReq); 981 if(pVFrame->HasChildWindow(SID_BROWSER)) 982 { 983 const SwDBData& rData = GetWrtShell().GetDBDesc(); 984 SW_MOD()->ShowDBObj(*this, rData, sal_False); 985 } 986 } 987 break; 988 case FN_INSERT_FIELD_DATA_ONLY : 989 { 990 sal_Bool bShow = sal_False; 991 if( pArgs && 992 SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem )) 993 bShow = ((const SfxBoolItem*)pItem)->GetValue(); 994 //GetViewFrame()->ShowChildWindow(nSlot, bShow && bInMailMerge); 995 if((bShow && bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot)) 996 GetViewFrame()->ToggleChildWindow(nSlot); 997 //if fields have been succesfully inserted call the "real" 998 //mail merge dialog 999 SwWrtShell &rSh = GetWrtShell(); 1000 if(bInMailMerge && rSh.IsAnyDatabaseFieldInDoc()) 1001 { 1002 SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr(); 1003 if (pNewDBMgr) 1004 { 1005 SwDBData aData; 1006 aData = rSh.GetDBData(); 1007 rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer 1008 // das Mischen von DB-Feldern notwendig. 1009 AttrChangedNotify( &rSh ); 1010 pNewDBMgr->SetMergeType( DBMGR_MERGE ); 1011 1012 Sequence<PropertyValue> aProperties(3); 1013 PropertyValue* pValues = aProperties.getArray(); 1014 pValues[0].Name = C2U("DataSourceName"); 1015 pValues[1].Name = C2U("Command"); 1016 pValues[2].Name = C2U("CommandType"); 1017 pValues[0].Value <<= aData.sDataSource; 1018 pValues[1].Value <<= aData.sCommand; 1019 pValues[2].Value <<= aData.nCommandType; 1020 pNewDBMgr->ExecuteFormLetter(rSh, aProperties, sal_True); 1021 } 1022 } 1023 bInMailMerge &= bShow; 1024 GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD); 1025 } 1026 break; 1027 case FN_QRY_MERGE: 1028 { 1029 sal_Bool bUseCurrentDocument = sal_True; 1030 sal_Bool bQuery = !pArgs||SFX_ITEM_SET != pArgs->GetItemState(nSlot); 1031 if(bQuery) 1032 { 1033 SfxViewFrame* pTmpFrame = GetViewFrame(); 1034 SfxHelp::OpenHelpAgent( &pTmpFrame->GetFrame(), HID_MAIL_MERGE_SELECT ); 1035 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 1036 DBG_ASSERT(pFact, "Dialogdiet fail!"); 1037 AbstractMailMergeCreateFromDlg* pDlg = pFact->CreateMailMergeCreateFromDlg( DLG_MERGE_CREATE, 1038 &pTmpFrame->GetWindow()); 1039 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 1040 if(RET_OK == pDlg->Execute()) 1041 bUseCurrentDocument = pDlg->IsThisDocument(); 1042 else 1043 break; 1044 } 1045 GenerateFormLetter(bUseCurrentDocument); 1046 } 1047 break; 1048 case SID_RECHECK_DOCUMENT: 1049 { 1050 SwDocShell* pDocShell = GetDocShell(); 1051 SwDoc* pDoc = pDocShell->GetDoc(); 1052 uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() ); 1053 if( xGCIterator.is() ) 1054 { 1055 xGCIterator->resetIgnoreRules(); 1056 } 1057 // reset ignore lists 1058 pDoc->SpellItAgainSam( sal_True, sal_False, sal_False ); 1059 // clear ignore dictionary 1060 uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY ); 1061 if( xDictionary.is() ) 1062 xDictionary->clear(); 1063 // put cursor to the start of the document 1064 pWrtShell->SttDoc(); 1065 } 1066 // no break; - but call spell/grammar dialog 1067 case FN_SPELL_GRAMMAR_DIALOG: 1068 { 1069 SfxViewFrame* pViewFrame = GetViewFrame(); 1070 if (rReq.GetArgs() != NULL) 1071 pViewFrame->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG, 1072 ((const SfxBoolItem&) (rReq.GetArgs()-> 1073 Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue()); 1074 else 1075 pViewFrame->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG); 1076 1077 pViewFrame->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG); 1078 rReq.Ignore (); 1079 } 1080 break; 1081 case SID_ALIGN_ANY_LEFT : 1082 case SID_ALIGN_ANY_HCENTER : 1083 case SID_ALIGN_ANY_RIGHT : 1084 case SID_ALIGN_ANY_JUSTIFIED: 1085 case SID_ALIGN_ANY_TOP : 1086 case SID_ALIGN_ANY_VCENTER : 1087 case SID_ALIGN_ANY_BOTTOM : 1088 case SID_ALIGN_ANY_HDEFAULT : 1089 case SID_ALIGN_ANY_VDEFAULT : 1090 { 1091 sal_uInt16 nAlias = 0; 1092 if( nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) ) 1093 { 1094 switch( nSlot ) 1095 { 1096 case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break; 1097 case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break; 1098 case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break; 1099 case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break; 1100 case SID_ALIGN_ANY_TOP : nAlias = FN_TABLE_VERT_NONE; break; 1101 case SID_ALIGN_ANY_VCENTER : nAlias = FN_TABLE_VERT_CENTER; break; 1102 case SID_ALIGN_ANY_BOTTOM : nAlias = FN_TABLE_VERT_BOTTOM; break; 1103 } 1104 } 1105 else 1106 { 1107 switch( nSlot ) 1108 { 1109 case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break; 1110 case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break; 1111 case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break; 1112 case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break; 1113 case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break; 1114 case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break; 1115 } 1116 } 1117 //special handling for the draw shell 1118 if(nAlias && (nSelectionType & (nsSelectionType::SEL_DRW))) 1119 { 1120 SfxAllEnumItem aEnumItem(SID_OBJECT_ALIGN, nAlias - SID_OBJECT_ALIGN_LEFT); 1121 GetViewFrame()->GetDispatcher()->Execute( 1122 SID_OBJECT_ALIGN, SFX_CALLMODE_ASYNCHRON, &aEnumItem, 0L); 1123 } 1124 else if(nAlias) 1125 //these slots are either re-mapped to text or object alignment 1126 GetViewFrame()->GetDispatcher()->Execute( 1127 nAlias, SFX_CALLMODE_ASYNCHRON); 1128 } 1129 break; 1130 case SID_RESTORE_EDITING_VIEW: 1131 { 1132 //#i33307# restore editing position 1133 Point aCrsrPos; 1134 bool bSelectObj; 1135 if(pViewImpl->GetRestorePosition(aCrsrPos, bSelectObj)) 1136 { 1137 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj ); 1138 if( bSelectObj ) 1139 { 1140 pWrtShell->SelectObj( aCrsrPos ); 1141 pWrtShell->EnterSelFrmMode( &aCrsrPos ); 1142 } 1143 } 1144 } 1145 break; 1146 case SID_INSERT_GRAPHIC: 1147 { 1148 rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq ))); 1149 } 1150 break; 1151 1152 1153 default: 1154 ASSERT(!this, falscher Dispatcher); 1155 return; 1156 } 1157 if(!bIgnore) 1158 rReq.Done(); 1159 } 1160 1161 /*-------------------------------------------------------------------- 1162 Beschreibung: SeitenNr-Feld invalidieren 1163 --------------------------------------------------------------------*/ 1164 1165 void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const String& rPgStr) 1166 { 1167 String sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr )); 1168 const SfxStringItem aTmp( FN_STAT_PAGE, sTemp ); 1169 SfxBindings &rBnd = GetViewFrame()->GetBindings(); 1170 rBnd.SetState( aTmp ); 1171 rBnd.Update( FN_STAT_PAGE ); 1172 } 1173 1174 /*-------------------------------------------------------------------- 1175 Beschreibung: Status der Stauszeile 1176 --------------------------------------------------------------------*/ 1177 1178 1179 void SwView::StateStatusLine(SfxItemSet &rSet) 1180 { 1181 SwWrtShell& rShell = GetWrtShell(); 1182 1183 SfxWhichIter aIter( rSet ); 1184 sal_uInt16 nWhich = aIter.FirstWhich(); 1185 ASSERT( nWhich, "leeres Set"); 1186 1187 while( nWhich ) 1188 { 1189 switch( nWhich ) 1190 { 1191 case FN_STAT_PAGE: 1192 /* 1193 //JP 07.01.00: is a nice feature - show the selektion of DrawObjects 1194 if( rShell.IsObjSelected() 1195 //??? || rShell.IsFrmSelected() 1196 ) 1197 { 1198 String sDisplay( rShell.GetDrawView()->GetMarkedObjectList(). 1199 GetDescriptionOfMarkedObjects() ); 1200 rSet.Put( SfxStringItem( FN_STAT_PAGE, sDisplay )); 1201 } 1202 else 1203 */ { 1204 // Anzahl der Seiten, log. SeitenNr. SeitenNr ermitteln 1205 sal_uInt16 nPage, nLogPage; 1206 String sDisplay; 1207 rShell.GetPageNumber( -1, rShell.IsCrsrVisible(), nPage, nLogPage, sDisplay ); 1208 rSet.Put( SfxStringItem( FN_STAT_PAGE, 1209 GetPageStr( nPage, nLogPage, sDisplay) )); 1210 1211 sal_uInt16 nCnt = GetWrtShell().GetPageCnt(); 1212 if (nPageCnt != nCnt) // Basic benachrichtigen 1213 { 1214 nPageCnt = nCnt; 1215 SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), sal_False); 1216 } 1217 } 1218 break; 1219 case FN_STAT_TEMPLATE: 1220 { 1221 rSet.Put(SfxStringItem( FN_STAT_TEMPLATE, 1222 rShell.GetCurPageStyle(sal_False))); 1223 1224 } 1225 break; 1226 case SID_ATTR_ZOOM: 1227 { 1228 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) 1229 { 1230 const SwViewOption* pVOpt = rShell.GetViewOptions(); 1231 SvxZoomType eZoom = (SvxZoomType) pVOpt->GetZoomType(); 1232 SvxZoomItem aZoom(eZoom, 1233 pVOpt->GetZoom()); 1234 if( pVOpt->getBrowseMode() ) 1235 { 1236 aZoom.SetValueSet( 1237 SVX_ZOOM_ENABLE_50| 1238 SVX_ZOOM_ENABLE_75| 1239 SVX_ZOOM_ENABLE_100| 1240 SVX_ZOOM_ENABLE_150| 1241 SVX_ZOOM_ENABLE_200); 1242 } 1243 rSet.Put( aZoom ); 1244 } 1245 else 1246 rSet.DisableItem( SID_ATTR_ZOOM ); 1247 } 1248 break; 1249 case SID_ATTR_VIEWLAYOUT: 1250 { 1251 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) 1252 { 1253 const SwViewOption* pVOpt = rShell.GetViewOptions(); 1254 const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns(); 1255 const bool bBookMode = pVOpt->IsViewLayoutBookMode(); 1256 SvxViewLayoutItem aViewLayout(nColumns, bBookMode); 1257 rSet.Put( aViewLayout ); 1258 } 1259 else 1260 rSet.DisableItem( SID_ATTR_VIEWLAYOUT ); 1261 } 1262 break; 1263 case SID_ATTR_ZOOMSLIDER: 1264 { 1265 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) 1266 { 1267 const SwViewOption* pVOpt = rShell.GetViewOptions(); 1268 const sal_uInt16 nCurrentZoom = pVOpt->GetZoom(); 1269 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM ); 1270 aZoomSliderItem.AddSnappingPoint( 100 ); 1271 1272 if ( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ) 1273 { 1274 const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns(); 1275 const bool bAutomaticViewLayout = 0 == nColumns; 1276 const SwPostItMgr* pMgr = GetPostItMgr(); 1277 1278 // snapping points: 1279 // automatic mode: 1 Page, 2 Pages, 100% 1280 // n Columns mode: n Pages, 100% 1281 // n Columns book mode: nPages without gaps, 100% 1282 const SwRect aPageRect( pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) ); 1283 const SwRect aRootRect( pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) ); // width of columns 1284 Size aPageSize( aPageRect.SSize() ); 1285 aPageSize.Width() += pMgr->HasNotes() && pMgr->ShowNotes() ? 1286 pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() : 1287 0; 1288 1289 Size aRootSize( aRootRect.SSize() ); 1290 1291 const MapMode aTmpMap( MAP_TWIP ); 1292 const Size& rEditSize = GetEditWin().GetOutputSizePixel(); 1293 const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) ); 1294 1295 const long nOf = DOCUMENTBORDER * 2L; 1296 long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width(); 1297 nTmpWidth += nOf; 1298 aPageSize.Height() += nOf; 1299 long nFac = aWindowSize.Width() * 100 / nTmpWidth; 1300 1301 long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height(); 1302 nFac = Min( nFac, nVisPercent ); 1303 1304 aZoomSliderItem.AddSnappingPoint( nFac ); 1305 1306 if ( bAutomaticViewLayout ) 1307 { 1308 nTmpWidth += aPageSize.Width() + GAPBETWEENPAGES; 1309 nFac = aWindowSize.Width() * 100 / nTmpWidth; 1310 nFac = Min( nFac, nVisPercent ); 1311 aZoomSliderItem.AddSnappingPoint( nFac ); 1312 } 1313 } 1314 1315 rSet.Put( aZoomSliderItem ); 1316 } 1317 else 1318 rSet.DisableItem( SID_ATTR_ZOOMSLIDER ); 1319 } 1320 break; 1321 case SID_ATTR_POSITION: 1322 case SID_ATTR_SIZE: 1323 { 1324 if( !rShell.IsFrmSelected() && !rShell.IsObjSelected() ) 1325 SwBaseShell::_SetFrmMode( FLY_DRAG_END ); 1326 else 1327 { 1328 FlyMode eFrameMode = SwBaseShell::GetFrmMode(); 1329 if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG ) 1330 { 1331 if ( nWhich == SID_ATTR_POSITION ) 1332 rSet.Put( SfxPointItem( SID_ATTR_POSITION, 1333 rShell.GetAnchorObjDiff())); 1334 else 1335 rSet.Put( SvxSizeItem( SID_ATTR_SIZE, 1336 rShell.GetObjSize())); 1337 } 1338 } 1339 } 1340 break; 1341 case SID_TABLE_CELL: 1342 1343 if( rShell.IsFrmSelected() || rShell.IsObjSelected() ) 1344 { 1345 // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem. 1346 // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot 1347 // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied 1348 // in SID_ATTR_SIZE). 1349 } 1350 else 1351 { 1352 String sStr; 1353 if( rShell.IsCrsrInTbl() ) 1354 { 1355 // table name + cell coordinate 1356 sStr = rShell.GetTableFmt()->GetName(); 1357 sStr += ':'; 1358 sStr += rShell.GetBoxNms(); 1359 } 1360 else 1361 { 1362 const SwSection* pCurrSect = rShell.GetCurrSection(); 1363 if( pCurrSect ) 1364 { 1365 switch( pCurrSect->GetType() ) 1366 { 1367 case TOX_HEADER_SECTION: 1368 case TOX_CONTENT_SECTION: 1369 { 1370 const SwTOXBase* pTOX = pWrtShell->GetCurTOX(); 1371 if( pTOX ) 1372 sStr = pTOX->GetTOXName(); 1373 else 1374 { 1375 ASSERT( !this, 1376 "was ist das fuer ein Verzeichnis?" ); 1377 sStr = pCurrSect->GetSectionName(); 1378 } 1379 } 1380 break; 1381 default: 1382 sStr = pCurrSect->GetSectionName(); 1383 break; 1384 } 1385 } 1386 } 1387 1388 //#outline level, removed by zhaojianwei 1389 //const SwNumRule* pNumRule = rShell.GetCurNumRule(); 1390 //if (pNumRule) // Cursor in Numerierung 1391 //{ 1392 // sal_uInt8 nNumLevel = rShell.GetNumLevel(); 1393 // if( IsShowNum(nNumLevel) && MAXLEVEL > 1394 // ( nNumLevel = GetRealLevel( nNumLevel )) ) 1395 // { 1396 // if( sStr.Len() ) 1397 // sStr.AppendAscii(sStatusDelim); 1398 // sStr += SW_RESSTR(STR_NUM_LEVEL); 1399 // sStr += String::CreateFromInt32( nNumLevel + 1 ); 1400 // if(!pNumRule->IsAutoRule()) 1401 // { 1402 // SfxItemSet aSet(GetPool(), 1403 // RES_PARATR_NUMRULE, RES_PARATR_NUMRULE); 1404 // rShell.GetCurAttr(aSet); 1405 // /* const SfxPoolItem* pItem; */ 1406 // if(SFX_ITEM_AVAILABLE <= 1407 // aSet.GetItemState(RES_PARATR_NUMRULE, sal_True 1408 // /*, &pItem */ )) 1409 // { 1410 // const String& rNumStyle = 1411 // ((const SfxStringItem &) 1412 // aSet.Get(RES_PARATR_NUMRULE)).GetValue(); 1413 // /* #i5116# GetItemState does not necessarily 1414 // change pItem */ 1415 // // ((const SfxStringItem*)pItem)->GetValue(); 1416 // if(rNumStyle.Len()) 1417 // { 1418 // sStr.AppendAscii(sStatusDelim); 1419 // sStr += rNumStyle; 1420 // } 1421 // } 1422 // } 1423 // } 1424 //}//<-removed end ,zhaojianwei 1425 1426 //-->#outline level,added by zhaojianwei 1427 const SwNumRule* pNumRule = rShell.GetCurNumRule(); 1428 const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0; 1429 //((SwTxtFmtColl*)rShell.GetCrsr()->GetNode()->GetTxtNode()->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle(); 1430 1431 if (pNumRule && !bOutlineNum ) // Cursor in Numerierung 1432 { 1433 sal_uInt8 nNumLevel = rShell.GetNumLevel(); 1434 // --> OD 2008-04-02 #refactorlists# 1435 // if( IsShowNum(nNumLevel) && MAXLEVEL > 1436 // ( nNumLevel = GetRealLevel( nNumLevel )) ) 1437 if ( nNumLevel < MAXLEVEL ) 1438 // <-- 1439 { 1440 if(!pNumRule->IsAutoRule()) 1441 { 1442 SfxItemSet aSet(GetPool(), 1443 RES_PARATR_NUMRULE, RES_PARATR_NUMRULE); 1444 rShell.GetCurAttr(aSet); 1445 /* const SfxPoolItem* pItem; */ 1446 if(SFX_ITEM_AVAILABLE <= 1447 aSet.GetItemState(RES_PARATR_NUMRULE, sal_True 1448 /*, &pItem */ )) 1449 { 1450 const String& rNumStyle = 1451 ((const SfxStringItem &) 1452 aSet.Get(RES_PARATR_NUMRULE)).GetValue(); 1453 /* #i5116# GetItemState does not necessarily 1454 change pItem */ 1455 // ((const SfxStringItem*)pItem)->GetValue(); 1456 if(rNumStyle.Len()) 1457 { 1458 if( sStr.Len() ) 1459 sStr.AppendAscii(sStatusDelim); 1460 sStr += rNumStyle; 1461 } 1462 } 1463 } 1464 if( sStr.Len() ) 1465 sStr.AppendAscii(sStatusDelim); 1466 sStr += SW_RESSTR(STR_NUM_LEVEL); 1467 sStr += String::CreateFromInt32( nNumLevel + 1 ); 1468 1469 } 1470 } 1471 const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel(); 1472 if( nOutlineLevel != 0 ) 1473 { 1474 if( sStr.Len() ) 1475 sStr.AppendAscii(sStatusComma); 1476 if( bOutlineNum ) 1477 { 1478 sStr += SW_RESSTR(STR_OUTLINE_NUMBERING); 1479 sStr.AppendAscii(sStatusDelim); 1480 sStr += SW_RESSTR(STR_NUM_LEVEL); 1481 } 1482 else 1483 sStr += SW_RESSTR(STR_NUM_OUTLINE); 1484 sStr += String::CreateFromInt32( nOutlineLevel); 1485 } 1486 //<-end ,zhaojianwei 1487 1488 if( rShell.HasReadonlySel() ) 1489 { 1490 if( sStr.Len() ) 1491 sStr.InsertAscii( sStatusDelim, 0 ); 1492 sStr.Insert( SW_RESSTR( STR_READONLY_SEL ), 0 ); 1493 } 1494 if( sStr.Len() ) 1495 rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr )); 1496 } 1497 break; 1498 case FN_STAT_SELMODE: 1499 { 1500 if(rShell.IsStdMode()) 1501 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0)); 1502 else if(rShell.IsAddMode()) 1503 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2)); 1504 else if(rShell.IsBlockMode()) 1505 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3)); 1506 else 1507 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1)); 1508 break; 1509 } 1510 case SID_ATTR_INSERT: 1511 if( rShell.IsRedlineOn() ) 1512 rSet.DisableItem( nWhich ); 1513 else 1514 { 1515 rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode())); 1516 } 1517 break; 1518 } 1519 nWhich = aIter.NextWhich(); 1520 } 1521 } 1522 1523 /*-------------------------------------------------------------------- 1524 Beschreibung: Execute fuer die Stauszeile 1525 --------------------------------------------------------------------*/ 1526 1527 1528 void SwView::ExecuteStatusLine(SfxRequest &rReq) 1529 { 1530 SwWrtShell &rSh = GetWrtShell(); 1531 const SfxItemSet* pArgs = rReq.GetArgs(); 1532 const SfxPoolItem* pItem=NULL; 1533 sal_Bool bUp = sal_False; 1534 sal_uInt16 nWhich = rReq.GetSlot(); 1535 switch( nWhich ) 1536 { 1537 case FN_STAT_PAGE: 1538 { 1539 GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR, 1540 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD ); 1541 } 1542 break; 1543 1544 case FN_STAT_BOOKMARK: 1545 if ( pArgs ) 1546 { 1547 if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_True, &pItem)) 1548 { 1549 const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess(); 1550 const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); 1551 if(nIdx < pMarkAccess->getBookmarksCount()) 1552 { 1553 const IDocumentMarkAccess::const_iterator_t ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx; 1554 rSh.EnterStdMode(); 1555 rSh.GotoMark( ppBookmark->get() ); 1556 } 1557 else 1558 OSL_ENSURE(false, 1559 "SwView::ExecuteStatusLine(..)" 1560 " - Ignoring out of range bookmark index"); 1561 } 1562 } 1563 break; 1564 1565 case FN_STAT_TEMPLATE: 1566 { 1567 GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG, 1568 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD ); 1569 } 1570 break; 1571 case SID_ATTR_ZOOM: 1572 { 1573 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) 1574 { 1575 const SfxItemSet *pSet = 0; 1576 AbstractSvxZoomDialog *pDlg = 0; 1577 if ( pArgs ) 1578 pSet = pArgs; 1579 else 1580 { 1581 const SwViewOption& rViewOptions = *rSh.GetViewOptions(); 1582 SfxItemSet aCoreSet(pShell->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM, SID_ATTR_VIEWLAYOUT, SID_ATTR_VIEWLAYOUT, 0 ); 1583 SvxZoomItem aZoom( (SvxZoomType)rViewOptions.GetZoomType(), rViewOptions.GetZoom() ); 1584 1585 const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode(); 1586 if( bBrowseMode ) 1587 { 1588 aZoom.SetValueSet( 1589 SVX_ZOOM_ENABLE_50| 1590 SVX_ZOOM_ENABLE_75| 1591 SVX_ZOOM_ENABLE_100| 1592 SVX_ZOOM_ENABLE_150| 1593 SVX_ZOOM_ENABLE_200); 1594 } 1595 aCoreSet.Put( aZoom ); 1596 1597 // PAGES01 1598 if ( !bBrowseMode ) 1599 { 1600 const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() ); 1601 aCoreSet.Put( aViewLayout ); 1602 } 1603 1604 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1605 if(pFact) 1606 { 1607 pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet); 1608 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 1609 } 1610 1611 pDlg->SetLimits( MINZOOM, MAXZOOM ); 1612 1613 if( pDlg->Execute() != RET_CANCEL ) 1614 pSet = pDlg->GetOutputItemSet(); 1615 } 1616 1617 // PAGES01 1618 const SfxPoolItem* pViewLayoutItem = 0; 1619 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, sal_True, &pViewLayoutItem)) 1620 { 1621 const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pViewLayoutItem)->GetValue(); 1622 const bool bBookMode = ((const SvxViewLayoutItem *)pViewLayoutItem)->IsBookMode(); 1623 SetViewLayout( nColumns, bBookMode ); 1624 } 1625 1626 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_ZOOM, sal_True, &pItem)) 1627 { 1628 enum SvxZoomType eType = ((const SvxZoomItem *)pItem)->GetType(); 1629 SetZoom( eType, ((const SvxZoomItem *)pItem)->GetValue() ); 1630 } 1631 bUp = sal_True; 1632 if ( pItem ) 1633 rReq.AppendItem( *pItem ); 1634 rReq.Done(); 1635 1636 delete pDlg; 1637 } 1638 } 1639 break; 1640 1641 case SID_ATTR_VIEWLAYOUT: 1642 { 1643 if ( pArgs && !rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) && 1644 ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) ) 1645 { 1646 // PAGES01 1647 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, sal_True, &pItem )) 1648 { 1649 const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pItem)->GetValue(); 1650 const bool bBookMode = (0 == nColumns || 0 != (nColumns % 2)) ? 1651 false : 1652 ((const SvxViewLayoutItem *)pItem)->IsBookMode(); 1653 1654 SetViewLayout( nColumns, bBookMode ); 1655 } 1656 1657 bUp = sal_True; 1658 rReq.Done(); 1659 1660 InvalidateRulerPos(); 1661 } 1662 } 1663 break; 1664 1665 case SID_ATTR_ZOOMSLIDER: 1666 { 1667 if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) ) 1668 { 1669 // PAGES01 1670 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, sal_True, &pItem )) 1671 { 1672 const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue(); 1673 SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom ); 1674 } 1675 1676 bUp = sal_True; 1677 rReq.Done(); 1678 } 1679 } 1680 break; 1681 1682 case SID_ATTR_SIZE: 1683 { 1684 sal_uLong nId = FN_INSERT_FIELD; 1685 if( rSh.IsCrsrInTbl() ) 1686 nId = FN_FORMAT_TABLE_DLG; 1687 else if( rSh.GetCurTOX() ) 1688 nId = FN_INSERT_MULTI_TOX; 1689 else if( rSh.GetCurrSection() ) 1690 nId = FN_EDIT_REGION; 1691 else 1692 { 1693 const SwNumRule* pNumRule = rSh.GetCurNumRule(); 1694 if( pNumRule ) // Cursor in Numerierung 1695 { 1696 if( pNumRule->IsAutoRule() ) 1697 nId = FN_NUMBER_BULLETS; 1698 else 1699 { 1700 // Dialog vom Gestalter starten ;-) 1701 nId = 0; 1702 } 1703 } 1704 else if( rSh.IsFrmSelected() ) 1705 nId = FN_FORMAT_FRAME_DLG; 1706 else if( rSh.IsObjSelected() ) 1707 nId = SID_ATTR_TRANSFORM; 1708 } 1709 if( nId ) 1710 GetViewFrame()->GetDispatcher()->Execute( 1711 static_cast< sal_uInt16 >( nId ), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD ); 1712 } 1713 break; 1714 1715 case FN_STAT_SELMODE: 1716 { 1717 if ( pArgs ) 1718 { 1719 if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_True, &pItem)) 1720 { 1721 switch ( ((const SfxUInt16Item *)pItem)->GetValue() ) 1722 { 1723 case 0: rSh.EnterStdMode(); break; 1724 case 1: rSh.EnterExtMode(); break; 1725 case 2: rSh.EnterAddMode(); break; 1726 case 3: rSh.EnterBlockMode(); break; 1727 } 1728 } 1729 } 1730 else 1731 { 1732 1733 if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() ) 1734 rSh.ToggleExtMode(); 1735 else if ( rSh.IsExtMode() ) 1736 { 1737 rSh.ToggleExtMode(); 1738 rSh.ToggleAddMode(); 1739 } 1740 else if ( rSh.IsAddMode() ) 1741 { 1742 rSh.ToggleAddMode(); 1743 rSh.ToggleBlockMode(); 1744 } 1745 else 1746 rSh.ToggleBlockMode(); 1747 } 1748 bUp = sal_True; 1749 break; 1750 } 1751 case FN_SET_ADD_MODE: 1752 rSh.ToggleAddMode(); 1753 nWhich = FN_STAT_SELMODE; 1754 bUp = sal_True; 1755 break; 1756 case FN_SET_BLOCK_MODE: 1757 rSh.ToggleBlockMode(); 1758 nWhich = FN_STAT_SELMODE; 1759 bUp = sal_True; 1760 break; 1761 case FN_SET_EXT_MODE: 1762 rSh.ToggleExtMode(); 1763 nWhich = FN_STAT_SELMODE; 1764 bUp = sal_True; 1765 break; 1766 case SID_ATTR_INSERT: 1767 SwPostItMgr* pMgr = GetPostItMgr(); 1768 if ( pMgr && pMgr->HasActiveSidebarWin() ) 1769 { 1770 pMgr->ToggleInsModeOnActiveSidebarWin(); 1771 } 1772 else 1773 rSh.ToggleInsMode(); 1774 bUp = sal_True; 1775 break; 1776 1777 } 1778 if ( bUp ) 1779 { 1780 SfxBindings &rBnd = GetViewFrame()->GetBindings(); 1781 rBnd.Invalidate(nWhich); 1782 rBnd.Update(nWhich); 1783 } 1784 } 1785 1786 void SwView::InsFrmMode(sal_uInt16 nCols) 1787 { 1788 if ( pWrtShell->HasWholeTabSelection() ) 1789 { 1790 SwFlyFrmAttrMgr aMgr( sal_True, pWrtShell, FRMMGR_TYPE_TEXT ); 1791 1792 const SwFrmFmt &rPageFmt = 1793 pWrtShell->GetPageDesc(pWrtShell->GetCurPageDesc()).GetMaster(); 1794 SwTwips lWidth = rPageFmt.GetFrmSize().GetWidth(); 1795 const SvxLRSpaceItem &rLR = rPageFmt.GetLRSpace(); 1796 lWidth -= rLR.GetLeft() + rLR.GetRight(); 1797 aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height())); 1798 if(nCols > 1) 1799 { 1800 SwFmtCol aCol; 1801 aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() ); 1802 aMgr.SetCol( aCol ); 1803 } 1804 aMgr.InsertFlyFrm(); 1805 } 1806 else 1807 GetEditWin().InsFrm(nCols); 1808 } 1809 1810 /*-------------------------------------------------------------------- 1811 Beschreibung: Links bearbeiten 1812 --------------------------------------------------------------------*/ 1813 1814 void SwView::EditLinkDlg() 1815 { 1816 sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this); 1817 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1818 SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb ); 1819 if ( pDlg ) 1820 { 1821 pDlg->Execute(); 1822 delete pDlg; 1823 } 1824 /* 1825 SwLinkDlg* pDlg = new SwLinkDlg(GetFrameWindow()); 1826 pDlg->SetShell(&GetWrtShell()); 1827 pDlg->Execute(); 1828 1829 DELETEZ(pDlg); 1830 */ 1831 } 1832 1833 sal_Bool SwView::JumpToSwMark( const String& rMark ) 1834 { 1835 sal_Bool bRet = sal_False; 1836 if( rMark.Len() ) 1837 { 1838 // wir wollen den Bookmark aber am oberen Rand haben 1839 sal_Bool bSaveCC = IsCrsrAtCenter(); 1840 sal_Bool bSaveCT = IsCrsrAtTop(); 1841 SetCrsrAtTop( sal_True ); 1842 1843 //JP 27.04.98: Bug 49786 1844 // Damit in FrameSet auch gescrollt werden kann, muss die 1845 // entsprechende Shell auch das Focus-Flag gesetzt haben! 1846 sal_Bool bHasShFocus = pWrtShell->HasShFcs(); 1847 if( !bHasShFocus ) 1848 pWrtShell->ShGetFcs( sal_False ); 1849 1850 const SwFmtINetFmt* pINet; 1851 String sCmp, sMark( INetURLObject::decode( rMark, INET_HEX_ESCAPE, 1852 INetURLObject::DECODE_WITH_CHARSET, 1853 RTL_TEXTENCODING_UTF8 )); 1854 1855 xub_StrLen nLastPos, nPos = sMark.Search( cMarkSeperator ); 1856 if( STRING_NOTFOUND != nPos ) 1857 while( STRING_NOTFOUND != ( nLastPos = 1858 sMark.Search( cMarkSeperator, nPos + 1 )) ) 1859 nPos = nLastPos; 1860 1861 IDocumentMarkAccess::const_iterator_t ppMark; 1862 IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess(); 1863 if( STRING_NOTFOUND != nPos && 1864 ( sCmp = sMark.Copy( nPos + 1 ) ).EraseAllChars().Len() ) 1865 { 1866 String sName( sMark.Copy( 0, nPos ) ); 1867 sCmp.ToLowerAscii(); 1868 FlyCntType eFlyType = FLYCNTTYPE_ALL; 1869 1870 if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToRegion ) ) 1871 { 1872 pWrtShell->EnterStdMode(); 1873 bRet = pWrtShell->GotoRegion( sName ); 1874 } 1875 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOutline ) ) 1876 { 1877 pWrtShell->EnterStdMode(); 1878 bRet = pWrtShell->GotoOutline( sName ); 1879 } 1880 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToFrame ) ) 1881 eFlyType = FLYCNTTYPE_FRM; 1882 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToGraphic ) ) 1883 eFlyType = FLYCNTTYPE_GRF; 1884 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOLE ) ) 1885 eFlyType = FLYCNTTYPE_OLE; 1886 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToTable ) ) 1887 { 1888 pWrtShell->EnterStdMode(); 1889 bRet = pWrtShell->GotoTable( sName ); 1890 } 1891 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToText ) ) 1892 { 1893 // Normale Textsuche 1894 pWrtShell->EnterStdMode(); 1895 1896 SearchOptions aSearchOpt( 1897 SearchAlgorithms_ABSOLUTE, 0, 1898 sName, rtl::OUString(), 1899 SvxCreateLocale( LANGUAGE_SYSTEM ), 1900 0,0,0, 1901 TransliterationModules_IGNORE_CASE ); 1902 1903 //todo/mba: assuming that notes shouldn't be searched 1904 sal_Bool bSearchInNotes = sal_False; 1905 if( pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END )) 1906 { 1907 pWrtShell->EnterStdMode(); // Selektion wieder aufheben 1908 bRet = sal_True; 1909 } 1910 } 1911 else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) ) 1912 pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = sal_True; 1913 else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) )) 1914 bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() ); 1915 1916 // fuer alle Arten von Flys 1917 if( FLYCNTTYPE_ALL != eFlyType && pWrtShell->GotoFly( sName, eFlyType )) 1918 { 1919 bRet = sal_True; 1920 if( FLYCNTTYPE_FRM == eFlyType ) 1921 { 1922 // TextFrames: Cursor in den Frame setzen 1923 pWrtShell->UnSelectFrm(); 1924 pWrtShell->LeaveSelFrmMode(); 1925 } 1926 else 1927 { 1928 pWrtShell->HideCrsr(); 1929 pWrtShell->EnterSelFrmMode(); 1930 } 1931 } 1932 } 1933 else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark))) 1934 pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = sal_True; 1935 else if( 0 != ( pINet = pWrtShell->FindINetAttr( sMark ) )) 1936 bRet = pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() ); 1937 1938 // #b6330459# make selection visible later 1939 if ( aVisArea.IsEmpty() ) 1940 bMakeSelectionVisible = sal_True; 1941 1942 // ViewStatus wieder zurueck setzen 1943 SetCrsrAtTop( bSaveCT, bSaveCC ); 1944 1945 if( !bHasShFocus ) 1946 pWrtShell->ShLooseFcs(); 1947 } 1948 return bRet; 1949 } 1950 1951 // #i67305, #1367991: Undo after insert from file: 1952 // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled 1953 // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains 1954 // page styles with active header/footer => disabled for those documents 1955 1956 sal_uInt16 lcl_PageDescWithHeader( const SwDoc& rDoc ) 1957 { 1958 sal_uInt16 nRet = 0; 1959 sal_uInt16 nCnt = rDoc.GetPageDescCnt(); 1960 for( sal_uInt16 i = 0; i < nCnt; ++i ) 1961 { 1962 const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i ); 1963 const SwFrmFmt& rMaster = rPageDesc.GetMaster(); 1964 const SfxPoolItem* pItem; 1965 if( ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem ) && 1966 ((SwFmtHeader*)pItem)->IsActive() ) || 1967 ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem ) && 1968 ((SwFmtFooter*)pItem)->IsActive()) ) 1969 ++nRet; 1970 } 1971 return nRet; // number of page styles with active header/footer 1972 } 1973 1974 /*-------------------------------------------------------------------- 1975 Beschreibung: Links bearbeiten 1976 --------------------------------------------------------------------*/ 1977 1978 void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem ) 1979 { 1980 pViewImpl->InitRequest( rRequest ); 1981 pViewImpl->SetParam( pItem ? 1 : 0 ); 1982 sal_uInt16 nSlot = rRequest.GetSlot(); 1983 1984 if ( !pItem ) 1985 { 1986 String sEmpty; 1987 InsertDoc( nSlot, sEmpty, sEmpty ); 1988 } 1989 else 1990 { 1991 String sFile, sFilter; 1992 sFile = ( (const SfxStringItem *)pItem )->GetValue(); 1993 if ( SFX_ITEM_SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, sal_True, &pItem ) ) 1994 sFilter = ( (const SfxStringItem *)pItem )->GetValue(); 1995 1996 bool bHasFileName = ( sFile.Len() > 0 ); 1997 long nFound = InsertDoc( nSlot, sFile, sFilter ); 1998 1999 if ( bHasFileName ) 2000 { 2001 rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) ); 2002 rRequest.Done(); 2003 } 2004 } 2005 } 2006 2007 long SwView::InsertDoc( sal_uInt16 nSlotId, const String& rFileName, const String& rFilterName, sal_Int16 nVersion ) 2008 { 2009 SfxMedium* pMed = 0; 2010 SwDocShell* pDocSh = GetDocShell(); 2011 2012 if( rFileName.Len() ) 2013 { 2014 SfxObjectFactory& rFact = pDocSh->GetFactory(); 2015 const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName ); 2016 if ( !pFilter ) 2017 { 2018 pMed = new SfxMedium(rFileName, STREAM_READ, sal_True, 0, 0 ); 2019 SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() ); 2020 pMed->UseInteractionHandler( sal_True ); 2021 ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, sal_False ); 2022 if ( nErr ) 2023 DELETEZ(pMed); 2024 else 2025 pMed->SetFilter( pFilter ); 2026 } 2027 else 2028 pMed = new SfxMedium(rFileName, STREAM_READ, sal_True, pFilter, 0); 2029 } 2030 else 2031 { 2032 String sFactory = String::CreateFromAscii( pDocSh->GetFactory().GetShortName() ); 2033 pViewImpl->StartDocumentInserter( sFactory, LINK( this, SwView, DialogClosedHdl ) ); 2034 return -1; 2035 } 2036 2037 if( !pMed ) 2038 return -1; 2039 2040 return InsertMedium( nSlotId, pMed, nVersion ); 2041 } 2042 2043 long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVersion ) 2044 { 2045 sal_Bool bInsert = sal_False, bCompare = sal_False, bMerge = sal_False; 2046 long nFound = 0; 2047 SwDocShell* pDocSh = GetDocShell(); 2048 2049 switch( nSlotId ) 2050 { 2051 case SID_DOCUMENT_MERGE: bMerge = sal_True; break; 2052 case SID_DOCUMENT_COMPARE: bCompare = sal_True; break; 2053 case SID_INSERTDOC: bInsert = sal_True; break; 2054 2055 default: 2056 ASSERT( !this, "Unbekannte SlotId!" ); 2057 bInsert = sal_True; 2058 nSlotId = SID_INSERTDOC; 2059 break; 2060 } 2061 2062 if( bInsert ) 2063 { 2064 uno::Reference< frame::XDispatchRecorder > xRecorder = 2065 GetViewFrame()->GetBindings().GetRecorder(); 2066 if ( xRecorder.is() ) 2067 { 2068 SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC); 2069 aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL())); 2070 if(pMedium->GetFilter()) 2071 aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName())); 2072 aRequest.Done(); 2073 } 2074 2075 SfxObjectShellRef aRef( pDocSh ); 2076 2077 sal_uInt32 nError = SfxObjectShell::HandleFilter( pMedium, pDocSh ); 2078 // #i16722# aborted? 2079 if(nError != ERRCODE_NONE) 2080 { 2081 delete pMedium; 2082 return -1; 2083 } 2084 pDocSh->RegisterTransfer( *pMedium ); 2085 pMedium->DownLoad(); // ggfs. den DownLoad anstossen 2086 if( aRef.Is() && 1 < aRef->GetRefCount() ) // noch gueltige Ref? 2087 { 2088 SwReader* pRdr; 2089 Reader *pRead = pDocSh->StartConvertFrom( *pMedium, &pRdr, pWrtShell ); 2090 if( pRead || 2091 (pMedium->GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER) != 0 ) 2092 { 2093 sal_uInt16 nUndoCheck = 0; 2094 SwDoc *pDoc = pDocSh->GetDoc(); 2095 if( pRead && pDocSh->GetDoc() ) 2096 nUndoCheck = lcl_PageDescWithHeader( *pDoc ); 2097 sal_uLong nErrno; 2098 { //Scope for SwWait-Object, to be able to execute slots 2099 //outside this scope. 2100 SwWait aWait( *GetDocShell(), sal_True ); 2101 pWrtShell->StartAllAction(); 2102 if ( pWrtShell->HasSelection() ) 2103 pWrtShell->DelRight(); // Selektionen loeschen 2104 if( pRead ) 2105 { 2106 nErrno = pRdr->Read( *pRead ); // und Dokument einfuegen 2107 delete pRdr; 2108 } 2109 else 2110 { 2111 ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); 2112 nErrno = pDocSh->InsertFrom( *pMedium ) ? 0 : ERR_SWG_READ_ERROR; 2113 } 2114 2115 } 2116 2117 // ggfs. alle Verzeichnisse updaten: 2118 if( pWrtShell->IsUpdateTOX() ) 2119 { 2120 SfxRequest aReq( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() ); 2121 Execute( aReq ); 2122 pWrtShell->SetUpdateTOX( sal_False ); // wieder zurueck setzen 2123 } 2124 2125 if( pDoc ) 2126 { // Disable Undo for .sdw (136991) or 2127 // if the number of page styles with header/footer has changed (#i67305) 2128 if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) ) 2129 { 2130 pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); 2131 } 2132 } 2133 2134 pWrtShell->EndAllAction(); 2135 if( nErrno ) 2136 { 2137 ErrorHandler::HandleError( nErrno ); 2138 nFound = IsError( nErrno ) ? -1 : 0; 2139 } 2140 else 2141 nFound = 0; 2142 } 2143 } 2144 } 2145 else 2146 { 2147 SfxObjectShellRef xDocSh; 2148 SfxObjectShellLock xLockRef; 2149 2150 extern int lcl_FindDocShell( SfxObjectShellRef& xDocSh, SfxObjectShellLock& xLockRef, 2151 const String& rFileName, const String& rPasswd, 2152 String& rFilter, sal_Int16 nVersion, 2153 SwDocShell* pDestSh ); 2154 2155 String sFltNm; 2156 int nRet = lcl_FindDocShell( xDocSh, xLockRef, pMedium->GetName(), aEmptyStr, 2157 sFltNm, nVersion, pDocSh ); 2158 if( nRet ) 2159 { 2160 SwWait aWait( *GetDocShell(), sal_True ); 2161 pWrtShell->StartAllAction(); 2162 2163 pWrtShell->EnterStdMode(); // Selektionen loeschen 2164 2165 if( bCompare ) 2166 nFound = pWrtShell->CompareDoc( *((SwDocShell*)&xDocSh)->GetDoc() ); 2167 else 2168 nFound = pWrtShell->MergeDoc( *((SwDocShell*)&xDocSh)->GetDoc() ); 2169 2170 pWrtShell->EndAllAction(); 2171 2172 if (!bCompare && !nFound) 2173 { 2174 Window* pWin = &GetEditWin(); 2175 InfoBox(pWin, SW_RES(MSG_NO_MERGE_ENTRY)).Execute(); 2176 } 2177 } 2178 if( 2 == nRet && xDocSh.Is() ) 2179 xDocSh->DoClose(); 2180 } 2181 2182 delete pMedium; 2183 return nFound; 2184 } 2185 /* -----------------05.02.2003 12:06----------------- 2186 * 2187 * --------------------------------------------------*/ 2188 void SwView::EnableMailMerge(sal_Bool bEnable ) 2189 { 2190 bInMailMerge = bEnable; 2191 SfxBindings& rBind = GetViewFrame()->GetBindings(); 2192 rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY); 2193 rBind.Update(FN_INSERT_FIELD_DATA_ONLY); 2194 } 2195 /* 2196 */ 2197 namespace 2198 { 2199 sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XNameAccess >& _rDatasourceContext ) 2200 { 2201 Sequence < OUString > aNames = _rDatasourceContext->getElementNames(); 2202 2203 return ( !aNames.getLength() 2204 || ( ( 1 == aNames.getLength() ) 2205 && aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource 2206 ) 2207 ); 2208 } 2209 } 2210 2211 /* -----------------27.11.2002 12:12----------------- 2212 * 2213 * --------------------------------------------------*/ 2214 2215 class SwMergeSourceWarningBox_Impl : public ModalDialog 2216 { 2217 FixedInfo aMessageFI; 2218 OKButton aOK; 2219 CancelButton aCancel; 2220 2221 FixedImage aWarnImage; 2222 public: 2223 SwMergeSourceWarningBox_Impl( Window* pParent ) : 2224 ModalDialog( pParent, SW_RES( DLG_MERGE_SOURCE_UNAVAILABLE ) ), 2225 aMessageFI( this, SW_RES( ST_MERGE_SOURCE_UNAVAILABLE ) ), 2226 aOK( this, SW_RES( PB_MERGE_OK ) ), 2227 aCancel( this, SW_RES( PB_MERGE_CANCEL ) ), 2228 aWarnImage( this, SW_RES( IMG_MERGE ) ) 2229 { 2230 FreeResource(); 2231 SetText( Application::GetDisplayName() ); 2232 const Image& rImg = WarningBox::GetStandardImage(); 2233 aWarnImage.SetImage( rImg ); 2234 Size aImageSize( rImg.GetSizePixel() ); 2235 aImageSize.Width() += 4; 2236 aImageSize.Height() += 4; 2237 aWarnImage.SetSizePixel( aImageSize ); 2238 2239 aImageSize.Width() += aWarnImage.GetPosPixel().X(); 2240 Size aSz(GetSizePixel()); 2241 aSz.Width() += aImageSize.Width(); 2242 SetSizePixel(aSz); 2243 2244 Point aPos(aMessageFI.GetPosPixel()); 2245 aPos.X() += aImageSize.Width(); 2246 aMessageFI.SetPosPixel( aPos ); 2247 2248 aPos = aOK.GetPosPixel(); 2249 aPos.X() += aImageSize.Width(); 2250 aOK.SetPosPixel( aPos ); 2251 aPos = aCancel.GetPosPixel(); 2252 aPos.X() += aImageSize.Width(); 2253 aCancel.SetPosPixel( aPos ); 2254 2255 } 2256 2257 String GetMessText() const { return aMessageFI.GetText(); } 2258 void SetMessText( const String& rText ) { aMessageFI.SetText( rText ); } 2259 }; 2260 2261 2262 2263 2264 void SwView::GenerateFormLetter(sal_Bool bUseCurrentDocument) 2265 { 2266 if(bUseCurrentDocument) 2267 { 2268 if(!GetWrtShell().IsAnyDatabaseFieldInDoc()) 2269 { 2270 //check availability of data sources (except biblio source) 2271 uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); 2272 uno::Reference<XNameAccess> xDBContext; 2273 if( xMgr.is() ) 2274 { 2275 uno::Reference<XInterface> xInstance = xMgr->createInstance( 2276 OUString::createFromAscii( "com.sun.star.sdb.DatabaseContext" )); 2277 xDBContext = uno::Reference<XNameAccess>(xInstance, UNO_QUERY) ; 2278 } 2279 if(!xDBContext.is()) 2280 return ; 2281 sal_Bool bCallAddressPilot = sal_False; 2282 if ( lcl_NeedAdditionalDataSource( xDBContext ) ) 2283 { 2284 // no data sources are available - create a new one 2285 WarningBox aWarning( 2286 &GetViewFrame()->GetWindow(), 2287 SW_RES(MSG_DATA_SOURCES_UNAVAILABLE)); 2288 // no cancel allowed 2289 if ( RET_OK != aWarning.Execute() ) 2290 return; 2291 bCallAddressPilot = sal_True; 2292 } 2293 else 2294 { 2295 //take an existing data source or create a new one? 2296 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 2297 DBG_ASSERT(pFact, "Dialogdiet fail!"); 2298 AbstractMailMergeFieldConnectionsDlg* pConnectionsDlg = pFact->CreateMailMergeFieldConnectionsDlg( 2299 DLG_MERGE_FIELD_CONNECTIONS, 2300 &GetViewFrame()->GetWindow()); 2301 DBG_ASSERT(pConnectionsDlg, "Dialogdiet fail!"); 2302 if(RET_OK == pConnectionsDlg->Execute()) 2303 bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections(); 2304 else 2305 return; 2306 2307 } 2308 if(bCallAddressPilot) 2309 { 2310 GetViewFrame()->GetDispatcher()->Execute( 2311 SID_ADDRESS_DATA_SOURCE, SFX_CALLMODE_SYNCHRON); 2312 if ( lcl_NeedAdditionalDataSource( xDBContext ) ) 2313 // no additional data source has been created 2314 // -> assume that the user has cancelled the pilot 2315 return; 2316 } 2317 2318 //call insert fields with database field page available, only 2319 SfxViewFrame* pVFrame = GetViewFrame(); 2320 //at first hide the default field dialog if currently visible 2321 pVFrame->SetChildWindow(FN_INSERT_FIELD, sal_False); 2322 //enable the status of the db field dialog - it is disabled in the status method 2323 //to prevent creation of the dialog without mail merge active 2324 EnableMailMerge(); 2325 //then show the "Data base only" field dialog 2326 SfxBoolItem aOn(FN_INSERT_FIELD_DATA_ONLY, sal_True); 2327 pVFrame->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY, 2328 SFX_CALLMODE_SYNCHRON, &aOn, 0L); 2329 return; 2330 } 2331 else 2332 { 2333 // check whether the 2334 String sSource; 2335 if(!GetWrtShell().IsFieldDataSourceAvailable(sSource)) 2336 { 2337 SwMergeSourceWarningBox_Impl aWarning( &GetViewFrame()->GetWindow()); 2338 String sTmp(aWarning.GetMessText()); 2339 sTmp.SearchAndReplaceAscii("%1", sSource); 2340 aWarning.SetMessText(sTmp); 2341 if(RET_OK == aWarning.Execute()) 2342 { 2343 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 2344 if ( pFact ) 2345 { 2346 VclAbstractDialog* pDlg = pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES ); 2347 pDlg->Execute(); 2348 delete pDlg; 2349 } 2350 } 2351 return ; 2352 } 2353 } 2354 SwNewDBMgr* pNewDBMgr = GetWrtShell().GetNewDBMgr(); 2355 2356 SwDBData aData; 2357 SwWrtShell &rSh = GetWrtShell(); 2358 aData = rSh.GetDBData(); 2359 rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer 2360 // das Mischen von DB-Feldern notwendig. 2361 AttrChangedNotify( &rSh ); 2362 pNewDBMgr->SetMergeType( DBMGR_MERGE ); 2363 2364 if (pNewDBMgr) 2365 { 2366 Sequence<PropertyValue> aProperties(3); 2367 PropertyValue* pValues = aProperties.getArray(); 2368 pValues[0].Name = C2U("DataSourceName"); 2369 pValues[1].Name = C2U("Command"); 2370 pValues[2].Name = C2U("CommandType"); 2371 pValues[0].Value <<= aData.sDataSource; 2372 pValues[1].Value <<= aData.sCommand; 2373 pValues[2].Value <<= aData.nCommandType; 2374 pNewDBMgr->ExecuteFormLetter(GetWrtShell(), aProperties, sal_True); 2375 } 2376 } 2377 else 2378 { 2379 //call documents and template dialog 2380 SfxApplication* pSfxApp = SFX_APP(); 2381 Window* pTopWin = pSfxApp->GetTopWindow(); 2382 SvtDocumentTemplateDialog* pDocTemplDlg = new SvtDocumentTemplateDialog( pTopWin ); 2383 pDocTemplDlg->SelectTemplateFolder(); 2384 2385 int nRet = pDocTemplDlg->Execute(); 2386 sal_Bool bNewWin = sal_False; 2387 if ( nRet == RET_OK ) 2388 { 2389 if ( pTopWin != pSfxApp->GetTopWindow() ) 2390 { 2391 // the dialogue opens a document -> a new TopWindow appears 2392 pTopWin = pSfxApp->GetTopWindow(); 2393 bNewWin = sal_True; 2394 } 2395 } 2396 2397 delete pDocTemplDlg; 2398 if ( bNewWin ) 2399 // after the destruction of the dialogue its parent comes to top, 2400 // but we want that the new document is on top 2401 pTopWin->ToTop(); 2402 2403 // return; 2404 } 2405 } 2406 2407 IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) 2408 { 2409 if ( ERRCODE_NONE == _pFileDlg->GetError() ) 2410 { 2411 SfxMedium* pMed = pViewImpl->CreateMedium(); 2412 if ( pMed ) 2413 { 2414 sal_uInt16 nSlot = pViewImpl->GetRequest()->GetSlot(); 2415 long nFound = InsertMedium( nSlot, pMed, pViewImpl->GetParam() ); 2416 2417 if ( SID_INSERTDOC == nSlot ) 2418 { 2419 if ( pViewImpl->GetParam() == 0 ) 2420 { 2421 pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) ); 2422 pViewImpl->GetRequest()->Ignore(); 2423 } 2424 else 2425 { 2426 pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) ); 2427 pViewImpl->GetRequest()->Done(); 2428 } 2429 } 2430 else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot ) 2431 { 2432 pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) ); 2433 2434 if ( nFound > 0 ) // Redline-Browser anzeigen 2435 { 2436 SfxViewFrame* pVFrame = GetViewFrame(); 2437 pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT); 2438 2439 // RedlineDlg neu initialisieren 2440 sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId(); 2441 SwRedlineAcceptChild* pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow( nId ); 2442 if ( pRed ) 2443 pRed->ReInitDlg( GetDocShell() ); 2444 } 2445 } 2446 } 2447 } 2448 return 0; 2449 } 2450 2451 void SwView::ExecuteScan( SfxRequest& rReq ) 2452 { 2453 if (pViewImpl) 2454 pViewImpl->ExecuteScan(rReq) ; 2455 } 2456 2457