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