bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / uiview / view2.cxx
blob744428ca716ade7c03436dc7b57ec831090a3103
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/util/SearchOptions.hpp>
21 #include <com/sun/star/util/SearchFlags.hpp>
22 #include <com/sun/star/i18n/TransliterationModules.hpp>
23 #include <vcl/graphicfilter.hxx>
24 #include <com/sun/star/sdb/DatabaseContext.hpp>
25 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
26 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
27 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
28 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
29 #include <svl/aeitem.hxx>
30 #include <SwStyleNameMapper.hxx>
31 #include <docary.hxx>
32 #include <hintids.hxx>
33 #include <SwRewriter.hxx>
34 #include <numrule.hxx>
35 #include <swundo.hxx>
36 #include <caption.hxx>
37 #include <svl/PasswordHelper.hxx>
38 #include <svl/urihelper.hxx>
39 #include <svtools/miscopt.hxx>
40 #include <sfx2/passwd.hxx>
41 #include <sfx2/sfxdlg.hxx>
42 #include <sfx2/filedlghelper.hxx>
43 #include <sfx2/sfxhelp.hxx>
44 #include <editeng/langitem.hxx>
45 #include <svx/viewlayoutitem.hxx>
46 #include <svx/zoomslideritem.hxx>
47 #include <svtools/xwindowitem.hxx>
48 #include <svx/linkwarn.hxx>
49 #include <sfx2/htmlmode.hxx>
50 #include <vcl/svapp.hxx>
51 #include <vcl/wrkwin.hxx>
52 #include <sfx2/app.hxx>
53 #include <sfx2/request.hxx>
54 #include <sfx2/bindings.hxx>
55 #include <editeng/lrspitem.hxx>
56 #include <unotools/textsearch.hxx>
57 #include "editeng/unolingu.hxx"
58 #include <vcl/msgbox.hxx>
59 #include <editeng/tstpitem.hxx>
60 #include <sfx2/event.hxx>
61 #include <sfx2/docfile.hxx>
62 #include <sfx2/docfilt.hxx>
63 #include <sfx2/fcontnr.hxx>
64 #include <editeng/sizeitem.hxx>
65 #include <sfx2/dispatch.hxx>
66 #include <svl/whiter.hxx>
67 #include <svl/ptitem.hxx>
68 #include <sfx2/linkmgr.hxx>
69 #include <tools/errinf.hxx>
70 #include <tools/urlobj.hxx>
71 #include <svx/svdview.hxx>
72 #include <swtypes.hxx>
73 #include <swwait.hxx>
74 #include <redlndlg.hxx>
75 #include <view.hxx>
76 #include <uivwimp.hxx>
77 #include <docsh.hxx>
78 #include <doc.hxx>
79 #include <IDocumentUndoRedo.hxx>
80 #include <wrtsh.hxx>
81 #include <viewopt.hxx>
82 #include <basesh.hxx>
83 #include <swmodule.hxx>
84 #include <uitool.hxx>
85 #include <shellio.hxx>
86 #include <fmtinfmt.hxx>
87 #include <mdiexp.hxx>
88 #include <drawbase.hxx>
89 #include <frmmgr.hxx>
90 #include <pagedesc.hxx>
91 #include <section.hxx>
92 #include <usrpref.hxx>
93 #include <IMark.hxx>
94 #include <navipi.hxx>
95 #include <tox.hxx>
96 #include <workctrl.hxx>
97 #include <scroll.hxx>
98 #include <edtwin.hxx>
99 #include <wview.hxx>
100 #include <textsh.hxx>
101 #include <tabsh.hxx>
102 #include <listsh.hxx>
103 #include <cmdid.h>
104 #include <comcore.hrc>
105 #include <poolfmt.hrc>
106 #include <statstr.hrc>
107 #include <swerror.h>
108 #include <globals.hrc>
109 #include <shells.hrc>
110 #include <web.hrc>
111 #include <view.hrc>
112 #include <app.hrc>
113 #include <fmtclds.hxx>
114 #include <helpid.h>
115 #include <svtools/templdlg.hxx>
116 #include <dbconfig.hxx>
117 #include <dbmgr.hxx>
118 #include <reffld.hxx>
120 #include <PostItMgr.hxx>
122 #include <ndtxt.hxx>
124 #include <comphelper/processfactory.hxx>
125 #include <comphelper/string.hxx>
127 #include <svx/svxdlg.hxx>
128 #include <svx/dialogs.hrc>
129 #include "swabstdlg.hxx"
130 #include "globals.hrc"
131 #include <envelp.hrc>
132 #include <fmthdft.hxx>
133 #include <svx/ofaitem.hxx>
134 #include <unomid.h>
135 #include <docstat.hxx>
136 #include <wordcountdialog.hxx>
138 #include <vcl/GraphicNativeTransform.hxx>
139 #include <vcl/GraphicNativeMetadata.hxx>
141 const char sStatusDelim[] = " : ";
142 const char sStatusComma[] = " , ";//#outlinelevel, define a Variable for "," add by zhaojianwei
144 using namespace sfx2;
145 using namespace ::com::sun::star;
146 using namespace ::com::sun::star::i18n;
147 using namespace ::com::sun::star::util;
148 using namespace ::com::sun::star::uno;
149 using namespace ::com::sun::star::lang;
150 using namespace ::com::sun::star::scanner;
151 using namespace ::com::sun::star::beans;
152 using namespace ::com::sun::star::container;
153 using namespace ::com::sun::star::sdb;
154 using namespace ::com::sun::star::ui::dialogs;
156 static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhichId )
158 if (nWhichId == RES_CHRATR_LANGUAGE ||
159 nWhichId == RES_CHRATR_CJK_LANGUAGE ||
160 nWhichId == RES_CHRATR_CTL_LANGUAGE)
162 rWrtSh.StartAction();
163 rWrtSh.LockView( sal_True );
164 rWrtSh.Push();
166 // prepare to apply new language to all text in document
167 rWrtSh.SelAll();
168 rWrtSh.ExtendedSelectAll();
170 // set language attribute to default for all text
171 std::set<sal_uInt16> aAttribs;
172 aAttribs.insert( nWhichId );
173 rWrtSh.ResetAttr( aAttribs );
175 rWrtSh.Pop( sal_False );
176 rWrtSh.LockView( sal_False );
177 rWrtSh.EndAction();
181 /* Create string for showing of page in statusbar */
182 String SwView::GetPageStr( sal_uInt16 nPg, sal_uInt16 nLogPg,
183 const String& rDisplay )
185 String aStr( m_aPageStr );
186 if( rDisplay.Len() )
187 aStr += rDisplay;
188 else
189 aStr += OUString::number(nLogPg);
191 if( nLogPg && nLogPg != nPg )
193 aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" "));
194 aStr += OUString::number(nPg);
196 aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
197 aStr += OUString::number( GetWrtShell().GetPageCnt() );
199 return aStr;
202 int SwView::InsertGraphic( const String &rPath, const String &rFilter,
203 sal_Bool bLink, GraphicFilter *pFilter,
204 Graphic* pPreviewGrf, sal_Bool bRule )
206 SwWait aWait( *GetDocShell(), true );
208 Graphic aGraphic;
209 int aResult = GRFILTER_OK;
210 if ( pPreviewGrf )
211 aGraphic = *pPreviewGrf;
212 else
214 if( !pFilter )
216 pFilter = &GraphicFilter::GetGraphicFilter();
218 aResult = GraphicFilter::LoadGraphic( rPath, rFilter, aGraphic, pFilter );
221 if( GRFILTER_OK == aResult )
223 GraphicNativeMetadata aMetadata;
224 if ( aMetadata.read(aGraphic) )
226 sal_uInt16 aRotation = aMetadata.getRotation();
227 if (aRotation != 0)
229 QueryBox aQueryBox(GetWindow(), WB_YES_NO | WB_DEF_YES, SW_RES(STR_ROTATE_TO_STANDARD_ORIENTATION) );
230 if (aQueryBox.Execute() == RET_YES)
232 GraphicNativeTransform aTransform( aGraphic );
233 aTransform.rotate( aRotation );
238 SwFlyFrmAttrMgr aFrameManager( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
240 SwWrtShell& rShell = GetWrtShell();
241 rShell.StartAction();
242 if( bLink )
244 SwDocShell* pDocSh = GetDocShell();
245 INetURLObject aTemp(
246 pDocSh->HasName() ?
247 pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
248 OUString());
250 String sURL = URIHelper::SmartRel2Abs( aTemp, rPath, URIHelper::GetMaybeFileHdl() );
252 rShell.Insert( sURL, rFilter, aGraphic, &aFrameManager, bRule );
254 else
256 rShell.Insert( aEmptyStr, aEmptyStr, aGraphic, &aFrameManager );
259 // it is too late after "EndAction" because the Shell can already be destroyed.
260 rShell.EndAction();
262 return aResult;
265 sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq )
267 sal_Bool bReturn = sal_False;
268 SwDocShell* pDocShell = GetDocShell();
269 sal_uInt16 nHtmlMode = ::GetHtmlMode(pDocShell);
270 // im HTML-Mode nur verknuepft einfuegen
271 FileDialogHelper* pFileDlg = new FileDialogHelper(
272 ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE,
273 SFXWB_GRAPHIC );
274 pFileDlg->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC ));
275 pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC );
276 uno::Reference < XFilePicker > xFP = pFileDlg->GetFilePicker();
277 uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY);
278 if(nHtmlMode & HTMLMODE_ON)
280 sal_Bool bTrue = sal_True;
281 Any aVal(&bTrue, ::getBooleanCppuType());
282 xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, aVal);
283 xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False);
286 std::vector<String> aFormats;
287 SwDoc* pDoc = pDocShell->GetDoc();
288 const sal_uInt16 nArrLen = pDoc->GetFrmFmts()->size();
289 sal_uInt16 i;
290 for( i = 0; i < nArrLen; i++ )
292 SwFrmFmt* pFmt = (*pDoc->GetFrmFmts())[ i ];
293 if(pFmt->IsDefault() || pFmt->IsAuto())
294 continue;
295 aFormats.push_back(pFmt->GetName());
298 // pool formats
300 const boost::ptr_vector<String>& rFrmPoolArr(SwStyleNameMapper::GetFrmFmtUINameArray());
301 for( i = 0; i < rFrmPoolArr.size(); ++i )
303 aFormats.push_back(rFrmPoolArr[i]);
306 std::sort(aFormats.begin(), aFormats.end());
307 aFormats.erase(std::unique(aFormats.begin(), aFormats.end()), aFormats.end());
309 Sequence<OUString> aListBoxEntries(aFormats.size());
310 OUString* pEntries = aListBoxEntries.getArray();
311 sal_Int16 nSelect = 0;
312 String sGraphicFormat = SW_RESSTR(STR_POOLFRM_GRAPHIC);
313 for( i = 0; i < aFormats.size(); i++ )
315 pEntries[i] = aFormats[i];
316 if(pEntries[i].equals(sGraphicFormat))
317 nSelect = i;
321 Any aTemplates(&aListBoxEntries, ::getCppuType(&aListBoxEntries));
323 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
324 ListboxControlActions::ADD_ITEMS , aTemplates );
326 Any aSelectPos(&nSelect, ::getCppuType(&nSelect));
327 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
328 ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
330 catch (const Exception&)
332 OSL_FAIL("control acces failed");
335 SFX_REQUEST_ARG( rReq, pName, SfxStringItem, SID_INSERT_GRAPHIC , sal_False );
336 sal_Bool bShowError = !pName;
337 if( pName || ERRCODE_NONE == pFileDlg->Execute() )
340 String aFileName, aFilterName;
341 if ( pName )
343 aFileName = pName->GetValue();
344 SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, FN_PARAM_FILTER , sal_False );
345 if ( pFilter )
346 aFilterName = pFilter->GetValue();
348 else
350 aFileName = pFileDlg->GetPath();
351 aFilterName = pFileDlg->GetCurrentFilter();
352 rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
353 rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
355 sal_Bool bAsLink = sal_False;
356 if(nHtmlMode & HTMLMODE_ON)
357 bAsLink = sal_True;
358 else
362 Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
363 OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
364 bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
365 Any aTemplateValue = xCtrlAcc->getValue(
366 ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
367 ListboxControlActions::GET_SELECTED_ITEM );
368 OUString sTmpl;
369 aTemplateValue >>= sTmpl;
370 rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) );
372 catch (const Exception&)
374 OSL_FAIL("control access failed");
377 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
380 SFX_REQUEST_ARG( rReq, pAsLink, SfxBoolItem, FN_PARAM_1 , sal_False );
381 SFX_REQUEST_ARG( rReq, pStyle, SfxStringItem, FN_PARAM_2 , sal_False );
383 sal_Bool bAsLink = sal_False;
384 if( nHtmlMode & HTMLMODE_ON )
385 bAsLink = sal_True;
386 else
388 if ( rReq.GetArgs() )
390 if ( pAsLink )
391 bAsLink = pAsLink->GetValue();
392 if ( pStyle && !pStyle->GetValue().isEmpty() )
393 sGraphicFormat = pStyle->GetValue();
395 else
397 Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
398 OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
399 bAsLink = aVal.hasValue() ? *(sal_Bool*) aVal.getValue() : sal_True;
400 Any aTemplateValue = xCtrlAcc->getValue(
401 ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
402 ListboxControlActions::GET_SELECTED_ITEM );
403 OUString sTmpl;
404 aTemplateValue >>= sTmpl;
405 if( !sTmpl.isEmpty() )
406 sGraphicFormat = sTmpl;
407 rReq.AppendItem( SfxStringItem( FN_PARAM_2, sGraphicFormat ) );
408 rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
411 // really store as link only?
412 if( bAsLink && SvtMiscOptions().ShowLinkWarningDialog() )
414 SvxLinkWarningDialog aWarnDlg(GetWindow(),pFileDlg->GetPath());
415 if( aWarnDlg.Execute() != RET_OK )
416 bAsLink=sal_False; // don't store as link
420 SwWrtShell& rSh = GetWrtShell();
421 rSh.LockPaint();
422 rSh.StartAction();
424 SwRewriter aRewriter;
425 aRewriter.AddRule(UndoArg1, SW_RESSTR(STR_GRAPHIC_DEFNAME));
427 rSh.StartUndo(UNDO_INSERT, &aRewriter);
429 int nError = InsertGraphic( aFileName, aFilterName, bAsLink, &GraphicFilter::GetGraphicFilter() );
431 // Format ist ungleich Current Filter, jetzt mit auto. detection
432 if( nError == GRFILTER_FORMATERROR )
433 nError = InsertGraphic( aFileName, aEmptyStr, bAsLink, &GraphicFilter::GetGraphicFilter() );
434 if ( rSh.IsFrmSelected() )
436 SwFrmFmt* pFmt = pDoc->FindFrmFmtByName( sGraphicFormat );
437 if(!pFmt)
438 pFmt = pDoc->MakeFrmFmt(sGraphicFormat,
439 pDocShell->GetDoc()->GetDfltFrmFmt(),
440 true, false);
441 rSh.SetFrmFmt( pFmt );
444 RESOURCE_TYPE nResId = 0;
445 switch( nError )
447 case GRFILTER_OPENERROR:
448 nResId = STR_GRFILTER_OPENERROR;
449 break;
450 case GRFILTER_IOERROR:
451 nResId = STR_GRFILTER_IOERROR;
452 break;
453 case GRFILTER_FORMATERROR:
454 nResId = STR_GRFILTER_FORMATERROR;
455 break;
456 case GRFILTER_VERSIONERROR:
457 nResId = STR_GRFILTER_VERSIONERROR;
458 break;
459 case GRFILTER_FILTERERROR:
460 nResId = STR_GRFILTER_FILTERERROR;
461 break;
462 case GRFILTER_TOOBIG:
463 nResId = STR_GRFILTER_TOOBIG;
464 break;
467 rSh.EndAction();
468 rSh.UnlockPaint();
469 if( nResId )
471 if( bShowError )
473 InfoBox aInfoBox( GetWindow(), SW_RESSTR( nResId ));
474 aInfoBox.Execute();
476 rReq.Ignore();
478 else
480 // set the specific graphic attrbutes to the graphic
481 bReturn = sal_True;
482 AutoCaption( GRAPHIC_CAP );
483 rReq.Done();
486 rSh.EndUndo(); // due to possible change of Shell
489 delete pFileDlg;
491 return bReturn;
494 void SwView::Execute(SfxRequest &rReq)
496 sal_uInt16 nSlot = rReq.GetSlot();
497 const SfxItemSet* pArgs = rReq.GetArgs();
498 const SfxPoolItem* pItem;
499 sal_Bool bIgnore = sal_False;
500 switch( nSlot )
502 case SID_CREATE_SW_DRAWVIEW:
503 m_pWrtShell->getIDocumentDrawModelAccess()->GetOrCreateDrawModel();
504 break;
506 case FN_LINE_NUMBERING_DLG:
508 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
509 OSL_ENSURE(pFact, "Dialogdiet fail!");
510 VclAbstractDialog* pDlg = pFact->CreateVclSwViewDialog(*this);
511 OSL_ENSURE(pDlg, "Dialogdiet fail!");
512 pDlg->Execute();
513 delete pDlg;
514 break;
516 case FN_EDIT_LINK_DLG:
517 EditLinkDlg();
518 break;
519 case FN_REFRESH_VIEW:
520 GetEditWin().Invalidate();
521 break;
522 case FN_PAGEUP:
523 case FN_PAGEUP_SEL:
524 case FN_PAGEDOWN:
525 case FN_PAGEDOWN_SEL:
527 Rectangle aVis( GetVisArea() );
528 SwEditWin& rTmpWin = GetEditWin();
529 if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
530 PageUpCrsr(FN_PAGEUP_SEL == nSlot);
531 else
532 PageDownCrsr(FN_PAGEDOWN_SEL == nSlot);
534 rReq.SetReturnValue(SfxBoolItem(nSlot,
535 aVis != GetVisArea()));
536 //#i42732# - notify the edit window that from now on we do not use the input language
537 rTmpWin.SetUseInputLanguage( sal_False );
539 break;
540 case FN_REDLINE_ON:
542 if( pArgs &&
543 SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem ))
545 IDocumentRedlineAccess* pIDRA = m_pWrtShell->getIDocumentRedlineAccess();
546 Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
547 if( aPasswd.getLength() )
549 OSL_ENSURE( !((const SfxBoolItem*)pItem)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" );
550 // xmlsec05: new password dialog
551 Window* pParent;
552 const SfxPoolItem* pParentItem;
553 if( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, sal_False, &pParentItem ) )
554 pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
555 else
556 pParent = &GetViewFrame()->GetWindow();
557 SfxPasswordDialog aPasswdDlg( pParent );
558 aPasswdDlg.SetMinLen( 1 );
559 //#i69751# the result of Execute() can be ignored
560 aPasswdDlg.Execute();
561 String sNewPasswd( aPasswdDlg.GetPassword() );
562 Sequence <sal_Int8> aNewPasswd = pIDRA->GetRedlinePassword();
563 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
564 if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
565 pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
566 else
567 { // xmlsec05: message box for wrong password
568 break;
572 sal_uInt16 nOn = ((const SfxBoolItem*)pItem)->GetValue() ? nsRedlineMode_t::REDLINE_ON : 0;
573 sal_uInt16 nMode = m_pWrtShell->GetRedlineMode();
574 m_pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
577 break;
578 case FN_REDLINE_PROTECT :
580 IDocumentRedlineAccess* pIDRA = m_pWrtShell->getIDocumentRedlineAccess();
581 Sequence <sal_Int8> aPasswd = pIDRA->GetRedlinePassword();
582 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem )
583 && ((SfxBoolItem*)pItem)->GetValue() == ( aPasswd.getLength() != 0 ) )
584 break;
586 // xmlsec05: new password dialog
587 // message box for wrong password
588 Window* pParent;
589 const SfxPoolItem* pParentItem;
590 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_XWINDOW, sal_False, &pParentItem ) )
591 pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
592 else
593 pParent = &GetViewFrame()->GetWindow();
594 SfxPasswordDialog aPasswdDlg( pParent );
595 aPasswdDlg.SetMinLen( 1 );
596 if(!aPasswd.getLength())
597 aPasswdDlg.ShowExtras(SHOWEXTRAS_CONFIRM);
598 if (aPasswdDlg.Execute())
600 sal_uInt16 nOn = nsRedlineMode_t::REDLINE_ON;
601 String sNewPasswd( aPasswdDlg.GetPassword() );
602 Sequence <sal_Int8> aNewPasswd =
603 pIDRA->GetRedlinePassword();
604 SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
605 if(!aPasswd.getLength())
607 pIDRA->SetRedlinePassword(aNewPasswd);
609 else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
611 pIDRA->SetRedlinePassword(Sequence <sal_Int8> ());
612 nOn = 0;
614 sal_uInt16 nMode = pIDRA->GetRedlineMode();
615 m_pWrtShell->SetRedlineModeAndCheckInsMode( (nMode & ~nsRedlineMode_t::REDLINE_ON) | nOn);
616 rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, ((nMode&nsRedlineMode_t::REDLINE_ON)==0) ) );
618 else
619 bIgnore = sal_True;
621 break;
622 case FN_REDLINE_SHOW:
624 if( pArgs &&
625 SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem))
627 sal_uInt16 nMode = ( ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)
628 & m_pWrtShell->GetRedlineMode() ) | nsRedlineMode_t::REDLINE_SHOW_INSERT;
629 if( ((const SfxBoolItem*)pItem)->GetValue() )
630 nMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
632 m_pWrtShell->SetRedlineModeAndCheckInsMode( nMode );
634 break;
635 case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
636 case FN_REDLINE_ACCEPT:
637 GetViewFrame()->ToggleChildWindow(nSlot);
638 break;
639 case FN_REDLINE_ACCEPT_DIRECT:
640 case FN_REDLINE_REJECT_DIRECT:
642 // We check for a redline at the start of the selection/cursor, not the point.
643 // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the
644 // point at the *end* of the redline and the mark at the start (so GetRedline
645 // would return NULL if called on the point)
646 SwDoc *pDoc = m_pWrtShell->GetDoc();
647 SwPaM *pCursor = m_pWrtShell->GetCrsr();
649 sal_uInt16 nRedline = 0;
650 const SwRedline *pRedline = pDoc->GetRedline(*pCursor->Start(), &nRedline);
651 assert(pRedline != 0);
652 if (pRedline)
654 if (FN_REDLINE_ACCEPT_DIRECT == nSlot)
655 m_pWrtShell->AcceptRedline(nRedline);
656 else
657 m_pWrtShell->RejectRedline(nRedline);
660 break;
662 case FN_REDLINE_NEXT_CHANGE:
664 const SwRedline *pCurrent = m_pWrtShell->GetCurrRedline();
665 const SwRedline *pNext = m_pWrtShell->SelNextRedline();
667 // FN_REDLINE_PREV_CHANGE leaves the selection point at the start of the redline.
668 // In such cases, SelNextRedline (which starts searching from the selection point)
669 // immediately finds the current redline and advances the selection point to its end.
671 // This behavior means that PREV_CHANGE followed by NEXT_CHANGE would not change
672 // the current redline, so we detect it and select the next redline again.
673 if (pCurrent && pCurrent == pNext)
674 pNext = m_pWrtShell->SelNextRedline();
676 if (pNext)
677 m_pWrtShell->SetInSelect();
679 break;
681 case FN_REDLINE_PREV_CHANGE:
683 const SwPaM *pCursor = m_pWrtShell->GetCrsr();
684 const SwPosition initialCursorStart = *pCursor->Start();
685 const SwRedline *pPrev = m_pWrtShell->SelPrevRedline();
687 if (pPrev)
689 // FN_REDLINE_NEXT_CHANGE leaves the selection point at the end of the redline.
690 // In such cases, SelPrevRedline (which starts searching from the selection point)
691 // immediately finds the current redline and advances the selection point to its
692 // start.
694 // This behavior means that NEXT_CHANGE followed by PREV_CHANGE would not change
695 // the current redline, so we detect it and move to the previous redline again.
696 if (initialCursorStart == *pPrev->Start())
697 pPrev = m_pWrtShell->SelPrevRedline();
700 if (pPrev)
701 m_pWrtShell->SetInSelect();
703 break;
705 case SID_DOCUMENT_COMPARE:
706 case SID_DOCUMENT_MERGE:
708 String sFileName, sFilterName;
709 sal_Int16 nVersion = 0;
710 bool bHasFileName = false;
711 m_pViewImpl->SetParam( 0 );
713 if( pArgs )
715 if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILE_NAME, sal_False, &pItem ))
716 sFileName = ((const SfxStringItem*)pItem)->GetValue();
717 bHasFileName = ( sFileName.Len() > 0 );
719 if( SFX_ITEM_SET == pArgs->GetItemState( SID_FILTER_NAME, sal_False, &pItem ))
720 sFilterName = ((const SfxStringItem*)pItem)->GetValue();
722 if( SFX_ITEM_SET == pArgs->GetItemState( SID_VERSION, sal_False, &pItem ))
724 nVersion = ((const SfxInt16Item *)pItem)->GetValue();
725 m_pViewImpl->SetParam( nVersion );
729 m_pViewImpl->InitRequest( rReq );
730 long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion );
732 if ( bHasFileName )
734 rReq.SetReturnValue( SfxInt32Item( nSlot, nFound ));
736 if (nFound > 0) // Redline-Browser anzeigen
738 SfxViewFrame* pVFrame = GetViewFrame();
739 pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
741 // RedlineDlg neu initialisieren
742 sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
743 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)
744 pVFrame->GetChildWindow(nId);
745 if (pRed)
746 pRed->ReInitDlg(GetDocShell());
749 else
750 bIgnore = sal_True;
752 break;
753 case FN_SYNC_LABELS:
754 case FN_MAILMERGE_CHILDWINDOW:
755 GetViewFrame()->ShowChildWindow(nSlot, sal_True);
756 break;
757 case FN_ESCAPE:
759 if ( m_pWrtShell->HasDrawView() && m_pWrtShell->GetDrawView()->IsDragObj() )
761 m_pWrtShell->BreakDrag();
762 m_pWrtShell->EnterSelFrmMode();
764 else if ( m_pWrtShell->IsDrawCreate() )
766 GetDrawFuncPtr()->BreakCreate();
767 AttrChangedNotify(m_pWrtShell); // ggf Shellwechsel...
769 else if ( m_pWrtShell->HasSelection() || IsDrawMode() )
771 SdrView *pSdrView = m_pWrtShell->HasDrawView() ? m_pWrtShell->GetDrawView() : 0;
772 if(pSdrView && pSdrView->AreObjectsMarked() &&
773 pSdrView->GetHdlList().GetFocusHdl())
775 ((SdrHdlList&)pSdrView->GetHdlList()).ResetFocusHdl();
777 else
779 if(pSdrView)
781 LeaveDrawCreate();
782 Point aPt(LONG_MIN, LONG_MIN);
783 //go out of the frame
784 m_pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME);
785 SfxBindings& rBind = GetViewFrame()->GetBindings();
786 rBind.Invalidate( SID_ATTR_SIZE );
788 m_pWrtShell->EnterStdMode();
789 AttrChangedNotify(m_pWrtShell); // ggf Shellwechsel...
792 else if ( GetEditWin().GetApplyTemplate() )
794 GetEditWin().SetApplyTemplate(SwApplyTemplate());
796 else if( ((SfxObjectShell*)GetDocShell())->IsInPlaceActive() )
798 Escape();
800 else if ( GetEditWin().IsChainMode() )
802 GetEditWin().SetChainMode( sal_False );
804 else if( m_pWrtShell->GetFlyFrmFmt() )
806 const SwFrmFmt* pFmt = m_pWrtShell->GetFlyFrmFmt();
807 if(m_pWrtShell->GotoFly( pFmt->GetName(), FLYCNTTYPE_FRM ))
809 m_pWrtShell->HideCrsr();
810 m_pWrtShell->EnterSelFrmMode();
813 else
815 SfxBoolItem aItem( SID_WIN_FULLSCREEN, sal_False );
816 GetViewFrame()->GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SFX_CALLMODE_RECORD, &aItem, 0L );
817 bIgnore = sal_True;
820 break;
821 case SID_ATTR_BORDER_INNER:
822 case SID_ATTR_BORDER_OUTER:
823 case SID_ATTR_BORDER_SHADOW:
824 if(pArgs)
825 m_pWrtShell->SetAttr(*pArgs);
826 break;
828 case SID_ATTR_PAGE:
829 case SID_ATTR_PAGE_SIZE:
830 case SID_ATTR_PAGE_MAXSIZE:
831 case SID_ATTR_PAGE_PAPERBIN:
832 case SID_ATTR_PAGE_EXT1:
833 case FN_PARAM_FTN_INFO:
835 if(pArgs)
837 const sal_uInt16 nCurIdx = m_pWrtShell->GetCurPageDesc();
838 SwPageDesc aPageDesc( m_pWrtShell->GetPageDesc( nCurIdx ) );
839 ::ItemSetToPageDesc( *pArgs, aPageDesc );
840 // Den Descriptor der Core veraendern.
841 m_pWrtShell->ChgPageDesc( nCurIdx, aPageDesc );
844 break;
845 case FN_NAVIGATION_PI_GOTO_PAGE:
847 SfxViewFrame* pVFrame = GetViewFrame();
848 SfxChildWindow* pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
849 if(!pCh)
851 pVFrame->ToggleChildWindow( SID_NAVIGATOR );
852 pCh = pVFrame->GetChildWindow( SID_NAVIGATOR );
855 ((SwNavigationPI*) pCh->GetContextWindow(SW_MOD()))->GotoPage();
857 break;
858 case FN_EDIT_CURRENT_TOX:
860 GetViewFrame()->GetDispatcher()->Execute(
861 FN_INSERT_MULTI_TOX, SFX_CALLMODE_ASYNCHRON);
863 break;
864 case FN_UPDATE_CUR_TOX:
866 const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
867 if(pBase)
869 m_pWrtShell->StartAction();
870 if(TOX_INDEX == pBase->GetType())
871 m_pWrtShell->ApplyAutoMark();
872 m_pWrtShell->UpdateTableOf( *pBase );
873 m_pWrtShell->EndAction();
876 break;
877 case FN_UPDATE_TOX:
879 m_pWrtShell->StartAction();
880 m_pWrtShell->EnterStdMode();
881 sal_Bool bOldCrsrInReadOnly = m_pWrtShell->IsReadOnlyAvailable();
882 m_pWrtShell->SetReadOnlyAvailable( sal_True );
884 for( sal_uInt16 i = 0; i < 2; ++i )
886 sal_uInt16 nCount = m_pWrtShell->GetTOXCount();
887 if( 1 == nCount )
888 ++i;
890 while( m_pWrtShell->GotoPrevTOXBase() )
891 ; // aufs erste Verzeichnis springen
893 // falls wir nicht mehr in einem stehen, dann zum naechsten
894 // springen.
895 const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
896 if( !pBase )
898 m_pWrtShell->GotoNextTOXBase();
899 pBase = m_pWrtShell->GetCurTOX();
902 sal_Bool bAutoMarkApplied = sal_False;
903 while( pBase )
905 if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
907 m_pWrtShell->ApplyAutoMark();
908 bAutoMarkApplied = sal_True;
910 // das pBase wird nur fuer die Schnittstelle
911 // benoetigt. Muss mal umgetstellt werden!!!
912 m_pWrtShell->UpdateTableOf( *pBase );
914 if( m_pWrtShell->GotoNextTOXBase() )
915 pBase = m_pWrtShell->GetCurTOX();
916 else
917 pBase = 0;
920 m_pWrtShell->SetReadOnlyAvailable( bOldCrsrInReadOnly );
921 m_pWrtShell->EndAction();
923 break;
924 case SID_ATTR_BRUSH:
926 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_BACKGROUND, sal_False, &pItem))
928 const sal_uInt16 nCurIdx = m_pWrtShell->GetCurPageDesc();
929 SwPageDesc aDesc( m_pWrtShell->GetPageDesc( nCurIdx ));
930 SwFrmFmt& rMaster = aDesc.GetMaster();
931 rMaster.SetFmtAttr(*pItem);
932 m_pWrtShell->ChgPageDesc( nCurIdx, aDesc);
935 break;
936 case SID_CLEARHISTORY:
938 m_pWrtShell->DelAllUndoObj();
940 break;
941 case SID_UNDO:
943 m_pShell->ExecuteSlot(rReq);
945 break;
946 case FN_INSERT_CTRL:
947 case FN_INSERT_OBJ_CTRL:
949 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem))
951 sal_uInt16 nValue = ((SfxUInt16Item*)pItem)->GetValue();
952 switch ( nSlot )
954 case FN_INSERT_CTRL:
956 sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
957 if(bWeb)
958 SwView::m_nWebInsertCtrlState = nValue;
959 else
960 SwView::m_nInsertCtrlState = nValue;
962 break;
963 case FN_INSERT_OBJ_CTRL: SwView::m_nInsertObjectCtrlState = nValue ;break;
967 GetViewFrame()->GetBindings().Invalidate( nSlot );
969 break;
970 #if defined WNT || defined UNX
971 case SID_TWAIN_SELECT:
972 case SID_TWAIN_TRANSFER:
973 GetViewImpl()->ExecuteScan( rReq );
974 break;
975 #endif
977 case SID_ATTR_DEFTABSTOP:
979 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, sal_False, &pItem))
981 SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
982 sal_uInt16 nTab = ((const SfxUInt16Item*)pItem)->GetValue();
983 MakeDefTabs( nTab, aDefTabs );
984 m_pWrtShell->SetDefault( aDefTabs );
987 break;
988 case SID_ATTR_LANGUAGE :
989 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, sal_False, &pItem))
991 SvxLanguageItem aLang(((SvxLanguageItem*)pItem)->GetLanguage(), RES_CHRATR_LANGUAGE);
992 m_pWrtShell->SetDefault( aLang );
993 lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_LANGUAGE );
995 break;
996 case SID_ATTR_CHAR_CTL_LANGUAGE:
997 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, sal_False, &pItem))
999 m_pWrtShell->SetDefault( *pItem );
1000 lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_CTL_LANGUAGE );
1002 break;
1003 case SID_ATTR_CHAR_CJK_LANGUAGE:
1004 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, sal_False, &pItem))
1006 m_pWrtShell->SetDefault( *pItem );
1007 lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_CJK_LANGUAGE );
1009 break;
1010 case FN_SCROLL_NEXT_PREV:
1011 if(pArgs && pArgs->GetItemState(FN_SCROLL_NEXT_PREV, sal_False, &pItem))
1013 // call the handlers of PageUp/DownButtons, only
1014 bool* pbNext = new bool ( ((const SfxBoolItem*)pItem)->GetValue() );
1015 // #i75416# move the execution of the search to an asynchronously called static link
1016 Application::PostUserEvent( STATIC_LINK(this, SwView, MoveNavigationHdl), pbNext );
1018 break;
1019 case SID_JUMPTOMARK:
1020 if( pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_JUMPTOMARK, sal_False, &pItem))
1021 JumpToSwMark( (( const SfxStringItem*)pItem)->GetValue() );
1022 break;
1023 case SID_GALLERY :
1024 GetViewFrame()->ChildWindowExecute(rReq);
1025 break;
1026 case SID_AVMEDIA_PLAYER :
1027 GetViewFrame()->ChildWindowExecute(rReq);
1028 break;
1029 case SID_VIEW_DATA_SOURCE_BROWSER:
1031 SfxViewFrame* pVFrame = GetViewFrame();
1032 pVFrame->ChildWindowExecute(rReq);
1033 if(pVFrame->HasChildWindow(SID_BROWSER))
1035 const SwDBData& rData = GetWrtShell().GetDBDesc();
1036 SW_MOD()->ShowDBObj(*this, rData, sal_False);
1039 break;
1040 case FN_INSERT_FIELD_DATA_ONLY :
1042 sal_Bool bShow = sal_False;
1043 if( pArgs &&
1044 SFX_ITEM_SET == pArgs->GetItemState(nSlot, sal_False, &pItem ))
1045 bShow = ((const SfxBoolItem*)pItem)->GetValue();
1046 if((bShow && m_bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot))
1047 GetViewFrame()->ToggleChildWindow(nSlot);
1048 //if fields have been successfully inserted call the "real"
1049 //mail merge dialog
1050 SwWrtShell &rSh = GetWrtShell();
1051 if(m_bInMailMerge && rSh.IsAnyDatabaseFieldInDoc())
1053 SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
1054 if (pNewDBMgr)
1056 SwDBData aData;
1057 aData = rSh.GetDBData();
1058 rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
1059 // das Mischen von DB-Feldern notwendig.
1060 AttrChangedNotify( &rSh );
1061 pNewDBMgr->SetMergeType( DBMGR_MERGE );
1063 Sequence<PropertyValue> aProperties(3);
1064 PropertyValue* pValues = aProperties.getArray();
1065 pValues[0].Name = "DataSourceName";
1066 pValues[1].Name = "Command";
1067 pValues[2].Name = "CommandType";
1068 pValues[0].Value <<= aData.sDataSource;
1069 pValues[1].Value <<= aData.sCommand;
1070 pValues[2].Value <<= aData.nCommandType;
1071 pNewDBMgr->ExecuteFormLetter(rSh, aProperties, sal_True);
1074 m_bInMailMerge &= bShow;
1075 GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD);
1077 break;
1078 case FN_QRY_MERGE:
1080 sal_Bool bUseCurrentDocument = sal_True;
1081 sal_Bool bQuery = !pArgs||SFX_ITEM_SET != pArgs->GetItemState(nSlot);
1082 if(bQuery)
1084 SfxViewFrame* pTmpFrame = GetViewFrame();
1085 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1086 OSL_ENSURE(pFact, "Dialogdiet fail!");
1087 AbstractMailMergeCreateFromDlg* pDlg = pFact->CreateMailMergeCreateFromDlg( DLG_MERGE_CREATE,
1088 &pTmpFrame->GetWindow());
1089 OSL_ENSURE(pDlg, "Dialogdiet fail!");
1090 if(RET_OK == pDlg->Execute())
1091 bUseCurrentDocument = pDlg->IsThisDocument();
1092 else
1093 break;
1095 GenerateFormLetter(bUseCurrentDocument);
1097 break;
1098 case SID_RECHECK_DOCUMENT:
1100 SwDocShell* pDocShell = GetDocShell();
1101 SwDoc* pDoc = pDocShell->GetDoc();
1102 uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() );
1103 if( xGCIterator.is() )
1105 xGCIterator->resetIgnoreRules();
1107 // reset ignore lists
1108 pDoc->SpellItAgainSam( true, false, false );
1109 // clear ignore dictionary
1110 uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY );
1111 if( xDictionary.is() )
1112 xDictionary->clear();
1113 // put cursor to the start of the document
1114 m_pWrtShell->SttDoc();
1116 // no break; - but call spell/grammar dialog
1117 case FN_SPELL_GRAMMAR_DIALOG:
1119 SfxViewFrame* pViewFrame = GetViewFrame();
1120 if (rReq.GetArgs() != NULL)
1121 pViewFrame->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG,
1122 ((const SfxBoolItem&) (rReq.GetArgs()->
1123 Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue());
1124 else
1125 pViewFrame->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG);
1127 pViewFrame->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG);
1128 rReq.Ignore ();
1130 break;
1131 case SID_ALIGN_ANY_LEFT :
1132 case SID_ALIGN_ANY_HCENTER :
1133 case SID_ALIGN_ANY_RIGHT :
1134 case SID_ALIGN_ANY_JUSTIFIED:
1135 case SID_ALIGN_ANY_TOP :
1136 case SID_ALIGN_ANY_VCENTER :
1137 case SID_ALIGN_ANY_BOTTOM :
1138 case SID_ALIGN_ANY_HDEFAULT :
1139 case SID_ALIGN_ANY_VDEFAULT :
1141 sal_uInt16 nAlias = 0;
1142 if( m_nSelectionType & (nsSelectionType::SEL_DRW_TXT|nsSelectionType::SEL_TXT) )
1144 switch( nSlot )
1146 case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
1147 case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
1148 case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
1149 case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
1150 case SID_ALIGN_ANY_TOP : nAlias = SID_TABLE_VERT_NONE; break;
1151 case SID_ALIGN_ANY_VCENTER : nAlias = SID_TABLE_VERT_CENTER; break;
1152 case SID_ALIGN_ANY_BOTTOM : nAlias = SID_TABLE_VERT_BOTTOM; break;
1155 else
1157 switch( nSlot )
1159 case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break;
1160 case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break;
1161 case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break;
1162 case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break;
1163 case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break;
1164 case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break;
1167 //special handling for the draw shell
1168 if(nAlias && (m_nSelectionType & (nsSelectionType::SEL_DRW)))
1170 SfxAllEnumItem aEnumItem(SID_OBJECT_ALIGN, nAlias - SID_OBJECT_ALIGN_LEFT);
1171 GetViewFrame()->GetDispatcher()->Execute(
1172 SID_OBJECT_ALIGN, SFX_CALLMODE_ASYNCHRON, &aEnumItem, 0L);
1174 else if(nAlias)
1175 //these slots are either re-mapped to text or object alignment
1176 GetViewFrame()->GetDispatcher()->Execute(
1177 nAlias, SFX_CALLMODE_ASYNCHRON);
1179 break;
1180 case SID_RESTORE_EDITING_VIEW:
1182 //#i33307# restore editing position
1183 Point aCrsrPos;
1184 bool bSelectObj;
1185 if(m_pViewImpl->GetRestorePosition(aCrsrPos, bSelectObj))
1187 m_pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1188 if( bSelectObj )
1190 m_pWrtShell->SelectObj( aCrsrPos );
1191 m_pWrtShell->EnterSelFrmMode( &aCrsrPos );
1195 break;
1196 case SID_INSERT_GRAPHIC:
1198 rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq )));
1200 break;
1203 default:
1204 OSL_ENSURE(!this, "wrong dispatcher");
1205 return;
1207 if(!bIgnore)
1208 rReq.Done();
1211 /*--------------------------------------------------------------------
1212 Beschreibung: SeitenNr-Feld invalidieren
1213 --------------------------------------------------------------------*/
1214 void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const String& rPgStr)
1216 String sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr ));
1217 const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
1218 SfxBindings &rBnd = GetViewFrame()->GetBindings();
1219 rBnd.SetState( aTmp );
1220 rBnd.Update( FN_STAT_PAGE );
1223 void SwView::UpdateDocStats()
1225 SfxBindings &rBnd = GetViewFrame()->GetBindings();
1226 rBnd.Invalidate( FN_STAT_WORDCOUNT );
1227 rBnd.Update( FN_STAT_WORDCOUNT );
1230 void SwView::SetAnnotationMode(bool bMode)
1232 m_bAnnotationMode = bMode;
1235 /*--------------------------------------------------------------------
1236 Beschreibung: Status der Stauszeile
1237 --------------------------------------------------------------------*/
1238 void SwView::StateStatusLine(SfxItemSet &rSet)
1240 SwWrtShell& rShell = GetWrtShell();
1242 SfxWhichIter aIter( rSet );
1243 sal_uInt16 nWhich = aIter.FirstWhich();
1244 OSL_ENSURE( nWhich, "empty set");
1246 while( nWhich )
1248 switch( nWhich )
1250 case FN_STAT_PAGE: {
1251 // Anzahl der Seiten, log. SeitenNr. SeitenNr ermitteln
1252 sal_uInt16 nPage, nLogPage;
1253 String sDisplay;
1254 rShell.GetPageNumber( -1, rShell.IsCrsrVisible(), nPage, nLogPage, sDisplay );
1255 rSet.Put( SfxStringItem( FN_STAT_PAGE,
1256 GetPageStr( nPage, nLogPage, sDisplay) ));
1258 sal_uInt16 nCnt = GetWrtShell().GetPageCnt();
1259 if (m_nPageCnt != nCnt) // Basic benachrichtigen
1261 m_nPageCnt = nCnt;
1262 SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), sal_False);
1265 break;
1267 case FN_STAT_WORDCOUNT:
1269 SwDocStat selectionStats;
1270 SwDocStat documentStats;
1272 rShell.CountWords(selectionStats);
1273 documentStats = rShell.GetDoc()->GetUpdatedDocStat( true /* complete-async */, false /* don't update fields */ );
1276 const sal_uInt32 stringId = selectionStats.nWord? STR_STATUSBAR_WORDCOUNT : STR_STATUSBAR_WORDCOUNT_NO_SELECTION;
1277 OUString wordCount(SW_RES(stringId));
1278 wordCount = wordCount.replaceAll("$1", OUString::number(documentStats.nWord));
1279 wordCount = wordCount.replaceAll("$2", OUString::number(documentStats.nChar));
1280 if (selectionStats.nWord)
1282 wordCount = wordCount.replaceAll("$3", OUString::number(selectionStats.nWord));
1283 wordCount = wordCount.replaceAll("$4", OUString::number(selectionStats.nChar));
1285 rSet.Put(SfxStringItem(FN_STAT_WORDCOUNT, wordCount));
1287 SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
1288 if (pWrdCnt)
1289 pWrdCnt->SetCounts(selectionStats, documentStats);
1291 break;
1293 case FN_STAT_TEMPLATE:
1295 rSet.Put(SfxStringItem( FN_STAT_TEMPLATE,
1296 rShell.GetCurPageStyle(sal_False)));
1299 break;
1300 case SID_ATTR_ZOOM:
1302 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1304 const SwViewOption* pVOpt = rShell.GetViewOptions();
1305 SvxZoomType eZoom = (SvxZoomType) pVOpt->GetZoomType();
1306 SvxZoomItem aZoom(eZoom,
1307 pVOpt->GetZoom());
1308 if( pVOpt->getBrowseMode() )
1310 aZoom.SetValueSet(
1311 SVX_ZOOM_ENABLE_50|
1312 SVX_ZOOM_ENABLE_75|
1313 SVX_ZOOM_ENABLE_100|
1314 SVX_ZOOM_ENABLE_150|
1315 SVX_ZOOM_ENABLE_200);
1317 rSet.Put( aZoom );
1319 else
1320 rSet.DisableItem( SID_ATTR_ZOOM );
1322 break;
1323 case SID_ATTR_VIEWLAYOUT:
1325 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1327 const SwViewOption* pVOpt = rShell.GetViewOptions();
1328 const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
1329 const bool bBookMode = pVOpt->IsViewLayoutBookMode();
1330 SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
1331 rSet.Put( aViewLayout );
1333 else
1334 rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
1336 break;
1337 case SID_ATTR_ZOOMSLIDER:
1339 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1341 const SwViewOption* pVOpt = rShell.GetViewOptions();
1342 const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
1343 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
1344 aZoomSliderItem.AddSnappingPoint( 100 );
1346 if ( !m_pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
1348 const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
1349 const bool bAutomaticViewLayout = 0 == nColumns;
1350 const SwPostItMgr* pMgr = GetPostItMgr();
1352 // snapping points:
1353 // automatic mode: 1 Page, 2 Pages, 100%
1354 // n Columns mode: n Pages, 100%
1355 // n Columns book mode: nPages without gaps, 100%
1356 const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( RECT_PAGE_CALC ) );
1357 const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( RECT_PAGES_AREA ) ); // width of columns
1358 Size aPageSize( aPageRect.SSize() );
1359 aPageSize.Width() += pMgr->HasNotes() && pMgr->ShowNotes() ?
1360 pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() :
1363 Size aRootSize( aRootRect.SSize() );
1365 const MapMode aTmpMap( MAP_TWIP );
1366 const Size& rEditSize = GetEditWin().GetOutputSizePixel();
1367 const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
1369 const long nOf = DOCUMENTBORDER * 2L;
1370 long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
1371 nTmpWidth += nOf;
1372 aPageSize.Height() += nOf;
1373 long nFac = aWindowSize.Width() * 100 / nTmpWidth;
1375 long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
1376 nFac = std::min( nFac, nVisPercent );
1378 aZoomSliderItem.AddSnappingPoint( nFac );
1380 if ( bAutomaticViewLayout )
1382 nTmpWidth += aPageSize.Width() + GAPBETWEENPAGES;
1383 nFac = aWindowSize.Width() * 100 / nTmpWidth;
1384 nFac = std::min( nFac, nVisPercent );
1385 aZoomSliderItem.AddSnappingPoint( nFac );
1389 rSet.Put( aZoomSliderItem );
1391 else
1392 rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1394 break;
1395 case SID_ATTR_POSITION:
1396 case SID_ATTR_SIZE:
1398 if( !rShell.IsFrmSelected() && !rShell.IsObjSelected() )
1399 SwBaseShell::_SetFrmMode( FLY_DRAG_END );
1400 else
1402 FlyMode eFrameMode = SwBaseShell::GetFrmMode();
1403 if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG )
1405 if ( nWhich == SID_ATTR_POSITION )
1406 rSet.Put( SfxPointItem( SID_ATTR_POSITION,
1407 rShell.GetAnchorObjDiff()));
1408 else
1409 rSet.Put( SvxSizeItem( SID_ATTR_SIZE,
1410 rShell.GetObjSize()));
1414 break;
1415 case SID_TABLE_CELL:
1417 if( rShell.IsFrmSelected() || rShell.IsObjSelected() )
1419 // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
1420 // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
1421 // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
1422 // in SID_ATTR_SIZE).
1424 else
1426 String sStr;
1427 if( rShell.IsCrsrInTbl() )
1429 // table name + cell coordinate
1430 sStr = rShell.GetTableFmt()->GetName();
1431 sStr += ':';
1432 sStr += rShell.GetBoxNms();
1434 else
1436 const SwSection* pCurrSect = rShell.GetCurrSection();
1437 if( pCurrSect )
1439 switch( pCurrSect->GetType() )
1441 case TOX_HEADER_SECTION:
1442 case TOX_CONTENT_SECTION:
1444 const SwTOXBase* pTOX = m_pWrtShell->GetCurTOX();
1445 if( pTOX )
1446 sStr = pTOX->GetTOXName();
1447 else
1449 OSL_ENSURE( !this,
1450 "was ist das fuer ein Verzeichnis?" );
1451 sStr = pCurrSect->GetSectionName();
1454 break;
1455 default:
1456 sStr = pCurrSect->GetSectionName();
1457 break;
1461 //-->#outline level,added by zhaojianwei
1462 const SwNumRule* pNumRule = rShell.GetCurNumRule();
1463 const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0;
1465 if (pNumRule && !bOutlineNum ) // Cursor in Numerierung
1467 sal_uInt8 nNumLevel = rShell.GetNumLevel();
1468 if ( nNumLevel < MAXLEVEL )
1470 if(!pNumRule->IsAutoRule())
1472 SfxItemSet aSet(GetPool(),
1473 RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
1474 rShell.GetCurAttr(aSet);
1475 if(SFX_ITEM_AVAILABLE <=
1476 aSet.GetItemState(RES_PARATR_NUMRULE, sal_True))
1478 const String& rNumStyle =
1479 ((const SfxStringItem &)
1480 aSet.Get(RES_PARATR_NUMRULE)).GetValue();
1481 if(rNumStyle.Len())
1483 if( sStr.Len() )
1484 sStr.AppendAscii(sStatusDelim);
1485 sStr += rNumStyle;
1489 if( sStr.Len() )
1490 sStr.AppendAscii(sStatusDelim);
1491 sStr += SW_RESSTR(STR_NUM_LEVEL);
1492 sStr += OUString::number( nNumLevel + 1 );
1496 const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
1497 if( nOutlineLevel != 0 )
1499 if( sStr.Len() )
1500 sStr.AppendAscii(sStatusComma);
1501 if( bOutlineNum )
1503 sStr += SW_RESSTR(STR_OUTLINE_NUMBERING);
1504 sStr.AppendAscii(sStatusDelim);
1505 sStr += SW_RESSTR(STR_NUM_LEVEL);
1507 else
1508 sStr += SW_RESSTR(STR_NUM_OUTLINE);
1509 sStr += OUString::number( nOutlineLevel);
1511 //<-end ,zhaojianwei
1513 if( rShell.HasReadonlySel() )
1515 if( sStr.Len() )
1516 sStr.InsertAscii( sStatusDelim, 0 );
1517 sStr.Insert( SW_RESSTR(SW_STR_READONLY), 0 );
1519 if( sStr.Len() )
1520 rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
1522 break;
1523 case FN_STAT_SELMODE:
1525 if(rShell.IsStdMode())
1526 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
1527 else if(rShell.IsAddMode())
1528 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2));
1529 else if(rShell.IsBlockMode())
1530 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3));
1531 else
1532 rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1));
1533 break;
1535 case SID_ATTR_INSERT:
1536 if( rShell.IsRedlineOn() )
1537 rSet.DisableItem( nWhich );
1538 else
1540 rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
1542 break;
1544 nWhich = aIter.NextWhich();
1548 /*--------------------------------------------------------------------
1549 Beschreibung: Execute fuer die Stauszeile
1550 --------------------------------------------------------------------*/
1551 void SwView::ExecuteStatusLine(SfxRequest &rReq)
1553 SwWrtShell &rSh = GetWrtShell();
1554 const SfxItemSet* pArgs = rReq.GetArgs();
1555 const SfxPoolItem* pItem=NULL;
1556 sal_Bool bUp = sal_False;
1557 sal_uInt16 nWhich = rReq.GetSlot();
1558 switch( nWhich )
1560 case FN_STAT_PAGE:
1562 GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR,
1563 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1565 break;
1567 case FN_STAT_WORDCOUNT:
1569 GetViewFrame()->GetDispatcher()->Execute(FN_WORDCOUNT_DIALOG,
1570 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1572 break;
1574 case FN_STAT_BOOKMARK:
1575 if ( pArgs )
1577 if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_True, &pItem))
1579 const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
1580 const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1581 if(nIdx < pMarkAccess->getBookmarksCount())
1583 const IDocumentMarkAccess::const_iterator_t ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx;
1584 rSh.EnterStdMode();
1585 rSh.GotoMark( ppBookmark->get() );
1587 else
1588 OSL_FAIL("SwView::ExecuteStatusLine(..)"
1589 " - Ignoring out of range bookmark index");
1592 break;
1594 case FN_STAT_TEMPLATE:
1596 GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
1597 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
1599 break;
1600 case SID_ATTR_ZOOM:
1602 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1604 const SfxItemSet *pSet = 0;
1605 AbstractSvxZoomDialog *pDlg = 0;
1606 if ( pArgs )
1607 pSet = pArgs;
1608 else
1610 const SwViewOption& rViewOptions = *rSh.GetViewOptions();
1611 SfxItemSet aCoreSet(m_pShell->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM, SID_ATTR_VIEWLAYOUT, SID_ATTR_VIEWLAYOUT, 0 );
1612 SvxZoomItem aZoom( (SvxZoomType)rViewOptions.GetZoomType(), rViewOptions.GetZoom() );
1614 const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode();
1615 if( bBrowseMode )
1617 aZoom.SetValueSet(
1618 SVX_ZOOM_ENABLE_50|
1619 SVX_ZOOM_ENABLE_75|
1620 SVX_ZOOM_ENABLE_100|
1621 SVX_ZOOM_ENABLE_150|
1622 SVX_ZOOM_ENABLE_200);
1624 aCoreSet.Put( aZoom );
1626 if ( !bBrowseMode )
1628 const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
1629 aCoreSet.Put( aViewLayout );
1632 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1633 if(pFact)
1635 pDlg = pFact->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet);
1636 OSL_ENSURE(pDlg, "Dialogdiet fail!");
1637 if (pDlg)
1639 pDlg->SetLimits( MINZOOM, MAXZOOM );
1640 if( pDlg->Execute() != RET_CANCEL )
1641 pSet = pDlg->GetOutputItemSet();
1646 const SfxPoolItem* pViewLayoutItem = 0;
1647 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, sal_True, &pViewLayoutItem))
1649 const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pViewLayoutItem)->GetValue();
1650 const bool bBookMode = ((const SvxViewLayoutItem *)pViewLayoutItem)->IsBookMode();
1651 SetViewLayout( nColumns, bBookMode );
1654 if ( pSet && SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_ZOOM, sal_True, &pItem))
1656 enum SvxZoomType eType = ((const SvxZoomItem *)pItem)->GetType();
1657 SetZoom( eType, ((const SvxZoomItem *)pItem)->GetValue() );
1659 bUp = sal_True;
1660 if ( pItem )
1661 rReq.AppendItem( *pItem );
1662 rReq.Done();
1664 delete pDlg;
1667 break;
1669 case SID_ATTR_VIEWLAYOUT:
1671 if ( pArgs && !rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) &&
1672 ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1674 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, sal_True, &pItem ))
1676 const sal_uInt16 nColumns = ((const SvxViewLayoutItem *)pItem)->GetValue();
1677 const bool bBookMode = (0 == nColumns || 0 != (nColumns % 2)) ?
1678 false :
1679 ((const SvxViewLayoutItem *)pItem)->IsBookMode();
1681 SetViewLayout( nColumns, bBookMode );
1684 bUp = sal_True;
1685 rReq.Done();
1687 InvalidateRulerPos();
1690 break;
1692 case SID_ATTR_ZOOMSLIDER:
1694 if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1696 if ( SFX_ITEM_SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, sal_True, &pItem ))
1698 const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
1699 SetZoom( SVX_ZOOM_PERCENT, nCurrentZoom );
1702 bUp = sal_True;
1703 rReq.Done();
1706 break;
1708 case SID_ATTR_SIZE:
1710 sal_uLong nId = FN_INSERT_FIELD;
1711 if( rSh.IsCrsrInTbl() )
1712 nId = FN_FORMAT_TABLE_DLG;
1713 else if( rSh.GetCurTOX() )
1714 nId = FN_INSERT_MULTI_TOX;
1715 else if( rSh.GetCurrSection() )
1716 nId = FN_EDIT_REGION;
1717 else
1719 const SwNumRule* pNumRule = rSh.GetCurNumRule();
1720 if( pNumRule ) // Cursor in Numerierung
1722 if( pNumRule->IsAutoRule() )
1723 nId = FN_NUMBER_BULLETS;
1724 else
1726 // Dialog vom Gestalter starten ;-)
1727 nId = 0;
1730 else if( rSh.IsFrmSelected() )
1731 nId = FN_FORMAT_FRAME_DLG;
1732 else if( rSh.IsObjSelected() )
1733 nId = SID_ATTR_TRANSFORM;
1735 if( nId )
1736 GetViewFrame()->GetDispatcher()->Execute(
1737 static_cast< sal_uInt16 >( nId ), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
1739 break;
1741 case FN_STAT_SELMODE:
1743 if ( pArgs )
1745 if (SFX_ITEM_SET == pArgs->GetItemState( nWhich, sal_True, &pItem))
1747 switch ( ((const SfxUInt16Item *)pItem)->GetValue() )
1749 case 0: rSh.EnterStdMode(); break;
1750 case 1: rSh.EnterExtMode(); break;
1751 case 2: rSh.EnterAddMode(); break;
1752 case 3: rSh.EnterBlockMode(); break;
1756 else
1759 if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
1760 rSh.ToggleExtMode();
1761 else if ( rSh.IsExtMode() )
1763 rSh.ToggleExtMode();
1764 rSh.ToggleAddMode();
1766 else if ( rSh.IsAddMode() )
1768 rSh.ToggleAddMode();
1769 rSh.ToggleBlockMode();
1771 else
1772 rSh.ToggleBlockMode();
1774 bUp = sal_True;
1775 break;
1777 case FN_SET_ADD_MODE:
1778 rSh.ToggleAddMode();
1779 nWhich = FN_STAT_SELMODE;
1780 bUp = sal_True;
1781 break;
1782 case FN_SET_BLOCK_MODE:
1783 rSh.ToggleBlockMode();
1784 nWhich = FN_STAT_SELMODE;
1785 bUp = sal_True;
1786 break;
1787 case FN_SET_EXT_MODE:
1788 rSh.ToggleExtMode();
1789 nWhich = FN_STAT_SELMODE;
1790 bUp = sal_True;
1791 break;
1792 case SID_ATTR_INSERT:
1793 SwPostItMgr* pMgr = GetPostItMgr();
1794 if ( pMgr && pMgr->HasActiveSidebarWin() )
1796 pMgr->ToggleInsModeOnActiveSidebarWin();
1798 else
1799 rSh.ToggleInsMode();
1800 bUp = sal_True;
1801 break;
1804 if ( bUp )
1806 SfxBindings &rBnd = GetViewFrame()->GetBindings();
1807 rBnd.Invalidate(nWhich);
1808 rBnd.Update(nWhich);
1812 void SwView::InsFrmMode(sal_uInt16 nCols)
1814 if ( m_pWrtShell->HasWholeTabSelection() )
1816 SwFlyFrmAttrMgr aMgr( sal_True, m_pWrtShell, FRMMGR_TYPE_TEXT );
1818 const SwFrmFmt &rPageFmt =
1819 m_pWrtShell->GetPageDesc(m_pWrtShell->GetCurPageDesc()).GetMaster();
1820 SwTwips lWidth = rPageFmt.GetFrmSize().GetWidth();
1821 const SvxLRSpaceItem &rLR = rPageFmt.GetLRSpace();
1822 lWidth -= rLR.GetLeft() + rLR.GetRight();
1823 aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
1824 if(nCols > 1)
1826 SwFmtCol aCol;
1827 aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
1828 aMgr.SetCol( aCol );
1830 aMgr.InsertFlyFrm();
1832 else
1833 GetEditWin().InsFrm(nCols);
1836 /*--------------------------------------------------------------------
1837 Beschreibung: Links bearbeiten
1838 --------------------------------------------------------------------*/
1839 void SwView::EditLinkDlg()
1841 sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
1842 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1843 SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb );
1844 if ( pDlg )
1846 pDlg->Execute();
1847 delete pDlg;
1851 bool SwView::JumpToSwMark( const String& rMark )
1853 bool bRet = false;
1854 if( rMark.Len() )
1856 // wir wollen den Bookmark aber am oberen Rand haben
1857 sal_Bool bSaveCC = IsCrsrAtCenter();
1858 sal_Bool bSaveCT = IsCrsrAtTop();
1859 SetCrsrAtTop( sal_True );
1861 // Damit in FrameSet auch gescrollt werden kann, muss die
1862 // entsprechende Shell auch das Focus-Flag gesetzt haben!
1863 sal_Bool bHasShFocus = m_pWrtShell->HasShFcs();
1864 if( !bHasShFocus )
1865 m_pWrtShell->ShGetFcs( sal_False );
1867 const SwFmtINetFmt* pINet;
1868 String sCmp, sMark( INetURLObject::decode( rMark, INET_HEX_ESCAPE,
1869 INetURLObject::DECODE_WITH_CHARSET,
1870 RTL_TEXTENCODING_UTF8 ));
1872 xub_StrLen nLastPos, nPos = sMark.Search( cMarkSeparator );
1873 if( STRING_NOTFOUND != nPos )
1874 while( STRING_NOTFOUND != ( nLastPos =
1875 sMark.Search( cMarkSeparator, nPos + 1 )) )
1876 nPos = nLastPos;
1878 IDocumentMarkAccess::const_iterator_t ppMark;
1879 IDocumentMarkAccess* const pMarkAccess = m_pWrtShell->getIDocumentMarkAccess();
1880 if( STRING_NOTFOUND != nPos )
1881 sCmp = comphelper::string::remove(sMark.Copy(nPos + 1), ' ');
1883 if( sCmp.Len() )
1885 rtl::OUString sName( sMark.Copy( 0, nPos ) );
1886 sCmp.ToLowerAscii();
1887 FlyCntType eFlyType = FLYCNTTYPE_ALL;
1889 if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToRegion ) )
1891 m_pWrtShell->EnterStdMode();
1892 bRet = m_pWrtShell->GotoRegion( sName );
1894 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOutline ) )
1896 m_pWrtShell->EnterStdMode();
1897 bRet = m_pWrtShell->GotoOutline( sName );
1899 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToFrame ) )
1900 eFlyType = FLYCNTTYPE_FRM;
1901 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToGraphic ) )
1902 eFlyType = FLYCNTTYPE_GRF;
1903 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToOLE ) )
1904 eFlyType = FLYCNTTYPE_OLE;
1905 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToTable ) )
1907 m_pWrtShell->EnterStdMode();
1908 bRet = m_pWrtShell->GotoTable( sName );
1910 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToSequence ) )
1912 m_pWrtShell->EnterStdMode();
1913 sal_Int32 nNoPos = sName.indexOf( cSequenceMarkSeparator );
1914 if ( nNoPos != -1 )
1916 sal_uInt16 nSeqNo = sName.copy( nNoPos + 1 ).toInt32();
1917 sName = sName.copy( 0, nNoPos );
1918 m_pWrtShell->GotoRefMark( sName, REF_SEQUENCEFLD, nSeqNo );
1921 else if( COMPARE_EQUAL == sCmp.CompareToAscii( pMarkToText ) )
1923 // Normale Textsuche
1924 m_pWrtShell->EnterStdMode();
1926 SearchOptions aSearchOpt(
1927 SearchAlgorithms_ABSOLUTE, 0,
1928 sName, OUString(),
1929 SvtSysLocale().GetLanguageTag().getLocale(),
1930 0,0,0,
1931 TransliterationModules_IGNORE_CASE );
1933 //todo/mba: assuming that notes shouldn't be searched
1934 sal_Bool bSearchInNotes = sal_False;
1935 if( m_pWrtShell->SearchPattern( aSearchOpt, bSearchInNotes, DOCPOS_START, DOCPOS_END ))
1937 m_pWrtShell->EnterStdMode(); // Selektion wieder aufheben
1938 bRet = true;
1941 else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
1942 m_pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = true;
1943 else if( 0 != ( pINet = m_pWrtShell->FindINetAttr( sMark ) )) {
1944 m_pWrtShell->addCurrentPosition();
1945 bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
1948 // fuer alle Arten von Flys
1949 if( FLYCNTTYPE_ALL != eFlyType && m_pWrtShell->GotoFly( sName, eFlyType ))
1951 bRet = true;
1952 if( FLYCNTTYPE_FRM == eFlyType )
1954 // TextFrames: Cursor in den Frame setzen
1955 m_pWrtShell->UnSelectFrm();
1956 m_pWrtShell->LeaveSelFrmMode();
1958 else
1960 m_pWrtShell->HideCrsr();
1961 m_pWrtShell->EnterSelFrmMode();
1965 else if( pMarkAccess->getMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
1966 m_pWrtShell->GotoMark( ppMark->get(), sal_False, sal_True ), bRet = true;
1967 else if( 0 != ( pINet = m_pWrtShell->FindINetAttr( sMark ) ))
1968 bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTxtINetFmt() );
1970 // make selection visible later
1971 if ( m_aVisArea.IsEmpty() )
1972 m_bMakeSelectionVisible = sal_True;
1974 // ViewStatus wieder zurueck setzen
1975 SetCrsrAtTop( bSaveCT, bSaveCC );
1977 if( !bHasShFocus )
1978 m_pWrtShell->ShLooseFcs();
1980 return bRet;
1983 // #i67305# Undo after insert from file:
1984 // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
1985 // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
1986 // page styles with active header/footer => disabled for those documents
1987 static sal_uInt16 lcl_PageDescWithHeader( const SwDoc& rDoc )
1989 sal_uInt16 nRet = 0;
1990 sal_uInt16 nCnt = rDoc.GetPageDescCnt();
1991 for( sal_uInt16 i = 0; i < nCnt; ++i )
1993 const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
1994 const SwFrmFmt& rMaster = rPageDesc.GetMaster();
1995 const SfxPoolItem* pItem;
1996 if( ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem ) &&
1997 ((SwFmtHeader*)pItem)->IsActive() ) ||
1998 ( SFX_ITEM_SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem ) &&
1999 ((SwFmtFooter*)pItem)->IsActive()) )
2000 ++nRet;
2002 return nRet; // number of page styles with active header/footer
2005 /*--------------------------------------------------------------------
2006 Beschreibung: Links bearbeiten
2007 --------------------------------------------------------------------*/
2008 void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
2010 m_pViewImpl->InitRequest( rRequest );
2011 m_pViewImpl->SetParam( pItem ? 1 : 0 );
2012 sal_uInt16 nSlot = rRequest.GetSlot();
2014 if ( !pItem )
2016 String sEmpty;
2017 InsertDoc( nSlot, sEmpty, sEmpty );
2019 else
2021 String sFile, sFilter;
2022 sFile = ( (const SfxStringItem *)pItem )->GetValue();
2023 if ( SFX_ITEM_SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, sal_True, &pItem ) )
2024 sFilter = ( (const SfxStringItem *)pItem )->GetValue();
2026 bool bHasFileName = ( sFile.Len() > 0 );
2027 long nFound = InsertDoc( nSlot, sFile, sFilter );
2029 if ( bHasFileName )
2031 rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2032 rRequest.Done();
2037 long SwView::InsertDoc( sal_uInt16 nSlotId, const String& rFileName, const String& rFilterName, sal_Int16 nVersion )
2039 SfxMedium* pMed = 0;
2040 SwDocShell* pDocSh = GetDocShell();
2042 if( rFileName.Len() )
2044 SfxObjectFactory& rFact = pDocSh->GetFactory();
2045 const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
2046 if ( !pFilter )
2048 pMed = new SfxMedium(rFileName, STREAM_READ, 0, 0 );
2049 SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
2050 pMed->UseInteractionHandler( sal_True );
2051 ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, sal_False );
2052 if ( nErr )
2053 DELETEZ(pMed);
2054 else
2055 pMed->SetFilter( pFilter );
2057 else
2058 pMed = new SfxMedium(rFileName, STREAM_READ, pFilter, 0);
2060 else
2062 OUString sFactory = OUString::createFromAscii( pDocSh->GetFactory().GetShortName() );
2063 m_pViewImpl->StartDocumentInserter( sFactory, LINK( this, SwView, DialogClosedHdl ) );
2064 return -1;
2067 if( !pMed )
2068 return -1;
2070 return InsertMedium( nSlotId, pMed, nVersion );
2073 long SwView::InsertMedium( sal_uInt16 nSlotId, SfxMedium* pMedium, sal_Int16 nVersion )
2075 sal_Bool bInsert = sal_False, bCompare = sal_False;
2076 long nFound = 0;
2077 SwDocShell* pDocSh = GetDocShell();
2079 switch( nSlotId )
2081 case SID_DOCUMENT_MERGE: break;
2082 case SID_DOCUMENT_COMPARE: bCompare = sal_True; break;
2083 case SID_INSERTDOC: bInsert = sal_True; break;
2085 default:
2086 OSL_ENSURE( !this, "unknown SlotId!" );
2087 bInsert = sal_True;
2088 nSlotId = SID_INSERTDOC;
2089 break;
2092 if( bInsert )
2094 uno::Reference< frame::XDispatchRecorder > xRecorder =
2095 GetViewFrame()->GetBindings().GetRecorder();
2096 if ( xRecorder.is() )
2098 SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
2099 aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
2100 if(pMedium->GetFilter())
2101 aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
2102 aRequest.Done();
2105 SfxObjectShellRef aRef( pDocSh );
2107 sal_uInt32 nError = SfxObjectShell::HandleFilter( pMedium, pDocSh );
2108 // #i16722# aborted?
2109 if(nError != ERRCODE_NONE)
2111 delete pMedium;
2112 return -1;
2115 pMedium->DownLoad(); // ggfs. den DownLoad anstossen
2116 if( aRef.Is() && 1 < aRef->GetRefCount() ) // noch gueltige Ref?
2118 SwReader* pRdr;
2119 Reader *pRead = pDocSh->StartConvertFrom( *pMedium, &pRdr, m_pWrtShell );
2120 if( pRead ||
2121 (pMedium->GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER) != 0 )
2123 sal_uInt16 nUndoCheck = 0;
2124 SwDoc *pDoc = pDocSh->GetDoc();
2125 if( pRead && pDocSh->GetDoc() )
2126 nUndoCheck = lcl_PageDescWithHeader( *pDoc );
2127 sal_uLong nErrno;
2128 { //Scope for SwWait-Object, to be able to execute slots
2129 //outside this scope.
2130 SwWait aWait( *GetDocShell(), sal_True );
2131 m_pWrtShell->StartAllAction();
2132 if ( m_pWrtShell->HasSelection() )
2133 m_pWrtShell->DelRight(); // Selektionen loeschen
2134 if( pRead )
2136 nErrno = pRdr->Read( *pRead ); // und Dokument einfuegen
2137 delete pRdr;
2139 else
2141 ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
2142 nErrno = pDocSh->ImportFrom( *pMedium, true ) ? 0 : ERR_SWG_READ_ERROR;
2147 // ggfs. alle Verzeichnisse updaten:
2148 if( m_pWrtShell->IsUpdateTOX() )
2150 SfxRequest aReq( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
2151 Execute( aReq );
2152 m_pWrtShell->SetUpdateTOX( sal_False ); // wieder zurueck setzen
2155 if( pDoc )
2156 { // Disable Undo for .sdw or
2157 // if the number of page styles with header/footer has changed
2158 if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
2160 pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
2164 m_pWrtShell->EndAllAction();
2165 if( nErrno )
2167 ErrorHandler::HandleError( nErrno );
2168 nFound = IsError( nErrno ) ? -1 : 0;
2170 else
2171 nFound = 0;
2175 else
2177 SfxObjectShellRef xDocSh;
2178 SfxObjectShellLock xLockRef;
2180 extern int sw_FindDocShell( SfxObjectShellRef& xDocSh, SfxObjectShellLock& xLockRef,
2181 const String& rFileName, const String& rPasswd,
2182 String& rFilter, sal_Int16 nVersion,
2183 SwDocShell* pDestSh );
2185 String sFltNm;
2186 int nRet = sw_FindDocShell( xDocSh, xLockRef, pMedium->GetName(), aEmptyStr,
2187 sFltNm, nVersion, pDocSh );
2188 if( nRet )
2190 SwWait aWait( *GetDocShell(), sal_True );
2191 m_pWrtShell->StartAllAction();
2193 m_pWrtShell->EnterStdMode(); // Selektionen loeschen
2195 if( bCompare )
2196 nFound = m_pWrtShell->CompareDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
2197 else
2198 nFound = m_pWrtShell->MergeDoc( *((SwDocShell*)&xDocSh)->GetDoc() );
2200 m_pWrtShell->EndAllAction();
2202 if (!bCompare && !nFound)
2204 Window* pWin = &GetEditWin();
2205 InfoBox(pWin, SW_RES(MSG_NO_MERGE_ENTRY)).Execute();
2208 if( 2 == nRet && xDocSh.Is() )
2209 xDocSh->DoClose();
2212 delete pMedium;
2213 return nFound;
2216 void SwView::EnableMailMerge(sal_Bool bEnable )
2218 m_bInMailMerge = bEnable;
2219 SfxBindings& rBind = GetViewFrame()->GetBindings();
2220 rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY);
2221 rBind.Update(FN_INSERT_FIELD_DATA_ONLY);
2224 namespace
2226 sal_Bool lcl_NeedAdditionalDataSource( const uno::Reference< XDatabaseContext >& _rDatasourceContext )
2228 Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
2230 return ( !aNames.getLength()
2231 || ( ( 1 == aNames.getLength() )
2232 && aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
2238 class SwMergeSourceWarningBox_Impl : public ModalDialog
2240 FixedInfo aMessageFI;
2241 OKButton aOK;
2242 CancelButton aCancel;
2244 FixedImage aWarnImage;
2245 public:
2246 SwMergeSourceWarningBox_Impl( Window* pParent ) :
2247 ModalDialog( pParent, SW_RES( DLG_MERGE_SOURCE_UNAVAILABLE ) ),
2248 aMessageFI( this, SW_RES( ST_MERGE_SOURCE_UNAVAILABLE ) ),
2249 aOK( this, SW_RES( PB_MERGE_OK ) ),
2250 aCancel( this, SW_RES( PB_MERGE_CANCEL ) ),
2251 aWarnImage( this, SW_RES( IMG_MERGE ) )
2253 FreeResource();
2254 SetText( Application::GetDisplayName() );
2255 const Image& rImg = WarningBox::GetStandardImage();
2256 aWarnImage.SetImage( rImg );
2257 Size aImageSize( rImg.GetSizePixel() );
2258 aImageSize.Width() += 4;
2259 aImageSize.Height() += 4;
2260 aWarnImage.SetSizePixel( aImageSize );
2262 aImageSize.Width() += aWarnImage.GetPosPixel().X();
2263 Size aSz(GetSizePixel());
2264 aSz.Width() += aImageSize.Width();
2265 SetSizePixel(aSz);
2267 Point aPos(aMessageFI.GetPosPixel());
2268 aPos.X() += aImageSize.Width();
2269 aMessageFI.SetPosPixel( aPos );
2271 aPos = aOK.GetPosPixel();
2272 aPos.X() += aImageSize.Width();
2273 aOK.SetPosPixel( aPos );
2274 aPos = aCancel.GetPosPixel();
2275 aPos.X() += aImageSize.Width();
2276 aCancel.SetPosPixel( aPos );
2280 String GetMessText() const { return aMessageFI.GetText(); }
2281 void SetMessText( const String& rText ) { aMessageFI.SetText( rText ); }
2284 void SwView::GenerateFormLetter(sal_Bool bUseCurrentDocument)
2286 if(bUseCurrentDocument)
2288 if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
2290 //check availability of data sources (except biblio source)
2291 uno::Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
2292 uno::Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
2293 sal_Bool bCallAddressPilot = sal_False;
2294 if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2296 // no data sources are available - create a new one
2297 WarningBox aWarning(
2298 &GetViewFrame()->GetWindow(),
2299 SW_RES(MSG_DATA_SOURCES_UNAVAILABLE));
2300 // no cancel allowed
2301 if ( RET_OK != aWarning.Execute() )
2302 return;
2303 bCallAddressPilot = sal_True;
2305 else
2307 //take an existing data source or create a new one?
2308 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
2309 OSL_ENSURE(pFact, "Dialogdiet fail!");
2310 AbstractMailMergeFieldConnectionsDlg* pConnectionsDlg = pFact->CreateMailMergeFieldConnectionsDlg(
2311 DLG_MERGE_FIELD_CONNECTIONS,
2312 &GetViewFrame()->GetWindow());
2313 OSL_ENSURE(pConnectionsDlg, "Dialogdiet fail!");
2314 if(RET_OK == pConnectionsDlg->Execute())
2315 bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections();
2316 else
2317 return;
2320 if(bCallAddressPilot)
2322 GetViewFrame()->GetDispatcher()->Execute(
2323 SID_ADDRESS_DATA_SOURCE, SFX_CALLMODE_SYNCHRON);
2324 if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2325 // no additional data source has been created
2326 // -> assume that the user has cancelled the pilot
2327 return;
2330 //call insert fields with database field page available, only
2331 SfxViewFrame* pVFrame = GetViewFrame();
2332 //at first hide the default field dialog if currently visible
2333 pVFrame->SetChildWindow(FN_INSERT_FIELD, sal_False);
2334 //enable the status of the db field dialog - it is disabled in the status method
2335 //to prevent creation of the dialog without mail merge active
2336 EnableMailMerge();
2337 //then show the "Data base only" field dialog
2338 SfxBoolItem aOn(FN_INSERT_FIELD_DATA_ONLY, sal_True);
2339 pVFrame->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY,
2340 SFX_CALLMODE_SYNCHRON, &aOn, 0L);
2341 return;
2343 else
2345 // check whether the
2346 String sSource;
2347 if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
2349 SwMergeSourceWarningBox_Impl aWarning( &GetViewFrame()->GetWindow());
2350 String sTmp(aWarning.GetMessText());
2351 sTmp.SearchAndReplaceAscii("%1", sSource);
2352 aWarning.SetMessText(sTmp);
2353 if(RET_OK == aWarning.Execute())
2355 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
2356 if ( pFact )
2358 VclAbstractDialog* pDlg = pFact->CreateVclDialog( NULL, SID_OPTIONS_DATABASES );
2359 pDlg->Execute();
2360 delete pDlg;
2363 return ;
2366 SwNewDBMgr* pNewDBMgr = GetWrtShell().GetNewDBMgr();
2368 SwDBData aData;
2369 SwWrtShell &rSh = GetWrtShell();
2371 std::vector<String> aDBNameList;
2372 std::vector<String> aAllDBNames;
2373 rSh.GetAllUsedDB( aDBNameList, &aAllDBNames );
2374 if(!aDBNameList.empty())
2376 String sDBName(aDBNameList[0]);
2377 aData.sDataSource = sDBName.GetToken(0, DB_DELIM);
2378 aData.sCommand = sDBName.GetToken(1, DB_DELIM);
2379 aData.nCommandType = sDBName.GetToken(2, DB_DELIM ).ToInt32();
2381 rSh.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
2382 // das Mischen von DB-Feldern notwendig.
2383 AttrChangedNotify( &rSh );
2385 if (pNewDBMgr)
2387 pNewDBMgr->SetMergeType( DBMGR_MERGE );
2389 Sequence<PropertyValue> aProperties(3);
2390 PropertyValue* pValues = aProperties.getArray();
2391 pValues[0].Name = "DataSourceName";
2392 pValues[1].Name = "Command";
2393 pValues[2].Name = "CommandType";
2394 pValues[0].Value <<= aData.sDataSource;
2395 pValues[1].Value <<= aData.sCommand;
2396 pValues[2].Value <<= aData.nCommandType;
2397 pNewDBMgr->ExecuteFormLetter(GetWrtShell(), aProperties, sal_True);
2400 else
2402 //call documents and template dialog
2403 SfxApplication* pSfxApp = SFX_APP();
2404 Window* pTopWin = pSfxApp->GetTopWindow();
2405 SvtDocumentTemplateDialog* pDocTemplDlg = new SvtDocumentTemplateDialog( pTopWin );
2406 pDocTemplDlg->SelectTemplateFolder();
2408 int nRet = pDocTemplDlg->Execute();
2409 sal_Bool bNewWin = sal_False;
2410 if ( nRet == RET_OK )
2412 if ( pTopWin != pSfxApp->GetTopWindow() )
2414 // the dialogue opens a document -> a new TopWindow appears
2415 pTopWin = pSfxApp->GetTopWindow();
2416 bNewWin = sal_True;
2420 delete pDocTemplDlg;
2421 if ( bNewWin )
2422 // after the destruction of the dialogue its parent comes to top,
2423 // but we want that the new document is on top
2424 pTopWin->ToTop();
2428 IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
2430 if ( ERRCODE_NONE == _pFileDlg->GetError() )
2432 SfxMedium* pMed = m_pViewImpl->CreateMedium();
2433 if ( pMed )
2435 sal_uInt16 nSlot = m_pViewImpl->GetRequest()->GetSlot();
2436 long nFound = InsertMedium( nSlot, pMed, m_pViewImpl->GetParam() );
2438 if ( SID_INSERTDOC == nSlot )
2440 if ( m_pViewImpl->GetParam() == 0 )
2442 m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2443 m_pViewImpl->GetRequest()->Ignore();
2445 else
2447 m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2448 m_pViewImpl->GetRequest()->Done();
2451 else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
2453 m_pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
2455 if ( nFound > 0 ) // Redline-Browser anzeigen
2457 SfxViewFrame* pVFrame = GetViewFrame();
2458 pVFrame->ShowChildWindow(FN_REDLINE_ACCEPT);
2460 // RedlineDlg neu initialisieren
2461 sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
2462 SwRedlineAcceptChild* pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow( nId );
2463 if ( pRed )
2464 pRed->ReInitDlg( GetDocShell() );
2469 return 0;
2472 void SwView::ExecuteScan( SfxRequest& rReq )
2474 if (m_pViewImpl)
2475 m_pViewImpl->ExecuteScan(rReq) ;
2478 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */