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 <sfx2/sidebar/Sidebar.hxx>
29 #include <svl/ptitem.hxx>
30 #include <svl/stritem.hxx>
31 #include <tools/urlobj.hxx>
32 #include <sfx2/objface.hxx>
33 #include <vcl/msgbox.hxx>
34 #include <vcl/vclenum.hxx>
36 #include "globstr.hrc"
38 #include "appoptio.hxx"
39 #include "tabvwsh.hxx"
40 #include "document.hxx"
42 #include "inputwin.hxx"
43 #include "scresid.hxx"
44 #include "printfun.hxx"
46 #include "rangelst.hxx"
47 #include "prevwsh.hxx"
48 #include "rangeutl.hxx"
49 #include "reffact.hxx"
50 #include "uiitems.hxx"
51 #include "formulacell.hxx"
52 #include "inputhdl.hxx"
53 #include "autoform.hxx"
54 #include "autofmt.hxx"
55 #include "dwfunctr.hxx"
56 #include "shtabdlg.hxx"
57 #include "tabprotection.hxx"
58 #include "protectiondlg.hxx"
59 #include "markdata.hxx"
61 #include <svl/ilstitem.hxx>
64 #include <svx/zoomslideritem.hxx>
65 #include <svx/svxdlg.hxx>
66 #include <svx/dialogs.hrc>
67 #include <comphelper/string.hxx>
68 #include "scabstdlg.hxx"
70 #include <boost/scoped_ptr.hpp>
72 /** Try to parse the given range using Calc-style syntax first, then
73 Excel-style if that fails. */
74 static sal_uInt16
lcl_ParseRange(ScRange
& rScRange
, const OUString
& aAddress
, ScDocument
* pDoc
, sal_uInt16
/* nSlot */)
76 sal_uInt16 nResult
= rScRange
.Parse(aAddress
, pDoc
);
77 if ( (nResult
& SCA_VALID
) )
80 return rScRange
.Parse(aAddress
, pDoc
, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1
, 0, 0));
83 /** Try to parse the given address using Calc-style syntax first, then
84 Excel-style if that fails. */
85 static sal_uInt16
lcl_ParseAddress(ScAddress
& rScAddress
, const OUString
& aAddress
, ScDocument
* pDoc
, sal_uInt16
/* nSlot */)
87 sal_uInt16 nResult
= rScAddress
.Parse(aAddress
, pDoc
);
88 if ( (nResult
& SCA_VALID
) )
91 return rScAddress
.Parse(aAddress
, pDoc
, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1
, 0, 0));
94 void ScTabViewShell::Execute( SfxRequest
& rReq
)
96 SfxViewFrame
* pThisFrame
= GetViewFrame();
97 SfxBindings
& rBindings
= pThisFrame
->GetBindings();
98 ScModule
* pScMod
= SC_MOD();
99 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
100 sal_uInt16 nSlot
= rReq
.GetSlot();
102 if (nSlot
!= SID_CURRENTCELL
) // der kommt beim MouseButtonUp
103 HideListBox(); // Autofilter-DropDown-Listbox
107 case FID_INSERT_FILE
:
109 const SfxPoolItem
* pItem
;
111 pReqArgs
->GetItemState(FID_INSERT_FILE
,true,&pItem
) == SfxItemState::SET
)
113 OUString aFileName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
118 if ( pReqArgs
->GetItemState(FN_PARAM_1
,true,&pItem
) == SfxItemState::SET
)
119 aInsertPos
= static_cast<const SfxPointItem
*>(pItem
)->GetValue();
121 aInsertPos
= GetInsertPos();
125 bool bAsLink
= false;
126 if ( pReqArgs
->GetItemState(FN_PARAM_2
,true,&pItem
) == SfxItemState::SET
)
127 bAsLink
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
131 PasteFile( aInsertPos
, aFileName
, bAsLink
);
136 case SID_OPENDLG_EDIT_PRINTAREA
:
138 sal_uInt16 nId
= ScPrintAreasDlgWrapper::GetChildWindowId();
139 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
141 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
145 case SID_CHANGE_PRINTAREA
:
147 if ( pReqArgs
) // OK aus Dialog
152 bool bEntire
= false;
153 const SfxPoolItem
* pItem
;
154 if ( pReqArgs
->GetItemState( SID_CHANGE_PRINTAREA
, true, &pItem
) == SfxItemState::SET
)
155 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
156 if ( pReqArgs
->GetItemState( FN_PARAM_2
, true, &pItem
) == SfxItemState::SET
)
157 aRowStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
158 if ( pReqArgs
->GetItemState( FN_PARAM_3
, true, &pItem
) == SfxItemState::SET
)
159 aColStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
160 if ( pReqArgs
->GetItemState( FN_PARAM_4
, true, &pItem
) == SfxItemState::SET
)
161 bEntire
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
163 SetPrintRanges( bEntire
, &aPrintStr
, &aColStr
, &aRowStr
, false );
170 case SID_ADD_PRINTAREA
:
171 case SID_DEFINE_PRINTAREA
: // Menue oder Basic
173 bool bAdd
= ( nSlot
== SID_ADD_PRINTAREA
);
177 const SfxPoolItem
* pItem
;
178 if ( pReqArgs
->GetItemState( SID_DEFINE_PRINTAREA
, true, &pItem
) == SfxItemState::SET
)
179 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
180 SetPrintRanges( false, &aPrintStr
, NULL
, NULL
, bAdd
);
184 SetPrintRanges( false, NULL
, NULL
, NULL
, bAdd
); // aus Selektion
190 case SID_DELETE_PRINTAREA
:
192 // Clear currently defined print range if any, and reset it to
193 // print entire sheet which is the default.
195 SetPrintRanges(true, &aEmpty
, NULL
, NULL
, false);
200 case FID_DEL_MANUALBREAKS
:
201 RemoveManualBreaks();
205 case FID_ADJUST_PRINTZOOM
:
210 case FID_RESET_PRINTZOOM
:
211 SetPrintZoom( 100, 0 ); // 100%, nicht auf Seiten
216 case SID_STATUS_PAGESTYLE
:
218 GetViewData().GetDocShell()->
219 ExecutePageStyle( *this, rReq
, GetViewData().GetTabNo() );
223 case SID_CURRENTCELL
:
227 const SfxPoolItem
* pItem
;
228 if ( pReqArgs
->GetItemState( nSlot
, true, &pItem
) == SfxItemState::SET
)
229 aAddress
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
230 else if ( nSlot
== SID_JUMPTOMARK
&& pReqArgs
->GetItemState(
231 SID_JUMPTOMARK
, true, &pItem
) == SfxItemState::SET
)
232 aAddress
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
234 // #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
235 // isn't set (for recorded macros, because IsAPI is no longer available).
236 // ScGridWindow::MouseButtonUp no longer executes the slot for a single
237 // cell if there is a multi selection.
238 bool bUnmark
= ( nSlot
== SID_CURRENTCELL
);
239 if ( pReqArgs
->GetItemState( FN_PARAM_1
, true, &pItem
) == SfxItemState::SET
)
240 bUnmark
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
242 bool bAlignToCursor
= true;
243 if (pReqArgs
->GetItemState(FN_PARAM_2
, true, &pItem
) == SfxItemState::SET
)
244 bAlignToCursor
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
246 if ( nSlot
== SID_JUMPTOMARK
)
248 // URL has to be decoded for escaped characters (%20)
249 aAddress
= INetURLObject::decode( aAddress
,
250 INetURLObject::DECODE_WITH_CHARSET
,
251 RTL_TEXTENCODING_UTF8
);
255 ScViewData
& rViewData
= GetViewData();
256 ScDocument
* pDoc
= rViewData
.GetDocument();
257 ScMarkData
& rMark
= rViewData
.GetMarkData();
259 ScAddress aScAddress
;
260 sal_uInt16 nResult
= lcl_ParseRange(aScRange
, aAddress
, pDoc
, nSlot
);
261 SCTAB nTab
= rViewData
.GetTabNo();
265 if( nResult
& SCA_VALID
)
267 if ( nResult
& SCA_TAB_3D
)
269 if( aScRange
.aStart
.Tab() != nTab
)
270 SetTabNo( nTab
= aScRange
.aStart
.Tab() );
274 aScRange
.aStart
.SetTab( nTab
);
275 aScRange
.aEnd
.SetTab( nTab
);
279 else if ( (nResult
= lcl_ParseAddress(aScAddress
, aAddress
, pDoc
, nSlot
)) & SCA_VALID
)
281 if ( nResult
& SCA_TAB_3D
)
283 if( aScAddress
.Tab() != nTab
)
284 SetTabNo( nTab
= aScAddress
.Tab() );
287 aScAddress
.SetTab( nTab
);
289 aScRange
= ScRange( aScAddress
, aScAddress
);
290 // Zellen sollen nicht markiert werden
293 // Ist es benahmster Bereich (erst Namen dann DBBereiche) ?
296 ScRangeUtil aRangeUtil
;
297 formula::FormulaGrammar::AddressConvention eConv
= pDoc
->GetAddressConvention();
298 if( ScRangeUtil::MakeRangeFromName( aAddress
, pDoc
, nTab
, aScRange
, RUTL_NAMES
, eConv
) ||
299 ScRangeUtil::MakeRangeFromName( aAddress
, pDoc
, nTab
, aScRange
, RUTL_DBASE
, eConv
) )
301 nResult
|= SCA_VALID
;
302 if( aScRange
.aStart
.Tab() != nTab
)
303 SetTabNo( nTab
= aScRange
.aStart
.Tab() );
307 if ( !(nResult
& SCA_VALID
) && comphelper::string::isdigitAsciiString(aAddress
) )
309 sal_Int32 nNumeric
= aAddress
.toInt32();
310 if ( nNumeric
> 0 && nNumeric
<= MAXROW
+1 )
312 // 1-basierte Zeilennummer
314 aScAddress
.SetRow( (SCROW
)(nNumeric
- 1) );
315 aScAddress
.SetCol( rViewData
.GetCurX() );
316 aScAddress
.SetTab( nTab
);
317 aScRange
= ScRange( aScAddress
, aScAddress
);
323 if ( !ValidRow(aScRange
.aStart
.Row()) || !ValidRow(aScRange
.aEnd
.Row()) )
326 // wir haben was gefunden
327 if( nResult
& SCA_VALID
)
330 SCCOL nCol
= aScRange
.aStart
.Col();
331 SCROW nRow
= aScRange
.aStart
.Row();
332 bool bNothing
= ( rViewData
.GetCurX()==nCol
&& rViewData
.GetCurY()==nRow
);
337 if (rMark
.IsMarked()) // ist derselbe Bereich schon markiert?
340 rMark
.GetMarkArea( aOldMark
);
342 ScRange aCurrent
= aScRange
;
344 bNothing
= ( aCurrent
== aOldMark
);
350 MarkRange( aScRange
, false ); // Cursor kommt hinterher...
354 // remove old selection, unless bUnmark argument is sal_False (from navigator)
357 MoveCursorAbs( nCol
, nRow
,
358 SC_FOLLOW_NONE
, false, false );
364 // zusammengefasste Zellen beruecksichtigen:
365 pDoc
->SkipOverlapped(nCol
, nRow
, nTab
);
367 // Navigator-Aufrufe sind nicht API!!!
372 rReq
.Ignore(); // wenn Makro, dann gar nix
374 rReq
.Done(); // sonst wenigstens aufzeichnen
378 rViewData
.ResetOldCursor();
379 SetCursor( nCol
, nRow
);
380 rBindings
.Invalidate( SID_CURRENTCELL
);
381 rBindings
.Update( nSlot
);
389 // align to cursor even if the cursor position hasn't changed,
390 // because the cursor may be set outside the visible area.
391 AlignToCursor( nCol
, nRow
, SC_FOLLOW_JUMP
);
394 rReq
.SetReturnValue( SfxStringItem( SID_CURRENTCELL
, aAddress
) );
397 if (!bFound
) // kein gueltiger Bereich
399 // wenn es ein Tabellenname ist, umschalten (fuer Navigator/URL's)
402 if ( pDoc
->GetTable( aAddress
, nNameTab
) )
405 if ( nNameTab
!= nTab
)
406 SetTabNo( nNameTab
);
410 if ( !bFound
&& nSlot
== SID_JUMPTOMARK
)
412 // Grafik-Objekte probieren (nur bei URL's)
414 bFound
= SelectObject( aAddress
);
417 if (!bFound
&& !rReq
.IsAPI())
418 ErrorMessage( STR_ERR_INVALID_AREA
);
422 case SID_CURRENTOBJECT
:
425 OUString aName
= static_cast<const SfxStringItem
&>(pReqArgs
->Get(nSlot
)).GetValue();
426 SelectObject( aName
);
433 // Tabelle fuer Basic ist 1-basiert
434 SCTAB nTab
= static_cast<const SfxUInt16Item
&>(pReqArgs
->Get(nSlot
)).GetValue() - 1;
435 ScDocument
* pDoc
= GetViewData().GetDocument();
436 if ( nTab
< pDoc
->GetTableCount() )
439 rBindings
.Update( nSlot
);
451 OUString
aStrDocName( static_cast<const SfxStringItem
&>(pReqArgs
->
452 Get(nSlot
)).GetValue() );
454 SfxViewFrame
* pViewFrame
= NULL
;
455 ScDocShell
* pDocSh
= static_cast<ScDocShell
*>(SfxObjectShell::GetFirst());
458 // zu aktivierenden ViewFrame suchen
460 while ( pDocSh
&& !bFound
)
462 if ( pDocSh
->GetTitle() == aStrDocName
)
464 pViewFrame
= SfxViewFrame::GetFirst( pDocSh
);
465 bFound
= ( NULL
!= pViewFrame
);
468 pDocSh
= static_cast<ScDocShell
*>(SfxObjectShell::GetNext( *pDocSh
));
472 pViewFrame
->GetFrame().Appear();
474 rReq
.Ignore();//XXX wird von SFX erledigt
477 case SID_PRINTPREVIEW
:
479 if ( !pThisFrame
->GetFrame().IsInPlace() ) // nicht bei OLE
481 // print preview is now always in the same frame as the tab view
482 // -> always switch this frame back to normal view
483 // (ScPreviewShell ctor reads view data)
485 // #102785#; finish input
486 pScMod
->InputEnterHandler();
488 pThisFrame
->GetDispatcher()->Execute( SID_VIEWSHELL1
, SfxCallMode::ASYNCHRON
);
490 // else Fehler (z.B. Ole)
494 case SID_DETECTIVE_DEL_ALL
:
499 // SID_TABLE_ACTIVATE und SID_MARKAREA werden von Basic aus an der versteckten
500 // View aufgerufen, um auf der sichtbaren View zu markieren/umzuschalten:
502 case SID_TABLE_ACTIVATE
:
503 OSL_FAIL("old slot SID_TABLE_ACTIVATE");
514 case FID_NORMALVIEWMODE
:
515 case FID_PAGEBREAKMODE
:
517 bool bWantPageBreak
= nSlot
== FID_PAGEBREAKMODE
;
519 // check whether there is an explicit argument, use it
520 const SfxPoolItem
* pItem
;
521 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
523 bool bItemValue
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
524 bWantPageBreak
= (nSlot
== FID_PAGEBREAKMODE
) == bItemValue
;
527 if( GetViewData().IsPagebreakMode() != bWantPageBreak
)
529 SetPagebreakMode( bWantPageBreak
);
530 UpdatePageBreakData();
531 SetCurSubShell( GetCurObjectSelectionType(), true );
535 rBindings
.Invalidate( nSlot
);
536 rReq
.AppendItem( SfxBoolItem( nSlot
, true ) );
542 case FID_FUNCTION_BOX
:
544 // First make sure that the sidebar is visible
545 pThisFrame
->ShowChildWindow(SID_SIDEBAR
);
547 ::sfx2::sidebar::Sidebar::ShowPanel("FunctionsPanel",
548 pThisFrame
->GetFrame().GetFrameInterface());
553 case FID_TOGGLESYNTAX
:
555 bool bSet
= !GetViewData().IsSyntaxMode();
556 const SfxPoolItem
* pItem
;
557 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
558 bSet
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
559 GetViewData().SetSyntaxMode( bSet
);
561 rBindings
.Invalidate( FID_TOGGLESYNTAX
);
562 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
566 case FID_TOGGLEHEADERS
:
568 bool bSet
= !GetViewData().IsHeaderMode();
569 const SfxPoolItem
* pItem
;
570 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
571 bSet
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
572 GetViewData().SetHeaderMode( bSet
);
574 rBindings
.Invalidate( FID_TOGGLEHEADERS
);
575 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
580 case FID_TOGGLEFORMULA
:
582 ScViewData
& rViewData
= GetViewData();
583 const ScViewOptions
& rOpts
= rViewData
.GetOptions();
584 bool bFormulaMode
= !rOpts
.GetOption( VOPT_FORMULAS
);
585 const SfxPoolItem
*pItem
;
586 if( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
587 bFormulaMode
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
589 ScViewOptions rSetOpts
= ScViewOptions( rOpts
);
590 rSetOpts
.SetOption( VOPT_FORMULAS
, bFormulaMode
);
591 rViewData
.SetOptions( rSetOpts
);
593 rViewData
.GetDocShell()->PostPaintGridAll();
595 rBindings
.Invalidate( FID_TOGGLEFORMULA
);
596 rReq
.AppendItem( SfxBoolItem( nSlot
, bFormulaMode
) );
601 case FID_TOGGLEINPUTLINE
:
603 sal_uInt16 nId
= ScInputWindowWrapper::GetChildWindowId();
604 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
605 bool bSet
= ( pWnd
== NULL
);
606 const SfxPoolItem
* pItem
;
607 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
608 bSet
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
610 pThisFrame
->SetChildWindow( nId
, bSet
);
611 rBindings
.Invalidate( FID_TOGGLEINPUTLINE
);
612 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
617 case SID_ATTR_ZOOM
: // Statuszeile
620 bool bSyncZoom
= SC_MOD()->GetAppOptions().GetSynchronizeZoom();
621 SvxZoomType eOldZoomType
= GetZoomType();
622 SvxZoomType eNewZoomType
= eOldZoomType
;
623 const Fraction
& rOldY
= GetViewData().GetZoomY(); // Y wird angezeigt
624 sal_uInt16 nOldZoom
= (sal_uInt16
)(( rOldY
.GetNumerator() * 100 )
625 / rOldY
.GetDenominator());
626 sal_uInt16 nZoom
= nOldZoom
;
627 bool bCancel
= false;
631 const SvxZoomItem
& rZoomItem
= static_cast<const SvxZoomItem
&>(
632 pReqArgs
->Get(SID_ATTR_ZOOM
));
634 eNewZoomType
= rZoomItem
.GetType();
635 nZoom
= rZoomItem
.GetValue();
639 SfxItemSet
aSet ( GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
640 SvxZoomItem
aZoomItem( eOldZoomType
, nOldZoom
, SID_ATTR_ZOOM
);
641 boost::scoped_ptr
<AbstractSvxZoomDialog
> pDlg
;
642 ScMarkData
& rMark
= GetViewData().GetMarkData();
643 SvxZoomEnableFlags nBtnFlags
= SvxZoomEnableFlags::N50
644 | SvxZoomEnableFlags::N75
645 | SvxZoomEnableFlags::N100
646 | SvxZoomEnableFlags::N150
647 | SvxZoomEnableFlags::N200
648 | SvxZoomEnableFlags::WHOLEPAGE
649 | SvxZoomEnableFlags::PAGEWIDTH
;
651 if ( rMark
.IsMarked() || rMark
.IsMultiMarked() )
652 nBtnFlags
= nBtnFlags
| SvxZoomEnableFlags::OPTIMAL
;
654 aZoomItem
.SetValueSet( nBtnFlags
);
655 aSet
.Put( aZoomItem
);
656 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
659 pDlg
.reset(pFact
->CreateSvxZoomDialog(GetDialogParent(), aSet
));
660 OSL_ENSURE(pDlg
, "Dialog creation failed!");
664 pDlg
->SetLimits( MINZOOM
, MAXZOOM
);
666 bCancel
= ( RET_CANCEL
== pDlg
->Execute() );
668 // bCancel is True only if we were in the previous if block,
669 // so no need to check again pDlg
672 const SvxZoomItem
& rZoomItem
= static_cast<const SvxZoomItem
&>(
673 pDlg
->GetOutputItemSet()->
674 Get( SID_ATTR_ZOOM
));
676 eNewZoomType
= rZoomItem
.GetType();
677 nZoom
= rZoomItem
.GetValue();
684 if ( eNewZoomType
== SvxZoomType::PERCENT
)
686 if ( nZoom
< MINZOOM
) nZoom
= MINZOOM
;
687 if ( nZoom
> MAXZOOM
) nZoom
= MAXZOOM
;
691 nZoom
= CalcZoom( eNewZoomType
, nOldZoom
);
692 bCancel
= nZoom
== 0;
695 switch ( eNewZoomType
)
697 case SvxZoomType::WHOLEPAGE
:
698 case SvxZoomType::PAGEWIDTH
:
699 SetZoomType( eNewZoomType
, bSyncZoom
);
703 SetZoomType( SvxZoomType::PERCENT
, bSyncZoom
);
707 if ( nZoom
!= nOldZoom
&& !bCancel
)
709 if (!GetViewData().IsPagebreakMode())
711 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
712 aNewOpt
.SetZoom( nZoom
);
713 aNewOpt
.SetZoomType( GetZoomType() );
714 pScMod
->SetAppOptions( aNewOpt
);
716 Fraction
aFract( nZoom
, 100 );
717 SetZoom( aFract
, aFract
, bSyncZoom
);
721 rBindings
.Invalidate( SID_ATTR_ZOOM
);
722 rReq
.AppendItem( SvxZoomItem( GetZoomType(), nZoom
, nSlot
) );
728 case SID_ATTR_ZOOMSLIDER
:
730 const SfxPoolItem
* pItem
= NULL
;
731 bool bSyncZoom
= SC_MOD()->GetAppOptions().GetSynchronizeZoom();
732 if ( pReqArgs
&& pReqArgs
->GetItemState(SID_ATTR_ZOOMSLIDER
, true, &pItem
) == SfxItemState::SET
)
734 const sal_uInt16 nCurrentZoom
= static_cast<const SvxZoomSliderItem
*>(pItem
)->GetValue();
737 SetZoomType( SvxZoomType::PERCENT
, bSyncZoom
);
738 if (!GetViewData().IsPagebreakMode())
740 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
741 aNewOpt
.SetZoom( nCurrentZoom
);
742 aNewOpt
.SetZoomType( GetZoomType() );
743 pScMod
->SetAppOptions( aNewOpt
);
745 Fraction
aFract( nCurrentZoom
,100 );
746 SetZoom( aFract
, aFract
, bSyncZoom
);
750 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
757 case FID_TAB_SELECTALL
:
762 case FID_TAB_DESELECTALL
:
767 case SID_SELECT_TABLES
:
769 ScViewData
& rViewData
= GetViewData();
770 ScDocument
& rDoc
= *rViewData
.GetDocument();
771 ScMarkData
& rMark
= rViewData
.GetMarkData();
772 SCTAB nTabCount
= rDoc
.GetTableCount();
775 ::std::vector
< sal_Int32
> aIndexList
;
776 SFX_REQUEST_ARG( rReq
, pItem
, SfxIntegerListItem
, SID_SELECT_TABLES
, false );
778 pItem
->GetList( aIndexList
);
781 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
782 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
784 boost::scoped_ptr
<AbstractScShowTabDlg
> pDlg(pFact
->CreateScShowTabDlg(GetDialogParent()));
785 OSL_ENSURE(pDlg
, "Dialog create fail!");
786 pDlg
->SetDescription(
787 OUString( ScResId( STR_DLG_SELECTTABLES_TITLE
) ),
788 OUString( ScResId( STR_DLG_SELECTTABLES_LBNAME
) ),
789 GetStaticInterface()->GetSlot(SID_SELECT_TABLES
)->GetCommand(), HID_SELECTTABLES
);
791 // fill all table names with selection state
793 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
795 rDoc
.GetName( nTab
, aTabName
);
796 pDlg
->Insert( aTabName
, rMark
.GetTableSelect( nTab
) );
799 if( pDlg
->Execute() == RET_OK
)
801 sal_uInt16 nSelCount
= pDlg
->GetSelectEntryCount();
803 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
804 aIndexList
.insert( aIndexList
.begin()+nSelIx
, pDlg
->GetSelectEntryPos( nSelIx
) );
806 rReq
.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES
, aIndexList
) );
812 if ( !aIndexList
.empty() )
814 sal_uInt16 nSelCount
= aIndexList
.size();
816 SCTAB nFirstVisTab
= 0;
818 // special case: only hidden tables selected -> do nothing
819 bool bVisSelected
= false;
820 for( nSelIx
= 0; !bVisSelected
&& (nSelIx
< nSelCount
); ++nSelIx
)
821 bVisSelected
= rDoc
.IsVisible( nFirstVisTab
= static_cast<SCTAB
>(aIndexList
[nSelIx
]) );
828 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
829 rMark
.SelectTable( nTab
, false );
831 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
832 rMark
.SelectTable( static_cast<SCTAB
>(aIndexList
[nSelIx
]), true );
834 // activate another table, if current is deselected
835 if( !rMark
.GetTableSelect( rViewData
.GetTabNo() ) )
837 rMark
.SelectTable( nFirstVisTab
, true );
838 SetTabNo( nFirstVisTab
);
841 rViewData
.GetDocShell()->PostPaintExtras();
842 SfxBindings
& rBind
= rViewData
.GetBindings();
843 rBind
.Invalidate( FID_FILL_TAB
);
844 rBind
.Invalidate( FID_TAB_DESELECTALL
);
852 case SID_OUTLINE_DELETEALL
:
857 case SID_AUTO_OUTLINE
:
862 case SID_WINDOW_SPLIT
:
864 ScSplitMode eHSplit
= GetViewData().GetHSplitMode();
865 ScSplitMode eVSplit
= GetViewData().GetVSplitMode();
866 if ( eHSplit
== SC_SPLIT_NORMAL
|| eVSplit
== SC_SPLIT_NORMAL
) // aufheben
868 else if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // normal
869 FreezeSplitters( false );
880 ScSplitMode eHSplit
= GetViewData().GetHSplitMode();
881 ScSplitMode eVSplit
= GetViewData().GetVSplitMode();
882 if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // aufheben
885 FreezeSplitters( true ); // erzeugen oder fixieren
894 sal_uInt16 nId
= ScHighlightChgDlgWrapper::GetChildWindowId();
895 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
897 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
903 pThisFrame
->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
904 GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT
);
908 sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
909 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
911 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
916 case FID_CHG_COMMENT
:
918 ScViewData
& rData
= GetViewData();
919 ScAddress
aCursorPos( rData
.GetCurX(), rData
.GetCurY(), rData
.GetTabNo() );
920 ScDocShell
* pDocSh
= rData
.GetDocShell();
922 ScChangeAction
* pAction
= pDocSh
->GetChangeAction( aCursorPos
);
925 const SfxPoolItem
* pItem
;
927 pReqArgs
->GetItemState( nSlot
, true, &pItem
) == SfxItemState::SET
&&
928 pItem
->ISA( SfxStringItem
) )
930 OUString aComment
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
931 pDocSh
->SetChangeComment( pAction
, aComment
);
936 pDocSh
->ExecuteChangeCommentDialog( pAction
, GetDialogParent() );
943 case SID_CREATE_SW_DRAWVIEW
:
944 // wird von den Forms gerufen, wenn die DrawView mit allem Zubehoer
945 // angelegt werden muss
946 if (!GetScDrawView())
948 GetViewData().GetDocShell()->MakeDrawLayer();
949 rBindings
.InvalidateAll(false);
953 case FID_PROTECT_DOC
:
955 ScDocument
* pDoc
= GetViewData().GetDocument();
959 const SfxPoolItem
* pItem
;
960 if( pReqArgs
->HasItem( FID_PROTECT_DOC
, &pItem
) &&
961 static_cast<const SfxBoolItem
*>(pItem
)->GetValue() == pDoc
->IsDocProtected() )
968 ScDocProtection
* pProtect
= pDoc
->GetDocProtection();
969 if (pProtect
&& pProtect
->isProtected())
971 bool bCancel
= false;
974 if (pProtect
->isProtectedWithPass())
976 OUString
aText(ScResId(SCSTR_PASSWORD
));
978 VclPtrInstance
< SfxPasswordDialog
> pDlg(GetDialogParent(), &aText
);
979 pDlg
->SetText( ScResId(SCSTR_UNPROTECTDOC
) );
980 pDlg
->SetMinLen( 0 );
981 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC
)->GetCommand() );
982 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
984 if (pDlg
->Execute() == RET_OK
)
985 aPassword
= pDlg
->GetPassword();
991 Unprotect( TABLEID_DOC
, aPassword
);
992 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, false ) );
998 OUString
aText(ScResId(SCSTR_PASSWORDOPT
));
1000 VclPtrInstance
< SfxPasswordDialog
> pDlg(GetDialogParent(), &aText
);
1001 pDlg
->SetText( ScResId(SCSTR_PROTECTDOC
) );
1002 pDlg
->SetMinLen( 0 );
1003 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_DOC
)->GetCommand() );
1004 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
1005 pDlg
->ShowExtras( SfxShowExtras::CONFIRM
);
1007 if (pDlg
->Execute() == RET_OK
)
1009 OUString aPassword
= pDlg
->GetPassword();
1010 Protect( TABLEID_DOC
, aPassword
);
1011 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, true ) );
1015 rBindings
.Invalidate( FID_PROTECT_DOC
);
1019 case FID_PROTECT_TABLE
:
1021 ScDocument
* pDoc
= GetViewData().GetDocument();
1022 SCTAB nTab
= GetViewData().GetTabNo();
1023 bool bOldProtection
= pDoc
->IsTabProtected(nTab
);
1027 const SfxPoolItem
* pItem
;
1028 bool bNewProtection
= !bOldProtection
;
1029 if( pReqArgs
->HasItem( FID_PROTECT_TABLE
, &pItem
) )
1030 bNewProtection
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1031 if( bNewProtection
== bOldProtection
)
1040 // Unprotect a protected sheet.
1042 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1043 if (pProtect
&& pProtect
->isProtectedWithPass())
1045 OUString
aText( ScResId(SCSTR_PASSWORDOPT
) );
1046 VclPtrInstance
< SfxPasswordDialog
> pDlg(GetDialogParent(), &aText
);
1047 pDlg
->SetText( ScResId(SCSTR_UNPROTECTTAB
) );
1048 pDlg
->SetMinLen( 0 );
1049 pDlg
->SetHelpId( GetStaticInterface()->GetSlot(FID_PROTECT_TABLE
)->GetCommand() );
1050 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1052 if (pDlg
->Execute() == RET_OK
)
1054 OUString aPassword
= pDlg
->GetPassword();
1055 Unprotect(nTab
, aPassword
);
1059 // this sheet is not password-protected.
1060 Unprotect(nTab
, OUString());
1064 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
1070 // Protect a current sheet.
1072 VclPtrInstance
< ScTableProtectionDlg
> pDlg(GetDialogParent());
1074 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1076 pDlg
->SetDialogData(*pProtect
);
1078 if (pDlg
->Execute() == RET_OK
)
1080 pScMod
->InputEnterHandler();
1082 ScTableProtection aNewProtect
;
1083 pDlg
->WriteData(aNewProtect
);
1084 ProtectSheet(nTab
, aNewProtect
);
1087 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, true) );
1093 UpdateInputHandler(true); // damit sofort wieder eingegeben werden kann
1098 case SID_OPT_LOCALE_CHANGED
:
1099 { // locale changed, SYSTEM number formats changed => repaint cell contents
1106 OSL_FAIL("Unknown Slot at ScTabViewShell::Execute");
1111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */