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 FID_TAB_DESELECTALL
:
817 case SID_SELECT_TABLES
:
819 ScViewData
& rViewData
= *GetViewData();
820 ScDocument
& rDoc
= *rViewData
.GetDocument();
821 ScMarkData
& rMark
= rViewData
.GetMarkData();
822 SCTAB nTabCount
= rDoc
.GetTableCount();
825 SvULongs
aIndexList( 4, 4 );
826 SFX_REQUEST_ARG( rReq
, pItem
, SfxIntegerListItem
, SID_SELECT_TABLES
, sal_False
);
828 pItem
->GetList( aIndexList
);
831 //CHINA001 ScShowTabDlg* pDlg = new ScShowTabDlg( GetDialogParent() );
832 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
833 DBG_ASSERT(pFact
, "ScAbstractFactory create fail!");//CHINA001
835 AbstractScShowTabDlg
* pDlg
= pFact
->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB
);
836 DBG_ASSERT(pDlg
, "Dialog create fail!");//CHINA001
837 pDlg
->SetDescription(
838 String( ScResId( STR_DLG_SELECTTABLES_TITLE
) ),
839 String( ScResId( STR_DLG_SELECTTABLES_LBNAME
) ),
840 SID_SELECT_TABLES
, HID_SELECTTABLES
);
842 // fill all table names with selection state
844 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
846 rDoc
.GetName( nTab
, aTabName
);
847 pDlg
->Insert( aTabName
, rMark
.GetTableSelect( nTab
) );
850 if( pDlg
->Execute() == RET_OK
)
852 sal_uInt16 nSelCount
= pDlg
->GetSelectEntryCount();
854 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
855 aIndexList
.Insert( pDlg
->GetSelectEntryPos( nSelIx
), nSelIx
);
857 rReq
.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES
, aIndexList
) );
863 if ( aIndexList
.Count() )
865 sal_uInt16 nSelCount
= aIndexList
.Count();
867 SCTAB nFirstVisTab
= 0;
869 // special case: only hidden tables selected -> do nothing
870 sal_Bool bVisSelected
= sal_False
;
871 for( nSelIx
= 0; !bVisSelected
&& (nSelIx
< nSelCount
); ++nSelIx
)
872 bVisSelected
= rDoc
.IsVisible( nFirstVisTab
= static_cast<SCTAB
>(aIndexList
[nSelIx
]) );
879 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
880 rMark
.SelectTable( nTab
, sal_False
);
882 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
883 rMark
.SelectTable( static_cast<SCTAB
>(aIndexList
[nSelIx
]), sal_True
);
885 // activate another table, if current is deselected
886 if( !rMark
.GetTableSelect( rViewData
.GetTabNo() ) )
888 rMark
.SelectTable( nFirstVisTab
, sal_True
);
889 SetTabNo( nFirstVisTab
);
892 rViewData
.GetDocShell()->PostPaintExtras();
893 SfxBindings
& rBind
= rViewData
.GetBindings();
894 rBind
.Invalidate( FID_FILL_TAB
);
895 rBind
.Invalidate( FID_TAB_DESELECTALL
);
904 case SID_OUTLINE_DELETEALL
:
909 case SID_AUTO_OUTLINE
:
915 case SID_WINDOW_SPLIT
:
917 ScSplitMode eHSplit
= GetViewData()->GetHSplitMode();
918 ScSplitMode eVSplit
= GetViewData()->GetVSplitMode();
919 if ( eHSplit
== SC_SPLIT_NORMAL
|| eVSplit
== SC_SPLIT_NORMAL
) // aufheben
921 else if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // normal
922 FreezeSplitters( FALSE
);
933 ScSplitMode eHSplit
= GetViewData()->GetHSplitMode();
934 ScSplitMode eVSplit
= GetViewData()->GetVSplitMode();
935 if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // aufheben
938 FreezeSplitters( TRUE
); // erzeugen oder fixieren
945 // ----------------------------------------------------------------
949 USHORT nId
= ScHighlightChgDlgWrapper::GetChildWindowId();
950 SfxChildWindow
* pWnd
= pThisFrame
->GetChildWindow( nId
);
952 pScMod
->SetRefDialog( nId
, pWnd
? FALSE
: TRUE
);
958 pThisFrame
->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
959 GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT
);
963 USHORT nId = ScAcceptChgDlgWrapper::GetChildWindowId();
964 SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
966 pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
971 case FID_CHG_COMMENT
:
973 ScViewData
* pData
= GetViewData();
974 ScAddress
aCursorPos( pData
->GetCurX(), pData
->GetCurY(), pData
->GetTabNo() );
975 ScDocShell
* pDocSh
= pData
->GetDocShell();
977 ScChangeAction
* pAction
= pDocSh
->GetChangeAction( aCursorPos
);
980 const SfxPoolItem
* pItem
;
982 pReqArgs
->GetItemState( nSlot
, TRUE
, &pItem
) == SFX_ITEM_SET
&&
983 pItem
->ISA( SfxStringItem
) )
985 String aComment
= ((const SfxStringItem
*)pItem
)->GetValue();
986 pDocSh
->SetChangeComment( pAction
, aComment
);
991 pDocSh
->ExecuteChangeCommentDialog( pAction
, GetDialogParent() );
998 case SID_CREATE_SW_DRAWVIEW
:
999 // wird von den Forms gerufen, wenn die DrawView mit allem Zubehoer
1000 // angelegt werden muss
1001 if (!GetScDrawView())
1003 GetViewData()->GetDocShell()->MakeDrawLayer();
1004 rBindings
.InvalidateAll(FALSE
);
1008 case FID_PROTECT_DOC
:
1010 ScDocument
* pDoc
= GetViewData()->GetDocument();
1011 SfxPasswordDialog
* pDlg
;
1015 const SfxPoolItem
* pItem
;
1016 if( IS_AVAILABLE( FID_PROTECT_DOC
, &pItem
) &&
1017 ((const SfxBoolItem
*)pItem
)->GetValue() == pDoc
->IsDocProtected() )
1024 ScDocProtection
* pProtect
= pDoc
->GetDocProtection();
1025 if (pProtect
&& pProtect
->isProtected())
1027 BOOL bCancel
= FALSE
;
1030 if (pProtect
->isProtectedWithPass())
1032 String
aText( ScResId(SCSTR_PASSWORD
) );
1034 pDlg
= new SfxPasswordDialog( GetDialogParent(), &aText
);
1035 pDlg
->SetText( ScResId(SCSTR_UNPROTECTDOC
) );
1036 pDlg
->SetMinLen( 0 );
1037 pDlg
->SetHelpId( FID_PROTECT_DOC
);
1038 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
1040 if (pDlg
->Execute() == RET_OK
)
1041 aPassword
= pDlg
->GetPassword();
1048 Unprotect( TABLEID_DOC
, aPassword
);
1049 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, FALSE
) );
1055 String
aText( ScResId(SCSTR_PASSWORDOPT
) );
1057 pDlg
= new SfxPasswordDialog( GetDialogParent(), &aText
);
1058 pDlg
->SetText( ScResId(SCSTR_PROTECTDOC
) );
1059 pDlg
->SetMinLen( 0 );
1060 pDlg
->SetHelpId( FID_PROTECT_DOC
);
1061 pDlg
->SetEditHelpId( HID_PASSWD_DOC
);
1062 pDlg
->ShowExtras( SHOWEXTRAS_CONFIRM
);
1064 if (pDlg
->Execute() == RET_OK
)
1066 String aPassword
= pDlg
->GetPassword();
1067 Protect( TABLEID_DOC
, aPassword
);
1068 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, TRUE
) );
1074 rBindings
.Invalidate( FID_PROTECT_DOC
);
1079 case FID_PROTECT_TABLE
:
1081 ScDocument
* pDoc
= GetViewData()->GetDocument();
1082 SCTAB nTab
= GetViewData()->GetTabNo();
1083 bool bOldProtection
= pDoc
->IsTabProtected(nTab
);
1085 #if ENABLE_SHEET_PROTECTION
1089 const SfxPoolItem
* pItem
;
1090 bool bNewProtection
= !bOldProtection
;
1091 if( IS_AVAILABLE( FID_PROTECT_TABLE
, &pItem
) )
1092 bNewProtection
= ((const SfxBoolItem
*)pItem
)->GetValue();
1093 if( bNewProtection
== bOldProtection
)
1102 // Unprotect a protected sheet.
1104 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1105 if (pProtect
&& pProtect
->isProtectedWithPass())
1107 String
aText( ScResId(SCSTR_PASSWORDOPT
) );
1108 auto_ptr
<SfxPasswordDialog
> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText
));
1109 pDlg
->SetText( ScResId(SCSTR_UNPROTECTTAB
) );
1110 pDlg
->SetMinLen( 0 );
1111 pDlg
->SetHelpId( FID_PROTECT_TABLE
);
1112 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1114 if (pDlg
->Execute() == RET_OK
)
1116 String aPassword
= pDlg
->GetPassword();
1117 Unprotect(nTab
, aPassword
);
1121 // this sheet is not password-protected.
1122 Unprotect(nTab
, String());
1126 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
1132 // Protect a current sheet.
1134 auto_ptr
<ScTableProtectionDlg
> pDlg(new ScTableProtectionDlg(GetDialogParent()));
1136 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1138 pDlg
->SetDialogData(*pProtect
);
1140 if (pDlg
->Execute() == RET_OK
)
1142 pScMod
->InputEnterHandler();
1144 ScTableProtection aNewProtect
;
1145 pDlg
->WriteData(aNewProtect
);
1146 ProtectSheet(nTab
, aNewProtect
);
1149 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, true) );
1155 auto_ptr
<SfxPasswordDialog
> pDlg
;
1157 BOOL bCancel
= FALSE
;
1158 bool bNewProtection
= ! bOldProtection
;
1162 const SfxPoolItem
* pItem
;
1163 if( IS_AVAILABLE( FID_PROTECT_TABLE
, &pItem
) )
1164 bNewProtection
= ((const SfxBoolItem
*)pItem
)->GetValue();
1165 if( bNewProtection
== bOldProtection
)
1172 if ( bOldProtection
)
1174 // Unprotect a protected sheet.
1176 ScTableProtection
* pProtect
= pDoc
->GetTabProtection(nTab
);
1177 if (pProtect
&& pProtect
->isProtectedWithPass())
1179 String
aText( ScResId(SCSTR_PASSWORDOPT
) );
1180 pDlg
.reset(new SfxPasswordDialog(GetDialogParent(), &aText
));
1181 pDlg
->SetText( ScResId(SCSTR_UNPROTECTTAB
) );
1182 pDlg
->SetMinLen( 0 );
1183 pDlg
->SetHelpId( FID_PROTECT_TABLE
);
1184 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1186 if (pDlg
->Execute() == RET_OK
)
1187 aPassword
= pDlg
->GetPassword();
1194 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
1200 String
aText( ScResId(SCSTR_PASSWORDOPT
) );
1202 pDlg
.reset(new SfxPasswordDialog(GetDialogParent(), &aText
));
1203 pDlg
->SetText( ScResId(SCSTR_PROTECTTAB
) );
1204 pDlg
->SetMinLen( 0 );
1205 pDlg
->SetHelpId( FID_PROTECT_TABLE
);
1206 pDlg
->SetEditHelpId( HID_PASSWD_TABLE
);
1207 pDlg
->ShowExtras( SHOWEXTRAS_CONFIRM
);
1209 if (pDlg
->Execute() == RET_OK
)
1210 aPassword
= pDlg
->GetPassword();
1217 if ( bOldProtection
)
1218 Unprotect( nTab
, aPassword
);
1221 pScMod
->InputEnterHandler();
1223 Protect( nTab
, aPassword
);
1228 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_TABLE
, bNewProtection
) );
1234 UpdateInputHandler(true); // damit sofort wieder eingegeben werden kann
1239 case SID_OPT_LOCALE_CHANGED
:
1240 { // locale changed, SYSTEM number formats changed => repaint cell contents
1246 case SID_OUTPLACE_OBJECT
:
1247 case SID_INPLACE_OBJECT
:
1249 SdrView
* pDrView
= GetSdrView();
1252 const SdrMarkList
& rMarkList
= pDrView
->GetMarkedObjectList();
1253 if (rMarkList
.GetMarkCount() == 1)
1255 BOOL bOle
= GetViewFrame()->GetFrame()->IsInPlace();
1256 SdrObject
* pObj
= rMarkList
.GetMark( 0 )->GetMarkedSdrObj();
1257 if( pObj
&& pObj
->ISA( SdrOle2Obj
) && !bOle
)
1259 if( nSlot
== SID_OUTPLACE_OBJECT
)
1260 ActivateObject( static_cast< SdrOle2Obj
* >( pObj
),
1261 embed::EmbedVerbs::MS_OLEVERB_OPEN
);
1263 ActivateObject( static_cast< SdrOle2Obj
* >( pObj
),
1264 embed::EmbedVerbs::MS_OLEVERB_PRIMARY
);
1272 DBG_ERROR("Unbekannter Slot bei ScTabViewShell::Execute");