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: tabvwshc.cxx,v $
10 * $Revision: 1.13.32.1 $
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 //------------------------------------------------------------------
38 // INCLUDE ---------------------------------------------------------------
39 #include "scitems.hxx"
40 #include <vcl/msgbox.hxx>
41 #include <sfx2/childwin.hxx>
42 #include <sfx2/dispatch.hxx>
44 #include "tabvwsh.hxx"
46 #include "globstr.hrc"
50 #include "document.hxx"
51 #include "uiitems.hxx"
53 #include "namedlg.hxx"
54 #include "solvrdlg.hxx"
55 #include "optsolver.hxx"
56 #include "tabopdlg.hxx"
57 #include "autoform.hxx" // Core
58 #include "autofmt.hxx" // Dialog
59 #include "consdlg.hxx"
60 //CHINA001 #include "sortdlg.hxx"
61 #include "filtdlg.hxx"
62 #include "dbnamdlg.hxx"
63 #include "pvlaydlg.hxx"
64 #include "areasdlg.hxx"
65 #include "condfrmt.hxx"
66 #include "rangeutl.hxx"
67 #include "crnrdlg.hxx"
68 #include "formula.hxx"
69 #include "cell.hxx" // Input Status Edit-Zellen
70 #include "acredlin.hxx"
71 #include "highred.hxx"
72 #include "simpref.hxx"
73 #include "funcdesc.hxx"
74 #include "dpobject.hxx"
76 //------------------------------------------------------------------
78 void ScTabViewShell::SetCurRefDlgId( USHORT nNew
)
80 // CurRefDlgId is stored in ScModule to find if a ref dialog is open,
81 // and in the view to identify the view that has opened the dialog
85 SfxModelessDialog
* ScTabViewShell::CreateRefDialog(
86 SfxBindings
* pB
, SfxChildWindow
* pCW
, SfxChildWinInfo
* pInfo
,
87 Window
* pParent
, USHORT nSlotId
)
89 // Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit
90 // z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#).
92 if ( SC_MOD()->GetCurRefDlgId() != nSlotId
)
95 if ( nCurRefDlgId
!= nSlotId
)
97 // the dialog has been opened in a different view
98 // -> lock the dispatcher for this view (modal mode)
100 GetViewData()->GetDispatcher().Lock( TRUE
); // lock is reset when closing dialog
104 SfxModelessDialog
* pResult
= 0;
107 pCW
->SetHideNotDelete(TRUE
);
111 case FID_DEFINE_NAME
:
112 pResult
= new ScNameDlg( pB
, pCW
, pParent
, GetViewData(),
113 ScAddress( GetViewData()->GetCurX(),
114 GetViewData()->GetCurY(),
115 GetViewData()->GetTabNo() ) );
118 case SID_DEFINE_COLROWNAMERANGES
:
120 pResult
= new ScColRowNameRangesDlg( pB
, pCW
, pParent
, GetViewData() );
124 case SID_OPENDLG_CONSOLIDATE
:
126 SfxItemSet
aArgSet( GetPool(),
127 SCITEM_CONSOLIDATEDATA
,
128 SCITEM_CONSOLIDATEDATA
);
130 const ScConsolidateParam
* pDlgData
=
131 GetViewData()->GetDocument()->GetConsolidateDlgData();
135 ScConsolidateParam aConsParam
;
136 SCCOL nStartCol
, nEndCol
;
137 SCROW nStartRow
, nEndRow
;
138 SCTAB nStartTab
, nEndTab
;
140 GetViewData()->GetSimpleArea( nStartCol
, nStartRow
, nStartTab
,
141 nEndCol
, nEndRow
, nEndTab
);
143 PutInOrder( nStartCol
, nEndCol
);
144 PutInOrder( nStartRow
, nEndRow
);
145 PutInOrder( nStartTab
, nEndTab
);
147 aConsParam
.nCol
= nStartCol
;
148 aConsParam
.nRow
= nStartRow
;
149 aConsParam
.nTab
= nStartTab
;
151 aArgSet
.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA
,
156 aArgSet
.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA
, pDlgData
) );
158 pResult
= new ScConsolidateDlg( pB
, pCW
, pParent
, aArgSet
);
162 case SID_DEFINE_DBNAME
:
164 // wenn auf einem bestehenden Bereich aufgerufen, den markieren
165 GetDBData( TRUE
, SC_DB_OLD
);
166 const ScMarkData
& rMark
= GetViewData()->GetMarkData();
167 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
168 MarkDataArea( FALSE
);
170 pResult
= new ScDbNameDlg( pB
, pCW
, pParent
, GetViewData() );
174 case SID_SPECIAL_FILTER
:
176 ScQueryParam aQueryParam
;
177 SfxItemSet
aArgSet( GetPool(),
181 ScDBData
* pDBData
= GetDBData(true, SC_DB_MAKE
, true);
182 pDBData
->GetQueryParam( aQueryParam
);
183 aQueryParam
.bUseDynamicRange
= true;
185 ScQueryItem
aItem( SCITEM_QUERYDATA
, GetViewData(), &aQueryParam
);
187 if (pDBData
->GetAdvancedQuerySource(aAdvSource
))
188 aItem
.SetAdvancedQuerySource( &aAdvSource
);
190 aArgSet
.Put( aItem
);
192 // aktuelle Tabelle merken (wg. RefInput im Dialog)
193 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
195 pResult
= new ScSpecialFilterDlg( pB
, pCW
, pParent
, aArgSet
);
202 ScQueryParam aQueryParam
;
203 SfxItemSet
aArgSet( GetPool(),
207 ScDBData
* pDBData
= GetDBData(true, SC_DB_MAKE
, true);
208 pDBData
->GetQueryParam( aQueryParam
);
209 aQueryParam
.bUseDynamicRange
= true;
211 aArgSet
.Put( ScQueryItem( SCITEM_QUERYDATA
,
215 // aktuelle Tabelle merken (wg. RefInput im Dialog)
216 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
218 pResult
= new ScFilterDlg( pB
, pCW
, pParent
, aArgSet
);
222 case SID_OPENDLG_TABOP
:
224 ScViewData
* pViewData
= GetViewData();
225 ScRefAddress
aCurPos ( pViewData
->GetCurX(),
226 pViewData
->GetCurY(),
227 pViewData
->GetTabNo(),
228 FALSE
, FALSE
, FALSE
);
230 pResult
= new ScTabOpDlg( pB
, pCW
, pParent
, pViewData
->GetDocument(), aCurPos
);
234 case SID_OPENDLG_SOLVE
:
236 ScViewData
* pViewData
= GetViewData();
237 ScAddress
aCurPos( pViewData
->GetCurX(),
238 pViewData
->GetCurY(),
239 pViewData
->GetTabNo());
240 pResult
= new ScSolverDlg( pB
, pCW
, pParent
, pViewData
->GetDocument(), aCurPos
);
244 case SID_OPENDLG_OPTSOLVER
:
246 ScViewData
* pViewData
= GetViewData();
247 ScAddress
aCurPos( pViewData
->GetCurX(), pViewData
->GetCurY(), pViewData
->GetTabNo());
248 pResult
= new ScOptSolverDlg( pB
, pCW
, pParent
, pViewData
->GetDocShell(), aCurPos
);
252 case SID_OPENDLG_PIVOTTABLE
:
254 // all settings must be in pDialogDPObject
256 if( pDialogDPObject
)
258 // Check for an existing datapilot output.
259 ScViewData
* pViewData
= GetViewData();
260 ScDPObject
* pObj
= GetViewData()->GetDocument()->GetDPAtCursor(
261 pViewData
->GetCurX(), pViewData
->GetCurY(), pViewData
->GetTabNo());
263 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
264 pResult
= new ScDPLayoutDlg( pB
, pCW
, pParent
, *pDialogDPObject
, pObj
== NULL
);
269 case SID_OPENDLG_EDIT_PRINTAREA
:
271 pResult
= new ScPrintAreasDlg( pB
, pCW
, pParent
);
275 case SID_OPENDLG_CONDFRMT
:
277 ScViewData
* pViewData
= GetViewData();
279 ScDocument
* pDoc
= pViewData
->GetDocument();
280 const ScConditionalFormat
* pForm
= pDoc
->GetCondFormat(
281 pViewData
->GetCurX(), pViewData
->GetCurY(), pViewData
->GetTabNo() );
283 // aktuelle Tabelle merken (wg. RefInput im Dialog)
284 pViewData
->SetRefTabNo( pViewData
->GetTabNo() );
286 pResult
= new ScConditionalFormatDlg( pB
, pCW
, pParent
, pDoc
, pForm
);
290 case SID_OPENDLG_FUNCTION
:
292 // Dialog schaut selber, was in der Zelle steht
294 pResult
= new ScFormulaDlg( pB
, pCW
, pParent
, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
300 // Dialog schaut selber, was in der Zelle steht
302 pResult
= new ScHighlightChgDlg( pB
, pCW
, pParent
, GetViewData() );
308 // Dialog schaut selber, was in der Zelle steht
310 ScViewData
* pViewData
= GetViewData();
311 pViewData
->SetRefTabNo( pViewData
->GetTabNo() );
312 pResult
= new ScSimpleRefDlg( pB
, pCW
, pParent
, pViewData
);
318 DBG_ERROR( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
324 // Die Dialoge gehen immer mit eingeklapptem Zusaetze-Button auf,
325 // darum muss die Groesse ueber das Initialize gerettet werden
326 // (oder den Zusaetze-Status mit speichern !!!)
328 Size aSize
= pResult
->GetSizePixel();
329 pResult
->Initialize( pInfo
);
330 pResult
->SetSizePixel(aSize
);