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