xref: /aoo42x/main/sc/source/ui/view/tabvwsha.cxx (revision b3f79822)
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
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
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.
19*b3f79822SAndrew Rist  *
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 #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 
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 
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:
228cdf0e10cSrcweir 				rSet.Put( ScGlobal::GetSearchItem() );
229cdf0e10cSrcweir 				break;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 			case SID_SEARCH_OPTIONS:
232cdf0e10cSrcweir 				{
233cdf0e10cSrcweir 					sal_uInt16 nOptions = 0xffff;		// alles erlaubt
234cdf0e10cSrcweir 													// wenn ReadOnly, kein Ersetzen:
235cdf0e10cSrcweir 					if (GetViewData()->GetDocShell()->IsReadOnly())
236cdf0e10cSrcweir 						nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL );
237cdf0e10cSrcweir 					rSet.Put( SfxUInt16Item( nWhich, nOptions ) );
238cdf0e10cSrcweir 				}
239cdf0e10cSrcweir 				break;
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 			case SID_CURRENTCELL:
242cdf0e10cSrcweir 				{
243cdf0e10cSrcweir 					ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
244cdf0e10cSrcweir 					String	aAddr;
245cdf0e10cSrcweir 					aScAddress.Format( aAddr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
246cdf0e10cSrcweir 					SfxStringItem	aPosItem( SID_CURRENTCELL, aAddr );
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 					rSet.Put( aPosItem );
249cdf0e10cSrcweir 				}
250cdf0e10cSrcweir 				break;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 			case SID_CURRENTTAB:
253cdf0e10cSrcweir 				//	Tabelle fuer Basic ist 1-basiert
254cdf0e10cSrcweir 				rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData()->GetTabNo()) + 1 ) );
255cdf0e10cSrcweir 				break;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 			case SID_CURRENTDOC:
258cdf0e10cSrcweir 				rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) );
259cdf0e10cSrcweir 				break;
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 			case FID_TOGGLEINPUTLINE:
262cdf0e10cSrcweir 				{
263cdf0e10cSrcweir 					sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 					if ( pThisFrame->KnowsChildWindow( nId ) )
266cdf0e10cSrcweir 					{
267cdf0e10cSrcweir 						SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
268cdf0e10cSrcweir 						rSet.Put( SfxBoolItem( nWhich, pWnd ? sal_True : sal_False ) );
269cdf0e10cSrcweir 					}
270cdf0e10cSrcweir 					else
271cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
272cdf0e10cSrcweir 				}
273cdf0e10cSrcweir 				break;
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 			case FID_DEL_MANUALBREAKS:
276cdf0e10cSrcweir 				if (!pDoc->HasManualBreaks(nTab))
277cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
278cdf0e10cSrcweir 				break;
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 			case FID_RESET_PRINTZOOM:
281cdf0e10cSrcweir 				{
282cdf0e10cSrcweir 					//	disablen, wenn schon Default eingestellt
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 					String aStyleName = pDoc->GetPageStyle( nTab );
285cdf0e10cSrcweir 					ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
286cdf0e10cSrcweir 					SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
287cdf0e10cSrcweir 													SFX_STYLE_FAMILY_PAGE );
288cdf0e10cSrcweir 					DBG_ASSERT( pStyleSheet, "PageStyle not found" );
289cdf0e10cSrcweir 					if ( pStyleSheet )
290cdf0e10cSrcweir 					{
291cdf0e10cSrcweir 						SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
292cdf0e10cSrcweir 						sal_uInt16 nScale = ((const SfxUInt16Item&)
293cdf0e10cSrcweir 											rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
294cdf0e10cSrcweir 						sal_uInt16 nPages = ((const SfxUInt16Item&)
295cdf0e10cSrcweir 											rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
296cdf0e10cSrcweir 						if ( nScale == 100 && nPages == 0 )
297cdf0e10cSrcweir 							rSet.DisableItem( nWhich );
298cdf0e10cSrcweir 					}
299cdf0e10cSrcweir 				}
300cdf0e10cSrcweir 				break;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir 			case FID_SCALE:
303cdf0e10cSrcweir 			case SID_ATTR_ZOOM:
304cdf0e10cSrcweir 				if ( bOle )
305cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
306cdf0e10cSrcweir 				else
307cdf0e10cSrcweir 				{
308cdf0e10cSrcweir 					const Fraction& rOldY = GetViewData()->GetZoomY();
309cdf0e10cSrcweir 					sal_uInt16 nZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 )
310cdf0e10cSrcweir 												/ rOldY.GetDenominator());
311cdf0e10cSrcweir 					rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) );
312cdf0e10cSrcweir 				}
313cdf0e10cSrcweir 				break;
314cdf0e10cSrcweir 
315cdf0e10cSrcweir             case SID_ATTR_ZOOMSLIDER:
316cdf0e10cSrcweir                 {
317cdf0e10cSrcweir                     if ( bOle )
318cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
319cdf0e10cSrcweir                     else
320cdf0e10cSrcweir                     {
321cdf0e10cSrcweir                         const Fraction& rOldY = GetViewData()->GetZoomY();
322cdf0e10cSrcweir                         sal_uInt16 nCurrentZoom = (sal_uInt16)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
323cdf0e10cSrcweir 
324cdf0e10cSrcweir                         if( nCurrentZoom )
325cdf0e10cSrcweir                         {
326cdf0e10cSrcweir                             SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
327cdf0e10cSrcweir                             aZoomSliderItem.AddSnappingPoint( 100 );
328cdf0e10cSrcweir                             rSet.Put( aZoomSliderItem );
329cdf0e10cSrcweir                         }
330cdf0e10cSrcweir                     }
331cdf0e10cSrcweir                 }
332cdf0e10cSrcweir                 break;
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 			case FID_TOGGLESYNTAX:
335cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode()));
336cdf0e10cSrcweir 				break;
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 			case FID_TOGGLEHEADERS:
339cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode()));
340cdf0e10cSrcweir 				break;
341cdf0e10cSrcweir 
342cdf0e10cSrcweir             case FID_TOGGLEFORMULA:
343cdf0e10cSrcweir                 {
344cdf0e10cSrcweir                     const ScViewOptions& rOpts = pViewData->GetOptions();
345cdf0e10cSrcweir                     sal_Bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
346cdf0e10cSrcweir                     rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
347cdf0e10cSrcweir                 }
348cdf0e10cSrcweir                 break;
349cdf0e10cSrcweir 
350cdf0e10cSrcweir             case FID_NORMALVIEWMODE:
351cdf0e10cSrcweir 			case FID_PAGEBREAKMODE:
352cdf0e10cSrcweir                 // always handle both slots - they exclude each other
353cdf0e10cSrcweir 				if ( bOle )
354cdf0e10cSrcweir                 {
355cdf0e10cSrcweir                     rSet.DisableItem( FID_NORMALVIEWMODE );
356cdf0e10cSrcweir                     rSet.DisableItem( FID_PAGEBREAKMODE );
357cdf0e10cSrcweir                 }
358cdf0e10cSrcweir 				else
359cdf0e10cSrcweir                 {
360cdf0e10cSrcweir                     rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData()->IsPagebreakMode()));
361cdf0e10cSrcweir                     rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData()->IsPagebreakMode()));
362cdf0e10cSrcweir                 }
363cdf0e10cSrcweir 				break;
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 			case FID_FUNCTION_BOX:
366cdf0e10cSrcweir 				nMyId = ScFunctionChildWindow::GetChildWindowId();
367cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId)));
368cdf0e10cSrcweir 				break;
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 			case FID_PROTECT_DOC:
371cdf0e10cSrcweir                 {
372cdf0e10cSrcweir                     if ( pDocShell && pDocShell->IsDocShared() )
373cdf0e10cSrcweir                     {
374cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
375cdf0e10cSrcweir                     }
376cdf0e10cSrcweir                     else
377cdf0e10cSrcweir                     {
378cdf0e10cSrcweir                         rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) );
379cdf0e10cSrcweir                     }
380cdf0e10cSrcweir                 }
381cdf0e10cSrcweir 				break;
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 			case FID_PROTECT_TABLE:
384cdf0e10cSrcweir                 {
385cdf0e10cSrcweir                     if ( pDocShell && pDocShell->IsDocShared() )
386cdf0e10cSrcweir                     {
387cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
388cdf0e10cSrcweir                     }
389cdf0e10cSrcweir                     else
390cdf0e10cSrcweir                     {
391cdf0e10cSrcweir                         rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) );
392cdf0e10cSrcweir                     }
393cdf0e10cSrcweir                 }
394cdf0e10cSrcweir 				break;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 			case SID_AUTO_OUTLINE:
397cdf0e10cSrcweir 				{
398cdf0e10cSrcweir 					if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
399cdf0e10cSrcweir 					{
400cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
401cdf0e10cSrcweir 					}
402cdf0e10cSrcweir 				}
403cdf0e10cSrcweir 				break;
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 			case SID_OUTLINE_DELETEALL:
406cdf0e10cSrcweir 				{
407cdf0e10cSrcweir 					SCTAB nOlTab = GetViewData()->GetTabNo();
408cdf0e10cSrcweir 					ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab );
409cdf0e10cSrcweir 					if (pOlTable == NULL)
410cdf0e10cSrcweir 						rSet.DisableItem( nWhich );
411cdf0e10cSrcweir 				}
412cdf0e10cSrcweir 				break;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 			case SID_WINDOW_SPLIT:
415cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich,
416cdf0e10cSrcweir 							pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
417cdf0e10cSrcweir 							pViewData->GetVSplitMode() == SC_SPLIT_NORMAL ));
418cdf0e10cSrcweir 				break;
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 			case SID_WINDOW_FIX:
421cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich,
422cdf0e10cSrcweir 							pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
423cdf0e10cSrcweir 							pViewData->GetVSplitMode() == SC_SPLIT_FIX ));
424cdf0e10cSrcweir 				break;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 			case FID_CHG_SHOW:
427cdf0e10cSrcweir 				{
428cdf0e10cSrcweir                     if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) )
429cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
430cdf0e10cSrcweir 				}
431cdf0e10cSrcweir 				break;
432cdf0e10cSrcweir 			case FID_CHG_ACCEPT:
433cdf0e10cSrcweir 				{
434cdf0e10cSrcweir 					rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
435cdf0e10cSrcweir 							pThisFrame->HasChildWindow(FID_CHG_ACCEPT)));
436cdf0e10cSrcweir 					if(pDoc->GetChangeTrack()==NULL)
437cdf0e10cSrcweir 					{
438cdf0e10cSrcweir 						if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
439cdf0e10cSrcweir 						{
440cdf0e10cSrcweir 							rSet.DisableItem( nWhich);
441cdf0e10cSrcweir 						}
442cdf0e10cSrcweir 					}
443cdf0e10cSrcweir                     if ( pDocShell && pDocShell->IsDocShared() )
444cdf0e10cSrcweir                     {
445cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
446cdf0e10cSrcweir                     }
447cdf0e10cSrcweir 				}
448cdf0e10cSrcweir 				break;
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 			case SID_FORMATPAGE:
451cdf0e10cSrcweir 				//!	bei geschuetzten Tabellen ???
452cdf0e10cSrcweir                 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
453cdf0e10cSrcweir 					rSet.DisableItem( nWhich );
454cdf0e10cSrcweir 				break;
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 			case SID_PRINTPREVIEW:
457cdf0e10cSrcweir 				// #58924# Toggle-Slot braucht einen State
458cdf0e10cSrcweir 				rSet.Put( SfxBoolItem( nWhich, sal_False ) );
459cdf0e10cSrcweir 				break;
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 			case SID_READONLY_MODE:
462cdf0e10cSrcweir 				rSet.Put( SfxBoolItem( nWhich, GetViewData()->GetDocShell()->IsReadOnly() ) );
463cdf0e10cSrcweir 				break;
464cdf0e10cSrcweir 
465cdf0e10cSrcweir             case FID_TAB_DESELECTALL:
466cdf0e10cSrcweir                 if ( nTabSelCount == 1 )
467cdf0e10cSrcweir                     rSet.DisableItem( nWhich );     // enabled only if several sheets are selected
468cdf0e10cSrcweir                 break;
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 		} // switch ( nWitch )
471cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
472cdf0e10cSrcweir 	} // while ( nWitch )
473cdf0e10cSrcweir }
474cdf0e10cSrcweir 
475cdf0e10cSrcweir //------------------------------------------------------------------
476cdf0e10cSrcweir void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest& rReq, sal_uInt16 nTabPage )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir 	//CHINA001 ScAttrDlg*				pDlg	= NULL;
479cdf0e10cSrcweir 	SfxAbstractTabDialog * pDlg	= NULL; //CHINA001
480cdf0e10cSrcweir 	ScDocument* 			pDoc	= GetViewData()->GetDocument();
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 	SvxBoxItem				aLineOuter( ATTR_BORDER );
483cdf0e10cSrcweir 	SvxBoxInfoItem			aLineInner( ATTR_BORDER_INNER );
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	SvxNumberInfoItem*		pNumberInfoItem = NULL;
486cdf0e10cSrcweir 	const ScPatternAttr*	pOldAttrs		= GetSelectionPattern();
487cdf0e10cSrcweir 	SfxItemSet* 			pOldSet 		= new SfxItemSet(
488cdf0e10cSrcweir 													pOldAttrs->GetItemSet() );
489cdf0e10cSrcweir 
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 	// Umrandungs-Items holen und in den Set packen:
492cdf0e10cSrcweir 	GetSelectionFrame( aLineOuter, aLineInner );
493cdf0e10cSrcweir 	pOldSet->Put( aLineOuter );
494cdf0e10cSrcweir 	pOldSet->Put( aLineInner );
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 	// NumberFormat Value aus Value und Language erzeugen und eintueten
497cdf0e10cSrcweir 	pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
498cdf0e10cSrcweir 		pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 	MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 	pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
503cdf0e10cSrcweir 	pOldSet->Put(*pNumberInfoItem );
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 	bInFormatDialog = sal_True;
506cdf0e10cSrcweir 	//CHINA001 pDlg = new ScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet );
507cdf0e10cSrcweir 	ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
508cdf0e10cSrcweir 	DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 	pDlg = pFact->CreateScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet, RID_SCDLG_ATTR);
511cdf0e10cSrcweir 	DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
512cdf0e10cSrcweir 	if ( nTabPage != 0xffff )
513cdf0e10cSrcweir 		pDlg->SetCurPageId( nTabPage );
514cdf0e10cSrcweir 	short nResult = pDlg->Execute();
515cdf0e10cSrcweir 	bInFormatDialog = sal_False;
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 	if ( nResult == RET_OK )
518cdf0e10cSrcweir 	{
519cdf0e10cSrcweir 		const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 		const SfxPoolItem* pItem=NULL;
522cdf0e10cSrcweir 		if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,sal_True,&pItem)==SFX_ITEM_SET)
523cdf0e10cSrcweir 		{
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 			UpdateNumberFormatter( pDoc,(const SvxNumberInfoItem&)*pItem);
526cdf0e10cSrcweir 		}
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 		ApplyAttributes( pOutSet, pOldSet );
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 		rReq.Done( *pOutSet );
531cdf0e10cSrcweir 	}
532cdf0e10cSrcweir 	delete pOldSet;
533cdf0e10cSrcweir 	delete pNumberInfoItem;
534cdf0e10cSrcweir 	delete pDlg;
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir //------------------------------------------------------------------
538cdf0e10cSrcweir 
539cdf0e10cSrcweir bool ScTabViewShell::IsRefInputMode() const
540cdf0e10cSrcweir {
541cdf0e10cSrcweir     ScModule* pScMod = SC_MOD();
542cdf0e10cSrcweir     if ( pScMod )
543cdf0e10cSrcweir     {
544cdf0e10cSrcweir         if( pScMod->IsRefDialogOpen() )
545cdf0e10cSrcweir             return pScMod->IsFormulaMode();
546cdf0e10cSrcweir         if( pScMod->IsFormulaMode() )
547cdf0e10cSrcweir         {
548cdf0e10cSrcweir             ScInputHandler* pHdl = pScMod->GetInputHdl();
549cdf0e10cSrcweir             if ( pHdl )
550cdf0e10cSrcweir             {
551cdf0e10cSrcweir                 String aString = pHdl->GetEditString();
552cdf0e10cSrcweir                 if ( !pHdl->GetSelIsRef() && aString.Len() > 1 &&
553cdf0e10cSrcweir                      ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
554cdf0e10cSrcweir                 {
555cdf0e10cSrcweir                     const ScViewData* pViewData = GetViewData();
556cdf0e10cSrcweir                     if ( pViewData )
557cdf0e10cSrcweir                     {
558cdf0e10cSrcweir                         ScDocument* pDoc = pViewData->GetDocument();
559cdf0e10cSrcweir                         if ( pDoc )
560cdf0e10cSrcweir                         {
561cdf0e10cSrcweir                             const ScAddress aPos( pViewData->GetCurPos() );
562cdf0e10cSrcweir                             ScCompiler aComp( pDoc, aPos );
563cdf0e10cSrcweir                             aComp.SetGrammar(pDoc->GetGrammar());
564cdf0e10cSrcweir                             aComp.SetCloseBrackets( false );
565cdf0e10cSrcweir                             ScTokenArray* pArr = aComp.CompileString( aString );
566cdf0e10cSrcweir                             if ( pArr && pArr->MayReferenceFollow() )
567cdf0e10cSrcweir                             {
568cdf0e10cSrcweir                                 return true;
569cdf0e10cSrcweir                             }
570cdf0e10cSrcweir                         }
571cdf0e10cSrcweir                     }
572cdf0e10cSrcweir                 }
573cdf0e10cSrcweir                 else
574cdf0e10cSrcweir                 {
575cdf0e10cSrcweir                     return true;
576cdf0e10cSrcweir                 }
577cdf0e10cSrcweir             }
578cdf0e10cSrcweir         }
579cdf0e10cSrcweir     }
580cdf0e10cSrcweir 
581cdf0e10cSrcweir     return false;
582cdf0e10cSrcweir }
583cdf0e10cSrcweir 
584cdf0e10cSrcweir //------------------------------------------------------------------
585cdf0e10cSrcweir 
586cdf0e10cSrcweir void ScTabViewShell::ExecuteInputDirect()
587cdf0e10cSrcweir {
588cdf0e10cSrcweir     if ( !IsRefInputMode() )
589cdf0e10cSrcweir     {
590cdf0e10cSrcweir         ScModule* pScMod = SC_MOD();
591cdf0e10cSrcweir         if ( pScMod )
592cdf0e10cSrcweir         {
593cdf0e10cSrcweir             pScMod->InputEnterHandler();
594cdf0e10cSrcweir         }
595cdf0e10cSrcweir     }
596cdf0e10cSrcweir }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir //------------------------------------------------------------------
599cdf0e10cSrcweir 
600cdf0e10cSrcweir void ScTabViewShell::UpdateInputHandler( sal_Bool bForce /* = sal_False */, sal_Bool bStopEditing /* = sal_True */ )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir 	ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl();
603cdf0e10cSrcweir 
604cdf0e10cSrcweir 	if ( pHdl )
605cdf0e10cSrcweir 	{
606cdf0e10cSrcweir 		String					aString;
607cdf0e10cSrcweir 		const EditTextObject*	pObject 	= NULL;
608cdf0e10cSrcweir 		ScViewData*				pViewData	= GetViewData();
609cdf0e10cSrcweir 		ScDocument*				pDoc		= pViewData->GetDocument();
610cdf0e10cSrcweir 		CellType				eType;
611cdf0e10cSrcweir 		SCCOL					nPosX		= pViewData->GetCurX();
612cdf0e10cSrcweir 		SCROW					nPosY		= pViewData->GetCurY();
613cdf0e10cSrcweir 		SCTAB					nTab		= pViewData->GetTabNo();
614cdf0e10cSrcweir 		SCTAB					nStartTab	= 0;
615cdf0e10cSrcweir 		SCTAB					nEndTab 	= 0;
616cdf0e10cSrcweir 		SCCOL					nStartCol	= 0;
617cdf0e10cSrcweir 		SCROW					nStartRow	= 0;
618cdf0e10cSrcweir 		SCCOL					nEndCol 	= 0;
619cdf0e10cSrcweir 		SCROW					nEndRow 	= 0;
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 		pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
622cdf0e10cSrcweir 								  nEndCol,   nEndRow,   nEndTab );
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 		PutInOrder( nStartCol, nEndCol );
625cdf0e10cSrcweir 		PutInOrder( nStartRow, nEndRow );
626cdf0e10cSrcweir 		PutInOrder( nStartTab, nEndTab );
627cdf0e10cSrcweir 
628cdf0e10cSrcweir 		sal_Bool bHideFormula = sal_False;
629cdf0e10cSrcweir 		sal_Bool bHideAll	  = sal_False;
630cdf0e10cSrcweir 
631cdf0e10cSrcweir 		if (pDoc->IsTabProtected(nTab))
632cdf0e10cSrcweir 		{
633cdf0e10cSrcweir 			const ScProtectionAttr* pProt = (const ScProtectionAttr*)
634cdf0e10cSrcweir 											pDoc->GetAttr( nPosX,nPosY,nTab,
635cdf0e10cSrcweir 														   ATTR_PROTECTION);
636cdf0e10cSrcweir 			bHideFormula = pProt->GetHideFormula();
637cdf0e10cSrcweir 			bHideAll	 = pProt->GetHideCell();
638cdf0e10cSrcweir 		}
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 		if (!bHideAll)
641cdf0e10cSrcweir 		{
642cdf0e10cSrcweir 			pDoc->GetCellType( nPosX, nPosY, nTab, eType );
643cdf0e10cSrcweir 			if (eType == CELLTYPE_FORMULA)
644cdf0e10cSrcweir 			{
645cdf0e10cSrcweir 				if (!bHideFormula)
646cdf0e10cSrcweir 					pDoc->GetFormula( nPosX, nPosY, nTab, aString );
647cdf0e10cSrcweir 			}
648cdf0e10cSrcweir 			else if (eType == CELLTYPE_EDIT)
649cdf0e10cSrcweir 			{
650cdf0e10cSrcweir 				ScBaseCell* pCell;
651cdf0e10cSrcweir 				pDoc->GetCell( nPosX, nPosY, nTab, pCell );
652cdf0e10cSrcweir 				((ScEditCell*)pCell)->GetData( pObject );
653cdf0e10cSrcweir 			}
654cdf0e10cSrcweir 			else
655cdf0e10cSrcweir 			{
656cdf0e10cSrcweir 				pDoc->GetInputString( nPosX, nPosY, nTab, aString );
657cdf0e10cSrcweir 				if (eType == CELLTYPE_STRING)
658cdf0e10cSrcweir 				{
659cdf0e10cSrcweir 					//	Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
660cdf0e10cSrcweir 					//	als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
661cdf0e10cSrcweir 					//	dass es ein String ist (#35060#).
662cdf0e10cSrcweir 					//!	Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 					SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
665cdf0e10cSrcweir 					sal_uInt32 nNumFmt;
666cdf0e10cSrcweir 					pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
667cdf0e10cSrcweir 					double fDummy;
668cdf0e10cSrcweir 					if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) )
669cdf0e10cSrcweir 						aString.Insert('\'',0);
670cdf0e10cSrcweir 				}
671cdf0e10cSrcweir 			}
672cdf0e10cSrcweir 		}
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 		ScInputHdlState	aState( ScAddress( nPosX,	  nPosY, 	 nTab ),
675cdf0e10cSrcweir 								ScAddress( nStartCol, nStartRow, nTab ),
676cdf0e10cSrcweir 								ScAddress( nEndCol,	  nEndRow,   nTab ),
677cdf0e10cSrcweir 								aString,
678cdf0e10cSrcweir 								pObject );
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 		//	if using the view's local input handler, this view can always be set
681cdf0e10cSrcweir 		//	as current view inside NotifyChange.
682cdf0e10cSrcweir 		ScTabViewShell* pSourceSh = pInputHandler ? this : NULL;
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 		pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
685cdf0e10cSrcweir 	}
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 	SfxBindings& rBindings = GetViewFrame()->GetBindings();
688cdf0e10cSrcweir 	rBindings.Invalidate( SID_STATUS_SUM );			// immer zusammen mit Eingabezeile
689cdf0e10cSrcweir 	rBindings.Invalidate( SID_ATTR_SIZE );
690cdf0e10cSrcweir     rBindings.Invalidate( SID_TABLE_CELL );
691cdf0e10cSrcweir }
692cdf0e10cSrcweir 
693cdf0e10cSrcweir void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir     if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() )
696cdf0e10cSrcweir         pHdl->UpdateCellAdjust( eJust );
697cdf0e10cSrcweir }
698cdf0e10cSrcweir 
699cdf0e10cSrcweir //------------------------------------------------------------------
700cdf0e10cSrcweir 
701cdf0e10cSrcweir void __EXPORT ScTabViewShell::ExecuteSave( SfxRequest& rReq )
702cdf0e10cSrcweir {
703cdf0e10cSrcweir 	//	nur SID_SAVEDOC / SID_SAVEASDOC
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 	// Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird
706cdf0e10cSrcweir 	SC_MOD()->InputEnterHandler();
707cdf0e10cSrcweir 
708cdf0e10cSrcweir     if ( GetViewData()->GetDocShell()->IsDocShared() )
709cdf0e10cSrcweir     {
710cdf0e10cSrcweir         GetViewData()->GetDocShell()->SetDocumentModified();
711cdf0e10cSrcweir     }
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 	// ansonsten normal weiter
714cdf0e10cSrcweir 	GetViewData()->GetDocShell()->ExecuteSlot( rReq );
715cdf0e10cSrcweir }
716cdf0e10cSrcweir 
717cdf0e10cSrcweir void __EXPORT ScTabViewShell::GetSaveState( SfxItemSet& rSet )
718cdf0e10cSrcweir {
719cdf0e10cSrcweir 	SfxShell* pDocSh = GetViewData()->GetDocShell();
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
722cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
723cdf0e10cSrcweir 	while( nWhich )
724cdf0e10cSrcweir 	{
725cdf0e10cSrcweir         if ( nWhich != SID_SAVEDOC || !GetViewData()->GetDocShell()->IsDocShared() )
726cdf0e10cSrcweir         {
727cdf0e10cSrcweir             // get state from DocShell
728cdf0e10cSrcweir             pDocSh->GetSlotState( nWhich, NULL, &rSet );
729cdf0e10cSrcweir         }
730cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
731cdf0e10cSrcweir 	}
732cdf0e10cSrcweir }
733cdf0e10cSrcweir 
734cdf0e10cSrcweir //------------------------------------------------------------------
735cdf0e10cSrcweir 
736cdf0e10cSrcweir void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq )
737cdf0e10cSrcweir {
738cdf0e10cSrcweir 	ScViewOptions aViewOptions = GetViewData()->GetOptions();
739cdf0e10cSrcweir 	ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
740cdf0e10cSrcweir 
741cdf0e10cSrcweir 	SfxBindings& rBindings = GetViewFrame()->GetBindings();
742cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
743cdf0e10cSrcweir 	const SfxPoolItem* pItem;
744cdf0e10cSrcweir 	sal_uInt16 nSlotId = rReq.GetSlot();
745cdf0e10cSrcweir 	switch (nSlotId)
746cdf0e10cSrcweir 	{
747cdf0e10cSrcweir 		case SID_GRID_VISIBLE:
748cdf0e10cSrcweir 			if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
749cdf0e10cSrcweir 			{
750cdf0e10cSrcweir 				aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() );
751cdf0e10cSrcweir 				aViewOptions.SetGridOptions(aGridOptions);
752cdf0e10cSrcweir 				rBindings.Invalidate(SID_GRID_VISIBLE);
753cdf0e10cSrcweir 			}
754cdf0e10cSrcweir 			break;
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 		case SID_GRID_USE:
757cdf0e10cSrcweir 			if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
758cdf0e10cSrcweir 			{
759cdf0e10cSrcweir 				aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() );
760cdf0e10cSrcweir 				aViewOptions.SetGridOptions(aGridOptions);
761cdf0e10cSrcweir 				rBindings.Invalidate(SID_GRID_USE);
762cdf0e10cSrcweir 			}
763cdf0e10cSrcweir 			break;
764cdf0e10cSrcweir 
765cdf0e10cSrcweir 		case SID_HELPLINES_MOVE:
766cdf0e10cSrcweir 			if ( pArgs && pArgs->GetItemState(nSlotId,sal_True,&pItem) == SFX_ITEM_SET )
767cdf0e10cSrcweir 			{
768cdf0e10cSrcweir 				aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() );
769cdf0e10cSrcweir 				rBindings.Invalidate(SID_HELPLINES_MOVE);
770cdf0e10cSrcweir 			}
771cdf0e10cSrcweir 			break;
772cdf0e10cSrcweir 	}
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 	GetViewData()->SetOptions(aViewOptions);
775cdf0e10cSrcweir }
776cdf0e10cSrcweir 
777cdf0e10cSrcweir void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet )
778cdf0e10cSrcweir {
779cdf0e10cSrcweir 	SfxBoolItem aBool;
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 	const ScViewOptions& rViewOptions = GetViewData()->GetOptions();
782cdf0e10cSrcweir 	const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
783cdf0e10cSrcweir 
784cdf0e10cSrcweir 	aBool.SetValue(rGridOptions.GetGridVisible());
785cdf0e10cSrcweir 	aBool.SetWhich( SID_GRID_VISIBLE );
786cdf0e10cSrcweir 	rSet.Put( aBool );
787cdf0e10cSrcweir 
788cdf0e10cSrcweir 	aBool.SetValue(rGridOptions.GetUseGridSnap());
789cdf0e10cSrcweir 	aBool.SetWhich( SID_GRID_USE );
790cdf0e10cSrcweir 	rSet.Put( aBool );
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 	aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
793cdf0e10cSrcweir 	aBool.SetWhich( SID_HELPLINES_MOVE );
794cdf0e10cSrcweir 	rSet.Put( aBool );
795cdf0e10cSrcweir }
796cdf0e10cSrcweir 
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 
800