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