Kaydet (Commit) e0b93ef5 authored tarafından Dennis Francis's avatar Dennis Francis Kaydeden (comit) Eike Rathke

tdf#34094 : Allow column and row selections while creating a formula

Change-Id: I516ca96c0743840fb03d8208f7236ca25027bc45
Reviewed-on: https://gerrit.libreoffice.org/20102Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst f88576cb
...@@ -102,7 +102,7 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW, ...@@ -102,7 +102,7 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
if ( pInputHdl ) if ( pInputHdl )
pInputHdl->NotifyChange( nullptr ); pInputHdl->NotifyChange( nullptr );
ScFormulaReferenceHelper::enableInput( false ); ScFormulaReferenceHelper::enableInput( true );
ScFormulaReferenceHelper::EnableSpreadsheets(); ScFormulaReferenceHelper::EnableSpreadsheets();
m_aHelper.Init(); m_aHelper.Init();
ScFormulaReferenceHelper::SetDispatcherLock( true ); ScFormulaReferenceHelper::SetDispatcherLock( true );
......
...@@ -25,16 +25,17 @@ ...@@ -25,16 +25,17 @@
class ScHeaderFunctionSet; class ScHeaderFunctionSet;
class ScHeaderSelectionEngine; class ScHeaderSelectionEngine;
class ScTabView;
class ScColBar : public ScHeaderControl class ScColBar : public ScHeaderControl
{ {
ScViewData* pViewData;
ScHSplitPos eWhich; ScHSplitPos eWhich;
ScHeaderFunctionSet* pFuncSet; ScHeaderFunctionSet* pFuncSet;
public: public:
ScColBar( vcl::Window* pParent, ScViewData* pData, ScHSplitPos eWhichPos, ScColBar( vcl::Window* pParent, ScHSplitPos eWhichPos,
ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng ); ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng,
ScTabView* pTab );
virtual ~ScColBar(); virtual ~ScColBar();
virtual SCCOLROW GetPos() const override; virtual SCCOLROW GetPos() const override;
...@@ -60,13 +61,13 @@ public: ...@@ -60,13 +61,13 @@ public:
class ScRowBar : public ScHeaderControl class ScRowBar : public ScHeaderControl
{ {
ScViewData* pViewData;
ScVSplitPos eWhich; ScVSplitPos eWhich;
ScHeaderFunctionSet* pFuncSet; ScHeaderFunctionSet* pFuncSet;
public: public:
ScRowBar( vcl::Window* pParent, ScViewData* pData, ScVSplitPos eWhichPos, ScRowBar( vcl::Window* pParent, ScVSplitPos eWhichPos,
ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng ); ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng,
ScTabView* pTab );
virtual ~ScRowBar(); virtual ~ScRowBar();
virtual SCCOLROW GetPos() const override; virtual SCCOLROW GetPos() const override;
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
// Size of the sliders // Size of the sliders
#define HDR_SLIDERSIZE 2 #define HDR_SLIDERSIZE 2
class ScTabView;
class ScHeaderControl : public vcl::Window class ScHeaderControl : public vcl::Window
{ {
private: private:
...@@ -57,6 +59,8 @@ private: ...@@ -57,6 +59,8 @@ private:
bool bIgnoreMove; bool bIgnoreMove;
bool bDoneInitRef;
long GetScrPos( SCCOLROW nEntryNo ) const; long GetScrPos( SCCOLROW nEntryNo ) const;
SCCOLROW GetMousePos( const MouseEvent& rMEvt, bool& rBorder ) const; SCCOLROW GetMousePos( const MouseEvent& rMEvt, bool& rBorder ) const;
bool IsSelectionAllowed(SCCOLROW nPos) const; bool IsSelectionAllowed(SCCOLROW nPos) const;
...@@ -67,6 +71,8 @@ private: ...@@ -67,6 +71,8 @@ private:
void DrawShadedRect( long nStart, long nEnd, const Color& rBaseColor ); void DrawShadedRect( long nStart, long nEnd, const Color& rBaseColor );
protected: protected:
ScTabView* pTabView;
// Window overrides // Window overrides
virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) override; virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) override;
...@@ -102,7 +108,7 @@ protected: ...@@ -102,7 +108,7 @@ protected:
public: public:
ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelectionEngine, ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelectionEngine,
SCCOLROW nNewSize, bool bNewVertical ); SCCOLROW nNewSize, bool bNewVertical, ScTabView* pTab );
virtual ~ScHeaderControl(); virtual ~ScHeaderControl();
void SetIgnoreMove(bool bSet) { bIgnoreMove = bSet; } void SetIgnoreMove(bool bSet) { bIgnoreMove = bSet; }
......
This diff is collapsed.
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include "gridmerg.hxx" #include "gridmerg.hxx"
#include "document.hxx" #include "document.hxx"
#include "markdata.hxx" #include "markdata.hxx"
#include "tabview.hxx"
#include "viewdata.hxx"
#define SC_DRAG_MIN 2 #define SC_DRAG_MIN 2
...@@ -45,7 +47,7 @@ ...@@ -45,7 +47,7 @@
#define SC_HDRPAINT_COUNT 7 #define SC_HDRPAINT_COUNT 7
ScHeaderControl::ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelectionEngine, ScHeaderControl::ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelectionEngine,
SCCOLROW nNewSize, bool bNewVertical ) : SCCOLROW nNewSize, bool bNewVertical, ScTabView* pTab ) :
Window ( pParent ), Window ( pParent ),
pSelEngine ( pSelectionEngine ), pSelEngine ( pSelectionEngine ),
bVertical ( bNewVertical ), bVertical ( bNewVertical ),
...@@ -58,7 +60,9 @@ ScHeaderControl::ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelect ...@@ -58,7 +60,9 @@ ScHeaderControl::ScHeaderControl( vcl::Window* pParent, SelectionEngine* pSelect
nDragStart ( 0 ), nDragStart ( 0 ),
nDragPos ( 0 ), nDragPos ( 0 ),
bDragMoved ( false ), bDragMoved ( false ),
bIgnoreMove ( false ) bIgnoreMove ( false ),
bDoneInitRef( false ),
pTabView ( pTab )
{ {
// --- RTL --- no default mirroring for this window, the spreadsheet itself // --- RTL --- no default mirroring for this window, the spreadsheet itself
// is also not mirrored // is also not mirrored
...@@ -656,6 +660,26 @@ void ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -656,6 +660,26 @@ void ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
return; return;
if ( ! rMEvt.IsLeft() ) if ( ! rMEvt.IsLeft() )
return; return;
if ( SC_MOD()->IsFormulaMode() )
{
if( !pTabView )
return;
SCTAB nTab = pTabView->GetViewData().GetTabNo();
if( !rMEvt.IsShift() )
pTabView->DoneRefMode();
bDoneInitRef = true;
if( !bVertical )
{
pTabView->InitRefMode( nHitNo, 0, nTab, SC_REFTYPE_REF );
pTabView->UpdateRef( nHitNo, MAXROW, nTab );
}
else
{
pTabView->InitRefMode( 0, nHitNo, nTab, SC_REFTYPE_REF );
pTabView->UpdateRef( MAXCOL, nHitNo, nTab );
}
return;
}
if ( bIsBorder && ResizeAllowed() ) if ( bIsBorder && ResizeAllowed() )
{ {
nDragNo = nHitNo; nDragNo = nHitNo;
...@@ -714,6 +738,13 @@ void ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt ) ...@@ -714,6 +738,13 @@ void ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt )
if ( IsDisabled() ) if ( IsDisabled() )
return; return;
if ( SC_MOD()->IsFormulaMode() )
{
SC_MOD()->EndReference();
bDoneInitRef = false;
return;
}
SetMarking( false ); SetMarking( false );
bIgnoreMove = false; bIgnoreMove = false;
...@@ -767,6 +798,21 @@ void ScHeaderControl::MouseMove( const MouseEvent& rMEvt ) ...@@ -767,6 +798,21 @@ void ScHeaderControl::MouseMove( const MouseEvent& rMEvt )
return; return;
} }
if ( bDoneInitRef && rMEvt.IsLeft() && SC_MOD()->IsFormulaMode() )
{
if( !pTabView )
return;
bool bTmp;
SCCOLROW nHitNo = GetMousePos( rMEvt, bTmp );
SCTAB nTab = pTabView->GetViewData().GetTabNo();
if( !bVertical )
pTabView->UpdateRef( nHitNo, MAXROW, nTab );
else
pTabView->UpdateRef( MAXCOL, nHitNo, nTab );
return;
}
if ( bDragging ) if ( bDragging )
{ {
long nNewPos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X(); long nNewPos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X();
......
...@@ -1479,11 +1479,11 @@ void ScTabView::UpdateShow() ...@@ -1479,11 +1479,11 @@ void ScTabView::UpdateShow()
pRowOutline[SC_SPLIT_TOP] = VclPtr<ScOutlineWindow>::Create( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_TOPLEFT ); pRowOutline[SC_SPLIT_TOP] = VclPtr<ScOutlineWindow>::Create( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_TOPLEFT );
if (bShowH && bHeader && !pColBar[SC_SPLIT_RIGHT]) if (bShowH && bHeader && !pColBar[SC_SPLIT_RIGHT])
pColBar[SC_SPLIT_RIGHT] = VclPtr<ScColBar>::Create( pFrameWin, &aViewData, SC_SPLIT_RIGHT, pColBar[SC_SPLIT_RIGHT] = VclPtr<ScColBar>::Create( pFrameWin, SC_SPLIT_RIGHT,
&aHdrFunc, pHdrSelEng ); &aHdrFunc, pHdrSelEng, this );
if (bShowV && bHeader && !pRowBar[SC_SPLIT_TOP]) if (bShowV && bHeader && !pRowBar[SC_SPLIT_TOP])
pRowBar[SC_SPLIT_TOP] = VclPtr<ScRowBar>::Create( pFrameWin, &aViewData, SC_SPLIT_TOP, pRowBar[SC_SPLIT_TOP] = VclPtr<ScRowBar>::Create( pFrameWin, SC_SPLIT_TOP,
&aHdrFunc, pHdrSelEng ); &aHdrFunc, pHdrSelEng, this );
// show Windows // show Windows
......
...@@ -85,11 +85,11 @@ void ScTabView::Init() ...@@ -85,11 +85,11 @@ void ScTabView::Init()
pHdrSelEng = new ScHeaderSelectionEngine( pFrameWin, &aHdrFunc ); pHdrSelEng = new ScHeaderSelectionEngine( pFrameWin, &aHdrFunc );
pColBar[SC_SPLIT_LEFT] = VclPtr<ScColBar>::Create( pFrameWin, &aViewData, SC_SPLIT_LEFT, pColBar[SC_SPLIT_LEFT] = VclPtr<ScColBar>::Create( pFrameWin, SC_SPLIT_LEFT,
&aHdrFunc, pHdrSelEng ); &aHdrFunc, pHdrSelEng, this );
pColBar[SC_SPLIT_RIGHT] = nullptr; pColBar[SC_SPLIT_RIGHT] = nullptr;
pRowBar[SC_SPLIT_BOTTOM] = VclPtr<ScRowBar>::Create( pFrameWin, &aViewData, SC_SPLIT_BOTTOM, pRowBar[SC_SPLIT_BOTTOM] = VclPtr<ScRowBar>::Create( pFrameWin, SC_SPLIT_BOTTOM,
&aHdrFunc, pHdrSelEng ); &aHdrFunc, pHdrSelEng, this );
pRowBar[SC_SPLIT_TOP] = nullptr; pRowBar[SC_SPLIT_TOP] = nullptr;
for (i=0; i<2; i++) for (i=0; i<2; i++)
pColOutline[i] = pRowOutline[i] = nullptr; pColOutline[i] = pRowOutline[i] = nullptr;
......
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