[Libreoffice-commits] .: 2 commits - sc/source
Noel Power
noelp at kemper.freedesktop.org
Tue Dec 13 05:05:18 PST 2011
sc/source/ui/app/inputhdl.cxx | 4 +-
sc/source/ui/app/inputwin.cxx | 69 ++++++++++++++++++++----------------------
sc/source/ui/inc/inputwin.hxx | 15 ++++++---
3 files changed, 45 insertions(+), 43 deletions(-)
New commits:
commit 4b6e0d42d72f8d2f5a18a0e0af595d884d96f552
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Tue Dec 13 00:08:41 2011 -0500
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.
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 649050b..5843cda 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -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
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 9f70ecb..1e896e7 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -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 );
commit 43c7830b03d141ae11d8617c0fdabefa32dd243c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Mon Dec 12 23:13:18 2011 -0500
Don't crash when typing Japanese via SCIM.
There should only be one active edit view while the user is typing
into a cell, or else it crashes when an external input method is
being used to input values (such as Japanese).
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 98cfac2..7620df7 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1719,7 +1719,7 @@ void ScInputHandler::UpdateActiveView()
else
pTableView = NULL;
- if (pInputWin)
+ if (pInputWin && pInputWin->IsInputActive())
pTopView = pInputWin->GetEditView();
else
pTopView = NULL;
@@ -2047,7 +2047,7 @@ void ScInputHandler::SyncViews( EditView* pSourceView )
lcl_SetTopSelection( pTableView, aSel );
}
// Only sync selection from topView if we are actually editiing there
- else if ( ( eMode == SC_INPUT_TOP ) && pTopView && pTableView)
+ else if (pTopView && pTableView)
{
aSel = pTopView->GetSelection();
lcl_SetTopSelection( pTableView, aSel );
More information about the Libreoffice-commits
mailing list