1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: view2.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <com/sun/star/util/SearchOptions.hpp>
34 #include <com/sun/star/util/SearchFlags.hpp>
35 #include <com/sun/star/i18n/TransliterationModules.hpp>
37 // #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
38 // #include <com/sun/star/lang/Locale.hpp>
40 // #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKER_HPP_
41 // #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
43 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
44 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
45 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
48 #define _SVSTDARR_STRINGSSORTDTOR
49 #include <svtools/svstdarr.hxx>
50 #include <svtools/aeitem.hxx>
52 // #ifndef _FILTER_HXX
53 // #include <svtools/filter.hxx>
55 #include <SwStyleNameMapper.hxx>
57 #include <hintids.hxx>
58 #include <SwRewriter.hxx>
61 #include <caption.hxx>
62 #include <svtools/PasswordHelper.hxx>
63 #include <svtools/urihelper.hxx>
64 #include <svtools/miscopt.hxx>
65 #include <sfx2/passwd.hxx>
66 #include <sfx2/sfxdlg.hxx>
67 #include <sfx2/filedlghelper.hxx>
68 #include <sfx2/sfxhelp.hxx>
69 #include <svx/langitem.hxx>
70 #include <svx/viewlayoutitem.hxx>
71 #include <svx/zoomslideritem.hxx>
72 #include <svx/linkwarn.hxx>
73 #include <svx/htmlmode.hxx>
74 #ifndef _APP_HXX //autogen
75 #include <vcl/svapp.hxx>
77 #ifndef _WRKWIN_HXX //autogen
78 #include <vcl/wrkwin.hxx>
80 #include <sfx2/app.hxx>
81 #include <sfx2/request.hxx>
82 #include <sfx2/bindings.hxx>
83 #include <svx/lrspitem.hxx>
84 #include <svx/impgrf.hxx>
85 #include <svtools/txtcmp.hxx>
86 #include "svx/unolingu.hxx"
87 #include <vcl/msgbox.hxx>
88 #include <svx/tstpitem.hxx>
89 #include <sfx2/event.hxx>
90 #include <sfx2/docfile.hxx>
91 #include <sfx2/docfilt.hxx>
92 #include <sfx2/fcontnr.hxx>
93 #include <svx/sizeitem.hxx>
94 #include <sfx2/dispatch.hxx>
95 #include <sfx2/topfrm.hxx>
96 #include <svtools/whiter.hxx>
97 #include <svtools/ptitem.hxx>
98 #include <svx/linkmgr.hxx>
99 #ifndef __RSC //autogen
100 #include <tools/errinf.hxx>
102 #include <tools/urlobj.hxx>
103 #include <svx/svdview.hxx>
104 #include <swtypes.hxx>
105 #include <swwait.hxx>
106 #include <redlndlg.hxx>
108 #include <uivwimp.hxx>
112 #include <viewopt.hxx>
113 #include <basesh.hxx>
114 #include <swmodule.hxx>
115 #include <uitool.hxx>
116 #include <shellio.hxx>
117 #include <fmtinfmt.hxx>
118 #include <mdiexp.hxx>
119 #include <drawbase.hxx>
120 #include <frmmgr.hxx>
121 #include <pagedesc.hxx>
122 #include <section.hxx>
123 #include <usrpref.hxx>
125 #include <navipi.hxx>
127 #include <workctrl.hxx>
128 #include <scroll.hxx>
129 #include <edtwin.hxx>
131 #include <textsh.hxx>
133 #include <listsh.hxx>
135 #include <comcore.hrc>
136 #include <poolfmt.hrc>
137 #include <statstr.hrc>
139 #include <globals.hrc>
140 #include <shells.hrc>
144 #include <fmtclds.hxx>
146 #include <svtools/templdlg.hxx>
147 #include <dbconfig.hxx>
150 #include <PostItMgr.hxx>
151 #include <postit.hxx>
153 // #ifndef _FRMMGR_HXX
154 // #include <frmmgr.hxx>
157 #include <ndtxt.hxx> //#outline level,added by zhaojianwei
159 #include <comphelper/processfactory.hxx>
161 #include <svx/svxdlg.hxx>
162 #include <svx/dialogs.hrc>
163 #include "swabstdlg.hxx"
164 #include "globals.hrc"
165 #include <envelp.hrc>
166 #include <fmthdft.hxx>
167 #include <svx/ofaitem.hxx>
170 const char __FAR_DATA sStatusDelim
[] = " : ";
171 const char __FAR_DATA sStatusComma
[] = " , ";//#outlinelevel, define a Variable for "," add by zhaojianwei
173 using ::rtl::OUString
;
174 using namespace sfx2
;
175 using namespace ::com::sun::star
;
176 using namespace ::com::sun::star::i18n
;
177 using namespace ::com::sun::star::util
;
178 using namespace ::com::sun::star::uno
;
179 using namespace ::com::sun::star::lang
;
180 using namespace ::com::sun::star::scanner
;
181 using namespace ::com::sun::star::i18n
;
182 using namespace ::com::sun::star::beans
;
183 using namespace ::com::sun::star::container
;
184 using namespace ::com::sun::star::ui::dialogs
;
187 static void lcl_SetAllTextToDefaultLanguage( SwWrtShell
&rWrtSh
, USHORT nWhichId
)
189 if (nWhichId
== RES_CHRATR_LANGUAGE
||
190 nWhichId
== RES_CHRATR_CJK_LANGUAGE
||
191 nWhichId
== RES_CHRATR_CTL_LANGUAGE
)
193 rWrtSh
.StartAction();
194 rWrtSh
.LockView( TRUE
);
197 // prepare to apply new language to all text in document
199 rWrtSh
.ExtendedSelectAll();
201 // set language attribute to default for all text
202 SvUShortsSort aAttribs
;
203 aAttribs
.Insert( nWhichId
);
204 rWrtSh
.ResetAttr( &aAttribs
);
207 rWrtSh
.LockView( FALSE
);
212 /*---------------------------------------------------------------------------
213 Beschreibung: String fuer die Seitenanzeige in der Statusbar basteln.
214 ----------------------------------------------------------------------------*/
216 String
SwView::GetPageStr( USHORT nPg
, USHORT nLogPg
,
217 const String
& rDisplay
)
219 String
aStr( aPageStr
);
223 aStr
+= String::CreateFromInt32(nLogPg
);
225 if( nLogPg
&& nLogPg
!= nPg
)
227 aStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" "));
228 aStr
+= String::CreateFromInt32(nPg
);
230 aStr
.AppendAscii( RTL_CONSTASCII_STRINGPARAM(" / "));
231 aStr
+= String::CreateFromInt32( GetWrtShell().GetPageCnt() );
237 int SwView::InsertGraphic( const String
&rPath
, const String
&rFilter
,
238 BOOL bLink
, GraphicFilter
*pFlt
,
239 Graphic
* pPreviewGrf
, BOOL bRule
)
241 SwWait
aWait( *GetDocShell(), TRUE
);
244 int nRes
= GRFILTER_OK
;
250 pFlt
= ::GetGrfFilter();
251 nRes
= ::LoadGraphic( rPath
, rFilter
, aGrf
, pFlt
/*, nFilter*/ );
254 if( GRFILTER_OK
== nRes
)
256 SwFlyFrmAttrMgr
aFrmMgr( TRUE
, GetWrtShellPtr(), FRMMGR_TYPE_GRF
);
258 SwWrtShell
&rSh
= GetWrtShell();
262 SwDocShell
* pDocSh
= GetDocShell();
265 pDocSh
->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE
) :
268 String sURL
= URIHelper::SmartRel2Abs(
269 aTemp
, rPath
, URIHelper::GetMaybeFileHdl() );
272 rFilter
, aGrf
, &aFrmMgr
, bRule
);
275 rSh
.Insert( aEmptyStr
, aEmptyStr
, aGrf
, &aFrmMgr
);
276 // nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann
283 BOOL
SwView::InsertGraphicDlg( SfxRequest
& rReq
)
285 #ifndef ENABLE_PROP_WITHOUTLINK
286 #define ENABLE_PROP_WITHOUTLINK 0x08
289 BOOL bReturn
= FALSE
;
290 SwDocShell
* pDocShell
= GetDocShell();
291 USHORT nHtmlMode
= ::GetHtmlMode(pDocShell
);
292 // im HTML-Mode nur verknuepft einfuegen
293 FileDialogHelper
* pFileDlg
= new FileDialogHelper( SFXWB_GRAPHIC
| SFXWB_SHOWSTYLES
);
294 pFileDlg
->SetTitle(SW_RESSTR(STR_INSERT_GRAPHIC
));
295 pFileDlg
->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC
);
296 uno::Reference
< XFilePicker
> xFP
= pFileDlg
->GetFilePicker();
297 uno::Reference
< XFilePickerControlAccess
> xCtrlAcc(xFP
, UNO_QUERY
);
298 if(nHtmlMode
& HTMLMODE_ON
)
300 sal_Bool bTrue
= sal_True
;
301 Any
aVal(&bTrue
, ::getBooleanCppuType());
302 xCtrlAcc
->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK
, 0, aVal
);
303 xCtrlAcc
->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK
, sal_False
);
306 SvStringsSortDtor aFormats
;
307 SwDoc
* pDoc
= pDocShell
->GetDoc();
308 const USHORT nArrLen
= pDoc
->GetFrmFmts()->Count();
310 for( i
= 0; i
< nArrLen
; i
++ )
312 SwFrmFmt
* pFmt
= (*pDoc
->GetFrmFmts())[ i
];
313 if(pFmt
->IsDefault() || pFmt
->IsAuto())
315 String
*pFormat
= new String(pFmt
->GetName());
316 aFormats
.Insert(pFormat
);
321 const SvStringsDtor
& rFrmPoolArr
= SwStyleNameMapper::GetFrmFmtUINameArray();
322 for( i
= 0; i
< rFrmPoolArr
.Count(); i
++ )
324 String
*pFormat
= new String(*rFrmPoolArr
[i
]);
325 if (!aFormats
.Insert(pFormat
))
329 Sequence
<OUString
> aListBoxEntries(aFormats
.Count());
330 OUString
* pEntries
= aListBoxEntries
.getArray();
331 sal_Int16 nSelect
= 0;
332 String sGraphicFormat
= SW_RESSTR(STR_POOLFRM_GRAPHIC
);
333 for(i
= 0; i
< aFormats
.Count(); ++i
)
335 pEntries
[i
] = *aFormats
[i
];
336 if(pEntries
[i
].equals(sGraphicFormat
))
341 Any
aTemplates(&aListBoxEntries
, ::getCppuType(&aListBoxEntries
));
343 xCtrlAcc
->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
,
344 ListboxControlActions::ADD_ITEMS
, aTemplates
);
346 Any
aSelectPos(&nSelect
, ::getCppuType(&nSelect
));
347 xCtrlAcc
->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
,
348 ListboxControlActions::SET_SELECT_ITEM
, aSelectPos
);
352 DBG_ERROR("control acces failed");
355 SFX_REQUEST_ARG( rReq
, pName
, SfxStringItem
, SID_INSERT_GRAPHIC
, sal_False
);
356 BOOL bShowError
= !pName
;
357 if( pName
|| ERRCODE_NONE
== pFileDlg
->Execute() )
360 String aFileName
, aFilterName
;
363 aFileName
= pName
->GetValue();
364 SFX_REQUEST_ARG( rReq
, pFilter
, SfxStringItem
, FN_PARAM_FILTER
, sal_False
);
366 aFilterName
= pFilter
->GetValue();
370 aFileName
= pFileDlg
->GetPath();
371 aFilterName
= pFileDlg
->GetCurrentFilter();
372 rReq
.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC
, aFileName
) );
373 rReq
.AppendItem( SfxStringItem( FN_PARAM_FILTER
, aFilterName
) );
375 sal_Bool bAsLink
= sal_False
;
376 if(nHtmlMode
& HTMLMODE_ON
)
382 Any aVal
= xCtrlAcc
->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK
, 0);
383 DBG_ASSERT(aVal
.hasValue(), "Value CBX_INSERT_AS_LINK not found");
384 bAsLink
= aVal
.hasValue() ? *(sal_Bool
*) aVal
.getValue() : sal_True
;
385 Any aTemplateValue
= xCtrlAcc
->getValue(
386 ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
,
387 ListboxControlActions::GET_SELECTED_ITEM
);
389 aTemplateValue
>>= sTmpl
;
390 rReq
.AppendItem( SfxStringItem( FN_PARAM_2
, sTmpl
) );
394 DBG_ERROR("control acces failed");
397 rReq
.AppendItem( SfxBoolItem( FN_PARAM_1
, bAsLink
) );
400 SFX_REQUEST_ARG( rReq
, pAsLink
, SfxBoolItem
, FN_PARAM_1
, sal_False
);
401 SFX_REQUEST_ARG( rReq
, pStyle
, SfxStringItem
, FN_PARAM_2
, sal_False
);
403 sal_Bool bAsLink
= sal_False
;
404 if( nHtmlMode
& HTMLMODE_ON
)
408 if ( rReq
.GetArgs() )
411 bAsLink
= pAsLink
->GetValue();
412 if ( pStyle
&& pStyle
->GetValue().Len() )
413 sGraphicFormat
= pStyle
->GetValue();
417 Any aVal
= xCtrlAcc
->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK
, 0);
418 DBG_ASSERT(aVal
.hasValue(), "Value CBX_INSERT_AS_LINK not found");
419 bAsLink
= aVal
.hasValue() ? *(sal_Bool
*) aVal
.getValue() : sal_True
;
420 Any aTemplateValue
= xCtrlAcc
->getValue(
421 ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE
,
422 ListboxControlActions::GET_SELECTED_ITEM
);
424 aTemplateValue
>>= sTmpl
;
425 if( sTmpl
.getLength() )
426 sGraphicFormat
= sTmpl
;
427 rReq
.AppendItem( SfxStringItem( FN_PARAM_2
, sGraphicFormat
) );
428 rReq
.AppendItem( SfxBoolItem( FN_PARAM_1
, bAsLink
) );
431 // really store as link only?
432 if( bAsLink
&& SvtMiscOptions().ShowLinkWarningDialog() )
434 SvxLinkWarningDialog
aWarnDlg(GetWindow(),pFileDlg
->GetPath());
435 if( aWarnDlg
.Execute() != RET_OK
)
436 bAsLink
=sal_False
; // don't store as link
440 SwWrtShell
& rSh
= GetWrtShell();
445 SwRewriter aRewriter
;
446 aRewriter
.AddRule(UNDO_ARG1
, String(SW_RES(STR_GRAPHIC_DEFNAME
)));
448 rSh
.StartUndo(UNDO_INSERT
, &aRewriter
);
450 int nError
= InsertGraphic( aFileName
, aFilterName
, bAsLink
, ::GetGrfFilter() );
452 // Format ist ungleich Current Filter, jetzt mit auto. detection
453 if( nError
== GRFILTER_FORMATERROR
)
454 nError
= InsertGraphic( aFileName
, aEmptyStr
, bAsLink
, ::GetGrfFilter() );
455 if ( rSh
.IsFrmSelected() )
457 SwFrmFmt
* pFmt
= pDoc
->FindFrmFmtByName( sGraphicFormat
);
459 pFmt
= pDoc
->MakeFrmFmt(sGraphicFormat
,
460 pDocShell
->GetDoc()->GetDfltFrmFmt(),
462 rSh
.SetFrmFmt( pFmt
);
465 RESOURCE_TYPE nResId
= 0;
468 case GRFILTER_OPENERROR
:
469 nResId
= STR_GRFILTER_OPENERROR
;
471 case GRFILTER_IOERROR
:
472 nResId
= STR_GRFILTER_IOERROR
;
474 case GRFILTER_FORMATERROR
:
475 nResId
= STR_GRFILTER_FORMATERROR
;
477 case GRFILTER_VERSIONERROR
:
478 nResId
= STR_GRFILTER_VERSIONERROR
;
480 case GRFILTER_FILTERERROR
:
481 nResId
= STR_GRFILTER_FILTERERROR
;
483 case GRFILTER_TOOBIG
:
484 nResId
= STR_GRFILTER_TOOBIG
;
494 InfoBox
aInfoBox( GetWindow(), SW_RESSTR( nResId
));
501 // set the specific graphic attrbutes to the graphic
503 AutoCaption( GRAPHIC_CAP
);
507 rSh
.EndUndo(UNDO_INSERT
); // wegen moegl. Shellwechsel
516 void __EXPORT
SwView::Execute(SfxRequest
&rReq
)
518 USHORT nSlot
= rReq
.GetSlot();
519 const SfxItemSet
* pArgs
= rReq
.GetArgs();
520 const SfxPoolItem
* pItem
;
521 BOOL bIgnore
= FALSE
;
524 case SID_CREATE_SW_DRAWVIEW
:
525 // --> OD 2005-08-08 #i52858# - method name changed
526 pWrtShell
->getIDocumentDrawModelAccess()->GetOrCreateDrawModel();
530 case FN_LINE_NUMBERING_DLG
:
532 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
533 DBG_ASSERT(pFact
, "Dialogdiet fail!");
534 VclAbstractDialog
* pDlg
= pFact
->CreateVclSwViewDialog( DLG_LINE_NUMBERING
, *this);
535 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
540 case FN_EDIT_LINK_DLG
:
543 case FN_REFRESH_VIEW
:
544 GetEditWin().Invalidate();
549 case FN_PAGEDOWN_SEL
:
551 Rectangle
aVis( GetVisArea() );
552 SwEditWin
& rTmpWin
= GetEditWin();
553 if ( FN_PAGEUP
== nSlot
|| FN_PAGEUP_SEL
== nSlot
)
554 PageUpCrsr(FN_PAGEUP_SEL
== nSlot
);
556 PageDownCrsr(FN_PAGEDOWN_SEL
== nSlot
);
558 rReq
.SetReturnValue(SfxBoolItem(nSlot
,
559 aVis
!= GetVisArea()));
560 //#i42732# - notify the edit window that from now on we do not use the input language
561 rTmpWin
.SetUseInputLanguage( sal_False
);
567 SFX_ITEM_SET
== pArgs
->GetItemState(nSlot
, FALSE
, &pItem
))
569 IDocumentRedlineAccess
* pIDRA
= pWrtShell
->getIDocumentRedlineAccess();
570 Sequence
<sal_Int8
> aPasswd
= pIDRA
->GetRedlinePassword();
571 if( aPasswd
.getLength() )
573 DBG_ASSERT( !((const SfxBoolItem
*)pItem
)->GetValue(), "SwView::Execute(): password set an redlining off doesn't match!" );
574 // xmlsec05: new password dialog
576 const SfxPoolItem
* pParentItem
;
577 if( SFX_ITEM_SET
== pArgs
->GetItemState( SID_ATTR_PARENTWINDOW
, FALSE
, &pParentItem
) )
578 pParent
= ( Window
* ) ( ( const OfaPtrItem
* ) pParentItem
)->GetValue();
580 pParent
= &GetViewFrame()->GetWindow();
581 SfxPasswordDialog
aPasswdDlg( pParent
);
582 //#i69751# the result of Execute() can be ignored
583 aPasswdDlg
.Execute();
584 String
sNewPasswd( aPasswdDlg
.GetPassword() );
585 Sequence
<sal_Int8
> aNewPasswd
= pIDRA
->GetRedlinePassword();
586 SvPasswordHelper::GetHashPassword( aNewPasswd
, sNewPasswd
);
587 if(SvPasswordHelper::CompareHashPassword(aPasswd
, sNewPasswd
))
588 pIDRA
->SetRedlinePassword(Sequence
<sal_Int8
> ());
590 { // xmlsec05: message box for wrong password
595 USHORT nOn
= ((const SfxBoolItem
*)pItem
)->GetValue() ? nsRedlineMode_t::REDLINE_ON
: 0;
596 USHORT nMode
= pWrtShell
->GetRedlineMode();
597 pWrtShell
->SetRedlineModeAndCheckInsMode( (nMode
& ~nsRedlineMode_t::REDLINE_ON
) | nOn
);
601 case FN_REDLINE_PROTECT
:
603 IDocumentRedlineAccess
* pIDRA
= pWrtShell
->getIDocumentRedlineAccess();
604 Sequence
<sal_Int8
> aPasswd
= pIDRA
->GetRedlinePassword();
605 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(nSlot
, FALSE
, &pItem
)
606 && ((SfxBoolItem
*)pItem
)->GetValue() == ( aPasswd
.getLength() != 0 ) )
609 // xmlsec05: new password dialog
610 // message box for wrong password
612 const SfxPoolItem
* pParentItem
;
613 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( SID_ATTR_PARENTWINDOW
, FALSE
, &pParentItem
) )
614 pParent
= ( Window
* ) ( ( const OfaPtrItem
* ) pParentItem
)->GetValue();
616 pParent
= &GetViewFrame()->GetWindow();
617 SfxPasswordDialog
aPasswdDlg( pParent
);
618 if(!aPasswd
.getLength())
619 aPasswdDlg
.ShowExtras(SHOWEXTRAS_CONFIRM
);
620 if (aPasswdDlg
.Execute())
622 USHORT nOn
= nsRedlineMode_t::REDLINE_ON
;
623 String
sNewPasswd( aPasswdDlg
.GetPassword() );
624 Sequence
<sal_Int8
> aNewPasswd
=
625 pIDRA
->GetRedlinePassword();
626 SvPasswordHelper::GetHashPassword( aNewPasswd
, sNewPasswd
);
627 if(!aPasswd
.getLength())
629 pIDRA
->SetRedlinePassword(aNewPasswd
);
631 else if(SvPasswordHelper::CompareHashPassword(aPasswd
, sNewPasswd
))
633 pIDRA
->SetRedlinePassword(Sequence
<sal_Int8
> ());
636 USHORT nMode
= pIDRA
->GetRedlineMode();
637 pWrtShell
->SetRedlineModeAndCheckInsMode( (nMode
& ~nsRedlineMode_t::REDLINE_ON
) | nOn
);
638 rReq
.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT
, ((nMode
&nsRedlineMode_t::REDLINE_ON
)==0) ) );
644 case FN_REDLINE_SHOW
:
647 SFX_ITEM_SET
== pArgs
->GetItemState(nSlot
, FALSE
, &pItem
))
649 USHORT nMode
= ( ~(nsRedlineMode_t::REDLINE_SHOW_INSERT
| nsRedlineMode_t::REDLINE_SHOW_DELETE
)
650 & pWrtShell
->GetRedlineMode() ) | nsRedlineMode_t::REDLINE_SHOW_INSERT
;
651 if( ((const SfxBoolItem
*)pItem
)->GetValue() )
652 nMode
|= nsRedlineMode_t::REDLINE_SHOW_DELETE
;
654 pWrtShell
->SetRedlineModeAndCheckInsMode( nMode
);
657 case FN_MAILMERGE_SENDMAIL_CHILDWINDOW
:
658 case FN_REDLINE_ACCEPT
:
659 GetViewFrame()->ToggleChildWindow(nSlot
);
661 case FN_REDLINE_ACCEPT_DIRECT
:
662 case FN_REDLINE_REJECT_DIRECT
:
664 SwContentAtPos
aCntntAtPos( SwContentAtPos::SW_REDLINE
);
665 Point aCrsrPos
= pWrtShell
->GetCrsrDocPos( sal_True
);
666 if( pWrtShell
->GetContentAtPos( aCrsrPos
, aCntntAtPos
) )
668 USHORT nCount
= pWrtShell
->GetRedlineCount();
669 for( USHORT nRedline
= 0; nRedline
< nCount
; ++nRedline
)
671 const SwRedline
& rRedline
= pWrtShell
->GetRedline( nRedline
);
672 if( *aCntntAtPos
.aFnd
.pRedl
== rRedline
)
674 if( FN_REDLINE_ACCEPT_DIRECT
== nSlot
)
675 pWrtShell
->AcceptRedline( nRedline
);
677 pWrtShell
->RejectRedline( nRedline
);
684 case SID_DOCUMENT_COMPARE
:
685 case SID_DOCUMENT_MERGE
:
687 String sFileName
, sFilterName
;
689 bool bHasFileName
= false;
690 pViewImpl
->SetParam( 0 );
694 if( SFX_ITEM_SET
== pArgs
->GetItemState( SID_FILE_NAME
, FALSE
, &pItem
))
695 sFileName
= ((const SfxStringItem
*)pItem
)->GetValue();
696 bHasFileName
= ( sFileName
.Len() > 0 );
698 if( SFX_ITEM_SET
== pArgs
->GetItemState( SID_FILTER_NAME
, FALSE
, &pItem
))
699 sFilterName
= ((const SfxStringItem
*)pItem
)->GetValue();
701 if( SFX_ITEM_SET
== pArgs
->GetItemState( SID_VERSION
, FALSE
, &pItem
))
703 nVersion
= ((const SfxInt16Item
*)pItem
)->GetValue();
704 pViewImpl
->SetParam( nVersion
);
708 pViewImpl
->InitRequest( rReq
);
709 long nFound
= InsertDoc( nSlot
, sFileName
, sFilterName
, nVersion
);
713 rReq
.SetReturnValue( SfxInt32Item( nSlot
, nFound
));
715 if (nFound
> 0) // Redline-Browser anzeigen
717 SfxViewFrame
* pVFrame
= GetViewFrame();
718 pVFrame
->ShowChildWindow(FN_REDLINE_ACCEPT
);
720 // RedlineDlg neu initialisieren
721 USHORT nId
= SwRedlineAcceptChild::GetChildWindowId();
722 SwRedlineAcceptChild
*pRed
= (SwRedlineAcceptChild
*)
723 pVFrame
->GetChildWindow(nId
);
725 pRed
->ReInitDlg(GetDocShell());
733 case FN_MAILMERGE_CHILDWINDOW
:
734 GetViewFrame()->ShowChildWindow(nSlot
, TRUE
);
738 if ( pWrtShell
->HasDrawView() && pWrtShell
->GetDrawView()->IsDragObj() )
740 pWrtShell
->BreakDrag();
741 pWrtShell
->EnterSelFrmMode();
743 else if ( pWrtShell
->IsDrawCreate() )
745 GetDrawFuncPtr()->BreakCreate();
746 AttrChangedNotify(pWrtShell
); // ggf Shellwechsel...
748 else if ( pWrtShell
->HasSelection() || IsDrawMode() )
750 SdrView
*pSdrView
= pWrtShell
->HasDrawView() ? pWrtShell
->GetDrawView() : 0;
751 if(pSdrView
&& pSdrView
->AreObjectsMarked() &&
752 pSdrView
->GetHdlList().GetFocusHdl())
754 ((SdrHdlList
&)pSdrView
->GetHdlList()).ResetFocusHdl();
761 Point
aPt(LONG_MIN
, LONG_MIN
);
762 //go out of the frame
763 pWrtShell
->SelectObj(aPt
, SW_LEAVE_FRAME
);
764 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
765 rBind
.Invalidate( SID_ATTR_SIZE
);
767 pWrtShell
->EnterStdMode();
768 AttrChangedNotify(pWrtShell
); // ggf Shellwechsel...
771 else if ( GetEditWin().GetApplyTemplate() )
773 GetEditWin().SetApplyTemplate(SwApplyTemplate());
775 else if( ((SfxObjectShell
*)GetDocShell())->IsInPlaceActive() )
779 else if ( GetEditWin().IsChainMode() )
781 GetEditWin().SetChainMode( FALSE
);
783 else if( pWrtShell
->GetFlyFrmFmt() )
785 const SwFrmFmt
* pFmt
= pWrtShell
->GetFlyFrmFmt();
786 if(pWrtShell
->GotoFly( pFmt
->GetName(), FLYCNTTYPE_FRM
))
788 pWrtShell
->HideCrsr();
789 pWrtShell
->EnterSelFrmMode();
794 SfxBoolItem
aItem( SID_WIN_FULLSCREEN
, FALSE
);
795 GetViewFrame()->GetDispatcher()->Execute( SID_WIN_FULLSCREEN
, SFX_CALLMODE_RECORD
, &aItem
, 0L );
800 case SID_ATTR_BORDER_INNER
:
801 case SID_ATTR_BORDER_OUTER
:
802 case SID_ATTR_BORDER_SHADOW
:
804 pWrtShell
->SetAttr(*pArgs
);
808 case SID_ATTR_PAGE_SIZE
:
809 case SID_ATTR_PAGE_MAXSIZE
:
810 case SID_ATTR_PAGE_PAPERBIN
:
811 case SID_ATTR_PAGE_EXT1
:
812 case FN_PARAM_FTN_INFO
:
816 const USHORT nCurIdx
= pWrtShell
->GetCurPageDesc();
817 SwPageDesc
aPageDesc( pWrtShell
->GetPageDesc( nCurIdx
) );
818 ::ItemSetToPageDesc( *pArgs
, aPageDesc
);
819 // Den Descriptor der Core veraendern.
820 pWrtShell
->ChgPageDesc( nCurIdx
, aPageDesc
);
824 case FN_NAVIGATION_PI_GOTO_PAGE
:
826 SfxViewFrame
* pVFrame
= GetViewFrame();
827 SfxChildWindow
* pCh
= pVFrame
->GetChildWindow( SID_NAVIGATOR
);
830 pVFrame
->ToggleChildWindow( SID_NAVIGATOR
);
831 pCh
= pVFrame
->GetChildWindow( SID_NAVIGATOR
);
834 ((SwNavigationPI
*) pCh
->GetContextWindow(SW_MOD()))->GotoPage();
837 case FN_EDIT_CURRENT_TOX
:
839 GetViewFrame()->GetDispatcher()->Execute(
840 FN_INSERT_MULTI_TOX
, SFX_CALLMODE_ASYNCHRON
);
843 case FN_UPDATE_CUR_TOX
:
845 const SwTOXBase
* pBase
= pWrtShell
->GetCurTOX();
848 pWrtShell
->StartAction();
849 if(TOX_INDEX
== pBase
->GetType())
850 pWrtShell
->ApplyAutoMark();
851 pWrtShell
->UpdateTableOf( *pBase
);
852 pWrtShell
->EndAction();
858 pWrtShell
->StartAction();
859 pWrtShell
->EnterStdMode();
860 BOOL bOldCrsrInReadOnly
= pWrtShell
->IsReadOnlyAvailable();
861 pWrtShell
->SetReadOnlyAvailable( TRUE
);
863 for( USHORT i
= 0; i
< 2; ++i
)
865 USHORT nCount
= pWrtShell
->GetTOXCount();
869 while( pWrtShell
->GotoPrevTOXBase() )
870 ; // aufs erste Verzeichnis springen
872 // falls wir nicht mehr in einem stehen, dann zum naechsten
874 const SwTOXBase
* pBase
= pWrtShell
->GetCurTOX();
877 pWrtShell
->GotoNextTOXBase();
878 pBase
= pWrtShell
->GetCurTOX();
881 BOOL bAutoMarkApplied
= FALSE
;
884 if(TOX_INDEX
== pBase
->GetType() && !bAutoMarkApplied
)
886 pWrtShell
->ApplyAutoMark();
887 bAutoMarkApplied
= TRUE
;
889 // JP 15.07.96: das pBase wird nur fuer die Schnittstelle
890 // benoetigt. Muss mal umgetstellt werden!!!
891 pWrtShell
->UpdateTableOf( *pBase
);
893 if( pWrtShell
->GotoNextTOXBase() )
894 pBase
= pWrtShell
->GetCurTOX();
899 pWrtShell
->SetReadOnlyAvailable( bOldCrsrInReadOnly
);
900 pWrtShell
->EndAction();
905 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(RES_BACKGROUND
, FALSE
, &pItem
))
907 const USHORT nCurIdx
= pWrtShell
->GetCurPageDesc();
908 SwPageDesc
aDesc( pWrtShell
->GetPageDesc( nCurIdx
));
909 SwFrmFmt
& rMaster
= aDesc
.GetMaster();
910 rMaster
.SetFmtAttr(*pItem
);
911 pWrtShell
->ChgPageDesc( nCurIdx
, aDesc
);
915 case SID_CLEARHISTORY
:
917 pWrtShell
->DelAllUndoObj();
922 pShell
->ExecuteSlot(rReq
);
926 case FN_INSERT_OBJ_CTRL
:
928 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(nSlot
, FALSE
, &pItem
))
930 USHORT nValue
= ((SfxUInt16Item
*)pItem
)->GetValue();
935 BOOL bWeb
= 0 != PTR_CAST(SwWebView
, this);
937 SwView::nWebInsertCtrlState
= nValue
;
939 SwView::nInsertCtrlState
= nValue
;
942 case FN_INSERT_OBJ_CTRL
: SwView::nInsertObjectCtrlState
= nValue
;break;
946 GetViewFrame()->GetBindings().Invalidate( nSlot
);
949 #if defined WIN || defined WNT || defined UNX
950 case SID_TWAIN_SELECT
:
951 case SID_TWAIN_TRANSFER
:
952 GetViewImpl()->ExecuteScan( rReq
);
956 case SID_ATTR_DEFTABSTOP
:
958 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(SID_ATTR_DEFTABSTOP
, FALSE
, &pItem
))
960 SvxTabStopItem
aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT
, RES_PARATR_TABSTOP
);
961 USHORT nTab
= ((const SfxUInt16Item
*)pItem
)->GetValue();
962 MakeDefTabs( nTab
, aDefTabs
);
963 pWrtShell
->SetDefault( aDefTabs
);
967 case SID_ATTR_LANGUAGE
:
968 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(SID_ATTR_LANGUAGE
, FALSE
, &pItem
))
970 SvxLanguageItem
aLang(((SvxLanguageItem
*)pItem
)->GetLanguage(), RES_CHRATR_LANGUAGE
);
971 pWrtShell
->SetDefault( aLang
);
972 lcl_SetAllTextToDefaultLanguage( *pWrtShell
, RES_CHRATR_LANGUAGE
);
975 case SID_ATTR_CHAR_CTL_LANGUAGE
:
976 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(RES_CHRATR_CTL_LANGUAGE
, FALSE
, &pItem
))
978 pWrtShell
->SetDefault( *pItem
);
979 lcl_SetAllTextToDefaultLanguage( *pWrtShell
, RES_CHRATR_CTL_LANGUAGE
);
982 case SID_ATTR_CHAR_CJK_LANGUAGE
:
983 if(pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(RES_CHRATR_CJK_LANGUAGE
, FALSE
, &pItem
))
985 pWrtShell
->SetDefault( *pItem
);
986 lcl_SetAllTextToDefaultLanguage( *pWrtShell
, RES_CHRATR_CJK_LANGUAGE
);
989 case FN_SCROLL_NEXT_PREV
:
990 if(pArgs
&& pArgs
->GetItemState(FN_SCROLL_NEXT_PREV
, FALSE
, &pItem
))
992 // call the handlers of PageUp/DownButtons, only
993 bool* pbNext
= new bool ( ((const SfxBoolItem
*)pItem
)->GetValue() );
994 // #i75416# move the execution of the search to an asynchronously called static link
995 Application::PostUserEvent( STATIC_LINK(this, SwView
, MoveNavigationHdl
), pbNext
);
999 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState(SID_JUMPTOMARK
, FALSE
, &pItem
))
1000 JumpToSwMark( (( const SfxStringItem
*)pItem
)->GetValue() );
1003 GetViewFrame()->ChildWindowExecute(rReq
);//ToggleChildWindow(SID_GALLERY);
1005 case SID_AVMEDIA_PLAYER
:
1006 GetViewFrame()->ChildWindowExecute(rReq
);//ToggleChildWindow(SID_AVMEDIA_PLAYER);
1008 case SID_VIEW_DATA_SOURCE_BROWSER
:
1010 SfxViewFrame
* pVFrame
= GetViewFrame();
1011 pVFrame
->ChildWindowExecute(rReq
);
1012 if(pVFrame
->HasChildWindow(SID_BROWSER
))
1014 const SwDBData
& rData
= GetWrtShell().GetDBDesc();
1015 SW_MOD()->ShowDBObj(*this, rData
, FALSE
);
1019 case FN_INSERT_FIELD_DATA_ONLY
:
1023 SFX_ITEM_SET
== pArgs
->GetItemState(nSlot
, FALSE
, &pItem
))
1024 bShow
= ((const SfxBoolItem
*)pItem
)->GetValue();
1025 //GetViewFrame()->ShowChildWindow(nSlot, bShow && bInMailMerge);
1026 if((bShow
&& bInMailMerge
) != GetViewFrame()->HasChildWindow(nSlot
))
1027 GetViewFrame()->ToggleChildWindow(nSlot
);
1028 //if fields have been succesfully inserted call the "real"
1030 SwWrtShell
&rSh
= GetWrtShell();
1031 if(bInMailMerge
&& rSh
.IsAnyDatabaseFieldInDoc())
1033 SwNewDBMgr
* pNewDBMgr
= rSh
.GetNewDBMgr();
1037 aData
= rSh
.GetDBData();
1038 rSh
.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
1039 // das Mischen von DB-Feldern notwendig.
1040 AttrChangedNotify( &rSh
);
1041 pNewDBMgr
->SetMergeType( DBMGR_MERGE
);
1043 Sequence
<PropertyValue
> aProperties(3);
1044 PropertyValue
* pValues
= aProperties
.getArray();
1045 pValues
[0].Name
= C2U("DataSourceName");
1046 pValues
[1].Name
= C2U("Command");
1047 pValues
[2].Name
= C2U("CommandType");
1048 pValues
[0].Value
<<= aData
.sDataSource
;
1049 pValues
[1].Value
<<= aData
.sCommand
;
1050 pValues
[2].Value
<<= aData
.nCommandType
;
1051 pNewDBMgr
->ExecuteFormLetter(rSh
, aProperties
, TRUE
);
1054 bInMailMerge
&= bShow
;
1055 GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD
);
1060 BOOL bUseCurrentDocument
= TRUE
;
1061 BOOL bQuery
= !pArgs
||SFX_ITEM_SET
!= pArgs
->GetItemState(nSlot
);
1064 SfxViewFrame
* pTmpFrame
= GetViewFrame();
1065 SfxHelp::OpenHelpAgent( pTmpFrame
->GetFrame(), HID_MAIL_MERGE_SELECT
);
1066 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
1067 DBG_ASSERT(pFact
, "Dialogdiet fail!");
1068 AbstractMailMergeCreateFromDlg
* pDlg
= pFact
->CreateMailMergeCreateFromDlg( DLG_MERGE_CREATE
,
1069 &pTmpFrame
->GetWindow());
1070 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
1071 if(RET_OK
== pDlg
->Execute())
1072 bUseCurrentDocument
= pDlg
->IsThisDocument();
1076 GenerateFormLetter(bUseCurrentDocument
);
1079 case SID_RECHECK_DOCUMENT
:
1081 SwDocShell
* pDocShell
= GetDocShell();
1082 SwDoc
* pDoc
= pDocShell
->GetDoc();
1083 uno::Reference
< linguistic2::XProofreadingIterator
> xGCIterator( pDoc
->GetGCIterator() );
1084 if( xGCIterator
.is() )
1086 xGCIterator
->resetIgnoreRules();
1088 // reset ignore lists
1089 pDoc
->SpellItAgainSam( sal_True
, sal_False
, sal_False
);
1090 // clear ignore dictionary
1091 uno::Reference
< linguistic2::XDictionary
> xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY
);
1092 if( xDictionary
.is() )
1093 xDictionary
->clear();
1094 // put cursor to the start of the document
1095 pWrtShell
->SttDoc();
1097 // no break; - but call spell/grammar dialog
1098 case FN_SPELL_GRAMMAR_DIALOG
:
1100 SfxViewFrame
* pViewFrame
= GetViewFrame();
1101 if (rReq
.GetArgs() != NULL
)
1102 pViewFrame
->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG
,
1103 ((const SfxBoolItem
&) (rReq
.GetArgs()->
1104 Get(FN_SPELL_GRAMMAR_DIALOG
))).GetValue());
1106 pViewFrame
->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG
);
1108 pViewFrame
->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG
);
1112 case SID_ALIGN_ANY_LEFT
:
1113 case SID_ALIGN_ANY_HCENTER
:
1114 case SID_ALIGN_ANY_RIGHT
:
1115 case SID_ALIGN_ANY_JUSTIFIED
:
1116 case SID_ALIGN_ANY_TOP
:
1117 case SID_ALIGN_ANY_VCENTER
:
1118 case SID_ALIGN_ANY_BOTTOM
:
1119 case SID_ALIGN_ANY_HDEFAULT
:
1120 case SID_ALIGN_ANY_VDEFAULT
:
1123 if( nSelectionType
& (nsSelectionType::SEL_DRW_TXT
|nsSelectionType::SEL_TXT
) )
1127 case SID_ALIGN_ANY_LEFT
: nAlias
= SID_ATTR_PARA_ADJUST_LEFT
; break;
1128 case SID_ALIGN_ANY_HCENTER
: nAlias
= SID_ATTR_PARA_ADJUST_CENTER
; break;
1129 case SID_ALIGN_ANY_RIGHT
: nAlias
= SID_ATTR_PARA_ADJUST_RIGHT
; break;
1130 case SID_ALIGN_ANY_JUSTIFIED
: nAlias
= SID_ATTR_PARA_ADJUST_BLOCK
; break;
1131 case SID_ALIGN_ANY_TOP
: nAlias
= FN_TABLE_VERT_NONE
; break;
1132 case SID_ALIGN_ANY_VCENTER
: nAlias
= FN_TABLE_VERT_CENTER
; break;
1133 case SID_ALIGN_ANY_BOTTOM
: nAlias
= FN_TABLE_VERT_BOTTOM
; break;
1140 case SID_ALIGN_ANY_LEFT
: nAlias
= SID_OBJECT_ALIGN_LEFT
; break;
1141 case SID_ALIGN_ANY_HCENTER
: nAlias
= SID_OBJECT_ALIGN_CENTER
; break;
1142 case SID_ALIGN_ANY_RIGHT
: nAlias
= SID_OBJECT_ALIGN_RIGHT
; break;
1143 case SID_ALIGN_ANY_TOP
: nAlias
= SID_OBJECT_ALIGN_UP
; break;
1144 case SID_ALIGN_ANY_VCENTER
: nAlias
= SID_OBJECT_ALIGN_MIDDLE
; break;
1145 case SID_ALIGN_ANY_BOTTOM
: nAlias
= SID_OBJECT_ALIGN_DOWN
; break;
1148 //special handling for the draw shell
1149 if(nAlias
&& (nSelectionType
& (nsSelectionType::SEL_DRW
)))
1151 SfxAllEnumItem
aEnumItem(SID_OBJECT_ALIGN
, nAlias
- SID_OBJECT_ALIGN_LEFT
);
1152 GetViewFrame()->GetDispatcher()->Execute(
1153 SID_OBJECT_ALIGN
, SFX_CALLMODE_ASYNCHRON
, &aEnumItem
, 0L);
1156 //these slots are either re-mapped to text or object alignment
1157 GetViewFrame()->GetDispatcher()->Execute(
1158 nAlias
, SFX_CALLMODE_ASYNCHRON
);
1161 case SID_RESTORE_EDITING_VIEW
:
1163 //#i33307# restore editing position
1166 if(pViewImpl
->GetRestorePosition(aCrsrPos
, bSelectObj
))
1168 pWrtShell
->SwCrsrShell::SetCrsr( aCrsrPos
, !bSelectObj
);
1171 pWrtShell
->SelectObj( aCrsrPos
);
1172 pWrtShell
->EnterSelFrmMode( &aCrsrPos
);
1177 case SID_INSERT_GRAPHIC
:
1179 rReq
.SetReturnValue(SfxBoolItem(nSlot
, InsertGraphicDlg( rReq
)));
1185 ASSERT(!this, falscher Dispatcher
);
1192 /*--------------------------------------------------------------------
1193 Beschreibung: SeitenNr-Feld invalidieren
1194 --------------------------------------------------------------------*/
1196 void SwView::UpdatePageNums(USHORT nPhyNum
, USHORT nVirtNum
, const String
& rPgStr
)
1198 String
sTemp(GetPageStr( nPhyNum
, nVirtNum
, rPgStr
));
1199 const SfxStringItem
aTmp( FN_STAT_PAGE
, sTemp
);
1200 SfxBindings
&rBnd
= GetViewFrame()->GetBindings();
1201 rBnd
.SetState( aTmp
);
1202 rBnd
.Update( FN_STAT_PAGE
);
1205 /*--------------------------------------------------------------------
1206 Beschreibung: Status der Stauszeile
1207 --------------------------------------------------------------------*/
1210 void SwView::StateStatusLine(SfxItemSet
&rSet
)
1212 SwWrtShell
& rShell
= GetWrtShell();
1214 SfxWhichIter
aIter( rSet
);
1215 USHORT nWhich
= aIter
.FirstWhich();
1216 ASSERT( nWhich
, "leeres Set");
1224 //JP 07.01.00: is a nice feature - show the selektion of DrawObjects
1225 if( rShell.IsObjSelected()
1226 //??? || rShell.IsFrmSelected()
1229 String sDisplay( rShell.GetDrawView()->GetMarkedObjectList().
1230 GetDescriptionOfMarkedObjects() );
1231 rSet.Put( SfxStringItem( FN_STAT_PAGE, sDisplay ));
1235 // Anzahl der Seiten, log. SeitenNr. SeitenNr ermitteln
1236 USHORT nPage
, nLogPage
;
1238 rShell
.GetPageNumber( -1, rShell
.IsCrsrVisible(), nPage
, nLogPage
, sDisplay
);
1239 rSet
.Put( SfxStringItem( FN_STAT_PAGE
,
1240 GetPageStr( nPage
, nLogPage
, sDisplay
) ));
1242 USHORT nCnt
= GetWrtShell().GetPageCnt();
1243 if (nPageCnt
!= nCnt
) // Basic benachrichtigen
1246 SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT
, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT
), GetViewFrame()->GetObjectShell()), FALSE
);
1250 case FN_STAT_TEMPLATE
:
1252 rSet
.Put(SfxStringItem( FN_STAT_TEMPLATE
,
1253 rShell
.GetCurPageStyle(FALSE
)));
1259 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
) || !GetDocShell()->IsInPlaceActive() )
1261 const SwViewOption
* pVOpt
= rShell
.GetViewOptions();
1262 SvxZoomType eZoom
= (SvxZoomType
) pVOpt
->GetZoomType();
1263 SvxZoomItem
aZoom(eZoom
, pVOpt
->GetZoom());
1264 if(pWrtShell
->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE
))
1269 SVX_ZOOM_ENABLE_100
|
1270 SVX_ZOOM_ENABLE_150
|
1271 SVX_ZOOM_ENABLE_200
);
1276 rSet
.DisableItem( SID_ATTR_ZOOM
);
1279 case SID_ATTR_VIEWLAYOUT
:
1281 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
) || !GetDocShell()->IsInPlaceActive() )
1283 const SwViewOption
* pVOpt
= rShell
.GetViewOptions();
1284 const USHORT nColumns
= pVOpt
->GetViewLayoutColumns();
1285 const bool bBookMode
= pVOpt
->IsViewLayoutBookMode();
1286 SvxViewLayoutItem
aViewLayout(nColumns
, bBookMode
);
1287 rSet
.Put( aViewLayout
);
1290 rSet
.DisableItem( SID_ATTR_VIEWLAYOUT
);
1293 case SID_ATTR_ZOOMSLIDER
:
1295 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
) || !GetDocShell()->IsInPlaceActive() )
1297 const SwViewOption
* pVOpt
= rShell
.GetViewOptions();
1298 const USHORT nCurrentZoom
= pVOpt
->GetZoom();
1299 SvxZoomSliderItem
aZoomSliderItem( nCurrentZoom
, MINZOOM
, MAXZOOM
);
1300 aZoomSliderItem
.AddSnappingPoint( 100 );
1302 if ( !pWrtShell
->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE
) )
1304 const USHORT nColumns
= pVOpt
->GetViewLayoutColumns();
1305 const bool bAutomaticViewLayout
= 0 == nColumns
;
1306 const SwPostItMgr
* pMgr
= GetPostItMgr();
1309 // automatic mode: 1 Page, 2 Pages, 100%
1310 // n Columns mode: n Pages, 100%
1311 // n Columns book mode: nPages without gaps, 100%
1312 const SwRect
aPageRect( pWrtShell
->GetAnyCurRect( RECT_PAGE_CALC
) );
1313 const SwRect
aRootRect( pWrtShell
->GetAnyCurRect( RECT_PAGES_AREA
) ); // width of columns
1314 Size
aPageSize( aPageRect
.SSize() );
1315 aPageSize
.Width() += pMgr
->HasNotes() && pMgr
->ShowNotes() ?
1316 pMgr
->GetSidebarWidth() + pMgr
->GetSidebarBorderWidth() :
1319 Size
aRootSize( aRootRect
.SSize() );
1321 const MapMode
aTmpMap( MAP_TWIP
);
1322 const Size
& rEditSize
= GetEditWin().GetOutputSizePixel();
1323 const Size
aWindowSize( GetEditWin().PixelToLogic( rEditSize
, aTmpMap
) );
1325 const long nOf
= DOCUMENTBORDER
* 2L;
1326 long nTmpWidth
= bAutomaticViewLayout
? aPageSize
.Width() : aRootSize
.Width();
1328 aPageSize
.Height() += nOf
;
1329 long nFac
= aWindowSize
.Width() * 100 / nTmpWidth
;
1331 long nVisPercent
= aWindowSize
.Height() * 100 / aPageSize
.Height();
1332 nFac
= Min( nFac
, nVisPercent
);
1334 aZoomSliderItem
.AddSnappingPoint( nFac
);
1336 if ( bAutomaticViewLayout
)
1338 nTmpWidth
+= aPageSize
.Width() + GAPBETWEENPAGES
;
1339 nFac
= aWindowSize
.Width() * 100 / nTmpWidth
;
1340 nFac
= Min( nFac
, nVisPercent
);
1341 aZoomSliderItem
.AddSnappingPoint( nFac
);
1345 rSet
.Put( aZoomSliderItem
);
1348 rSet
.DisableItem( SID_ATTR_ZOOMSLIDER
);
1351 case SID_ATTR_POSITION
:
1354 if( !rShell
.IsFrmSelected() && !rShell
.IsObjSelected() )
1355 SwBaseShell::_SetFrmMode( FLY_DRAG_END
);
1358 FlyMode eFrameMode
= SwBaseShell::GetFrmMode();
1359 if ( eFrameMode
== FLY_DRAG_START
|| eFrameMode
== FLY_DRAG
)
1361 if ( nWhich
== SID_ATTR_POSITION
)
1362 rSet
.Put( SfxPointItem( SID_ATTR_POSITION
,
1363 rShell
.GetAnchorObjDiff()));
1365 rSet
.Put( SvxSizeItem( SID_ATTR_SIZE
,
1366 rShell
.GetObjSize()));
1371 case SID_TABLE_CELL
:
1373 if( rShell
.IsFrmSelected() || rShell
.IsObjSelected() )
1375 // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
1376 // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
1377 // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
1378 // in SID_ATTR_SIZE).
1383 if( rShell
.IsCrsrInTbl() )
1385 // table name + cell coordinate
1386 sStr
= rShell
.GetTableFmt()->GetName();
1388 sStr
+= rShell
.GetBoxNms();
1392 const SwSection
* pCurrSect
= rShell
.GetCurrSection();
1395 switch( pCurrSect
->GetType() )
1397 case TOX_HEADER_SECTION
:
1398 case TOX_CONTENT_SECTION
:
1400 const SwTOXBase
* pTOX
= pWrtShell
->GetCurTOX();
1402 sStr
= pTOX
->GetTOXName();
1406 "was ist das fuer ein Verzeichnis?" );
1407 sStr
= pCurrSect
->GetName();
1412 sStr
= pCurrSect
->GetName();
1418 //#outline level, removed by zhaojianwei
1419 //const SwNumRule* pNumRule = rShell.GetCurNumRule();
1420 //if (pNumRule) // Cursor in Numerierung
1422 // BYTE nNumLevel = rShell.GetNumLevel();
1423 // if( IsShowNum(nNumLevel) && MAXLEVEL >
1424 // ( nNumLevel = GetRealLevel( nNumLevel )) )
1427 // sStr.AppendAscii(sStatusDelim);
1428 // sStr += SW_RESSTR(STR_NUM_LEVEL);
1429 // sStr += String::CreateFromInt32( nNumLevel + 1 );
1430 // if(!pNumRule->IsAutoRule())
1432 // SfxItemSet aSet(GetPool(),
1433 // RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
1434 // rShell.GetCurAttr(aSet);
1435 // /* const SfxPoolItem* pItem; */
1436 // if(SFX_ITEM_AVAILABLE <=
1437 // aSet.GetItemState(RES_PARATR_NUMRULE, TRUE
1440 // const String& rNumStyle =
1441 // ((const SfxStringItem &)
1442 // aSet.Get(RES_PARATR_NUMRULE)).GetValue();
1443 // /* #i5116# GetItemState does not necessarily
1445 // // ((const SfxStringItem*)pItem)->GetValue();
1446 // if(rNumStyle.Len())
1448 // sStr.AppendAscii(sStatusDelim);
1449 // sStr += rNumStyle;
1454 //}//<-removed end ,zhaojianwei
1456 //-->#outline level,added by zhaojianwei
1457 const SwNumRule
* pNumRule
= rShell
.GetCurNumRule();
1458 const bool bOutlineNum
= pNumRule
? pNumRule
->IsOutlineRule() : 0;
1459 //((SwTxtFmtColl*)rShell.GetCrsr()->GetNode()->GetTxtNode()->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle();
1461 if (pNumRule
&& !bOutlineNum
) // Cursor in Numerierung
1463 BYTE nNumLevel
= rShell
.GetNumLevel();
1464 // --> OD 2008-04-02 #refactorlists#
1465 // if( IsShowNum(nNumLevel) && MAXLEVEL >
1466 // ( nNumLevel = GetRealLevel( nNumLevel )) )
1467 if ( nNumLevel
< MAXLEVEL
)
1470 if(!pNumRule
->IsAutoRule())
1472 SfxItemSet
aSet(GetPool(),
1473 RES_PARATR_NUMRULE
, RES_PARATR_NUMRULE
);
1474 rShell
.GetCurAttr(aSet
);
1475 /* const SfxPoolItem* pItem; */
1476 if(SFX_ITEM_AVAILABLE
<=
1477 aSet
.GetItemState(RES_PARATR_NUMRULE
, TRUE
1480 const String
& rNumStyle
=
1481 ((const SfxStringItem
&)
1482 aSet
.Get(RES_PARATR_NUMRULE
)).GetValue();
1483 /* #i5116# GetItemState does not necessarily
1485 // ((const SfxStringItem*)pItem)->GetValue();
1489 sStr
.AppendAscii(sStatusDelim
);
1495 sStr
.AppendAscii(sStatusDelim
);
1496 sStr
+= SW_RESSTR(STR_NUM_LEVEL
);
1497 sStr
+= String::CreateFromInt32( nNumLevel
+ 1 );
1501 const int nOutlineLevel
= rShell
.GetCurrentParaOutlineLevel();
1502 if( nOutlineLevel
!= 0 )
1505 sStr
.AppendAscii(sStatusComma
);
1508 sStr
+= SW_RESSTR(STR_OUTLINE_NUMBERING
);
1509 sStr
.AppendAscii(sStatusDelim
);
1510 sStr
+= SW_RESSTR(STR_NUM_LEVEL
);
1513 sStr
+= SW_RESSTR(STR_NUM_OUTLINE
);
1514 sStr
+= String::CreateFromInt32( nOutlineLevel
);
1516 //<-end ,zhaojianwei
1518 if( rShell
.HasReadonlySel() )
1521 sStr
.InsertAscii( sStatusDelim
, 0 );
1522 sStr
.Insert( SW_RESSTR( STR_READONLY_SEL
), 0 );
1525 rSet
.Put( SfxStringItem( SID_TABLE_CELL
, sStr
));
1528 case FN_STAT_SELMODE
:
1530 if(rShell
.IsStdMode())
1531 rSet
.Put(SfxUInt16Item(FN_STAT_SELMODE
, 0));
1532 else if(rShell
.IsAddMode())
1533 rSet
.Put(SfxUInt16Item(FN_STAT_SELMODE
, 2));
1534 else if(rShell
.IsBlockMode())
1535 rSet
.Put(SfxUInt16Item(FN_STAT_SELMODE
, 3));
1537 rSet
.Put(SfxUInt16Item(FN_STAT_SELMODE
, 1));
1540 case SID_ATTR_INSERT
:
1541 if( rShell
.IsRedlineOn() )
1542 rSet
.DisableItem( nWhich
);
1545 rSet
.Put(SfxBoolItem(SID_ATTR_INSERT
,rShell
.IsInsMode()));
1549 nWhich
= aIter
.NextWhich();
1553 /*--------------------------------------------------------------------
1554 Beschreibung: Execute fuer die Stauszeile
1555 --------------------------------------------------------------------*/
1558 void SwView::ExecuteStatusLine(SfxRequest
&rReq
)
1560 SwWrtShell
&rSh
= GetWrtShell();
1561 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1562 const SfxPoolItem
* pItem
=NULL
;
1564 USHORT nWhich
= rReq
.GetSlot();
1569 GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR
,
1570 SFX_CALLMODE_SYNCHRON
|SFX_CALLMODE_RECORD
);
1574 case FN_STAT_BOOKMARK
:
1577 if (SFX_ITEM_SET
== pArgs
->GetItemState( nWhich
, TRUE
, &pItem
))
1579 const IDocumentMarkAccess
* pMarkAccess
= rSh
.getIDocumentMarkAccess();
1580 const sal_Int32 nIdx
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1581 if(nIdx
< pMarkAccess
->getBookmarksCount())
1583 const IDocumentMarkAccess::const_iterator_t ppBookmark
= rSh
.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx
;
1585 rSh
.GotoMark( ppBookmark
->get() );
1589 "SwView::ExecuteStatusLine(..)"
1590 " - Ignoring out of range bookmark index");
1595 case FN_STAT_TEMPLATE
:
1597 GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG
,
1598 SFX_CALLMODE_SYNCHRON
|SFX_CALLMODE_RECORD
);
1603 if ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
) || !GetDocShell()->IsInPlaceActive() )
1605 const SfxItemSet
*pSet
= 0;
1606 AbstractSvxZoomDialog
*pDlg
= 0;
1611 const SwViewOption
& rViewOptions
= *rSh
.GetViewOptions();
1612 SfxItemSet
aCoreSet(pShell
->GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
, SID_ATTR_VIEWLAYOUT
, SID_ATTR_VIEWLAYOUT
, 0 );
1613 SvxZoomItem
aZoom( (SvxZoomType
)rViewOptions
.GetZoomType(), rViewOptions
.GetZoom() );
1615 const bool bBrowseMode
= rSh
.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE
);
1621 SVX_ZOOM_ENABLE_100
|
1622 SVX_ZOOM_ENABLE_150
|
1623 SVX_ZOOM_ENABLE_200
);
1625 aCoreSet
.Put( aZoom
);
1630 const SvxViewLayoutItem
aViewLayout( rViewOptions
.GetViewLayoutColumns(), rViewOptions
.IsViewLayoutBookMode() );
1631 aCoreSet
.Put( aViewLayout
);
1634 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1637 pDlg
= pFact
->CreateSvxZoomDialog(&GetViewFrame()->GetWindow(), aCoreSet
, RID_SVXDLG_ZOOM
);
1638 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
1641 pDlg
->SetLimits( MINZOOM
, MAXZOOM
);
1643 if( pDlg
->Execute() != RET_CANCEL
)
1644 pSet
= pDlg
->GetOutputItemSet();
1648 const SfxPoolItem
* pViewLayoutItem
= 0;
1649 if ( pSet
&& SFX_ITEM_SET
== pSet
->GetItemState(SID_ATTR_VIEWLAYOUT
, TRUE
, &pViewLayoutItem
))
1651 const USHORT nColumns
= ((const SvxViewLayoutItem
*)pViewLayoutItem
)->GetValue();
1652 const bool bBookMode
= ((const SvxViewLayoutItem
*)pViewLayoutItem
)->IsBookMode();
1653 SetViewLayout( nColumns
, bBookMode
);
1656 if ( pSet
&& SFX_ITEM_SET
== pSet
->GetItemState(SID_ATTR_ZOOM
, TRUE
, &pItem
))
1658 enum SvxZoomType eType
= ((const SvxZoomItem
*)pItem
)->GetType();
1659 SetZoom( eType
, ((const SvxZoomItem
*)pItem
)->GetValue() );
1663 rReq
.AppendItem( *pItem
);
1671 case SID_ATTR_VIEWLAYOUT
:
1673 if ( pArgs
&& !rSh
.getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE
) &&
1674 ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
) || !GetDocShell()->IsInPlaceActive() ) )
1677 if ( SFX_ITEM_SET
== pArgs
->GetItemState(SID_ATTR_VIEWLAYOUT
, TRUE
, &pItem
))
1679 const USHORT nColumns
= ((const SvxViewLayoutItem
*)pItem
)->GetValue();
1680 const bool bBookMode
= (0 == nColumns
|| 0 != (nColumns
% 2)) ?
1682 ((const SvxViewLayoutItem
*)pItem
)->IsBookMode();
1684 SetViewLayout( nColumns
, bBookMode
);
1690 InvalidateRulerPos();
1695 case SID_ATTR_ZOOMSLIDER
:
1697 if ( pArgs
&& ( ( GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED
) || !GetDocShell()->IsInPlaceActive() ) )
1700 if ( SFX_ITEM_SET
== pArgs
->GetItemState(SID_ATTR_ZOOMSLIDER
, TRUE
, &pItem
))
1702 const USHORT nCurrentZoom
= ((const SvxZoomSliderItem
*)pItem
)->GetValue();
1703 SetZoom( SVX_ZOOM_PERCENT
, nCurrentZoom
);
1714 ULONG nId
= FN_INSERT_FIELD
;
1715 if( rSh
.IsCrsrInTbl() )
1716 nId
= FN_FORMAT_TABLE_DLG
;
1717 else if( rSh
.GetCurTOX() )
1718 nId
= FN_INSERT_MULTI_TOX
;
1719 else if( rSh
.GetCurrSection() )
1720 nId
= FN_EDIT_REGION
;
1723 const SwNumRule
* pNumRule
= rSh
.GetCurNumRule();
1724 if( pNumRule
) // Cursor in Numerierung
1726 if( pNumRule
->IsAutoRule() )
1727 nId
= FN_NUMBER_BULLETS
;
1730 // Dialog vom Gestalter starten ;-)
1734 else if( rSh
.IsFrmSelected() )
1735 nId
= FN_FORMAT_FRAME_DLG
;
1736 else if( rSh
.IsObjSelected() )
1737 nId
= SID_ATTR_TRANSFORM
;
1740 GetViewFrame()->GetDispatcher()->Execute(
1741 static_cast< USHORT
>( nId
), SFX_CALLMODE_SYNCHRON
| SFX_CALLMODE_RECORD
);
1745 case FN_STAT_SELMODE
:
1749 if (SFX_ITEM_SET
== pArgs
->GetItemState( nWhich
, TRUE
, &pItem
))
1751 switch ( ((const SfxUInt16Item
*)pItem
)->GetValue() )
1753 case 0: rSh
.EnterStdMode(); break;
1754 case 1: rSh
.EnterExtMode(); break;
1755 case 2: rSh
.EnterAddMode(); break;
1756 case 3: rSh
.EnterBlockMode(); break;
1763 if( !rSh
.IsAddMode() && !rSh
.IsExtMode() && !rSh
.IsBlockMode() )
1764 rSh
.ToggleExtMode();
1765 else if ( rSh
.IsExtMode() )
1767 rSh
.ToggleExtMode();
1768 rSh
.ToggleAddMode();
1770 else if ( rSh
.IsAddMode() )
1772 rSh
.ToggleAddMode();
1773 rSh
.ToggleBlockMode();
1776 rSh
.ToggleBlockMode();
1781 case FN_SET_ADD_MODE
:
1782 rSh
.ToggleAddMode();
1783 nWhich
= FN_STAT_SELMODE
;
1786 case FN_SET_BLOCK_MODE
:
1787 rSh
.ToggleBlockMode();
1788 nWhich
= FN_STAT_SELMODE
;
1791 case FN_SET_EXT_MODE
:
1792 rSh
.ToggleExtMode();
1793 nWhich
= FN_STAT_SELMODE
;
1796 case SID_ATTR_INSERT
:
1797 SwPostItMgr
* pMgr
= GetPostItMgr();
1798 if (pMgr
&& pMgr
->GetActivePostIt())
1799 pMgr
->GetActivePostIt()->ToggleInsMode();
1801 rSh
.ToggleInsMode();
1808 SfxBindings
&rBnd
= GetViewFrame()->GetBindings();
1809 rBnd
.Invalidate(nWhich
);
1810 rBnd
.Update(nWhich
);
1817 void SwView::InsFrmMode(USHORT nCols
)
1819 if ( pWrtShell
->HasWholeTabSelection() )
1821 SwFlyFrmAttrMgr
aMgr( TRUE
, pWrtShell
, FRMMGR_TYPE_TEXT
);
1823 const SwFrmFmt
&rPageFmt
=
1824 pWrtShell
->GetPageDesc(pWrtShell
->GetCurPageDesc()).GetMaster();
1825 SwTwips lWidth
= rPageFmt
.GetFrmSize().GetWidth();
1826 const SvxLRSpaceItem
&rLR
= rPageFmt
.GetLRSpace();
1827 lWidth
-= rLR
.GetLeft() + rLR
.GetRight();
1828 aMgr
.SetSize(Size(lWidth
, aMgr
.GetSize().Height()));
1832 aCol
.Init( nCols
, aCol
.GetGutterWidth(), aCol
.GetWishWidth() );
1833 aMgr
.SetCol( aCol
);
1835 aMgr
.InsertFlyFrm();
1838 GetEditWin().InsFrm(nCols
);
1841 /*--------------------------------------------------------------------
1842 Beschreibung: Links bearbeiten
1843 --------------------------------------------------------------------*/
1845 void SwView::EditLinkDlg()
1847 BOOL bWeb
= 0 != PTR_CAST(SwWebView
, this);
1848 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1849 SfxAbstractLinksDialog
* pDlg
= pFact
->CreateLinksDialog( &GetViewFrame()->GetWindow(), &GetWrtShell().GetLinkManager(), bWeb
);
1856 SwLinkDlg* pDlg = new SwLinkDlg(GetFrameWindow());
1857 pDlg->SetShell(&GetWrtShell());
1864 BOOL
SwView::JumpToSwMark( const String
& rMark
)
1869 // wir wollen den Bookmark aber am oberen Rand haben
1870 BOOL bSaveCC
= IsCrsrAtCenter();
1871 BOOL bSaveCT
= IsCrsrAtTop();
1872 SetCrsrAtTop( TRUE
);
1874 //JP 27.04.98: Bug 49786
1875 // Damit in FrameSet auch gescrollt werden kann, muss die
1876 // entsprechende Shell auch das Focus-Flag gesetzt haben!
1877 BOOL bHasShFocus
= pWrtShell
->HasShFcs();
1879 pWrtShell
->ShGetFcs( FALSE
);
1881 const SwFmtINetFmt
* pINet
;
1882 String sCmp
, sMark( INetURLObject::decode( rMark
, INET_HEX_ESCAPE
,
1883 INetURLObject::DECODE_WITH_CHARSET
,
1884 RTL_TEXTENCODING_UTF8
));
1886 xub_StrLen nLastPos
, nPos
= sMark
.Search( cMarkSeperator
);
1887 if( STRING_NOTFOUND
!= nPos
)
1888 while( STRING_NOTFOUND
!= ( nLastPos
=
1889 sMark
.Search( cMarkSeperator
, nPos
+ 1 )) )
1892 IDocumentMarkAccess::const_iterator_t ppMark
;
1893 IDocumentMarkAccess
* const pMarkAccess
= pWrtShell
->getIDocumentMarkAccess();
1894 if( STRING_NOTFOUND
!= nPos
&&
1895 ( sCmp
= sMark
.Copy( nPos
+ 1 ) ).EraseAllChars().Len() )
1897 String
sName( sMark
.Copy( 0, nPos
) );
1898 sCmp
.ToLowerAscii();
1899 FlyCntType eFlyType
= FLYCNTTYPE_ALL
;
1901 if( COMPARE_EQUAL
== sCmp
.CompareToAscii( pMarkToRegion
) )
1903 pWrtShell
->EnterStdMode();
1904 bRet
= pWrtShell
->GotoRegion( sName
);
1906 else if( COMPARE_EQUAL
== sCmp
.CompareToAscii( pMarkToOutline
) )
1908 pWrtShell
->EnterStdMode();
1909 bRet
= pWrtShell
->GotoOutline( sName
);
1911 else if( COMPARE_EQUAL
== sCmp
.CompareToAscii( pMarkToFrame
) )
1912 eFlyType
= FLYCNTTYPE_FRM
;
1913 else if( COMPARE_EQUAL
== sCmp
.CompareToAscii( pMarkToGraphic
) )
1914 eFlyType
= FLYCNTTYPE_GRF
;
1915 else if( COMPARE_EQUAL
== sCmp
.CompareToAscii( pMarkToOLE
) )
1916 eFlyType
= FLYCNTTYPE_OLE
;
1917 else if( COMPARE_EQUAL
== sCmp
.CompareToAscii( pMarkToTable
) )
1919 pWrtShell
->EnterStdMode();
1920 bRet
= pWrtShell
->GotoTable( sName
);
1922 else if( COMPARE_EQUAL
== sCmp
.CompareToAscii( pMarkToText
) )
1924 // Normale Textsuche
1925 pWrtShell
->EnterStdMode();
1927 SearchOptions
aSearchOpt(
1928 SearchAlgorithms_ABSOLUTE
, 0,
1929 sName
, rtl::OUString(),
1930 SvxCreateLocale( LANGUAGE_SYSTEM
),
1932 TransliterationModules_IGNORE_CASE
);
1934 //todo/mba: assuming that notes shouldn't be searched
1935 BOOL bSearchInNotes
= FALSE
;
1936 if( pWrtShell
->SearchPattern( aSearchOpt
, bSearchInNotes
, DOCPOS_START
, DOCPOS_END
))
1938 pWrtShell
->EnterStdMode(); // Selektion wieder aufheben
1942 else if( pMarkAccess
->getMarksEnd() != (ppMark
= pMarkAccess
->findMark(sMark
)) )
1943 pWrtShell
->GotoMark( ppMark
->get(), FALSE
, TRUE
), bRet
= TRUE
;
1944 else if( 0 != ( pINet
= pWrtShell
->FindINetAttr( sMark
) ))
1945 bRet
= pWrtShell
->GotoINetAttr( *pINet
->GetTxtINetFmt() );
1947 // fuer alle Arten von Flys
1948 if( FLYCNTTYPE_ALL
!= eFlyType
&& pWrtShell
->GotoFly( sName
, eFlyType
))
1951 if( FLYCNTTYPE_FRM
== eFlyType
)
1953 // TextFrames: Cursor in den Frame setzen
1954 pWrtShell
->UnSelectFrm();
1955 pWrtShell
->LeaveSelFrmMode();
1959 pWrtShell
->HideCrsr();
1960 pWrtShell
->EnterSelFrmMode();
1964 else if( pMarkAccess
->getMarksEnd() != (ppMark
= pMarkAccess
->findMark(sMark
)))
1965 pWrtShell
->GotoMark( ppMark
->get(), FALSE
, TRUE
), bRet
= TRUE
;
1966 else if( 0 != ( pINet
= pWrtShell
->FindINetAttr( sMark
) ))
1967 bRet
= pWrtShell
->GotoINetAttr( *pINet
->GetTxtINetFmt() );
1969 // #b6330459# make selection visible later
1970 if ( aVisArea
.IsEmpty() )
1971 bMakeSelectionVisible
= sal_True
;
1973 // ViewStatus wieder zurueck setzen
1974 SetCrsrAtTop( bSaveCT
, bSaveCC
);
1977 pWrtShell
->ShLooseFcs();
1982 // #i67305, #1367991: Undo after insert from file:
1983 // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
1984 // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
1985 // page styles with active header/footer => disabled for those documents
1987 sal_uInt16
lcl_PageDescWithHeader( const SwDoc
& rDoc
)
1989 sal_uInt16 nRet
= 0;
1990 sal_uInt16 nCnt
= rDoc
.GetPageDescCnt();
1991 for( sal_uInt16 i
= 0; i
< nCnt
; ++i
)
1993 const SwPageDesc
& rPageDesc
= rDoc
.GetPageDesc( i
);
1994 const SwFrmFmt
& rMaster
= rPageDesc
.GetMaster();
1995 const SfxPoolItem
* pItem
;
1996 if( ( SFX_ITEM_SET
== rMaster
.GetAttrSet().GetItemState( RES_HEADER
, FALSE
, &pItem
) &&
1997 ((SwFmtHeader
*)pItem
)->IsActive() ) ||
1998 ( SFX_ITEM_SET
== rMaster
.GetAttrSet().GetItemState( RES_FOOTER
, FALSE
, &pItem
) &&
1999 ((SwFmtFooter
*)pItem
)->IsActive()) )
2002 return nRet
; // number of page styles with active header/footer
2005 /*--------------------------------------------------------------------
2006 Beschreibung: Links bearbeiten
2007 --------------------------------------------------------------------*/
2009 void SwView::ExecuteInsertDoc( SfxRequest
& rRequest
, const SfxPoolItem
* pItem
)
2011 pViewImpl
->InitRequest( rRequest
);
2012 pViewImpl
->SetParam( pItem
? 1 : 0 );
2013 USHORT nSlot
= rRequest
.GetSlot();
2018 InsertDoc( nSlot
, sEmpty
, sEmpty
);
2022 String sFile
, sFilter
;
2023 sFile
= ( (const SfxStringItem
*)pItem
)->GetValue();
2024 if ( SFX_ITEM_SET
== rRequest
.GetArgs()->GetItemState( FN_PARAM_1
, TRUE
, &pItem
) )
2025 sFilter
= ( (const SfxStringItem
*)pItem
)->GetValue();
2027 bool bHasFileName
= ( sFile
.Len() > 0 );
2028 long nFound
= InsertDoc( nSlot
, sFile
, sFilter
);
2032 rRequest
.SetReturnValue( SfxBoolItem( nSlot
, nFound
!= -1 ) );
2038 long SwView::InsertDoc( USHORT nSlotId
, const String
& rFileName
, const String
& rFilterName
, INT16 nVersion
)
2040 SfxMedium
* pMed
= 0;
2041 SwDocShell
* pDocSh
= GetDocShell();
2043 if( rFileName
.Len() )
2045 SfxObjectFactory
& rFact
= pDocSh
->GetFactory();
2046 const SfxFilter
* pFilter
= rFact
.GetFilterContainer()->GetFilter4FilterName( rFilterName
);
2049 pMed
= new SfxMedium(rFileName
, STREAM_READ
, TRUE
, 0, 0 );
2050 SfxFilterMatcher
aMatcher( rFact
.GetFilterContainer()->GetName() );
2051 pMed
->UseInteractionHandler( TRUE
);
2052 ErrCode nErr
= aMatcher
.GuessFilter( *pMed
, &pFilter
, FALSE
);
2056 pMed
->SetFilter( pFilter
);
2059 pMed
= new SfxMedium(rFileName
, STREAM_READ
, TRUE
, pFilter
, 0);
2063 String sFactory
= String::CreateFromAscii( pDocSh
->GetFactory().GetShortName() );
2064 pViewImpl
->StartDocumentInserter( sFactory
, LINK( this, SwView
, DialogClosedHdl
) );
2071 return InsertMedium( nSlotId
, pMed
, nVersion
);
2074 long SwView::InsertMedium( USHORT nSlotId
, SfxMedium
* pMedium
, INT16 nVersion
)
2076 BOOL bInsert
= FALSE
, bCompare
= FALSE
, bMerge
= FALSE
;
2078 SwDocShell
* pDocSh
= GetDocShell();
2082 case SID_DOCUMENT_MERGE
: bMerge
= TRUE
; break;
2083 case SID_DOCUMENT_COMPARE
: bCompare
= TRUE
; break;
2084 case SID_INSERTDOC
: bInsert
= TRUE
; break;
2087 ASSERT( !this, "Unbekannte SlotId!" );
2089 nSlotId
= SID_INSERTDOC
;
2095 uno::Reference
< frame::XDispatchRecorder
> xRecorder
=
2096 GetViewFrame()->GetBindings().GetRecorder();
2097 if ( xRecorder
.is() )
2099 SfxRequest
aRequest(GetViewFrame(), SID_INSERTDOC
);
2100 aRequest
.AppendItem(SfxStringItem(SID_INSERTDOC
, pMedium
->GetOrigURL()));
2101 if(pMedium
->GetFilter())
2102 aRequest
.AppendItem(SfxStringItem(FN_PARAM_1
, pMedium
->GetFilter()->GetName()));
2106 SfxObjectShellRef
aRef( pDocSh
);
2108 sal_uInt32 nError
= SfxObjectShell::HandleFilter( pMedium
, pDocSh
);
2109 // #i16722# aborted?
2110 if(nError
!= ERRCODE_NONE
)
2115 pDocSh
->RegisterTransfer( *pMedium
);
2116 pMedium
->DownLoad(); // ggfs. den DownLoad anstossen
2117 if( aRef
.Is() && 1 < aRef
->GetRefCount() ) // noch gueltige Ref?
2120 Reader
*pRead
= pDocSh
->StartConvertFrom( *pMedium
, &pRdr
, pWrtShell
);
2122 (pMedium
->GetFilter()->GetFilterFlags() & SFX_FILTER_STARONEFILTER
) != 0 )
2124 sal_uInt16 nUndoCheck
= 0;
2125 SwDoc
*pDoc
= pDocSh
->GetDoc();
2126 if( pRead
&& pDocSh
->GetDoc() )
2127 nUndoCheck
= lcl_PageDescWithHeader( *pDoc
);
2129 { //Scope for SwWait-Object, to be able to execute slots
2130 //outside this scope.
2131 SwWait
aWait( *GetDocShell(), TRUE
);
2132 pWrtShell
->StartAllAction();
2133 if ( pWrtShell
->HasSelection() )
2134 pWrtShell
->DelRight(); // Selektionen loeschen
2137 nErrno
= pRdr
->Read( *pRead
); // und Dokument einfuegen
2142 sal_Bool bUndo
= pDoc
->DoesUndo();
2143 pDoc
->DoUndo( sal_False
);
2144 nErrno
= pDocSh
->InsertFrom( *pMedium
) ? 0 : ERR_SWG_READ_ERROR
;
2145 pDoc
->DoUndo( bUndo
);
2150 // ggfs. alle Verzeichnisse updaten:
2151 if( pWrtShell
->IsUpdateTOX() )
2153 SfxRequest
aReq( FN_UPDATE_TOX
, SFX_CALLMODE_SLOT
, GetPool() );
2155 pWrtShell
->SetUpdateTOX( FALSE
); // wieder zurueck setzen
2159 { // Disable Undo for .sdw (136991) or
2160 // if the number of page styles with header/footer has changed (#i67305)
2161 if( !pRead
|| nUndoCheck
!= lcl_PageDescWithHeader( *pDoc
) )
2162 pDoc
->DelAllUndoObj();
2165 pWrtShell
->EndAllAction();
2168 ErrorHandler::HandleError( nErrno
);
2169 nFound
= IsError( nErrno
) ? -1 : 0;
2178 SfxObjectShellRef xDocSh
;
2180 extern int lcl_FindDocShell( SfxObjectShellRef
& xDocSh
,
2181 const String
& rFileName
, const String
& rPasswd
,
2182 String
& rFilter
, INT16 nVersion
,
2183 SwDocShell
* pDestSh
);
2186 int nRet
= lcl_FindDocShell( xDocSh
, pMedium
->GetName(), aEmptyStr
,
2187 sFltNm
, nVersion
, pDocSh
);
2190 SwWait
aWait( *GetDocShell(), TRUE
);
2191 pWrtShell
->StartAllAction();
2193 pWrtShell
->EnterStdMode(); // Selektionen loeschen
2196 nFound
= pWrtShell
->CompareDoc( *((SwDocShell
*)&xDocSh
)->GetDoc() );
2198 nFound
= pWrtShell
->MergeDoc( *((SwDocShell
*)&xDocSh
)->GetDoc() );
2200 pWrtShell
->EndAllAction();
2202 if (!bCompare
&& !nFound
)
2204 Window
* pWin
= &GetEditWin();
2205 InfoBox(pWin
, SW_RES(MSG_NO_MERGE_ENTRY
)).Execute();
2208 if( 2 == nRet
&& xDocSh
.Is() )
2215 /* -----------------05.02.2003 12:06-----------------
2217 * --------------------------------------------------*/
2218 void SwView::EnableMailMerge(BOOL bEnable
)
2220 bInMailMerge
= bEnable
;
2221 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
2222 rBind
.Invalidate(FN_INSERT_FIELD_DATA_ONLY
);
2223 rBind
.Update(FN_INSERT_FIELD_DATA_ONLY
);
2229 sal_Bool
lcl_NeedAdditionalDataSource( const uno::Reference
< XNameAccess
>& _rDatasourceContext
)
2231 Sequence
< OUString
> aNames
= _rDatasourceContext
->getElementNames();
2233 return ( !aNames
.getLength()
2234 || ( ( 1 == aNames
.getLength() )
2235 && aNames
.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
2241 /* -----------------27.11.2002 12:12-----------------
2243 * --------------------------------------------------*/
2245 class SwMergeSourceWarningBox_Impl
: public ModalDialog
2247 FixedInfo aMessageFI
;
2249 CancelButton aCancel
;
2251 FixedImage aWarnImage
;
2253 SwMergeSourceWarningBox_Impl( Window
* pParent
) :
2254 ModalDialog( pParent
, SW_RES( DLG_MERGE_SOURCE_UNAVAILABLE
) ),
2255 aMessageFI( this, SW_RES( ST_MERGE_SOURCE_UNAVAILABLE
) ),
2256 aOK( this, SW_RES( PB_MERGE_OK
) ),
2257 aCancel( this, SW_RES( PB_MERGE_CANCEL
) ),
2258 aWarnImage( this, SW_RES( IMG_MERGE
) )
2261 SetText( Application::GetDisplayName() );
2262 const Image
& rImg
= WarningBox::GetStandardImage();
2263 aWarnImage
.SetImage( rImg
);
2264 Size
aImageSize( rImg
.GetSizePixel() );
2265 aImageSize
.Width() += 4;
2266 aImageSize
.Height() += 4;
2267 aWarnImage
.SetSizePixel( aImageSize
);
2269 aImageSize
.Width() += aWarnImage
.GetPosPixel().X();
2270 Size
aSz(GetSizePixel());
2271 aSz
.Width() += aImageSize
.Width();
2274 Point
aPos(aMessageFI
.GetPosPixel());
2275 aPos
.X() += aImageSize
.Width();
2276 aMessageFI
.SetPosPixel( aPos
);
2278 aPos
= aOK
.GetPosPixel();
2279 aPos
.X() += aImageSize
.Width();
2280 aOK
.SetPosPixel( aPos
);
2281 aPos
= aCancel
.GetPosPixel();
2282 aPos
.X() += aImageSize
.Width();
2283 aCancel
.SetPosPixel( aPos
);
2287 String
GetMessText() const { return aMessageFI
.GetText(); }
2288 void SetMessText( const String
& rText
) { aMessageFI
.SetText( rText
); }
2294 void SwView::GenerateFormLetter(BOOL bUseCurrentDocument
)
2296 if(bUseCurrentDocument
)
2298 if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
2300 //check availability of data sources (except biblio source)
2301 uno::Reference
< XMultiServiceFactory
> xMgr( ::comphelper::getProcessServiceFactory() );
2302 uno::Reference
<XNameAccess
> xDBContext
;
2305 uno::Reference
<XInterface
> xInstance
= xMgr
->createInstance(
2306 OUString::createFromAscii( "com.sun.star.sdb.DatabaseContext" ));
2307 xDBContext
= uno::Reference
<XNameAccess
>(xInstance
, UNO_QUERY
) ;
2309 if(!xDBContext
.is())
2311 BOOL bCallAddressPilot
= FALSE
;
2312 if ( lcl_NeedAdditionalDataSource( xDBContext
) )
2314 // no data sources are available - create a new one
2315 WarningBox
aWarning(
2316 &GetViewFrame()->GetWindow(),
2317 SW_RES(MSG_DATA_SOURCES_UNAVAILABLE
));
2318 // no cancel allowed
2319 if ( RET_OK
!= aWarning
.Execute() )
2321 bCallAddressPilot
= TRUE
;
2325 //take an existing data source or create a new one?
2326 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
2327 DBG_ASSERT(pFact
, "Dialogdiet fail!");
2328 AbstractMailMergeFieldConnectionsDlg
* pConnectionsDlg
= pFact
->CreateMailMergeFieldConnectionsDlg(
2329 DLG_MERGE_FIELD_CONNECTIONS
,
2330 &GetViewFrame()->GetWindow());
2331 DBG_ASSERT(pConnectionsDlg
, "Dialogdiet fail!");
2332 if(RET_OK
== pConnectionsDlg
->Execute())
2333 bCallAddressPilot
= !pConnectionsDlg
->IsUseExistingConnections();
2338 if(bCallAddressPilot
)
2340 GetViewFrame()->GetDispatcher()->Execute(
2341 SID_ADDRESS_DATA_SOURCE
, SFX_CALLMODE_SYNCHRON
);
2342 if ( lcl_NeedAdditionalDataSource( xDBContext
) )
2343 // no additional data source has been created
2344 // -> assume that the user has cancelled the pilot
2348 //call insert fields with database field page available, only
2349 SfxViewFrame
* pVFrame
= GetViewFrame();
2350 //at first hide the default field dialog if currently visible
2351 pVFrame
->SetChildWindow(FN_INSERT_FIELD
, FALSE
);
2352 //enable the status of the db field dialog - it is disabled in the status method
2353 //to prevent creation of the dialog without mail merge active
2355 //then show the "Data base only" field dialog
2356 SfxBoolItem
aOn(FN_INSERT_FIELD_DATA_ONLY
, TRUE
);
2357 pVFrame
->GetDispatcher()->Execute(FN_INSERT_FIELD_DATA_ONLY
,
2358 SFX_CALLMODE_SYNCHRON
, &aOn
, 0L);
2363 // check whether the
2365 if(!GetWrtShell().IsFieldDataSourceAvailable(sSource
))
2367 SwMergeSourceWarningBox_Impl
aWarning( &GetViewFrame()->GetWindow());
2368 String
sTmp(aWarning
.GetMessText());
2369 sTmp
.SearchAndReplaceAscii("%1", sSource
);
2370 aWarning
.SetMessText(sTmp
);
2371 if(RET_OK
== aWarning
.Execute())
2373 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
2376 VclAbstractDialog
* pDlg
= pFact
->CreateVclDialog( NULL
, SID_OPTIONS_DATABASES
);
2384 SwNewDBMgr
* pNewDBMgr
= GetWrtShell().GetNewDBMgr();
2387 SwWrtShell
&rSh
= GetWrtShell();
2388 aData
= rSh
.GetDBData();
2389 rSh
.EnterStdMode(); // Wechsel in Textshell erzwingen; ist fuer
2390 // das Mischen von DB-Feldern notwendig.
2391 AttrChangedNotify( &rSh
);
2392 pNewDBMgr
->SetMergeType( DBMGR_MERGE
);
2396 Sequence
<PropertyValue
> aProperties(3);
2397 PropertyValue
* pValues
= aProperties
.getArray();
2398 pValues
[0].Name
= C2U("DataSourceName");
2399 pValues
[1].Name
= C2U("Command");
2400 pValues
[2].Name
= C2U("CommandType");
2401 pValues
[0].Value
<<= aData
.sDataSource
;
2402 pValues
[1].Value
<<= aData
.sCommand
;
2403 pValues
[2].Value
<<= aData
.nCommandType
;
2404 pNewDBMgr
->ExecuteFormLetter(GetWrtShell(), aProperties
, TRUE
);
2409 //call documents and template dialog
2410 SfxApplication
* pSfxApp
= SFX_APP();
2411 Window
* pTopWin
= pSfxApp
->GetTopWindow();
2412 SvtDocumentTemplateDialog
* pDocTemplDlg
= new SvtDocumentTemplateDialog( pTopWin
);
2413 pDocTemplDlg
->SelectTemplateFolder();
2415 int nRet
= pDocTemplDlg
->Execute();
2416 sal_Bool bNewWin
= sal_False
;
2417 if ( nRet
== RET_OK
)
2419 if ( pTopWin
!= pSfxApp
->GetTopWindow() )
2421 // the dialogue opens a document -> a new TopWindow appears
2422 pTopWin
= pSfxApp
->GetTopWindow();
2427 delete pDocTemplDlg
;
2429 // after the destruction of the dialogue its parent comes to top,
2430 // but we want that the new document is on top
2437 IMPL_LINK( SwView
, DialogClosedHdl
, sfx2::FileDialogHelper
*, _pFileDlg
)
2439 if ( ERRCODE_NONE
== _pFileDlg
->GetError() )
2441 SfxMedium
* pMed
= pViewImpl
->CreateMedium();
2444 USHORT nSlot
= pViewImpl
->GetRequest()->GetSlot();
2445 long nFound
= InsertMedium( nSlot
, pMed
, pViewImpl
->GetParam() );
2447 if ( SID_INSERTDOC
== nSlot
)
2449 if ( pViewImpl
->GetParam() == 0 )
2451 pViewImpl
->GetRequest()->SetReturnValue( SfxBoolItem( nSlot
, nFound
!= -1 ) );
2452 pViewImpl
->GetRequest()->Ignore();
2456 pViewImpl
->GetRequest()->SetReturnValue( SfxBoolItem( nSlot
, nFound
!= -1 ) );
2457 pViewImpl
->GetRequest()->Done();
2460 else if ( SID_DOCUMENT_COMPARE
== nSlot
|| SID_DOCUMENT_MERGE
== nSlot
)
2462 pViewImpl
->GetRequest()->SetReturnValue( SfxInt32Item( nSlot
, nFound
) );
2464 if ( nFound
> 0 ) // Redline-Browser anzeigen
2466 SfxViewFrame
* pVFrame
= GetViewFrame();
2467 pVFrame
->ShowChildWindow(FN_REDLINE_ACCEPT
);
2469 // RedlineDlg neu initialisieren
2470 USHORT nId
= SwRedlineAcceptChild::GetChildWindowId();
2471 SwRedlineAcceptChild
* pRed
= (SwRedlineAcceptChild
*)pVFrame
->GetChildWindow( nId
);
2473 pRed
->ReInitDlg( GetDocShell() );
2481 void SwView::ExecuteScan( SfxRequest
& rReq
)
2484 pViewImpl
->ExecuteScan(rReq
) ;