1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5b3f79822SAndrew Rist * distributed with this work for additional information
6b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist * software distributed under the License is distributed on an
15b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17b3f79822SAndrew Rist * specific language governing permissions and limitations
18b3f79822SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20b3f79822SAndrew Rist *************************************************************/
21b3f79822SAndrew Rist
22b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29cdf0e10cSrcweir //------------------------------------------------------------------
30cdf0e10cSrcweir
31cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include "scitems.hxx"
34cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
35cdf0e10cSrcweir #include <sfx2/app.hxx>
36cdf0e10cSrcweir #include <sfx2/request.hxx>
37cdf0e10cSrcweir #include <svl/aeitem.hxx>
38cdf0e10cSrcweir #include <basic/sbxcore.hxx>
39cdf0e10cSrcweir #include <svl/whiter.hxx>
40cdf0e10cSrcweir #include <svl/zforlist.hxx>
41cdf0e10cSrcweir #include <vcl/msgbox.hxx>
42cdf0e10cSrcweir #include <svl/stritem.hxx>
43cdf0e10cSrcweir #include <svl/visitem.hxx>
44cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
45cdf0e10cSrcweir
46cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
47cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
48cdf0e10cSrcweir
49cdf0e10cSrcweir #include "cellsh.hxx"
50cdf0e10cSrcweir #include "tabvwsh.hxx"
51cdf0e10cSrcweir #include "sc.hrc"
52cdf0e10cSrcweir #include "globstr.hrc"
53cdf0e10cSrcweir #include "global.hxx"
54cdf0e10cSrcweir #include "scmod.hxx"
55cdf0e10cSrcweir #include "docsh.hxx"
56cdf0e10cSrcweir #include "document.hxx"
57cdf0e10cSrcweir #include "uiitems.hxx"
58cdf0e10cSrcweir #include "dbfunc.hxx"
59cdf0e10cSrcweir #include "dbdocfun.hxx"
60cdf0e10cSrcweir //CHINA001 #include "lbseldlg.hxx"
61cdf0e10cSrcweir //CHINA001 #include "sortdlg.hxx"
62cdf0e10cSrcweir #include "filtdlg.hxx"
63cdf0e10cSrcweir #include "dbnamdlg.hxx"
64cdf0e10cSrcweir //CHINA001 #include "subtdlg.hxx"
65cdf0e10cSrcweir #include "reffact.hxx"
66cdf0e10cSrcweir #include "pvlaydlg.hxx"
67cdf0e10cSrcweir #include "validat.hxx"
68cdf0e10cSrcweir #include "scresid.hxx"
69cdf0e10cSrcweir //CHINA001 #include "validate.hxx"
70cdf0e10cSrcweir #include "pivot.hxx"
71cdf0e10cSrcweir #include "dpobject.hxx"
72cdf0e10cSrcweir //CHINA001 #include "dapitype.hxx"
73cdf0e10cSrcweir //CHINA001 #include "dapidata.hxx"
74cdf0e10cSrcweir #include "dpsdbtab.hxx" // ScImportSourceDesc
75cdf0e10cSrcweir #include "dpshttab.hxx" // ScSheetSourceDesc
76cdf0e10cSrcweir
77cdf0e10cSrcweir #include "validate.hrc" //CHINA001 add for ScValidationDlg
78cdf0e10cSrcweir #include "scui_def.hxx" //CHINA001
79cdf0e10cSrcweir #include "scabstdlg.hxx" //CHINA001
80cdf0e10cSrcweir #include "impex.hxx"
81cdf0e10cSrcweir #include "asciiopt.hxx"
82cdf0e10cSrcweir using namespace com::sun::star;
83cdf0e10cSrcweir
84cdf0e10cSrcweir //#include "strindlg.hxx" //! Test !!!!!
85cdf0e10cSrcweir
86cdf0e10cSrcweir //static ScArea aPivotSource; //! wohin? (ueber den Dialog retten)
87cdf0e10cSrcweir
88cdf0e10cSrcweir
89cdf0e10cSrcweir #define IS_AVAILABLE(WhichId,ppItem) \
90cdf0e10cSrcweir (pReqArgs->GetItemState((WhichId), sal_True, ppItem ) == SFX_ITEM_SET)
91cdf0e10cSrcweir
92cdf0e10cSrcweir //------------------------------------------------------------------
93cdf0e10cSrcweir
lcl_GetTextToColumnsRange(const ScViewData * pData,ScRange & rRange)94cdf0e10cSrcweir bool lcl_GetTextToColumnsRange( const ScViewData* pData, ScRange& rRange )
95cdf0e10cSrcweir {
96cdf0e10cSrcweir DBG_ASSERT( pData, "lcl_GetTextToColumnsRange: pData is null!" );
97cdf0e10cSrcweir
98cdf0e10cSrcweir bool bRet = false;
99cdf0e10cSrcweir const ScMarkData& rMark = pData->GetMarkData();
100cdf0e10cSrcweir
101cdf0e10cSrcweir if ( rMark.IsMarked() )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir if ( !rMark.IsMultiMarked() )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir rMark.GetMarkArea( rRange );
106cdf0e10cSrcweir if ( rRange.aStart.Col() == rRange.aEnd.Col() )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir bRet = true;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir }
111cdf0e10cSrcweir }
112cdf0e10cSrcweir else
113cdf0e10cSrcweir {
114cdf0e10cSrcweir const SCCOL nCol = pData->GetCurX();
115cdf0e10cSrcweir const SCROW nRow = pData->GetCurY();
116cdf0e10cSrcweir const SCTAB nTab = pData->GetTabNo();
117cdf0e10cSrcweir rRange = ScRange( nCol, nRow, nTab, nCol, nRow, nTab );
118cdf0e10cSrcweir bRet = true;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir const ScDocument* pDoc = pData->GetDocument();
122cdf0e10cSrcweir DBG_ASSERT( pDoc, "lcl_GetTextToColumnsRange: pDoc is null!" );
123cdf0e10cSrcweir
124cdf0e10cSrcweir if ( bRet && pDoc->IsBlockEmpty( rRange.aStart.Tab(), rRange.aStart.Col(),
125cdf0e10cSrcweir rRange.aStart.Row(), rRange.aEnd.Col(),
126cdf0e10cSrcweir rRange.aEnd.Row() ) )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir bRet = false;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
131cdf0e10cSrcweir return bRet;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
lcl_GetSortParam(const ScViewData * pData,ScSortParam & rSortParam)134cdf0e10cSrcweir sal_Bool lcl_GetSortParam( const ScViewData* pData, ScSortParam& rSortParam )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir ScTabViewShell* pTabViewShell = pData->GetViewShell();
137cdf0e10cSrcweir ScDBData* pDBData = pTabViewShell->GetDBData();
138cdf0e10cSrcweir ScDocument* pDoc = pData->GetDocument();
139cdf0e10cSrcweir SCTAB nTab = pData->GetTabNo();
140cdf0e10cSrcweir ScDirection eFillDir = DIR_TOP;
141cdf0e10cSrcweir sal_Bool bSort = sal_True;
142cdf0e10cSrcweir ScRange aExternalRange;
143cdf0e10cSrcweir
144cdf0e10cSrcweir if( rSortParam.nCol1 != rSortParam.nCol2 )
145cdf0e10cSrcweir eFillDir = DIR_LEFT;
146cdf0e10cSrcweir if( rSortParam.nRow1 != rSortParam.nRow2 )
147cdf0e10cSrcweir eFillDir = DIR_TOP;
148cdf0e10cSrcweir
149cdf0e10cSrcweir SCSIZE nCount = pDoc->GetEmptyLinesInBlock( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab, eFillDir );
150cdf0e10cSrcweir
151cdf0e10cSrcweir if( rSortParam.nRow2 == MAXROW )
152cdf0e10cSrcweir aExternalRange = ScRange( rSortParam.nCol1,sal::static_int_cast<SCROW>( nCount ), nTab );
153cdf0e10cSrcweir else
154cdf0e10cSrcweir aExternalRange = ScRange( pData->GetCurX(), pData->GetCurY(), nTab );
155cdf0e10cSrcweir
156cdf0e10cSrcweir SCROW nStartRow = aExternalRange.aStart.Row();
157cdf0e10cSrcweir SCCOL nStartCol = aExternalRange.aStart.Col();
158cdf0e10cSrcweir SCROW nEndRow = aExternalRange.aEnd.Row();
159cdf0e10cSrcweir SCCOL nEndCol = aExternalRange.aEnd.Col();
160cdf0e10cSrcweir pDoc->GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, sal_False, false );
161cdf0e10cSrcweir aExternalRange.aStart.SetRow( nStartRow );
162cdf0e10cSrcweir aExternalRange.aStart.SetCol( nStartCol );
163cdf0e10cSrcweir aExternalRange.aEnd.SetRow( nEndRow );
164cdf0e10cSrcweir aExternalRange.aEnd.SetCol( nEndCol );
165cdf0e10cSrcweir
166cdf0e10cSrcweir if(( rSortParam.nCol1 == rSortParam.nCol2 && aExternalRange.aStart.Col() != aExternalRange.aEnd.Col() ) ||
167cdf0e10cSrcweir ( rSortParam.nRow1 == rSortParam.nRow2 && aExternalRange.aStart.Row() != aExternalRange.aEnd.Row() ) )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir sal_uInt16 nFmt = SCA_VALID;
170cdf0e10cSrcweir String aExtendStr,aCurrentStr;
171cdf0e10cSrcweir
172cdf0e10cSrcweir pTabViewShell->AddHighlightRange( aExternalRange,Color( COL_LIGHTBLUE ) );
173cdf0e10cSrcweir ScRange rExtendRange( aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), nTab, aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row(), nTab );
174cdf0e10cSrcweir rExtendRange.Format( aExtendStr, nFmt, pDoc );
175cdf0e10cSrcweir
176cdf0e10cSrcweir ScRange rCurrentRange( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab );
177cdf0e10cSrcweir rCurrentRange.Format( aCurrentStr, nFmt, pDoc );
178cdf0e10cSrcweir
179cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
180cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
181cdf0e10cSrcweir
182cdf0e10cSrcweir VclAbstractDialog* pWarningDlg = pFact->CreateScSortWarningDlg( pTabViewShell->GetDialogParent(),aExtendStr,aCurrentStr,RID_SCDLG_SORT_WARNING );
183cdf0e10cSrcweir DBG_ASSERT(pWarningDlg, "Dialog create fail!");//CHINA001
184cdf0e10cSrcweir short bResult = pWarningDlg->Execute();
185cdf0e10cSrcweir if( bResult == BTN_EXTEND_RANGE || bResult == BTN_CURRENT_SELECTION )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir if( bResult == BTN_EXTEND_RANGE )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir pTabViewShell->MarkRange( aExternalRange, sal_False );
190cdf0e10cSrcweir pDBData->SetArea( nTab, aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row() );
191cdf0e10cSrcweir }
192cdf0e10cSrcweir }
193cdf0e10cSrcweir else
194cdf0e10cSrcweir {
195cdf0e10cSrcweir bSort = sal_False;
196cdf0e10cSrcweir pData->GetDocShell()->CancelAutoDBRange();
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199cdf0e10cSrcweir delete pWarningDlg;
200cdf0e10cSrcweir pTabViewShell->ClearHighlightRanges();
201cdf0e10cSrcweir }
202cdf0e10cSrcweir return bSort;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir //<!-- Added by PengYunQuan for Validity Cell Range Picker
206cdf0e10cSrcweir //after end execute from !IsModalInputMode, it is safer to delay deleting
207cdf0e10cSrcweir namespace
208cdf0e10cSrcweir {
DelayDeleteAbstractDialog(void * pAbstractDialog,void *)209cdf0e10cSrcweir long DelayDeleteAbstractDialog( void *pAbstractDialog, void * /*pArg*/ )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir delete reinterpret_cast<VclAbstractDialog*>( pAbstractDialog );
212cdf0e10cSrcweir return 0;
213cdf0e10cSrcweir }
214cdf0e10cSrcweir }
215cdf0e10cSrcweir //--> Added by PengYunQuan for Validity Cell Range Picker
216cdf0e10cSrcweir
ExecuteDB(SfxRequest & rReq)217cdf0e10cSrcweir void ScCellShell::ExecuteDB( SfxRequest& rReq )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
220cdf0e10cSrcweir sal_uInt16 nSlotId = rReq.GetSlot();
221cdf0e10cSrcweir const SfxItemSet* pReqArgs = rReq.GetArgs();
222cdf0e10cSrcweir ScModule* pScMod = SC_MOD();
223cdf0e10cSrcweir
224cdf0e10cSrcweir pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
225cdf0e10cSrcweir
226cdf0e10cSrcweir if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir pScMod->InputEnterHandler();
229cdf0e10cSrcweir pTabViewShell->UpdateInputHandler();
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir switch ( nSlotId )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir case SID_VIEW_DATA_SOURCE_BROWSER:
235cdf0e10cSrcweir {
236cdf0e10cSrcweir // check if database beamer is open
237cdf0e10cSrcweir
238cdf0e10cSrcweir SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
239cdf0e10cSrcweir sal_Bool bWasOpen = sal_False;
240cdf0e10cSrcweir {
241cdf0e10cSrcweir uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
242cdf0e10cSrcweir uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
243cdf0e10cSrcweir rtl::OUString::createFromAscii("_beamer"),
244cdf0e10cSrcweir frame::FrameSearchFlag::CHILDREN);
245cdf0e10cSrcweir if ( xBeamerFrame.is() )
246cdf0e10cSrcweir bWasOpen = sal_True;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir
249cdf0e10cSrcweir if ( bWasOpen )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir // close database beamer: just forward to SfxViewFrame
252cdf0e10cSrcweir
253cdf0e10cSrcweir pViewFrame->ExecuteSlot( rReq );
254cdf0e10cSrcweir }
255cdf0e10cSrcweir else
256cdf0e10cSrcweir {
257cdf0e10cSrcweir // show database beamer: SfxViewFrame call must be synchronous
258cdf0e10cSrcweir
259cdf0e10cSrcweir pViewFrame->ExecuteSlot( rReq, (sal_Bool) sal_False ); // sal_False = synchronous
260cdf0e10cSrcweir
261cdf0e10cSrcweir // select current database in database beamer
262cdf0e10cSrcweir
263cdf0e10cSrcweir ScImportParam aImportParam;
264cdf0e10cSrcweir ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD); // don't create if none found
265cdf0e10cSrcweir if (pDBData)
266cdf0e10cSrcweir pDBData->GetImportParam( aImportParam );
267cdf0e10cSrcweir
268cdf0e10cSrcweir ScDBDocFunc::ShowInBeamer( aImportParam, pTabViewShell->GetViewFrame() );
269cdf0e10cSrcweir }
270cdf0e10cSrcweir rReq.Done(); // needed because it's a toggle slot
271cdf0e10cSrcweir }
272cdf0e10cSrcweir break;
273cdf0e10cSrcweir
274cdf0e10cSrcweir case SID_REIMPORT_DATA:
275cdf0e10cSrcweir {
276cdf0e10cSrcweir sal_Bool bOk = sal_False;
277cdf0e10cSrcweir ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD);
278cdf0e10cSrcweir if (pDBData)
279cdf0e10cSrcweir {
280cdf0e10cSrcweir ScImportParam aImportParam;
281cdf0e10cSrcweir pDBData->GetImportParam( aImportParam );
282cdf0e10cSrcweir if (aImportParam.bImport && !pDBData->HasImportSelection())
283cdf0e10cSrcweir {
284cdf0e10cSrcweir pTabViewShell->ImportData( aImportParam );
285cdf0e10cSrcweir pDBData->SetImportParam( aImportParam ); //! Undo ??
286cdf0e10cSrcweir bOk = sal_True;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
290cdf0e10cSrcweir if (!bOk && ! rReq.IsAPI() )
291cdf0e10cSrcweir pTabViewShell->ErrorMessage(STR_REIMPORT_EMPTY);
292cdf0e10cSrcweir
293cdf0e10cSrcweir if( bOk )
294cdf0e10cSrcweir rReq.Done();
295cdf0e10cSrcweir }
296cdf0e10cSrcweir break;
297cdf0e10cSrcweir
298cdf0e10cSrcweir case SID_REFRESH_DBAREA:
299cdf0e10cSrcweir {
300cdf0e10cSrcweir ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD);
301cdf0e10cSrcweir if (pDBData)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir // Import wiederholen wie SID_REIMPORT_DATA
304cdf0e10cSrcweir
305cdf0e10cSrcweir sal_Bool bContinue = sal_True;
306cdf0e10cSrcweir ScImportParam aImportParam;
307cdf0e10cSrcweir pDBData->GetImportParam( aImportParam );
308cdf0e10cSrcweir if (aImportParam.bImport && !pDBData->HasImportSelection())
309cdf0e10cSrcweir {
310cdf0e10cSrcweir bContinue = pTabViewShell->ImportData( aImportParam );
311cdf0e10cSrcweir pDBData->SetImportParam( aImportParam ); //! Undo ??
312cdf0e10cSrcweir
313cdf0e10cSrcweir // markieren (Groesse kann sich geaendert haben)
314cdf0e10cSrcweir ScRange aNewRange;
315cdf0e10cSrcweir pDBData->GetArea(aNewRange);
316cdf0e10cSrcweir pTabViewShell->MarkRange(aNewRange);
317cdf0e10cSrcweir }
318cdf0e10cSrcweir
319cdf0e10cSrcweir if ( bContinue ) // #41905# Fehler beim Import -> Abbruch
320cdf0e10cSrcweir {
321cdf0e10cSrcweir // interne Operationen, wenn welche gespeichert
322cdf0e10cSrcweir
323cdf0e10cSrcweir if ( pDBData->HasQueryParam() || pDBData->HasSortParam() ||
324cdf0e10cSrcweir pDBData->HasSubTotalParam() )
325cdf0e10cSrcweir pTabViewShell->RepeatDB();
326cdf0e10cSrcweir
327cdf0e10cSrcweir // Pivottabellen die den Bereich als Quelldaten haben
328cdf0e10cSrcweir
329cdf0e10cSrcweir ScRange aRange;
330cdf0e10cSrcweir pDBData->GetArea(aRange);
331cdf0e10cSrcweir GetViewData()->GetDocShell()->RefreshPivotTables(aRange);
332cdf0e10cSrcweir }
333cdf0e10cSrcweir }
334cdf0e10cSrcweir rReq.Done();
335cdf0e10cSrcweir }
336cdf0e10cSrcweir break;
337cdf0e10cSrcweir
338cdf0e10cSrcweir case SID_SBA_BRW_INSERT:
339cdf0e10cSrcweir {
340cdf0e10cSrcweir DBG_ERROR( "Deprecated Slot" );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir break;
343cdf0e10cSrcweir
344cdf0e10cSrcweir case SID_SUBTOTALS:
345cdf0e10cSrcweir {
346cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
347cdf0e10cSrcweir if ( pArgs )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir pTabViewShell->DoSubTotals( ((const ScSubTotalItem&) pArgs->Get( SCITEM_SUBTDATA )).
350cdf0e10cSrcweir GetSubTotalData() );
351cdf0e10cSrcweir rReq.Done();
352cdf0e10cSrcweir }
353cdf0e10cSrcweir else
354cdf0e10cSrcweir {
355cdf0e10cSrcweir //CHINA001 ScSubTotalDlg* pDlg = NULL;
356cdf0e10cSrcweir SfxAbstractTabDialog * pDlg = NULL;
357cdf0e10cSrcweir ScSubTotalParam aSubTotalParam;
358cdf0e10cSrcweir SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
359cdf0e10cSrcweir
360*22407013SOliver-Rainer Wittmann ScDBData* pDBData = pTabViewShell->GetDBData();
361cdf0e10cSrcweir pDBData->GetSubTotalParam( aSubTotalParam );
362cdf0e10cSrcweir aSubTotalParam.bRemoveOnly = sal_False;
363cdf0e10cSrcweir
364cdf0e10cSrcweir aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
365cdf0e10cSrcweir //CHINA001 pDlg = new ScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet );
366cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
367cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
368cdf0e10cSrcweir
369cdf0e10cSrcweir pDlg = pFact->CreateScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SUBTOTALS );
370cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
371cdf0e10cSrcweir pDlg->SetCurPageId(1);
372cdf0e10cSrcweir
373cdf0e10cSrcweir short bResult = pDlg->Execute();
374cdf0e10cSrcweir
375cdf0e10cSrcweir if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir const SfxItemSet* pOutSet = NULL;
378cdf0e10cSrcweir
379cdf0e10cSrcweir if ( bResult == RET_OK )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir pOutSet = pDlg->GetOutputItemSet();
382cdf0e10cSrcweir aSubTotalParam =
383cdf0e10cSrcweir ((const ScSubTotalItem&)
384cdf0e10cSrcweir pOutSet->Get( SCITEM_SUBTDATA )).
385cdf0e10cSrcweir GetSubTotalData();
386cdf0e10cSrcweir }
387cdf0e10cSrcweir else // if (bResult == SCRET_REMOVE)
388cdf0e10cSrcweir {
389cdf0e10cSrcweir pOutSet = &aArgSet;
390cdf0e10cSrcweir aSubTotalParam.bRemoveOnly = sal_True;
391cdf0e10cSrcweir aSubTotalParam.bReplace = sal_True;
392cdf0e10cSrcweir aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
393cdf0e10cSrcweir GetViewData(),
394cdf0e10cSrcweir &aSubTotalParam ) );
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
397cdf0e10cSrcweir pTabViewShell->DoSubTotals( aSubTotalParam );
398cdf0e10cSrcweir rReq.Done( *pOutSet );
399cdf0e10cSrcweir }
400cdf0e10cSrcweir else
401cdf0e10cSrcweir GetViewData()->GetDocShell()->CancelAutoDBRange();
402cdf0e10cSrcweir
403cdf0e10cSrcweir delete pDlg;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir }
406cdf0e10cSrcweir break;
407cdf0e10cSrcweir
408cdf0e10cSrcweir case SID_SORT_DESCENDING:
409cdf0e10cSrcweir case SID_SORT_ASCENDING:
410cdf0e10cSrcweir {
411cdf0e10cSrcweir //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
412cdf0e10cSrcweir //the patch comes from maoyg
413cdf0e10cSrcweir ScSortParam aSortParam;
414*22407013SOliver-Rainer Wittmann ScDBData* pDBData = pTabViewShell->GetDBData();
415cdf0e10cSrcweir ScViewData* pData = GetViewData();
416cdf0e10cSrcweir
417cdf0e10cSrcweir pDBData->GetSortParam( aSortParam );
418cdf0e10cSrcweir
419cdf0e10cSrcweir if( lcl_GetSortParam( pData, aSortParam ) )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA );
422cdf0e10cSrcweir SCCOL nCol = GetViewData()->GetCurX();
423cdf0e10cSrcweir SCCOL nTab = GetViewData()->GetTabNo();
424cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument();
425cdf0e10cSrcweir
426cdf0e10cSrcweir pDBData->GetSortParam( aSortParam );
427cdf0e10cSrcweir sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, nTab );
428cdf0e10cSrcweir
429cdf0e10cSrcweir if( nCol < aSortParam.nCol1 )
430cdf0e10cSrcweir nCol = aSortParam.nCol1;
431cdf0e10cSrcweir else if( nCol > aSortParam.nCol2 )
432cdf0e10cSrcweir nCol = aSortParam.nCol2;
433cdf0e10cSrcweir
434cdf0e10cSrcweir aSortParam.bHasHeader = bHasHeader;
435cdf0e10cSrcweir aSortParam.bByRow = sal_True;
436cdf0e10cSrcweir aSortParam.bCaseSens = sal_False;
437cdf0e10cSrcweir aSortParam.bIncludePattern = sal_True;
438cdf0e10cSrcweir aSortParam.bInplace = sal_True;
439cdf0e10cSrcweir aSortParam.bDoSort[0] = sal_True;
440cdf0e10cSrcweir aSortParam.nField[0] = nCol;
441cdf0e10cSrcweir aSortParam.bAscending[0] = (nSlotId == SID_SORT_ASCENDING);
442cdf0e10cSrcweir
443cdf0e10cSrcweir for ( sal_uInt16 i=1; i<MAXSORT; i++ )
444cdf0e10cSrcweir aSortParam.bDoSort[i] = sal_False;
445cdf0e10cSrcweir
446cdf0e10cSrcweir aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
447cdf0e10cSrcweir
448cdf0e10cSrcweir pTabViewShell->UISort( aSortParam ); // Teilergebnisse bei Bedarf neu
449cdf0e10cSrcweir
450cdf0e10cSrcweir rReq.Done();
451cdf0e10cSrcweir }
452cdf0e10cSrcweir }
453cdf0e10cSrcweir break;
454cdf0e10cSrcweir
455cdf0e10cSrcweir case SID_SORT:
456cdf0e10cSrcweir {
457cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
458cdf0e10cSrcweir
459cdf0e10cSrcweir //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
460cdf0e10cSrcweir //the patch comes from maoyg
461cdf0e10cSrcweir
462cdf0e10cSrcweir if ( pArgs ) // Basic
463cdf0e10cSrcweir {
464cdf0e10cSrcweir ScSortParam aSortParam;
465*22407013SOliver-Rainer Wittmann ScDBData* pDBData = pTabViewShell->GetDBData();
466cdf0e10cSrcweir ScViewData* pData = GetViewData();
467cdf0e10cSrcweir
468cdf0e10cSrcweir pDBData->GetSortParam( aSortParam );
469cdf0e10cSrcweir
470cdf0e10cSrcweir if( lcl_GetSortParam( pData, aSortParam ) )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument();
473cdf0e10cSrcweir
474cdf0e10cSrcweir pDBData->GetSortParam( aSortParam );
475cdf0e10cSrcweir sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, pData->GetTabNo() );
476cdf0e10cSrcweir if( bHasHeader )
477cdf0e10cSrcweir aSortParam.bHasHeader = bHasHeader;
478cdf0e10cSrcweir
479cdf0e10cSrcweir aSortParam.bInplace = sal_True; // von Basic immer
480cdf0e10cSrcweir
481cdf0e10cSrcweir const SfxPoolItem* pItem;
482cdf0e10cSrcweir if ( pArgs->GetItemState( SID_SORT_BYROW, sal_True, &pItem ) == SFX_ITEM_SET )
483cdf0e10cSrcweir aSortParam.bByRow = ((const SfxBoolItem*)pItem)->GetValue();
484cdf0e10cSrcweir if ( pArgs->GetItemState( SID_SORT_HASHEADER, sal_True, &pItem ) == SFX_ITEM_SET )
485cdf0e10cSrcweir aSortParam.bHasHeader = ((const SfxBoolItem*)pItem)->GetValue();
486cdf0e10cSrcweir if ( pArgs->GetItemState( SID_SORT_CASESENS, sal_True, &pItem ) == SFX_ITEM_SET )
487cdf0e10cSrcweir aSortParam.bCaseSens = ((const SfxBoolItem*)pItem)->GetValue();
488cdf0e10cSrcweir if ( pArgs->GetItemState( SID_SORT_ATTRIBS, sal_True, &pItem ) == SFX_ITEM_SET )
489cdf0e10cSrcweir aSortParam.bIncludePattern = ((const SfxBoolItem*)pItem)->GetValue();
490cdf0e10cSrcweir if ( pArgs->GetItemState( SID_SORT_USERDEF, sal_True, &pItem ) == SFX_ITEM_SET )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir sal_uInt16 nUserIndex = ((const SfxUInt16Item*)pItem)->GetValue();
493cdf0e10cSrcweir aSortParam.bUserDef = ( nUserIndex != 0 );
494cdf0e10cSrcweir if ( nUserIndex )
495cdf0e10cSrcweir aSortParam.nUserIndex = nUserIndex - 1; // Basic: 1-basiert
496cdf0e10cSrcweir }
497cdf0e10cSrcweir
498cdf0e10cSrcweir SCCOLROW nField0 = 0;
499cdf0e10cSrcweir if ( pArgs->GetItemState( FN_PARAM_1, sal_True, &pItem ) == SFX_ITEM_SET )
500cdf0e10cSrcweir nField0 = ((const SfxInt32Item*)pItem)->GetValue();
501cdf0e10cSrcweir aSortParam.bDoSort[0] = ( nField0 != 0 );
502cdf0e10cSrcweir aSortParam.nField[0] = nField0 > 0 ? (nField0-1) : 0;
503cdf0e10cSrcweir if ( pArgs->GetItemState( FN_PARAM_2, sal_True, &pItem ) == SFX_ITEM_SET )
504cdf0e10cSrcweir aSortParam.bAscending[0] = ((const SfxBoolItem*)pItem)->GetValue();
505cdf0e10cSrcweir SCCOLROW nField1 = 0;
506cdf0e10cSrcweir if ( pArgs->GetItemState( FN_PARAM_3, sal_True, &pItem ) == SFX_ITEM_SET )
507cdf0e10cSrcweir nField1 = ((const SfxInt32Item*)pItem)->GetValue();
508cdf0e10cSrcweir aSortParam.bDoSort[1] = ( nField1 != 0 );
509cdf0e10cSrcweir aSortParam.nField[1] = nField1 > 0 ? (nField1-1) : 0;
510cdf0e10cSrcweir if ( pArgs->GetItemState( FN_PARAM_4, sal_True, &pItem ) == SFX_ITEM_SET )
511cdf0e10cSrcweir aSortParam.bAscending[1] = ((const SfxBoolItem*)pItem)->GetValue();
512cdf0e10cSrcweir SCCOLROW nField2 = 0;
513cdf0e10cSrcweir if ( pArgs->GetItemState( FN_PARAM_5, sal_True, &pItem ) == SFX_ITEM_SET )
514cdf0e10cSrcweir nField2 = ((const SfxInt32Item*)pItem)->GetValue();
515cdf0e10cSrcweir aSortParam.bDoSort[2] = ( nField2 != 0 );
516cdf0e10cSrcweir aSortParam.nField[2] = nField2 > 0 ? (nField2-1) : 0;
517cdf0e10cSrcweir if ( pArgs->GetItemState( FN_PARAM_6, sal_True, &pItem ) == SFX_ITEM_SET )
518cdf0e10cSrcweir aSortParam.bAscending[2] = ((const SfxBoolItem*)pItem)->GetValue();
519cdf0e10cSrcweir
520cdf0e10cSrcweir // Teilergebnisse bei Bedarf neu
521cdf0e10cSrcweir pTabViewShell->UISort( aSortParam );
522cdf0e10cSrcweir rReq.Done();
523cdf0e10cSrcweir }
524cdf0e10cSrcweir }
525cdf0e10cSrcweir else
526cdf0e10cSrcweir {
527cdf0e10cSrcweir ScSortParam aSortParam;
528*22407013SOliver-Rainer Wittmann ScDBData* pDBData = pTabViewShell->GetDBData();
529cdf0e10cSrcweir ScViewData* pData = GetViewData();
530cdf0e10cSrcweir
531cdf0e10cSrcweir pDBData->GetSortParam( aSortParam );
532cdf0e10cSrcweir
533cdf0e10cSrcweir if( lcl_GetSortParam( pData, aSortParam ) )
534cdf0e10cSrcweir {
535cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = NULL;
536cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument();
537cdf0e10cSrcweir SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA );
538cdf0e10cSrcweir
539cdf0e10cSrcweir pDBData->GetSortParam( aSortParam );
540cdf0e10cSrcweir sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, pData->GetTabNo() );
541cdf0e10cSrcweir if( bHasHeader )
542cdf0e10cSrcweir aSortParam.bHasHeader = bHasHeader;
543cdf0e10cSrcweir
544cdf0e10cSrcweir aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
545cdf0e10cSrcweir
546cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
547cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
548cdf0e10cSrcweir
549cdf0e10cSrcweir pDlg = pFact->CreateScSortDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SORT );
550cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
551cdf0e10cSrcweir pDlg->SetCurPageId(1);
552cdf0e10cSrcweir
553cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
556cdf0e10cSrcweir const ScSortParam& rOutParam = ((const ScSortItem&)
557cdf0e10cSrcweir pOutSet->Get( SCITEM_SORTDATA )).GetSortData();
558cdf0e10cSrcweir
559cdf0e10cSrcweir // Teilergebnisse bei Bedarf neu
560cdf0e10cSrcweir pTabViewShell->UISort( rOutParam );
561cdf0e10cSrcweir
562cdf0e10cSrcweir if ( rOutParam.bInplace )
563cdf0e10cSrcweir {
564cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( SID_SORT_BYROW,
565cdf0e10cSrcweir rOutParam.bByRow ) );
566cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( SID_SORT_HASHEADER,
567cdf0e10cSrcweir rOutParam.bHasHeader ) );
568cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
569cdf0e10cSrcweir rOutParam.bCaseSens ) );
570cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
571cdf0e10cSrcweir rOutParam.bIncludePattern ) );
572cdf0e10cSrcweir sal_uInt16 nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;
573cdf0e10cSrcweir rReq.AppendItem( SfxUInt16Item( SID_SORT_USERDEF, nUser ) );
574cdf0e10cSrcweir if ( rOutParam.bDoSort[0] )
575cdf0e10cSrcweir {
576cdf0e10cSrcweir rReq.AppendItem( SfxInt32Item( FN_PARAM_1,
577cdf0e10cSrcweir rOutParam.nField[0] + 1 ) );
578cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_2,
579cdf0e10cSrcweir rOutParam.bAscending[0] ) );
580cdf0e10cSrcweir }
581cdf0e10cSrcweir if ( rOutParam.bDoSort[1] )
582cdf0e10cSrcweir {
583cdf0e10cSrcweir rReq.AppendItem( SfxInt32Item( FN_PARAM_3,
584cdf0e10cSrcweir rOutParam.nField[1] + 1 ) );
585cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_4,
586cdf0e10cSrcweir rOutParam.bAscending[1] ) );
587cdf0e10cSrcweir }
588cdf0e10cSrcweir if ( rOutParam.bDoSort[2] )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir rReq.AppendItem( SfxInt32Item( FN_PARAM_5,
591cdf0e10cSrcweir rOutParam.nField[2] + 1 ) );
592cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_6,
593cdf0e10cSrcweir rOutParam.bAscending[2] ) );
594cdf0e10cSrcweir }
595cdf0e10cSrcweir }
596cdf0e10cSrcweir
597cdf0e10cSrcweir rReq.Done();
598cdf0e10cSrcweir }
599cdf0e10cSrcweir else
600cdf0e10cSrcweir GetViewData()->GetDocShell()->CancelAutoDBRange();
601cdf0e10cSrcweir
602cdf0e10cSrcweir delete pDlg;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir }
605cdf0e10cSrcweir }
606cdf0e10cSrcweir break;
607cdf0e10cSrcweir
608cdf0e10cSrcweir case SID_FILTER:
609cdf0e10cSrcweir {
610cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
611cdf0e10cSrcweir if ( pArgs )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir DBG_ERROR("SID_FILTER with arguments?");
614cdf0e10cSrcweir pTabViewShell->Query( ((const ScQueryItem&)
615cdf0e10cSrcweir pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, sal_True );
616cdf0e10cSrcweir rReq.Done();
617cdf0e10cSrcweir }
618cdf0e10cSrcweir else
619cdf0e10cSrcweir {
620cdf0e10cSrcweir sal_uInt16 nId = ScFilterDlgWrapper::GetChildWindowId();
621cdf0e10cSrcweir SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
622cdf0e10cSrcweir SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
623cdf0e10cSrcweir
624cdf0e10cSrcweir pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
625cdf0e10cSrcweir }
626cdf0e10cSrcweir }
627cdf0e10cSrcweir break;
628cdf0e10cSrcweir
629cdf0e10cSrcweir case SID_SPECIAL_FILTER:
630cdf0e10cSrcweir {
631cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
632cdf0e10cSrcweir if ( pArgs )
633cdf0e10cSrcweir {
634cdf0e10cSrcweir DBG_ERROR("SID_SPECIAL_FILTER with arguments?");
635cdf0e10cSrcweir pTabViewShell->Query( ((const ScQueryItem&)
636cdf0e10cSrcweir pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, sal_True );
637cdf0e10cSrcweir rReq.Done();
638cdf0e10cSrcweir }
639cdf0e10cSrcweir else
640cdf0e10cSrcweir {
641cdf0e10cSrcweir sal_uInt16 nId = ScSpecialFilterDlgWrapper::GetChildWindowId();
642cdf0e10cSrcweir SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
643cdf0e10cSrcweir SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
644cdf0e10cSrcweir
645cdf0e10cSrcweir pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
646cdf0e10cSrcweir }
647cdf0e10cSrcweir }
648cdf0e10cSrcweir break;
649cdf0e10cSrcweir
650cdf0e10cSrcweir case FID_FILTER_OK:
651cdf0e10cSrcweir {
652cdf0e10cSrcweir const SfxPoolItem* pItem;
653cdf0e10cSrcweir if ( pReqArgs && SFX_ITEM_SET ==
654cdf0e10cSrcweir pReqArgs->GetItemState( SCITEM_QUERYDATA, sal_True, &pItem ) )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(*pItem);
657cdf0e10cSrcweir
658cdf0e10cSrcweir SCTAB nCurTab = GetViewData()->GetTabNo();
659cdf0e10cSrcweir SCTAB nRefTab = GetViewData()->GetRefTabNo();
660cdf0e10cSrcweir
661cdf0e10cSrcweir // If RefInput switched to a different sheet from the data sheet,
662cdf0e10cSrcweir // switch back:
663cdf0e10cSrcweir
664cdf0e10cSrcweir if ( nCurTab != nRefTab )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir pTabViewShell->SetTabNo( nRefTab );
667cdf0e10cSrcweir pTabViewShell->PaintExtras();
668cdf0e10cSrcweir }
669cdf0e10cSrcweir
670cdf0e10cSrcweir ScRange aAdvSource;
671cdf0e10cSrcweir if (rQueryItem.GetAdvancedQuerySource(aAdvSource))
672cdf0e10cSrcweir pTabViewShell->Query( rQueryItem.GetQueryData(), &aAdvSource, sal_True );
673cdf0e10cSrcweir else
674cdf0e10cSrcweir pTabViewShell->Query( rQueryItem.GetQueryData(), NULL, sal_True );
675cdf0e10cSrcweir rReq.Done( *pReqArgs );
676cdf0e10cSrcweir }
677cdf0e10cSrcweir }
678cdf0e10cSrcweir break;
679cdf0e10cSrcweir
680cdf0e10cSrcweir case SID_UNFILTER:
681cdf0e10cSrcweir {
682cdf0e10cSrcweir ScQueryParam aParam;
683*22407013SOliver-Rainer Wittmann ScDBData* pDBData = pTabViewShell->GetDBData();
684cdf0e10cSrcweir
685cdf0e10cSrcweir pDBData->GetQueryParam( aParam );
686cdf0e10cSrcweir SCSIZE nEC = aParam.GetEntryCount();
687cdf0e10cSrcweir for (SCSIZE i=0; i<nEC; i++)
688cdf0e10cSrcweir aParam.GetEntry(i).bDoQuery = sal_False;
689cdf0e10cSrcweir aParam.bDuplicate = sal_True;
690cdf0e10cSrcweir pTabViewShell->Query( aParam, NULL, sal_True );
691cdf0e10cSrcweir rReq.Done();
692cdf0e10cSrcweir }
693cdf0e10cSrcweir break;
694cdf0e10cSrcweir
695cdf0e10cSrcweir case SID_AUTO_FILTER:
696cdf0e10cSrcweir pTabViewShell->ToggleAutoFilter();
697cdf0e10cSrcweir rReq.Done();
698cdf0e10cSrcweir break;
699cdf0e10cSrcweir
700cdf0e10cSrcweir case SID_AUTOFILTER_HIDE:
701cdf0e10cSrcweir pTabViewShell->HideAutoFilter();
702cdf0e10cSrcweir rReq.Done();
703cdf0e10cSrcweir break;
704cdf0e10cSrcweir
705cdf0e10cSrcweir case SID_PIVOT_TABLE:
706cdf0e10cSrcweir {
707cdf0e10cSrcweir const SfxPoolItem* pItem;
708cdf0e10cSrcweir if ( pReqArgs && SFX_ITEM_SET ==
709cdf0e10cSrcweir pReqArgs->GetItemState( SCITEM_PIVOTDATA, sal_True, &pItem ) )
710cdf0e10cSrcweir {
711cdf0e10cSrcweir SCTAB nCurTab = GetViewData()->GetTabNo();
712cdf0e10cSrcweir SCTAB nRefTab = GetViewData()->GetRefTabNo();
713cdf0e10cSrcweir
714cdf0e10cSrcweir // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet
715cdf0e10cSrcweir // hat wieder zurueckschalten:
716cdf0e10cSrcweir
717cdf0e10cSrcweir if ( nCurTab != nRefTab )
718cdf0e10cSrcweir {
719cdf0e10cSrcweir pTabViewShell->SetTabNo( nRefTab );
720cdf0e10cSrcweir pTabViewShell->PaintExtras();
721cdf0e10cSrcweir }
722cdf0e10cSrcweir
723cdf0e10cSrcweir const ScDPObject* pDPObject = pTabViewShell->GetDialogDPObject();
724cdf0e10cSrcweir if ( pDPObject )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir const ScPivotItem* pPItem = (const ScPivotItem*)pItem;
727cdf0e10cSrcweir bool bSuccess = pTabViewShell->MakePivotTable(
728cdf0e10cSrcweir pPItem->GetData(), pPItem->GetDestRange(), pPItem->IsNewSheet(), *pDPObject );
729cdf0e10cSrcweir SfxBoolItem aRet(0, bSuccess);
730cdf0e10cSrcweir rReq.SetReturnValue(aRet);
731cdf0e10cSrcweir }
732cdf0e10cSrcweir rReq.Done();
733cdf0e10cSrcweir }
734cdf0e10cSrcweir else if (rReq.IsAPI())
735cdf0e10cSrcweir SbxBase::SetError(SbxERR_BAD_PARAMETER);
736cdf0e10cSrcweir }
737cdf0e10cSrcweir break;
738cdf0e10cSrcweir
739cdf0e10cSrcweir case SID_OPENDLG_PIVOTTABLE:
740cdf0e10cSrcweir {
741cdf0e10cSrcweir ScViewData* pData = GetViewData();
742cdf0e10cSrcweir ScDocument* pDoc = pData->GetDocument();
743cdf0e10cSrcweir
744cdf0e10cSrcweir ScDPObject* pNewDPObject = NULL;
745cdf0e10cSrcweir
746cdf0e10cSrcweir // ScPivot is no longer used...
747cdf0e10cSrcweir ScDPObject* pDPObj = pDoc->GetDPAtCursor(
748cdf0e10cSrcweir pData->GetCurX(), pData->GetCurY(),
749cdf0e10cSrcweir pData->GetTabNo() );
750cdf0e10cSrcweir if ( pDPObj ) // on an existing table?
751cdf0e10cSrcweir {
752cdf0e10cSrcweir pNewDPObject = new ScDPObject( *pDPObj );
753cdf0e10cSrcweir }
754cdf0e10cSrcweir else // create new table
755cdf0e10cSrcweir {
756cdf0e10cSrcweir // select database range or data
757cdf0e10cSrcweir pTabViewShell->GetDBData( sal_True, SC_DB_OLD );
758cdf0e10cSrcweir ScMarkData& rMark = GetViewData()->GetMarkData();
759cdf0e10cSrcweir if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
760cdf0e10cSrcweir pTabViewShell->MarkDataArea( sal_False );
761cdf0e10cSrcweir
762cdf0e10cSrcweir // output to cursor position for non-sheet data
763cdf0e10cSrcweir ScAddress aDestPos( pData->GetCurX(), pData->GetCurY(),
764cdf0e10cSrcweir pData->GetTabNo() );
765cdf0e10cSrcweir
766cdf0e10cSrcweir // first select type of source data
767cdf0e10cSrcweir
768cdf0e10cSrcweir sal_Bool bEnableExt = ScDPObject::HasRegisteredSources();
769cdf0e10cSrcweir //CHINA001 ScDataPilotSourceTypeDlg* pTypeDlg = new ScDataPilotSourceTypeDlg(
770cdf0e10cSrcweir //CHINA001 pTabViewShell->GetDialogParent(), bEnableExt );
771cdf0e10cSrcweir
772cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
773cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
774cdf0e10cSrcweir
775cdf0e10cSrcweir AbstractScDataPilotSourceTypeDlg* pTypeDlg = pFact->CreateScDataPilotSourceTypeDlg( pTabViewShell->GetDialogParent(), bEnableExt, RID_SCDLG_DAPITYPE );
776cdf0e10cSrcweir DBG_ASSERT(pTypeDlg, "Dialog create fail!");//CHINA001
777cdf0e10cSrcweir if ( pTypeDlg->Execute() == RET_OK )
778cdf0e10cSrcweir {
779cdf0e10cSrcweir if ( pTypeDlg->IsExternal() )
780cdf0e10cSrcweir {
781cdf0e10cSrcweir uno::Sequence<rtl::OUString> aSources = ScDPObject::GetRegisteredSources();
782cdf0e10cSrcweir //CHINA001 ScDataPilotServiceDlg* pServDlg = new ScDataPilotServiceDlg(
783cdf0e10cSrcweir //CHINA001 pTabViewShell->GetDialogParent(), aSources );
784cdf0e10cSrcweir AbstractScDataPilotServiceDlg* pServDlg = pFact->CreateScDataPilotServiceDlg( pTabViewShell->GetDialogParent(), aSources, RID_SCDLG_DAPISERVICE );
785cdf0e10cSrcweir DBG_ASSERT(pServDlg, "Dialog create fail!");//CHINA001
786cdf0e10cSrcweir if ( pServDlg->Execute() == RET_OK )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir ScDPServiceDesc aServDesc(
789cdf0e10cSrcweir pServDlg->GetServiceName(),
790cdf0e10cSrcweir pServDlg->GetParSource(),
791cdf0e10cSrcweir pServDlg->GetParName(),
792cdf0e10cSrcweir pServDlg->GetParUser(),
793cdf0e10cSrcweir pServDlg->GetParPass() );
794cdf0e10cSrcweir pNewDPObject = new ScDPObject( pDoc );
795cdf0e10cSrcweir pNewDPObject->SetServiceData( aServDesc );
796cdf0e10cSrcweir }
797cdf0e10cSrcweir delete pServDlg;
798cdf0e10cSrcweir }
799cdf0e10cSrcweir else if ( pTypeDlg->IsDatabase() )
800cdf0e10cSrcweir {
801cdf0e10cSrcweir //CHINA001 ScDataPilotDatabaseDlg* pDataDlg = new ScDataPilotDatabaseDlg(
802cdf0e10cSrcweir //CHINA001 pTabViewShell->GetDialogParent() );
803cdf0e10cSrcweir //ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
804cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
805cdf0e10cSrcweir
806cdf0e10cSrcweir AbstractScDataPilotDatabaseDlg* pDataDlg = pFact->CreateScDataPilotDatabaseDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DAPIDATA);
807cdf0e10cSrcweir DBG_ASSERT(pDataDlg, "Dialog create fail!");//CHINA001
808cdf0e10cSrcweir if ( pDataDlg->Execute() == RET_OK )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir ScImportSourceDesc aImpDesc;
811cdf0e10cSrcweir pDataDlg->GetValues( aImpDesc );
812cdf0e10cSrcweir pNewDPObject = new ScDPObject( pDoc );
813cdf0e10cSrcweir pNewDPObject->SetImportDesc( aImpDesc );
814cdf0e10cSrcweir }
815cdf0e10cSrcweir delete pDataDlg;
816cdf0e10cSrcweir }
817cdf0e10cSrcweir else // selection
818cdf0e10cSrcweir {
819cdf0e10cSrcweir //! use database ranges (select before type dialog?)
820cdf0e10cSrcweir ScRange aRange;
821cdf0e10cSrcweir ScMarkType eType = GetViewData()->GetSimpleArea(aRange);
822cdf0e10cSrcweir if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir // Shrink the range to the data area.
825cdf0e10cSrcweir SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
826cdf0e10cSrcweir SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
827cdf0e10cSrcweir if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
828cdf0e10cSrcweir {
829cdf0e10cSrcweir aRange.aStart.SetCol(nStartCol);
830cdf0e10cSrcweir aRange.aStart.SetRow(nStartRow);
831cdf0e10cSrcweir aRange.aEnd.SetCol(nEndCol);
832cdf0e10cSrcweir aRange.aEnd.SetRow(nEndRow);
833cdf0e10cSrcweir rMark.SetMarkArea(aRange);
834cdf0e10cSrcweir pTabViewShell->MarkRange(aRange);
835cdf0e10cSrcweir }
836cdf0e10cSrcweir
837cdf0e10cSrcweir sal_Bool bOK = sal_True;
838cdf0e10cSrcweir if ( pDoc->HasSubTotalCells( aRange ) )
839cdf0e10cSrcweir {
840cdf0e10cSrcweir // confirm selection if it contains SubTotal cells
841cdf0e10cSrcweir
842cdf0e10cSrcweir QueryBox aBox( pTabViewShell->GetDialogParent(),
843cdf0e10cSrcweir WinBits(WB_YES_NO | WB_DEF_YES),
844cdf0e10cSrcweir ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL) );
845cdf0e10cSrcweir if (aBox.Execute() == RET_NO)
846cdf0e10cSrcweir bOK = sal_False;
847cdf0e10cSrcweir }
848cdf0e10cSrcweir if (bOK)
849cdf0e10cSrcweir {
850cdf0e10cSrcweir ScSheetSourceDesc aShtDesc;
851cdf0e10cSrcweir aShtDesc.aSourceRange = aRange;
852cdf0e10cSrcweir pNewDPObject = new ScDPObject( pDoc );
853cdf0e10cSrcweir pNewDPObject->SetSheetDesc( aShtDesc );
854cdf0e10cSrcweir
855cdf0e10cSrcweir // output below source data
856cdf0e10cSrcweir if ( aRange.aEnd.Row()+2 <= MAXROW - 4 )
857cdf0e10cSrcweir aDestPos = ScAddress( aRange.aStart.Col(),
858cdf0e10cSrcweir aRange.aEnd.Row()+2,
859cdf0e10cSrcweir aRange.aStart.Tab() );
860cdf0e10cSrcweir }
861cdf0e10cSrcweir }
862cdf0e10cSrcweir }
863cdf0e10cSrcweir }
864cdf0e10cSrcweir delete pTypeDlg;
865cdf0e10cSrcweir
866cdf0e10cSrcweir if ( pNewDPObject )
867cdf0e10cSrcweir pNewDPObject->SetOutRange( aDestPos );
868cdf0e10cSrcweir
869cdf0e10cSrcweir #if 0
870cdf0e10cSrcweir ScDBData* pDBData = pTabViewShell->GetDBData();
871cdf0e10cSrcweir String aErrMsg;
872cdf0e10cSrcweir
873cdf0e10cSrcweir pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 );
874cdf0e10cSrcweir
875cdf0e10cSrcweir bAreaOk = sal_True;
876cdf0e10cSrcweir if ( nRow2-nRow1 < 1 )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir // "mindestens eine Datenzeile"
879cdf0e10cSrcweir pTabViewShell->ErrorMessage(STR_PIVOT_INVALID_DBAREA);
880cdf0e10cSrcweir bAreaOk = sal_False;
881cdf0e10cSrcweir }
882cdf0e10cSrcweir else if (!pDBData->HasHeader())
883cdf0e10cSrcweir {
884cdf0e10cSrcweir if ( MessBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
885cdf0e10cSrcweir ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc"
886cdf0e10cSrcweir ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) // Koepfe aus erster Zeile?
887cdf0e10cSrcweir ).Execute() == RET_YES )
888cdf0e10cSrcweir {
889cdf0e10cSrcweir pDBData->SetHeader( sal_True ); //! Undo ??
890cdf0e10cSrcweir }
891cdf0e10cSrcweir else
892cdf0e10cSrcweir bAreaOk = sal_False;
893cdf0e10cSrcweir }
894cdf0e10cSrcweir #endif
895cdf0e10cSrcweir }
896cdf0e10cSrcweir
897cdf0e10cSrcweir pTabViewShell->SetDialogDPObject( pNewDPObject ); // is copied
898cdf0e10cSrcweir if ( pNewDPObject )
899cdf0e10cSrcweir {
900cdf0e10cSrcweir // start layout dialog
901cdf0e10cSrcweir
902cdf0e10cSrcweir sal_uInt16 nId = ScPivotLayoutWrapper::GetChildWindowId();
903cdf0e10cSrcweir SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
904cdf0e10cSrcweir SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
905cdf0e10cSrcweir pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
906cdf0e10cSrcweir }
907cdf0e10cSrcweir delete pNewDPObject;
908cdf0e10cSrcweir }
909cdf0e10cSrcweir break;
910cdf0e10cSrcweir
911cdf0e10cSrcweir case SID_DEFINE_DBNAME:
912cdf0e10cSrcweir {
913cdf0e10cSrcweir
914cdf0e10cSrcweir sal_uInt16 nId = ScDbNameDlgWrapper::GetChildWindowId();
915cdf0e10cSrcweir SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
916cdf0e10cSrcweir SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
917cdf0e10cSrcweir
918cdf0e10cSrcweir pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
919cdf0e10cSrcweir
920cdf0e10cSrcweir }
921cdf0e10cSrcweir break;
922cdf0e10cSrcweir
923cdf0e10cSrcweir case SID_SELECT_DB:
924cdf0e10cSrcweir {
925cdf0e10cSrcweir if ( pReqArgs )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir const SfxStringItem* pItem =
928cdf0e10cSrcweir (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_DB );
929cdf0e10cSrcweir
930cdf0e10cSrcweir if( pItem )
931cdf0e10cSrcweir {
932cdf0e10cSrcweir pTabViewShell->GotoDBArea( pItem->GetValue() );
933cdf0e10cSrcweir rReq.Done();
934cdf0e10cSrcweir }
935cdf0e10cSrcweir else
936cdf0e10cSrcweir {
937cdf0e10cSrcweir DBG_ERROR("NULL");
938cdf0e10cSrcweir }
939cdf0e10cSrcweir }
940cdf0e10cSrcweir else
941cdf0e10cSrcweir {
942cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument();
943cdf0e10cSrcweir ScDBCollection* pDBCol = pDoc->GetDBCollection();
944cdf0e10cSrcweir
945cdf0e10cSrcweir if ( pDBCol )
946cdf0e10cSrcweir {
947cdf0e10cSrcweir List aList;
948cdf0e10cSrcweir sal_uInt16 nDBCount = pDBCol->GetCount();
949cdf0e10cSrcweir ScDBData* pDbData = NULL;
950cdf0e10cSrcweir String* pDBName = NULL;
951cdf0e10cSrcweir
952cdf0e10cSrcweir for ( sal_uInt16 i=0; i < nDBCount; i++ )
953cdf0e10cSrcweir {
954cdf0e10cSrcweir pDbData = (ScDBData*)(pDBCol->At( i ));
955cdf0e10cSrcweir if ( pDbData )
956cdf0e10cSrcweir {
957cdf0e10cSrcweir pDBName = new String;
958cdf0e10cSrcweir pDbData->GetName( *pDBName );
959cdf0e10cSrcweir
960*22407013SOliver-Rainer Wittmann if ( !pDbData->IsInternalUnnamed() )
961cdf0e10cSrcweir aList.Insert( pDBName );
962cdf0e10cSrcweir else
963cdf0e10cSrcweir DELETEZ(pDBName);
964cdf0e10cSrcweir }
965cdf0e10cSrcweir }
966cdf0e10cSrcweir
967cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
968cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
969cdf0e10cSrcweir
970cdf0e10cSrcweir AbstractScSelEntryDlg* pDlg = pFact->CreateScSelEntryDlg( pTabViewShell->GetDialogParent(),
971cdf0e10cSrcweir RID_SCDLG_SELECTDB,
972cdf0e10cSrcweir String(ScResId(SCSTR_SELECTDB)),
973cdf0e10cSrcweir String(ScResId(SCSTR_AREAS)),
974cdf0e10cSrcweir aList,
975cdf0e10cSrcweir RID_SCDLG_SELECTDB);
976cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
977cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK )
978cdf0e10cSrcweir {
979cdf0e10cSrcweir String aName = pDlg->GetSelectEntry();
980cdf0e10cSrcweir pTabViewShell->GotoDBArea( aName );
981cdf0e10cSrcweir rReq.AppendItem( SfxStringItem( SID_SELECT_DB, aName ) );
982cdf0e10cSrcweir rReq.Done();
983cdf0e10cSrcweir }
984cdf0e10cSrcweir
985cdf0e10cSrcweir delete pDlg;
986cdf0e10cSrcweir
987cdf0e10cSrcweir void* pEntry = aList.First();
988cdf0e10cSrcweir while ( pEntry )
989cdf0e10cSrcweir {
990cdf0e10cSrcweir delete (String*) aList.Remove( pEntry );
991cdf0e10cSrcweir pEntry = aList.Next();
992cdf0e10cSrcweir }
993cdf0e10cSrcweir }
994cdf0e10cSrcweir }
995cdf0e10cSrcweir }
996cdf0e10cSrcweir break;
997cdf0e10cSrcweir
998cdf0e10cSrcweir case FID_VALIDATION:
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir const SfxPoolItem* pItem;
1001cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
1002cdf0e10cSrcweir if ( pArgs )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir DBG_ERROR("spaeter...");
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir else
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir //CHINA001 SfxItemSet aArgSet( GetPool(), ScTPValidationValue::GetRanges() );
1009cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1010cdf0e10cSrcweir DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1011cdf0e10cSrcweir ::GetTabPageRanges ScTPValidationValueGetRanges = pFact->GetTabPageRangesFunc(TP_VALIDATION_VALUES);
1012cdf0e10cSrcweir DBG_ASSERT(ScTPValidationValueGetRanges, "TabPage create fail!");//CHINA001
1013cdf0e10cSrcweir SfxItemSet aArgSet( GetPool(), (*ScTPValidationValueGetRanges)() );//CHINA001
1014cdf0e10cSrcweir ScValidationMode eMode = SC_VALID_ANY;
1015cdf0e10cSrcweir ScConditionMode eOper = SC_COND_EQUAL;
1016cdf0e10cSrcweir String aExpr1, aExpr2;
1017cdf0e10cSrcweir sal_Bool bBlank = sal_True;
1018cdf0e10cSrcweir sal_Int16 nListType = ValidListType::UNSORTED;
1019cdf0e10cSrcweir sal_Bool bShowHelp = sal_False;
1020cdf0e10cSrcweir String aHelpTitle, aHelpText;
1021cdf0e10cSrcweir sal_Bool bShowError = sal_False;
1022cdf0e10cSrcweir ScValidErrorStyle eErrStyle = SC_VALERR_STOP;
1023cdf0e10cSrcweir String aErrTitle, aErrText;
1024cdf0e10cSrcweir
1025cdf0e10cSrcweir ScDocument* pDoc = GetViewData()->GetDocument();
1026cdf0e10cSrcweir SCCOL nCurX = GetViewData()->GetCurX();
1027cdf0e10cSrcweir SCROW nCurY = GetViewData()->GetCurY();
1028cdf0e10cSrcweir SCTAB nTab = GetViewData()->GetTabNo();
1029cdf0e10cSrcweir ScAddress aCursorPos( nCurX, nCurY, nTab );
1030cdf0e10cSrcweir sal_uLong nIndex = ((SfxUInt32Item*)pDoc->GetAttr(
1031cdf0e10cSrcweir nCurX, nCurY, nTab, ATTR_VALIDDATA ))->GetValue();
1032cdf0e10cSrcweir if ( nIndex )
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir const ScValidationData* pOldData = pDoc->GetValidationEntry( nIndex );
1035cdf0e10cSrcweir if ( pOldData )
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir eMode = pOldData->GetDataMode();
1038cdf0e10cSrcweir eOper = pOldData->GetOperation();
1039cdf0e10cSrcweir sal_uLong nNumFmt = 0;
1040cdf0e10cSrcweir if ( eMode == SC_VALID_DATE || eMode == SC_VALID_TIME )
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir short nType = ( eMode == SC_VALID_DATE ) ? NUMBERFORMAT_DATE
1043cdf0e10cSrcweir : NUMBERFORMAT_TIME;
1044cdf0e10cSrcweir nNumFmt = pDoc->GetFormatTable()->GetStandardFormat(
1045cdf0e10cSrcweir nType, ScGlobal::eLnge );
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir aExpr1 = pOldData->GetExpression( aCursorPos, 0, nNumFmt );
1048cdf0e10cSrcweir aExpr2 = pOldData->GetExpression( aCursorPos, 1, nNumFmt );
1049cdf0e10cSrcweir bBlank = pOldData->IsIgnoreBlank();
1050cdf0e10cSrcweir nListType = pOldData->GetListType();
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir bShowHelp = pOldData->GetInput( aHelpTitle, aHelpText );
1053cdf0e10cSrcweir bShowError = pOldData->GetErrMsg( aErrTitle, aErrText, eErrStyle );
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir aArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(eMode) ) );
1056cdf0e10cSrcweir aArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(eOper) ) );
1057cdf0e10cSrcweir aArgSet.Put( SfxStringItem( FID_VALID_VALUE1, aExpr1 ) );
1058cdf0e10cSrcweir aArgSet.Put( SfxStringItem( FID_VALID_VALUE2, aExpr2 ) );
1059cdf0e10cSrcweir aArgSet.Put( SfxBoolItem( FID_VALID_BLANK, bBlank ) );
1060cdf0e10cSrcweir aArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
1061cdf0e10cSrcweir aArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, bShowHelp ) );
1062cdf0e10cSrcweir aArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aHelpTitle ) );
1063cdf0e10cSrcweir aArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aHelpText ) );
1064cdf0e10cSrcweir aArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, bShowError ) );
1065cdf0e10cSrcweir aArgSet.Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, sal::static_int_cast<sal_uInt16>(eErrStyle) ) );
1066cdf0e10cSrcweir aArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aErrTitle ) );
1067cdf0e10cSrcweir aArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aErrText ) );
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir }
1070cdf0e10cSrcweir
1071cdf0e10cSrcweir //CHINA001 ScValidationDlg* pDlg = new ScValidationDlg( NULL, &aArgSet );
1072cdf0e10cSrcweir //CHINA001 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1073cdf0e10cSrcweir //CHINA001 DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
1074cdf0e10cSrcweir
1075cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker
1076cdf0e10cSrcweir //SfxAbstractTabDialog* pDlg = pFact->CreateScValidationDlg( NULL, &aArgSet, TAB_DLG_VALIDATION );
1077cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateScValidationDlg( NULL, &aArgSet, TAB_DLG_VALIDATION, pTabViewShell );
1078cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker
1079cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
1080cdf0e10cSrcweir
1081cdf0e10cSrcweir //<!--Modified by PengYunQuan for Validity Cell Range Picker
1082cdf0e10cSrcweir //if ( pDlg->Execute() == RET_OK )
1083cdf0e10cSrcweir short nResult = pDlg->Execute();
1084cdf0e10cSrcweir pTabViewShell->SetTabNo( nTab );//When picking Cell Range ,other Tab may be switched. Need restore the correct tab
1085cdf0e10cSrcweir if ( nResult == RET_OK )
1086cdf0e10cSrcweir //-->Modified by PengYunQuan for Validity Cell Range Picker
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_MODE, sal_True, &pItem ) == SFX_ITEM_SET )
1091cdf0e10cSrcweir eMode = (ScValidationMode) ((const SfxAllEnumItem*)pItem)->GetValue();
1092cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_CONDMODE, sal_True, &pItem ) == SFX_ITEM_SET )
1093cdf0e10cSrcweir eOper = (ScConditionMode) ((const SfxAllEnumItem*)pItem)->GetValue();
1094cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_VALUE1, sal_True, &pItem ) == SFX_ITEM_SET )
1095cdf0e10cSrcweir {
1096cdf0e10cSrcweir String aTemp1 = ((const SfxStringItem*)pItem)->GetValue();
1097cdf0e10cSrcweir if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir sal_uInt32 nNumIndex = 0;
1100cdf0e10cSrcweir double nVal;
1101cdf0e10cSrcweir if (pDoc->GetFormatTable()->IsNumberFormat(aTemp1, nNumIndex, nVal))
1102cdf0e10cSrcweir aExpr1 =String( ::rtl::math::doubleToUString( nVal,
1103cdf0e10cSrcweir rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
1104cdf0e10cSrcweir ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), sal_True));
1105cdf0e10cSrcweir else
1106cdf0e10cSrcweir aExpr1 = aTemp1;
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir else
1109cdf0e10cSrcweir aExpr1 = aTemp1;
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_VALUE2, sal_True, &pItem ) == SFX_ITEM_SET )
1112cdf0e10cSrcweir {
1113cdf0e10cSrcweir String aTemp2 = ((const SfxStringItem*)pItem)->GetValue();
1114cdf0e10cSrcweir if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir sal_uInt32 nNumIndex = 0;
1117cdf0e10cSrcweir double nVal;
1118cdf0e10cSrcweir if (pDoc->GetFormatTable()->IsNumberFormat(aTemp2, nNumIndex, nVal))
1119cdf0e10cSrcweir aExpr2 =String( ::rtl::math::doubleToUString( nVal,
1120cdf0e10cSrcweir rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
1121cdf0e10cSrcweir ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), sal_True));
1122cdf0e10cSrcweir else
1123cdf0e10cSrcweir aExpr2 = aTemp2;
1124cdf0e10cSrcweir }
1125cdf0e10cSrcweir else
1126cdf0e10cSrcweir aExpr2 = aTemp2;
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir
1129cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_BLANK, sal_True, &pItem ) == SFX_ITEM_SET )
1130cdf0e10cSrcweir bBlank = ((const SfxBoolItem*)pItem)->GetValue();
1131cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_LISTTYPE, sal_True, &pItem ) == SFX_ITEM_SET )
1132cdf0e10cSrcweir nListType = ((const SfxInt16Item*)pItem)->GetValue();
1133cdf0e10cSrcweir
1134cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_SHOWHELP, sal_True, &pItem ) == SFX_ITEM_SET )
1135cdf0e10cSrcweir bShowHelp = ((const SfxBoolItem*)pItem)->GetValue();
1136cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_HELPTITLE, sal_True, &pItem ) == SFX_ITEM_SET )
1137cdf0e10cSrcweir aHelpTitle = ((const SfxStringItem*)pItem)->GetValue();
1138cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_HELPTEXT, sal_True, &pItem ) == SFX_ITEM_SET )
1139cdf0e10cSrcweir aHelpText = ((const SfxStringItem*)pItem)->GetValue();
1140cdf0e10cSrcweir
1141cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_SHOWERR, sal_True, &pItem ) == SFX_ITEM_SET )
1142cdf0e10cSrcweir bShowError = ((const SfxBoolItem*)pItem)->GetValue();
1143cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_ERRSTYLE, sal_True, &pItem ) == SFX_ITEM_SET )
1144cdf0e10cSrcweir eErrStyle = (ScValidErrorStyle) ((const SfxAllEnumItem*)pItem)->GetValue();
1145cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_ERRTITLE, sal_True, &pItem ) == SFX_ITEM_SET )
1146cdf0e10cSrcweir aErrTitle = ((const SfxStringItem*)pItem)->GetValue();
1147cdf0e10cSrcweir if ( pOutSet->GetItemState( FID_VALID_ERRTEXT, sal_True, &pItem ) == SFX_ITEM_SET )
1148cdf0e10cSrcweir aErrText = ((const SfxStringItem*)pItem)->GetValue();
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir ScValidationData aData( eMode, eOper, aExpr1, aExpr2, pDoc, aCursorPos );
1151cdf0e10cSrcweir aData.SetIgnoreBlank( bBlank );
1152cdf0e10cSrcweir aData.SetListType( nListType );
1153cdf0e10cSrcweir
1154cdf0e10cSrcweir aData.SetInput(aHelpTitle, aHelpText); // sets bShowInput to TRUE
1155cdf0e10cSrcweir if (!bShowHelp)
1156cdf0e10cSrcweir aData.ResetInput(); // reset only bShowInput
1157cdf0e10cSrcweir
1158cdf0e10cSrcweir aData.SetError(aErrTitle, aErrText, eErrStyle); // sets bShowError to TRUE
1159cdf0e10cSrcweir if (!bShowError)
1160cdf0e10cSrcweir aData.ResetError(); // reset only bShowError
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir pTabViewShell->SetValidation( aData );
1163cdf0e10cSrcweir rReq.Done( *pOutSet );
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir //<!-- Modified by PengYunQuan for Validity Cell Range Picker
1166cdf0e10cSrcweir //after end execute from !IsModalInputMode, it is safer to delay deleting
1167cdf0e10cSrcweir //delete pDlg;
1168cdf0e10cSrcweir Application::PostUserEvent( Link( pDlg, &DelayDeleteAbstractDialog ) );
1169cdf0e10cSrcweir //--> Modified by PengYunQuan for Validity Cell Range Picker
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir break;
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir case SID_TEXT_TO_COLUMNS:
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir ScViewData* pData = GetViewData();
1177cdf0e10cSrcweir DBG_ASSERT( pData, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pData is null!" );
1178cdf0e10cSrcweir ScRange aRange;
1179cdf0e10cSrcweir
1180cdf0e10cSrcweir if ( lcl_GetTextToColumnsRange( pData, aRange ) )
1181cdf0e10cSrcweir {
1182cdf0e10cSrcweir ScDocument* pDoc = pData->GetDocument();
1183cdf0e10cSrcweir DBG_ASSERT( pDoc, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDoc is null!" );
1184cdf0e10cSrcweir
1185cdf0e10cSrcweir ScImportExport aExport( pDoc, aRange );
1186cdf0e10cSrcweir aExport.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::None, 0, false ) );
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir // #i87703# text to columns fails with tab separator
1189cdf0e10cSrcweir aExport.SetDelimiter( static_cast< sal_Unicode >( 0 ) );
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir SvMemoryStream aStream;
1192cdf0e10cSrcweir aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
1193cdf0e10cSrcweir ScImportExport::SetNoEndianSwap( aStream );
1194cdf0e10cSrcweir aExport.ExportStream( aStream, String(), FORMAT_STRING );
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1197cdf0e10cSrcweir DBG_ASSERT( pFact, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pFact is null!" );
1198cdf0e10cSrcweir AbstractScImportAsciiDlg *pDlg = pFact->CreateScImportAsciiDlg(
1199cdf0e10cSrcweir NULL, String(), &aStream, RID_SCDLG_ASCII );
1200cdf0e10cSrcweir DBG_ASSERT( pDlg, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDlg is null!" );
1201cdf0e10cSrcweir pDlg->SetTextToColumnsMode();
1202cdf0e10cSrcweir
1203cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir ScDocShell* pDocSh = pData->GetDocShell();
1206cdf0e10cSrcweir DBG_ASSERT( pDocSh, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDocSh is null!" );
1207cdf0e10cSrcweir
1208cdf0e10cSrcweir String aUndo = ScGlobal::GetRscString( STR_UNDO_TEXTTOCOLUMNS );
1209cdf0e10cSrcweir pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir ScImportExport aImport( pDoc, aRange.aStart );
1212cdf0e10cSrcweir ScAsciiOptions aOptions;
1213cdf0e10cSrcweir pDlg->GetOptions( aOptions );
1214cdf0e10cSrcweir aImport.SetExtOptions( aOptions );
1215cdf0e10cSrcweir aImport.SetApi( false );
1216cdf0e10cSrcweir aStream.Seek( 0 );
1217cdf0e10cSrcweir aImport.ImportStream( aStream, String(), FORMAT_STRING );
1218cdf0e10cSrcweir
1219cdf0e10cSrcweir pDocSh->GetUndoManager()->LeaveListAction();
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir delete pDlg;
1222cdf0e10cSrcweir }
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir break;
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir }
1227cdf0e10cSrcweir
GetDBState(SfxItemSet & rSet)1228cdf0e10cSrcweir void __EXPORT ScCellShell::GetDBState( SfxItemSet& rSet )
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
1231cdf0e10cSrcweir ScViewData* pData = GetViewData();
1232cdf0e10cSrcweir ScDocShell* pDocSh = pData->GetDocShell();
1233cdf0e10cSrcweir ScDocument* pDoc = pDocSh->GetDocument();
1234cdf0e10cSrcweir SCCOL nPosX = pData->GetCurX();
1235cdf0e10cSrcweir SCROW nPosY = pData->GetCurY();
1236cdf0e10cSrcweir SCTAB nTab = pData->GetTabNo();
1237cdf0e10cSrcweir
1238cdf0e10cSrcweir sal_Bool bAutoFilter = sal_False;
1239cdf0e10cSrcweir sal_Bool bAutoFilterTested = sal_False;
1240cdf0e10cSrcweir
1241cdf0e10cSrcweir SfxWhichIter aIter(rSet);
1242cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
1243cdf0e10cSrcweir while (nWhich)
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir switch (nWhich)
1246cdf0e10cSrcweir {
1247cdf0e10cSrcweir case SID_REFRESH_DBAREA:
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir // importierte Daten ohne Selektion
1250cdf0e10cSrcweir // oder Filter,Sortierung,Teilergebis (auch ohne Import)
1251cdf0e10cSrcweir sal_Bool bOk = sal_False;
1252cdf0e10cSrcweir ScDBData* pDBData = pTabViewShell->GetDBData(sal_False,SC_DB_OLD);
1253cdf0e10cSrcweir if (pDBData && pDoc->GetChangeTrack() == NULL)
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir if ( pDBData->HasImportParam() )
1256cdf0e10cSrcweir bOk = !pDBData->HasImportSelection();
1257cdf0e10cSrcweir else
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir bOk = pDBData->HasQueryParam() ||
1260cdf0e10cSrcweir pDBData->HasSortParam() ||
1261cdf0e10cSrcweir pDBData->HasSubTotalParam();
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir }
1264cdf0e10cSrcweir if (!bOk)
1265cdf0e10cSrcweir rSet.DisableItem( nWhich );
1266cdf0e10cSrcweir }
1267cdf0e10cSrcweir break;
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir case SID_FILTER:
1270cdf0e10cSrcweir case SID_SPECIAL_FILTER:
1271cdf0e10cSrcweir {
1272cdf0e10cSrcweir ScRange aDummy;
1273cdf0e10cSrcweir ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
1274cdf0e10cSrcweir if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1275cdf0e10cSrcweir {
1276cdf0e10cSrcweir rSet.DisableItem( nWhich );
1277cdf0e10cSrcweir }
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir break;
1280cdf0e10cSrcweir
1281cdf0e10cSrcweir
1282cdf0e10cSrcweir //Bei Redlining und Multiselektion Disablen
1283cdf0e10cSrcweir case SID_SORT_ASCENDING:
1284cdf0e10cSrcweir case SID_SORT_DESCENDING:
1285cdf0e10cSrcweir case SCITEM_SORTDATA:
1286cdf0e10cSrcweir case SCITEM_SUBTDATA:
1287cdf0e10cSrcweir case SID_OPENDLG_PIVOTTABLE:
1288cdf0e10cSrcweir {
1289cdf0e10cSrcweir //! move ReadOnly check to idl flags
1290cdf0e10cSrcweir
1291cdf0e10cSrcweir if ( pDocSh->IsReadOnly() || pDoc->GetChangeTrack()!=NULL ||
1292cdf0e10cSrcweir GetViewData()->IsMultiMarked() )
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir rSet.DisableItem( nWhich );
1295cdf0e10cSrcweir }
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir break;
1298cdf0e10cSrcweir
1299cdf0e10cSrcweir case SID_REIMPORT_DATA:
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir // nur importierte Daten ohne Selektion
1302cdf0e10cSrcweir ScDBData* pDBData = pTabViewShell->GetDBData(sal_False,SC_DB_OLD);
1303cdf0e10cSrcweir if (!pDBData || !pDBData->HasImportParam() || pDBData->HasImportSelection() ||
1304cdf0e10cSrcweir pDoc->GetChangeTrack()!=NULL)
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir rSet.DisableItem( nWhich );
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir }
1309cdf0e10cSrcweir break;
1310cdf0e10cSrcweir
1311cdf0e10cSrcweir case SID_VIEW_DATA_SOURCE_BROWSER:
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
1314cdf0e10cSrcweir rSet.Put(SfxVisibilityItem(nWhich, sal_False));
1315cdf0e10cSrcweir else
1316cdf0e10cSrcweir // get state (BoolItem) from SfxViewFrame
1317cdf0e10cSrcweir pTabViewShell->GetViewFrame()->GetSlotState( nWhich, NULL, &rSet );
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir break;
1320cdf0e10cSrcweir case SID_SBA_BRW_INSERT:
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir // SBA will ein sal_Bool-Item, damit ueberhaupt enabled
1323cdf0e10cSrcweir
1324cdf0e10cSrcweir sal_Bool bEnable = sal_True;
1325cdf0e10cSrcweir rSet.Put(SfxBoolItem(nWhich, bEnable));
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir break;
1328cdf0e10cSrcweir
1329cdf0e10cSrcweir case SID_AUTO_FILTER:
1330cdf0e10cSrcweir case SID_AUTOFILTER_HIDE:
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir if (!bAutoFilterTested)
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir bAutoFilter = pDoc->HasAutoFilter( nPosX, nPosY, nTab );
1335cdf0e10cSrcweir bAutoFilterTested = sal_True;
1336cdf0e10cSrcweir }
1337cdf0e10cSrcweir if ( nWhich == SID_AUTO_FILTER )
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir ScRange aDummy;
1340cdf0e10cSrcweir ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
1341cdf0e10cSrcweir if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1342cdf0e10cSrcweir {
1343cdf0e10cSrcweir rSet.DisableItem( nWhich );
1344cdf0e10cSrcweir }
1345cdf0e10cSrcweir else if (pDoc->GetDPAtBlock(aDummy))
1346cdf0e10cSrcweir {
1347cdf0e10cSrcweir rSet.DisableItem( nWhich );
1348cdf0e10cSrcweir }
1349cdf0e10cSrcweir else
1350cdf0e10cSrcweir rSet.Put( SfxBoolItem( nWhich, bAutoFilter ) );
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir else
1353cdf0e10cSrcweir if (!bAutoFilter)
1354cdf0e10cSrcweir rSet.DisableItem( nWhich );
1355cdf0e10cSrcweir }
1356cdf0e10cSrcweir break;
1357cdf0e10cSrcweir
1358cdf0e10cSrcweir case SID_UNFILTER:
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir SCCOL nStartCol, nEndCol;
1361cdf0e10cSrcweir SCROW nStartRow, nEndRow;
1362cdf0e10cSrcweir SCTAB nStartTab, nEndTab;
1363cdf0e10cSrcweir sal_Bool bAnyQuery = sal_False;
1364cdf0e10cSrcweir
1365cdf0e10cSrcweir sal_Bool bSelected = (GetViewData()->GetSimpleArea(
1366cdf0e10cSrcweir nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab )
1367cdf0e10cSrcweir == SC_MARK_SIMPLE);
1368cdf0e10cSrcweir
1369cdf0e10cSrcweir if ( bSelected )
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir if (nStartCol==nEndCol && nStartRow==nEndRow)
1372cdf0e10cSrcweir bSelected = sal_False;
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir else
1375cdf0e10cSrcweir {
1376cdf0e10cSrcweir nStartCol = GetViewData()->GetCurX();
1377cdf0e10cSrcweir nStartRow = GetViewData()->GetCurY();
1378cdf0e10cSrcweir nStartTab = GetViewData()->GetTabNo();
1379cdf0e10cSrcweir }
1380cdf0e10cSrcweir
1381cdf0e10cSrcweir ScDBData* pDBData = bSelected
1382cdf0e10cSrcweir ? pDoc->GetDBAtArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow )
1383cdf0e10cSrcweir : pDoc->GetDBAtCursor( nStartCol, nStartRow, nStartTab );
1384cdf0e10cSrcweir
1385cdf0e10cSrcweir if ( pDBData )
1386cdf0e10cSrcweir {
1387cdf0e10cSrcweir ScQueryParam aParam;
1388cdf0e10cSrcweir pDBData->GetQueryParam( aParam );
1389cdf0e10cSrcweir if ( aParam.GetEntry(0).bDoQuery )
1390cdf0e10cSrcweir bAnyQuery = sal_True;
1391cdf0e10cSrcweir }
1392cdf0e10cSrcweir
1393cdf0e10cSrcweir if ( !bAnyQuery )
1394cdf0e10cSrcweir rSet.DisableItem( nWhich );
1395cdf0e10cSrcweir }
1396cdf0e10cSrcweir break;
1397cdf0e10cSrcweir
1398cdf0e10cSrcweir case SID_DEFINE_DBNAME:
1399cdf0e10cSrcweir {
1400cdf0e10cSrcweir if ( pDocSh && pDocSh->IsDocShared() )
1401cdf0e10cSrcweir {
1402cdf0e10cSrcweir rSet.DisableItem( nWhich );
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir break;
1406cdf0e10cSrcweir
1407cdf0e10cSrcweir case SID_TEXT_TO_COLUMNS:
1408cdf0e10cSrcweir {
1409cdf0e10cSrcweir ScRange aRange;
1410cdf0e10cSrcweir if ( !lcl_GetTextToColumnsRange( pData, aRange ) )
1411cdf0e10cSrcweir {
1412cdf0e10cSrcweir rSet.DisableItem( nWhich );
1413cdf0e10cSrcweir }
1414cdf0e10cSrcweir }
1415cdf0e10cSrcweir break;
1416cdf0e10cSrcweir }
1417cdf0e10cSrcweir nWhich = aIter.NextWhich();
1418cdf0e10cSrcweir }
1419cdf0e10cSrcweir }
1420cdf0e10cSrcweir
1421cdf0e10cSrcweir
1422cdf0e10cSrcweir
1423