1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabvwsh3.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include "scitems.hxx"
39 #include <svx/eeitem.hxx>
40 #include <svx/svdmark.hxx>
41 #include <svx/svdoole2.hxx>
42 #include <svx/svdview.hxx>
44 #include <sfx2/app.hxx>
45 //CHINA001 #include <svx/zoom.hxx>
46 #include <sfx2/bindings.hxx>
47 #include <sfx2/dispatch.hxx>
48 #include <sfx2/passwd.hxx>
49 #include <sfx2/request.hxx>
50 #include <sfx2/topfrm.hxx>
51 #include <svtools/ptitem.hxx>
52 #include <svtools/stritem.hxx>
53 #include <tools/urlobj.hxx>
55 #include <vcl/msgbox.hxx>
56 #include <vcl/vclenum.hxx>
58 #include <com/sun/star/embed/EmbedVerbs.hpp>
60 #include "globstr.hrc"
62 #include "appoptio.hxx"
63 #include "tabvwsh.hxx"
64 #include "document.hxx"
66 #include "inputwin.hxx"
67 #include "scresid.hxx"
68 #include "printfun.hxx"
70 #include "rangelst.hxx"
71 #include "prevwsh.hxx"
72 #include "rangeutl.hxx"
73 #include "reffact.hxx"
74 #include "uiitems.hxx"
76 #include "inputhdl.hxx"
77 //CHINA001 #include "scendlg.hxx"
78 //CHINA001 #include "mtrindlg.hxx"
79 #include "autoform.hxx"
80 #include "autofmt.hxx"
81 #include "dwfunctr.hxx"
82 #include "shtabdlg.hxx"
83 #include "tabprotection.hxx"
84 #include "protectiondlg.hxx"
86 #include <svtools/ilstitem.hxx>
87 #define _SVSTDARR_ULONGS
88 #include <svtools/svstdarr.hxx>
90 #include <svx/zoomslideritem.hxx>
91 #include <svx/svxdlg.hxx> //CHINA001
92 #include <svx/dialogs.hrc> //CHINA001
93 #include "scabstdlg.hxx" //CHINA001
97 using ::std::auto_ptr
;
99 #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
100 #define IS_AVAILABLE(WhichId,ppItem) \
101 (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
102 #define GET_STRING(nid) ((const SfxStringItem&)pReqArgs->Get(nid)).GetValue()
103 #define GET_UINT16(nid) ((const SfxUInt16Item&)pReqArgs->Get(nid)).GetValue()
104 #define GET_BOOL(nid) ((const SfxBoolItem&)pReqArgs->Get(nid)).GetValue()
105 #define RECALC_PAGE(pDocSh) ScPrintFunc( pDocSh, GetPrinter(), nCurTab ).UpdatePages()
107 using namespace com::sun::star
;
109 //------------------------------------------------------------------
111 /** Try to parse the given range using Calc-style syntax first, then
112 Excel-style if that fails. */
113 USHORT
lcl_ParseRange(ScRange
& rScRange
, const String
& aAddress
, ScDocument
* pDoc
, USHORT
/* nSlot */)
115 USHORT nResult
= rScRange
.Parse(aAddress
, pDoc
);
116 if ( (nResult
& SCA_VALID
) )
119 return rScRange
.Parse(aAddress
, pDoc
, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1
, 0, 0));
122 /** Try to parse the given address using Calc-style syntax first, then
123 Excel-style if that fails. */
124 USHORT
lcl_ParseAddress(ScAddress
& rScAddress
, const String
& aAddress
, ScDocument
* pDoc
, USHORT
/* nSlot */)
126 USHORT nResult
= rScAddress
.Parse(aAddress
, pDoc
);
127 if ( (nResult
& SCA_VALID
) )
130 return rScAddress
.Parse(aAddress
, pDoc
, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1
, 0, 0));
133 void ScTabViewShell::Execute( SfxRequest
& rReq
)
135 SfxViewFrame
* pThisFrame
= GetViewFrame();
136 SfxBindings
& rBindings
= pThisFrame
->GetBindings();
137 ScModule
* pScMod
= SC_MOD();
138 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
139 USHORT nSlot
= rReq
.GetSlot();
141 if (nSlot
!= SID_CURRENTCELL
) // der kommt beim MouseButtonUp
142 HideListBox(); // Autofilter-DropDown-Listbox
146 case FID_INSERT_FILE
:
148 const SfxPoolItem
* pItem
;
150 pReqArgs
->GetItemState(FID_INSERT_FILE
,TRUE
,&pItem
) == SFX_ITEM_SET
)
152 String aFileName
= ((const SfxStringItem
*)pItem
)->GetValue();
157 if ( pReqArgs
->GetItemState(FN_PARAM_1
,TRUE
,&pItem
) == SFX_ITEM_SET
)
158 aInsertPos
= ((const SfxPointItem
*)pItem
)->GetValue();
160 aInsertPos
= GetInsertPos();
164 BOOL bAsLink
= FALSE
;
165 if ( pReqArgs
->GetItemState(FN_PARAM_2
,TRUE
,&pItem
) == SFX_ITEM_SET
)
166 bAsLink
= ((const SfxBoolItem
*)pItem
)->GetValue();
170 PasteFile( aInsertPos
, aFileName
, bAsLink
);
175 case SID_OPENDLG_EDIT_PRINTAREA
:
177 USHORT nId
= ScPrintAreasDlgWrapper::GetChildWindowId();
178 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
180 pScMod
->SetRefDialog( nId
, pWnd
? FALSE
: TRUE
);
184 case SID_CHANGE_PRINTAREA
:
186 if ( pReqArgs
) // OK aus Dialog
191 BOOL bEntire
= FALSE
;
192 const SfxPoolItem
* pItem
;
193 if ( pReqArgs
->GetItemState( SID_CHANGE_PRINTAREA
, TRUE
, &pItem
) == SFX_ITEM_SET
)
194 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
195 if ( pReqArgs
->GetItemState( FN_PARAM_2
, TRUE
, &pItem
) == SFX_ITEM_SET
)
196 aRowStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
197 if ( pReqArgs
->GetItemState( FN_PARAM_3
, TRUE
, &pItem
) == SFX_ITEM_SET
)
198 aColStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
199 if ( pReqArgs
->GetItemState( FN_PARAM_4
, TRUE
, &pItem
) == SFX_ITEM_SET
)
200 bEntire
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
202 SetPrintRanges( bEntire
, &aPrintStr
, &aColStr
, &aRowStr
, FALSE
);
209 case SID_ADD_PRINTAREA
:
210 case SID_DEFINE_PRINTAREA
: // Menue oder Basic
212 BOOL bAdd
= ( nSlot
== SID_ADD_PRINTAREA
);
216 const SfxPoolItem
* pItem
;
217 if ( pReqArgs
->GetItemState( SID_DEFINE_PRINTAREA
, TRUE
, &pItem
) == SFX_ITEM_SET
)
218 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
219 SetPrintRanges( FALSE
, &aPrintStr
, NULL
, NULL
, bAdd
);
223 SetPrintRanges( FALSE
, NULL
, NULL
, NULL
, bAdd
); // aus Selektion
229 case SID_DELETE_PRINTAREA
:
232 SetPrintRanges( FALSE
, &aEmpty
, NULL
, NULL
, FALSE
); // Druckbereich loeschen
237 case FID_DEL_MANUALBREAKS
:
238 RemoveManualBreaks();
242 case FID_ADJUST_PRINTZOOM
:
247 case FID_RESET_PRINTZOOM
:
248 SetPrintZoom( 100, 0 ); // 100%, nicht auf Seiten
253 case SID_STATUS_PAGESTYLE
:
255 GetViewData()->GetDocShell()->
256 ExecutePageStyle( *this, rReq
, GetViewData()->GetTabNo() );
260 case SID_CURRENTCELL
:
264 const SfxPoolItem
* pItem
;
265 if ( pReqArgs
->GetItemState( nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
266 aAddress
= ((const SfxStringItem
*)pItem
)->GetValue();
267 else if ( nSlot
== SID_JUMPTOMARK
&& pReqArgs
->GetItemState(
268 SID_JUMPTOMARK
, TRUE
, &pItem
) == SFX_ITEM_SET
)
269 aAddress
= ((const SfxStringItem
*)pItem
)->GetValue();
271 // #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
272 // isn't set (for recorded macros, because IsAPI is no longer available).
273 // ScGridWindow::MouseButtonUp no longer executes the slot for a single
274 // cell if there is a multi selection.
275 BOOL bUnmark
= ( nSlot
== SID_CURRENTCELL
);
276 if ( pReqArgs
->GetItemState( FN_PARAM_1
, TRUE
, &pItem
) == SFX_ITEM_SET
)
277 bUnmark
= ((const SfxBoolItem
*)pItem
)->GetValue();
279 bool bAlignToCursor
= true;
280 if (pReqArgs
->GetItemState(FN_PARAM_2
, true, &pItem
) == SFX_ITEM_SET
)
281 bAlignToCursor
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
283 if ( nSlot
== SID_JUMPTOMARK
)
285 // #106586# URL has to be decoded for escaped characters (%20)
286 aAddress
= INetURLObject::decode( aAddress
, INET_HEX_ESCAPE
,
287 INetURLObject::DECODE_WITH_CHARSET
,
288 RTL_TEXTENCODING_UTF8
);
292 ScViewData
* pViewData
= GetViewData();
293 ScDocument
* pDoc
= pViewData
->GetDocument();
294 ScMarkData
& rMark
= pViewData
->GetMarkData();
296 ScAddress aScAddress
;
297 USHORT nResult
= lcl_ParseRange(aScRange
, aAddress
, pDoc
, nSlot
);
298 SCTAB nTab
= pViewData
->GetTabNo();
302 if( nResult
& SCA_VALID
)
304 if ( nResult
& SCA_TAB_3D
)
306 if( aScRange
.aStart
.Tab() != nTab
)
307 SetTabNo( nTab
= aScRange
.aStart
.Tab() );
311 aScRange
.aStart
.SetTab( nTab
);
312 aScRange
.aEnd
.SetTab( nTab
);
316 else if ( (nResult
= lcl_ParseAddress(aScAddress
, aAddress
, pDoc
, nSlot
)) & SCA_VALID
)
318 if ( nResult
& SCA_TAB_3D
)
320 if( aScAddress
.Tab() != nTab
)
321 SetTabNo( nTab
= aScAddress
.Tab() );
324 aScAddress
.SetTab( nTab
);
326 aScRange
= ScRange( aScAddress
, aScAddress
);
327 // Zellen sollen nicht markiert werden
330 // Ist es benahmster Bereich (erst Namen dann DBBereiche) ?
333 ScRangeUtil aRangeUtil
;
334 formula::FormulaGrammar::AddressConvention eConv
= pDoc
->GetAddressConvention();
335 if( aRangeUtil
.MakeRangeFromName( aAddress
, pDoc
, nTab
, aScRange
, RUTL_NAMES
, eConv
) ||
336 aRangeUtil
.MakeRangeFromName( aAddress
, pDoc
, nTab
, aScRange
, RUTL_DBASE
, eConv
) )
338 nResult
|= SCA_VALID
;
339 if( aScRange
.aStart
.Tab() != nTab
)
340 SetTabNo( nTab
= aScRange
.aStart
.Tab() );
344 if ( !(nResult
& SCA_VALID
) &&
345 ByteString(aAddress
, RTL_TEXTENCODING_ASCII_US
).IsNumericAscii() )
347 sal_Int32 nNumeric
= aAddress
.ToInt32();
348 if ( nNumeric
> 0 && nNumeric
<= MAXROW
+1 )
350 // 1-basierte Zeilennummer
352 aScAddress
.SetRow( (SCROW
)(nNumeric
- 1) );
353 aScAddress
.SetCol( pViewData
->GetCurX() );
354 aScAddress
.SetTab( nTab
);
355 aScRange
= ScRange( aScAddress
, aScAddress
);
361 if ( !ValidRow(aScRange
.aStart
.Row()) || !ValidRow(aScRange
.aEnd
.Row()) )
364 // wir haben was gefunden
365 if( nResult
& SCA_VALID
)
368 SCCOL nCol
= aScRange
.aStart
.Col();
369 SCROW nRow
= aScRange
.aStart
.Row();
370 BOOL bNothing
= ( pViewData
->GetCurX()==nCol
&& pViewData
->GetCurY()==nRow
);
375 if (rMark
.IsMarked()) // ist derselbe Bereich schon markiert?
378 rMark
.GetMarkArea( aOldMark
);
380 ScRange aCurrent
= aScRange
;
382 bNothing
= ( aCurrent
== aOldMark
);
388 MarkRange( aScRange
, FALSE
); // Cursor kommt hinterher...
392 // remove old selection, unless bUnmark argument is FALSE (from navigator)
395 MoveCursorAbs( nCol
, nRow
,
396 SC_FOLLOW_NONE
, FALSE
, FALSE
);
402 // zusammengefasste Zellen beruecksichtigen:
403 pDoc
->SkipOverlapped(nCol
, nRow
, nTab
);
405 // Navigator-Aufrufe sind nicht API!!!
410 rReq
.Ignore(); // wenn Makro, dann gar nix
412 rReq
.Done(); // sonst wenigstens aufzeichnen
416 pViewData
->ResetOldCursor();
417 SetCursor( nCol
, nRow
);
418 rBindings
.Invalidate( SID_CURRENTCELL
);
419 rBindings
.Update( nSlot
);
427 // align to cursor even if the cursor position hasn't changed,
428 // because the cursor may be set outside the visible area.
429 AlignToCursor( nCol
, nRow
, SC_FOLLOW_JUMP
);
432 rReq
.SetReturnValue( SfxStringItem( SID_CURRENTCELL
, aAddress
) );
435 if (!bFound
) // kein gueltiger Bereich
437 // wenn es ein Tabellenname ist, umschalten (fuer Navigator/URL's)
440 if ( pDoc
->GetTable( aAddress
, nNameTab
) )
443 if ( nNameTab
!= nTab
)
444 SetTabNo( nNameTab
);
448 if ( !bFound
&& nSlot
== SID_JUMPTOMARK
)
450 // Grafik-Objekte probieren (nur bei URL's)
452 bFound
= SelectObject( aAddress
);
455 if (!bFound
&& !rReq
.IsAPI())
456 ErrorMessage( STR_ERR_INVALID_AREA
);
460 case SID_CURRENTOBJECT
:
463 String aName
= ((const SfxStringItem
&)pReqArgs
->Get(nSlot
)).GetValue();
464 SelectObject( aName
);
471 // Tabelle fuer Basic ist 1-basiert
472 SCTAB nTab
= ((const SfxUInt16Item
&)pReqArgs
->Get(nSlot
)).GetValue() - 1;
473 ScDocument
* pDoc
= GetViewData()->GetDocument();
474 if ( nTab
< pDoc
->GetTableCount() )
477 rBindings
.Update( nSlot
);
489 String
aStrDocName( ((const SfxStringItem
&)pReqArgs
->
490 Get(nSlot
)).GetValue() );
492 SfxViewFrame
* pViewFrame
= NULL
;
493 ScDocShell
* pDocSh
= (ScDocShell
*)SfxObjectShell::GetFirst();
496 // zu aktivierenden ViewFrame suchen
498 while ( pDocSh
&& !bFound
)
500 if ( pDocSh
->GetTitle() == aStrDocName
)
502 pViewFrame
= SfxViewFrame::GetFirst( pDocSh
, TYPE(SfxTopViewFrame
) );
503 bFound
= ( NULL
!= pViewFrame
);
506 pDocSh
= (ScDocShell
*)SfxObjectShell::GetNext( *pDocSh
);
510 if ( pViewFrame
->ISA(SfxTopViewFrame
) )
511 pViewFrame
->GetFrame()->Appear();
513 rReq
.Ignore();//XXX wird von SFX erledigt
516 case SID_ATTR_SIZE
://XXX ???
520 case SID_PRINTPREVIEW
:
522 if ( !pThisFrame
->GetFrame()->IsInPlace() ) // nicht bei OLE
524 // print preview is now always in the same frame as the tab view
525 // -> always switch this frame back to normal view
526 // (ScPreviewShell ctor reads view data)
528 // #102785#; finish input
529 pScMod
->InputEnterHandler();
531 pThisFrame
->GetDispatcher()->Execute( SID_VIEWSHELL1
, SFX_CALLMODE_ASYNCHRON
);
533 // else Fehler (z.B. Ole)
537 case SID_DETECTIVE_DEL_ALL
:
542 // SID_TABLE_ACTIVATE und SID_MARKAREA werden von Basic aus an der versteckten
543 // View aufgerufen, um auf der sichtbaren View zu markieren/umzuschalten:
545 case SID_TABLE_ACTIVATE
:
546 DBG_ERROR("old slot SID_TABLE_ACTIVATE");
557 case FID_NORMALVIEWMODE
:
558 case FID_PAGEBREAKMODE
:
560 BOOL bWantPageBreak
= nSlot
== FID_PAGEBREAKMODE
;
562 // check whether there is an explicit argument, use it
563 const SfxPoolItem
* pItem
;
564 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
566 BOOL bItemValue
= ((const SfxBoolItem
*)pItem
)->GetValue();
567 bWantPageBreak
= (nSlot
== FID_PAGEBREAKMODE
) == bItemValue
;
570 if( GetViewData()->IsPagebreakMode() != bWantPageBreak
)
572 SetPagebreakMode( bWantPageBreak
);
573 UpdatePageBreakData();
574 SetCurSubShell( GetCurObjectSelectionType(), TRUE
);
578 rBindings
.Invalidate( nSlot
);
579 rReq
.AppendItem( SfxBoolItem( nSlot
, TRUE
) );
585 case FID_FUNCTION_BOX
:
587 USHORT nChildId
= ScFunctionChildWindow::GetChildWindowId();
588 if ( rReq
.GetArgs() )
589 pThisFrame
->SetChildWindow( nChildId
, ((const SfxBoolItem
&) (rReq
.GetArgs()->Get(FID_FUNCTION_BOX
))).GetValue());
592 pThisFrame
->ToggleChildWindow( nChildId
);
593 rReq
.AppendItem( SfxBoolItem( FID_FUNCTION_BOX
, pThisFrame
->HasChildWindow( nChildId
) ) );
596 GetViewFrame()->GetBindings().Invalidate(FID_FUNCTION_BOX
);
602 case FID_TOGGLESYNTAX
:
604 BOOL bSet
= !GetViewData()->IsSyntaxMode();
605 const SfxPoolItem
* pItem
;
606 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
607 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
608 GetViewData()->SetSyntaxMode( bSet
);
610 rBindings
.Invalidate( FID_TOGGLESYNTAX
);
611 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
615 case FID_TOGGLEHEADERS
:
617 BOOL bSet
= !GetViewData()->IsHeaderMode();
618 const SfxPoolItem
* pItem
;
619 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
620 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
621 GetViewData()->SetHeaderMode( bSet
);
623 rBindings
.Invalidate( FID_TOGGLEHEADERS
);
624 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
629 case FID_TOGGLEFORMULA
:
631 ScViewData
* pViewData
= GetViewData();
632 const ScViewOptions
& rOpts
= pViewData
->GetOptions();
633 BOOL bFormulaMode
= !rOpts
.GetOption( VOPT_FORMULAS
);
634 const SfxPoolItem
*pItem
;
635 if( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
636 bFormulaMode
= ((const SfxBoolItem
*)pItem
)->GetValue();
638 ScViewOptions rSetOpts
= ScViewOptions( rOpts
);
639 rSetOpts
.SetOption( VOPT_FORMULAS
, bFormulaMode
);
640 pViewData
->SetOptions( rSetOpts
);
642 pViewData
->GetDocShell()->PostPaintGridAll();
644 rBindings
.Invalidate( FID_TOGGLEFORMULA
);
645 rReq
.AppendItem( SfxBoolItem( nSlot
, bFormulaMode
) );
650 case FID_TOGGLEINPUTLINE
:
652 USHORT nId
= ScInputWindowWrapper::GetChildWindowId();
653 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
654 BOOL bSet
= ( pWnd
== NULL
);
655 const SfxPoolItem
* pItem
;
656 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
)
657 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
659 pThisFrame
->SetChildWindow( nId
, bSet
);
660 rBindings
.Invalidate( FID_TOGGLEINPUTLINE
);
661 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
666 case SID_ATTR_ZOOM
: // Statuszeile
669 BOOL bSyncZoom
= SC_MOD()->GetAppOptions().GetSynchronizeZoom();
670 SvxZoomType eOldZoomType
= GetZoomType();
671 SvxZoomType eNewZoomType
= eOldZoomType
;
672 const Fraction
& rOldY
= GetViewData()->GetZoomY(); // Y wird angezeigt
673 USHORT nOldZoom
= (USHORT
)(( rOldY
.GetNumerator() * 100 )
674 / rOldY
.GetDenominator());
675 USHORT nZoom
= nOldZoom
;
676 BOOL bCancel
= FALSE
;
680 const SvxZoomItem
& rZoomItem
= (const SvxZoomItem
&)
681 pReqArgs
->Get(SID_ATTR_ZOOM
);
683 eNewZoomType
= rZoomItem
.GetType();
684 nZoom
= rZoomItem
.GetValue();
688 SfxItemSet
aSet ( GetPool(), SID_ATTR_ZOOM
, SID_ATTR_ZOOM
);
689 SvxZoomItem
aZoomItem( eOldZoomType
, nOldZoom
, SID_ATTR_ZOOM
);
690 //CHINA001 SvxZoomDialog* pDlg = NULL;
691 AbstractSvxZoomDialog
* pDlg
= NULL
;
692 ScMarkData
& rMark
= GetViewData()->GetMarkData();
693 USHORT nBtnFlags
= SVX_ZOOM_ENABLE_50
695 | SVX_ZOOM_ENABLE_100
696 | SVX_ZOOM_ENABLE_150
697 | SVX_ZOOM_ENABLE_200
698 | SVX_ZOOM_ENABLE_WHOLEPAGE
699 | SVX_ZOOM_ENABLE_PAGEWIDTH
;
701 if ( rMark
.IsMarked() || rMark
.IsMultiMarked() )
702 nBtnFlags
= nBtnFlags
| SVX_ZOOM_ENABLE_OPTIMAL
;
704 aZoomItem
.SetValueSet( nBtnFlags
);
705 aSet
.Put( aZoomItem
);
706 //CHINA001 pDlg = new SvxZoomDialog( GetDialogParent(), aSet );
707 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
710 pDlg
= pFact
->CreateSvxZoomDialog(GetDialogParent(), aSet
, RID_SVXDLG_ZOOM
);
711 DBG_ASSERT(pDlg
, "Dialogdiet fail!");//CHINA001
713 pDlg
->SetLimits( MINZOOM
, MAXZOOM
);
715 bCancel
= ( RET_CANCEL
== pDlg
->Execute() );
719 const SvxZoomItem
& rZoomItem
= (const SvxZoomItem
&)
720 pDlg
->GetOutputItemSet()->
721 Get( SID_ATTR_ZOOM
);
723 eNewZoomType
= rZoomItem
.GetType();
724 nZoom
= rZoomItem
.GetValue();
732 if ( eNewZoomType
== SVX_ZOOM_PERCENT
)
734 if ( nZoom
< MINZOOM
) nZoom
= MINZOOM
;
735 if ( nZoom
> MAXZOOM
) nZoom
= MAXZOOM
;
739 nZoom
= CalcZoom( eNewZoomType
, nOldZoom
);
740 bCancel
= nZoom
== 0;
743 switch ( eNewZoomType
)
745 case SVX_ZOOM_WHOLEPAGE
:
746 case SVX_ZOOM_PAGEWIDTH
:
747 SetZoomType( eNewZoomType
, bSyncZoom
);
751 SetZoomType( SVX_ZOOM_PERCENT
, bSyncZoom
);
755 if ( nZoom
!= nOldZoom
&& !bCancel
)
757 if (!GetViewData()->IsPagebreakMode())
759 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
760 aNewOpt
.SetZoom( nZoom
);
761 aNewOpt
.SetZoomType( GetZoomType() );
762 pScMod
->SetAppOptions( aNewOpt
);
764 Fraction
aFract( nZoom
, 100 );
765 SetZoom( aFract
, aFract
, bSyncZoom
);
769 rBindings
.Invalidate( SID_ATTR_ZOOM
);
770 rReq
.AppendItem( SvxZoomItem( GetZoomType(), nZoom
, nSlot
) );
776 case SID_ATTR_ZOOMSLIDER
:
778 const SfxPoolItem
* pItem
= NULL
;
779 BOOL bSyncZoom
= SC_MOD()->GetAppOptions().GetSynchronizeZoom();
780 if ( pReqArgs
&& pReqArgs
->GetItemState(SID_ATTR_ZOOMSLIDER
, TRUE
, &pItem
) == SFX_ITEM_SET
)
782 const USHORT nCurrentZoom
= ((const SvxZoomSliderItem
*)pItem
)->GetValue();
785 SetZoomType( SVX_ZOOM_PERCENT
, bSyncZoom
);
786 if (!GetViewData()->IsPagebreakMode())
788 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
789 aNewOpt
.SetZoom( nCurrentZoom
);
790 aNewOpt
.SetZoomType( GetZoomType() );
791 pScMod
->SetAppOptions( aNewOpt
);
793 Fraction
aFract( nCurrentZoom
,100 );
794 SetZoom( aFract
, aFract
, bSyncZoom
);
798 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
805 //----------------------------------------------------------------
807 case FID_TAB_SELECTALL
:
812 case SID_SELECT_TABLES
:
814 ScViewData
& rViewData
= *GetViewData();
815 ScDocument
& rDoc
= *rViewData
.GetDocument();
816 ScMarkData
& rMark
= rViewData
.GetMarkData();
817 SCTAB nTabCount
= rDoc
.GetTableCount();
820 SvULongs
aIndexList( 4, 4 );
821 SFX_REQUEST_ARG( rReq
, pItem
, SfxIntegerListItem
, SID_SELECT_TABLES
, sal_False
);
823 pItem
->GetList( aIndexList
);
826 //CHINA001 ScShowTabDlg* pDlg = new ScShowTabDlg( GetDialogParent() );
827 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
828 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
830 AbstractScShowTabDlg
* pDlg
= pFact
->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB
);
831 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
832 pDlg
->SetDescription(
833 String( ScResId( STR_DLG_SELECTTABLES_TITLE
) ),
834 String( ScResId( STR_DLG_SELECTTABLES_LBNAME
) ),
835 SID_SELECT_TABLES
, HID_SELECTTABLES
);
837 // fill all table names with selection state
839 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
841 rDoc
.GetName( nTab
, aTabName
);
842 pDlg
->Insert( aTabName
, rMark
.GetTableSelect( nTab
) );
845 if( pDlg
->Execute() == RET_OK
)
847 sal_uInt16 nSelCount
= pDlg
->GetSelectEntryCount();
849 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
850 aIndexList
.Insert( pDlg
->GetSelectEntryPos( nSelIx
), nSelIx
);
852 rReq
.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES
, aIndexList
) );
858 if ( aIndexList
.Count() )
860 sal_uInt16 nSelCount
= aIndexList
.Count();
862 SCTAB nFirstVisTab
= 0;
864 // special case: only hidden tables selected -> do nothing
865 sal_Bool bVisSelected
= sal_False
;
866 for( nSelIx
= 0; !bVisSelected
&& (nSelIx
< nSelCount
); ++nSelIx
)
867 bVisSelected
= rDoc
.IsVisible( nFirstVisTab
= static_cast<SCTAB
>(aIndexList
[nSelIx
]) );
874 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
875 rMark
.SelectTable( nTab
, sal_False
);
877 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
878 rMark
.SelectTable( static_cast<SCTAB
>(aIndexList
[nSelIx
]), sal_True
);
880 // activate another table, if current is deselected
881 if( !rMark
.GetTableSelect( rViewData
.GetTabNo() ) )
883 rMark
.SelectTable( nFirstVisTab
, sal_True
);
884 SetTabNo( nFirstVisTab
);
887 rViewData
.GetDocShell()->PostPaintExtras();
888 rViewData
.GetBindings().Invalidate( FID_FILL_TAB
);
897 case SID_OUTLINE_DELETEALL
:
902 case SID_AUTO_OUTLINE
:
908 case SID_WINDOW_SPLIT
:
910 ScSplitMode eHSplit
= GetViewData()->GetHSplitMode();
911 ScSplitMode eVSplit
= GetViewData()->GetVSplitMode();
912 if ( eHSplit
== SC_SPLIT_NORMAL
|| eVSplit
== SC_SPLIT_NORMAL
) // aufheben
914 else if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // normal
915 FreezeSplitters( FALSE
);
926 ScSplitMode eHSplit
= GetViewData()->GetHSplitMode();
927 ScSplitMode eVSplit
= GetViewData()->GetVSplitMode();
928 if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // aufheben
931 FreezeSplitters( TRUE
); // erzeugen oder fixieren
938 // ----------------------------------------------------------------
942 USHORT nId
= ScHighlightChgDlgWrapper::GetChildWindowId();
943 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
945 pScMod
->SetRefDialog( nId
, pWnd
? FALSE
: TRUE
);
951 pThisFrame
->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
952 GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT
);
956 USHORT nId = ScAcceptChgDlgWrapper::GetChildWindowId();
957 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
959 pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
964 case FID_CHG_COMMENT
:
966 ScViewData
* pData
= GetViewData();
967 ScAddress
aCursorPos( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
968 ScDocShell
* pDocSh
= pData
->GetDocShell();
970 ScChangeAction
* pAction
= pDocSh
->GetChangeAction( aCursorPos
);
973 const SfxPoolItem
* pItem
;
975 pReqArgs
->GetItemState( nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
&&
976 pItem
->ISA( SfxStringItem
) )
978 String aComment
= ((const SfxStringItem
*)pItem
)->GetValue();
979 pDocSh
->SetChangeComment( pAction
, aComment
);
984 pDocSh
->ExecuteChangeCommentDialog( pAction
, GetDialogParent() );
991 case SID_CREATE_SW_DRAWVIEW
:
992 // wird von den Forms gerufen, wenn die DrawView mit allem Zubehoer
993 // angelegt werden muss
994 if (!GetScDrawView())
996 GetViewData()->GetDocShell()->MakeDrawLayer();
997 rBindings
.InvalidateAll(FALSE
);
1001 case FID_PROTECT_DOC
:
1003 ScDocument
* pDoc
= GetViewData()->GetDocument();
1004 SfxPasswordDialog
* pDlg
;
1008 const SfxPoolItem
* pItem
;
1009 if( IS_AVAILABLE( FID_PROTECT_DOC
, &pItem
) &&
1010 ((const SfxBoolItem
*)pItem
)->GetValue() == pDoc
->IsDocProtected() )
1017 ScDocProtection
* pProtect
= pDoc
->GetDocProtection();
1018 if (pProtect
&& pProtect
->isProtected())
1020 BOOL bCancel
= FALSE
;
1023 if (pProtect
->isProtectedWithPass())
1025 String
aText( ScResId(SCSTR_PASSWORD
) );
1027 pDlg
= new SfxPasswordDialog( GetDialogParent(), &aText
);
1028 pDlg
->SetText( ScResId(SCSTR_UNPROTECTDOC
) );
1029 pDlg
->SetMinLen( 0 );
1030 pDlg
->SetHelpId( FID_PROTECT_DOC
);
1031 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
1033 if (pDlg
->Execute() == RET_OK
)
1034 aPassword
= pDlg
->GetPassword();
1041 Unprotect( TABLEID_DOC
, aPassword
);
1042 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, FALSE
) );
1048 String
aText( ScResId(SCSTR_PASSWORDOPT
) );
1050 pDlg
= new SfxPasswordDialog( GetDialogParent(), &aText
);
1051 pDlg
->SetText( ScResId(SCSTR_PROTECTDOC
) );
1052 pDlg
->SetMinLen( 0 );
1053 pDlg
->SetHelpId( FID_PROTECT_DOC
);
1054 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
1055 pDlg
->ShowExtras( SHOWEXTRAS_CONFIRM
);
1057 if (pDlg
->Execute() == RET_OK
)
1059 String aPassword
= pDlg
->GetPassword();
1060 Protect( TABLEID_DOC
, aPassword
);
1061 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, TRUE
) );
1067 rBindings
.Invalidate( FID_PROTECT_DOC
);
1072 case FID_PROTECT_TABLE
:
1074 ScDocument
* pDoc
= GetViewData()->GetDocument();
1075 SCTAB nTab
= GetViewData()->GetTabNo();
1076 bool bOldProtection
= pDoc
->IsTabProtected(nTab
);
1078 #if ENABLE_SHEET_PROTECTION
1082 const SfxPoolItem
* pItem
;
1083 bool bNewProtection
= !bOldProtection
;
1084 if( IS_AVAILABLE( FID_PROTECT_TABLE
, &pItem
) )
1085 bNewProtection
= ((const SfxBoolItem
*)pItem
)->GetValue();
1086 if( bNewProtection
== bOldProtection
)
1095 // Unprotect a protected sheet.
1097 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1098 if (pProtect
&& pProtect
->isProtectedWithPass())
1100 String
aText( ScResId(SCSTR_PASSWORDOPT
) );
1101 auto_ptr
<SfxPasswordDialog
> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText
));
1102 pDlg
->SetText( ScResId(SCSTR_UNPROTECTTAB
) );
1103 pDlg
->SetMinLen( 0 );
1104 pDlg
->SetHelpId( FID_PROTECT_TABLE
);
1105 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1107 if (pDlg
->Execute() == RET_OK
)
1109 String aPassword
= pDlg
->GetPassword();
1110 Unprotect(nTab
, aPassword
);
1114 // this sheet is not password-protected.
1115 Unprotect(nTab
, String());
1119 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
1125 // Protect a current sheet.
1127 auto_ptr
<ScTableProtectionDlg
> pDlg(new ScTableProtectionDlg(GetDialogParent()));
1129 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1131 pDlg
->SetDialogData(*pProtect
);
1133 if (pDlg
->Execute() == RET_OK
)
1135 pScMod
->InputEnterHandler();
1137 ScTableProtection aNewProtect
;
1138 pDlg
->WriteData(aNewProtect
);
1139 ProtectSheet(nTab
, aNewProtect
);
1142 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, true) );
1148 auto_ptr
<SfxPasswordDialog
> pDlg
;
1150 BOOL bCancel
= FALSE
;
1151 BOOL bNewProtection
= ! bOldProtection
;
1155 const SfxPoolItem
* pItem
;
1156 if( IS_AVAILABLE( FID_PROTECT_TABLE
, &pItem
) )
1157 bNewProtection
= ((const SfxBoolItem
*)pItem
)->GetValue();
1158 if( bNewProtection
== bOldProtection
)
1165 if ( bOldProtection
)
1167 // Unprotect a protected sheet.
1169 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1170 if (pProtect
&& pProtect
->isProtectedWithPass())
1172 String
aText( ScResId(SCSTR_PASSWORDOPT
) );
1173 pDlg
.reset(new SfxPasswordDialog(GetDialogParent(), &aText
));
1174 pDlg
->SetText( ScResId(SCSTR_UNPROTECTTAB
) );
1175 pDlg
->SetMinLen( 0 );
1176 pDlg
->SetHelpId( FID_PROTECT_TABLE
);
1177 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1179 if (pDlg
->Execute() == RET_OK
)
1180 aPassword
= pDlg
->GetPassword();
1187 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
1193 String
aText( ScResId(SCSTR_PASSWORDOPT
) );
1195 pDlg
.reset(new SfxPasswordDialog(GetDialogParent(), &aText
));
1196 pDlg
->SetText( ScResId(SCSTR_PROTECTTAB
) );
1197 pDlg
->SetMinLen( 0 );
1198 pDlg
->SetHelpId( FID_PROTECT_TABLE
);
1199 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1200 pDlg
->ShowExtras( SHOWEXTRAS_CONFIRM
);
1202 if (pDlg
->Execute() == RET_OK
)
1203 aPassword
= pDlg
->GetPassword();
1210 if ( bOldProtection
)
1211 Unprotect( nTab
, aPassword
);
1214 pScMod
->InputEnterHandler();
1216 Protect( nTab
, aPassword
);
1221 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_TABLE
, bNewProtection
) );
1227 UpdateInputHandler(true); // damit sofort wieder eingegeben werden kann
1232 case SID_OPT_LOCALE_CHANGED
:
1233 { // locale changed, SYSTEM number formats changed => repaint cell contents
1239 case SID_OUTPLACE_OBJECT
:
1240 case SID_INPLACE_OBJECT
:
1242 SdrView
* pDrView
= GetSdrView();
1245 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
1246 if (rMarkList
.GetMarkCount() == 1)
1248 BOOL bOle
= GetViewFrame()->GetFrame()->IsInPlace();
1249 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
1250 if( pObj
&& pObj
->ISA( SdrOle2Obj
) && !bOle
)
1252 if( nSlot
== SID_OUTPLACE_OBJECT
)
1253 ActivateObject( static_cast< SdrOle2Obj
* >( pObj
),
1254 embed::EmbedVerbs::MS_OLEVERB_OPEN
);
1256 ActivateObject( static_cast< SdrOle2Obj
* >( pObj
),
1257 embed::EmbedVerbs::MS_OLEVERB_PRIMARY
);
1265 DBG_ERROR("Unbekannter Slot bei ScTabViewShell::Execute");