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() ...@@ -159,18 +159,27 @@ bool lcl_isExperimentalMode()
// class ScInputWindow // 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() ) if ( !lcl_isExperimentalMode() )
return new ScTextWnd( pParent ); return new ScTextWnd( pParent, pViewSh );
return new ScInputBarGroup( pParent ); return new ScInputBarGroup( pParent, pViewSh );
} }
ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) : ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
// mit WB_CLIPCHILDREN, sonst Flicker // mit WB_CLIPCHILDREN, sonst Flicker
ToolBox ( pParent, WinBits(WB_BORDER|WB_3DLOOK|WB_CLIPCHILDREN) ), ToolBox ( pParent, WinBits(WB_BORDER|WB_3DLOOK|WB_CLIPCHILDREN) ),
aWndPos ( this ), aWndPos ( this ),
pRuntimeWindow ( lcl_chooseRuntimeImpl( this ) ), pRuntimeWindow ( lcl_chooseRuntimeImpl( this, pBind ) ),
aTextWindow ( *pRuntimeWindow ), aTextWindow ( *pRuntimeWindow ),
pInputHdl ( NULL ), pInputHdl ( NULL ),
pBindings ( pBind ), pBindings ( pBind ),
...@@ -848,9 +857,9 @@ void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt ) ...@@ -848,9 +857,9 @@ void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt )
// ScInputBarGroup // ScInputBarGroup
//======================================================================== //========================================================================
ScInputBarGroup::ScInputBarGroup(Window* pParent) ScInputBarGroup::ScInputBarGroup(Window* pParent, ScTabViewShell* pViewSh)
: ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_TABSTOP ) ), : ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_TABSTOP ) ),
aMultiTextWnd ( this ), aMultiTextWnd ( this, pViewSh ),
aButton ( this, WB_TABSTOP | WB_RECTSTYLE ), aButton ( this, WB_TABSTOP | WB_RECTSTYLE ),
aScrollBar ( this, WB_TABSTOP | WB_VERT | WB_DRAG ) aScrollBar ( this, WB_TABSTOP | WB_VERT | WB_DRAG )
{ {
...@@ -1094,11 +1103,10 @@ IMPL_LINK( ScInputBarGroup, Impl_ScrollHdl, ScrollBar*, EMPTYARG ) ...@@ -1094,11 +1103,10 @@ IMPL_LINK( ScInputBarGroup, Impl_ScrollHdl, ScrollBar*, EMPTYARG )
// ScMultiTextWnd // ScMultiTextWnd
//======================================================================== //========================================================================
ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen ) ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen, ScTabViewShell* pViewSh )
: :
ScTextWnd( pParen/*, WB_TABSTOP*/ ), ScTextWnd( pParen, pViewSh ),
mrGroupBar(* pParen ), mrGroupBar(* pParen ),
mpAssignedDocument( NULL ),
mnLines( 1 ), mnLines( 1 ),
mnLastExpandedLines( INPUTWIN_MULTILINES ) mnLastExpandedLines( INPUTWIN_MULTILINES )
{ {
...@@ -1119,7 +1127,7 @@ void ScMultiTextWnd::Paint( const Rectangle& rRec ) ...@@ -1119,7 +1127,7 @@ void ScMultiTextWnd::Paint( const Rectangle& rRec )
EditView* ScMultiTextWnd::GetEditView() EditView* ScMultiTextWnd::GetEditView()
{ {
if ( !pEditView ) if ( !pEditView )
InitEditEngine( SfxObjectShell::Current() ); InitEditEngine();
return pEditView; return pEditView;
} }
...@@ -1226,7 +1234,7 @@ void ScMultiTextWnd::StartEditEngine() ...@@ -1226,7 +1234,7 @@ void ScMultiTextWnd::StartEditEngine()
if ( !pEditView || !pEditEngine ) if ( !pEditView || !pEditEngine )
{ {
InitEditEngine(pObjSh); InitEditEngine();
} }
SC_MOD()->SetInputMode( SC_INPUT_TOP ); SC_MOD()->SetInputMode( SC_INPUT_TOP );
...@@ -1281,31 +1289,15 @@ void lcl_ModifyRTLVisArea( EditView* pEditView ) ...@@ -1281,31 +1289,15 @@ void lcl_ModifyRTLVisArea( EditView* pEditView )
} }
void ScMultiTextWnd::InitEditEngine(SfxObjectShell* pObjSh) void ScMultiTextWnd::InitEditEngine()
{ {
ScFieldEditEngine* pNew; ScFieldEditEngine* pNew;
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); ScTabViewShell* pViewSh = GetViewShell();
ScDocShell* pDocSh = NULL;
if ( pViewSh ) if ( pViewSh )
{ {
pDocSh = pViewSh->GetViewData()->GetDocShell();
const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument(); 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() ); pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
} }
else else
...@@ -1371,10 +1363,9 @@ void ScMultiTextWnd::InitEditEngine(SfxObjectShell* pObjSh) ...@@ -1371,10 +1363,9 @@ void ScMultiTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
// as long as EditEngine and DrawText sometimes differ for CTL text, // as long as EditEngine and DrawText sometimes differ for CTL text,
// repaint now to have the EditEngine's version visible // repaint now to have the EditEngine's version visible
// SfxObjectShell* pObjSh = SfxObjectShell::Current(); if (pDocSh)
if ( pObjSh && pObjSh->ISA(ScDocShell) )
{ {
ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument(); // any document ScDocument* pDoc = pDocSh->GetDocument(); // any document
sal_uInt8 nScript = pDoc->GetStringScriptType( aString ); sal_uInt8 nScript = pDoc->GetStringScriptType( aString );
if ( nScript & SCRIPTTYPE_COMPLEX ) if ( nScript & SCRIPTTYPE_COMPLEX )
Invalidate(); Invalidate();
...@@ -1405,7 +1396,7 @@ void ScMultiTextWnd::SetTextString( const String& rNewString ) ...@@ -1405,7 +1396,7 @@ void ScMultiTextWnd::SetTextString( const String& rNewString )
// ScTextWnd // ScTextWnd
//======================================================================== //========================================================================
ScTextWnd::ScTextWnd( Window* pParent ) ScTextWnd::ScTextWnd( Window* pParent, ScTabViewShell* pViewSh )
: ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_BORDER) ), : ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
DragSourceHelper( this ), DragSourceHelper( this ),
pEditEngine ( NULL ), pEditEngine ( NULL ),
...@@ -1413,7 +1404,8 @@ ScTextWnd::ScTextWnd( Window* pParent ) ...@@ -1413,7 +1404,8 @@ ScTextWnd::ScTextWnd( Window* pParent )
bIsInsertMode( sal_True ), bIsInsertMode( sal_True ),
bFormulaMode ( false ), bFormulaMode ( false ),
bInputMode ( false ), bInputMode ( false ),
nTextStartPos ( TEXT_STARTPOS ) nTextStartPos ( TEXT_STARTPOS ),
mpViewShell(pViewSh)
{ {
EnableRTL( false ); // EditEngine can't be used with VCL EnableRTL EnableRTL( false ); // EditEngine can't be used with VCL EnableRTL
...@@ -1669,6 +1661,11 @@ void ScTextWnd::UpdateAutoCorrFlag() ...@@ -1669,6 +1661,11 @@ void ScTextWnd::UpdateAutoCorrFlag()
} }
} }
ScTabViewShell* ScTextWnd::GetViewShell()
{
return mpViewShell;
}
void ScTextWnd::StartEditEngine() void ScTextWnd::StartEditEngine()
{ {
// Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren // Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
......
...@@ -47,6 +47,7 @@ class ScAccessibleEditLineTextData; ...@@ -47,6 +47,7 @@ class ScAccessibleEditLineTextData;
struct EENotify; struct EENotify;
class ScRangeList; class ScRangeList;
class ScDocument; class ScDocument;
class ScTabViewShell;
//======================================================================== //========================================================================
...@@ -69,7 +70,7 @@ public: ...@@ -69,7 +70,7 @@ public:
class ScTextWnd : public ScTextWndBase, public DragSourceHelper // edit window class ScTextWnd : public ScTextWndBase, public DragSourceHelper // edit window
{ {
public: public:
ScTextWnd( Window* pParent ); ScTextWnd( Window* pParent, ScTabViewShell* pViewSh );
virtual ~ScTextWnd(); virtual ~ScTextWnd();
virtual void SetTextString( const String& rString ); virtual void SetTextString( const String& rString );
...@@ -114,6 +115,8 @@ protected: ...@@ -114,6 +115,8 @@ protected:
void ImplInitSettings(); void ImplInitSettings();
void UpdateAutoCorrFlag(); void UpdateAutoCorrFlag();
ScTabViewShell* GetViewShell();
typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector; typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
String aString; String aString;
...@@ -129,6 +132,9 @@ protected: ...@@ -129,6 +132,9 @@ protected:
// it prevents the call of InputChanged in the ModifyHandler of the EditEngine // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
sal_Bool bInputMode; sal_Bool bInputMode;
sal_Int16 nTextStartPos; sal_Int16 nTextStartPos;
private:
ScTabViewShell* mpViewShell;
}; };
//======================================================================== //========================================================================
...@@ -172,7 +178,7 @@ class ScInputBarGroup; ...@@ -172,7 +178,7 @@ class ScInputBarGroup;
class ScMultiTextWnd : public ScTextWnd class ScMultiTextWnd : public ScTextWnd
{ {
public: public:
ScMultiTextWnd( ScInputBarGroup* pParent ); ScMultiTextWnd( ScInputBarGroup* pParent, ScTabViewShell* pViewSh );
virtual ~ScMultiTextWnd(); virtual ~ScMultiTextWnd();
virtual void StartEditEngine(); virtual void StartEditEngine();
virtual void StopEditEngine( sal_Bool bAll ); virtual void StopEditEngine( sal_Bool bAll );
...@@ -188,7 +194,7 @@ public: ...@@ -188,7 +194,7 @@ public:
long GetLastNumExpandedLines() { return mnLastExpandedLines; } long GetLastNumExpandedLines() { return mnLastExpandedLines; }
protected: protected:
void SetScrollBarRange(); void SetScrollBarRange();
void InitEditEngine(SfxObjectShell* pObjSh); void InitEditEngine();
virtual void Paint( const Rectangle& rRec ); virtual void Paint( const Rectangle& rRec );
DECL_LINK( NotifyHdl, EENotify* ); DECL_LINK( NotifyHdl, EENotify* );
...@@ -196,7 +202,6 @@ protected: ...@@ -196,7 +202,6 @@ protected:
private: private:
long GetPixelTextHeight(); long GetPixelTextHeight();
ScInputBarGroup& mrGroupBar; ScInputBarGroup& mrGroupBar;
const ScDocument* mpAssignedDocument;
long mnLines; long mnLines;
long mnLastExpandedLines; long mnLastExpandedLines;
}; };
...@@ -205,7 +210,7 @@ class ScInputBarGroup : public ScTextWndBase ...@@ -205,7 +210,7 @@ class ScInputBarGroup : public ScTextWndBase
{ {
public: public:
ScInputBarGroup( Window* Parent ); ScInputBarGroup( Window* Parent, ScTabViewShell* pViewSh );
virtual ~ScInputBarGroup(); virtual ~ScInputBarGroup();
virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ); virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
virtual void RemoveAccessibleTextData( 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