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"
69 #include <boost/scoped_ptr.hpp>
71 /** Try to parse the given range using Calc-style syntax first, then
72 Excel-style if that fails. */
73 static sal_uInt16
lcl_ParseRange(ScRange
& rScRange
, const OUString
& aAddress
, ScDocument
* pDoc
, sal_uInt16
/* nSlot */)
75 sal_uInt16 nResult
= rScRange
.Parse(aAddress
, pDoc
);
76 if ( (nResult
& SCA_VALID
) )
79 return rScRange
.Parse(aAddress
, pDoc
, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1
, 0, 0));
82 /** Try to parse the given address using Calc-style syntax first, then
83 Excel-style if that fails. */
84 static sal_uInt16
lcl_ParseAddress(ScAddress
& rScAddress
, const OUString
& aAddress
, ScDocument
* pDoc
, sal_uInt16
/* nSlot */)
86 sal_uInt16 nResult
= rScAddress
.Parse(aAddress
, pDoc
);
87 if ( (nResult
& SCA_VALID
) )
90 return rScAddress
.Parse(aAddress
, pDoc
, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1
, 0, 0));
93 void ScTabViewShell::Execute( SfxRequest
& rReq
)
95 SfxViewFrame
* pThisFrame
= GetViewFrame();
96 SfxBindings
& rBindings
= pThisFrame
->GetBindings();
97 ScModule
* pScMod
= SC_MOD();
98 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
99 sal_uInt16 nSlot
= rReq
.GetSlot();
101 if (nSlot
!= SID_CURRENTCELL
) // der kommt beim MouseButtonUp
102 HideListBox(); // Autofilter-DropDown-Listbox
106 case FID_INSERT_FILE
:
108 const SfxPoolItem
* pItem
;
110 pReqArgs
->GetItemState(FID_INSERT_FILE
,true,&pItem
) == SFX_ITEM_SET
)
112 OUString aFileName
= ((const SfxStringItem
*)pItem
)->GetValue();
117 if ( pReqArgs
->GetItemState(FN_PARAM_1
,true,&pItem
) == SFX_ITEM_SET
)
118 aInsertPos
= ((const SfxPointItem
*)pItem
)->GetValue();
120 aInsertPos
= GetInsertPos();
124 bool bAsLink
= false;
125 if ( pReqArgs
->GetItemState(FN_PARAM_2
,true,&pItem
) == SFX_ITEM_SET
)
126 bAsLink
= ((const SfxBoolItem
*)pItem
)->GetValue();
130 PasteFile( aInsertPos
, aFileName
, bAsLink
);
135 case SID_OPENDLG_EDIT_PRINTAREA
:
137 sal_uInt16 nId
= ScPrintAreasDlgWrapper::GetChildWindowId();
138 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
140 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
144 case SID_CHANGE_PRINTAREA
:
146 if ( pReqArgs
) // OK aus Dialog
151 bool bEntire
= false;
152 const SfxPoolItem
* pItem
;
153 if ( pReqArgs
->GetItemState( SID_CHANGE_PRINTAREA
, true, &pItem
) == SFX_ITEM_SET
)
154 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
155 if ( pReqArgs
->GetItemState( FN_PARAM_2
, true, &pItem
) == SFX_ITEM_SET
)
156 aRowStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
157 if ( pReqArgs
->GetItemState( FN_PARAM_3
, true, &pItem
) == SFX_ITEM_SET
)
158 aColStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
159 if ( pReqArgs
->GetItemState( FN_PARAM_4
, true, &pItem
) == SFX_ITEM_SET
)
160 bEntire
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
162 SetPrintRanges( bEntire
, &aPrintStr
, &aColStr
, &aRowStr
, false );
169 case SID_ADD_PRINTAREA
:
170 case SID_DEFINE_PRINTAREA
: // Menue oder Basic
172 bool bAdd
= ( nSlot
== SID_ADD_PRINTAREA
);
176 const SfxPoolItem
* pItem
;
177 if ( pReqArgs
->GetItemState( SID_DEFINE_PRINTAREA
, true, &pItem
) == SFX_ITEM_SET
)
178 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
179 SetPrintRanges( false, &aPrintStr
, NULL
, NULL
, bAdd
);
183 SetPrintRanges( false, NULL
, NULL
, NULL
, bAdd
); // aus Selektion
189 case SID_DELETE_PRINTAREA
:
191 // Clear currently defined print range if any, and reset it to
192 // print entire sheet which is the default.
194 SetPrintRanges(true, &aEmpty
, NULL
, NULL
, false);
199 case FID_DEL_MANUALBREAKS
:
200 RemoveManualBreaks();
204 case FID_ADJUST_PRINTZOOM
:
209 case FID_RESET_PRINTZOOM
:
210 SetPrintZoom( 100, 0 ); // 100%, nicht auf Seiten
215 case SID_STATUS_PAGESTYLE
:
217 GetViewData()->GetDocShell()->
218 ExecutePageStyle( *this, rReq
, GetViewData()->GetTabNo() );
222 case SID_CURRENTCELL
:
226 const SfxPoolItem
* pItem
;
227 if ( pReqArgs
->GetItemState( nSlot
, true, &pItem
) == SFX_ITEM_SET
)
228 aAddress
= ((const SfxStringItem
*)pItem
)->GetValue();
229 else if ( nSlot
== SID_JUMPTOMARK
&& pReqArgs
->GetItemState(
230 SID_JUMPTOMARK
, true, &pItem
) == SFX_ITEM_SET
)
231 aAddress
= ((const SfxStringItem
*)pItem
)->GetValue();
233 // #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
234 // isn't set (for recorded macros, because IsAPI is no longer available).
235 // ScGridWindow::MouseButtonUp no longer executes the slot for a single
236 // cell if there is a multi selection.
237 bool bUnmark
= ( nSlot
== SID_CURRENTCELL
);
238 if ( pReqArgs
->GetItemState( FN_PARAM_1
, true, &pItem
) == SFX_ITEM_SET
)
239 bUnmark
= ((const SfxBoolItem
*)pItem
)->GetValue();
241 bool bAlignToCursor
= true;
242 if (pReqArgs
->GetItemState(FN_PARAM_2
, true, &pItem
) == SFX_ITEM_SET
)
243 bAlignToCursor
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
245 if ( nSlot
== SID_JUMPTOMARK
)
247 // URL has to be decoded for escaped characters (%20)
248 aAddress
= INetURLObject::decode( aAddress
, '%',
249 INetURLObject::DECODE_WITH_CHARSET
,
250 RTL_TEXTENCODING_UTF8
);
254 ScViewData
* pViewData
= GetViewData();
255 ScDocument
* pDoc
= pViewData
->GetDocument();
256 ScMarkData
& rMark
= pViewData
->GetMarkData();
258 ScAddress aScAddress
;
259 sal_uInt16 nResult
= lcl_ParseRange(aScRange
, aAddress
, pDoc
, nSlot
);
260 SCTAB nTab
= pViewData
->GetTabNo();
264 if( nResult
& SCA_VALID
)
266 if ( nResult
& SCA_TAB_3D
)
268 if( aScRange
.aStart
.Tab() != nTab
)
269 SetTabNo( nTab
= aScRange
.aStart
.Tab() );
273 aScRange
.aStart
.SetTab( nTab
);
274 aScRange
.aEnd
.SetTab( nTab
);
278 else if ( (nResult
= lcl_ParseAddress(aScAddress
, aAddress
, pDoc
, nSlot
)) & SCA_VALID
)
280 if ( nResult
& SCA_TAB_3D
)
282 if( aScAddress
.Tab() != nTab
)
283 SetTabNo( nTab
= aScAddress
.Tab() );
286 aScAddress
.SetTab( nTab
);
288 aScRange
= ScRange( aScAddress
, aScAddress
);
289 // Zellen sollen nicht markiert werden
292 // Ist es benahmster Bereich (erst Namen dann DBBereiche) ?
295 ScRangeUtil aRangeUtil
;
296 formula::FormulaGrammar::AddressConvention eConv
= pDoc
->GetAddressConvention();
297 if( aRangeUtil
.MakeRangeFromName( aAddress
, pDoc
, nTab
, aScRange
, RUTL_NAMES
, eConv
) ||
298 aRangeUtil
.MakeRangeFromName( aAddress
, pDoc
, nTab
, aScRange
, RUTL_DBASE
, eConv
) )
300 nResult
|= SCA_VALID
;
301 if( aScRange
.aStart
.Tab() != nTab
)
302 SetTabNo( nTab
= aScRange
.aStart
.Tab() );
306 if ( !(nResult
& SCA_VALID
) && comphelper::string::isdigitAsciiString(aAddress
) )
308 sal_Int32 nNumeric
= aAddress
.toInt32();
309 if ( nNumeric
> 0 && nNumeric
<= MAXROW
+1 )
311 // 1-basierte Zeilennummer
313 aScAddress
.SetRow( (SCROW
)(nNumeric
- 1) );
314 aScAddress
.SetCol( pViewData
->GetCurX() );
315 aScAddress
.SetTab( nTab
);
316 aScRange
= ScRange( aScAddress
, aScAddress
);
322 if ( !ValidRow(aScRange
.aStart
.Row()) || !ValidRow(aScRange
.aEnd
.Row()) )
325 // wir haben was gefunden
326 if( nResult
& SCA_VALID
)
329 SCCOL nCol
= aScRange
.aStart
.Col();
330 SCROW nRow
= aScRange
.aStart
.Row();
331 bool bNothing
= ( pViewData
->GetCurX()==nCol
&& pViewData
->GetCurY()==nRow
);
336 if (rMark
.IsMarked()) // ist derselbe Bereich schon markiert?
339 rMark
.GetMarkArea( aOldMark
);
341 ScRange aCurrent
= aScRange
;
343 bNothing
= ( aCurrent
== aOldMark
);
349 MarkRange( aScRange
, false ); // Cursor kommt hinterher...
353 // remove old selection, unless bUnmark argument is sal_False (from navigator)
356 MoveCursorAbs( nCol
, nRow
,
357 SC_FOLLOW_NONE
, false, false );
363 // zusammengefasste Zellen beruecksichtigen:
364 pDoc
->SkipOverlapped(nCol
, nRow
, nTab
);
366 // Navigator-Aufrufe sind nicht API!!!
371 rReq
.Ignore(); // wenn Makro, dann gar nix
373 rReq
.Done(); // sonst wenigstens aufzeichnen
377 pViewData
->ResetOldCursor();
378 SetCursor( nCol
, nRow
);
379 rBindings
.Invalidate( SID_CURRENTCELL
);
380 rBindings
.Update( nSlot
);
388 // align to cursor even if the cursor position hasn't changed,
389 // because the cursor may be set outside the visible area.
390 AlignToCursor( nCol
, nRow
, SC_FOLLOW_JUMP
);
393 rReq
.SetReturnValue( SfxStringItem( SID_CURRENTCELL
, aAddress
) );
396 if (!bFound
) // kein gueltiger Bereich
398 // wenn es ein Tabellenname ist, umschalten (fuer Navigator/URL's)
401 if ( pDoc
->GetTable( aAddress
, nNameTab
) )
404 if ( nNameTab
!= nTab
)
405 SetTabNo( nNameTab
);
409 if ( !bFound
&& nSlot
== SID_JUMPTOMARK
)
411 // Grafik-Objekte probieren (nur bei URL's)
413 bFound
= SelectObject( aAddress
);
416 if (!bFound
&& !rReq
.IsAPI())
417 ErrorMessage( STR_ERR_INVALID_AREA
);
421 case SID_CURRENTOBJECT
:
424 OUString aName
= ((const SfxStringItem
&)pReqArgs
->Get(nSlot
)).GetValue();
425 SelectObject( aName
);
432 // Tabelle fuer Basic ist 1-basiert
433 SCTAB nTab
= ((const SfxUInt16Item
&)pReqArgs
->Get(nSlot
)).GetValue() - 1;
434 ScDocument
* pDoc
= GetViewData()->GetDocument();
435 if ( nTab
< pDoc
->GetTableCount() )
438 rBindings
.Update( nSlot
);
450 OUString
aStrDocName( ((const SfxStringItem
&)pReqArgs
->
451 Get(nSlot
)).GetValue() );
453 SfxViewFrame
* pViewFrame
= NULL
;
454 ScDocShell
* pDocSh
= (ScDocShell
*)SfxObjectShell::GetFirst();
457 // zu aktivierenden ViewFrame suchen
459 while ( pDocSh
&& !bFound
)
461 if ( pDocSh
->GetTitle() == aStrDocName
)
463 pViewFrame
= SfxViewFrame::GetFirst( pDocSh
);
464 bFound
= ( NULL
!= pViewFrame
);
467 pDocSh
= (ScDocShell
*)SfxObjectShell::GetNext( *pDocSh
);
471 pViewFrame
->GetFrame().Appear();
473 rReq
.Ignore();//XXX wird von SFX erledigt
476 case SID_ATTR_SIZE
://XXX ???
480 case SID_PRINTPREVIEW
:
482 if ( !pThisFrame
->GetFrame().IsInPlace() ) // nicht bei OLE
484 // print preview is now always in the same frame as the tab view
485 // -> always switch this frame back to normal view
486 // (ScPreviewShell ctor reads view data)
488 // #102785#; finish input
489 pScMod
->InputEnterHandler();
491 pThisFrame
->GetDispatcher()->Execute( SID_VIEWSHELL1
, SFX_CALLMODE_ASYNCHRON
);
493 // else Fehler (z.B. Ole)
497 case SID_DETECTIVE_DEL_ALL
:
502 // SID_TABLE_ACTIVATE und SID_MARKAREA werden von Basic aus an der versteckten
503 // View aufgerufen, um auf der sichtbaren View zu markieren/umzuschalten:
505 case SID_TABLE_ACTIVATE
:
506 OSL_FAIL("old slot SID_TABLE_ACTIVATE");
517 case FID_NORMALVIEWMODE
:
518 case FID_PAGEBREAKMODE
:
520 bool bWantPageBreak
= nSlot
== FID_PAGEBREAKMODE
;
522 // check whether there is an explicit argument, use it
523 const SfxPoolItem
* pItem
;
524 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SFX_ITEM_SET
)
526 bool bItemValue
= ((const SfxBoolItem
*)pItem
)->GetValue();
527 bWantPageBreak
= (nSlot
== FID_PAGEBREAKMODE
) == bItemValue
;
530 if( GetViewData()->IsPagebreakMode() != bWantPageBreak
)
532 SetPagebreakMode( bWantPageBreak
);
533 UpdatePageBreakData();
534 SetCurSubShell( GetCurObjectSelectionType(), true );
538 rBindings
.Invalidate( nSlot
);
539 rReq
.AppendItem( SfxBoolItem( nSlot
, true ) );
545 case FID_FUNCTION_BOX
:
547 sal_uInt16 nChildId
= ScFunctionChildWindow::GetChildWindowId();
548 if ( rReq
.GetArgs() )
549 pThisFrame
->SetChildWindow( nChildId
, ((const SfxBoolItem
&) (rReq
.GetArgs()->Get(FID_FUNCTION_BOX
))).GetValue());
552 pThisFrame
->ToggleChildWindow( nChildId
);
553 rReq
.AppendItem( SfxBoolItem( FID_FUNCTION_BOX
, pThisFrame
->HasChildWindow( nChildId
) ) );
556 GetViewFrame()->GetBindings().Invalidate(FID_FUNCTION_BOX
);
562 case FID_TOGGLESYNTAX
:
564 bool bSet
= !GetViewData()->IsSyntaxMode();
565 const SfxPoolItem
* pItem
;
566 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SFX_ITEM_SET
)
567 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
568 GetViewData()->SetSyntaxMode( bSet
);
570 rBindings
.Invalidate( FID_TOGGLESYNTAX
);
571 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
575 case FID_TOGGLEHEADERS
:
577 bool bSet
= !GetViewData()->IsHeaderMode();
578 const SfxPoolItem
* pItem
;
579 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SFX_ITEM_SET
)
580 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
581 GetViewData()->SetHeaderMode( bSet
);
583 rBindings
.Invalidate( FID_TOGGLEHEADERS
);
584 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
589 case FID_TOGGLEFORMULA
:
591 ScViewData
* pViewData
= GetViewData();
592 const ScViewOptions
& rOpts
= pViewData
->GetOptions();
593 bool bFormulaMode
= !rOpts
.GetOption( VOPT_FORMULAS
);
594 const SfxPoolItem
*pItem
;
595 if( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SFX_ITEM_SET
)
596 bFormulaMode
= ((const SfxBoolItem
*)pItem
)->GetValue();
598 ScViewOptions rSetOpts
= ScViewOptions( rOpts
);
599 rSetOpts
.SetOption( VOPT_FORMULAS
, bFormulaMode
);
600 pViewData
->SetOptions( rSetOpts
);
602 pViewData
->GetDocShell()->PostPaintGridAll();
604 rBindings
.Invalidate( FID_TOGGLEFORMULA
);
605 rReq
.AppendItem( SfxBoolItem( nSlot
, bFormulaMode
) );
610 case FID_TOGGLEINPUTLINE
:
612 sal_uInt16 nId
= ScInputWindowWrapper::GetChildWindowId();
613 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
614 bool bSet
= ( pWnd
== NULL
);
615 const SfxPoolItem
* pItem
;
616 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SFX_ITEM_SET
)
617 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
619 pThisFrame
->SetChildWindow( nId
, bSet
);
620 rBindings
.Invalidate( FID_TOGGLEINPUTLINE
);
621 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
626 case SID_ATTR_ZOOM
: // Statuszeile
629 bool bSyncZoom
= SC_MOD()->GetAppOptions().GetSynchronizeZoom();
630 SvxZoomType eOldZoomType
= GetZoomType();
631 SvxZoomType eNewZoomType
= eOldZoomType
;
632 const Fraction
& rOldY
= GetViewData()->GetZoomY(); // Y wird angezeigt
633 sal_uInt16 nOldZoom
= (sal_uInt16
)(( rOldY
.GetNumerator() * 100 )
634 / rOldY
.GetDenominator());
635 sal_uInt16 nZoom
= nOldZoom
;
636 bool bCancel
= false;
640 const SvxZoomItem
& rZoomItem
= (const SvxZoomItem
&)
641 pReqArgs
->Get(SID_ATTR_ZOOM
);
643 eNewZoomType
= rZoomItem
.GetType();
644 nZoom
= rZoomItem
.GetValue();
648 SfxItemSet
aSet ( GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
649 SvxZoomItem
aZoomItem( eOldZoomType
, nOldZoom
, SID_ATTR_ZOOM
);
650 boost::scoped_ptr
<AbstractSvxZoomDialog
> pDlg
;
651 ScMarkData
& rMark
= GetViewData()->GetMarkData();
652 sal_uInt16 nBtnFlags
= SVX_ZOOM_ENABLE_50
654 | SVX_ZOOM_ENABLE_100
655 | SVX_ZOOM_ENABLE_150
656 | SVX_ZOOM_ENABLE_200
657 | SVX_ZOOM_ENABLE_WHOLEPAGE
658 | SVX_ZOOM_ENABLE_PAGEWIDTH
;
660 if ( rMark
.IsMarked() || rMark
.IsMultiMarked() )
661 nBtnFlags
= nBtnFlags
| SVX_ZOOM_ENABLE_OPTIMAL
;
663 aZoomItem
.SetValueSet( nBtnFlags
);
664 aSet
.Put( aZoomItem
);
665 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
668 pDlg
.reset(pFact
->CreateSvxZoomDialog(GetDialogParent(), aSet
));
669 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
673 pDlg
->SetLimits( MINZOOM
, MAXZOOM
);
675 bCancel
= ( RET_CANCEL
== pDlg
->Execute() );
677 // bCancel is True only if we were in the previous if block,
678 // so no need to check again pDlg
681 const SvxZoomItem
& rZoomItem
= (const SvxZoomItem
&)
682 pDlg
->GetOutputItemSet()->
683 Get( SID_ATTR_ZOOM
);
685 eNewZoomType
= rZoomItem
.GetType();
686 nZoom
= rZoomItem
.GetValue();
693 if ( eNewZoomType
== SVX_ZOOM_PERCENT
)
695 if ( nZoom
< MINZOOM
) nZoom
= MINZOOM
;
696 if ( nZoom
> MAXZOOM
) nZoom
= MAXZOOM
;
700 nZoom
= CalcZoom( eNewZoomType
, nOldZoom
);
701 bCancel
= nZoom
== 0;
704 switch ( eNewZoomType
)
706 case SVX_ZOOM_WHOLEPAGE
:
707 case SVX_ZOOM_PAGEWIDTH
:
708 SetZoomType( eNewZoomType
, bSyncZoom
);
712 SetZoomType( SVX_ZOOM_PERCENT
, bSyncZoom
);
716 if ( nZoom
!= nOldZoom
&& !bCancel
)
718 if (!GetViewData()->IsPagebreakMode())
720 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
721 aNewOpt
.SetZoom( nZoom
);
722 aNewOpt
.SetZoomType( GetZoomType() );
723 pScMod
->SetAppOptions( aNewOpt
);
725 Fraction
aFract( nZoom
, 100 );
726 SetZoom( aFract
, aFract
, bSyncZoom
);
730 rBindings
.Invalidate( SID_ATTR_ZOOM
);
731 rReq
.AppendItem( SvxZoomItem( GetZoomType(), nZoom
, nSlot
) );
737 case SID_ATTR_ZOOMSLIDER
:
739 const SfxPoolItem
* pItem
= NULL
;
740 bool bSyncZoom
= SC_MOD()->GetAppOptions().GetSynchronizeZoom();
741 if ( pReqArgs
&& pReqArgs
->GetItemState(SID_ATTR_ZOOMSLIDER
, true, &pItem
) == SFX_ITEM_SET
)
743 const sal_uInt16 nCurrentZoom
= ((const SvxZoomSliderItem
*)pItem
)->GetValue();
746 SetZoomType( SVX_ZOOM_PERCENT
, bSyncZoom
);
747 if (!GetViewData()->IsPagebreakMode())
749 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
750 aNewOpt
.SetZoom( nCurrentZoom
);
751 aNewOpt
.SetZoomType( GetZoomType() );
752 pScMod
->SetAppOptions( aNewOpt
);
754 Fraction
aFract( nCurrentZoom
,100 );
755 SetZoom( aFract
, aFract
, bSyncZoom
);
759 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
766 case FID_TAB_SELECTALL
:
771 case FID_TAB_DESELECTALL
:
776 case SID_SELECT_TABLES
:
778 ScViewData
& rViewData
= *GetViewData();
779 ScDocument
& rDoc
= *rViewData
.GetDocument();
780 ScMarkData
& rMark
= rViewData
.GetMarkData();
781 SCTAB nTabCount
= rDoc
.GetTableCount();
784 ::std::vector
< sal_Int32
> aIndexList
;
785 SFX_REQUEST_ARG( rReq
, pItem
, SfxIntegerListItem
, SID_SELECT_TABLES
, false );
787 pItem
->GetList( aIndexList
);
790 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
791 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
793 boost::scoped_ptr
<AbstractScShowTabDlg
> pDlg(pFact
->CreateScShowTabDlg(GetDialogParent()));
794 OSL_ENSURE(pDlg
, "Dialog create fail!");
795 pDlg
->SetDescription(
796 OUString( ScResId( STR_DLG_SELECTTABLES_TITLE
) ),
797 OUString( ScResId( STR_DLG_SELECTTABLES_LBNAME
) ),
798 GetStaticInterface()->GetSlot(SID_SELECT_TABLES
)->GetCommand(), HID_SELECTTABLES
);
800 // fill all table names with selection state
802 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
804 rDoc
.GetName( nTab
, aTabName
);
805 pDlg
->Insert( aTabName
, rMark
.GetTableSelect( nTab
) );
808 if( pDlg
->Execute() == RET_OK
)
810 sal_uInt16 nSelCount
= pDlg
->GetSelectEntryCount();
812 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
813 aIndexList
.insert( aIndexList
.begin()+nSelIx
, pDlg
->GetSelectEntryPos( nSelIx
) );
815 rReq
.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES
, aIndexList
) );
821 if ( !aIndexList
.empty() )
823 sal_uInt16 nSelCount
= aIndexList
.size();
825 SCTAB nFirstVisTab
= 0;
827 // special case: only hidden tables selected -> do nothing
828 bool bVisSelected
= false;
829 for( nSelIx
= 0; !bVisSelected
&& (nSelIx
< nSelCount
); ++nSelIx
)
830 bVisSelected
= rDoc
.IsVisible( nFirstVisTab
= static_cast<SCTAB
>(aIndexList
[nSelIx
]) );
837 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
838 rMark
.SelectTable( nTab
, false );
840 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
841 rMark
.SelectTable( static_cast<SCTAB
>(aIndexList
[nSelIx
]), true );
843 // activate another table, if current is deselected
844 if( !rMark
.GetTableSelect( rViewData
.GetTabNo() ) )
846 rMark
.SelectTable( nFirstVisTab
, true );
847 SetTabNo( nFirstVisTab
);
850 rViewData
.GetDocShell()->PostPaintExtras();
851 SfxBindings
& rBind
= rViewData
.GetBindings();
852 rBind
.Invalidate( FID_FILL_TAB
);
853 rBind
.Invalidate( FID_TAB_DESELECTALL
);
862 case SID_OUTLINE_DELETEALL
:
867 case SID_AUTO_OUTLINE
:
873 case SID_WINDOW_SPLIT
:
875 ScSplitMode eHSplit
= GetViewData()->GetHSplitMode();
876 ScSplitMode eVSplit
= GetViewData()->GetVSplitMode();
877 if ( eHSplit
== SC_SPLIT_NORMAL
|| eVSplit
== SC_SPLIT_NORMAL
) // aufheben
879 else if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // normal
880 FreezeSplitters( false );
891 ScSplitMode eHSplit
= GetViewData()->GetHSplitMode();
892 ScSplitMode eVSplit
= GetViewData()->GetVSplitMode();
893 if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // aufheben
896 FreezeSplitters( true ); // erzeugen oder fixieren
905 sal_uInt16 nId
= ScHighlightChgDlgWrapper::GetChildWindowId();
906 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
908 pScMod
->SetRefDialog( nId
, pWnd
? false : sal_True
);
914 pThisFrame
->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
915 GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT
);
919 sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
920 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
922 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
927 case FID_CHG_COMMENT
:
929 ScViewData
* pData
= GetViewData();
930 ScAddress
aCursorPos( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
931 ScDocShell
* pDocSh
= pData
->GetDocShell();
933 ScChangeAction
* pAction
= pDocSh
->GetChangeAction( aCursorPos
);
936 const SfxPoolItem
* pItem
;
938 pReqArgs
->GetItemState( nSlot
, true, &pItem
) == SFX_ITEM_SET
&&
939 pItem
->ISA( SfxStringItem
) )
941 OUString aComment
= ((const SfxStringItem
*)pItem
)->GetValue();
942 pDocSh
->SetChangeComment( pAction
, aComment
);
947 pDocSh
->ExecuteChangeCommentDialog( pAction
, GetDialogParent() );
954 case SID_CREATE_SW_DRAWVIEW
:
955 // wird von den Forms gerufen, wenn die DrawView mit allem Zubehoer
956 // angelegt werden muss
957 if (!GetScDrawView())
959 GetViewData()->GetDocShell()->MakeDrawLayer();
960 rBindings
.InvalidateAll(false);
964 case FID_PROTECT_DOC
:
966 ScDocument
* pDoc
= GetViewData()->GetDocument();
970 const SfxPoolItem
* pItem
;
971 if( pReqArgs
->HasItem( FID_PROTECT_DOC
, &pItem
) &&
972 ((const SfxBoolItem
*)pItem
)->GetValue() == pDoc
->IsDocProtected() )
979 ScDocProtection
* pProtect
= pDoc
->GetDocProtection();
980 if (pProtect
&& pProtect
->isProtected())
982 bool bCancel
= false;
985 if (pProtect
->isProtectedWithPass())
987 OUString
aText(ScResId(SCSTR_PASSWORD
));
989 boost::scoped_ptr
<SfxPasswordDialog
> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText
));
990 pDlg
->SetText( ScResId(SCSTR_UNPROTECTDOC
) );
991 pDlg
->SetMinLen( 0 );
992 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC
)->GetCommand() );
993 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
995 if (pDlg
->Execute() == RET_OK
)
996 aPassword
= pDlg
->GetPassword();
1002 Unprotect( TABLEID_DOC
, aPassword
);
1003 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, false ) );
1009 OUString
aText(ScResId(SCSTR_PASSWORDOPT
));
1011 boost::scoped_ptr
<SfxPasswordDialog
> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText
));
1012 pDlg
->SetText( ScResId(SCSTR_PROTECTDOC
) );
1013 pDlg
->SetMinLen( 0 );
1014 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC
)->GetCommand() );
1015 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
1016 pDlg
->ShowExtras( SHOWEXTRAS_CONFIRM
);
1018 if (pDlg
->Execute() == RET_OK
)
1020 OUString aPassword
= pDlg
->GetPassword();
1021 Protect( TABLEID_DOC
, aPassword
);
1022 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, true ) );
1026 rBindings
.Invalidate( FID_PROTECT_DOC
);
1031 case FID_PROTECT_TABLE
:
1033 ScDocument
* pDoc
= GetViewData()->GetDocument();
1034 SCTAB nTab
= GetViewData()->GetTabNo();
1035 bool bOldProtection
= pDoc
->IsTabProtected(nTab
);
1039 const SfxPoolItem
* pItem
;
1040 bool bNewProtection
= !bOldProtection
;
1041 if( pReqArgs
->HasItem( FID_PROTECT_TABLE
, &pItem
) )
1042 bNewProtection
= ((const SfxBoolItem
*)pItem
)->GetValue();
1043 if( bNewProtection
== bOldProtection
)
1052 // Unprotect a protected sheet.
1054 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1055 if (pProtect
&& pProtect
->isProtectedWithPass())
1057 OUString
aText( ScResId(SCSTR_PASSWORDOPT
) );
1058 boost::scoped_ptr
<SfxPasswordDialog
> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText
));
1059 pDlg
->SetText( ScResId(SCSTR_UNPROTECTTAB
) );
1060 pDlg
->SetMinLen( 0 );
1061 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_TABLE
)->GetCommand() );
1062 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1064 if (pDlg
->Execute() == RET_OK
)
1066 OUString aPassword
= pDlg
->GetPassword();
1067 Unprotect(nTab
, aPassword
);
1071 // this sheet is not password-protected.
1072 Unprotect(nTab
, OUString());
1076 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
1082 // Protect a current sheet.
1084 boost::scoped_ptr
<ScTableProtectionDlg
> pDlg(new ScTableProtectionDlg(GetDialogParent()));
1086 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1088 pDlg
->SetDialogData(*pProtect
);
1090 if (pDlg
->Execute() == RET_OK
)
1092 pScMod
->InputEnterHandler();
1094 ScTableProtection aNewProtect
;
1095 pDlg
->WriteData(aNewProtect
);
1096 ProtectSheet(nTab
, aNewProtect
);
1099 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, true) );
1105 UpdateInputHandler(true); // damit sofort wieder eingegeben werden kann
1110 case SID_OPT_LOCALE_CHANGED
:
1111 { // locale changed, SYSTEM number formats changed => repaint cell contents
1118 OSL_FAIL("Unbekannter Slot bei ScTabViewShell::Execute");
1123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */