Kaydet (Commit) 46e663c4 authored tarafından Caolán McNamara's avatar Caolán McNamara

adapt code to data form .ui conversion

this dialog has some bizarre behaviour which is unchanged
with the .ui conversion

a) the scrollbar does not scroll the window beside it
up and down through the rows (which map to the spreadsheet columns),
but instead scrolls through the records (which map to the spreadsheet rows)
b) the dialog grows to include a row for each spreadsheet column, i.e.
large number of spreadsheet columns -> unusable dialog with too many rows
to fit on the screen.

what's indicated here is to clip the dialog to some max size and make the
scrollbar then scroll through the rows of the widget, and add another
scrollbar if necessary to scroll through the records.

Change-Id: I9b56992fc57468eb058d2a2914c08074f958a692
üst e9c05011
......@@ -57,7 +57,6 @@ $(eval $(call gb_SrsTarget_add_files,sc/res,\
sc/source/ui/src/autofmt.src \
sc/source/ui/src/globstr.src \
sc/source/ui/src/optsolver.src \
sc/source/ui/src/datafdlg.src \
sc/source/ui/src/toolbox.src \
sc/source/ui/src/scfuncs.src \
sc/source/ui/src/textdlgs.src \
......
......@@ -61,6 +61,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/scalc,\
$(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/cellprotectionpage \
sc/uiconfig/scalc/ui/createnamesdialog \
sc/uiconfig/scalc/ui/dataform \
sc/uiconfig/scalc/ui/definename \
sc/uiconfig/scalc/ui/deletecells \
sc/uiconfig/scalc/ui/deletecontents \
......
......@@ -367,7 +367,8 @@ public:
virtual AbstractScDeleteCellDlg * CreateScDeleteCellDlg(Window* pParent, bool bDisallowCellMove = false) = 0 ; //add for ScDeleteCellDlg
//for dataform
virtual AbstractScDataFormDlg * CreateScDataFormDlg( Window* pParent, int nId, ScTabViewShell* pTabViewShell ) = 0 ; //add for ScDataFormDlg
virtual AbstractScDataFormDlg * CreateScDataFormDlg(Window* pParent,
ScTabViewShell* pTabViewShell) = 0;
virtual AbstractScDeleteContentsDlg * CreateScDeleteContentsDlg(Window* pParent, //add for ScDeleteContentsDlg
sal_uInt16 nCheckDefaults = 0) = 0;
......
......@@ -827,26 +827,13 @@ AbstractScDeleteCellDlg* ScAbstractDialogFactory_Impl::CreateScDeleteCellDlg(Win
return new AbstractScDeleteCellDlg_Impl( pDlg );
}
AbstractScDataFormDlg* ScAbstractDialogFactory_Impl::CreateScDataFormDlg( Window* pParent, int nId, ScTabViewShell* pTabViewShell )
AbstractScDataFormDlg* ScAbstractDialogFactory_Impl::CreateScDataFormDlg(Window* pParent,
ScTabViewShell* pTabViewShell)
{
ScDataFormDlg * pDlg=NULL;
switch ( nId )
{
case RID_SCDLG_DATAFORM :
pDlg = new ScDataFormDlg( pParent, pTabViewShell);
break;
default:
break;
}
if ( pDlg )
return new AbstractScDataFormDlg_Impl( pDlg );
return 0;
ScDataFormDlg* pDlg = new ScDataFormDlg(pParent, pTabViewShell);
return new AbstractScDataFormDlg_Impl(pDlg);
}
AbstractScDeleteContentsDlg* ScAbstractDialogFactory_Impl::CreateScDeleteContentsDlg(Window* pParent,
sal_uInt16 nCheckDefaults)
{
......
......@@ -434,7 +434,8 @@ public:
virtual AbstractScDeleteCellDlg * CreateScDeleteCellDlg(Window* pParent, bool bDisallowCellMove = false );
//for dataform
virtual AbstractScDataFormDlg * CreateScDataFormDlg( Window* pParent, int nId, ScTabViewShell* pTabViewShell); //add for ScDeleteCellDlg
virtual AbstractScDataFormDlg* CreateScDataFormDlg(Window* pParent,
ScTabViewShell* pTabViewShell);
virtual AbstractScDeleteContentsDlg * CreateScDeleteContentsDlg(Window* pParent, //add for ScDeleteContentsDlg
sal_uInt16 nCheckDefaults = 0);
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Novell Inc.
* Portions created by the Initial Developer are Copyright (C) 2010 the
* Initial Developer. All Rights Reserved.
*
* Contributor(s): Amelia Wang <amwang@novell.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include "sc.hrc" // -> RID_SCDLG_DATAFORM
//dataform
#define BTN_DATAFORM_NEW 1
#define BTN_DATAFORM_DELETE 2
#define BTN_DATAFORM_RESTORE 3
#define BTN_DATAFORM_PREV 4
#define BTN_DATAFORM_NEXT 5
#define BTN_DATAFORM_CLOSE 6
#define WND_DATAFORM_SCROLLBAR 7
#define LAB_DATAFORM_RECORDNO 8
#define STR_NEW_RECORD 11
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -51,19 +51,19 @@
#define EDIT_LEFT 62
#define LINE_HEIGHT 16
//zhangyun
class ScDataFormDlg : public ModalDialog
{
private:
PushButton aBtnNew;
PushButton aBtnDelete;
PushButton aBtnRestore;
PushButton aBtnPrev;
PushButton aBtnNext;
PushButton aBtnClose;
ScrollBar aSlider;
FixedText aFixedText;
PushButton* m_pBtnNew;
PushButton* m_pBtnDelete;
PushButton* m_pBtnRestore;
PushButton* m_pBtnPrev;
PushButton* m_pBtnNext;
PushButton* m_pBtnClose;
ScrollBar* m_pSlider;
VclGrid* m_pGrid;
FixedText* m_pFixedText;
OUString sNewRecord;
ScTabViewShell* pTabViewShell;
......
......@@ -33,7 +33,6 @@
#include "datafdlg.hxx"
#include "scresid.hxx"
#include "datafdlg.hrc"
#include "viewdata.hxx"
#include "docsh.hxx"
#include "refundo.hxx"
......@@ -44,21 +43,21 @@
#define HDL(hdl) LINK( this, ScDataFormDlg, hdl )
//zhangyun
ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri) :
ModalDialog ( pParent, ScResId( RID_SCDLG_DATAFORM ) ),
aBtnNew ( this, ScResId( BTN_DATAFORM_NEW ) ),
aBtnDelete ( this, ScResId( BTN_DATAFORM_DELETE ) ),
aBtnRestore ( this, ScResId( BTN_DATAFORM_RESTORE ) ),
aBtnPrev ( this, ScResId( BTN_DATAFORM_PREV ) ),
aBtnNext ( this, ScResId( BTN_DATAFORM_NEXT ) ),
aBtnClose ( this, ScResId( BTN_DATAFORM_CLOSE ) ),
aSlider ( this, ScResId( WND_DATAFORM_SCROLLBAR ) ),
aFixedText ( this, ScResId( LAB_DATAFORM_RECORDNO ) ),
sNewRecord(SC_RESSTR(STR_NEW_RECORD))
ScDataFormDlg::ScDataFormDlg(Window* pParent, ScTabViewShell* pTabViewShellOri)
: ModalDialog(pParent, "DataFormDialog", "modules/scalc/ui/dataform.ui")
, pTabViewShell(pTabViewShellOri)
{
pTabViewShell = pTabViewShellOri;
FreeResource();
get(m_pBtnNew, "new");
get(m_pBtnDelete, "delete");
get(m_pBtnRestore, "restore");
get(m_pBtnPrev, "prev");
get(m_pBtnNext, "next");
get(m_pBtnClose, "close");
get(m_pFixedText, "label");
sNewRecord = m_pFixedText->GetText();
get(m_pSlider, "scrollbar");
get(m_pGrid, "grid");
//read header form current document, and add new controls
OSL_ENSURE( pTabViewShell, "pTabViewShell is NULL! :-/" );
ScViewData* pViewData = pTabViewShell->GetViewData();
......@@ -157,42 +156,35 @@ ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri
nCurrentRow = nStartRow + 1;
String aFieldName;
//align with LAB_DATAFORM_RECORDNO
int nTop = LogicToPixel( Size(1,6), MapMode(MAP_APPFONT) ).getHeight();
const int nOne = LogicToPixel( Size(1,1), MapMode(MAP_APPFONT) ).getHeight();
const int nLineHeight = LogicToPixel( Size(1, LINE_HEIGHT), MapMode(MAP_APPFONT) ).getHeight();
const int nFixedLeft = LogicToPixel( Size(FIXED_LEFT, 1), MapMode(MAP_APPFONT) ).getWidth();
const int nEditLeft = LogicToPixel( Size(EDIT_LEFT, 1), MapMode(MAP_APPFONT) ).getWidth();
Size nFixedSize(LogicToPixel( Size(FIXED_WIDTH, FIXED_HEIGHT), MapMode(MAP_APPFONT) ));
Size nEditSize(LogicToPixel( Size(EDIT_WIDTH, EDIT_HEIGHT), MapMode(MAP_APPFONT) ));
aColLength = nEndCol - nStartCol + 1;
//new the controls
maFixedTexts.reserve(aColLength);
maEdits.reserve(aColLength);
for(sal_uInt16 nIndex = 0; nIndex < aColLength; nIndex++)
sal_Int32 nGridRow = 0;
for(sal_uInt16 nIndex = 0; nIndex < aColLength; ++nIndex)
{
aFieldName = pDoc->GetString(nIndex + nStartCol, nStartRow, nTab);
OUString aFieldName = pDoc->GetString(nIndex + nStartCol, nStartRow, nTab);
int nColWidth = pDoc->GetColWidth( nIndex + nStartCol, nTab );
if (nColWidth)
{
maFixedTexts.push_back( new FixedText(this) );
maEdits.push_back( new Edit(this, WB_BORDER) );
maFixedTexts.push_back( new FixedText(m_pGrid) );
maEdits.push_back( new Edit(m_pGrid, WB_BORDER) );
maFixedTexts[nIndex].set_grid_left_attach(0);
maEdits[nIndex].set_grid_left_attach(1);
maFixedTexts[nIndex].set_grid_top_attach(nGridRow);
maEdits[nIndex].set_grid_top_attach(nGridRow);
maEdits[nIndex].SetWidthInChars(32);
maEdits[nIndex].set_hexpand(true);
++nGridRow;
maFixedTexts[nIndex].SetSizePixel(nFixedSize);
maEdits[nIndex].SetSizePixel(nEditSize);
maFixedTexts[nIndex].SetPosPixel(Point(nFixedLeft, nTop + nOne));
maEdits[nIndex].SetPosPixel(Point(nEditLeft, nTop));
maFixedTexts[nIndex].SetText(aFieldName);
maFixedTexts[nIndex].Show();
maEdits[nIndex].Show();
nTop += nLineHeight;
}
else
{
......@@ -202,35 +194,25 @@ ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri
if (!maEdits.is_null(nIndex))
maEdits[nIndex].SetModifyHdl( HDL(Impl_DataModifyHdl) );
}
Size nDialogSize = this->GetSizePixel();
if (nTop > nDialogSize.Height())
{
nDialogSize.setHeight(nTop);
this->SetSizePixel(nDialogSize);
}
Size nScrollSize = aSlider.GetSizePixel();
nScrollSize.setHeight(nDialogSize.Height()-20);
aSlider.SetSizePixel(nScrollSize);
}
FillCtrls(nCurrentRow);
aSlider.SetPageSize( 10 );
aSlider.SetVisibleSize( 1 );
aSlider.SetLineSize( 1 );
aSlider.SetRange( Range( 0, nEndRow - nStartRow + 1) );
aSlider.Show();
m_pSlider->SetPageSize( 10 );
m_pSlider->SetVisibleSize( 1 );
m_pSlider->SetLineSize( 1 );
m_pSlider->SetRange( Range( 0, nEndRow - nStartRow + 1) );
m_pSlider->Show();
aBtnNew.SetClickHdl ( HDL(Impl_NewHdl) );
aBtnPrev.SetClickHdl ( HDL(Impl_PrevHdl) );
aBtnNext.SetClickHdl ( HDL(Impl_NextHdl) );
m_pBtnNew->SetClickHdl(HDL(Impl_NewHdl));
m_pBtnPrev->SetClickHdl(HDL(Impl_PrevHdl));
m_pBtnNext->SetClickHdl(HDL(Impl_NextHdl));
aBtnRestore.SetClickHdl ( HDL(Impl_RestoreHdl) );
aBtnDelete.SetClickHdl ( HDL(Impl_DeleteHdl) );
aBtnClose.SetClickHdl ( HDL(Impl_CloseHdl) );
m_pBtnRestore->SetClickHdl(HDL(Impl_RestoreHdl));
m_pBtnDelete->SetClickHdl(HDL(Impl_DeleteHdl));
m_pBtnClose->SetClickHdl(HDL(Impl_CloseHdl));
aSlider.SetEndScrollHdl( HDL( Impl_ScrollHdl ) );
m_pSlider->SetEndScrollHdl(HDL(Impl_ScrollHdl));
SetButtonState();
}
......@@ -263,18 +245,18 @@ void ScDataFormDlg::FillCtrls(SCROW /*nCurrentRow*/)
aBuf.append(static_cast<sal_Int32>(nCurrentRow - nStartRow));
aBuf.appendAscii(" / ");
aBuf.append(static_cast<sal_Int32>(nEndRow - nStartRow));
aFixedText.SetText(aBuf.makeStringAndClear());
m_pFixedText->SetText(aBuf.makeStringAndClear());
}
else
aFixedText.SetText(sNewRecord);
m_pFixedText->SetText(sNewRecord);
aSlider.SetThumbPos(nCurrentRow-nStartRow-1);
m_pSlider->SetThumbPos(nCurrentRow-nStartRow-1);
}
IMPL_LINK( ScDataFormDlg, Impl_DataModifyHdl, Edit*, pEdit)
{
if ( pEdit->IsModified() )
aBtnRestore.Enable( true );
m_pBtnRestore->Enable( true );
return 0;
}
......@@ -301,7 +283,7 @@ IMPL_LINK_NOARG(ScDataFormDlg, Impl_NewHdl)
if (nCurrentRow >= nEndRow + 2)
{
nEndRow ++ ;
aSlider.SetRange( Range( 0, nEndRow - nStartRow + 1) );
m_pSlider->SetRange( Range( 0, nEndRow - nStartRow + 1) );
}
SetButtonState();
FillCtrls(nCurrentRow);
......@@ -375,7 +357,7 @@ IMPL_LINK_NOARG(ScDataFormDlg, Impl_CloseHdl)
IMPL_LINK_NOARG(ScDataFormDlg, Impl_ScrollHdl)
{
long nOffset = aSlider.GetThumbPos();
long nOffset = m_pSlider->GetThumbPos();
nCurrentRow = nStartRow + nOffset + 1;
SetButtonState();
FillCtrls(nCurrentRow);
......@@ -386,21 +368,21 @@ void ScDataFormDlg::SetButtonState()
{
if (nCurrentRow > nEndRow)
{
aBtnDelete.Enable( false );
aBtnNext.Enable( false );
m_pBtnDelete->Enable( false );
m_pBtnNext->Enable( false );
}
else
{
aBtnDelete.Enable( true );
aBtnNext.Enable( true );
m_pBtnDelete->Enable( true );
m_pBtnNext->Enable( true );
}
if (nCurrentRow == nStartRow + 1)
aBtnPrev.Enable( false );
m_pBtnPrev->Enable( false );
else
aBtnPrev.Enable( true );
m_pBtnPrev->Enable( true );
aBtnRestore.Enable( false );
m_pBtnRestore->Enable( false );
if ( maEdits.size()>=1 && !maEdits.is_null(0) )
maEdits[0].GrabFocus();
}
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Novell Inc.
* Portions created by the Initial Developer are Copyright (C) 2010 the
* Initial Developer. All Rights Reserved.
*
* Contributor(s): Amelia Wang <amwang@novell.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include "datafdlg.hrc"
ModalDialog RID_SCDLG_DATAFORM
{
OutputSize = TRUE ;
SVLook = TRUE ;
Size = MAP_APPFONT ( 257 , 180 ) ;
Text [ en-US ] = "Data Form" ;
Moveable = TRUE ;
Closeable = TRUE ;
FixedText LAB_DATAFORM_RECORDNO
{
Pos = MAP_APPFONT ( 162 , 6 ) ;
Size = MAP_APPFONT ( 60 , 12 ) ;
Text = "/" ; //placeholder only
};
PushButton BTN_DATAFORM_NEW
{
Pos = MAP_APPFONT ( 161 , 23 ) ;
Size = MAP_APPFONT ( 90 , 14 ) ;
TabStop = TRUE ;
DefButton = TRUE ;
Text [ en-US ] = "New" ;
};
PushButton BTN_DATAFORM_DELETE
{
Pos = MAP_APPFONT ( 161 , 40 ) ;
Size = MAP_APPFONT ( 90 , 14 ) ;
TabStop = TRUE ;
Text [ en-US ] = "Delete" ;
};
PushButton BTN_DATAFORM_RESTORE
{
Pos = MAP_APPFONT ( 161 , 57 ) ;
Size = MAP_APPFONT ( 90 , 14 ) ;
TabStop = TRUE ;
Text [ en-US ] = "Restore" ;
};
PushButton BTN_DATAFORM_PREV
{
Pos = MAP_APPFONT ( 161 , 82 ) ;
Size = MAP_APPFONT ( 90 , 14 ) ;
TabStop = TRUE ;
Text [ en-US ] = "Previous Record" ;
};
PushButton BTN_DATAFORM_NEXT
{
Pos = MAP_APPFONT ( 161 , 99 ) ;
Size = MAP_APPFONT ( 90 , 14 ) ;
TabStop = TRUE ;
Text [ en-US ] = "Next Record" ;
};
PushButton BTN_DATAFORM_CLOSE
{
Pos = MAP_APPFONT ( 161 , 116 ) ;
Size = MAP_APPFONT ( 90 , 14 ) ;
TabStop = TRUE ;
Text [ en-US ] = "Close" ;
};
ScrollBar WND_DATAFORM_SCROLLBAR
{
Pos = MAP_APPFONT ( 150 , 6 ) ;
Size = MAP_APPFONT ( 8 , 135 ) ;
HScroll = FALSE ;
TabStop = FALSE ;
};
String STR_NEW_RECORD
{
Text [ en-US ] = "New Record" ;
};
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -906,7 +906,8 @@ ScVbaWorksheet::ShowDataForm( ) throw (uno::RuntimeException)
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg( pTabViewShell->GetDialogParent(),RID_SCDLG_DATAFORM, pTabViewShell);
AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg(pTabViewShell->GetDialogParent(),
pTabViewShell);
OSL_ENSURE(pDlg, "Dialog create fail!");
pDlg->Execute();
......
......@@ -315,7 +315,8 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg( pTabViewShell->GetDialogParent(),RID_SCDLG_DATAFORM, pTabViewShell);
AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg(
pTabViewShell->GetDialogParent(), pTabViewShell);
OSL_ENSURE(pDlg, "Dialog create fail!");
pDlg->Execute();
......
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