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