summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-07-16 19:06:50 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-07-19 16:57:37 +0200
commitf2c9aa43666101c6970ea33f50fb4e780b99b97c (patch)
treebadef17067ab93d4f2f65ab013040eb92beee2a8
parentd2734a6ae65dc655787ba5a48d1fb5f44905a937 (diff)
fdo#66477 Add sampling feature to calc
Initial implementation of SamplingDialog. Change-Id: If26e8561705229f83777fb50d53c86b9fe056ffa
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu8
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/UIConfig_scalc.mk1
-rw-r--r--sc/inc/sc.hrc1
-rw-r--r--sc/sdi/cellsh.sdi3
-rw-r--r--sc/sdi/scalc.sdi22
-rw-r--r--sc/source/ui/StatisticsDialogs/SamplingDialog.cxx251
-rw-r--r--sc/source/ui/app/scdll.cxx1
-rw-r--r--sc/source/ui/inc/SamplingDialog.hxx79
-rw-r--r--sc/source/ui/inc/reffact.hxx1
-rw-r--r--sc/source/ui/view/cellsh.cxx1
-rw-r--r--sc/source/ui/view/cellsh1.cxx11
-rw-r--r--sc/source/ui/view/reffact.cxx74
-rw-r--r--sc/source/ui/view/tabvwsh.cxx1
-rw-r--r--sc/source/ui/view/tabvwshc.cxx8
-rw-r--r--sc/uiconfig/scalc/menubar/menubar.xml1
-rw-r--r--sc/uiconfig/scalc/ui/samplingdialog.ui202
17 files changed, 602 insertions, 64 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index 3df5946ffd76..1be53ec37b2c 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -632,6 +632,14 @@
<value xml:lang="en-US">R~andom Number...</value>
</prop>
</node>
+ <node oor:name=".uno:SamplingDialog" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">~Sampling...</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
<node oor:name=".uno:EditHeaderAndFooter" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Headers &amp; Footers...</value>
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index c72a967ce97c..76382ddc4ef3 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -474,6 +474,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/sidebar/NumberFormatPropertyPanel \
sc/source/ui/sidebar/ScPanelFactory \
sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog \
+ sc/source/ui/StatisticsDialogs/SamplingDialog \
sc/source/ui/undo/areasave \
sc/source/ui/undo/refundo \
sc/source/ui/undo/target \
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 6164084094d6..a740f25cd8e1 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -95,6 +95,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/randomnumbergenerator \
sc/uiconfig/scalc/ui/rightfooterdialog \
sc/uiconfig/scalc/ui/rightheaderdialog \
+ sc/uiconfig/scalc/ui/samplingdialog \
sc/uiconfig/scalc/ui/standardfilterdialog \
sc/uiconfig/scalc/ui/scgeneralpage \
sc/uiconfig/scalc/ui/selectrange \
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index b0842a2614d1..35e6d05fa656 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -253,6 +253,7 @@
#define SID_OPENDLG_CONDDATE (SC_MESSAGE_START + 69)
#define SID_OPENDLG_RANDOM_NUMBER_GENERATOR (SC_MESSAGE_START + 70)
+#define SID_SAMPLING_DIALOG (SC_MESSAGE_START + 71)
// functions
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 683ddc840c48..bf98c9485016 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -147,7 +147,8 @@ interface CellSelection
FID_FILL_TAB [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
FID_FILL_SERIES [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
FID_FILL_AUTO [ ExecMethod = ExecuteEdit; StateMethod = GetState; ]
- SID_OPENDLG_RANDOM_NUMBER_GENERATOR [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
+ SID_OPENDLG_RANDOM_NUMBER_GENERATOR [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
+ SID_SAMPLING_DIALOG [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_MARKDATAAREA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_MARKARRAYFORMULA [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
SID_SETINPUTMODE [ ExecMethod = ExecuteMove; StateMethod = GetStateCursor; ]
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 9520604ed9fa..5e7fcbd540a1 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -2966,7 +2966,29 @@ SfxVoidItem RandomNumberGeneratorDialog SID_OPENDLG_RANDOM_NUMBER_GENERATOR
GroupId = GID_OPTIONS;
]
+SfxVoidItem SamplingDialog SID_SAMPLING_DIALOG
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = TRUE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_OPTIONS;
+]
//--------------------------------------------------------------------------
SfxVoidItem SolverDialog SID_OPENDLG_OPTSOLVER
diff --git a/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx
new file mode 100644
index 000000000000..c9e8c3462e01
--- /dev/null
+++ b/sc/source/ui/StatisticsDialogs/SamplingDialog.cxx
@@ -0,0 +1,251 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <sfx2/dispatch.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/undo.hxx>
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "scresid.hxx"
+#include "random.hxx"
+#include "docfunc.hxx"
+#include "globstr.hrc"
+#include "sc.hrc"
+
+#include <boost/random.hpp>
+
+#include "SamplingDialog.hxx"
+
+#define ABS_DREF3D SCA_VALID | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_TAB_3D
+
+namespace
+{
+}
+
+ScSamplingDialog::ScSamplingDialog(
+ SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, ScViewData* pViewData ) :
+ ScAnyRefDlg ( pB, pCW, pParent, "SamplingDialog", "modules/scalc/ui/samplingdialog.ui" ),
+ mViewData ( pViewData ),
+ mDocument ( pViewData->GetDocument() ),
+ mAddressDetails ( mDocument->GetAddressConvention(), 0, 0 ),
+ mCurrentAddress ( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ),
+ mDialogLostFocus( false )
+{
+ get(mpInputRangeLabel, "input-range-label");
+ get(mpInputRangeEdit, "input-range-edit");
+ mpInputRangeEdit->SetReferences(this, mpInputRangeLabel);
+ get(mpInputRangeButton, "input-range-button");
+ mpInputRangeButton->SetReferences(this, mpInputRangeEdit);
+
+ get(mpOutputRangeLabel, "output-range-label");
+ get(mpOutputRangeEdit, "output-range-edit");
+ mpOutputRangeEdit->SetReferences(this, mpOutputRangeLabel);
+ get(mpOutputRangeButton, "output-range-button");
+ mpOutputRangeButton->SetReferences(this, mpOutputRangeEdit);
+
+ get(mpButtonOk, "ok");
+ get(mpButtonApply, "apply");
+ get(mpButtonCancel, "cancel");
+
+ Init();
+ GetRangeFromSelection();
+}
+
+void ScSamplingDialog::Init()
+{
+ mpButtonOk->SetClickHdl( LINK( this, ScSamplingDialog, OkClicked ) );
+ mpButtonCancel->SetClickHdl( LINK( this, ScSamplingDialog, CancelClicked ) );
+ mpButtonApply->SetClickHdl( LINK( this, ScSamplingDialog, ApplyClicked ) );
+
+ Link aLink = LINK( this, ScSamplingDialog, GetFocusHandler );
+ mpInputRangeEdit->SetGetFocusHdl( aLink );
+ mpInputRangeButton->SetGetFocusHdl( aLink );
+ mpOutputRangeEdit->SetGetFocusHdl( aLink );
+ mpOutputRangeButton->SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScSamplingDialog, LoseFocusHandler );
+ mpInputRangeEdit->SetLoseFocusHdl( aLink );
+ mpInputRangeButton->SetLoseFocusHdl( aLink );
+ mpOutputRangeEdit->SetLoseFocusHdl( aLink );
+ mpOutputRangeButton->SetLoseFocusHdl( aLink );
+}
+
+void ScSamplingDialog::GetRangeFromSelection()
+{
+ OUString aCurrentString;
+ mViewData->GetSimpleArea(mInputRange);
+ mInputRange.Format( aCurrentString, ABS_DREF3D, mDocument, mAddressDetails );
+ mpInputRangeEdit->SetText( aCurrentString );
+}
+
+
+ScSamplingDialog::~ScSamplingDialog()
+{
+}
+
+void ScSamplingDialog::SetActive()
+{
+ if ( mDialogLostFocus )
+ {
+ mDialogLostFocus = false;
+ if( mpActiveEdit )
+ mpActiveEdit->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+sal_Bool ScSamplingDialog::Close()
+{
+ return DoClose( ScSamplingDialogWrapper::GetChildWindowId() );
+}
+
+void ScSamplingDialog::SetReference( const ScRange& rReferenceRange, ScDocument* pDocument )
+{
+ if ( mpActiveEdit )
+ {
+ if ( rReferenceRange.aStart != rReferenceRange.aEnd )
+ RefInputStart( mpActiveEdit );
+
+ String aReferenceString;
+
+ if ( mpActiveEdit == mpInputRangeEdit )
+ {
+ mInputRange = rReferenceRange;
+ mInputRange.Format( aReferenceString, ABS_DREF3D, pDocument, mAddressDetails );
+ mpInputRangeEdit->SetRefString( aReferenceString );
+ }
+ else if ( mpActiveEdit == mpOutputRangeEdit )
+ {
+ mOutputAddress = rReferenceRange.aStart;
+ sal_uInt16 nFormat = ( mOutputAddress.Tab() == mCurrentAddress.Tab() ) ? SCA_ABS : SCA_ABS_3D;
+ mOutputAddress.Format( aReferenceString, nFormat, pDocument, pDocument->GetAddressConvention() );
+ mpActiveEdit->SetRefString( aReferenceString );
+ }
+ }
+}
+
+void ScSamplingDialog::PerformSampling()
+{
+ OUString aUndo("A");
+ ScDocShell* pDocShell = mViewData->GetDocShell();
+ svl::IUndoManager* pUndoManager = pDocShell->GetUndoManager();
+ pUndoManager->EnterListAction( aUndo, aUndo );
+
+ SCCOL nColStart = mInputRange.aStart.Col();
+ SCCOL nColEnd = mInputRange.aEnd.Col();
+ SCROW nRowStart = mInputRange.aStart.Row();
+ SCROW nRowEnd = mInputRange.aEnd.Row();
+ SCTAB nTabStart = mInputRange.aStart.Tab();
+ SCTAB nTabEnd = mInputRange.aEnd.Tab();
+
+ TimeValue now;
+ osl_getSystemTime(&now);
+ boost::mt19937 seed(now.Nanosec);
+ boost::uniform_01<boost::mt19937> rng(seed);
+
+ SCTAB nOutTab = mOutputAddress.Tab();
+ SCCOL nOutCol = mOutputAddress.Col();
+ SCROW nOutRow = mOutputAddress.Row();
+ for (SCROW nTab = nTabStart; nTab <= nTabEnd; nTab++)
+ {
+ nOutCol = mOutputAddress.Col();
+ for (SCCOL nCol = nColStart; nCol <= nColEnd; nCol++)
+ {
+ nOutRow = mOutputAddress.Row();
+ SCROW nRow = nRowStart;
+
+ SCROW t = 0;
+ SCROW N = (nRowEnd - nRowStart) + 1;
+ int m = 0;
+ int n = 3;
+ double u;
+
+ while (m < n)
+ {
+ u = rng();
+ if ( (N - t)*u >= n - m )
+ {
+ nRow++;
+ t++;
+ }
+ else
+ {
+ double aValue = mDocument->GetValue( ScAddress(nCol, nRow, nTab) );
+ pDocShell->GetDocFunc().SetValueCell(ScAddress(nOutCol, nOutRow, nOutTab), aValue, true);
+ nRow++;
+ nOutRow++;
+ m++;
+ t++;
+ }
+ }
+
+ nOutCol++;
+ }
+ nOutTab++;
+ }
+
+ ScRange aOutputRange(mOutputAddress, ScAddress(nOutCol, nOutRow, nOutTab) );
+
+ pUndoManager->LeaveListAction();
+
+ pDocShell->PostPaint( aOutputRange, PAINT_GRID );
+}
+
+IMPL_LINK( ScSamplingDialog, OkClicked, PushButton*, /*pButton*/ )
+{
+ PerformSampling();
+ Close();
+ return 0;
+}
+
+
+IMPL_LINK( ScSamplingDialog, ApplyClicked, PushButton*, /*pButton*/ )
+{
+ PerformSampling();
+ return 0;
+}
+
+IMPL_LINK( ScSamplingDialog, CancelClicked, PushButton*, /*pButton*/ )
+{
+ Close();
+ return 0;
+}
+
+IMPL_LINK( ScSamplingDialog, GetFocusHandler, Control*, pCtrl )
+{
+ mpActiveEdit = NULL;
+
+ if( (pCtrl == (Control*) mpInputRangeEdit) || (pCtrl == (Control*) mpInputRangeButton) )
+ mpActiveEdit = mpInputRangeEdit;
+ else if( (pCtrl == (Control*) mpOutputRangeEdit) || (pCtrl == (Control*) mpOutputRangeButton) )
+ mpActiveEdit = mpOutputRangeEdit;
+
+ if( mpActiveEdit )
+ mpActiveEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+IMPL_LINK_NOARG(ScSamplingDialog, LoseFocusHandler)
+{
+ mDialogLostFocus = !IsActive();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index cb6929ecd908..60da88491796 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -268,6 +268,7 @@ void ScDLL::Init()
ScFormulaDlgWrapper ::RegisterChildWindow(false, pMod);
ScRandomNumberGeneratorDialogWrapper::RegisterChildWindow(false, pMod);
+ ScSamplingDialogWrapper ::RegisterChildWindow(false, pMod);
// First docking Window for Calc
ScFunctionChildWindow ::RegisterChildWindow(false, pMod);
diff --git a/sc/source/ui/inc/SamplingDialog.hxx b/sc/source/ui/inc/SamplingDialog.hxx
new file mode 100644
index 000000000000..b46524a940bf
--- /dev/null
+++ b/sc/source/ui/inc/SamplingDialog.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef SAMPLING_DIALOG_HXX
+#define SAMPLING_DIALOG_HXX
+
+#include "global.hxx"
+#include "address.hxx"
+#include "anyrefdg.hxx"
+
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+
+class ScSamplingDialog : public ScAnyRefDlg
+{
+public:
+ ScSamplingDialog(
+ SfxBindings* pB, SfxChildWindow* pCW,
+ Window* pParent, ScViewData* pViewData );
+
+ virtual ~ScSamplingDialog();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual void SetActive();
+ virtual sal_Bool Close();
+
+private:
+ // Widgets
+ FixedText* mpInputRangeLabel;
+ formula::RefEdit* mpInputRangeEdit;
+ formula::RefButton* mpInputRangeButton;
+
+ FixedText* mpOutputRangeLabel;
+ formula::RefEdit* mpOutputRangeEdit;
+ formula::RefButton* mpOutputRangeButton;
+
+ PushButton* mpButtonApply;
+ OKButton* mpButtonOk;
+ CancelButton* mpButtonCancel;
+
+ //
+ formula::RefEdit* mpActiveEdit;
+
+ // Data
+ ScViewData* mViewData;
+ ScDocument* mDocument;
+
+ ScRange mInputRange;
+ ScAddress::Details mAddressDetails;
+ ScAddress mOutputAddress;
+
+ ScAddress mCurrentAddress;
+
+ bool mDialogLostFocus;
+
+ void Init();
+ void GetRangeFromSelection();
+ void PerformSampling();
+
+ DECL_LINK( OkClicked, PushButton* );
+ DECL_LINK( CancelClicked, PushButton* );
+ DECL_LINK( ApplyClicked, PushButton* );
+ DECL_LINK( GetFocusHandler, Control* );
+ DECL_LINK( LoseFocusHandler, void* );
+
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx
index aa94ff1108eb..7c1e7d0150d0 100644
--- a/sc/source/ui/inc/reffact.hxx
+++ b/sc/source/ui/inc/reffact.hxx
@@ -51,6 +51,7 @@ DECL_WRAPPER_WITHID(ScFormulaDlgWrapper)
DECL_WRAPPER_WITHID(ScHighlightChgDlgWrapper)
DECL_WRAPPER_WITHID(ScRandomNumberGeneratorDialogWrapper)
+DECL_WRAPPER_WITHID(ScSamplingDialogWrapper)
class ScAcceptChgDlgWrapper: public SfxChildWindow
{
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 05d55f4dee3e..489763953595 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -172,6 +172,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
break;
case FID_FILL_SERIES: // fill block
case SID_OPENDLG_RANDOM_NUMBER_GENERATOR:
+ case SID_SAMPLING_DIALOG:
case SID_OPENDLG_TABOP: // multiple-cell operations, are at least 2 cells marked?
if (pDoc->GetChangeTrack()!=NULL &&nWhich ==SID_OPENDLG_TABOP)
bDisable = sal_True;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index daac7ec9ca4b..15953b3f3e2f 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -905,7 +905,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
break;
case SID_OPENDLG_RANDOM_NUMBER_GENERATOR:
{
- sal_uInt16 nId = ScRandomNumberGeneratorDialogWrapper::GetChildWindowId();
+ sal_uInt16 nId = ScRandomNumberGeneratorDialogWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
+ }
+ break;
+ case SID_SAMPLING_DIALOG:
+ {
+ sal_uInt16 nId = ScSamplingDialogWrapper::GetChildWindowId();
SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx
index cf7e796af408..65adb74eac06 100644
--- a/sc/source/ui/view/reffact.cxx
+++ b/sc/source/ui/view/reffact.cxx
@@ -52,6 +52,7 @@ SFX_IMPL_MODELESSDIALOG_WITHID(ScHighlightChgDlgWrapper, FID_CHG_SHOW )
SFX_IMPL_MODELESSDIALOG_WITHID(ScSimpleRefDlgWrapper, WID_SIMPLE_REF )
SFX_IMPL_MODELESSDIALOG_WITHID(ScRandomNumberGeneratorDialogWrapper, SID_OPENDLG_RANDOM_NUMBER_GENERATOR )
+SFX_IMPL_MODELESSDIALOG_WITHID(ScSamplingDialogWrapper, SID_SAMPLING_DIALOG )
SFX_IMPL_CHILDWINDOW_WITHID(ScValidityRefChildWin, SID_VALIDITY_REFERENCE)
@@ -71,7 +72,10 @@ SfxChildWinInfo ScValidityRefChildWin::GetInfo() const
return anInfo;
}
-namespace { ScTabViewShell * lcl_GetTabViewShell( SfxBindings *pBindings ); }
+namespace
+{
+ ScTabViewShell* lcl_GetTabViewShell( SfxBindings* pBindings );
+}
#define IMPL_CHILD_CTOR(Class,sid) \
Class::Class( Window* pParentP, \
@@ -96,101 +100,47 @@ namespace { ScTabViewShell * lcl_GetTabViewShell( SfxBindings *pBindings ); }
pViewShell->GetViewFrame()->SetChildWindow( nId, false ); \
}
-
-//=========================================================================
-
-//-------------------------------------------------------------------------
-// ScNameDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScNameDlgWrapper, FID_DEFINE_NAME )
-//-------------------------------------------------------------------------
-// ScNameDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScNameDefDlgWrapper, FID_ADD_NAME )
-//-------------------------------------------------------------------------
-// ScSolverDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScSolverDlgWrapper, SID_OPENDLG_SOLVE )
-//-------------------------------------------------------------------------
-// ScOptSolverDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER )
-IMPL_CHILD_CTOR(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE)
-
-//-------------------------------------------------------------------------
-// ScPivotLayoutWrapper
-//-------------------------------------------------------------------------
+IMPL_CHILD_CTOR( ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE)
IMPL_CHILD_CTOR( ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE )
-//-------------------------------------------------------------------------
-// ScTabOpDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScTabOpDlgWrapper, SID_OPENDLG_TABOP )
-//-------------------------------------------------------------------------
-// ScFilterDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScFilterDlgWrapper, SID_FILTER )
-//-------------------------------------------------------------------------
-// ScSpecialFilterDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER )
-//-------------------------------------------------------------------------
-// ScDbNameDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScDbNameDlgWrapper, SID_DEFINE_DBNAME )
-//-------------------------------------------------------------------------
-// ScColRowNameRangesDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES )
-//-------------------------------------------------------------------------
-// ScConsolidateDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE )
-//-------------------------------------------------------------------------
-// ScPrintAreasDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA )
-//-------------------------------------------------------------------------
-// ScFormulaDlgWrapper
-//-------------------------------------------------------------------------
-
IMPL_CHILD_CTOR( ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
-
IMPL_CHILD_CTOR( ScRandomNumberGeneratorDialogWrapper, SID_OPENDLG_RANDOM_NUMBER_GENERATOR )
+IMPL_CHILD_CTOR( ScSamplingDialogWrapper, SID_SAMPLING_DIALOG )
+
//-------------------------------------------------------------------------
// ScSimpleRefDlgWrapper
//-------------------------------------------------------------------------
static sal_Bool bScSimpleRefFlag;
-static long nScSimpleRefHeight;
-static long nScSimpleRefWidth;
-static long nScSimpleRefX;
-static long nScSimpleRefY;
+static long nScSimpleRefHeight;
+static long nScSimpleRefWidth;
+static long nScSimpleRefX;
+static long nScSimpleRefY;
static sal_Bool bAutoReOpen=sal_True;
ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper( Window* pParentP,
diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx
index c53bf66f0e84..699a29df406a 100644
--- a/sc/source/ui/view/tabvwsh.cxx
+++ b/sc/source/ui/view/tabvwsh.cxx
@@ -82,6 +82,7 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL))
SFX_CHILDWINDOW_REGISTRATION(ScValidityRefChildWin::GetChildWindowId());
SFX_CHILDWINDOW_REGISTRATION(ScRandomNumberGeneratorDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScSamplingDialogWrapper::GetChildWindowId());
}
SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" )
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index a613c77b30d8..0b169bfd5feb 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -62,6 +62,7 @@
#include "xmlsourcedlg.hxx"
#include "RandomNumberGeneratorDialog.hxx"
+#include "SamplingDialog.hxx"
//------------------------------------------------------------------
@@ -320,6 +321,13 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
}
break;
+ case SID_SAMPLING_DIALOG:
+ {
+ ScViewData* pViewData = GetViewData();
+ pResult = new ScSamplingDialog( pB, pCW, pParent, pViewData );
+ }
+ break;
+
case SID_OPENDLG_OPTSOLVER:
{
ScViewData* pViewData = GetViewData();
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index 428b52cf5e73..44286d972557 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -474,6 +474,7 @@
<menu:menuitem menu:id=".uno:DeletePivotTable"/>
</menu:menupopup>
</menu:menu>
+ <menu:menuitem menu:id=".uno:SamplingDialog"/>
</menu:menupopup>
</menu:menu>
<menu:menu menu:id=".uno:WindowList">
diff --git a/sc/uiconfig/scalc/ui/samplingdialog.ui b/sc/uiconfig/scalc/ui/samplingdialog.ui
new file mode 100644
index 000000000000..690c37a53870
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/samplingdialog.ui
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <!-- interface-requires LibreOffice 1.0 -->
+ <object class="GtkDialog" id="SamplingDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="apply">
+ <property name="label">gtk-apply</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="ok">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="input-range-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Input Range</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="foruilo-RefEdit" id="input-range-edit">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">•</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="foruilo-RefButton" id="input-range-button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="output-range-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Output Range</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="foruilo-RefEdit" id="output-range-edit">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="valign">center</property>
+ <property name="hexpand">True</property>
+ <property name="invisible_char">•</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="foruilo-RefButton" id="output-range-button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="sampling-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0.4699999988079071</property>
+ <property name="label" translatable="yes">Sampling</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">apply</action-widget>
+ <action-widget response="0">ok</action-widget>
+ <action-widget response="0">cancel</action-widget>
+ </action-widgets>
+ </object>
+</interface>