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