/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
/* Position indexes for "Allow" list box. They do not map directly to ScValidationMode and can safely be modified to
change the order of the list box entries. */ #define SC_VALIDDLG_ALLOW_ANY 0 #define SC_VALIDDLG_ALLOW_WHOLE 1 #define SC_VALIDDLG_ALLOW_DECIMAL 2 #define SC_VALIDDLG_ALLOW_DATE 3 #define SC_VALIDDLG_ALLOW_TIME 4 #define SC_VALIDDLG_ALLOW_RANGE 5 #define SC_VALIDDLG_ALLOW_LIST 6 #define SC_VALIDDLG_ALLOW_TEXTLEN 7 #define SC_VALIDDLG_ALLOW_CUSTOM 8
/* Position indexes for "Data" list box. They do not map directly to ScConditionMode and can safely be modified to
change the order of the list box entries. */ #define SC_VALIDDLG_DATA_EQUAL 0 #define SC_VALIDDLG_DATA_LESS 1 #define SC_VALIDDLG_DATA_GREATER 2 #define SC_VALIDDLG_DATA_EQLESS 3 #define SC_VALIDDLG_DATA_EQGREATER 4 #define SC_VALIDDLG_DATA_NOTEQUAL 5 #define SC_VALIDDLG_DATA_VALIDRANGE 6 #define SC_VALIDDLG_DATA_INVALIDRANGE 7 #define SC_VALIDDLG_DATA_DIRECT 8
if (isLOKMobilePhone())
{
m_xBuilder->weld_button(u"cancel"_ustr)->hide();
m_xBuilder->weld_button(u"help"_ustr)->hide();
}
}
void ScValidationDlg::EndDialog(int nResponse)
{ // tdf#155708 - do not close, just hide validation window if we click in another sheet if (nResponse == nCloseResponseToJustHide && getDialog()->get_visible())
{
getDialog()->hide(); return;
} // tdf#137215 ensure original modality of true is restored before dialog loop ends if (m_bOwnRefHdlr)
RemoveRefDlg(true);
ScValidationDlgBase::EndDialog(nResponse);
}
ScValidationDlg::~ScValidationDlg()
{ if (m_bOwnRefHdlr)
RemoveRefDlg(false);
}
if (pNewParent != m_pBtnRefParent)
{ // if Edit SetParent but button not, the tab order will be // incorrect, so move button anyway, and restore // parent later in order to restore the tab order. But // hide it if it's moved but unwanted.
m_xRefGrid->move(m_xBtnRef->GetWidget(), pNewParent);
m_xBtnRef->GetWidget()->set_visible(pButton == m_xBtnRef.get());
m_pBtnRefParent = pNewParent;
}
pOldParent->hide();
ScViewData& rViewData = pValidationDlg->GetTabViewShell()->GetViewData();
SCTAB nCurTab = rViewData.GetTabNo();
SCTAB nRefTab = rViewData.GetRefTabNo(); // If RefInput switched to a different sheet from the data sheet, // switch back: fdo#53920 if ( nCurTab != nRefTab )
{
rViewData.GetViewShell()->SetTabNo( nRefTab );
}
}
if (m_pRefEdit && !m_pRefEdit->GetWidget()->has_focus())
m_pRefEdit->GrabFocus();
}
namespace {
/** Converts the passed ScValidationMode to the position in the list box. */
sal_uInt16 lclGetPosFromValMode( ScValidationMode eValMode )
{
sal_uInt16 nLbPos = SC_VALIDDLG_ALLOW_ANY; switch( eValMode )
{ case SC_VALID_ANY: nLbPos = SC_VALIDDLG_ALLOW_ANY; break; case SC_VALID_WHOLE: nLbPos = SC_VALIDDLG_ALLOW_WHOLE; break; case SC_VALID_DECIMAL: nLbPos = SC_VALIDDLG_ALLOW_DECIMAL; break; case SC_VALID_DATE: nLbPos = SC_VALIDDLG_ALLOW_DATE; break; case SC_VALID_TIME: nLbPos = SC_VALIDDLG_ALLOW_TIME; break; case SC_VALID_TEXTLEN: nLbPos = SC_VALIDDLG_ALLOW_TEXTLEN; break; case SC_VALID_LIST: nLbPos = SC_VALIDDLG_ALLOW_RANGE; break; case SC_VALID_CUSTOM: nLbPos = SC_VALIDDLG_ALLOW_CUSTOM; break; default: OSL_FAIL( "lclGetPosFromValMode - unknown validity mode" );
} return nLbPos;
}
/** Converts the passed list box position to an ScValidationMode. */
ScValidationMode lclGetValModeFromPos( sal_uInt16 nLbPos )
{
ScValidationMode eValMode = SC_VALID_ANY; switch( nLbPos )
{ case SC_VALIDDLG_ALLOW_ANY: eValMode = SC_VALID_ANY; break; case SC_VALIDDLG_ALLOW_WHOLE: eValMode = SC_VALID_WHOLE; break; case SC_VALIDDLG_ALLOW_DECIMAL: eValMode = SC_VALID_DECIMAL; break; case SC_VALIDDLG_ALLOW_DATE: eValMode = SC_VALID_DATE; break; case SC_VALIDDLG_ALLOW_TIME: eValMode = SC_VALID_TIME; break; case SC_VALIDDLG_ALLOW_RANGE: eValMode = SC_VALID_LIST; break; case SC_VALIDDLG_ALLOW_LIST: eValMode = SC_VALID_LIST; break; case SC_VALIDDLG_ALLOW_TEXTLEN: eValMode = SC_VALID_TEXTLEN; break; case SC_VALIDDLG_ALLOW_CUSTOM: eValMode = SC_VALID_CUSTOM; break; default: OSL_FAIL( "lclGetValModeFromPos - invalid list box position" );
} return eValMode;
}
/** Converts the passed ScConditionMode to the position in the list box. */
sal_uInt16 lclGetPosFromCondMode( ScConditionMode eCondMode )
{
sal_uInt16 nLbPos = SC_VALIDDLG_DATA_EQUAL; switch( eCondMode )
{ case ScConditionMode::NONE: // may occur in old XML files after Excel import case ScConditionMode::Equal: nLbPos = SC_VALIDDLG_DATA_EQUAL; break; case ScConditionMode::Less: nLbPos = SC_VALIDDLG_DATA_LESS; break; case ScConditionMode::Greater: nLbPos = SC_VALIDDLG_DATA_GREATER; break; case ScConditionMode::EqLess: nLbPos = SC_VALIDDLG_DATA_EQLESS; break; case ScConditionMode::EqGreater: nLbPos = SC_VALIDDLG_DATA_EQGREATER; break; case ScConditionMode::NotEqual: nLbPos = SC_VALIDDLG_DATA_NOTEQUAL; break; case ScConditionMode::Between: nLbPos = SC_VALIDDLG_DATA_VALIDRANGE; break; case ScConditionMode::NotBetween: nLbPos = SC_VALIDDLG_DATA_INVALIDRANGE; break; case ScConditionMode::Direct: nLbPos = SC_VALIDDLG_DATA_DIRECT; break; default: OSL_FAIL( "lclGetPosFromCondMode - unknown condition mode" );
} return nLbPos;
}
/** Converts the passed list box position to an ScConditionMode. */
ScConditionMode lclGetCondModeFromPos( sal_uInt16 nLbPos )
{
ScConditionMode eCondMode = ScConditionMode::Equal; switch( nLbPos )
{ case SC_VALIDDLG_DATA_EQUAL: eCondMode = ScConditionMode::Equal; break; case SC_VALIDDLG_DATA_LESS: eCondMode = ScConditionMode::Less; break; case SC_VALIDDLG_DATA_GREATER: eCondMode = ScConditionMode::Greater; break; case SC_VALIDDLG_DATA_EQLESS: eCondMode = ScConditionMode::EqLess; break; case SC_VALIDDLG_DATA_EQGREATER: eCondMode = ScConditionMode::EqGreater; break; case SC_VALIDDLG_DATA_NOTEQUAL: eCondMode = ScConditionMode::NotEqual; break; case SC_VALIDDLG_DATA_VALIDRANGE: eCondMode = ScConditionMode::Between; break; case SC_VALIDDLG_DATA_INVALIDRANGE: eCondMode = ScConditionMode::NotBetween; break; case SC_VALIDDLG_DATA_DIRECT: eCondMode = ScConditionMode::Direct; break; default: OSL_FAIL( "lclGetCondModeFromPos - invalid list box position" );
} return eCondMode;
}
/** Converts line feed separated string to a formula with strings separated by semicolons. @descr Keeps all empty strings. Example: abc\ndef\n\nghi -> "abc";"def";"";"ghi".
@param rFmlaStr (out-param) The converted formula string. */ void lclGetFormulaFromStringList( OUString& rFmlaStr, std::u16string_view rStringList, sal_Unicode cFmlaSep )
{
rFmlaStr.clear(); if (!rStringList.empty())
{
sal_Int32 nIdx {0}; do
{
OUString aToken {o3tl::getToken(rStringList, 0, '\n', nIdx )};
ScGlobal::AddQuotes( aToken, '"' );
rFmlaStr = ScGlobal::addToken(rFmlaStr, aToken, cFmlaSep);
} while (nIdx>0);
} if( rFmlaStr.isEmpty() )
rFmlaStr = "\"\"";
}
/** Converts formula with strings separated by semicolons to line feed separated string. @descr Keeps all empty strings. Ignores all empty tokens (multiple semicolons). Example: "abc";;;"def";"";"ghi" -> abc\ndef\n\nghi. @param rStringList (out-param) The converted line feed separated string list.
@return true = Conversion successful. */ bool lclGetStringListFromFormula( OUString& rStringList, const OUString& rFmlaStr, sal_Unicode cFmlaSep )
{ static constexpr OUStringLiteral aQuotes( u"\"\"" );
case SC_VALIDDLG_DATA_LESS: case SC_VALIDDLG_DATA_EQLESS: m_xFtMin->set_label( maStrMax ); break;
case SC_VALIDDLG_DATA_VALIDRANGE: case SC_VALIDDLG_DATA_INVALIDRANGE: bShowMax = true;
[[fallthrough]]; case SC_VALIDDLG_DATA_GREATER: case SC_VALIDDLG_DATA_EQGREATER: m_xFtMin->set_label( maStrMin ); break;
IMPL_LINK_NOARG(ScTPValidationError, ClickSearchHdl, weld::Button&, void)
{ // Use static SfxApplication method to bring up selector dialog for // choosing a script
OUString aScriptURL = SfxApplication::ChooseScript(GetFrameWeld());
if ( !aScriptURL.isEmpty() )
{
m_xEdtTitle->set_text( aScriptURL );
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.