summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2011-07-05 09:59:47 +0100
committerNoel Power <noel.power@novell.com>2011-07-05 09:59:47 +0100
commitce0a204f358d384434fd878d107c4f10bb75c66d (patch)
tree6209dd8d2c16bca50567730c813f720c40075291
parent0a5679e3a58301a433cb0bf2a210745dc752e52f (diff)
align with master.. brief description of changes
AccessibileText.cxx: basically disabled when using the new code via a dynamic_cast, it's not clear to me what to do with the accessibility side of things inputwin.[ch]xx: captured the differences between the core ScTextWnd and Anurag's ScTexWnd by creating a subclass ScMultiTextWnd ( not a great name but... ) Also made a common base class between ScInputBarGroup and ScTextWnd so they are substituteable at runtime, hooked that into the option stuff. what needs to be done: a) The resize logic seems a bit crazy to me, lots of duplication not really coherent, things changed and then rechanged in similar ways in different places b) seems there are some problems when trying to resize the ScMultiTextWnd text window ( didn't see it yet as I didn't yet have a patch ) presumably this is some draw or paint issue ( but shouldn't block getting the functionality working ) c) button and scrollbar hooking in
-rw-r--r--sc/source/ui/Accessibility/AccessibleText.cxx14
-rw-r--r--sc/source/ui/app/inputwin.cxx334
-rw-r--r--sc/source/ui/inc/inputwin.hxx81
3 files changed, 313 insertions, 116 deletions
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
index d7bdc3d37..1c096bff0 100644
--- a/sc/source/ui/Accessibility/AccessibleText.cxx
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -1096,7 +1096,7 @@ ScAccessibleEditLineTextData::ScAccessibleEditLineTextData(EditView* pEditView,
ScAccessibleEditObjectTextData(pEditView, pWin),
mbEditEngineCreated(false)
{
- ScTextWnd* pTxtWnd = (ScTextWnd*)pWin;
+ ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>( pWin );
if (pTxtWnd)
pTxtWnd->InsertAccessibleTextData( *this );
@@ -1104,7 +1104,7 @@ ScAccessibleEditLineTextData::ScAccessibleEditLineTextData(EditView* pEditView,
ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
{
- ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+ ScTextWnd* pTxtWnd = dynamic_cast< ScTextWnd* >(mpWindow);
if (pTxtWnd)
pTxtWnd->RemoveAccessibleTextData( *this );
@@ -1125,7 +1125,7 @@ ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
void ScAccessibleEditLineTextData::Dispose()
{
- ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+ ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow);
if (pTxtWnd)
pTxtWnd->RemoveAccessibleTextData( *this );
@@ -1141,7 +1141,7 @@ ScAccessibleTextData* ScAccessibleEditLineTextData::Clone() const
SvxTextForwarder* ScAccessibleEditLineTextData::GetTextForwarder()
{
- ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+ ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow);
if (pTxtWnd)
{
@@ -1187,7 +1187,7 @@ SvxTextForwarder* ScAccessibleEditLineTextData::GetTextForwarder()
SvxEditViewForwarder* ScAccessibleEditLineTextData::GetEditViewForwarder( sal_Bool bCreate )
{
- ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+ ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow);
if (pTxtWnd)
{
@@ -1209,7 +1209,7 @@ SvxEditViewForwarder* ScAccessibleEditLineTextData::GetEditViewForwarder( sal_Bo
void ScAccessibleEditLineTextData::ResetEditMode()
{
- ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+ ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow);
if (mbEditEngineCreated && mpEditEngine)
delete mpEditEngine;
@@ -1227,7 +1227,7 @@ void ScAccessibleEditLineTextData::TextChanged()
{
if (mbEditEngineCreated && mpEditEngine)
{
- ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+ ScTextWnd* pTxtWnd = dynamic_cast<ScTextWnd*>(mpWindow);
if (pTxtWnd)
mpEditEngine->SetText(pTxtWnd->GetTextString());
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index dc1237694..2d7a74874 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -31,8 +31,6 @@
#include <algorithm>
-#include<stdio.h>
-
#include "scitems.hxx"
#include <editeng/eeitem.hxx>
@@ -77,8 +75,10 @@
#include <com/sun/star/accessibility/XAccessible.hpp>
#include "AccessibleEditObject.hxx"
#include "AccessibleText.hxx"
+#include <svtools/miscopt.hxx>
-#define TEXT_STARTPOS 5
+#define TEXT_STARTPOS 3
+#define TEXT_MULTI_STARTPOS 5
#define THESIZE 1000000 //!!! langt... :-)
#define TBX_WINDOW_HEIGHT 22 // in Pixeln - fuer alle Systeme gleich?
@@ -130,20 +130,32 @@ SfxChildWinInfo ScInputWindowWrapper::GetInfo() const
//==================================================================
#define IMAGE(id) pImgMgr->SeekImage(id)
+bool lcl_isExperimentalMode()
+{
+ SvtMiscOptions aMiscOptions;
+ return aMiscOptions.IsExperimentalMode();
+}
//==================================================================
// class ScInputWindow
//==================================================================
+ScTextWndBase* lcl_chooseRuntimeImpl( Window* pParent )
+{
+ if ( !lcl_isExperimentalMode() )
+ return new ScTextWnd( pParent );
+ return new ScInputBarGroup( pParent );
+}
+
ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
// mit WB_CLIPCHILDREN, sonst Flicker
ToolBox ( pParent, WinBits(WB_BORDER|WB_3DLOOK|WB_CLIPCHILDREN) ),
aWndPos ( this ),
-// maScrollBar ( this, WB_VERT | WB_DRAG ),
- aBarGroup ( this),
+ pRuntimeWindow ( lcl_chooseRuntimeImpl( this ) ),
+ aTextWindow ( *pRuntimeWindow ),
pInputHdl ( NULL ),
pBindings ( pBind ),
- aTextOk ( ScResId( SCSTR_QHELP_BTNOK ) ), // not always new from Resource
+ aTextOk ( ScResId( SCSTR_QHELP_BTNOK ) ), // nicht immer neu aus Resource
aTextCancel ( ScResId( SCSTR_QHELP_BTNCANCEL ) ),
aTextSum ( ScResId( SCSTR_QHELP_BTNSUM ) ),
aTextEqual ( ScResId( SCSTR_QHELP_BTNEQUAL ) ),
@@ -164,20 +176,19 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
}
DBG_ASSERT( pViewSh, "no view shell for input window" );
- // Position window, 3 buttons, input window
+ // Positionsfenster, 3 Buttons, Eingabefenster
InsertWindow ( 1, &aWndPos, 0, 0 );
InsertSeparator ( 1 );
InsertItem ( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ), 0, 2 );
InsertItem ( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ), 0, 3 );
InsertItem ( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ), 0, 4 );
InsertSeparator ( 5 );
- InsertWindow ( 7, &aBarGroup, 0, 6 );
-// InsertWindow ( 8, &maScrollBar, 0, 8 );
+ InsertWindow ( 7, &aTextWindow, 0, 6 );
aWndPos .SetQuickHelpText( ScResId( SCSTR_QHELP_POSWND ) );
aWndPos .SetHelpId ( HID_INSWIN_POS );
-// aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
-// aTextWindow.SetHelpId ( HID_INSWIN_INPUT );
+ aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
+ aTextWindow.SetHelpId ( HID_INSWIN_INPUT );
// kein SetHelpText, die Hilfetexte kommen aus der Hilfe
@@ -193,8 +204,7 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
SetHelpId( HID_SC_INPUTWIN ); // fuer die ganze Eingabezeile
aWndPos .Show();
-// maScrollBar .Show();
- aBarGroup .Show();
+ aTextWindow.Show();
pInputHdl = SC_MOD()->GetInputHdl( pViewSh, false ); // use own handler even if ref-handler is set
if (pInputHdl)
@@ -206,7 +216,7 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
// -> Inhalt des Funktionsautopiloten wieder anzeigen
//! auch Selektion (am InputHdl gemerkt) wieder anzeigen
- aBarGroup.SetTextString( pInputHdl->GetFormString() );
+ aTextWindow.SetTextString( pInputHdl->GetFormString() );
}
else if ( pInputHdl && pInputHdl->IsInputMode() )
{
@@ -214,7 +224,7 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
// (Editieren einer Formel, dann umschalten zu fremdem Dokument/Hilfe),
// wieder den gerade editierten Text aus dem InputHandler anzeigen
- aBarGroup.SetTextString( pInputHdl->GetEditString() ); // Text anzeigen
+ aTextWindow.SetTextString( pInputHdl->GetEditString() ); // Text anzeigen
if ( pInputHdl->IsTopMode() )
pInputHdl->SetMode( SC_INPUT_TABLE ); // Focus kommt eh nach unten
}
@@ -357,7 +367,7 @@ void ScInputWindow::Select()
case SID_INPUT_OK:
pScMod->InputEnterHandler();
SetSumAssignMode();
- aBarGroup.Invalidate(); // sonst bleibt Selektion stehen
+ aTextWindow.Invalidate(); // sonst bleibt Selektion stehen
break;
case SID_INPUT_SUM:
@@ -464,13 +474,13 @@ void ScInputWindow::Select()
case SID_INPUT_EQUAL:
{
- aBarGroup.StartEditEngine();
+ aTextWindow.StartEditEngine();
if ( pScMod->IsEditMode() ) // nicht, wenn z.B. geschuetzt
{
- aBarGroup.GainFocus();
- aBarGroup.SetTextString( '=' );
+ aTextWindow.GrabFocus();
+ aTextWindow.SetTextString( '=' );
- EditView* pView = aBarGroup.GetEditView();
+ EditView* pView = aTextWindow.GetEditView();
if (pView)
{
pView->SetSelection( ESelection(0,1, 0,1) );
@@ -489,15 +499,18 @@ void ScInputWindow::Resize()
ToolBox::Resize();
long nWidth = GetSizePixel().Width();
- long nLeft = aBarGroup.GetPosPixel().X();
- Size aSize = aBarGroup.GetSizePixel();
-
- aSize.Width() = Max( ((long)(nWidth - nLeft - 10)), (long)0 );
- aSize.Height()= TBX_WINDOW_HEIGHT;
- aBarGroup.SetSizePixel( aSize );
- aBarGroup.Invalidate();
+ long nLeft = aTextWindow.GetPosPixel().X();
+ Size aSize = aTextWindow.GetSizePixel();
- aBarGroup.Resize();
+ aSize.Width() = Max( ((long)(nWidth - nLeft - 5)), (long)0 );
+ if ( lcl_isExperimentalMode() )
+ {
+ aSize.Height()= TBX_WINDOW_HEIGHT;
+ aTextWindow.SetSizePixel( aSize );
+ aTextWindow.Resize();
+ }
+ aTextWindow.SetSizePixel( aSize );
+ aTextWindow.Invalidate();
}
void ScInputWindow::SetFuncString( const String& rString, sal_Bool bDoEdit )
@@ -505,15 +518,15 @@ void ScInputWindow::SetFuncString( const String& rString, sal_Bool bDoEdit )
//! new method at ScModule to query if function autopilot is open
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
- aBarGroup.StartEditEngine();
+ aTextWindow.StartEditEngine();
ScModule* pScMod = SC_MOD();
if ( pScMod->IsEditMode() )
{
if ( bDoEdit )
- aBarGroup.GainFocus();
- aBarGroup.SetTextString( rString );
- EditView* pView = aBarGroup.GetEditView();
+ aTextWindow.GrabFocus();
+ aTextWindow.SetTextString( rString );
+ EditView* pView = aTextWindow.GetEditView();
if (pView)
{
xub_StrLen nLen = rString.Len();
@@ -540,18 +553,13 @@ void ScInputWindow::SetPosString( const String& rStr )
void ScInputWindow::SetTextString( const String& rString )
{
- int i = rString.Len();
if (rString.Len() <= 32767)
- {
- aBarGroup.SetTextString(rString);
-// printf("%d ScInputWnd:SetTextString(), if \n",i);
- }
+ aTextWindow.SetTextString(rString);
else
{
-// printf("%d ScInputWnd:SetTextString(), else \n",i);
String aNew = rString;
aNew.Erase(32767);
- aBarGroup.SetTextString(aNew);
+ aTextWindow.SetTextString(aNew);
}
}
@@ -605,7 +613,7 @@ void ScInputWindow::SetSumAssignMode()
void ScInputWindow::SetFormulaMode( sal_Bool bSet )
{
aWndPos.SetFormulaMode(bSet);
- aBarGroup.SetFormulaMode(bSet);
+ aTextWindow.SetFormulaMode(bSet);
}
void ScInputWindow::SetText( const String& rString )
@@ -620,43 +628,43 @@ String ScInputWindow::GetText() const
sal_Bool ScInputWindow::IsInputActive()
{
- return aBarGroup.IsInputActive();
+ return aTextWindow.IsInputActive();
}
EditView* ScInputWindow::GetEditView()
{
- return aBarGroup.GetEditView();
+ return aTextWindow.GetEditView();
}
void ScInputWindow::MakeDialogEditView()
{
- aBarGroup.MakeDialogEditView();
+ aTextWindow.MakeDialogEditView();
}
void ScInputWindow::StopEditEngine( sal_Bool bAll )
{
-// aTextWindow.StopEditEngine( bAll );
+ aTextWindow.StopEditEngine( bAll );
}
void ScInputWindow::TextGrabFocus()
{
- aBarGroup.GainFocus();
+ aTextWindow.GrabFocus();
}
void ScInputWindow::TextInvalidate()
{
- aBarGroup.Invalidate();
+ aTextWindow.Invalidate();
}
void ScInputWindow::SwitchToTextWin()
{
// used for shift-ctrl-F2
- aBarGroup.StartEditEngine();
+ aTextWindow.StartEditEngine();
if ( SC_MOD()->IsEditMode() )
{
- aBarGroup.GainFocus();
- EditView* pView = aBarGroup.GetEditView();
+ aTextWindow.GrabFocus();
+ EditView* pView = aTextWindow.GetEditView();
if (pView)
{
xub_StrLen nLen = pView->GetEditEngine()->GetTextLen(0);
@@ -720,28 +728,38 @@ void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
//========================================================================
ScInputBarGroup::ScInputBarGroup(Window* pParent)
- : Window ( pParent, WinBits(WB_HIDE) ),
+ : ScTextWndBase ( pParent, WinBits(WB_HIDE) ),
aTextWindow ( this ),
- maScrollBar ( this, WB_VERT | WB_DRAG ),
bIsMultiLine ( false )
{
-
aTextWindow.Show();
aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
aTextWindow.SetHelpId ( HID_INSWIN_INPUT );
-
- maScrollBar.SetPageSize( 1 );
- maScrollBar.SetVisibleSize( 1 );
- maScrollBar.SetLineSize( 1 );
- maScrollBar.SetRange( Range( 0, 1 ) );
- maScrollBar.SetThumbPos( 10 );
- maScrollBar.Show();
}
ScInputBarGroup::~ScInputBarGroup()
{
}
+
+void
+ScInputBarGroup::InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
+{
+ aTextWindow.InsertAccessibleTextData( rTextData );
+}
+
+void
+ScInputBarGroup::RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
+{
+ aTextWindow.RemoveAccessibleTextData( rTextData );
+}
+
+const String&
+ScInputBarGroup::GetTextString() const
+{
+ return aTextWindow.GetTextString();
+}
+
void ScInputBarGroup::SetTextString( const String& rString )
{
aTextWindow.SetTextString(rString);
@@ -752,6 +770,7 @@ void ScInputBarGroup::Resize()
long nWidth = GetSizePixel().Width();
long nLeft = aTextWindow.GetPosPixel().X();
Size aSize = aTextWindow.GetSizePixel();
+
aSize.Width() = Max( ((long)(nWidth - nLeft - 40)), (long)0 );
aSize.Height()=22;
aTextWindow.SetSizePixel( aSize );
@@ -764,6 +783,11 @@ void ScInputBarGroup::GainFocus()
}
+void ScInputBarGroup::StopEditEngine( sal_Bool bAll )
+{
+ aTextWindow.StopEditEngine( bAll );
+}
+
void ScInputBarGroup::StartEditEngine()
{
aTextWindow.StartEditEngine();
@@ -780,28 +804,61 @@ EditView* ScInputBarGroup::GetEditView()
return aTextWindow.GetEditView();
}
-bool ScInputBarGroup::IsInputActive()
+sal_Bool ScInputBarGroup::IsInputActive()
{
return aTextWindow.IsInputActive();
}
-void ScInputBarGroup::SetFormulaMode(bool bSet)
+void ScInputBarGroup::SetFormulaMode(sal_Bool bSet)
{
aTextWindow.SetFormulaMode(bSet);
}
+ScMultiTextWnd::ScMultiTextWnd( Window* pParen ) : ScTextWnd( pParen )
+{
+ nTextStartPos = TEXT_MULTI_STARTPOS;
+}
+
+void ScMultiTextWnd::Paint( const Rectangle& rRec )
+{
+ // We always use edit engine to draw text at all times.
+ if (!pEditEngine)
+ InitEditEngine(SfxObjectShell::Current());
+
+ if (pEditView)
+ {
+ pEditView->Paint(rRec);
+ }
+}
+
+void ScMultiTextWnd::Resize()
+{
+ if (pEditView)
+ {
+ Size aSize = GetOutputSizePixel();
+
+ Size bSize = LogicToPixel(Size(0,pEditEngine->GetLineHeight(0,0)));
+ int nDiff=(aSize.Height()-bSize.Height())/2;
+ Point aPos(nTextStartPos,nDiff*aSize.Height()/aSize.Height());
+ Point aPos2(aSize.Width()-5,(aSize.Height()-nDiff)*aSize.Height()/aSize.Height());
+ pEditView->SetOutputArea(
+ PixelToLogic(Rectangle(aPos, aPos2)));
+ }
+}
+
//========================================================================
-// Input Window
+// Eingabefenster
//========================================================================
ScTextWnd::ScTextWnd( Window* pParent )
- : Window ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
+ : ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
DragSourceHelper( this ),
pEditEngine ( NULL ),
pEditView ( NULL ),
bIsInsertMode( sal_True ),
bFormulaMode ( false ),
- bInputMode ( false )
+ bInputMode ( false ),
+ nTextStartPos ( TEXT_STARTPOS )
{
EnableRTL( false ); // EditEngine can't be used with VCL EnableRTL
@@ -832,7 +889,6 @@ ScTextWnd::ScTextWnd( Window* pParent )
SetLineColor ( COL_BLACK );
SetMapMode ( MAP_TWIP );
SetPointer ( POINTER_TEXT );
-// StartEditEngine();
}
ScTextWnd::~ScTextWnd()
@@ -846,13 +902,27 @@ ScTextWnd::~ScTextWnd()
void ScTextWnd::Paint( const Rectangle& rRec )
{
- // We always use edit engine to draw text at all times.
- if (!pEditEngine)
- InitEditEngine(SfxObjectShell::Current());
-
if (pEditView)
+ pEditView->Paint( rRec );
+ else
{
- pEditView->Paint(rRec);
+ SetFont( aTextFont );
+
+ long nDiff = GetOutputSizePixel().Height()
+ - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
+// if (nDiff<2) nDiff=2; // mind. 1 Pixel
+
+ long nStartPos = nTextStartPos;
+ if ( bIsRTL )
+ {
+ // right-align
+ nStartPos += GetOutputSizePixel().Width() - 2*nTextStartPos -
+ LogicToPixel( Size( GetTextWidth( aString ), 0 ) ).Width();
+
+ // LayoutMode isn't changed as long as ModifyRTLDefaults doesn't include SvxFrameDirectionItem
+ }
+
+ DrawText( PixelToLogic( Point( nStartPos, nDiff/2 ) ), aString );
}
}
@@ -861,12 +931,14 @@ void ScTextWnd::Resize()
if (pEditView)
{
Size aSize = GetOutputSizePixel();
- Size bSize = LogicToPixel(Size(0,pEditEngine->GetLineHeight(0,0)));
- int nDiff=(aSize.Height()-bSize.Height())/2;
- Point aPos(TEXT_STARTPOS,nDiff*aSize.Height()/aSize.Height());
- Point aPos2(aSize.Width()-5,(aSize.Height()-nDiff)*aSize.Height()/aSize.Height());
+ long nDiff = aSize.Height()
+ - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
+
+ aSize.Width() -= 2 * nTextStartPos - 1;
+
pEditView->SetOutputArea(
- PixelToLogic(Rectangle(aPos, aPos2)));
+ PixelToLogic( Rectangle( Point( nTextStartPos, (nDiff > 0) ? nDiff/2 : 1 ),
+ aSize ) ) );
}
}
@@ -1011,7 +1083,7 @@ void ScTextWnd::LoseFocus()
String ScTextWnd::GetText() const
{
// ueberladen, um per Testtool an den Text heranzukommen
-printf("ScTextWnd::GetText()\n");
+
if ( pEditEngine )
return pEditEngine->GetText();
else
@@ -1086,7 +1158,27 @@ void lcl_ModifyRTLVisArea( EditView* pEditView )
pEditView->SetVisArea(aVisArea);
}
-void ScTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
+void ScMultiTextWnd::StartEditEngine()
+{
+ // Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
+
+ SfxObjectShell* pObjSh = SfxObjectShell::Current();
+ if ( pObjSh && pObjSh->IsInModalMode() )
+ return;
+
+ if ( !pEditView || !pEditEngine )
+ {
+ InitEditEngine(pObjSh);
+ }
+
+ SC_MOD()->SetInputMode( SC_INPUT_TOP );
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
+}
+
+void ScMultiTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
{
ScFieldEditEngine* pNew;
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
@@ -1107,7 +1199,7 @@ void ScTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
long nDiff = barHeight - textHeight;
barSize.Height()=nDiff+barHeight;
- barSize.Width() -= 2*TEXT_STARTPOS-4;
+ barSize.Width() -= 2*nTextStartPos-4;
pEditEngine->SetUpdateMode( false );
pEditEngine->SetPaperSize( PixelToLogic(Size(barSize.Width(),10000)) );
pEditEngine->SetWordDelimiters(
@@ -1173,17 +1265,94 @@ void ScTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
}
}
+void ScMultiTextWnd::StopEditEngine( sal_Bool /*bAll*/ )
+{
+}
+
void ScTextWnd::StartEditEngine()
{
// Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
-
SfxObjectShell* pObjSh = SfxObjectShell::Current();
if ( pObjSh && pObjSh->IsInModalMode() )
return;
if ( !pEditView || !pEditEngine )
{
- InitEditEngine(pObjSh);
+ ScFieldEditEngine* pNew;
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ {
+ const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+ pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+ }
+ else
+ pNew = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, sal_True );
+ pNew->SetExecuteURL( false );
+ pEditEngine = pNew;
+
+ pEditEngine->SetUpdateMode( false );
+ pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
+ pEditEngine->SetWordDelimiters(
+ ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
+
+ UpdateAutoCorrFlag();
+
+ {
+ SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
+ pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont );
+ lcl_ExtendEditFontAttribs( *pSet );
+ // turn off script spacing to match DrawText output
+ pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
+ if ( bIsRTL )
+ lcl_ModifyRTLDefaults( *pSet );
+ pEditEngine->SetDefaults( pSet );
+ }
+
+ // Wenn in der Zelle URL-Felder enthalten sind, muessen die auch in
+ // die Eingabezeile uebernommen werden, weil sonst die Positionen nicht stimmen.
+
+ sal_Bool bFilled = false;
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+ if ( pHdl ) //! Testen, ob's der richtige InputHdl ist?
+ bFilled = pHdl->GetTextAndFields( *pEditEngine );
+
+ pEditEngine->SetUpdateMode( sal_True );
+
+ // aString ist die Wahrheit...
+ if ( bFilled && pEditEngine->GetText() == aString )
+ Invalidate(); // Repaint fuer (hinterlegte) Felder
+ else
+ pEditEngine->SetText(aString); // dann wenigstens den richtigen Text
+
+ pEditView = new EditView( pEditEngine, this );
+ pEditView->SetInsertMode(bIsInsertMode);
+
+ // Text aus Clipboard wird als ASCII einzeilig uebernommen
+ sal_uLong n = pEditView->GetControlWord();
+ pEditView->SetControlWord( n | EV_CNTRL_SINGLELINEPASTE );
+
+ pEditEngine->InsertView( pEditView, EE_APPEND );
+
+ Resize();
+
+ if ( bIsRTL )
+ lcl_ModifyRTLVisArea( pEditView );
+
+ pEditEngine->SetModifyHdl(LINK(this, ScTextWnd, NotifyHdl));
+
+ if (!maAccTextDatas.empty())
+ maAccTextDatas.back()->StartEdit();
+
+ // 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) )
+ {
+ ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument(); // any document
+ sal_uInt8 nScript = pDoc->GetStringScriptType( aString );
+ if ( nScript & SCRIPTTYPE_COMPLEX )
+ Invalidate();
+ }
}
SC_MOD()->SetInputMode( SC_INPUT_TOP );
@@ -1211,8 +1380,6 @@ IMPL_LINK(ScTextWnd, NotifyHdl, EENotify*, EMPTYARG)
void ScTextWnd::StopEditEngine( sal_Bool bAll )
{
- printf("stopping editEngine\n");
-#if 0 // Make this a no-op for now.
if (pEditView)
{
if (!maAccTextDatas.empty())
@@ -1239,7 +1406,6 @@ void ScTextWnd::StopEditEngine( sal_Bool bAll )
if (bSelection)
Invalidate(); // damit Selektion nicht stehenbleibt
}
-#endif
}
void ScTextWnd::SetTextString( const String& rNewString )
@@ -1296,7 +1462,7 @@ void ScTextWnd::SetTextString( const String& rNewString )
nDifPos = 0;
// -1 wegen Rundung und "A"
- Point aLogicStart = PixelToLogic(Point(TEXT_STARTPOS-1,0));
+ Point aLogicStart = PixelToLogic(Point(nTextStartPos-1,0));
long nStartPos = aLogicStart.X();
long nInvPos = nStartPos;
if (nDifPos)
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 94481582f..627c4be83 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -33,9 +33,7 @@
#include <vcl/toolbox.hxx>
#include <sfx2/childwin.hxx>
#include <svl/lstner.hxx>
-#include <vcl/button.hxx>
#include <vcl/combobox.hxx>
-#include <vcl/scrbar.hxx>
#include <vcl/window.hxx>
#include <svtools/transfer.hxx>
@@ -49,33 +47,48 @@ class ScRangeList;
//========================================================================
-class ScTextWnd : public Window, public DragSourceHelper // edit window
+class ScTextWndBase : public Window
+{
+public:
+ ScTextWndBase( Window* pParent, WinBits nStyle ) : Window ( pParent, nStyle ) {}
+ virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0;
+ virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0;
+ virtual void SetTextString( const String& rString ) = 0;
+ virtual const String& GetTextString() const = 0;
+ virtual void StartEditEngine() = 0;
+ virtual void StopEditEngine( sal_Bool bAll ) = 0;
+ virtual EditView* GetEditView() = 0;
+ virtual void MakeDialogEditView() = 0;
+ virtual void SetFormulaMode( sal_Bool bSet ) = 0;
+ virtual sal_Bool IsInputActive() = 0;
+};
+
+class ScTextWnd : public ScTextWndBase, public DragSourceHelper // edit window
{
public:
ScTextWnd( Window* pParent );
virtual ~ScTextWnd();
- void SetTextString( const String& rString );
- const String& GetTextString() const;
+ virtual void SetTextString( const String& rString );
+ virtual const String& GetTextString() const;
sal_Bool IsInputActive();
- EditView* GetEditView();
+ virtual EditView* GetEditView();
// fuer FunktionsAutopiloten
- void MakeDialogEditView();
+ virtual void MakeDialogEditView();
- void InitEditEngine(SfxObjectShell* pObjSh);
- void StartEditEngine();
- void StopEditEngine( sal_Bool bAll );
+ virtual void StartEditEngine();
+ virtual void StopEditEngine( sal_Bool bAll );
virtual void DataChanged( const DataChangedEvent& rDCEvt );
- void SetFormulaMode( sal_Bool bSet );
+ virtual void SetFormulaMode( sal_Bool bSet );
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
- void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
- void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
+ virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
+ virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
DECL_LINK( NotifyHdl, EENotify* );
@@ -95,11 +108,9 @@ protected:
virtual String GetText() const;
-private:
void ImplInitSettings();
void UpdateAutoCorrFlag();
-private:
typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
String aString;
@@ -110,14 +121,16 @@ private:
sal_Bool bIsRTL;
sal_Bool bIsInsertMode;
sal_Bool bFormulaMode;
+
// #102710#; this flag should be true if a key input or a command is handled
// it prevents the call of InputChanged in the ModifyHandler of the EditEngine
sal_Bool bInputMode;
+ sal_Int16 nTextStartPos;
};
//========================================================================
-class ScPosWnd : public ComboBox, public SfxListener // Position window
+class ScPosWnd : public ComboBox, public SfxListener // Positionsanzeige
{
private:
String aPosStr;
@@ -150,35 +163,51 @@ private:
void ReleaseFocus_Impl();
};
-//==================================================================
+//========================================================================
+
+class ScMultiTextWnd : public ScTextWnd
+{
+public:
+ ScMultiTextWnd( Window* pParent );
+ virtual void StartEditEngine();
+ virtual void StopEditEngine( sal_Bool bAll );
+protected:
+ void InitEditEngine(SfxObjectShell* pObjSh);
-class ScInputBarGroup : public Window
+ virtual void Paint( const Rectangle& rRec );
+ virtual void Resize();
+};
+
+class ScInputBarGroup : public ScTextWndBase
{
public:
ScInputBarGroup( Window* Parent );
virtual ~ScInputBarGroup();
+ virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
+ virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
// virtual void Paint(const Rectangle& rRec );
void SetTextString( const String& rString );
void StartEditEngine();
EditView* GetEditView();
void SetSize(Size aSize);
virtual void Resize();
+ virtual const String& GetTextString() const;
+ virtual void StopEditEngine( sal_Bool bAll );
void InitEditEngine(SfxObjectShell* pObjSh);
void GainFocus();
- void SetFormulaMode( bool bSet );
+ void SetFormulaMode( sal_Bool bSet );
bool IsFocus();
void MakeDialogEditView();
- bool IsInputActive();
+ sal_Bool IsInputActive();
+
private:
- ScTextWnd aTextWindow;
- ScrollBar maScrollBar;
+ ScMultiTextWnd aTextWindow;
bool bIsMultiLine;
};
-//========================================================================
class ScInputWindow : public ToolBox // Parent-Toolbox
{
@@ -199,7 +228,7 @@ public:
void SetFormulaMode( sal_Bool bSet );
- sal_Bool IsInputActive();
+ virtual sal_Bool IsInputActive();
EditView* GetEditView();
void TextGrabFocus();
@@ -229,7 +258,8 @@ protected:
private:
ScPosWnd aWndPos;
- ScInputBarGroup aBarGroup;
+ std::auto_ptr<ScTextWndBase> pRuntimeWindow;
+ ScTextWndBase& aTextWindow;
ScInputHandler* pInputHdl;
SfxBindings* pBindings;
String aTextOk;
@@ -252,6 +282,7 @@ public:
SFX_DECL_CHILDWINDOW(ScInputWindowWrapper);
};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */