Kaydet (Commit) 4b6e0d42 authored tarafından Kohei Yoshida's avatar Kohei Yoshida Kaydeden (comit) Noel Power

Pass the correct ScTabViewShell instance to the input box.

This eliminates the need to store the assigned doc pointer to cross-check
against whenever the edit engine is initialized.  It's cleaner this way
& fdo#43614 still remains fixed.
üst 43c7830b
......@@ -159,18 +159,27 @@ bool lcl_isExperimentalMode()
// class ScInputWindow
//==================================================================
ScTextWndBase* lcl_chooseRuntimeImpl( Window* pParent )
ScTextWndBase* lcl_chooseRuntimeImpl( Window* pParent, SfxBindings* pBind )
{
ScTabViewShell* pViewSh = NULL;
SfxDispatcher* pDisp = pBind->GetDispatcher();
if ( pDisp )
{
SfxViewFrame* pViewFrm = pDisp->GetFrame();
if ( pViewFrm )
pViewSh = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
}
if ( !lcl_isExperimentalMode() )
return new ScTextWnd( pParent );
return new ScInputBarGroup( pParent );
return new ScTextWnd( pParent, pViewSh );
return new ScInputBarGroup( pParent, pViewSh );
}
ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
// mit WB_CLIPCHILDREN, sonst Flicker
ToolBox ( pParent, WinBits(WB_BORDER|WB_3DLOOK|WB_CLIPCHILDREN) ),
aWndPos ( this ),
pRuntimeWindow ( lcl_chooseRuntimeImpl( this ) ),
pRuntimeWindow ( lcl_chooseRuntimeImpl( this, pBind ) ),
aTextWindow ( *pRuntimeWindow ),
pInputHdl ( NULL ),
pBindings ( pBind ),
......@@ -848,9 +857,9 @@ void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt )
// ScInputBarGroup
//========================================================================
ScInputBarGroup::ScInputBarGroup(Window* pParent)
ScInputBarGroup::ScInputBarGroup(Window* pParent, ScTabViewShell* pViewSh)
: ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_TABSTOP ) ),
aMultiTextWnd ( this ),
aMultiTextWnd ( this, pViewSh ),
aButton ( this, WB_TABSTOP | WB_RECTSTYLE ),
aScrollBar ( this, WB_TABSTOP | WB_VERT | WB_DRAG )
{
......@@ -1094,11 +1103,10 @@ IMPL_LINK( ScInputBarGroup, Impl_ScrollHdl, ScrollBar*, EMPTYARG )
// ScMultiTextWnd
//========================================================================
ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen )
ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen, ScTabViewShell* pViewSh )
:
ScTextWnd( pParen/*, WB_TABSTOP*/ ),
ScTextWnd( pParen, pViewSh ),
mrGroupBar(* pParen ),
mpAssignedDocument( NULL ),
mnLines( 1 ),
mnLastExpandedLines( INPUTWIN_MULTILINES )
{
......@@ -1119,7 +1127,7 @@ void ScMultiTextWnd::Paint( const Rectangle& rRec )
EditView* ScMultiTextWnd::GetEditView()
{
if ( !pEditView )
InitEditEngine( SfxObjectShell::Current() );
InitEditEngine();
return pEditView;
}
......@@ -1226,7 +1234,7 @@ void ScMultiTextWnd::StartEditEngine()
if ( !pEditView || !pEditEngine )
{
InitEditEngine(pObjSh);
InitEditEngine();
}
SC_MOD()->SetInputMode( SC_INPUT_TOP );
......@@ -1281,31 +1289,15 @@ void lcl_ModifyRTLVisArea( EditView* pEditView )
}
void ScMultiTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
void ScMultiTextWnd::InitEditEngine()
{
ScFieldEditEngine* pNew;
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
ScTabViewShell* pViewSh = GetViewShell();
ScDocShell* pDocSh = NULL;
if ( pViewSh )
{
pDocSh = pViewSh->GetViewData()->GetDocShell();
const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
// fdo#43614 If called from Paint() because pEditEngine==0 it may be
// that StopEditEngine() was previously called when opening another
// document or switching documents, the Paint() wants to paint the
// previous document, but GetActiveViewShell() already returns the
// shell of the new document. In that case we'd create an EditEngine
// with the wrong item pool that later crashes when the corresponding
// document was closed and may lead to other sorts of trouble.
if (mpAssignedDocument)
{
if (mpAssignedDocument != pDoc)
return; // Bail out, don't create and remember an
// EditEngine without document pools for this case.
}
else
mpAssignedDocument = pDoc; // stick with this document
pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
}
else
......@@ -1371,10 +1363,9 @@ void ScMultiTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
// as long as EditEngine and DrawText sometimes differ for CTL text,
// repaint now to have the EditEngine's version visible
// SfxObjectShell* pObjSh = SfxObjectShell::Current();
if ( pObjSh && pObjSh->ISA(ScDocShell) )
if (pDocSh)
{
ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument(); // any document
ScDocument* pDoc = pDocSh->GetDocument(); // any document
sal_uInt8 nScript = pDoc->GetStringScriptType( aString );
if ( nScript & SCRIPTTYPE_COMPLEX )
Invalidate();
......@@ -1405,7 +1396,7 @@ void ScMultiTextWnd::SetTextString( const String& rNewString )
// ScTextWnd
//========================================================================
ScTextWnd::ScTextWnd( Window* pParent )
ScTextWnd::ScTextWnd( Window* pParent, ScTabViewShell* pViewSh )
: ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
DragSourceHelper( this ),
pEditEngine ( NULL ),
......@@ -1413,7 +1404,8 @@ ScTextWnd::ScTextWnd( Window* pParent )
bIsInsertMode( sal_True ),
bFormulaMode ( false ),
bInputMode ( false ),
nTextStartPos ( TEXT_STARTPOS )
nTextStartPos ( TEXT_STARTPOS ),
mpViewShell(pViewSh)
{
EnableRTL( false ); // EditEngine can't be used with VCL EnableRTL
......@@ -1669,6 +1661,11 @@ void ScTextWnd::UpdateAutoCorrFlag()
}
}
ScTabViewShell* ScTextWnd::GetViewShell()
{
return mpViewShell;
}
void ScTextWnd::StartEditEngine()
{
// Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
......
......@@ -47,6 +47,7 @@ class ScAccessibleEditLineTextData;
struct EENotify;
class ScRangeList;
class ScDocument;
class ScTabViewShell;
//========================================================================
......@@ -69,7 +70,7 @@ public:
class ScTextWnd : public ScTextWndBase, public DragSourceHelper // edit window
{
public:
ScTextWnd( Window* pParent );
ScTextWnd( Window* pParent, ScTabViewShell* pViewSh );
virtual ~ScTextWnd();
virtual void SetTextString( const String& rString );
......@@ -114,6 +115,8 @@ protected:
void ImplInitSettings();
void UpdateAutoCorrFlag();
ScTabViewShell* GetViewShell();
typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
String aString;
......@@ -129,6 +132,9 @@ protected:
// it prevents the call of InputChanged in the ModifyHandler of the EditEngine
sal_Bool bInputMode;
sal_Int16 nTextStartPos;
private:
ScTabViewShell* mpViewShell;
};
//========================================================================
......@@ -172,7 +178,7 @@ class ScInputBarGroup;
class ScMultiTextWnd : public ScTextWnd
{
public:
ScMultiTextWnd( ScInputBarGroup* pParent );
ScMultiTextWnd( ScInputBarGroup* pParent, ScTabViewShell* pViewSh );
virtual ~ScMultiTextWnd();
virtual void StartEditEngine();
virtual void StopEditEngine( sal_Bool bAll );
......@@ -188,7 +194,7 @@ public:
long GetLastNumExpandedLines() { return mnLastExpandedLines; }
protected:
void SetScrollBarRange();
void InitEditEngine(SfxObjectShell* pObjSh);
void InitEditEngine();
virtual void Paint( const Rectangle& rRec );
DECL_LINK( NotifyHdl, EENotify* );
......@@ -196,7 +202,6 @@ protected:
private:
long GetPixelTextHeight();
ScInputBarGroup& mrGroupBar;
const ScDocument* mpAssignedDocument;
long mnLines;
long mnLastExpandedLines;
};
......@@ -205,7 +210,7 @@ class ScInputBarGroup : public ScTextWndBase
{
public:
ScInputBarGroup( Window* Parent );
ScInputBarGroup( Window* Parent, ScTabViewShell* pViewSh );
virtual ~ScInputBarGroup();
virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment