tdf#99708 Save formula bar height to document
Save the current state of the Calc formula bar to the document. Number of visible lines is saved into the document settings and restored when loading that document. Also adds a UNO property, so that the formula bar height can be changed via UNO. Change-Id: Ifef0c9e42cb4f7465516629d2c22974367e0eb33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133499 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
This commit is contained in:
@@ -152,6 +152,13 @@ published service SpreadsheetViewSettings
|
||||
com::sun::star::view::DocumentZoomType::BY_VALUE.
|
||||
*/
|
||||
[property] short ZoomValue;
|
||||
|
||||
/** Number of lines shown in the Formula bar
|
||||
Default is 1, maximum value is 25.
|
||||
|
||||
@since LibreOffice 7.4
|
||||
*/
|
||||
[optional, property] short FormulaBarHeight;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#define SC_RASTERSUBX 21
|
||||
#define SC_RASTERSUBY 22
|
||||
#define SC_RASTERSYNC 23
|
||||
#define SC_FORMULA_BAR_HEIGHT 24
|
||||
|
||||
// this are the defines for the position of the settings in the
|
||||
// TableViewSettingsSequence
|
||||
@@ -70,6 +71,7 @@
|
||||
#define SC_TABLE_ZOOM_TYPE 11
|
||||
#define SC_TABLE_ZOOM_VALUE 12
|
||||
#define SC_TABLE_PAGE_VIEW_ZOOM_VALUE 13
|
||||
#define SC_FORMULA_BAR_HEIGHT_VALUE 14
|
||||
#define SC_TABLE_SHOWGRID 15
|
||||
|
||||
inline constexpr OUStringLiteral SC_CURSORPOSITIONX = u"CursorPositionX";
|
||||
@@ -95,6 +97,7 @@ inline constexpr OUStringLiteral SC_ZOOMTYPE = u"ZoomType";
|
||||
inline constexpr OUStringLiteral SC_ZOOMVALUE = u"ZoomValue";
|
||||
inline constexpr OUStringLiteral SC_PAGEVIEWZOOMVALUE = u"PageViewZoomValue";
|
||||
inline constexpr OUStringLiteral SC_SHOWPAGEBREAKPREVIEW = u"ShowPageBreakPreview";
|
||||
inline constexpr OUStringLiteral SC_FORMULABARHEIGHT = u"FormulaBarHeight";
|
||||
inline constexpr OUStringLiteral SC_VIEWID = u"ViewId";
|
||||
#define SC_VIEW "view"
|
||||
|
||||
|
@@ -576,6 +576,7 @@ inline constexpr OUStringLiteral SC_SERVICENAME_CHART_PIVOTTABLE_DATAPROVIDER =
|
||||
#define SC_UNO_UPDTEMPL "UpdateFromTemplate"
|
||||
#define SC_UNO_FILTERED_RANGE_SELECTION "FilteredRangeSelection"
|
||||
#define SC_UNO_VISAREASCREEN "VisibleAreaOnScreen"
|
||||
#define SC_UNO_FORMULABARHEIGHT "FormulaBarHeight"
|
||||
#define SC_UNO_IMAGE_PREFERRED_DPI "ImagePreferredDPI"
|
||||
|
||||
/*Stampit enable/disable print cancel */
|
||||
|
@@ -677,6 +677,11 @@ void ScInputWindow::EnableButtons( bool bEnable )
|
||||
// Invalidate();
|
||||
}
|
||||
|
||||
void ScInputWindow::NumLinesChanged()
|
||||
{
|
||||
mxTextWindow->NumLinesChanged();
|
||||
}
|
||||
|
||||
void ScInputWindow::StateChanged( StateChangedType nType )
|
||||
{
|
||||
ToolBox::StateChanged( nType );
|
||||
@@ -908,6 +913,7 @@ void ScInputBarGroup::Resize()
|
||||
{
|
||||
mxTextWndGroup->SetScrollPolicy();
|
||||
InterimItemWindow::Resize();
|
||||
TriggerToolboxLayout();
|
||||
}
|
||||
|
||||
void ScInputBarGroup::StopEditEngine(bool bAll)
|
||||
@@ -1034,16 +1040,25 @@ IMPL_LINK_NOARG(ScInputWindow, DropdownClickHdl, ToolBox *, void)
|
||||
IMPL_LINK_NOARG(ScInputBarGroup, ClickHdl, weld::Button&, void)
|
||||
{
|
||||
if (mxTextWndGroup->GetNumLines() > 1)
|
||||
{
|
||||
mxTextWndGroup->SetNumLines(1);
|
||||
mxButtonUp->hide();
|
||||
mxButtonDown->show();
|
||||
else
|
||||
mxTextWndGroup->SetNumLines(mxTextWndGroup->GetLastNumExpandedLines());
|
||||
|
||||
NumLinesChanged();
|
||||
}
|
||||
|
||||
void ScInputBarGroup::NumLinesChanged()
|
||||
{
|
||||
if (mxTextWndGroup->GetNumLines() > 1)
|
||||
{
|
||||
mxButtonDown->hide();
|
||||
mxButtonUp->show();
|
||||
mxTextWndGroup->SetLastNumExpandedLines(mxTextWndGroup->GetNumLines());
|
||||
}
|
||||
else
|
||||
{
|
||||
mxTextWndGroup->SetNumLines(mxTextWndGroup->GetLastNumExpandedLines());
|
||||
mxButtonDown->hide();
|
||||
mxButtonUp->show();
|
||||
mxButtonUp->hide();
|
||||
mxButtonDown->show();
|
||||
}
|
||||
TriggerToolboxLayout();
|
||||
|
||||
@@ -1165,6 +1180,11 @@ tools::Long ScTextWndGroup::GetLastNumExpandedLines() const
|
||||
return mxTextWnd->GetLastNumExpandedLines();
|
||||
}
|
||||
|
||||
void ScTextWndGroup::SetLastNumExpandedLines(tools::Long nLastExpandedLines)
|
||||
{
|
||||
mxTextWnd->SetLastNumExpandedLines(nLastExpandedLines);
|
||||
}
|
||||
|
||||
tools::Long ScTextWndGroup::GetNumLines() const
|
||||
{
|
||||
return mxTextWnd->GetNumLines();
|
||||
@@ -1301,9 +1321,17 @@ int ScTextWnd::GetPixelHeightForLines(tools::Long nLines)
|
||||
return rDevice.LogicToPixel(Size(0, nLines * rDevice.GetTextHeight())).Height() + 1;
|
||||
}
|
||||
|
||||
tools::Long ScTextWnd::GetNumLines() const
|
||||
{
|
||||
ScViewData& rViewData = mpViewShell->GetViewData();
|
||||
return rViewData.GetFormulaBarLines();
|
||||
}
|
||||
|
||||
void ScTextWnd::SetNumLines(tools::Long nLines)
|
||||
{
|
||||
mnLines = nLines;
|
||||
ScViewData& rViewData = mpViewShell->GetViewData();
|
||||
rViewData.SetFormulaBarLines(nLines);
|
||||
|
||||
if ( nLines > 1 )
|
||||
{
|
||||
mnLastExpandedLines = nLines;
|
||||
@@ -1567,7 +1595,6 @@ ScTextWnd::ScTextWnd(ScTextWndGroup& rParent, ScTabViewShell* pViewSh) :
|
||||
bInputMode (false),
|
||||
mpViewShell(pViewSh),
|
||||
mrGroupBar(rParent),
|
||||
mnLines(1),
|
||||
mnLastExpandedLines(INPUTWIN_MULTILINES),
|
||||
mbInvalidate(false)
|
||||
{
|
||||
@@ -1931,7 +1958,7 @@ void ScTextWnd::SetTextString( const OUString& rNewString )
|
||||
// Find position of the change, only paint the rest
|
||||
if (!m_xEditEngine)
|
||||
{
|
||||
bool bPaintAll = mnLines > 1 || bIsRTL;
|
||||
bool bPaintAll = GetNumLines() > 1 || bIsRTL;
|
||||
if (!bPaintAll)
|
||||
{
|
||||
// test if CTL script type is involved
|
||||
|
@@ -104,9 +104,10 @@ public:
|
||||
int GetPixelHeightForLines(tools::Long nLines);
|
||||
int GetEditEngTxtHeight() const;
|
||||
|
||||
virtual tools::Long GetNumLines() const override { return mnLines; }
|
||||
virtual tools::Long GetNumLines() const override;
|
||||
void SetNumLines(tools::Long nLines);
|
||||
tools::Long GetLastNumExpandedLines() const { return mnLastExpandedLines; }
|
||||
void SetLastNumExpandedLines(tools::Long nLastExpandedLines) { mnLastExpandedLines = nLastExpandedLines; }
|
||||
|
||||
void DoScroll();
|
||||
|
||||
@@ -153,7 +154,6 @@ private:
|
||||
|
||||
ScTabViewShell* mpViewShell;
|
||||
ScTextWndGroup& mrGroupBar;
|
||||
tools::Long mnLines;
|
||||
tools::Long mnLastExpandedLines;
|
||||
bool mbInvalidate;
|
||||
};
|
||||
@@ -209,6 +209,7 @@ public:
|
||||
const OutputDevice& GetEditViewDevice() const;
|
||||
Point GetCursorScreenPixelPos(bool bBelowLine);
|
||||
tools::Long GetLastNumExpandedLines() const;
|
||||
void SetLastNumExpandedLines(tools::Long nLastExpandedLines);
|
||||
virtual tools::Long GetNumLines() const override;
|
||||
int GetPixelHeightForLines(tools::Long nLines);
|
||||
weld::ScrolledWindow& GetScrollWin();
|
||||
@@ -259,6 +260,7 @@ public:
|
||||
bool IsInputActive() override;
|
||||
void IncrementVerticalSize();
|
||||
void DecrementVerticalSize();
|
||||
void NumLinesChanged();
|
||||
virtual tools::Long GetNumLines() const override { return mxTextWndGroup->GetNumLines(); }
|
||||
tools::Long GetVertOffset() const { return mnVertOffset; }
|
||||
|
||||
@@ -300,6 +302,8 @@ public:
|
||||
void SetOkCancelMode();
|
||||
void SetSumAssignMode();
|
||||
void EnableButtons( bool bEnable );
|
||||
/// Update Input bar after the number of lines was changed externally
|
||||
void NumLinesChanged();
|
||||
|
||||
void StartFormula();
|
||||
void SetFormulaMode( bool bSet );
|
||||
|
@@ -329,6 +329,7 @@ private:
|
||||
bool bMoveArea:1;
|
||||
|
||||
bool bGrowing;
|
||||
sal_Int16 nFormulaBarLines; // Visible lines in the formula bar
|
||||
|
||||
tools::Long m_nLOKPageUpDownOffset;
|
||||
tools::Rectangle maLOKVisibleArea;///< The visible area in the LibreOfficeKit client.
|
||||
@@ -467,6 +468,15 @@ public:
|
||||
double GetPPTX() const { return nPPTX; }
|
||||
double GetPPTY() const { return nPPTY; }
|
||||
|
||||
void SetFormulaBarLines(sal_Int16 nLines)
|
||||
{
|
||||
// Formula bar must be between 1 and 25 lines (see SpreadsheetViewSettings.idl)
|
||||
nLines = std::max(nLines, static_cast<sal_Int16>(1));
|
||||
nLines = std::min(nLines, static_cast<sal_Int16>(25));
|
||||
nFormulaBarLines = nLines;
|
||||
}
|
||||
sal_Int16 GetFormulaBarLines() const { return nFormulaBarLines; };
|
||||
|
||||
ScMarkType GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab,
|
||||
SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const;
|
||||
ScMarkType GetSimpleArea( ScRange& rRange ) const;
|
||||
|
@@ -65,6 +65,8 @@
|
||||
#include <markdata.hxx>
|
||||
#include <scextopt.hxx>
|
||||
#include <preview.hxx>
|
||||
#include <inputhdl.hxx>
|
||||
#include <inputwin.hxx>
|
||||
#include <svx/sdrhittesthelper.hxx>
|
||||
#include <formatsh.hxx>
|
||||
#include <sfx2/app.hxx>
|
||||
@@ -107,6 +109,7 @@ static const SfxItemPropertyMapEntry* lcl_GetViewOptPropertyMap()
|
||||
{ SC_UNO_ZOOMTYPE, 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
|
||||
{ SC_UNO_ZOOMVALUE, 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
|
||||
{ SC_UNO_VISAREASCREEN,0, cppu::UnoType<awt::Rectangle>::get(), 0, 0},
|
||||
{ SC_UNO_FORMULABARHEIGHT,0,cppu::UnoType<sal_Int16>::get(), 0, 0},
|
||||
{ u"", 0, css::uno::Type(), 0, 0 }
|
||||
};
|
||||
return aViewOptPropertyMap_Impl;
|
||||
@@ -1793,6 +1796,22 @@ void SAL_CALL ScTabViewObj::setPropertyValue(
|
||||
if ( aValue >>= nIntVal )
|
||||
SetZoom(nIntVal);
|
||||
}
|
||||
else if ( aPropertyName == SC_UNO_FORMULABARHEIGHT )
|
||||
{
|
||||
sal_Int16 nIntVal = ScUnoHelpFunctions::GetInt16FromAny(aValue);
|
||||
if (nIntVal > 0)
|
||||
{
|
||||
rViewData.SetFormulaBarLines(nIntVal);
|
||||
// Notify formula bar about changed lines
|
||||
ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
|
||||
if (pInputHdl)
|
||||
{
|
||||
ScInputWindow* pInputWin = pInputHdl->GetInputWindow();
|
||||
if (pInputWin)
|
||||
pInputWin->NumLinesChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Options are set on the view and document (for new views),
|
||||
// so that they remain during saving.
|
||||
@@ -1832,7 +1851,8 @@ uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName
|
||||
ScTabViewShell* pViewSh = GetViewShell();
|
||||
if (pViewSh)
|
||||
{
|
||||
const ScViewOptions& rOpt = pViewSh->GetViewData().GetOptions();
|
||||
ScViewData& rViewData = pViewSh->GetViewData();
|
||||
const ScViewOptions& rOpt = rViewData.GetOptions();
|
||||
|
||||
if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
|
||||
aRet <<= rOpt.GetOption( VOPT_HEADER );
|
||||
@@ -1860,9 +1880,9 @@ uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName
|
||||
else if ( aPropertyName == SC_UNO_VISAREA ) aRet <<= GetVisArea();
|
||||
else if ( aPropertyName == SC_UNO_ZOOMTYPE ) aRet <<= GetZoomType();
|
||||
else if ( aPropertyName == SC_UNO_ZOOMVALUE ) aRet <<= GetZoom();
|
||||
else if ( aPropertyName == SC_UNO_FORMULABARHEIGHT ) aRet <<= rViewData.GetFormulaBarLines();
|
||||
else if ( aPropertyName == SC_UNO_VISAREASCREEN )
|
||||
{
|
||||
ScViewData& rViewData = pViewSh->GetViewData();
|
||||
vcl::Window* pActiveWin = rViewData.GetActiveWin();
|
||||
if ( pActiveWin )
|
||||
{
|
||||
|
@@ -53,6 +53,8 @@
|
||||
#include <miscuno.hxx>
|
||||
#include <unonames.hxx>
|
||||
#include <inputopt.hxx>
|
||||
#include <inputhdl.hxx>
|
||||
#include <inputwin.hxx>
|
||||
#include <viewutil.hxx>
|
||||
#include <markdata.hxx>
|
||||
#include <ViewSettingsSequenceDefines.hxx>
|
||||
@@ -814,6 +816,7 @@ ScViewData::ScViewData(ScDocument* pDoc, ScDocShell* pDocSh, ScTabViewShell* pVi
|
||||
bSelCtrlMouseClick( false ),
|
||||
bMoveArea ( false ),
|
||||
bGrowing (false),
|
||||
nFormulaBarLines(1),
|
||||
m_nLOKPageUpDownOffset( 0 )
|
||||
{
|
||||
assert(bool(pDoc) != bool(pDocSh)); // either one or the other, not both
|
||||
@@ -3764,6 +3767,8 @@ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSe
|
||||
pSettings[SC_OUTLSYMB].Value <<= maOptions.GetOption(VOPT_OUTLINER);
|
||||
pSettings[SC_VALUE_HIGHLIGHTING].Name = SC_UNO_VALUEHIGH;
|
||||
pSettings[SC_VALUE_HIGHLIGHTING].Value <<= maOptions.GetOption(VOPT_SYNTAX);
|
||||
pSettings[SC_FORMULA_BAR_HEIGHT_VALUE].Name = SC_FORMULABARHEIGHT;
|
||||
pSettings[SC_FORMULA_BAR_HEIGHT_VALUE].Value <<= GetFormulaBarLines();;
|
||||
|
||||
const ScGridOptions& aGridOpt = maOptions.GetGridOptions();
|
||||
pSettings[SC_SNAPTORASTER].Name = SC_UNO_SNAPTORASTER;
|
||||
@@ -3791,6 +3796,7 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>
|
||||
|
||||
sal_Int32 nTemp32(0);
|
||||
sal_Int16 nTemp16(0);
|
||||
sal_Int16 nFormulaBarLineCount(0);
|
||||
bool bPageMode(false);
|
||||
|
||||
EnsureTabDataSize(GetDocument().GetTableCount());
|
||||
@@ -3868,6 +3874,21 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>
|
||||
aDefPageZoomX = aDefPageZoomY = aZoom;
|
||||
}
|
||||
}
|
||||
else if (sName == SC_FORMULABARHEIGHT)
|
||||
{
|
||||
if (rSetting.Value >>= nFormulaBarLineCount)
|
||||
{
|
||||
SetFormulaBarLines(nFormulaBarLineCount);
|
||||
// Notify formula bar about changed lines
|
||||
ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
|
||||
if (pInputHdl)
|
||||
{
|
||||
ScInputWindow* pInputWin = pInputHdl->GetInputWindow();
|
||||
if (pInputWin)
|
||||
pInputWin->NumLinesChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sName == SC_SHOWPAGEBREAKPREVIEW)
|
||||
bPageMode = ScUnoHelpFunctions::GetBoolFromAny( rSetting.Value );
|
||||
else if ( sName == SC_UNO_SHOWZERO )
|
||||
|
@@ -235,6 +235,16 @@ void SpreadsheetViewSettings::testSpreadsheetViewSettingsProperties()
|
||||
xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
|
||||
CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomValue);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ZoomValue", sal_Int16(1), aZoomValue);
|
||||
|
||||
propName = "FormulaBarHeight";
|
||||
sal_Int16 aFormulaBarHeight;
|
||||
CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aFormulaBarHeight);
|
||||
|
||||
aNewValue <<= sal_Int16(15);
|
||||
xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
|
||||
CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aFormulaBarHeight);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue FormulaBarHeight", sal_Int16(15),
|
||||
aFormulaBarHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user