xref: /AOO41X/main/sc/source/ui/view/tabvwsh3.cxx (revision b3f79822e811ac3493b185030a72c3c5a51f32d8)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "scitems.hxx"
32cdf0e10cSrcweir #include <editeng/eeitem.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <sfx2/app.hxx>
35cdf0e10cSrcweir //CHINA001 #include <svx/zoom.hxx>
36cdf0e10cSrcweir #include <sfx2/bindings.hxx>
37cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
38cdf0e10cSrcweir #include <sfx2/passwd.hxx>
39cdf0e10cSrcweir #include <sfx2/request.hxx>
40cdf0e10cSrcweir #include <svl/ptitem.hxx>
41cdf0e10cSrcweir #include <svl/stritem.hxx>
42cdf0e10cSrcweir #include <tools/urlobj.hxx>
43cdf0e10cSrcweir #include <sfx2/objface.hxx>
44cdf0e10cSrcweir #include <vcl/msgbox.hxx>
45cdf0e10cSrcweir #include <vcl/vclenum.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "globstr.hrc"
48cdf0e10cSrcweir #include "scmod.hxx"
49cdf0e10cSrcweir #include "appoptio.hxx"
50cdf0e10cSrcweir #include "tabvwsh.hxx"
51cdf0e10cSrcweir #include "document.hxx"
52cdf0e10cSrcweir #include "sc.hrc"
53cdf0e10cSrcweir #include "inputwin.hxx"
54cdf0e10cSrcweir #include "scresid.hxx"
55cdf0e10cSrcweir #include "printfun.hxx"
56cdf0e10cSrcweir #include "docsh.hxx"
57cdf0e10cSrcweir #include "rangelst.hxx"
58cdf0e10cSrcweir #include "prevwsh.hxx"
59cdf0e10cSrcweir #include "rangeutl.hxx"
60cdf0e10cSrcweir #include "reffact.hxx"
61cdf0e10cSrcweir #include "uiitems.hxx"
62cdf0e10cSrcweir #include "cell.hxx"
63cdf0e10cSrcweir #include "inputhdl.hxx"
64cdf0e10cSrcweir //CHINA001 #include "scendlg.hxx"
65cdf0e10cSrcweir //CHINA001 #include "mtrindlg.hxx"
66cdf0e10cSrcweir #include "autoform.hxx"
67cdf0e10cSrcweir #include "autofmt.hxx"
68cdf0e10cSrcweir #include "dwfunctr.hxx"
69cdf0e10cSrcweir #include "shtabdlg.hxx"
70cdf0e10cSrcweir #include "tabprotection.hxx"
71cdf0e10cSrcweir #include "protectiondlg.hxx"
72cdf0e10cSrcweir 
73cdf0e10cSrcweir #include <svl/ilstitem.hxx>
74cdf0e10cSrcweir #define _SVSTDARR_ULONGS
75cdf0e10cSrcweir #include <svl/svstdarr.hxx>
76cdf0e10cSrcweir 
77cdf0e10cSrcweir #include <svx/zoomslideritem.hxx>
78cdf0e10cSrcweir #include <svx/svxdlg.hxx> //CHINA001
79cdf0e10cSrcweir #include <svx/dialogs.hrc> //CHINA001
80cdf0e10cSrcweir #include "scabstdlg.hxx" //CHINA001
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #include <memory>
83cdf0e10cSrcweir 
84cdf0e10cSrcweir using ::std::auto_ptr;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
87cdf0e10cSrcweir #define IS_AVAILABLE(WhichId,ppItem) \
88cdf0e10cSrcweir     (pReqArgs->GetItemState((WhichId), sal_True, ppItem ) == SFX_ITEM_SET)
89cdf0e10cSrcweir #define GET_STRING(nid) ((const SfxStringItem&)pReqArgs->Get(nid)).GetValue()
90cdf0e10cSrcweir #define GET_UINT16(nid) ((const SfxUInt16Item&)pReqArgs->Get(nid)).GetValue()
91cdf0e10cSrcweir #define GET_BOOL(nid)   ((const SfxBoolItem&)pReqArgs->Get(nid)).GetValue()
92cdf0e10cSrcweir #define RECALC_PAGE(pDocSh) ScPrintFunc( pDocSh, GetPrinter(), nCurTab ).UpdatePages()
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //------------------------------------------------------------------
95cdf0e10cSrcweir 
96cdf0e10cSrcweir /** Try to parse the given range using Calc-style syntax first, then
97cdf0e10cSrcweir     Excel-style if that fails. */
lcl_ParseRange(ScRange & rScRange,const String & aAddress,ScDocument * pDoc,sal_uInt16)98cdf0e10cSrcweir sal_uInt16 lcl_ParseRange(ScRange& rScRange, const String& aAddress, ScDocument* pDoc, sal_uInt16 /* nSlot */)
99cdf0e10cSrcweir {
100cdf0e10cSrcweir     sal_uInt16 nResult = rScRange.Parse(aAddress, pDoc);
101cdf0e10cSrcweir     if ( (nResult & SCA_VALID) )
102cdf0e10cSrcweir         return nResult;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     return rScRange.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0));
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir /** Try to parse the given address using Calc-style syntax first, then
108cdf0e10cSrcweir     Excel-style if that fails. */
lcl_ParseAddress(ScAddress & rScAddress,const String & aAddress,ScDocument * pDoc,sal_uInt16)109cdf0e10cSrcweir sal_uInt16 lcl_ParseAddress(ScAddress& rScAddress, const String& aAddress, ScDocument* pDoc, sal_uInt16 /* nSlot */)
110cdf0e10cSrcweir {
111cdf0e10cSrcweir     sal_uInt16 nResult = rScAddress.Parse(aAddress, pDoc);
112cdf0e10cSrcweir     if ( (nResult & SCA_VALID) )
113cdf0e10cSrcweir         return nResult;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     return rScAddress.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0));
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
Execute(SfxRequest & rReq)118cdf0e10cSrcweir void ScTabViewShell::Execute( SfxRequest& rReq )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir 	SfxViewFrame*		pThisFrame  = GetViewFrame();
121cdf0e10cSrcweir 	SfxBindings&		rBindings	= pThisFrame->GetBindings();
122cdf0e10cSrcweir 	ScModule*			pScMod		= SC_MOD();
123cdf0e10cSrcweir 	const SfxItemSet*	pReqArgs	= rReq.GetArgs();
124cdf0e10cSrcweir 	sal_uInt16				nSlot		= rReq.GetSlot();
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	if (nSlot != SID_CURRENTCELL)		// der kommt beim MouseButtonUp
127cdf0e10cSrcweir 		HideListBox();					// Autofilter-DropDown-Listbox
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	switch ( nSlot )
130cdf0e10cSrcweir 	{
131cdf0e10cSrcweir 		case FID_INSERT_FILE:
132cdf0e10cSrcweir 			{
133cdf0e10cSrcweir 				const SfxPoolItem* pItem;
134cdf0e10cSrcweir 				if ( pReqArgs &&
135cdf0e10cSrcweir 					 pReqArgs->GetItemState(FID_INSERT_FILE,sal_True,&pItem) == SFX_ITEM_SET )
136cdf0e10cSrcweir 				{
137cdf0e10cSrcweir 					String aFileName = ((const SfxStringItem*)pItem)->GetValue();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 						// Einfuege-Position
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 					Point aInsertPos;
142cdf0e10cSrcweir 					if ( pReqArgs->GetItemState(FN_PARAM_1,sal_True,&pItem) == SFX_ITEM_SET )
143cdf0e10cSrcweir 						aInsertPos = ((const SfxPointItem*)pItem)->GetValue();
144cdf0e10cSrcweir 					else
145cdf0e10cSrcweir 						aInsertPos = GetInsertPos();
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 						//	als Link?
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 					sal_Bool bAsLink = sal_False;
150cdf0e10cSrcweir 					if ( pReqArgs->GetItemState(FN_PARAM_2,sal_True,&pItem) == SFX_ITEM_SET )
151cdf0e10cSrcweir 						bAsLink = ((const SfxBoolItem*)pItem)->GetValue();
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 						// ausfuehren
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 					PasteFile( aInsertPos, aFileName, bAsLink );
156cdf0e10cSrcweir 				}
157cdf0e10cSrcweir 			}
158cdf0e10cSrcweir 			break;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 		case SID_OPENDLG_EDIT_PRINTAREA:
161cdf0e10cSrcweir 			{
162cdf0e10cSrcweir 				sal_uInt16			nId  = ScPrintAreasDlgWrapper::GetChildWindowId();
163cdf0e10cSrcweir 				SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 				pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
166cdf0e10cSrcweir 			}
167cdf0e10cSrcweir 			break;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 		case SID_CHANGE_PRINTAREA:
170cdf0e10cSrcweir 			{
171cdf0e10cSrcweir 				if ( pReqArgs )			// OK aus Dialog
172cdf0e10cSrcweir 				{
173cdf0e10cSrcweir                     String aPrintStr;
174cdf0e10cSrcweir                     String aRowStr;
175cdf0e10cSrcweir                     String aColStr;
176cdf0e10cSrcweir                     sal_Bool bEntire = sal_False;
177cdf0e10cSrcweir                     const SfxPoolItem* pItem;
178cdf0e10cSrcweir                     if ( pReqArgs->GetItemState( SID_CHANGE_PRINTAREA, sal_True, &pItem ) == SFX_ITEM_SET )
179cdf0e10cSrcweir                         aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
180cdf0e10cSrcweir                     if ( pReqArgs->GetItemState( FN_PARAM_2, sal_True, &pItem ) == SFX_ITEM_SET )
181cdf0e10cSrcweir                         aRowStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
182cdf0e10cSrcweir                     if ( pReqArgs->GetItemState( FN_PARAM_3, sal_True, &pItem ) == SFX_ITEM_SET )
183cdf0e10cSrcweir                         aColStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
184cdf0e10cSrcweir                     if ( pReqArgs->GetItemState( FN_PARAM_4, sal_True, &pItem ) == SFX_ITEM_SET )
185cdf0e10cSrcweir                         bEntire = static_cast<const SfxBoolItem*>(pItem)->GetValue();
186cdf0e10cSrcweir 
187cdf0e10cSrcweir                     SetPrintRanges( bEntire, &aPrintStr, &aColStr, &aRowStr, sal_False );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 					rReq.Done();
190cdf0e10cSrcweir 				}
191cdf0e10cSrcweir 			}
192cdf0e10cSrcweir 			break;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 		case SID_ADD_PRINTAREA:
195cdf0e10cSrcweir 		case SID_DEFINE_PRINTAREA:		// Menue oder Basic
196cdf0e10cSrcweir 			{
197cdf0e10cSrcweir 				sal_Bool bAdd = ( nSlot == SID_ADD_PRINTAREA );
198cdf0e10cSrcweir 				if ( pReqArgs )
199cdf0e10cSrcweir 				{
200cdf0e10cSrcweir                     String aPrintStr;
201cdf0e10cSrcweir                     const SfxPoolItem* pItem;
202cdf0e10cSrcweir                     if ( pReqArgs->GetItemState( SID_DEFINE_PRINTAREA, sal_True, &pItem ) == SFX_ITEM_SET )
203cdf0e10cSrcweir                         aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
204cdf0e10cSrcweir                     SetPrintRanges( sal_False, &aPrintStr, NULL, NULL, bAdd );
205cdf0e10cSrcweir 				}
206cdf0e10cSrcweir 				else
207cdf0e10cSrcweir 				{
208cdf0e10cSrcweir                     SetPrintRanges( sal_False, NULL, NULL, NULL, bAdd );      // aus Selektion
209cdf0e10cSrcweir 					rReq.Done();
210cdf0e10cSrcweir 				}
211cdf0e10cSrcweir 			}
212cdf0e10cSrcweir 			break;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 		case SID_DELETE_PRINTAREA:
215cdf0e10cSrcweir 			{
216cdf0e10cSrcweir 				String aEmpty;
217cdf0e10cSrcweir                 SetPrintRanges( sal_False, &aEmpty, NULL, NULL, sal_False );        // Druckbereich loeschen
218cdf0e10cSrcweir 				rReq.Done();
219cdf0e10cSrcweir 			}
220cdf0e10cSrcweir 			break;
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 		case FID_DEL_MANUALBREAKS:
223cdf0e10cSrcweir 			RemoveManualBreaks();
224cdf0e10cSrcweir 			rReq.Done();
225cdf0e10cSrcweir 			break;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 		case FID_ADJUST_PRINTZOOM:
228cdf0e10cSrcweir 			AdjustPrintZoom();
229cdf0e10cSrcweir 			rReq.Done();
230cdf0e10cSrcweir 			break;
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 		case FID_RESET_PRINTZOOM:
233cdf0e10cSrcweir 			SetPrintZoom( 100, 0 );		// 100%, nicht auf Seiten
234cdf0e10cSrcweir 			rReq.Done();
235cdf0e10cSrcweir 			break;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 		case SID_FORMATPAGE:
238cdf0e10cSrcweir 		case SID_STATUS_PAGESTYLE:
239cdf0e10cSrcweir 		case SID_HFEDIT:
240cdf0e10cSrcweir 			GetViewData()->GetDocShell()->
241cdf0e10cSrcweir 				ExecutePageStyle( *this, rReq, GetViewData()->GetTabNo() );
242cdf0e10cSrcweir 			break;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 		case SID_JUMPTOMARK:
245cdf0e10cSrcweir 		case SID_CURRENTCELL:
246cdf0e10cSrcweir 			if ( pReqArgs )
247cdf0e10cSrcweir 			{
248cdf0e10cSrcweir 				String aAddress;
249cdf0e10cSrcweir 				const SfxPoolItem* pItem;
250cdf0e10cSrcweir 				if ( pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET )
251cdf0e10cSrcweir 					aAddress = ((const SfxStringItem*)pItem)->GetValue();
252cdf0e10cSrcweir 				else if ( nSlot == SID_JUMPTOMARK && pReqArgs->GetItemState(
253cdf0e10cSrcweir 											SID_JUMPTOMARK, sal_True, &pItem ) == SFX_ITEM_SET )
254cdf0e10cSrcweir 					aAddress = ((const SfxStringItem*)pItem)->GetValue();
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 				//	#i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
257cdf0e10cSrcweir 				//	isn't set (for recorded macros, because IsAPI is no longer available).
258cdf0e10cSrcweir 				//	ScGridWindow::MouseButtonUp no longer executes the slot for a single
259cdf0e10cSrcweir 				//	cell if there is a multi selection.
260cdf0e10cSrcweir 				sal_Bool bUnmark = ( nSlot == SID_CURRENTCELL );
261cdf0e10cSrcweir 				if ( pReqArgs->GetItemState( FN_PARAM_1, sal_True, &pItem ) == SFX_ITEM_SET )
262cdf0e10cSrcweir 					bUnmark = ((const SfxBoolItem*)pItem)->GetValue();
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 				if ( nSlot == SID_JUMPTOMARK )
265cdf0e10cSrcweir 				{
266cdf0e10cSrcweir 					//	#106586# URL has to be decoded for escaped characters (%20)
267cdf0e10cSrcweir 					aAddress = INetURLObject::decode( aAddress, INET_HEX_ESCAPE,
268cdf0e10cSrcweir 							   				INetURLObject::DECODE_WITH_CHARSET,
269cdf0e10cSrcweir 											RTL_TEXTENCODING_UTF8 );
270cdf0e10cSrcweir 				}
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 				sal_Bool bFound = sal_False;
273cdf0e10cSrcweir 				ScViewData* pViewData = GetViewData();
274cdf0e10cSrcweir 				ScDocument* pDoc	  = pViewData->GetDocument();
275cdf0e10cSrcweir 				ScMarkData& rMark	  = pViewData->GetMarkData();
276cdf0e10cSrcweir 				ScRange		aScRange;
277cdf0e10cSrcweir 				ScAddress	aScAddress;
278cdf0e10cSrcweir                 sal_uInt16      nResult = lcl_ParseRange(aScRange, aAddress, pDoc, nSlot);
279cdf0e10cSrcweir 				SCTAB		nTab = pViewData->GetTabNo();
280cdf0e10cSrcweir 				sal_Bool		bMark = sal_True;
281cdf0e10cSrcweir 
282cdf0e10cSrcweir                 // Is this a range ?
283cdf0e10cSrcweir 				if( nResult & SCA_VALID )
284cdf0e10cSrcweir 				{
285cdf0e10cSrcweir 					if ( nResult & SCA_TAB_3D )
286cdf0e10cSrcweir 					{
287cdf0e10cSrcweir 						if( aScRange.aStart.Tab() != nTab )
288cdf0e10cSrcweir 							SetTabNo( nTab = aScRange.aStart.Tab() );
289cdf0e10cSrcweir 					}
290cdf0e10cSrcweir 					else
291cdf0e10cSrcweir 					{
292cdf0e10cSrcweir 						aScRange.aStart.SetTab( nTab );
293cdf0e10cSrcweir 						aScRange.aEnd.SetTab( nTab );
294cdf0e10cSrcweir 					}
295cdf0e10cSrcweir 				}
296cdf0e10cSrcweir                 // Is this a cell ?
297cdf0e10cSrcweir                 else if ( (nResult = lcl_ParseAddress(aScAddress, aAddress, pDoc, nSlot)) & SCA_VALID )
298cdf0e10cSrcweir 				{
299cdf0e10cSrcweir 					if ( nResult & SCA_TAB_3D )
300cdf0e10cSrcweir 					{
301cdf0e10cSrcweir 						if( aScAddress.Tab() != nTab )
302cdf0e10cSrcweir 							SetTabNo( nTab = aScAddress.Tab() );
303cdf0e10cSrcweir 					}
304cdf0e10cSrcweir 					else
305cdf0e10cSrcweir 						aScAddress.SetTab( nTab );
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 					aScRange = ScRange( aScAddress, aScAddress );
308cdf0e10cSrcweir 					// Zellen sollen nicht markiert werden
309cdf0e10cSrcweir 					bMark = sal_False;
310cdf0e10cSrcweir 				}
311cdf0e10cSrcweir 				// Ist es benahmster Bereich (erst Namen dann DBBereiche) ?
312cdf0e10cSrcweir 				else
313cdf0e10cSrcweir 				{
314cdf0e10cSrcweir 					ScRangeUtil		aRangeUtil;
315cdf0e10cSrcweir                     formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
316cdf0e10cSrcweir 					if(	aRangeUtil.MakeRangeFromName( aAddress, pDoc, nTab, aScRange, RUTL_NAMES, eConv ) ||
317cdf0e10cSrcweir 						aRangeUtil.MakeRangeFromName( aAddress, pDoc, nTab, aScRange, RUTL_DBASE, eConv ) )
318cdf0e10cSrcweir 					{
319cdf0e10cSrcweir 						nResult |= SCA_VALID;
320cdf0e10cSrcweir 						if( aScRange.aStart.Tab() != nTab )
321cdf0e10cSrcweir 							SetTabNo( nTab = aScRange.aStart.Tab() );
322cdf0e10cSrcweir 					}
323cdf0e10cSrcweir 				}
324cdf0e10cSrcweir 
325cdf0e10cSrcweir 				if ( !(nResult & SCA_VALID) &&
326cdf0e10cSrcweir 						ByteString(aAddress, RTL_TEXTENCODING_ASCII_US).IsNumericAscii() )
327cdf0e10cSrcweir 				{
328cdf0e10cSrcweir 					sal_Int32 nNumeric = aAddress.ToInt32();
329cdf0e10cSrcweir 					if ( nNumeric > 0 && nNumeric <= MAXROW+1 )
330cdf0e10cSrcweir 					{
331cdf0e10cSrcweir 						//	1-basierte Zeilennummer
332cdf0e10cSrcweir 
333cdf0e10cSrcweir 						aScAddress.SetRow( (SCROW)(nNumeric - 1) );
334cdf0e10cSrcweir 						aScAddress.SetCol( pViewData->GetCurX() );
335cdf0e10cSrcweir 						aScAddress.SetTab( nTab );
336cdf0e10cSrcweir 						aScRange = ScRange( aScAddress, aScAddress );
337cdf0e10cSrcweir 						bMark	 = sal_False;
338cdf0e10cSrcweir 						nResult  = SCA_VALID;
339cdf0e10cSrcweir 					}
340cdf0e10cSrcweir 				}
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 				if ( !ValidRow(aScRange.aStart.Row()) || !ValidRow(aScRange.aEnd.Row()) )
343cdf0e10cSrcweir 					nResult = 0;
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 				// wir haben was gefunden
346cdf0e10cSrcweir 				if( nResult & SCA_VALID )
347cdf0e10cSrcweir 				{
348cdf0e10cSrcweir 					bFound = sal_True;
349cdf0e10cSrcweir 					SCCOL nCol = aScRange.aStart.Col();
350cdf0e10cSrcweir 					SCROW nRow = aScRange.aStart.Row();
351cdf0e10cSrcweir 					sal_Bool bNothing = ( pViewData->GetCurX()==nCol && pViewData->GetCurY()==nRow );
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 					// markieren
354cdf0e10cSrcweir 					if( bMark )
355cdf0e10cSrcweir 					{
356cdf0e10cSrcweir 						if (rMark.IsMarked())			// ist derselbe Bereich schon markiert?
357cdf0e10cSrcweir 						{
358cdf0e10cSrcweir 							ScRange aOldMark;
359cdf0e10cSrcweir 							rMark.GetMarkArea( aOldMark );
360cdf0e10cSrcweir 							aOldMark.Justify();
361cdf0e10cSrcweir 							ScRange aCurrent = aScRange;
362cdf0e10cSrcweir 							aCurrent.Justify();
363cdf0e10cSrcweir 							bNothing = ( aCurrent == aOldMark );
364cdf0e10cSrcweir 						}
365cdf0e10cSrcweir 						else
366cdf0e10cSrcweir 							bNothing = sal_False;
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 						if (!bNothing)
369cdf0e10cSrcweir 							MarkRange( aScRange, sal_False );	// Cursor kommt hinterher...
370cdf0e10cSrcweir 					}
371cdf0e10cSrcweir 					else
372cdf0e10cSrcweir 					{
373cdf0e10cSrcweir 						//	remove old selection, unless bUnmark argument is sal_False (from navigator)
374cdf0e10cSrcweir 						if( bUnmark )
375cdf0e10cSrcweir 						{
376cdf0e10cSrcweir 							MoveCursorAbs( nCol, nRow,
377cdf0e10cSrcweir 								SC_FOLLOW_NONE, sal_False, sal_False );
378cdf0e10cSrcweir 						}
379cdf0e10cSrcweir 					}
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 					// und Cursor setzen
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 					// zusammengefasste Zellen beruecksichtigen:
384cdf0e10cSrcweir 					while ( pDoc->IsHorOverlapped( nCol, nRow, nTab ) )		//! ViewData !!!
385cdf0e10cSrcweir 						--nCol;
386cdf0e10cSrcweir 					while ( pDoc->IsVerOverlapped( nCol, nRow, nTab ) )
387cdf0e10cSrcweir 						--nRow;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 					//	Navigator-Aufrufe sind nicht API!!!
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 					if( bNothing )
392cdf0e10cSrcweir 					{
393cdf0e10cSrcweir 						if (rReq.IsAPI())
394cdf0e10cSrcweir 							rReq.Ignore();		// wenn Makro, dann gar nix
395cdf0e10cSrcweir 						else
396cdf0e10cSrcweir 							rReq.Done();		// sonst wenigstens aufzeichnen
397cdf0e10cSrcweir 					}
398cdf0e10cSrcweir 					else
399cdf0e10cSrcweir 					{
400cdf0e10cSrcweir 						pViewData->ResetOldCursor();
401cdf0e10cSrcweir 						SetCursor( nCol, nRow );
402cdf0e10cSrcweir 						AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
403cdf0e10cSrcweir 						rBindings.Invalidate( SID_CURRENTCELL );
404cdf0e10cSrcweir 						rBindings.Update( nSlot );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 						if (!rReq.IsAPI())
407cdf0e10cSrcweir 							rReq.Done();
408cdf0e10cSrcweir 					}
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 					rReq.SetReturnValue( SfxStringItem( SID_CURRENTCELL, aAddress ) );
411cdf0e10cSrcweir 				}
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 				if (!bFound)	// kein gueltiger Bereich
414cdf0e10cSrcweir 				{
415cdf0e10cSrcweir 					//	wenn es ein Tabellenname ist, umschalten (fuer Navigator/URL's)
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 					SCTAB nNameTab;
418cdf0e10cSrcweir 					if ( pDoc->GetTable( aAddress, nNameTab ) )
419cdf0e10cSrcweir 					{
420cdf0e10cSrcweir 						bFound = sal_True;
421cdf0e10cSrcweir 						if ( nNameTab != nTab )
422cdf0e10cSrcweir 							SetTabNo( nNameTab );
423cdf0e10cSrcweir 					}
424cdf0e10cSrcweir 				}
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 				if ( !bFound && nSlot == SID_JUMPTOMARK )
427cdf0e10cSrcweir 				{
428cdf0e10cSrcweir 					//	Grafik-Objekte probieren (nur bei URL's)
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 					bFound = SelectObject( aAddress );
431cdf0e10cSrcweir 				}
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 				if (!bFound && !rReq.IsAPI())
434cdf0e10cSrcweir 					ErrorMessage( STR_ERR_INVALID_AREA );
435cdf0e10cSrcweir 			}
436cdf0e10cSrcweir 			break;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 		case SID_CURRENTOBJECT:
439cdf0e10cSrcweir 			if ( pReqArgs )
440cdf0e10cSrcweir 			{
441cdf0e10cSrcweir 				String aName = ((const SfxStringItem&)pReqArgs->Get(nSlot)).GetValue();
442cdf0e10cSrcweir 				SelectObject( aName );
443cdf0e10cSrcweir 			}
444cdf0e10cSrcweir 			break;
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 		case SID_CURRENTTAB:
447cdf0e10cSrcweir 			if ( pReqArgs )
448cdf0e10cSrcweir 			{
449cdf0e10cSrcweir 				//	Tabelle fuer Basic ist 1-basiert
450cdf0e10cSrcweir 				SCTAB nTab = ((const SfxUInt16Item&)pReqArgs->Get(nSlot)).GetValue() - 1;
451cdf0e10cSrcweir 				ScDocument* pDoc = GetViewData()->GetDocument();
452cdf0e10cSrcweir 				if ( nTab < pDoc->GetTableCount() )
453cdf0e10cSrcweir 				{
454cdf0e10cSrcweir 					SetTabNo( nTab );
455cdf0e10cSrcweir 					rBindings.Update( nSlot );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 					if( ! rReq.IsAPI() )
458cdf0e10cSrcweir 						rReq.Done();
459cdf0e10cSrcweir 				}
460cdf0e10cSrcweir 				//!	sonst Fehler ?
461cdf0e10cSrcweir 			}
462cdf0e10cSrcweir 			break;
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 		case SID_CURRENTDOC:
465cdf0e10cSrcweir 			if ( pReqArgs )
466cdf0e10cSrcweir 			{
467cdf0e10cSrcweir 				String aStrDocName( ((const SfxStringItem&)pReqArgs->
468cdf0e10cSrcweir 										Get(nSlot)).GetValue() );
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 				SfxViewFrame*	pViewFrame = NULL;
471cdf0e10cSrcweir 				ScDocShell* 	pDocSh = (ScDocShell*)SfxObjectShell::GetFirst();
472cdf0e10cSrcweir 				sal_Bool			bFound = sal_False;
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 				// zu aktivierenden ViewFrame suchen
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 				while ( pDocSh && !bFound )
477cdf0e10cSrcweir 				{
478cdf0e10cSrcweir 					if ( pDocSh->GetTitle() == aStrDocName )
479cdf0e10cSrcweir 					{
480cdf0e10cSrcweir 						pViewFrame = SfxViewFrame::GetFirst( pDocSh );
481cdf0e10cSrcweir 						bFound = ( NULL != pViewFrame );
482cdf0e10cSrcweir 					}
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 					pDocSh = (ScDocShell*)SfxObjectShell::GetNext( *pDocSh );
485cdf0e10cSrcweir 				}
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 				if ( bFound )
488cdf0e10cSrcweir 					pViewFrame->GetFrame().Appear();
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 				rReq.Ignore();//XXX wird von SFX erledigt
491cdf0e10cSrcweir 			}
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 		case SID_ATTR_SIZE://XXX ???
494cdf0e10cSrcweir 			break;
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 		case SID_PRINTPREVIEW:
498cdf0e10cSrcweir 			{
499cdf0e10cSrcweir                 if ( !pThisFrame->GetFrame().IsInPlace() )          // nicht bei OLE
500cdf0e10cSrcweir 				{
501cdf0e10cSrcweir 					//	print preview is now always in the same frame as the tab view
502cdf0e10cSrcweir 					//	-> always switch this frame back to normal view
503cdf0e10cSrcweir 					//	(ScPreviewShell ctor reads view data)
504cdf0e10cSrcweir 
505cdf0e10cSrcweir                     // #102785#; finish input
506cdf0e10cSrcweir                     pScMod->InputEnterHandler();
507cdf0e10cSrcweir 
508cdf0e10cSrcweir                     pThisFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SFX_CALLMODE_ASYNCHRON );
509cdf0e10cSrcweir 				}
510cdf0e10cSrcweir 				//	else Fehler (z.B. Ole)
511cdf0e10cSrcweir 			}
512cdf0e10cSrcweir 			break;
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 		case SID_DETECTIVE_DEL_ALL:
515cdf0e10cSrcweir 			DetectiveDelAll();
516cdf0e10cSrcweir 			rReq.Done();
517cdf0e10cSrcweir 			break;
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 		//	SID_TABLE_ACTIVATE und SID_MARKAREA werden von Basic aus an der versteckten
520cdf0e10cSrcweir 		//	View aufgerufen, um auf der sichtbaren View zu markieren/umzuschalten:
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 		case SID_TABLE_ACTIVATE:
523cdf0e10cSrcweir 			DBG_ERROR("old slot SID_TABLE_ACTIVATE");
524cdf0e10cSrcweir 			break;
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 		case SID_REPAINT:
527cdf0e10cSrcweir 			PaintGrid();
528cdf0e10cSrcweir 			PaintTop();
529cdf0e10cSrcweir 			PaintLeft();
530cdf0e10cSrcweir 			PaintExtras();
531cdf0e10cSrcweir 			rReq.Done();
532cdf0e10cSrcweir 			break;
533cdf0e10cSrcweir 
534cdf0e10cSrcweir         case FID_NORMALVIEWMODE:
535cdf0e10cSrcweir 		case FID_PAGEBREAKMODE:
536cdf0e10cSrcweir 			{
537cdf0e10cSrcweir                 sal_Bool bWantPageBreak = nSlot == FID_PAGEBREAKMODE;
538cdf0e10cSrcweir 
539cdf0e10cSrcweir                 // check whether there is an explicit argument, use it
540cdf0e10cSrcweir 				const SfxPoolItem* pItem;
541cdf0e10cSrcweir                 if ( pReqArgs && pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET )
542cdf0e10cSrcweir                 {
543cdf0e10cSrcweir                     sal_Bool bItemValue = ((const SfxBoolItem*)pItem)->GetValue();
544cdf0e10cSrcweir                     bWantPageBreak = (nSlot == FID_PAGEBREAKMODE) == bItemValue;
545cdf0e10cSrcweir                 }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir                 if( GetViewData()->IsPagebreakMode() != bWantPageBreak )
548cdf0e10cSrcweir                 {
549cdf0e10cSrcweir                     SetPagebreakMode( bWantPageBreak );
550cdf0e10cSrcweir                     UpdatePageBreakData();
551cdf0e10cSrcweir                     SetCurSubShell( GetCurObjectSelectionType(), sal_True );
552cdf0e10cSrcweir                     PaintGrid();
553cdf0e10cSrcweir                     PaintTop();
554cdf0e10cSrcweir                     PaintLeft();
555cdf0e10cSrcweir                     rBindings.Invalidate( nSlot );
556cdf0e10cSrcweir                     rReq.AppendItem( SfxBoolItem( nSlot, sal_True ) );
557cdf0e10cSrcweir                     rReq.Done();
558cdf0e10cSrcweir                 }
559cdf0e10cSrcweir 			}
560cdf0e10cSrcweir 			break;
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 		case FID_FUNCTION_BOX:
563cdf0e10cSrcweir 			{
564cdf0e10cSrcweir                 sal_uInt16 nChildId = ScFunctionChildWindow::GetChildWindowId();
565cdf0e10cSrcweir 				if ( rReq.GetArgs() )
566cdf0e10cSrcweir                     pThisFrame->SetChildWindow( nChildId, ((const SfxBoolItem&) (rReq.GetArgs()->Get(FID_FUNCTION_BOX))).GetValue());
567cdf0e10cSrcweir 				else
568cdf0e10cSrcweir                 {
569cdf0e10cSrcweir                     pThisFrame->ToggleChildWindow( nChildId );
570cdf0e10cSrcweir                     rReq.AppendItem( SfxBoolItem( FID_FUNCTION_BOX , pThisFrame->HasChildWindow( nChildId ) ) );
571cdf0e10cSrcweir                 }
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 				GetViewFrame()->GetBindings().Invalidate(FID_FUNCTION_BOX);
574cdf0e10cSrcweir 				rReq.Done ();
575cdf0e10cSrcweir 			}
576cdf0e10cSrcweir 			break;
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 
579cdf0e10cSrcweir 		case FID_TOGGLESYNTAX:
580cdf0e10cSrcweir 			{
581cdf0e10cSrcweir 				sal_Bool bSet = !GetViewData()->IsSyntaxMode();
582cdf0e10cSrcweir 				const SfxPoolItem* pItem;
583cdf0e10cSrcweir 				if ( pReqArgs && pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET )
584cdf0e10cSrcweir 					bSet = ((const SfxBoolItem*)pItem)->GetValue();
585cdf0e10cSrcweir 				GetViewData()->SetSyntaxMode( bSet );
586cdf0e10cSrcweir 				PaintGrid();
587cdf0e10cSrcweir 				rBindings.Invalidate( FID_TOGGLESYNTAX );
588cdf0e10cSrcweir                 rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
589cdf0e10cSrcweir 				rReq.Done();
590cdf0e10cSrcweir 			}
591cdf0e10cSrcweir 			break;
592cdf0e10cSrcweir 		case FID_TOGGLEHEADERS:
593cdf0e10cSrcweir 			{
594cdf0e10cSrcweir 				sal_Bool bSet = !GetViewData()->IsHeaderMode();
595cdf0e10cSrcweir 				const SfxPoolItem* pItem;
596cdf0e10cSrcweir 				if ( pReqArgs && pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET )
597cdf0e10cSrcweir 					bSet = ((const SfxBoolItem*)pItem)->GetValue();
598cdf0e10cSrcweir 				GetViewData()->SetHeaderMode( bSet );
599cdf0e10cSrcweir 				RepeatResize();
600cdf0e10cSrcweir 				rBindings.Invalidate( FID_TOGGLEHEADERS );
601cdf0e10cSrcweir                 rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
602cdf0e10cSrcweir 				rReq.Done();
603cdf0e10cSrcweir 			}
604cdf0e10cSrcweir 			break;
605cdf0e10cSrcweir 
606cdf0e10cSrcweir         case FID_TOGGLEFORMULA:
607cdf0e10cSrcweir             {
608cdf0e10cSrcweir                 ScViewData* pViewData = GetViewData();
609cdf0e10cSrcweir                 const ScViewOptions& rOpts = pViewData->GetOptions();
610cdf0e10cSrcweir                 sal_Bool bFormulaMode = !rOpts.GetOption( VOPT_FORMULAS );
611cdf0e10cSrcweir                 const SfxPoolItem *pItem;
612cdf0e10cSrcweir                 if( pReqArgs && pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET )
613cdf0e10cSrcweir                     bFormulaMode = ((const SfxBoolItem *)pItem)->GetValue();
614cdf0e10cSrcweir 
615cdf0e10cSrcweir                 ScViewOptions rSetOpts = ScViewOptions( rOpts );
616cdf0e10cSrcweir                 rSetOpts.SetOption( VOPT_FORMULAS, bFormulaMode );
617cdf0e10cSrcweir                 pViewData->SetOptions( rSetOpts );
618cdf0e10cSrcweir 
619cdf0e10cSrcweir                 pViewData->GetDocShell()->PostPaintGridAll();
620cdf0e10cSrcweir 
621cdf0e10cSrcweir                 rBindings.Invalidate( FID_TOGGLEFORMULA );
622cdf0e10cSrcweir                 rReq.AppendItem( SfxBoolItem( nSlot, bFormulaMode ) );
623cdf0e10cSrcweir                 rReq.Done();
624cdf0e10cSrcweir             }
625cdf0e10cSrcweir             break;
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 		case FID_TOGGLEINPUTLINE:
628cdf0e10cSrcweir 			{
629cdf0e10cSrcweir 				sal_uInt16			nId  = ScInputWindowWrapper::GetChildWindowId();
630cdf0e10cSrcweir 				SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
631cdf0e10cSrcweir 				sal_Bool bSet = ( pWnd == NULL );
632cdf0e10cSrcweir 				const SfxPoolItem* pItem;
633cdf0e10cSrcweir 				if ( pReqArgs && pReqArgs->GetItemState(nSlot, sal_True, &pItem) == SFX_ITEM_SET )
634cdf0e10cSrcweir 					bSet = ((const SfxBoolItem*)pItem)->GetValue();
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 				pThisFrame->SetChildWindow( nId, bSet );
637cdf0e10cSrcweir 				rBindings.Invalidate( FID_TOGGLEINPUTLINE );
638cdf0e10cSrcweir                 rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
639cdf0e10cSrcweir                 rReq.Done();
640cdf0e10cSrcweir 			}
641cdf0e10cSrcweir 			break;
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 		case SID_ATTR_ZOOM: // Statuszeile
644cdf0e10cSrcweir 		case FID_SCALE:
645cdf0e10cSrcweir 			{
646cdf0e10cSrcweir                 sal_Bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
647cdf0e10cSrcweir 				SvxZoomType	eOldZoomType = GetZoomType();
648cdf0e10cSrcweir 				SvxZoomType	eNewZoomType = eOldZoomType;
649cdf0e10cSrcweir 				const Fraction& rOldY = GetViewData()->GetZoomY();	// Y wird angezeigt
650cdf0e10cSrcweir 				sal_uInt16 nOldZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 )
651cdf0e10cSrcweir 											/ rOldY.GetDenominator());
652cdf0e10cSrcweir 				sal_uInt16 nZoom = nOldZoom;
653cdf0e10cSrcweir 				sal_Bool bCancel = sal_False;
654cdf0e10cSrcweir 
655cdf0e10cSrcweir 				if ( pReqArgs )
656cdf0e10cSrcweir 				{
657cdf0e10cSrcweir 					const SvxZoomItem& rZoomItem = (const SvxZoomItem&)
658cdf0e10cSrcweir 												   pReqArgs->Get(SID_ATTR_ZOOM);
659cdf0e10cSrcweir 
660cdf0e10cSrcweir 					eNewZoomType = rZoomItem.GetType();
661cdf0e10cSrcweir 					nZoom	  = rZoomItem.GetValue();
662cdf0e10cSrcweir 				}
663cdf0e10cSrcweir 				else
664cdf0e10cSrcweir 				{
665cdf0e10cSrcweir 					SfxItemSet		aSet	 ( GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
666cdf0e10cSrcweir 					SvxZoomItem		aZoomItem( eOldZoomType, nOldZoom, SID_ATTR_ZOOM );
667cdf0e10cSrcweir 					//CHINA001 SvxZoomDialog*	pDlg = NULL;
668cdf0e10cSrcweir 					AbstractSvxZoomDialog* pDlg = NULL;
669cdf0e10cSrcweir 					ScMarkData&		rMark = GetViewData()->GetMarkData();
670cdf0e10cSrcweir 					sal_uInt16			nBtnFlags =   SVX_ZOOM_ENABLE_50
671cdf0e10cSrcweir 												| SVX_ZOOM_ENABLE_75
672cdf0e10cSrcweir 												| SVX_ZOOM_ENABLE_100
673cdf0e10cSrcweir 												| SVX_ZOOM_ENABLE_150
674cdf0e10cSrcweir 												| SVX_ZOOM_ENABLE_200
675cdf0e10cSrcweir 												| SVX_ZOOM_ENABLE_WHOLEPAGE
676cdf0e10cSrcweir 												| SVX_ZOOM_ENABLE_PAGEWIDTH;
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 					if ( rMark.IsMarked() || rMark.IsMultiMarked() )
679cdf0e10cSrcweir 						nBtnFlags = nBtnFlags | SVX_ZOOM_ENABLE_OPTIMAL;
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 					aZoomItem.SetValueSet( nBtnFlags );
682cdf0e10cSrcweir 					aSet.Put( aZoomItem );
683cdf0e10cSrcweir 					//CHINA001 pDlg = new SvxZoomDialog( GetDialogParent(), aSet );
684cdf0e10cSrcweir 					SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
685cdf0e10cSrcweir 					if(pFact)
686cdf0e10cSrcweir 					{
687cdf0e10cSrcweir 						pDlg = pFact->CreateSvxZoomDialog(GetDialogParent(), aSet );
688cdf0e10cSrcweir 						DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
689cdf0e10cSrcweir 					}
690cdf0e10cSrcweir 					pDlg->SetLimits( MINZOOM, MAXZOOM );
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 					bCancel = ( RET_CANCEL == pDlg->Execute() );
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 					if ( !bCancel )
695cdf0e10cSrcweir 					{
696cdf0e10cSrcweir 						const SvxZoomItem&	rZoomItem = (const SvxZoomItem&)
697cdf0e10cSrcweir 												pDlg->GetOutputItemSet()->
698cdf0e10cSrcweir 													Get( SID_ATTR_ZOOM );
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 						eNewZoomType = rZoomItem.GetType();
701cdf0e10cSrcweir 						nZoom	  = rZoomItem.GetValue();
702cdf0e10cSrcweir 					}
703cdf0e10cSrcweir 
704cdf0e10cSrcweir 					delete pDlg;
705cdf0e10cSrcweir 				}
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 				if ( !bCancel )
708cdf0e10cSrcweir 				{
709cdf0e10cSrcweir 					if ( eNewZoomType == SVX_ZOOM_PERCENT )
710cdf0e10cSrcweir 					{
711cdf0e10cSrcweir 						if ( nZoom < MINZOOM )	nZoom = MINZOOM;
712cdf0e10cSrcweir 						if ( nZoom > MAXZOOM )	nZoom = MAXZOOM;
713cdf0e10cSrcweir 					}
714cdf0e10cSrcweir 					else
715cdf0e10cSrcweir 					{
716cdf0e10cSrcweir 						nZoom = CalcZoom( eNewZoomType, nOldZoom );
717cdf0e10cSrcweir 						bCancel = nZoom == 0;
718cdf0e10cSrcweir 					}
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 					switch ( eNewZoomType )
721cdf0e10cSrcweir 					{
722cdf0e10cSrcweir 						case SVX_ZOOM_WHOLEPAGE:
723cdf0e10cSrcweir 						case SVX_ZOOM_PAGEWIDTH:
724cdf0e10cSrcweir                             SetZoomType( eNewZoomType, bSyncZoom );
725cdf0e10cSrcweir 							break;
726cdf0e10cSrcweir 
727cdf0e10cSrcweir 						default:
728cdf0e10cSrcweir                             SetZoomType( SVX_ZOOM_PERCENT, bSyncZoom );
729cdf0e10cSrcweir 					}
730cdf0e10cSrcweir 				}
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 				if ( nZoom != nOldZoom && !bCancel )
733cdf0e10cSrcweir 				{
734cdf0e10cSrcweir 					if (!GetViewData()->IsPagebreakMode())
735cdf0e10cSrcweir 					{
736cdf0e10cSrcweir 						ScAppOptions aNewOpt = pScMod->GetAppOptions();
737cdf0e10cSrcweir 						aNewOpt.SetZoom( nZoom );
738cdf0e10cSrcweir 						aNewOpt.SetZoomType( GetZoomType() );
739cdf0e10cSrcweir 						pScMod->SetAppOptions( aNewOpt );
740cdf0e10cSrcweir 					}
741cdf0e10cSrcweir 					Fraction aFract( nZoom, 100 );
742cdf0e10cSrcweir                     SetZoom( aFract, aFract, bSyncZoom );
743cdf0e10cSrcweir 					PaintGrid();
744cdf0e10cSrcweir 					PaintTop();
745cdf0e10cSrcweir 					PaintLeft();
746cdf0e10cSrcweir 					rBindings.Invalidate( SID_ATTR_ZOOM );
747cdf0e10cSrcweir                     rReq.AppendItem( SvxZoomItem( GetZoomType(), nZoom, nSlot ) );
748cdf0e10cSrcweir 					rReq.Done();
749cdf0e10cSrcweir 				}
750cdf0e10cSrcweir 			}
751cdf0e10cSrcweir 			break;
752cdf0e10cSrcweir 
753cdf0e10cSrcweir         case SID_ATTR_ZOOMSLIDER:
754cdf0e10cSrcweir             {
755cdf0e10cSrcweir                 const SfxPoolItem* pItem = NULL;
756cdf0e10cSrcweir                 sal_Bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
757cdf0e10cSrcweir                 if ( pReqArgs && pReqArgs->GetItemState(SID_ATTR_ZOOMSLIDER, sal_True, &pItem) == SFX_ITEM_SET )
758cdf0e10cSrcweir                 {
759cdf0e10cSrcweir                     const sal_uInt16 nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
760cdf0e10cSrcweir                     if( nCurrentZoom )
761cdf0e10cSrcweir                     {
762cdf0e10cSrcweir                         SetZoomType( SVX_ZOOM_PERCENT, bSyncZoom );
763cdf0e10cSrcweir                         if (!GetViewData()->IsPagebreakMode())
764cdf0e10cSrcweir                         {
765cdf0e10cSrcweir                             ScAppOptions aNewOpt = pScMod->GetAppOptions();
766cdf0e10cSrcweir                             aNewOpt.SetZoom( nCurrentZoom );
767cdf0e10cSrcweir                             aNewOpt.SetZoomType( GetZoomType() );
768cdf0e10cSrcweir                             pScMod->SetAppOptions( aNewOpt );
769cdf0e10cSrcweir                         }
770cdf0e10cSrcweir                         Fraction aFract( nCurrentZoom,100 );
771cdf0e10cSrcweir                         SetZoom( aFract, aFract, bSyncZoom );
772cdf0e10cSrcweir                         PaintGrid();
773cdf0e10cSrcweir                         PaintTop();
774cdf0e10cSrcweir                         PaintLeft();
775cdf0e10cSrcweir                         rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
776cdf0e10cSrcweir                         rReq.Done();
777cdf0e10cSrcweir                     }
778cdf0e10cSrcweir                 }
779cdf0e10cSrcweir             }
780cdf0e10cSrcweir             break;
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 		//----------------------------------------------------------------
783cdf0e10cSrcweir 
784cdf0e10cSrcweir 		case FID_TAB_SELECTALL:
785cdf0e10cSrcweir 			SelectAllTables();
786cdf0e10cSrcweir 			rReq.Done();
787cdf0e10cSrcweir 			break;
788cdf0e10cSrcweir 
789cdf0e10cSrcweir         case FID_TAB_DESELECTALL:
790cdf0e10cSrcweir             DeselectAllTables();
791cdf0e10cSrcweir             rReq.Done();
792cdf0e10cSrcweir             break;
793cdf0e10cSrcweir 
794cdf0e10cSrcweir         case SID_SELECT_TABLES:
795cdf0e10cSrcweir         {
796cdf0e10cSrcweir             ScViewData& rViewData = *GetViewData();
797cdf0e10cSrcweir             ScDocument& rDoc = *rViewData.GetDocument();
798cdf0e10cSrcweir             ScMarkData& rMark = rViewData.GetMarkData();
799cdf0e10cSrcweir             SCTAB nTabCount = rDoc.GetTableCount();
800cdf0e10cSrcweir             SCTAB nTab;
801cdf0e10cSrcweir 
802cdf0e10cSrcweir             SvULongs aIndexList( 4, 4 );
803cdf0e10cSrcweir             SFX_REQUEST_ARG( rReq, pItem, SfxIntegerListItem, SID_SELECT_TABLES, sal_False );
804cdf0e10cSrcweir             if ( pItem )
805cdf0e10cSrcweir                 pItem->GetList( aIndexList );
806cdf0e10cSrcweir             else
807cdf0e10cSrcweir             {
808cdf0e10cSrcweir                 //CHINA001 ScShowTabDlg* pDlg = new ScShowTabDlg( GetDialogParent() );
809cdf0e10cSrcweir 				ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
810cdf0e10cSrcweir 				DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 				AbstractScShowTabDlg* pDlg = pFact->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB);
813cdf0e10cSrcweir 				DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
814cdf0e10cSrcweir                 pDlg->SetDescription(
815cdf0e10cSrcweir                     String( ScResId( STR_DLG_SELECTTABLES_TITLE ) ),
816cdf0e10cSrcweir                     String( ScResId( STR_DLG_SELECTTABLES_LBNAME ) ),
817cdf0e10cSrcweir                     GetStaticInterface()->GetSlot(SID_SELECT_TABLES)->GetCommand(), HID_SELECTTABLES );
818cdf0e10cSrcweir 
819cdf0e10cSrcweir                 // fill all table names with selection state
820cdf0e10cSrcweir                 String aTabName;
821cdf0e10cSrcweir                 for( nTab = 0; nTab < nTabCount; ++nTab )
822cdf0e10cSrcweir                 {
823cdf0e10cSrcweir                     rDoc.GetName( nTab, aTabName );
824cdf0e10cSrcweir                     pDlg->Insert( aTabName, rMark.GetTableSelect( nTab ) );
825cdf0e10cSrcweir                 }
826cdf0e10cSrcweir 
827cdf0e10cSrcweir                 if( pDlg->Execute() == RET_OK )
828cdf0e10cSrcweir                 {
829cdf0e10cSrcweir                     sal_uInt16 nSelCount = pDlg->GetSelectEntryCount();
830cdf0e10cSrcweir                     sal_uInt16 nSelIx;
831cdf0e10cSrcweir                     for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx )
832cdf0e10cSrcweir                         aIndexList.Insert( pDlg->GetSelectEntryPos( nSelIx ), nSelIx );
833cdf0e10cSrcweir                     delete pDlg;
834cdf0e10cSrcweir                     rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES, aIndexList ) );
835cdf0e10cSrcweir                 }
836cdf0e10cSrcweir                 else
837cdf0e10cSrcweir                     rReq.Ignore();
838cdf0e10cSrcweir             }
839cdf0e10cSrcweir 
840cdf0e10cSrcweir             if ( aIndexList.Count() )
841cdf0e10cSrcweir             {
842cdf0e10cSrcweir                 sal_uInt16 nSelCount = aIndexList.Count();
843cdf0e10cSrcweir                 sal_uInt16 nSelIx;
844cdf0e10cSrcweir                 SCTAB nFirstVisTab = 0;
845cdf0e10cSrcweir 
846cdf0e10cSrcweir                 // special case: only hidden tables selected -> do nothing
847cdf0e10cSrcweir                 sal_Bool bVisSelected = sal_False;
848cdf0e10cSrcweir                 for( nSelIx = 0; !bVisSelected && (nSelIx < nSelCount); ++nSelIx )
849cdf0e10cSrcweir                     bVisSelected = rDoc.IsVisible( nFirstVisTab = static_cast<SCTAB>(aIndexList[nSelIx]) );
850cdf0e10cSrcweir                 if( !bVisSelected )
851cdf0e10cSrcweir                     nSelCount = 0;
852cdf0e10cSrcweir 
853cdf0e10cSrcweir                 // select the tables
854cdf0e10cSrcweir                 if( nSelCount )
855cdf0e10cSrcweir                 {
856cdf0e10cSrcweir                     for( nTab = 0; nTab < nTabCount; ++nTab )
857cdf0e10cSrcweir                         rMark.SelectTable( nTab, sal_False );
858cdf0e10cSrcweir 
859cdf0e10cSrcweir                     for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx )
860cdf0e10cSrcweir                         rMark.SelectTable( static_cast<SCTAB>(aIndexList[nSelIx]), sal_True );
861cdf0e10cSrcweir 
862cdf0e10cSrcweir                     // activate another table, if current is deselected
863cdf0e10cSrcweir                     if( !rMark.GetTableSelect( rViewData.GetTabNo() ) )
864cdf0e10cSrcweir                     {
865cdf0e10cSrcweir                         rMark.SelectTable( nFirstVisTab, sal_True );
866cdf0e10cSrcweir                         SetTabNo( nFirstVisTab );
867cdf0e10cSrcweir                     }
868cdf0e10cSrcweir 
869cdf0e10cSrcweir                     rViewData.GetDocShell()->PostPaintExtras();
870cdf0e10cSrcweir                     SfxBindings& rBind = rViewData.GetBindings();
871cdf0e10cSrcweir                     rBind.Invalidate( FID_FILL_TAB );
872cdf0e10cSrcweir                     rBind.Invalidate( FID_TAB_DESELECTALL );
873cdf0e10cSrcweir                 }
874cdf0e10cSrcweir 
875cdf0e10cSrcweir                 rReq.Done();
876cdf0e10cSrcweir             }
877cdf0e10cSrcweir         }
878cdf0e10cSrcweir         break;
879cdf0e10cSrcweir 
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 		case SID_OUTLINE_DELETEALL:
882cdf0e10cSrcweir 			RemoveAllOutlines();
883cdf0e10cSrcweir 			rReq.Done();
884cdf0e10cSrcweir 			break;
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 		case SID_AUTO_OUTLINE:
887cdf0e10cSrcweir 			AutoOutline();
888cdf0e10cSrcweir 			rReq.Done();
889cdf0e10cSrcweir 			break;
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 		case SID_WINDOW_SPLIT:
893cdf0e10cSrcweir 			{
894cdf0e10cSrcweir 				ScSplitMode eHSplit = GetViewData()->GetHSplitMode();
895cdf0e10cSrcweir 				ScSplitMode eVSplit = GetViewData()->GetVSplitMode();
896cdf0e10cSrcweir 				if ( eHSplit == SC_SPLIT_NORMAL || eVSplit == SC_SPLIT_NORMAL )		// aufheben
897cdf0e10cSrcweir 					RemoveSplit();
898cdf0e10cSrcweir 				else if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX )		// normal
899cdf0e10cSrcweir 					FreezeSplitters( sal_False );
900cdf0e10cSrcweir 				else																// erzeugen
901cdf0e10cSrcweir 					SplitAtCursor();
902cdf0e10cSrcweir 				rReq.Done();
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 				InvalidateSplit();
905cdf0e10cSrcweir 			}
906cdf0e10cSrcweir 			break;
907cdf0e10cSrcweir 
908cdf0e10cSrcweir 		case SID_WINDOW_FIX:
909cdf0e10cSrcweir 			{
910cdf0e10cSrcweir 				ScSplitMode eHSplit = GetViewData()->GetHSplitMode();
911cdf0e10cSrcweir 				ScSplitMode eVSplit = GetViewData()->GetVSplitMode();
912cdf0e10cSrcweir 				if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX )			// aufheben
913cdf0e10cSrcweir 					RemoveSplit();
914cdf0e10cSrcweir 				else
915cdf0e10cSrcweir 					FreezeSplitters( sal_True );		// erzeugen oder fixieren
916cdf0e10cSrcweir 				rReq.Done();
917cdf0e10cSrcweir 
918cdf0e10cSrcweir 				InvalidateSplit();
919cdf0e10cSrcweir 			}
920cdf0e10cSrcweir 			break;
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 		//	----------------------------------------------------------------
923cdf0e10cSrcweir 
924cdf0e10cSrcweir 		case FID_CHG_SHOW:
925cdf0e10cSrcweir 			{
926cdf0e10cSrcweir 				sal_uInt16			nId  = ScHighlightChgDlgWrapper::GetChildWindowId();
927cdf0e10cSrcweir 				SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
928cdf0e10cSrcweir 
929cdf0e10cSrcweir 				pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
930cdf0e10cSrcweir 			}
931cdf0e10cSrcweir 			break;
932cdf0e10cSrcweir 
933cdf0e10cSrcweir 		case FID_CHG_ACCEPT:
934cdf0e10cSrcweir 			{
935cdf0e10cSrcweir 				pThisFrame->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
936cdf0e10cSrcweir 				GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT);
937cdf0e10cSrcweir 				rReq.Done ();
938cdf0e10cSrcweir 
939cdf0e10cSrcweir 				/*
940cdf0e10cSrcweir 				sal_uInt16			nId  = ScAcceptChgDlgWrapper::GetChildWindowId();
941cdf0e10cSrcweir 				SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
942cdf0e10cSrcweir 
943cdf0e10cSrcweir 				pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
944cdf0e10cSrcweir 				*/
945cdf0e10cSrcweir 			}
946cdf0e10cSrcweir 			break;
947cdf0e10cSrcweir 
948cdf0e10cSrcweir 		case FID_CHG_COMMENT:
949cdf0e10cSrcweir 			{
950cdf0e10cSrcweir 				ScViewData* pData = GetViewData();
951cdf0e10cSrcweir 				ScAddress aCursorPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
952cdf0e10cSrcweir 				ScDocShell* pDocSh = pData->GetDocShell();
953cdf0e10cSrcweir 
954cdf0e10cSrcweir 				ScChangeAction*	pAction = pDocSh->GetChangeAction( aCursorPos );
955cdf0e10cSrcweir 				if ( pAction )
956cdf0e10cSrcweir 				{
957cdf0e10cSrcweir 					const SfxPoolItem* pItem;
958cdf0e10cSrcweir 					if ( pReqArgs &&
959cdf0e10cSrcweir 						 pReqArgs->GetItemState( nSlot, sal_True, &pItem ) == SFX_ITEM_SET &&
960cdf0e10cSrcweir 						 pItem->ISA( SfxStringItem ) )
961cdf0e10cSrcweir 					{
962cdf0e10cSrcweir 						String aComment = ((const SfxStringItem*)pItem)->GetValue();
963cdf0e10cSrcweir 						pDocSh->SetChangeComment( pAction, aComment );
964cdf0e10cSrcweir 						rReq.Done();
965cdf0e10cSrcweir 					}
966cdf0e10cSrcweir 					else
967cdf0e10cSrcweir 					{
968cdf0e10cSrcweir 						pDocSh->ExecuteChangeCommentDialog( pAction, GetDialogParent() );
969cdf0e10cSrcweir 						rReq.Done();
970cdf0e10cSrcweir 					}
971cdf0e10cSrcweir 				}
972cdf0e10cSrcweir 			}
973cdf0e10cSrcweir 			break;
974cdf0e10cSrcweir 
975cdf0e10cSrcweir 		case SID_CREATE_SW_DRAWVIEW:
976cdf0e10cSrcweir 			//	wird von den Forms gerufen, wenn die DrawView mit allem Zubehoer
977cdf0e10cSrcweir 			//	angelegt werden muss
978cdf0e10cSrcweir 			if (!GetScDrawView())
979cdf0e10cSrcweir 			{
980cdf0e10cSrcweir 				GetViewData()->GetDocShell()->MakeDrawLayer();
981cdf0e10cSrcweir 				rBindings.InvalidateAll(sal_False);
982cdf0e10cSrcweir 			}
983cdf0e10cSrcweir 			break;
984cdf0e10cSrcweir 
985cdf0e10cSrcweir 		case FID_PROTECT_DOC:
986cdf0e10cSrcweir 			{
987cdf0e10cSrcweir 				ScDocument* 		pDoc = GetViewData()->GetDocument();
988cdf0e10cSrcweir 				SfxPasswordDialog*	pDlg;
989cdf0e10cSrcweir 
990cdf0e10cSrcweir 				if( pReqArgs )
991cdf0e10cSrcweir 				{
992cdf0e10cSrcweir 					const SfxPoolItem* pItem;
993cdf0e10cSrcweir                     if( IS_AVAILABLE( FID_PROTECT_DOC, &pItem ) &&
994cdf0e10cSrcweir                         ((const SfxBoolItem*)pItem)->GetValue() == pDoc->IsDocProtected() )
995cdf0e10cSrcweir                     {
996cdf0e10cSrcweir                         rReq.Ignore();
997cdf0e10cSrcweir                         break;
998cdf0e10cSrcweir                     }
999cdf0e10cSrcweir                 }
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir                 ScDocProtection* pProtect = pDoc->GetDocProtection();
1002cdf0e10cSrcweir                 if (pProtect && pProtect->isProtected())
1003cdf0e10cSrcweir 				{
1004cdf0e10cSrcweir 					sal_Bool	bCancel = sal_False;
1005cdf0e10cSrcweir 					String	aPassword;
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir                     if (pProtect->isProtectedWithPass())
1008cdf0e10cSrcweir 					{
1009cdf0e10cSrcweir 						String	aText( ScResId(SCSTR_PASSWORD) );
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir 						pDlg = new SfxPasswordDialog( 	GetDialogParent(), &aText );
1012cdf0e10cSrcweir 						pDlg->SetText( ScResId(SCSTR_UNPROTECTDOC) );
1013cdf0e10cSrcweir 						pDlg->SetMinLen( 0 );
1014cdf0e10cSrcweir 						pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand() );
1015cdf0e10cSrcweir 						pDlg->SetEditHelpId( HID_PASSWD_DOC );
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir 						if (pDlg->Execute() == RET_OK)
1018cdf0e10cSrcweir 							aPassword = pDlg->GetPassword();
1019cdf0e10cSrcweir 						else
1020cdf0e10cSrcweir 							bCancel = sal_True;
1021cdf0e10cSrcweir 						delete pDlg;
1022cdf0e10cSrcweir 					}
1023cdf0e10cSrcweir 					if (!bCancel)
1024cdf0e10cSrcweir 					{
1025cdf0e10cSrcweir 						Unprotect( TABLEID_DOC, aPassword );
1026cdf0e10cSrcweir                         rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, sal_False ) );
1027cdf0e10cSrcweir 						rReq.Done();
1028cdf0e10cSrcweir 					}
1029cdf0e10cSrcweir 				}
1030cdf0e10cSrcweir 				else
1031cdf0e10cSrcweir 				{
1032cdf0e10cSrcweir 					String aText( ScResId(SCSTR_PASSWORDOPT) );
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir 					pDlg = new SfxPasswordDialog( 	GetDialogParent(), &aText );
1035cdf0e10cSrcweir 					pDlg->SetText( ScResId(SCSTR_PROTECTDOC) );
1036cdf0e10cSrcweir 					pDlg->SetMinLen( 0 );
1037cdf0e10cSrcweir     				pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand() );
1038cdf0e10cSrcweir 					pDlg->SetEditHelpId( HID_PASSWD_DOC );
1039cdf0e10cSrcweir 					pDlg->ShowExtras( SHOWEXTRAS_CONFIRM );
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 					if (pDlg->Execute() == RET_OK)
1042cdf0e10cSrcweir 					{
1043cdf0e10cSrcweir 						String aPassword = pDlg->GetPassword();
1044cdf0e10cSrcweir                         Protect( TABLEID_DOC, aPassword );
1045cdf0e10cSrcweir                         rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, sal_True ) );
1046cdf0e10cSrcweir                         rReq.Done();
1047cdf0e10cSrcweir 					}
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 					delete pDlg;
1050cdf0e10cSrcweir 				}
1051cdf0e10cSrcweir 				rBindings.Invalidate( FID_PROTECT_DOC );
1052cdf0e10cSrcweir 			}
1053cdf0e10cSrcweir 			break;
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir 		case FID_PROTECT_TABLE:
1057cdf0e10cSrcweir         {
1058cdf0e10cSrcweir             ScDocument* pDoc = GetViewData()->GetDocument();
1059cdf0e10cSrcweir             SCTAB		nTab = GetViewData()->GetTabNo();
1060cdf0e10cSrcweir             bool        bOldProtection = pDoc->IsTabProtected(nTab);
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir #if ENABLE_SHEET_PROTECTION
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir             if( pReqArgs )
1065cdf0e10cSrcweir             {
1066cdf0e10cSrcweir                 const SfxPoolItem* pItem;
1067cdf0e10cSrcweir                 bool bNewProtection = !bOldProtection;
1068cdf0e10cSrcweir                 if( IS_AVAILABLE( FID_PROTECT_TABLE, &pItem ) )
1069cdf0e10cSrcweir                     bNewProtection = ((const SfxBoolItem*)pItem)->GetValue();
1070cdf0e10cSrcweir                 if( bNewProtection == bOldProtection )
1071cdf0e10cSrcweir                 {
1072cdf0e10cSrcweir                     rReq.Ignore();
1073cdf0e10cSrcweir                     break;
1074cdf0e10cSrcweir                 }
1075cdf0e10cSrcweir             }
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir             if (bOldProtection)
1078cdf0e10cSrcweir             {
1079cdf0e10cSrcweir                 // Unprotect a protected sheet.
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir                 ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
1082cdf0e10cSrcweir                 if (pProtect && pProtect->isProtectedWithPass())
1083cdf0e10cSrcweir                 {
1084cdf0e10cSrcweir                     String aText( ScResId(SCSTR_PASSWORDOPT) );
1085cdf0e10cSrcweir                     auto_ptr<SfxPasswordDialog> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText));
1086cdf0e10cSrcweir                     pDlg->SetText( ScResId(SCSTR_UNPROTECTTAB) );
1087cdf0e10cSrcweir                     pDlg->SetMinLen( 0 );
1088cdf0e10cSrcweir 					pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_TABLE)->GetCommand() );
1089cdf0e10cSrcweir                     pDlg->SetEditHelpId( HID_PASSWD_TABLE );
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir                     if (pDlg->Execute() == RET_OK)
1092cdf0e10cSrcweir                     {
1093cdf0e10cSrcweir                         String aPassword = pDlg->GetPassword();
1094cdf0e10cSrcweir                         Unprotect(nTab, aPassword);
1095cdf0e10cSrcweir                     }
1096cdf0e10cSrcweir                 }
1097cdf0e10cSrcweir                 else
1098cdf0e10cSrcweir                     // this sheet is not password-protected.
1099cdf0e10cSrcweir                     Unprotect(nTab, String());
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir                 if (!pReqArgs)
1102cdf0e10cSrcweir                 {
1103cdf0e10cSrcweir                     rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, false) );
1104cdf0e10cSrcweir                     rReq.Done();
1105cdf0e10cSrcweir                 }
1106cdf0e10cSrcweir             }
1107cdf0e10cSrcweir             else
1108cdf0e10cSrcweir             {
1109cdf0e10cSrcweir                 // Protect a current sheet.
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir                 auto_ptr<ScTableProtectionDlg> pDlg(new ScTableProtectionDlg(GetDialogParent()));
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir                 ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
1114cdf0e10cSrcweir                 if (pProtect)
1115cdf0e10cSrcweir                     pDlg->SetDialogData(*pProtect);
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir                 if (pDlg->Execute() == RET_OK)
1118cdf0e10cSrcweir                 {
1119cdf0e10cSrcweir                     pScMod->InputEnterHandler();
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir                     ScTableProtection aNewProtect;
1122cdf0e10cSrcweir                     pDlg->WriteData(aNewProtect);
1123cdf0e10cSrcweir                     ProtectSheet(nTab, aNewProtect);
1124cdf0e10cSrcweir                     if (!pReqArgs)
1125cdf0e10cSrcweir                     {
1126cdf0e10cSrcweir                         rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, true) );
1127cdf0e10cSrcweir                         rReq.Done();
1128cdf0e10cSrcweir                     }
1129cdf0e10cSrcweir                 }
1130cdf0e10cSrcweir             }
1131cdf0e10cSrcweir #else
1132cdf0e10cSrcweir             auto_ptr<SfxPasswordDialog> pDlg;
1133cdf0e10cSrcweir             String				aPassword;
1134cdf0e10cSrcweir             sal_Bool				bCancel = sal_False;
1135cdf0e10cSrcweir             bool                bNewProtection = ! bOldProtection;
1136cdf0e10cSrcweir 
1137cdf0e10cSrcweir             if( pReqArgs )
1138cdf0e10cSrcweir             {
1139cdf0e10cSrcweir                 const SfxPoolItem* pItem;
1140cdf0e10cSrcweir                 if( IS_AVAILABLE( FID_PROTECT_TABLE, &pItem ) )
1141cdf0e10cSrcweir                     bNewProtection = ((const SfxBoolItem*)pItem)->GetValue();
1142cdf0e10cSrcweir                 if( bNewProtection == bOldProtection )
1143cdf0e10cSrcweir                 {
1144cdf0e10cSrcweir                     rReq.Ignore();
1145cdf0e10cSrcweir                     break;
1146cdf0e10cSrcweir                 }
1147cdf0e10cSrcweir             }
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir             if ( bOldProtection)
1150cdf0e10cSrcweir             {
1151cdf0e10cSrcweir                 // Unprotect a protected sheet.
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir                 ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
1154cdf0e10cSrcweir                 if (pProtect && pProtect->isProtectedWithPass())
1155cdf0e10cSrcweir                 {
1156cdf0e10cSrcweir                     String aText( ScResId(SCSTR_PASSWORDOPT) );
1157cdf0e10cSrcweir                     pDlg.reset(new SfxPasswordDialog(GetDialogParent(), &aText));
1158cdf0e10cSrcweir                     pDlg->SetText( ScResId(SCSTR_UNPROTECTTAB) );
1159cdf0e10cSrcweir                     pDlg->SetMinLen( 0 );
1160cdf0e10cSrcweir 					pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_TABLE)->GetCommand() );
1161cdf0e10cSrcweir                     pDlg->SetEditHelpId( HID_PASSWD_TABLE );
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir                     if (pDlg->Execute() == RET_OK)
1164cdf0e10cSrcweir                         aPassword = pDlg->GetPassword();
1165cdf0e10cSrcweir                     else
1166cdf0e10cSrcweir                         bCancel = sal_True;
1167cdf0e10cSrcweir                 }
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir                 if (!pReqArgs)
1170cdf0e10cSrcweir                 {
1171cdf0e10cSrcweir                     rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, false) );
1172cdf0e10cSrcweir                     rReq.Done();
1173cdf0e10cSrcweir                 }
1174cdf0e10cSrcweir             }
1175cdf0e10cSrcweir             else
1176cdf0e10cSrcweir             {
1177cdf0e10cSrcweir                 String aText( ScResId(SCSTR_PASSWORDOPT) );
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir                 pDlg.reset(new SfxPasswordDialog(GetDialogParent(), &aText));
1180cdf0e10cSrcweir                 pDlg->SetText( ScResId(SCSTR_PROTECTTAB) );
1181cdf0e10cSrcweir                 pDlg->SetMinLen( 0 );
1182cdf0e10cSrcweir                 pDlg->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_TABLE)->GetCommand() );
1183cdf0e10cSrcweir                 pDlg->SetEditHelpId( HID_PASSWD_TABLE );
1184cdf0e10cSrcweir                 pDlg->ShowExtras( SHOWEXTRAS_CONFIRM );
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir                 if (pDlg->Execute() == RET_OK)
1187cdf0e10cSrcweir                     aPassword = pDlg->GetPassword();
1188cdf0e10cSrcweir                 else
1189cdf0e10cSrcweir                     bCancel = sal_True;
1190cdf0e10cSrcweir             }
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir             if( !bCancel )
1193cdf0e10cSrcweir             {
1194cdf0e10cSrcweir                 if ( bOldProtection )
1195cdf0e10cSrcweir                     Unprotect( nTab, aPassword );
1196cdf0e10cSrcweir                 else
1197cdf0e10cSrcweir                 {
1198cdf0e10cSrcweir                     pScMod->InputEnterHandler();
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir                     Protect( nTab, aPassword );
1201cdf0e10cSrcweir                 }
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir                 if( !pReqArgs )
1204cdf0e10cSrcweir                 {
1205cdf0e10cSrcweir                     rReq.AppendItem( SfxBoolItem( FID_PROTECT_TABLE, bNewProtection ) );
1206cdf0e10cSrcweir                     rReq.Done();
1207cdf0e10cSrcweir                 }
1208cdf0e10cSrcweir             }
1209cdf0e10cSrcweir #endif
1210cdf0e10cSrcweir             TabChanged();
1211cdf0e10cSrcweir             UpdateInputHandler(true);   // damit sofort wieder eingegeben werden kann
1212cdf0e10cSrcweir             SelectionChanged();
1213cdf0e10cSrcweir         }
1214cdf0e10cSrcweir         break;
1215cdf0e10cSrcweir 
1216cdf0e10cSrcweir         case SID_OPT_LOCALE_CHANGED :
1217cdf0e10cSrcweir             {   // locale changed, SYSTEM number formats changed => repaint cell contents
1218cdf0e10cSrcweir                 PaintGrid();
1219cdf0e10cSrcweir 				rReq.Done();
1220cdf0e10cSrcweir 			}
1221cdf0e10cSrcweir             break;
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 		default:
1224cdf0e10cSrcweir 			DBG_ERROR("Unbekannter Slot bei ScTabViewShell::Execute");
1225cdf0e10cSrcweir 			break;
1226cdf0e10cSrcweir 	}
1227cdf0e10cSrcweir }
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir 
1231