xref: /aoo42x/main/sc/source/ui/view/tabvwsha.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE
36*cdf0e10cSrcweir #include "scitems.hxx"
37*cdf0e10cSrcweir #include <svl/stritem.hxx>
38*cdf0e10cSrcweir #include <svl/whiter.hxx>
39*cdf0e10cSrcweir #include <svl/zformat.hxx>
40*cdf0e10cSrcweir #include <editeng/boxitem.hxx>
41*cdf0e10cSrcweir #include <svx/numinf.hxx>
42*cdf0e10cSrcweir #include <svl/srchitem.hxx>
43*cdf0e10cSrcweir #include <svx/zoomslideritem.hxx>
44*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
45*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
46*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
47*cdf0e10cSrcweir #include <sfx2/request.hxx>
48*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #include "global.hxx"
51*cdf0e10cSrcweir #include "attrib.hxx"
52*cdf0e10cSrcweir #include "patattr.hxx"
53*cdf0e10cSrcweir #include "document.hxx"
54*cdf0e10cSrcweir #include "cell.hxx"             // Input Status Edit-Zellen
55*cdf0e10cSrcweir #include "globstr.hrc"
56*cdf0e10cSrcweir #include "scmod.hxx"
57*cdf0e10cSrcweir #include "inputhdl.hxx"
58*cdf0e10cSrcweir #include "inputwin.hxx"
59*cdf0e10cSrcweir #include "docsh.hxx"
60*cdf0e10cSrcweir #include "viewdata.hxx"
61*cdf0e10cSrcweir //CHINA001 #include "attrdlg.hxx"
62*cdf0e10cSrcweir #include "appoptio.hxx"
63*cdf0e10cSrcweir #include "sc.hrc"
64*cdf0e10cSrcweir #include "stlpool.hxx"
65*cdf0e10cSrcweir #include "tabvwsh.hxx"
66*cdf0e10cSrcweir #include "dwfunctr.hxx"
67*cdf0e10cSrcweir #include "scabstdlg.hxx" //CHINA001
68*cdf0e10cSrcweir #include "compiler.hxx"
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir sal_Bool ScTabViewShell::GetFunction( String& rFuncStr, sal_uInt16 nErrCode )
72*cdf0e10cSrcweir {
73*cdf0e10cSrcweir 	String aStr;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc();
76*cdf0e10cSrcweir     ScViewData* pViewData	= GetViewData();
77*cdf0e10cSrcweir     ScMarkData& rMark		= pViewData->GetMarkData();
78*cdf0e10cSrcweir     bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked());
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
81*cdf0e10cSrcweir         nErrCode = 0;
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     if (nErrCode)
84*cdf0e10cSrcweir     {
85*cdf0e10cSrcweir         rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
86*cdf0e10cSrcweir         return true;
87*cdf0e10cSrcweir     }
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	sal_uInt16 nGlobStrId = 0;
90*cdf0e10cSrcweir 	switch (eFunc)
91*cdf0e10cSrcweir 	{
92*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_AVE:	 nGlobStrId = STR_FUN_TEXT_AVG; break;
93*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_CNT:	 nGlobStrId = STR_FUN_TEXT_COUNT; break;
94*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break;
95*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_MAX:	 nGlobStrId = STR_FUN_TEXT_MAX; break;
96*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_MIN:	 nGlobStrId = STR_FUN_TEXT_MIN; break;
97*cdf0e10cSrcweir 		case SUBTOTAL_FUNC_SUM:	 nGlobStrId = STR_FUN_TEXT_SUM; break;
98*cdf0e10cSrcweir         default:
99*cdf0e10cSrcweir         {
100*cdf0e10cSrcweir             // added to avoid warnings
101*cdf0e10cSrcweir         }
102*cdf0e10cSrcweir 	}
103*cdf0e10cSrcweir 	if (nGlobStrId)
104*cdf0e10cSrcweir 	{
105*cdf0e10cSrcweir 		ScDocument* pDoc		= pViewData->GetDocument();
106*cdf0e10cSrcweir 		SCCOL		nPosX		= pViewData->GetCurX();
107*cdf0e10cSrcweir 		SCROW		nPosY		= pViewData->GetCurY();
108*cdf0e10cSrcweir 		SCTAB		nTab		= pViewData->GetTabNo();
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 		aStr = ScGlobal::GetRscString(nGlobStrId);
111*cdf0e10cSrcweir 		aStr += '=';
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir         ScAddress aCursor( nPosX, nPosY, nTab );
114*cdf0e10cSrcweir 		double nVal;
115*cdf0e10cSrcweir 		if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
116*cdf0e10cSrcweir 		{
117*cdf0e10cSrcweir             if ( nVal == 0.0 )
118*cdf0e10cSrcweir                 aStr += '0';
119*cdf0e10cSrcweir             else
120*cdf0e10cSrcweir             {
121*cdf0e10cSrcweir 		        //	Anzahl im Standardformat, die anderen nach Cursorposition
122*cdf0e10cSrcweir                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
123*cdf0e10cSrcweir 		        sal_uInt32 nNumFmt = 0;
124*cdf0e10cSrcweir 		        if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 )
125*cdf0e10cSrcweir 		        {
126*cdf0e10cSrcweir 			        //	Zahlformat aus Attributen oder Formel
127*cdf0e10cSrcweir 			        pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
128*cdf0e10cSrcweir 			        if ( (nNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
129*cdf0e10cSrcweir 			        {
130*cdf0e10cSrcweir 				        ScBaseCell* pCell;
131*cdf0e10cSrcweir 				        pDoc->GetCell( nPosX, nPosY, nTab, pCell );
132*cdf0e10cSrcweir 				        if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA)
133*cdf0e10cSrcweir                         {
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 					        nNumFmt = ((ScFormulaCell*)pCell)->GetStandardFormat(*pFormatter, nNumFmt );
136*cdf0e10cSrcweir                         }
137*cdf0e10cSrcweir 			        }
138*cdf0e10cSrcweir 		        }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 			    String aValStr;
141*cdf0e10cSrcweir 			    Color* pDummy;
142*cdf0e10cSrcweir 			    pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
143*cdf0e10cSrcweir 			    aStr += aValStr;
144*cdf0e10cSrcweir             }
145*cdf0e10cSrcweir 		}
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		rFuncStr = aStr;
148*cdf0e10cSrcweir 		return sal_True;
149*cdf0e10cSrcweir 	}
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	return sal_False;
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir //	Funktionen, die je nach Selektion disabled sind
157*cdf0e10cSrcweir //	Default:
158*cdf0e10cSrcweir //		SID_DELETE,
159*cdf0e10cSrcweir //		SID_DELETE_CONTENTS,
160*cdf0e10cSrcweir //		FID_DELETE_CELL
161*cdf0e10cSrcweir //		FID_VALIDATION
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir void __EXPORT ScTabViewShell::GetState( SfxItemSet& rSet )
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir 	ScViewData* pViewData	= GetViewData();
167*cdf0e10cSrcweir 	ScDocument* pDoc		= pViewData->GetDocument();
168*cdf0e10cSrcweir     ScDocShell* pDocShell   = pViewData->GetDocShell();
169*cdf0e10cSrcweir 	ScMarkData& rMark		= pViewData->GetMarkData();
170*cdf0e10cSrcweir 	SCCOL		nPosX		= pViewData->GetCurX();
171*cdf0e10cSrcweir 	SCROW		nPosY		= pViewData->GetCurY();
172*cdf0e10cSrcweir 	SCTAB		nTab		= pViewData->GetTabNo();
173*cdf0e10cSrcweir 	sal_uInt16		nMyId		= 0;
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 	SfxViewFrame* pThisFrame = GetViewFrame();
176*cdf0e10cSrcweir     sal_Bool bOle = GetViewFrame()->GetFrame().IsInPlace();
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	SCTAB nTabCount = pDoc->GetTableCount();
179*cdf0e10cSrcweir 	SCTAB nTabSelCount = rMark.GetSelectCount();
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 	SfxWhichIter	aIter(rSet);
182*cdf0e10cSrcweir 	sal_uInt16			nWhich = aIter.FirstWhich();
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	while ( nWhich )
185*cdf0e10cSrcweir 	{
186*cdf0e10cSrcweir 		switch ( nWhich )
187*cdf0e10cSrcweir 		{
188*cdf0e10cSrcweir 			case FID_CHG_COMMENT:
189*cdf0e10cSrcweir 				{
190*cdf0e10cSrcweir 					ScDocShell* pDocSh = GetViewData()->GetDocShell();
191*cdf0e10cSrcweir 					ScAddress aPos( nPosX, nPosY, nTab );
192*cdf0e10cSrcweir 					if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() )
193*cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
194*cdf0e10cSrcweir 				}
195*cdf0e10cSrcweir 				break;
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir             case SID_OPENDLG_EDIT_PRINTAREA:
198*cdf0e10cSrcweir             case SID_ADD_PRINTAREA:
199*cdf0e10cSrcweir             case SID_DEFINE_PRINTAREA:
200*cdf0e10cSrcweir                 {
201*cdf0e10cSrcweir                     if ( pDocShell && pDocShell->IsDocShared() )
202*cdf0e10cSrcweir                     {
203*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
204*cdf0e10cSrcweir                     }
205*cdf0e10cSrcweir                 }
206*cdf0e10cSrcweir                 break;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 			case SID_DELETE_PRINTAREA:
209*cdf0e10cSrcweir 				if ( nTabSelCount > 1 )
210*cdf0e10cSrcweir 				{
211*cdf0e10cSrcweir                     // #i22589# also take "Print Entire Sheet" into account here
212*cdf0e10cSrcweir 					sal_Bool bHas = sal_False;
213*cdf0e10cSrcweir                     for (SCTAB i=0; !bHas && i<nTabCount; i++)
214*cdf0e10cSrcweir                         bHas = rMark.GetTableSelect(i) && (pDoc->GetPrintRangeCount(i) || pDoc->IsPrintEntireSheet(i));
215*cdf0e10cSrcweir 					if (!bHas)
216*cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
217*cdf0e10cSrcweir 				}
218*cdf0e10cSrcweir                 else if ( !pDoc->GetPrintRangeCount( nTab ) && !pDoc->IsPrintEntireSheet( nTab ) )
219*cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
220*cdf0e10cSrcweir                 if ( pDocShell && pDocShell->IsDocShared() )
221*cdf0e10cSrcweir                 {
222*cdf0e10cSrcweir                     rSet.DisableItem( nWhich );
223*cdf0e10cSrcweir                 }
224*cdf0e10cSrcweir 				break;
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 			case SID_STATUS_PAGESTYLE:
227*cdf0e10cSrcweir 			case SID_HFEDIT:
228*cdf0e10cSrcweir 				GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet, nTab );
229*cdf0e10cSrcweir 				break;
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 			case SID_SEARCH_ITEM:
232*cdf0e10cSrcweir 				rSet.Put( ScGlobal::GetSearchItem() );
233*cdf0e10cSrcweir 				break;
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 			case SID_SEARCH_OPTIONS:
236*cdf0e10cSrcweir 				{
237*cdf0e10cSrcweir 					sal_uInt16 nOptions = 0xffff;		// alles erlaubt
238*cdf0e10cSrcweir 													// wenn ReadOnly, kein Ersetzen:
239*cdf0e10cSrcweir 					if (GetViewData()->GetDocShell()->IsReadOnly())
240*cdf0e10cSrcweir 						nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL );
241*cdf0e10cSrcweir 					rSet.Put( SfxUInt16Item( nWhich, nOptions ) );
242*cdf0e10cSrcweir 				}
243*cdf0e10cSrcweir 				break;
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir 			case SID_CURRENTCELL:
246*cdf0e10cSrcweir 				{
247*cdf0e10cSrcweir 					ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
248*cdf0e10cSrcweir 					String	aAddr;
249*cdf0e10cSrcweir 					aScAddress.Format( aAddr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
250*cdf0e10cSrcweir 					SfxStringItem	aPosItem( SID_CURRENTCELL, aAddr );
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 					rSet.Put( aPosItem );
253*cdf0e10cSrcweir 				}
254*cdf0e10cSrcweir 				break;
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 			case SID_CURRENTTAB:
257*cdf0e10cSrcweir 				//	Tabelle fuer Basic ist 1-basiert
258*cdf0e10cSrcweir 				rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData()->GetTabNo()) + 1 ) );
259*cdf0e10cSrcweir 				break;
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 			case SID_CURRENTDOC:
262*cdf0e10cSrcweir 				rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) );
263*cdf0e10cSrcweir 				break;
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 			case FID_TOGGLEINPUTLINE:
266*cdf0e10cSrcweir 				{
267*cdf0e10cSrcweir 					sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 					if ( pThisFrame->KnowsChildWindow( nId ) )
270*cdf0e10cSrcweir 					{
271*cdf0e10cSrcweir 						SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
272*cdf0e10cSrcweir 						rSet.Put( SfxBoolItem( nWhich, pWnd ? sal_True : sal_False ) );
273*cdf0e10cSrcweir 					}
274*cdf0e10cSrcweir 					else
275*cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
276*cdf0e10cSrcweir 				}
277*cdf0e10cSrcweir 				break;
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 			case FID_DEL_MANUALBREAKS:
280*cdf0e10cSrcweir 				if (!pDoc->HasManualBreaks(nTab))
281*cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
282*cdf0e10cSrcweir 				break;
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 			case FID_RESET_PRINTZOOM:
285*cdf0e10cSrcweir 				{
286*cdf0e10cSrcweir 					//	disablen, wenn schon Default eingestellt
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 					String aStyleName = pDoc->GetPageStyle( nTab );
289*cdf0e10cSrcweir 					ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
290*cdf0e10cSrcweir 					SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
291*cdf0e10cSrcweir 													SFX_STYLE_FAMILY_PAGE );
292*cdf0e10cSrcweir 					DBG_ASSERT( pStyleSheet, "PageStyle not found" );
293*cdf0e10cSrcweir 					if ( pStyleSheet )
294*cdf0e10cSrcweir 					{
295*cdf0e10cSrcweir 						SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
296*cdf0e10cSrcweir 						sal_uInt16 nScale = ((const SfxUInt16Item&)
297*cdf0e10cSrcweir 											rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
298*cdf0e10cSrcweir 						sal_uInt16 nPages = ((const SfxUInt16Item&)
299*cdf0e10cSrcweir 											rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
300*cdf0e10cSrcweir 						if ( nScale == 100 && nPages == 0 )
301*cdf0e10cSrcweir 							rSet.DisableItem( nWhich );
302*cdf0e10cSrcweir 					}
303*cdf0e10cSrcweir 				}
304*cdf0e10cSrcweir 				break;
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir 			case FID_SCALE:
307*cdf0e10cSrcweir 			case SID_ATTR_ZOOM:
308*cdf0e10cSrcweir 				if ( bOle )
309*cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
310*cdf0e10cSrcweir 				else
311*cdf0e10cSrcweir 				{
312*cdf0e10cSrcweir 					const Fraction& rOldY = GetViewData()->GetZoomY();
313*cdf0e10cSrcweir 					sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 )
314*cdf0e10cSrcweir 												/ rOldY.GetDenominator());
315*cdf0e10cSrcweir 					rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) );
316*cdf0e10cSrcweir 				}
317*cdf0e10cSrcweir 				break;
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir             case SID_ATTR_ZOOMSLIDER:
320*cdf0e10cSrcweir                 {
321*cdf0e10cSrcweir                     if ( bOle )
322*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
323*cdf0e10cSrcweir                     else
324*cdf0e10cSrcweir                     {
325*cdf0e10cSrcweir                         const Fraction& rOldY = GetViewData()->GetZoomY();
326*cdf0e10cSrcweir                         sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir                         if( nCurrentZoom )
329*cdf0e10cSrcweir                         {
330*cdf0e10cSrcweir                             SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
331*cdf0e10cSrcweir                             aZoomSliderItem.AddSnappingPoint( 100 );
332*cdf0e10cSrcweir                             rSet.Put( aZoomSliderItem );
333*cdf0e10cSrcweir                         }
334*cdf0e10cSrcweir                     }
335*cdf0e10cSrcweir                 }
336*cdf0e10cSrcweir                 break;
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 			case FID_TOGGLESYNTAX:
339*cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode()));
340*cdf0e10cSrcweir 				break;
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir 			case FID_TOGGLEHEADERS:
343*cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode()));
344*cdf0e10cSrcweir 				break;
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir             case FID_TOGGLEFORMULA:
347*cdf0e10cSrcweir                 {
348*cdf0e10cSrcweir                     const ScViewOptions& rOpts = pViewData->GetOptions();
349*cdf0e10cSrcweir                     sal_Bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
350*cdf0e10cSrcweir                     rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
351*cdf0e10cSrcweir                 }
352*cdf0e10cSrcweir                 break;
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir             case FID_NORMALVIEWMODE:
355*cdf0e10cSrcweir 			case FID_PAGEBREAKMODE:
356*cdf0e10cSrcweir                 // always handle both slots - they exclude each other
357*cdf0e10cSrcweir 				if ( bOle )
358*cdf0e10cSrcweir                 {
359*cdf0e10cSrcweir                     rSet.DisableItem( FID_NORMALVIEWMODE );
360*cdf0e10cSrcweir                     rSet.DisableItem( FID_PAGEBREAKMODE );
361*cdf0e10cSrcweir                 }
362*cdf0e10cSrcweir 				else
363*cdf0e10cSrcweir                 {
364*cdf0e10cSrcweir                     rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData()->IsPagebreakMode()));
365*cdf0e10cSrcweir                     rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData()->IsPagebreakMode()));
366*cdf0e10cSrcweir                 }
367*cdf0e10cSrcweir 				break;
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir 			case FID_FUNCTION_BOX:
370*cdf0e10cSrcweir 				nMyId = ScFunctionChildWindow::GetChildWindowId();
371*cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId)));
372*cdf0e10cSrcweir 				break;
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 			case FID_PROTECT_DOC:
375*cdf0e10cSrcweir                 {
376*cdf0e10cSrcweir                     if ( pDocShell && pDocShell->IsDocShared() )
377*cdf0e10cSrcweir                     {
378*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
379*cdf0e10cSrcweir                     }
380*cdf0e10cSrcweir                     else
381*cdf0e10cSrcweir                     {
382*cdf0e10cSrcweir                         rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) );
383*cdf0e10cSrcweir                     }
384*cdf0e10cSrcweir                 }
385*cdf0e10cSrcweir 				break;
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir 			case FID_PROTECT_TABLE:
388*cdf0e10cSrcweir                 {
389*cdf0e10cSrcweir                     if ( pDocShell && pDocShell->IsDocShared() )
390*cdf0e10cSrcweir                     {
391*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
392*cdf0e10cSrcweir                     }
393*cdf0e10cSrcweir                     else
394*cdf0e10cSrcweir                     {
395*cdf0e10cSrcweir                         rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) );
396*cdf0e10cSrcweir                     }
397*cdf0e10cSrcweir                 }
398*cdf0e10cSrcweir 				break;
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir 			case SID_AUTO_OUTLINE:
401*cdf0e10cSrcweir 				{
402*cdf0e10cSrcweir 					if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
403*cdf0e10cSrcweir 					{
404*cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
405*cdf0e10cSrcweir 					}
406*cdf0e10cSrcweir 				}
407*cdf0e10cSrcweir 				break;
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 			case SID_OUTLINE_DELETEALL:
410*cdf0e10cSrcweir 				{
411*cdf0e10cSrcweir 					SCTAB nOlTab = GetViewData()->GetTabNo();
412*cdf0e10cSrcweir 					ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab );
413*cdf0e10cSrcweir 					if (pOlTable == NULL)
414*cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
415*cdf0e10cSrcweir 				}
416*cdf0e10cSrcweir 				break;
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 			case SID_WINDOW_SPLIT:
419*cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich,
420*cdf0e10cSrcweir 							pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
421*cdf0e10cSrcweir 							pViewData->GetVSplitMode() == SC_SPLIT_NORMAL ));
422*cdf0e10cSrcweir 				break;
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir 			case SID_WINDOW_FIX:
425*cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich,
426*cdf0e10cSrcweir 							pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
427*cdf0e10cSrcweir 							pViewData->GetVSplitMode() == SC_SPLIT_FIX ));
428*cdf0e10cSrcweir 				break;
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 			case FID_CHG_SHOW:
431*cdf0e10cSrcweir 				{
432*cdf0e10cSrcweir                     if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) )
433*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
434*cdf0e10cSrcweir 				}
435*cdf0e10cSrcweir 				break;
436*cdf0e10cSrcweir 			case FID_CHG_ACCEPT:
437*cdf0e10cSrcweir 				{
438*cdf0e10cSrcweir 					rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
439*cdf0e10cSrcweir 							pThisFrame->HasChildWindow(FID_CHG_ACCEPT)));
440*cdf0e10cSrcweir 					if(pDoc->GetChangeTrack()==NULL)
441*cdf0e10cSrcweir 					{
442*cdf0e10cSrcweir 						if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
443*cdf0e10cSrcweir 						{
444*cdf0e10cSrcweir 							rSet.DisableItem( nWhich);
445*cdf0e10cSrcweir 						}
446*cdf0e10cSrcweir 					}
447*cdf0e10cSrcweir                     if ( pDocShell && pDocShell->IsDocShared() )
448*cdf0e10cSrcweir                     {
449*cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
450*cdf0e10cSrcweir                     }
451*cdf0e10cSrcweir 				}
452*cdf0e10cSrcweir 				break;
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 			case SID_FORMATPAGE:
455*cdf0e10cSrcweir 				//!	bei geschuetzten Tabellen ???
456*cdf0e10cSrcweir                 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
457*cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
458*cdf0e10cSrcweir 				break;
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir 			case SID_PRINTPREVIEW:
461*cdf0e10cSrcweir 				// #58924# Toggle-Slot braucht einen State
462*cdf0e10cSrcweir 				rSet.Put( SfxBoolItem( nWhich, sal_False ) );
463*cdf0e10cSrcweir 				break;
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 			case SID_READONLY_MODE:
466*cdf0e10cSrcweir 				rSet.Put( SfxBoolItem( nWhich, GetViewData()->GetDocShell()->IsReadOnly() ) );
467*cdf0e10cSrcweir 				break;
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir             case FID_TAB_DESELECTALL:
470*cdf0e10cSrcweir                 if ( nTabSelCount == 1 )
471*cdf0e10cSrcweir                     rSet.DisableItem( nWhich );     // enabled only if several sheets are selected
472*cdf0e10cSrcweir                 break;
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 		} // switch ( nWitch )
475*cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
476*cdf0e10cSrcweir 	} // while ( nWitch )
477*cdf0e10cSrcweir }
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir //------------------------------------------------------------------
480*cdf0e10cSrcweir void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest& rReq, sal_uInt16 nTabPage )
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir 	//CHINA001 ScAttrDlg*				pDlg	= NULL;
483*cdf0e10cSrcweir 	SfxAbstractTabDialog * pDlg	= NULL; //CHINA001
484*cdf0e10cSrcweir 	ScDocument* 			pDoc	= GetViewData()->GetDocument();
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 	SvxBoxItem				aLineOuter( ATTR_BORDER );
487*cdf0e10cSrcweir 	SvxBoxInfoItem			aLineInner( ATTR_BORDER_INNER );
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir 	SvxNumberInfoItem*		pNumberInfoItem = NULL;
490*cdf0e10cSrcweir 	const ScPatternAttr*	pOldAttrs		= GetSelectionPattern();
491*cdf0e10cSrcweir 	SfxItemSet* 			pOldSet 		= new SfxItemSet(
492*cdf0e10cSrcweir 													pOldAttrs->GetItemSet() );
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir 	// Umrandungs-Items holen und in den Set packen:
496*cdf0e10cSrcweir 	GetSelectionFrame( aLineOuter, aLineInner );
497*cdf0e10cSrcweir 	pOldSet->Put( aLineOuter );
498*cdf0e10cSrcweir 	pOldSet->Put( aLineInner );
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	// NumberFormat Value aus Value und Language erzeugen und eintueten
501*cdf0e10cSrcweir 	pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
502*cdf0e10cSrcweir 		pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 	MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir 	pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
507*cdf0e10cSrcweir 	pOldSet->Put(*pNumberInfoItem );
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 	bInFormatDialog = sal_True;
510*cdf0e10cSrcweir 	//CHINA001 pDlg = new ScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet );
511*cdf0e10cSrcweir 	ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
512*cdf0e10cSrcweir 	DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir 	pDlg = pFact->CreateScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet, RID_SCDLG_ATTR);
515*cdf0e10cSrcweir 	DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
516*cdf0e10cSrcweir 	if ( nTabPage != 0xffff )
517*cdf0e10cSrcweir 		pDlg->SetCurPageId( nTabPage );
518*cdf0e10cSrcweir 	short nResult = pDlg->Execute();
519*cdf0e10cSrcweir 	bInFormatDialog = sal_False;
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 	if ( nResult == RET_OK )
522*cdf0e10cSrcweir 	{
523*cdf0e10cSrcweir 		const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 		const SfxPoolItem* pItem=NULL;
526*cdf0e10cSrcweir 		if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,sal_True,&pItem)==SFX_ITEM_SET)
527*cdf0e10cSrcweir 		{
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir 			UpdateNumberFormatter( pDoc,(const SvxNumberInfoItem&)*pItem);
530*cdf0e10cSrcweir 		}
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 		ApplyAttributes( pOutSet, pOldSet );
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir 		rReq.Done( *pOutSet );
535*cdf0e10cSrcweir 	}
536*cdf0e10cSrcweir 	delete pOldSet;
537*cdf0e10cSrcweir 	delete pNumberInfoItem;
538*cdf0e10cSrcweir 	delete pDlg;
539*cdf0e10cSrcweir }
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir //------------------------------------------------------------------
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir bool ScTabViewShell::IsRefInputMode() const
544*cdf0e10cSrcweir {
545*cdf0e10cSrcweir     ScModule* pScMod = SC_MOD();
546*cdf0e10cSrcweir     if ( pScMod )
547*cdf0e10cSrcweir     {
548*cdf0e10cSrcweir         if( pScMod->IsRefDialogOpen() )
549*cdf0e10cSrcweir             return pScMod->IsFormulaMode();
550*cdf0e10cSrcweir         if( pScMod->IsFormulaMode() )
551*cdf0e10cSrcweir         {
552*cdf0e10cSrcweir             ScInputHandler* pHdl = pScMod->GetInputHdl();
553*cdf0e10cSrcweir             if ( pHdl )
554*cdf0e10cSrcweir             {
555*cdf0e10cSrcweir                 String aString = pHdl->GetEditString();
556*cdf0e10cSrcweir                 if ( !pHdl->GetSelIsRef() && aString.Len() > 1 &&
557*cdf0e10cSrcweir                      ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
558*cdf0e10cSrcweir                 {
559*cdf0e10cSrcweir                     const ScViewData* pViewData = GetViewData();
560*cdf0e10cSrcweir                     if ( pViewData )
561*cdf0e10cSrcweir                     {
562*cdf0e10cSrcweir                         ScDocument* pDoc = pViewData->GetDocument();
563*cdf0e10cSrcweir                         if ( pDoc )
564*cdf0e10cSrcweir                         {
565*cdf0e10cSrcweir                             const ScAddress aPos( pViewData->GetCurPos() );
566*cdf0e10cSrcweir                             ScCompiler aComp( pDoc, aPos );
567*cdf0e10cSrcweir                             aComp.SetGrammar(pDoc->GetGrammar());
568*cdf0e10cSrcweir                             aComp.SetCloseBrackets( false );
569*cdf0e10cSrcweir                             ScTokenArray* pArr = aComp.CompileString( aString );
570*cdf0e10cSrcweir                             if ( pArr && pArr->MayReferenceFollow() )
571*cdf0e10cSrcweir                             {
572*cdf0e10cSrcweir                                 return true;
573*cdf0e10cSrcweir                             }
574*cdf0e10cSrcweir                         }
575*cdf0e10cSrcweir                     }
576*cdf0e10cSrcweir                 }
577*cdf0e10cSrcweir                 else
578*cdf0e10cSrcweir                 {
579*cdf0e10cSrcweir                     return true;
580*cdf0e10cSrcweir                 }
581*cdf0e10cSrcweir             }
582*cdf0e10cSrcweir         }
583*cdf0e10cSrcweir     }
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir     return false;
586*cdf0e10cSrcweir }
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir //------------------------------------------------------------------
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir void ScTabViewShell::ExecuteInputDirect()
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir     if ( !IsRefInputMode() )
593*cdf0e10cSrcweir     {
594*cdf0e10cSrcweir         ScModule* pScMod = SC_MOD();
595*cdf0e10cSrcweir         if ( pScMod )
596*cdf0e10cSrcweir         {
597*cdf0e10cSrcweir             pScMod->InputEnterHandler();
598*cdf0e10cSrcweir         }
599*cdf0e10cSrcweir     }
600*cdf0e10cSrcweir }
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir //------------------------------------------------------------------
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_Bool bStopEditing /* = sal_True */ )
605*cdf0e10cSrcweir {
606*cdf0e10cSrcweir 	ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl();
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir 	if ( pHdl )
609*cdf0e10cSrcweir 	{
610*cdf0e10cSrcweir 		String					aString;
611*cdf0e10cSrcweir 		const EditTextObject*	pObject 	= NULL;
612*cdf0e10cSrcweir 		ScViewData*				pViewData	= GetViewData();
613*cdf0e10cSrcweir 		ScDocument*				pDoc		= pViewData->GetDocument();
614*cdf0e10cSrcweir 		CellType				eType;
615*cdf0e10cSrcweir 		SCCOL					nPosX		= pViewData->GetCurX();
616*cdf0e10cSrcweir 		SCROW					nPosY		= pViewData->GetCurY();
617*cdf0e10cSrcweir 		SCTAB					nTab		= pViewData->GetTabNo();
618*cdf0e10cSrcweir 		SCTAB					nStartTab	= 0;
619*cdf0e10cSrcweir 		SCTAB					nEndTab 	= 0;
620*cdf0e10cSrcweir 		SCCOL					nStartCol	= 0;
621*cdf0e10cSrcweir 		SCROW					nStartRow	= 0;
622*cdf0e10cSrcweir 		SCCOL					nEndCol 	= 0;
623*cdf0e10cSrcweir 		SCROW					nEndRow 	= 0;
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 		pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
626*cdf0e10cSrcweir 								  nEndCol,   nEndRow,   nEndTab );
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir 		PutInOrder( nStartCol, nEndCol );
629*cdf0e10cSrcweir 		PutInOrder( nStartRow, nEndRow );
630*cdf0e10cSrcweir 		PutInOrder( nStartTab, nEndTab );
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir 		sal_Bool bHideFormula = sal_False;
633*cdf0e10cSrcweir 		sal_Bool bHideAll	  = sal_False;
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir 		if (pDoc->IsTabProtected(nTab))
636*cdf0e10cSrcweir 		{
637*cdf0e10cSrcweir 			const ScProtectionAttr* pProt = (const ScProtectionAttr*)
638*cdf0e10cSrcweir 											pDoc->GetAttr( nPosX,nPosY,nTab,
639*cdf0e10cSrcweir 														   ATTR_PROTECTION);
640*cdf0e10cSrcweir 			bHideFormula = pProt->GetHideFormula();
641*cdf0e10cSrcweir 			bHideAll	 = pProt->GetHideCell();
642*cdf0e10cSrcweir 		}
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 		if (!bHideAll)
645*cdf0e10cSrcweir 		{
646*cdf0e10cSrcweir 			pDoc->GetCellType( nPosX, nPosY, nTab, eType );
647*cdf0e10cSrcweir 			if (eType == CELLTYPE_FORMULA)
648*cdf0e10cSrcweir 			{
649*cdf0e10cSrcweir 				if (!bHideFormula)
650*cdf0e10cSrcweir 					pDoc->GetFormula( nPosX, nPosY, nTab, aString );
651*cdf0e10cSrcweir 			}
652*cdf0e10cSrcweir 			else if (eType == CELLTYPE_EDIT)
653*cdf0e10cSrcweir 			{
654*cdf0e10cSrcweir 				ScBaseCell* pCell;
655*cdf0e10cSrcweir 				pDoc->GetCell( nPosX, nPosY, nTab, pCell );
656*cdf0e10cSrcweir 				((ScEditCell*)pCell)->GetData( pObject );
657*cdf0e10cSrcweir 			}
658*cdf0e10cSrcweir 			else
659*cdf0e10cSrcweir 			{
660*cdf0e10cSrcweir 				pDoc->GetInputString( nPosX, nPosY, nTab, aString );
661*cdf0e10cSrcweir 				if (eType == CELLTYPE_STRING)
662*cdf0e10cSrcweir 				{
663*cdf0e10cSrcweir 					//	Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
664*cdf0e10cSrcweir 					//	als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
665*cdf0e10cSrcweir 					//	dass es ein String ist (#35060#).
666*cdf0e10cSrcweir 					//!	Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir 					SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
669*cdf0e10cSrcweir 					sal_uInt32 nNumFmt;
670*cdf0e10cSrcweir 					pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
671*cdf0e10cSrcweir 					double fDummy;
672*cdf0e10cSrcweir 					if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) )
673*cdf0e10cSrcweir 						aString.Insert('\'',0);
674*cdf0e10cSrcweir 				}
675*cdf0e10cSrcweir 			}
676*cdf0e10cSrcweir 		}
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir 		ScInputHdlState	aState( ScAddress( nPosX,	  nPosY, 	 nTab ),
679*cdf0e10cSrcweir 								ScAddress( nStartCol, nStartRow, nTab ),
680*cdf0e10cSrcweir 								ScAddress( nEndCol,	  nEndRow,   nTab ),
681*cdf0e10cSrcweir 								aString,
682*cdf0e10cSrcweir 								pObject );
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir 		//	if using the view's local input handler, this view can always be set
685*cdf0e10cSrcweir 		//	as current view inside NotifyChange.
686*cdf0e10cSrcweir 		ScTabViewShell* pSourceSh = pInputHandler ? this : NULL;
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 		pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
689*cdf0e10cSrcweir 	}
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir 	SfxBindings& rBindings = GetViewFrame()->GetBindings();
692*cdf0e10cSrcweir 	rBindings.Invalidate( SID_STATUS_SUM );			// immer zusammen mit Eingabezeile
693*cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_SIZE );
694*cdf0e10cSrcweir     rBindings.Invalidate( SID_TABLE_CELL );
695*cdf0e10cSrcweir }
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust )
698*cdf0e10cSrcweir {
699*cdf0e10cSrcweir     if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() )
700*cdf0e10cSrcweir         pHdl->UpdateCellAdjust( eJust );
701*cdf0e10cSrcweir }
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir //------------------------------------------------------------------
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir void __EXPORT ScTabViewShell::ExecuteSave( SfxRequest& rReq )
706*cdf0e10cSrcweir {
707*cdf0e10cSrcweir 	//	nur SID_SAVEDOC / SID_SAVEASDOC
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir 	// Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird
710*cdf0e10cSrcweir 	SC_MOD()->InputEnterHandler();
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir     if ( GetViewData()->GetDocShell()->IsDocShared() )
713*cdf0e10cSrcweir     {
714*cdf0e10cSrcweir         GetViewData()->GetDocShell()->SetDocumentModified();
715*cdf0e10cSrcweir     }
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir 	// ansonsten normal weiter
718*cdf0e10cSrcweir 	GetViewData()->GetDocShell()->ExecuteSlot( rReq );
719*cdf0e10cSrcweir }
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir void __EXPORT ScTabViewShell::GetSaveState( SfxItemSet& rSet )
722*cdf0e10cSrcweir {
723*cdf0e10cSrcweir 	SfxShell* pDocSh = GetViewData()->GetDocShell();
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
726*cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
727*cdf0e10cSrcweir 	while( nWhich )
728*cdf0e10cSrcweir 	{
729*cdf0e10cSrcweir         if ( nWhich != SID_SAVEDOC || !GetViewData()->GetDocShell()->IsDocShared() )
730*cdf0e10cSrcweir         {
731*cdf0e10cSrcweir             // get state from DocShell
732*cdf0e10cSrcweir             pDocSh->GetSlotState( nWhich, NULL, &rSet );
733*cdf0e10cSrcweir         }
734*cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
735*cdf0e10cSrcweir 	}
736*cdf0e10cSrcweir }
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir //------------------------------------------------------------------
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq )
741*cdf0e10cSrcweir {
742*cdf0e10cSrcweir 	ScViewOptions aViewOptions = GetViewData()->GetOptions();
743*cdf0e10cSrcweir 	ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir 	SfxBindings& rBindings = GetViewFrame()->GetBindings();
746*cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
747*cdf0e10cSrcweir 	const SfxPoolItem* pItem;
748*cdf0e10cSrcweir 	sal_uInt16 nSlotId = rReq.GetSlot();
749*cdf0e10cSrcweir 	switch (nSlotId)
750*cdf0e10cSrcweir 	{
751*cdf0e10cSrcweir 		case SID_GRID_VISIBLE:
752*cdf0e10cSrcweir 			if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
753*cdf0e10cSrcweir 			{
754*cdf0e10cSrcweir 				aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() );
755*cdf0e10cSrcweir 				aViewOptions.SetGridOptions(aGridOptions);
756*cdf0e10cSrcweir 				rBindings.Invalidate(SID_GRID_VISIBLE);
757*cdf0e10cSrcweir 			}
758*cdf0e10cSrcweir 			break;
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir 		case SID_GRID_USE:
761*cdf0e10cSrcweir 			if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
762*cdf0e10cSrcweir 			{
763*cdf0e10cSrcweir 				aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() );
764*cdf0e10cSrcweir 				aViewOptions.SetGridOptions(aGridOptions);
765*cdf0e10cSrcweir 				rBindings.Invalidate(SID_GRID_USE);
766*cdf0e10cSrcweir 			}
767*cdf0e10cSrcweir 			break;
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir 		case SID_HELPLINES_MOVE:
770*cdf0e10cSrcweir 			if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
771*cdf0e10cSrcweir 			{
772*cdf0e10cSrcweir 				aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() );
773*cdf0e10cSrcweir 				rBindings.Invalidate(SID_HELPLINES_MOVE);
774*cdf0e10cSrcweir 			}
775*cdf0e10cSrcweir 			break;
776*cdf0e10cSrcweir 	}
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir 	GetViewData()->SetOptions(aViewOptions);
779*cdf0e10cSrcweir }
780*cdf0e10cSrcweir 
781*cdf0e10cSrcweir void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet )
782*cdf0e10cSrcweir {
783*cdf0e10cSrcweir 	SfxBoolItem aBool;
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 	const ScViewOptions& rViewOptions = GetViewData()->GetOptions();
786*cdf0e10cSrcweir 	const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir 	aBool.SetValue(rGridOptions.GetGridVisible());
789*cdf0e10cSrcweir 	aBool.SetWhich( SID_GRID_VISIBLE );
790*cdf0e10cSrcweir 	rSet.Put( aBool );
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir 	aBool.SetValue(rGridOptions.GetUseGridSnap());
793*cdf0e10cSrcweir 	aBool.SetWhich( SID_GRID_USE );
794*cdf0e10cSrcweir 	rSet.Put( aBool );
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir 	aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
797*cdf0e10cSrcweir 	aBool.SetWhich( SID_HELPLINES_MOVE );
798*cdf0e10cSrcweir 	rSet.Put( aBool );
799*cdf0e10cSrcweir }
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir 
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir 
804