1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "scitems.hxx"
21 #include <editeng/eeitem.hxx>
23 #include <sfx2/app.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <sfx2/dispatch.hxx>
26 #include <sfx2/passwd.hxx>
27 #include <sfx2/request.hxx>
28 #include <svl/ptitem.hxx>
29 #include <svl/stritem.hxx>
30 #include <tools/urlobj.hxx>
31 #include <sfx2/objface.hxx>
32 #include <vcl/msgbox.hxx>
33 #include <vcl/vclenum.hxx>
35 #include "globstr.hrc"
37 #include "appoptio.hxx"
38 #include "tabvwsh.hxx"
39 #include "document.hxx"
41 #include "inputwin.hxx"
42 #include "scresid.hxx"
43 #include "printfun.hxx"
45 #include "rangelst.hxx"
46 #include "prevwsh.hxx"
47 #include "rangeutl.hxx"
48 #include "reffact.hxx"
49 #include "uiitems.hxx"
50 #include "formulacell.hxx"
51 #include "inputhdl.hxx"
52 #include "autoform.hxx"
53 #include "autofmt.hxx"
54 #include "dwfunctr.hxx"
55 #include "shtabdlg.hxx"
56 #include "tabprotection.hxx"
57 #include "protectiondlg.hxx"
58 #include "markdata.hxx"
60 #include <svl/ilstitem.hxx>
63 #include <svx/zoomslideritem.hxx>
64 #include <svx/svxdlg.hxx>
65 #include <svx/dialogs.hrc>
66 #include <comphelper/string.hxx>
67 #include "scabstdlg.hxx"
71 using ::std::auto_ptr
;
73 //------------------------------------------------------------------
75 /** Try to parse the given range using Calc-style syntax first, then
76 Excel-style if that fails. */
77 static sal_uInt16
lcl_ParseRange(ScRange
& rScRange
, const OUString
& aAddress
, ScDocument
* pDoc
, sal_uInt16
/* nSlot */)
79 sal_uInt16 nResult
= rScRange
.Parse(aAddress
, pDoc
);
80 if ( (nResult
& SCA_VALID
) )
83 return rScRange
.Parse(aAddress
, pDoc
, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1
, 0, 0));
86 /** Try to parse the given address using Calc-style syntax first, then
87 Excel-style if that fails. */
88 static sal_uInt16
lcl_ParseAddress(ScAddress
& rScAddress
, const OUString
& aAddress
, ScDocument
* pDoc
, sal_uInt16
/* nSlot */)
90 sal_uInt16 nResult
= rScAddress
.Parse(aAddress
, pDoc
);
91 if ( (nResult
& SCA_VALID
) )
94 return rScAddress
.Parse(aAddress
, pDoc
, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1
, 0, 0));
97 void ScTabViewShell::Execute( SfxRequest
& rReq
)
99 SfxViewFrame
* pThisFrame
= GetViewFrame();
100 SfxBindings
& rBindings
= pThisFrame
->GetBindings();
101 ScModule
* pScMod
= SC_MOD();
102 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
103 sal_uInt16 nSlot
= rReq
.GetSlot();
105 if (nSlot
!= SID_CURRENTCELL
) // der kommt beim MouseButtonUp
106 HideListBox(); // Autofilter-DropDown-Listbox
110 case FID_INSERT_FILE
:
112 const SfxPoolItem
* pItem
;
114 pReqArgs
->GetItemState(FID_INSERT_FILE
,sal_True
,&pItem
) == SFX_ITEM_SET
)
116 OUString aFileName
= ((const SfxStringItem
*)pItem
)->GetValue();
121 if ( pReqArgs
->GetItemState(FN_PARAM_1
,sal_True
,&pItem
) == SFX_ITEM_SET
)
122 aInsertPos
= ((const SfxPointItem
*)pItem
)->GetValue();
124 aInsertPos
= GetInsertPos();
128 sal_Bool bAsLink
= false;
129 if ( pReqArgs
->GetItemState(FN_PARAM_2
,sal_True
,&pItem
) == SFX_ITEM_SET
)
130 bAsLink
= ((const SfxBoolItem
*)pItem
)->GetValue();
134 PasteFile( aInsertPos
, aFileName
, bAsLink
);
139 case SID_OPENDLG_EDIT_PRINTAREA
:
141 sal_uInt16 nId
= ScPrintAreasDlgWrapper::GetChildWindowId();
142 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
144 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
148 case SID_CHANGE_PRINTAREA
:
150 if ( pReqArgs
) // OK aus Dialog
155 sal_Bool bEntire
= false;
156 const SfxPoolItem
* pItem
;
157 if ( pReqArgs
->GetItemState( SID_CHANGE_PRINTAREA
, sal_True
, &pItem
) == SFX_ITEM_SET
)
158 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
159 if ( pReqArgs
->GetItemState( FN_PARAM_2
, sal_True
, &pItem
) == SFX_ITEM_SET
)
160 aRowStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
161 if ( pReqArgs
->GetItemState( FN_PARAM_3
, sal_True
, &pItem
) == SFX_ITEM_SET
)
162 aColStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
163 if ( pReqArgs
->GetItemState( FN_PARAM_4
, sal_True
, &pItem
) == SFX_ITEM_SET
)
164 bEntire
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
166 SetPrintRanges( bEntire
, &aPrintStr
, &aColStr
, &aRowStr
, false );
173 case SID_ADD_PRINTAREA
:
174 case SID_DEFINE_PRINTAREA
: // Menue oder Basic
176 sal_Bool bAdd
= ( nSlot
== SID_ADD_PRINTAREA
);
180 const SfxPoolItem
* pItem
;
181 if ( pReqArgs
->GetItemState( SID_DEFINE_PRINTAREA
, sal_True
, &pItem
) == SFX_ITEM_SET
)
182 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
183 SetPrintRanges( false, &aPrintStr
, NULL
, NULL
, bAdd
);
187 SetPrintRanges( false, NULL
, NULL
, NULL
, bAdd
); // aus Selektion
193 case SID_DELETE_PRINTAREA
:
196 SetPrintRanges( false, &aEmpty
, NULL
, NULL
, false ); // Druckbereich loeschen
201 case FID_DEL_MANUALBREAKS
:
202 RemoveManualBreaks();
206 case FID_ADJUST_PRINTZOOM
:
211 case FID_RESET_PRINTZOOM
:
212 SetPrintZoom( 100, 0 ); // 100%, nicht auf Seiten
217 case SID_STATUS_PAGESTYLE
:
219 GetViewData()->GetDocShell()->
220 ExecutePageStyle( *this, rReq
, GetViewData()->GetTabNo() );
224 case SID_CURRENTCELL
:
228 const SfxPoolItem
* pItem
;
229 if ( pReqArgs
->GetItemState( nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
)
230 aAddress
= ((const SfxStringItem
*)pItem
)->GetValue();
231 else if ( nSlot
== SID_JUMPTOMARK
&& pReqArgs
->GetItemState(
232 SID_JUMPTOMARK
, sal_True
, &pItem
) == SFX_ITEM_SET
)
233 aAddress
= ((const SfxStringItem
*)pItem
)->GetValue();
235 // #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
236 // isn't set (for recorded macros, because IsAPI is no longer available).
237 // ScGridWindow::MouseButtonUp no longer executes the slot for a single
238 // cell if there is a multi selection.
239 sal_Bool bUnmark
= ( nSlot
== SID_CURRENTCELL
);
240 if ( pReqArgs
->GetItemState( FN_PARAM_1
, sal_True
, &pItem
) == SFX_ITEM_SET
)
241 bUnmark
= ((const SfxBoolItem
*)pItem
)->GetValue();
243 bool bAlignToCursor
= true;
244 if (pReqArgs
->GetItemState(FN_PARAM_2
, true, &pItem
) == SFX_ITEM_SET
)
245 bAlignToCursor
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
247 if ( nSlot
== SID_JUMPTOMARK
)
249 // URL has to be decoded for escaped characters (%20)
250 aAddress
= INetURLObject::decode( aAddress
, INET_HEX_ESCAPE
,
251 INetURLObject::DECODE_WITH_CHARSET
,
252 RTL_TEXTENCODING_UTF8
);
255 sal_Bool bFound
= false;
256 ScViewData
* pViewData
= GetViewData();
257 ScDocument
* pDoc
= pViewData
->GetDocument();
258 ScMarkData
& rMark
= pViewData
->GetMarkData();
260 ScAddress aScAddress
;
261 sal_uInt16 nResult
= lcl_ParseRange(aScRange
, aAddress
, pDoc
, nSlot
);
262 SCTAB nTab
= pViewData
->GetTabNo();
263 sal_Bool bMark
= sal_True
;
266 if( nResult
& SCA_VALID
)
268 if ( nResult
& SCA_TAB_3D
)
270 if( aScRange
.aStart
.Tab() != nTab
)
271 SetTabNo( nTab
= aScRange
.aStart
.Tab() );
275 aScRange
.aStart
.SetTab( nTab
);
276 aScRange
.aEnd
.SetTab( nTab
);
280 else if ( (nResult
= lcl_ParseAddress(aScAddress
, aAddress
, pDoc
, nSlot
)) & SCA_VALID
)
282 if ( nResult
& SCA_TAB_3D
)
284 if( aScAddress
.Tab() != nTab
)
285 SetTabNo( nTab
= aScAddress
.Tab() );
288 aScAddress
.SetTab( nTab
);
290 aScRange
= ScRange( aScAddress
, aScAddress
);
291 // Zellen sollen nicht markiert werden
294 // Ist es benahmster Bereich (erst Namen dann DBBereiche) ?
297 ScRangeUtil aRangeUtil
;
298 formula::FormulaGrammar::AddressConvention eConv
= pDoc
->GetAddressConvention();
299 if( aRangeUtil
.MakeRangeFromName( aAddress
, pDoc
, nTab
, aScRange
, RUTL_NAMES
, eConv
) ||
300 aRangeUtil
.MakeRangeFromName( aAddress
, pDoc
, nTab
, aScRange
, RUTL_DBASE
, eConv
) )
302 nResult
|= SCA_VALID
;
303 if( aScRange
.aStart
.Tab() != nTab
)
304 SetTabNo( nTab
= aScRange
.aStart
.Tab() );
308 if ( !(nResult
& SCA_VALID
) && comphelper::string::isdigitAsciiString(aAddress
) )
310 sal_Int32 nNumeric
= aAddress
.toInt32();
311 if ( nNumeric
> 0 && nNumeric
<= MAXROW
+1 )
313 // 1-basierte Zeilennummer
315 aScAddress
.SetRow( (SCROW
)(nNumeric
- 1) );
316 aScAddress
.SetCol( pViewData
->GetCurX() );
317 aScAddress
.SetTab( nTab
);
318 aScRange
= ScRange( aScAddress
, aScAddress
);
324 if ( !ValidRow(aScRange
.aStart
.Row()) || !ValidRow(aScRange
.aEnd
.Row()) )
327 // wir haben was gefunden
328 if( nResult
& SCA_VALID
)
331 SCCOL nCol
= aScRange
.aStart
.Col();
332 SCROW nRow
= aScRange
.aStart
.Row();
333 sal_Bool bNothing
= ( pViewData
->GetCurX()==nCol
&& pViewData
->GetCurY()==nRow
);
338 if (rMark
.IsMarked()) // ist derselbe Bereich schon markiert?
341 rMark
.GetMarkArea( aOldMark
);
343 ScRange aCurrent
= aScRange
;
345 bNothing
= ( aCurrent
== aOldMark
);
351 MarkRange( aScRange
, false ); // Cursor kommt hinterher...
355 // remove old selection, unless bUnmark argument is sal_False (from navigator)
358 MoveCursorAbs( nCol
, nRow
,
359 SC_FOLLOW_NONE
, false, false );
365 // zusammengefasste Zellen beruecksichtigen:
366 pDoc
->SkipOverlapped(nCol
, nRow
, nTab
);
368 // Navigator-Aufrufe sind nicht API!!!
373 rReq
.Ignore(); // wenn Makro, dann gar nix
375 rReq
.Done(); // sonst wenigstens aufzeichnen
379 pViewData
->ResetOldCursor();
380 SetCursor( nCol
, nRow
);
381 rBindings
.Invalidate( SID_CURRENTCELL
);
382 rBindings
.Update( nSlot
);
390 // align to cursor even if the cursor position hasn't changed,
391 // because the cursor may be set outside the visible area.
392 AlignToCursor( nCol
, nRow
, SC_FOLLOW_JUMP
);
395 rReq
.SetReturnValue( SfxStringItem( SID_CURRENTCELL
, aAddress
) );
398 if (!bFound
) // kein gueltiger Bereich
400 // wenn es ein Tabellenname ist, umschalten (fuer Navigator/URL's)
403 if ( pDoc
->GetTable( aAddress
, nNameTab
) )
406 if ( nNameTab
!= nTab
)
407 SetTabNo( nNameTab
);
411 if ( !bFound
&& nSlot
== SID_JUMPTOMARK
)
413 // Grafik-Objekte probieren (nur bei URL's)
415 bFound
= SelectObject( aAddress
);
418 if (!bFound
&& !rReq
.IsAPI())
419 ErrorMessage( STR_ERR_INVALID_AREA
);
423 case SID_CURRENTOBJECT
:
426 OUString aName
= ((const SfxStringItem
&)pReqArgs
->Get(nSlot
)).GetValue();
427 SelectObject( aName
);
434 // Tabelle fuer Basic ist 1-basiert
435 SCTAB nTab
= ((const SfxUInt16Item
&)pReqArgs
->Get(nSlot
)).GetValue() - 1;
436 ScDocument
* pDoc
= GetViewData()->GetDocument();
437 if ( nTab
< pDoc
->GetTableCount() )
440 rBindings
.Update( nSlot
);
452 OUString
aStrDocName( ((const SfxStringItem
&)pReqArgs
->
453 Get(nSlot
)).GetValue() );
455 SfxViewFrame
* pViewFrame
= NULL
;
456 ScDocShell
* pDocSh
= (ScDocShell
*)SfxObjectShell::GetFirst();
457 sal_Bool bFound
= false;
459 // zu aktivierenden ViewFrame suchen
461 while ( pDocSh
&& !bFound
)
463 if ( pDocSh
->GetTitle() == aStrDocName
)
465 pViewFrame
= SfxViewFrame::GetFirst( pDocSh
);
466 bFound
= ( NULL
!= pViewFrame
);
469 pDocSh
= (ScDocShell
*)SfxObjectShell::GetNext( *pDocSh
);
473 pViewFrame
->GetFrame().Appear();
475 rReq
.Ignore();//XXX wird von SFX erledigt
478 case SID_ATTR_SIZE
://XXX ???
482 case SID_PRINTPREVIEW
:
484 if ( !pThisFrame
->GetFrame().IsInPlace() ) // nicht bei OLE
486 // print preview is now always in the same frame as the tab view
487 // -> always switch this frame back to normal view
488 // (ScPreviewShell ctor reads view data)
490 // #102785#; finish input
491 pScMod
->InputEnterHandler();
493 pThisFrame
->GetDispatcher()->Execute( SID_VIEWSHELL1
, SFX_CALLMODE_ASYNCHRON
);
495 // else Fehler (z.B. Ole)
499 case SID_DETECTIVE_DEL_ALL
:
504 // SID_TABLE_ACTIVATE und SID_MARKAREA werden von Basic aus an der versteckten
505 // View aufgerufen, um auf der sichtbaren View zu markieren/umzuschalten:
507 case SID_TABLE_ACTIVATE
:
508 OSL_FAIL("old slot SID_TABLE_ACTIVATE");
519 case FID_NORMALVIEWMODE
:
520 case FID_PAGEBREAKMODE
:
522 bool bWantPageBreak
= nSlot
== FID_PAGEBREAKMODE
;
524 // check whether there is an explicit argument, use it
525 const SfxPoolItem
* pItem
;
526 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
)
528 sal_Bool bItemValue
= ((const SfxBoolItem
*)pItem
)->GetValue();
529 bWantPageBreak
= (nSlot
== FID_PAGEBREAKMODE
) == bItemValue
;
532 if( GetViewData()->IsPagebreakMode() != bWantPageBreak
)
534 SetPagebreakMode( bWantPageBreak
);
535 UpdatePageBreakData();
536 SetCurSubShell( GetCurObjectSelectionType(), sal_True
);
540 rBindings
.Invalidate( nSlot
);
541 rReq
.AppendItem( SfxBoolItem( nSlot
, sal_True
) );
547 case FID_FUNCTION_BOX
:
549 sal_uInt16 nChildId
= ScFunctionChildWindow::GetChildWindowId();
550 if ( rReq
.GetArgs() )
551 pThisFrame
->SetChildWindow( nChildId
, ((const SfxBoolItem
&) (rReq
.GetArgs()->Get(FID_FUNCTION_BOX
))).GetValue());
554 pThisFrame
->ToggleChildWindow( nChildId
);
555 rReq
.AppendItem( SfxBoolItem( FID_FUNCTION_BOX
, pThisFrame
->HasChildWindow( nChildId
) ) );
558 GetViewFrame()->GetBindings().Invalidate(FID_FUNCTION_BOX
);
564 case FID_TOGGLESYNTAX
:
566 sal_Bool bSet
= !GetViewData()->IsSyntaxMode();
567 const SfxPoolItem
* pItem
;
568 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
)
569 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
570 GetViewData()->SetSyntaxMode( bSet
);
572 rBindings
.Invalidate( FID_TOGGLESYNTAX
);
573 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
577 case FID_TOGGLEHEADERS
:
579 sal_Bool bSet
= !GetViewData()->IsHeaderMode();
580 const SfxPoolItem
* pItem
;
581 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
)
582 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
583 GetViewData()->SetHeaderMode( bSet
);
585 rBindings
.Invalidate( FID_TOGGLEHEADERS
);
586 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
591 case FID_TOGGLEFORMULA
:
593 ScViewData
* pViewData
= GetViewData();
594 const ScViewOptions
& rOpts
= pViewData
->GetOptions();
595 sal_Bool bFormulaMode
= !rOpts
.GetOption( VOPT_FORMULAS
);
596 const SfxPoolItem
*pItem
;
597 if( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
)
598 bFormulaMode
= ((const SfxBoolItem
*)pItem
)->GetValue();
600 ScViewOptions rSetOpts
= ScViewOptions( rOpts
);
601 rSetOpts
.SetOption( VOPT_FORMULAS
, bFormulaMode
);
602 pViewData
->SetOptions( rSetOpts
);
604 pViewData
->GetDocShell()->PostPaintGridAll();
606 rBindings
.Invalidate( FID_TOGGLEFORMULA
);
607 rReq
.AppendItem( SfxBoolItem( nSlot
, bFormulaMode
) );
612 case FID_TOGGLEINPUTLINE
:
614 sal_uInt16 nId
= ScInputWindowWrapper::GetChildWindowId();
615 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
616 sal_Bool bSet
= ( pWnd
== NULL
);
617 const SfxPoolItem
* pItem
;
618 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
)
619 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
621 pThisFrame
->SetChildWindow( nId
, bSet
);
622 rBindings
.Invalidate( FID_TOGGLEINPUTLINE
);
623 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
628 case SID_ATTR_ZOOM
: // Statuszeile
631 sal_Bool bSyncZoom
= SC_MOD()->GetAppOptions().GetSynchronizeZoom();
632 SvxZoomType eOldZoomType
= GetZoomType();
633 SvxZoomType eNewZoomType
= eOldZoomType
;
634 const Fraction
& rOldY
= GetViewData()->GetZoomY(); // Y wird angezeigt
635 sal_uInt16 nOldZoom
= (sal_uInt16
)(( rOldY
.GetNumerator() * 100 )
636 / rOldY
.GetDenominator());
637 sal_uInt16 nZoom
= nOldZoom
;
638 sal_Bool bCancel
= false;
642 const SvxZoomItem
& rZoomItem
= (const SvxZoomItem
&)
643 pReqArgs
->Get(SID_ATTR_ZOOM
);
645 eNewZoomType
= rZoomItem
.GetType();
646 nZoom
= rZoomItem
.GetValue();
650 SfxItemSet
aSet ( GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
651 SvxZoomItem
aZoomItem( eOldZoomType
, nOldZoom
, SID_ATTR_ZOOM
);
652 AbstractSvxZoomDialog
* pDlg
= NULL
;
653 ScMarkData
& rMark
= GetViewData()->GetMarkData();
654 sal_uInt16 nBtnFlags
= SVX_ZOOM_ENABLE_50
656 | SVX_ZOOM_ENABLE_100
657 | SVX_ZOOM_ENABLE_150
658 | SVX_ZOOM_ENABLE_200
659 | SVX_ZOOM_ENABLE_WHOLEPAGE
660 | SVX_ZOOM_ENABLE_PAGEWIDTH
;
662 if ( rMark
.IsMarked() || rMark
.IsMultiMarked() )
663 nBtnFlags
= nBtnFlags
| SVX_ZOOM_ENABLE_OPTIMAL
;
665 aZoomItem
.SetValueSet( nBtnFlags
);
666 aSet
.Put( aZoomItem
);
667 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
670 pDlg
= pFact
->CreateSvxZoomDialog(GetDialogParent(), aSet
);
671 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
675 pDlg
->SetLimits( MINZOOM
, MAXZOOM
);
677 bCancel
= ( RET_CANCEL
== pDlg
->Execute() );
679 // bCancel is True only if we were in the previous if block,
680 // so no need to check again pDlg
683 const SvxZoomItem
& rZoomItem
= (const SvxZoomItem
&)
684 pDlg
->GetOutputItemSet()->
685 Get( SID_ATTR_ZOOM
);
687 eNewZoomType
= rZoomItem
.GetType();
688 nZoom
= rZoomItem
.GetValue();
696 if ( eNewZoomType
== SVX_ZOOM_PERCENT
)
698 if ( nZoom
< MINZOOM
) nZoom
= MINZOOM
;
699 if ( nZoom
> MAXZOOM
) nZoom
= MAXZOOM
;
703 nZoom
= CalcZoom( eNewZoomType
, nOldZoom
);
704 bCancel
= nZoom
== 0;
707 switch ( eNewZoomType
)
709 case SVX_ZOOM_WHOLEPAGE
:
710 case SVX_ZOOM_PAGEWIDTH
:
711 SetZoomType( eNewZoomType
, bSyncZoom
);
715 SetZoomType( SVX_ZOOM_PERCENT
, bSyncZoom
);
719 if ( nZoom
!= nOldZoom
&& !bCancel
)
721 if (!GetViewData()->IsPagebreakMode())
723 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
724 aNewOpt
.SetZoom( nZoom
);
725 aNewOpt
.SetZoomType( GetZoomType() );
726 pScMod
->SetAppOptions( aNewOpt
);
728 Fraction
aFract( nZoom
, 100 );
729 SetZoom( aFract
, aFract
, bSyncZoom
);
733 rBindings
.Invalidate( SID_ATTR_ZOOM
);
734 rReq
.AppendItem( SvxZoomItem( GetZoomType(), nZoom
, nSlot
) );
740 case SID_ATTR_ZOOMSLIDER
:
742 const SfxPoolItem
* pItem
= NULL
;
743 sal_Bool bSyncZoom
= SC_MOD()->GetAppOptions().GetSynchronizeZoom();
744 if ( pReqArgs
&& pReqArgs
->GetItemState(SID_ATTR_ZOOMSLIDER
, sal_True
, &pItem
) == SFX_ITEM_SET
)
746 const sal_uInt16 nCurrentZoom
= ((const SvxZoomSliderItem
*)pItem
)->GetValue();
749 SetZoomType( SVX_ZOOM_PERCENT
, bSyncZoom
);
750 if (!GetViewData()->IsPagebreakMode())
752 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
753 aNewOpt
.SetZoom( nCurrentZoom
);
754 aNewOpt
.SetZoomType( GetZoomType() );
755 pScMod
->SetAppOptions( aNewOpt
);
757 Fraction
aFract( nCurrentZoom
,100 );
758 SetZoom( aFract
, aFract
, bSyncZoom
);
762 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
769 //----------------------------------------------------------------
771 case FID_TAB_SELECTALL
:
776 case FID_TAB_DESELECTALL
:
781 case SID_SELECT_TABLES
:
783 ScViewData
& rViewData
= *GetViewData();
784 ScDocument
& rDoc
= *rViewData
.GetDocument();
785 ScMarkData
& rMark
= rViewData
.GetMarkData();
786 SCTAB nTabCount
= rDoc
.GetTableCount();
789 ::std::vector
< sal_Int32
> aIndexList
;
790 SFX_REQUEST_ARG( rReq
, pItem
, SfxIntegerListItem
, SID_SELECT_TABLES
, false );
792 pItem
->GetList( aIndexList
);
795 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
796 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
798 AbstractScShowTabDlg
* pDlg
= pFact
->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB
);
799 OSL_ENSURE(pDlg
, "Dialog create fail!");
800 pDlg
->SetDescription(
801 OUString( ScResId( STR_DLG_SELECTTABLES_TITLE
) ),
802 OUString( ScResId( STR_DLG_SELECTTABLES_LBNAME
) ),
803 GetStaticInterface()->GetSlot(SID_SELECT_TABLES
)->GetCommand(), HID_SELECTTABLES
);
805 // fill all table names with selection state
807 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
809 rDoc
.GetName( nTab
, aTabName
);
810 pDlg
->Insert( aTabName
, rMark
.GetTableSelect( nTab
) );
813 if( pDlg
->Execute() == RET_OK
)
815 sal_uInt16 nSelCount
= pDlg
->GetSelectEntryCount();
817 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
818 aIndexList
.insert( aIndexList
.begin()+nSelIx
, pDlg
->GetSelectEntryPos( nSelIx
) );
820 rReq
.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES
, aIndexList
) );
826 if ( !aIndexList
.empty() )
828 sal_uInt16 nSelCount
= aIndexList
.size();
830 SCTAB nFirstVisTab
= 0;
832 // special case: only hidden tables selected -> do nothing
833 sal_Bool bVisSelected
= false;
834 for( nSelIx
= 0; !bVisSelected
&& (nSelIx
< nSelCount
); ++nSelIx
)
835 bVisSelected
= rDoc
.IsVisible( nFirstVisTab
= static_cast<SCTAB
>(aIndexList
[nSelIx
]) );
842 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
843 rMark
.SelectTable( nTab
, false );
845 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
846 rMark
.SelectTable( static_cast<SCTAB
>(aIndexList
[nSelIx
]), sal_True
);
848 // activate another table, if current is deselected
849 if( !rMark
.GetTableSelect( rViewData
.GetTabNo() ) )
851 rMark
.SelectTable( nFirstVisTab
, sal_True
);
852 SetTabNo( nFirstVisTab
);
855 rViewData
.GetDocShell()->PostPaintExtras();
856 SfxBindings
& rBind
= rViewData
.GetBindings();
857 rBind
.Invalidate( FID_FILL_TAB
);
858 rBind
.Invalidate( FID_TAB_DESELECTALL
);
867 case SID_OUTLINE_DELETEALL
:
872 case SID_AUTO_OUTLINE
:
878 case SID_WINDOW_SPLIT
:
880 ScSplitMode eHSplit
= GetViewData()->GetHSplitMode();
881 ScSplitMode eVSplit
= GetViewData()->GetVSplitMode();
882 if ( eHSplit
== SC_SPLIT_NORMAL
|| eVSplit
== SC_SPLIT_NORMAL
) // aufheben
884 else if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // normal
885 FreezeSplitters( false );
896 ScSplitMode eHSplit
= GetViewData()->GetHSplitMode();
897 ScSplitMode eVSplit
= GetViewData()->GetVSplitMode();
898 if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // aufheben
901 FreezeSplitters( sal_True
); // erzeugen oder fixieren
908 // ----------------------------------------------------------------
912 sal_uInt16 nId
= ScHighlightChgDlgWrapper::GetChildWindowId();
913 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
915 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
921 pThisFrame
->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
922 GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT
);
926 sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
927 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
929 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
934 case FID_CHG_COMMENT
:
936 ScViewData
* pData
= GetViewData();
937 ScAddress
aCursorPos( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
938 ScDocShell
* pDocSh
= pData
->GetDocShell();
940 ScChangeAction
* pAction
= pDocSh
->GetChangeAction( aCursorPos
);
943 const SfxPoolItem
* pItem
;
945 pReqArgs
->GetItemState( nSlot
, sal_True
, &pItem
) == SFX_ITEM_SET
&&
946 pItem
->ISA( SfxStringItem
) )
948 OUString aComment
= ((const SfxStringItem
*)pItem
)->GetValue();
949 pDocSh
->SetChangeComment( pAction
, aComment
);
954 pDocSh
->ExecuteChangeCommentDialog( pAction
, GetDialogParent() );
961 case SID_CREATE_SW_DRAWVIEW
:
962 // wird von den Forms gerufen, wenn die DrawView mit allem Zubehoer
963 // angelegt werden muss
964 if (!GetScDrawView())
966 GetViewData()->GetDocShell()->MakeDrawLayer();
967 rBindings
.InvalidateAll(false);
971 case FID_PROTECT_DOC
:
973 ScDocument
* pDoc
= GetViewData()->GetDocument();
974 SfxPasswordDialog
* pDlg
;
978 const SfxPoolItem
* pItem
;
979 if( pReqArgs
->HasItem( FID_PROTECT_DOC
, &pItem
) &&
980 ((const SfxBoolItem
*)pItem
)->GetValue() == static_cast<sal_Bool
>(pDoc
->IsDocProtected()) )
987 ScDocProtection
* pProtect
= pDoc
->GetDocProtection();
988 if (pProtect
&& pProtect
->isProtected())
990 sal_Bool bCancel
= false;
993 if (pProtect
->isProtectedWithPass())
995 OUString
aText(ScResId(SCSTR_PASSWORD
));
997 pDlg
= new SfxPasswordDialog(GetDialogParent(), &aText
);
998 pDlg
->SetText( ScResId(SCSTR_UNPROTECTDOC
) );
999 pDlg
->SetMinLen( 0 );
1000 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC
)->GetCommand() );
1001 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
1003 if (pDlg
->Execute() == RET_OK
)
1004 aPassword
= pDlg
->GetPassword();
1011 Unprotect( TABLEID_DOC
, aPassword
);
1012 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, false ) );
1018 OUString
aText(ScResId(SCSTR_PASSWORDOPT
));
1020 pDlg
= new SfxPasswordDialog( GetDialogParent(), &aText
);
1021 pDlg
->SetText( ScResId(SCSTR_PROTECTDOC
) );
1022 pDlg
->SetMinLen( 0 );
1023 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC
)->GetCommand() );
1024 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
1025 pDlg
->ShowExtras( SHOWEXTRAS_CONFIRM
);
1027 if (pDlg
->Execute() == RET_OK
)
1029 OUString aPassword
= pDlg
->GetPassword();
1030 Protect( TABLEID_DOC
, aPassword
);
1031 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, sal_True
) );
1037 rBindings
.Invalidate( FID_PROTECT_DOC
);
1042 case FID_PROTECT_TABLE
:
1044 ScDocument
* pDoc
= GetViewData()->GetDocument();
1045 SCTAB nTab
= GetViewData()->GetTabNo();
1046 bool bOldProtection
= pDoc
->IsTabProtected(nTab
);
1050 const SfxPoolItem
* pItem
;
1051 bool bNewProtection
= !bOldProtection
;
1052 if( pReqArgs
->HasItem( FID_PROTECT_TABLE
, &pItem
) )
1053 bNewProtection
= ((const SfxBoolItem
*)pItem
)->GetValue();
1054 if( bNewProtection
== bOldProtection
)
1063 // Unprotect a protected sheet.
1065 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1066 if (pProtect
&& pProtect
->isProtectedWithPass())
1068 OUString
aText( ScResId(SCSTR_PASSWORDOPT
) );
1069 auto_ptr
<SfxPasswordDialog
> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText
));
1070 pDlg
->SetText( ScResId(SCSTR_UNPROTECTTAB
) );
1071 pDlg
->SetMinLen( 0 );
1072 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_TABLE
)->GetCommand() );
1073 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1075 if (pDlg
->Execute() == RET_OK
)
1077 OUString aPassword
= pDlg
->GetPassword();
1078 Unprotect(nTab
, aPassword
);
1082 // this sheet is not password-protected.
1083 Unprotect(nTab
, OUString());
1087 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
1093 // Protect a current sheet.
1095 auto_ptr
<ScTableProtectionDlg
> pDlg(new ScTableProtectionDlg(GetDialogParent()));
1097 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1099 pDlg
->SetDialogData(*pProtect
);
1101 if (pDlg
->Execute() == RET_OK
)
1103 pScMod
->InputEnterHandler();
1105 ScTableProtection aNewProtect
;
1106 pDlg
->WriteData(aNewProtect
);
1107 ProtectSheet(nTab
, aNewProtect
);
1110 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, true) );
1116 UpdateInputHandler(true); // damit sofort wieder eingegeben werden kann
1121 case SID_OPT_LOCALE_CHANGED
:
1122 { // locale changed, SYSTEM number formats changed => repaint cell contents
1129 OSL_FAIL("Unbekannter Slot bei ScTabViewShell::Execute");
1136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */