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