summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-03-08 09:23:53 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-03-08 13:42:32 +0000
commit4e0c6a0ac78d3c68922e032eec7f9c05cc39023a (patch)
tree625922e3f9afa276b0798ce0070d7db67cd4c295
parent6df8417b98a74f58638b5fce7459c64f18ddedb4 (diff)
Resolves: fdo#58630 crash with refEdit button in SfxTabDialog
Change-Id: I11d6a0f1d4852aab1fe08671fd9c2a0dac0825a7
-rw-r--r--formula/inc/formula/funcutl.hxx2
-rw-r--r--formula/source/ui/dlg/funcutl.cxx6
-rw-r--r--sc/source/ui/dbgui/validate.cxx39
-rw-r--r--sc/source/ui/inc/anyrefdg.hxx3
-rw-r--r--sc/source/ui/inc/validate.hxx9
-rw-r--r--sc/source/ui/miscdlgs/anyrefdg.cxx86
-rw-r--r--sc/source/ui/namedlg/namedefdlg.cxx1
7 files changed, 96 insertions, 50 deletions
diff --git a/formula/inc/formula/funcutl.hxx b/formula/inc/formula/funcutl.hxx
index 1dc10e88c062..b9e326786915 100644
--- a/formula/inc/formula/funcutl.hxx
+++ b/formula/inc/formula/funcutl.hxx
@@ -63,6 +63,8 @@ public:
void SetRefDialog( IControlReferenceHandler* pDlg );
inline IControlReferenceHandler* GetRefDialog() { return pAnyRefDlg; }
+ Window* GetLabelWidgetForShrinkMode() { return m_pLabelWidget; }
+ void SetLabelWidgetForShrinkMode(Window *pLabel) { m_pLabelWidget = pLabel; }
};
diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx
index 4b047d31185c..64830d5d73e9 100644
--- a/formula/source/ui/dlg/funcutl.cxx
+++ b/formula/source/ui/dlg/funcutl.cxx
@@ -849,7 +849,8 @@ void EditBox::UpdateOldSel()
RefEdit::RefEdit( Window* _pParent,IControlReferenceHandler* pParent, const ResId& rResId ) :
Edit( _pParent, rResId ),
- pAnyRefDlg( pParent )
+ pAnyRefDlg( pParent ),
+ m_pLabelWidget(NULL)
{
aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
aTimer.SetTimeout( SC_ENABLE_TIME );
@@ -857,7 +858,8 @@ RefEdit::RefEdit( Window* _pParent,IControlReferenceHandler* pParent, const ResI
RefEdit::RefEdit( Window* _pParent, WinBits nStyle ) :
Edit( _pParent, nStyle ),
- pAnyRefDlg( NULL )
+ pAnyRefDlg( NULL ),
+ m_pLabelWidget(NULL)
{
aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
aTimer.SetTimeout( SC_ENABLE_TIME );
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
index ecce534ebf79..48cf1ab87ba0 100644
--- a/sc/source/ui/dbgui/validate.cxx
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -75,6 +75,8 @@ ScValidationDlg::ScValidationDlg( Window* pParent,
AddTabPage( TP_VALIDATION_INPUTHELP, ScTPValidationHelp::Create, 0 );
AddTabPage( TP_VALIDATION_ERROR, ScTPValidationError::Create, 0 );
FreeResource();
+ //temp hack until converted to .ui
+ mpHBox = new VclHBox(get_content_area());
}
void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , ScDocument* pDoc )
@@ -107,43 +109,43 @@ void ScTPValidationValue::RefInputStartPreHdl( formula::RefEdit* pEdi
{
if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
{
+ Window *pNewParent = pValidationDlg->get_refinput_shrink_parent();
if( pEdit == m_pRefEdit )
{
if( Window *pPreWnd = pEdit==&maEdMax?&maFtMax:(pEdit==&maEdMin?&maFtMin:NULL) )
{
- pPreWnd->SetParent( pValidationDlg );
- pPreWnd->Hide();
+ m_pRefEdit->SetLabelWidgetForShrinkMode(pPreWnd);
}
- m_pRefEdit->SetParent( pValidationDlg );
+ maRefEditPos = m_pRefEdit->GetPosPixel();
+ maRefEditSize = m_pRefEdit->GetSizePixel();
+ m_pRefEdit->SetParent(pNewParent);
}
- if( pButton == &m_btnRef )m_btnRef.SetParent( pValidationDlg );
+ if( pButton == &m_btnRef )
+ {
+ maBtnRefPos = m_btnRef.GetPosPixel();
+ maBtnRefSize = m_btnRef.GetSizePixel();
+ m_btnRef.SetParent(pNewParent);
+ }
+ pNewParent->Show();
}
}
-void ScTPValidationValue::RefInputDonePreHdl()
+void ScTPValidationValue::RefInputDonePostHdl()
{
-
if( m_pRefEdit && m_pRefEdit->GetParent()!= this )
{
- if( Window *pPreWnd = m_pRefEdit==&maEdMax?&maFtMax:(m_pRefEdit==&maEdMin?&maFtMin:NULL) )
- {
- pPreWnd->SetParent( this );
- pPreWnd->Show();
- }
-
m_pRefEdit->SetParent( this );
+ m_pRefEdit->SetPosSizePixel( maRefEditPos, maRefEditSize );
m_btnRef.SetParent( m_pRefEdit ); //if Edit SetParent but button not, the tab order will be incorrect, need button to setparent to anthor window and restore parent later in order to restore the tab order
+ m_btnRef.SetPosSizePixel( maBtnRefPos, maBtnRefSize );
}
if( m_btnRef.GetParent()!=this ) m_btnRef.SetParent( this );
-}
-
-void ScTPValidationValue::RefInputDonePostHdl()
-{
-
+ if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ pValidationDlg->get_refinput_shrink_parent()->Hide();
if( m_pRefEdit && !m_pRefEdit->HasFocus() )
m_pRefEdit->GrabFocus();
@@ -164,6 +166,7 @@ ScValidationDlg::~ScValidationDlg()
{
if( m_bOwnRefHdlr )
RemoveRefDlg( false );
+ delete mpHBox;
}
@@ -488,7 +491,6 @@ void ScTPValidationValue::SetupRefDlg()
pValidationDlg->SetSetRefHdl( (ScRefHandlerHelper::PFUNCSETREFHDLTYPE)( &ScTPValidationValue::SetReferenceHdl ) );
pValidationDlg->SetSetActHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::SetActiveHdl ) );
pValidationDlg->SetRefInputStartPreHdl( (ScRefHandlerHelper::PINPUTSTARTDLTYPE)( &ScTPValidationValue::RefInputStartPreHdl ) );
- pValidationDlg->SetRefInputDonePreHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::RefInputDonePreHdl ) );
pValidationDlg->SetRefInputDonePostHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::RefInputDonePostHdl ) );
if ( maEdMax.IsVisible() ) { m_pRefEdit = &maEdMax; }
@@ -510,7 +512,6 @@ void ScTPValidationValue::RemoveRefDlg()
pValidationDlg->SetSetRefHdl( NULL );
pValidationDlg->SetSetActHdl( NULL );
pValidationDlg->SetRefInputStartPreHdl( NULL );
- pValidationDlg->SetRefInputDonePreHdl( NULL );
pValidationDlg->SetRefInputDonePostHdl( NULL );
if( m_pRefEdit ) m_pRefEdit->SetRefDialog( NULL );
diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx
index 0e847ac3e410..760879a90fb8 100644
--- a/sc/source/ui/inc/anyrefdg.hxx
+++ b/sc/source/ui/inc/anyrefdg.hxx
@@ -61,8 +61,11 @@ class ScFormulaReferenceHelper
Size aOldDialogSize; // Original size of the dialog window
Point aOldEditPos; // Original position of the input field
Size aOldEditSize; // Original size of the input field
+ long mnOldEditWidthReq;
Point aOldButtonPos; // Original position of the button
Window* mpOldEditParent; // Original parent of the edit field and the button
+ bool mbOldDlgLayoutEnabled; // Original layout state of parent dialog
+ bool mbOldEditParentLayoutEnabled; // Original layout state of edit widget parent
bool bEnableColorRef;
bool bHighLightRef;
diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx
index 726681e555b0..353f71545577 100644
--- a/sc/source/ui/inc/validate.hxx
+++ b/sc/source/ui/inc/validate.hxx
@@ -23,6 +23,7 @@
#include <sfx2/tabdlg.hxx>
#include <vcl/edit.hxx>
#include <vcl/fixed.hxx>
+#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx>
#include <svtools/svmedit.hxx>
@@ -87,6 +88,7 @@ class ScValidationDlg :public ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false
bool m_bOwnRefHdlr:1;
ScTabViewShell *m_pTabVwSh;
+ VclHBox* mpHBox;
bool m_bRefInputting:1;
bool EnterRefStatus();
bool LeaveRefStatus();
@@ -126,6 +128,7 @@ public:
}
bool IsRefInputting(){ return m_bRefInputting; }
+ Window* get_refinput_shrink_parent() { return mpHBox; }
virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL )
{
@@ -211,6 +214,11 @@ private:
String maStrList;
sal_Unicode mcFmlaSep; /// List separator in formulas.
+ Point maRefEditPos;
+ Point maBtnRefPos;
+ Size maRefEditSize;
+ Size maBtnRefSize;
+
DECL_LINK(EditSetFocusHdl, void *);
DECL_LINK( KillFocusHdl, Window *);
void OnClick( Button *pBtn );
@@ -225,7 +233,6 @@ private:
void SetReferenceHdl( const ScRange& , ScDocument* );
void SetActiveHdl();
void RefInputStartPreHdl( formula::RefEdit* pEdit, formula::RefButton* pButton );
- void RefInputDonePreHdl();
void RefInputDonePostHdl();
ScValidationDlg * GetValidationDlg();
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 6af81de0f0da..80983369ed08 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -50,7 +50,10 @@ ScFormulaReferenceHelper::ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindi
, m_pBindings(_pBindings)
, pAccel( NULL )
, nRefTab(0)
+ , mnOldEditWidthReq( -1 )
, mpOldEditParent( NULL )
+ , mbOldDlgLayoutEnabled( false )
+ , mbOldEditParentLayoutEnabled( false )
, bHighLightRef( false )
, bAccInserted( false )
{
@@ -358,9 +361,8 @@ void ScFormulaReferenceHelper::RefInputDone( bool bForced )
bAccInserted = false;
}
- bool bLayoutEnabled = isLayoutEnabled(m_pWindow);
//get rid of all this junk when we can
- if (!bLayoutEnabled)
+ if (!mbOldDlgLayoutEnabled)
{
m_pWindow->SetOutputSizePixel(aOldDialogSize);
@@ -370,13 +372,21 @@ void ScFormulaReferenceHelper::RefInputDone( bool bForced )
// Fenster wieder gross
m_pWindow->SetOutputSizePixel(aOldDialogSize);
+ // set button parent
+ if( pRefBtn )
+ {
+ pRefBtn->SetParent(m_pWindow);
+ }
+ }
+
+ if (!mbOldEditParentLayoutEnabled)
+ {
// pEditCell an alte Position
pRefEdit->SetPosSizePixel(aOldEditPos, aOldEditSize);
// set button position
if( pRefBtn )
{
- pRefBtn->SetParent(m_pWindow);
pRefBtn->SetPosPixel( aOldButtonPos );
}
}
@@ -396,11 +406,13 @@ void ScFormulaReferenceHelper::RefInputDone( bool bForced )
}
m_aHiddenWidgets.clear();
- if (bLayoutEnabled)
+ if (mbOldDlgLayoutEnabled)
{
+ pRefEdit->set_width_request(mnOldEditWidthReq);
Dialog* pResizeDialog = pRefEdit->GetParentDialog();
pResizeDialog->set_border_width(m_nOldBorderWidth);
- pResizeDialog->get_action_area()->Show();
+ if (Window *pActionArea = pResizeDialog->get_action_area())
+ pActionArea->Show();
pResizeDialog->setOptimalLayoutSize();
}
@@ -442,44 +454,60 @@ void ScFormulaReferenceHelper::RefInputStart( formula::RefEdit* pEdit, formula::
pRefEdit = pEdit;
pRefBtn = pButton;
- // Neuen Fenstertitel basteln
- String sNewDialogText;
- sOldDialogText = m_pWindow->GetText();
- sNewDialogText = sOldDialogText;
- sNewDialogText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ mbOldDlgLayoutEnabled = isLayoutEnabled(m_pWindow);
+ aOldEditSize = pRefEdit->GetSizePixel();
+ mnOldEditWidthReq = pRefEdit->get_width_request();
+ mpOldEditParent = pRefEdit->GetParent();
+ mbOldEditParentLayoutEnabled = isContainerWindow(mpOldEditParent);
- bool bLayoutEnabled = isLayoutEnabled(m_pWindow);
- //get rid of all the !bLayoutEnabled junk when we can
- //after the last user of this is widget-layout-ified
- if (!bLayoutEnabled)
+ //get rid of all the !mbOldDlgLayoutEnabled and
+ //mbOldEditParentLayoutEnabled junk when we can after the last user of
+ //this is widget-layout-ified
+ if (!mbOldEditParentLayoutEnabled)
{
- mpOldEditParent = pRefEdit->GetParent();
-
// Alte Daten merken
aOldDialogSize = m_pWindow->GetOutputSizePixel();
aOldEditPos = pRefEdit->GetPosPixel();
- aOldEditSize = pRefEdit->GetSizePixel();
if (pRefBtn)
aOldButtonPos = pRefBtn->GetPosPixel();
+ }
+ if (!mbOldDlgLayoutEnabled)
+ {
pRefEdit->SetParent(m_pWindow);
if(pRefBtn)
pRefBtn->SetParent(m_pWindow);
}
- //collect up edit window contents to use for the title bar
- for (Window* pChild = firstLogicalChildOfParent(m_pWindow); pChild; pChild = nextLogicalChildOfParent(m_pWindow, pChild))
+ OUString sLabel;
+ if (Window *pLabel = pRefEdit->GetLabelWidgetForShrinkMode())
+ {
+ sLabel = pLabel->GetText();
+ }
+ else
+ {
+ //find last widget before the edit widget to use as title bar contents
+ for (Window* pChild = firstLogicalChildOfParent(m_pWindow); pChild; pChild = nextLogicalChildOfParent(m_pWindow, pChild))
+ {
+ Window *pWin = pChild->GetWindow(WINDOW_CLIENT);
+ if (pWin == (Window*)pRefEdit || pWin == (Window*)pRefBtn)
+ break;
+ if (pWin->GetType() == WINDOW_EDIT || pWin->GetType() == WINDOW_FIXEDTEXT)
+ sLabel = pWin->GetText();
+ }
+ }
+
+ sOldDialogText = m_pWindow->GetText();
+ String sNewDialogText = sOldDialogText;
+ if (!sLabel.isEmpty())
{
- Window *pWin = pChild->GetWindow(WINDOW_CLIENT);
- if (pWin == (Window*)pRefEdit || pWin == (Window*)pRefBtn)
- continue; // do nothing
- if (pChild->IsVisible() && pWin->GetType() == WINDOW_EDIT)
- sNewDialogText += pWin->GetText();
+ sNewDialogText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ sNewDialogText += sLabel;
}
Dialog* pResizeDialog = NULL;
- if (!bLayoutEnabled)
+ if (!mbOldDlgLayoutEnabled)
{
for (Window* pChild = m_pWindow->GetWindow(WINDOW_FIRSTCHILD); pChild;
pChild = pChild->GetWindow(WINDOW_NEXT))
@@ -522,7 +550,7 @@ void ScFormulaReferenceHelper::RefInputStart( formula::RefEdit* pEdit, formula::
hideUnless(pContentArea, m_aVisibleWidgets, m_aHiddenWidgets);
}
- if (!bLayoutEnabled)
+ if (!mbOldDlgLayoutEnabled)
{
// Edit-Feld verschieben und anpassen
Size aNewDlgSize(aOldDialogSize.Width(), aOldEditSize.Height());
@@ -568,11 +596,13 @@ void ScFormulaReferenceHelper::RefInputStart( formula::RefEdit* pEdit, formula::
Application::InsertAccel( pAccel.get() );
bAccInserted = true;
- if (bLayoutEnabled)
+ if (mbOldDlgLayoutEnabled)
{
+ pRefEdit->set_width_request(aOldEditSize.Width());
m_nOldBorderWidth = pResizeDialog->get_border_width();
pResizeDialog->set_border_width(0);
- pResizeDialog->get_action_area()->Hide();
+ if (Window *pActionArea = pResizeDialog->get_action_area())
+ pActionArea->Hide();
pResizeDialog->setOptimalLayoutSize();
}
}
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index bb61ecc252dd..2743c3d8da48 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -69,6 +69,7 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
get(m_pEdRange, "range");
get(m_pRbRange, "refbutton");
m_pRbRange->SetReferences(this, m_pEdRange);
+ m_pEdRange->SetLabelWidgetForShrinkMode(m_pEdName);
get(m_pLbScope, "scope");
get(m_pBtnRowHeader, "rowheader");
get(m_pBtnColHeader, "colheader");