improve function-local statics in basic..cui

Change-Id: If737e8478f6f1c8fffb060ce132d80e0f07ef8ee
Reviewed-on: https://gerrit.libreoffice.org/63701
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2018-11-21 11:46:43 +02:00
parent e41667762b
commit 48314f2524
19 changed files with 113 additions and 148 deletions

View File

@ -34,9 +34,7 @@ bool BasicCharClass::isLetter( sal_Unicode c )
bool BasicCharClass::isLetterUnicode( sal_Unicode c )
{
static CharClass* pCharClass = nullptr;
if( pCharClass == nullptr )
pCharClass = new CharClass( Application::GetSettings().GetLanguageTag() );
static CharClass* pCharClass = new CharClass( Application::GetSettings().GetLanguageTag() );
// can we get pCharClass to accept a sal_Unicode instead of this waste?
return pCharClass->isLetter( OUString(c), 0 );
}

View File

@ -129,14 +129,7 @@ static long GetDayDiff( const Date& rDate );
static const CharClass& GetCharClass()
{
static bool bNeedsInit = true;
static LanguageTag aLanguageTag( LANGUAGE_SYSTEM);
if( bNeedsInit )
{
bNeedsInit = false;
aLanguageTag = Application::GetSettings().GetLanguageTag();
}
static CharClass aCharClass( aLanguageTag );
static CharClass aCharClass( Application::GetSettings().GetLanguageTag() );
return aCharClass;
}
@ -169,11 +162,7 @@ OUString getFullPath( const OUString& aRelPath )
// TODO: -> SbiGlobals
static uno::Reference< ucb::XSimpleFileAccess3 > const & getFileAccess()
{
static uno::Reference< ucb::XSimpleFileAccess3 > xSFI;
if( !xSFI.is() )
{
xSFI = ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() );
}
static uno::Reference< ucb::XSimpleFileAccess3 > xSFI = ucb::SimpleFileAccess::create( comphelper::getProcessComponentContext() );
return xSFI;
}

View File

@ -70,13 +70,7 @@ using namespace com::sun::star::uno;
static Reference< XCalendar4 > const & getLocaleCalendar()
{
static Reference< XCalendar4 > xCalendar;
if( !xCalendar.is() )
{
Reference< XComponentContext > xContext = getProcessComponentContext();
xCalendar = LocaleCalendar2::create(xContext);
}
static Reference< XCalendar4 > xCalendar = LocaleCalendar2::create(getProcessComponentContext());
static css::lang::Locale aLastLocale;
static bool bNeedsInit = true;

View File

@ -1337,14 +1337,12 @@ void SbiRuntime::StepCompare( SbxOperator eOp )
// I dumbly follow the pattern :-/
if ( bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) )
{
static SbxVariable* pNULL = nullptr;
if( !pNULL )
{
pNULL = new SbxVariable;
pNULL->PutNull();
pNULL->AddFirstRef();
}
static SbxVariable* pNULL = [&]() {
SbxVariable* p = new SbxVariable;
p->PutNull();
p->AddFirstRef();
return p;
}();
PushVar( pNULL );
}
else if( p2->Compare( eOp, *p1 ) )

View File

@ -2044,29 +2044,25 @@ namespace comphelper
const std::vector< OUString >& BackupFileHelper::getCustomizationDirNames()
{
static std::vector< OUString > aDirNames;
if (aDirNames.empty())
static std::vector< OUString > aDirNames =
{
aDirNames.emplace_back("config"); // UI config stuff
aDirNames.emplace_back("registry"); // most of the registry stuff
aDirNames.emplace_back("psprint"); // not really needed, can be abandoned
aDirNames.emplace_back("store"); // not really needed, can be abandoned
aDirNames.emplace_back("temp"); // not really needed, can be abandoned
aDirNames.emplace_back("pack"); // own backup dir
}
"config", // UI config stuff
"registry", // most of the registry stuff
"psprint", // not really needed, can be abandoned
"store", // not really needed, can be abandoned
"temp", // not really needed, can be abandoned
"pack" // own backup dir
};
return aDirNames;
}
const std::vector< OUString >& BackupFileHelper::getCustomizationFileNames()
{
static std::vector< OUString > aFileNames;
if (aFileNames.empty())
static std::vector< OUString > aFileNames =
{
aFileNames.emplace_back("registrymodifications.xcu"); // personal registry stuff
}
"registrymodifications.xcu" // personal registry stuff
};
return aFileNames;
}

View File

@ -109,8 +109,7 @@ ThreadPool& ThreadPool::getSharedOptimalPool()
sal_Int32 ThreadPool::getPreferredConcurrency()
{
static sal_Int32 ThreadCount = 0;
if (ThreadCount == 0)
static sal_Int32 ThreadCount = [&]()
{
const sal_Int32 nHardThreads = std::max(std::thread::hardware_concurrency(), 1U);
sal_Int32 nThreads = nHardThreads;
@ -122,8 +121,8 @@ sal_Int32 ThreadPool::getPreferredConcurrency()
}
nThreads = std::min(nHardThreads, nThreads);
ThreadCount = std::max<sal_Int32>(nThreads, 1);
}
return std::max<sal_Int32>(nThreads, 1);
}();
return ThreadCount;
}

View File

@ -27,9 +27,7 @@ namespace configmgr {
std::shared_ptr<osl::Mutex> const & lock()
{
static std::shared_ptr<osl::Mutex> theLock;
if (!theLock.get())
theLock.reset(new osl::Mutex);
static std::shared_ptr<osl::Mutex> theLock(new osl::Mutex);
return theLock;
}

View File

@ -173,9 +173,7 @@ bool EApiInit()
ESourceRegistry *get_e_source_registry()
{
static ESourceRegistry *theInstance;
if (!theInstance)
theInstance = e_source_registry_new_sync(nullptr, nullptr);
static ESourceRegistry *theInstance = e_source_registry_new_sync(nullptr, nullptr);
return theInstance;
}

View File

@ -1017,10 +1017,9 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( )
ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
Reference< XResultSet > xResultSet = pResultSet;
static ODatabaseMetaDataResultSet::ORows aRows;
if(aRows.empty())
static ODatabaseMetaDataResultSet::ORows aRows = []()
{
ODatabaseMetaDataResultSet::ORows tmp;
ODatabaseMetaDataResultSet::ORow aRow;
aRow.reserve(19);
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
@ -1044,13 +1043,14 @@ Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( )
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
aRow.push_back(new ORowSetValueDecorator(sal_Int32(10)));
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("VARCHAR"));
aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR);
aRow[3] = new ORowSetValueDecorator(sal_Int32(65535));
aRows.push_back(aRow);
}
tmp.push_back(aRow);
return tmp;
}();
pResultSet->setRows(aRows);
return xResultSet;
}

View File

@ -805,10 +805,9 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
ODatabaseMetaDataResultSet* pResultSet =
new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
uno::Reference< XResultSet > xResultSet = pResultSet;
static ODatabaseMetaDataResultSet::ORows aResults;
if(aResults.empty())
static ODatabaseMetaDataResultSet::ORows aResults = [&]()
{
ODatabaseMetaDataResultSet::ORows tmp;
ODatabaseMetaDataResultSet::ORow aRow(19);
// Common data
@ -838,7 +837,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[12] = new ORowSetValueDecorator(false); // Autoincrement
aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// Varchar
aRow[1] = new ORowSetValueDecorator(OUString("VARCHAR"));
@ -850,7 +849,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[12] = new ORowSetValueDecorator(false); // Autoincrement
aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// Binary (CHAR)
// It is distinguished from Text type by its character set
@ -862,7 +861,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
sal_Int16(ColumnSearch::NONE)); // Searchable
aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// Varbinary (VARCHAR)
aRow[1] = new ORowSetValueDecorator(OUString("VARCHAR"));
@ -882,12 +881,12 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[12] = new ORowSetValueDecorator(false); // Autoincrement
aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// Longvarbinary (SQL_BLOB)
// Distinguished from simple blob with a user-defined subtype.
aRow[2] = new ORowSetValueDecorator(DataType::LONGVARBINARY);
aResults.push_back(aRow);
tmp.push_back(aRow);
// Integer Types common
{
@ -902,17 +901,17 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[1] = new ORowSetValueDecorator(OUString("SMALLINT"));
aRow[2] = new ORowSetValueDecorator(DataType::SMALLINT);
aRow[3] = new ORowSetValueDecorator(sal_Int16(5)); // Prevision
aResults.push_back(aRow);
tmp.push_back(aRow);
// Integer (SQL_LONG)
aRow[1] = new ORowSetValueDecorator(OUString("INTEGER"));
aRow[2] = new ORowSetValueDecorator(DataType::INTEGER);
aRow[3] = new ORowSetValueDecorator(sal_Int16(10)); // Precision
aResults.push_back(aRow);
tmp.push_back(aRow);
// Bigint (SQL_INT64)
aRow[1] = new ORowSetValueDecorator(OUString("BIGINT"));
aRow[2] = new ORowSetValueDecorator(DataType::BIGINT);
aRow[3] = new ORowSetValueDecorator(sal_Int16(20)); // Precision
aResults.push_back(aRow);
tmp.push_back(aRow);
// Decimal Types common
{
@ -928,14 +927,14 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[3] = new ORowSetValueDecorator(sal_Int16(15)); // Precision
aRow[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
aRow[15] = new ORowSetValueDecorator(sal_Int16(15)); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// Decimal
aRow[1] = new ORowSetValueDecorator(OUString("DECIMAL"));
aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
aRow[3] = new ORowSetValueDecorator(sal_Int16(15)); // Precision
aRow[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
aRow[15] = new ORowSetValueDecorator(sal_Int16(15)); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
aRow[6] = new ORowSetValueDecorator(); // Create Params
// Float (SQL_FLOAT)
@ -944,14 +943,14 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[3] = new ORowSetValueDecorator(sal_Int16(7)); // Precision
aRow[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
aRow[15] = new ORowSetValueDecorator(sal_Int16(7)); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// Double (SQL_DOUBLE)
aRow[1] = new ORowSetValueDecorator(OUString("DOUBLE PRECISION"));
aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE);
aRow[3] = new ORowSetValueDecorator(sal_Int16(15)); // Precision
aRow[14] = new ORowSetValueDecorator(sal_Int16(1)); // Minimum scale
aRow[15] = new ORowSetValueDecorator(sal_Int16(15)); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// TODO: no idea whether D_FLOAT corresponds to an sql type
@ -965,7 +964,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[12] = new ORowSetValueDecorator(false); // Autoincrement
aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// SQL_TYPE_TIME
aRow[1] = new ORowSetValueDecorator(OUString("TIME"));
@ -989,7 +988,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[12] = new ORowSetValueDecorator(false); // Autoincrement
aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// SQL_BLOB
aRow[1] = new ORowSetValueDecorator(OUString("BLOB"));
@ -1001,7 +1000,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[12] = new ORowSetValueDecorator(false); // Autoincrement
aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
aResults.push_back(aRow);
tmp.push_back(aRow);
// SQL_BOOLEAN
aRow[1] = new ORowSetValueDecorator(OUString("BOOLEAN"));
@ -1013,9 +1012,9 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
aRow[12] = new ORowSetValueDecorator(false); // Autoincrement
aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
aResults.push_back(aRow);
}
tmp.push_back(aRow);
return tmp;
}();
pResultSet->setRows(aResults);
return xResultSet;
}

View File

@ -55,9 +55,9 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( )
::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
Reference< XResultSet > xRef = pResult;
static ODatabaseMetaDataResultSet::ORows aRows;
if(aRows.empty())
static ODatabaseMetaDataResultSet::ORows aRows = [&]()
{
ODatabaseMetaDataResultSet::ORows tmp;
ODatabaseMetaDataResultSet::ORow aRow;
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
@ -80,13 +80,13 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( )
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
aRow.push_back(new ORowSetValueDecorator(sal_Int32(10)));
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("VARCHAR"));
aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR);
aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("LONGVARCHAR"));
@ -94,53 +94,55 @@ Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( )
aRow[3] = new ORowSetValueDecorator(sal_Int32(65535));
aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("DATE"));
aRow[2] = new ORowSetValueDecorator(DataType::DATE);
aRow[3] = new ORowSetValueDecorator(sal_Int32(10));
aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("TIME"));
aRow[2] = new ORowSetValueDecorator(DataType::TIME);
aRow[3] = new ORowSetValueDecorator(sal_Int32(8));
aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
aRow[3] = new ORowSetValueDecorator(sal_Int32(19));
aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("BOOL"));
aRow[2] = new ORowSetValueDecorator(DataType::BIT);
aRow[3] = ODatabaseMetaDataResultSet::get1Value();
aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("DECIMAL"));
aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
aRow[3] = new ORowSetValueDecorator(sal_Int32(20));
aRow[15] = new ORowSetValueDecorator(sal_Int32(15));
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("DOUBLE"));
aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE);
aRow[3] = new ORowSetValueDecorator(sal_Int32(20));
aRow[15] = ODatabaseMetaDataResultSet::get0Value();
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("NUMERIC"));
aRow[2] = new ORowSetValueDecorator(DataType::NUMERIC);
aRow[3] = new ORowSetValueDecorator(sal_Int32(20));
aRow[15] = new ORowSetValueDecorator(sal_Int32(20));
aRows.push_back(aRow);
}
tmp.push_back(aRow);
return tmp;
}();
pResult->setRows(aRows);
return xRef;

View File

@ -353,14 +353,14 @@ namespace connectivity
xComp->addEventListener(this);
// we want to close all connections when the office shuts down
static Reference< XTerminateListener> s_xTerminateListener;
if( !s_xTerminateListener.is() )
static Reference< XTerminateListener> s_xTerminateListener = [&]()
{
Reference< XDesktop2 > xDesktop = Desktop::create( m_xContext );
s_xTerminateListener = new OConnectionController(this);
xDesktop->addTerminateListener(s_xTerminateListener);
}
auto tmp = new OConnectionController(this);
xDesktop->addTerminateListener(tmp);
return tmp;
}();
Reference< XComponent> xIfc = new OHsqlConnection( this, xOrig, m_xContext );
xConnection.set(xIfc,UNO_QUERY);
m_aConnections.push_back(TWeakPair(WeakReferenceHelper(xOrig),TWeakConnectionPair(sKey,TWeakRefPair(WeakReferenceHelper(xConnection),WeakReferenceHelper()))));

View File

@ -327,12 +327,11 @@ void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/)
// convert Parameter
jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,m_sSqlStatement));
static jmethodID mID(nullptr);
if ( !mID )
static jmethodID mID = [&]()
{
static const char * const cSignature = "(Ljava/lang/String;II)Ljava/sql/CallableStatement;";
mID = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
}
return t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
}();
if( mID ){
out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str.get() ,m_nResultSetType,m_nResultSetConcurrency);
} //mID

View File

@ -736,16 +736,16 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTableTypes( )
::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
Reference< XResultSet > xRef = pResult;
static ODatabaseMetaDataResultSet::ORows aRows;
static const char aTable[] = "TABLE";
if (aRows.empty())
static ODatabaseMetaDataResultSet::ORows aRows = [&]
{
static const char aTable[] = "TABLE";
ODatabaseMetaDataResultSet::ORows tmp;
ODatabaseMetaDataResultSet::ORow aRow(2);
aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
aRow[1] = new ORowSetValueDecorator(OUString(aTable));
aRows.push_back(aRow);
}
tmp.push_back(aRow);
return tmp;
}();
pResult->setRows(aRows);
return xRef;
}
@ -755,9 +755,9 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTypeInfo( )
ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
Reference< XResultSet > xRef = pResult;
static ODatabaseMetaDataResultSet::ORows aRows;
if (aRows.empty())
static ODatabaseMetaDataResultSet::ORows aRows = [&]()
{
ODatabaseMetaDataResultSet::ORows tmp;
ODatabaseMetaDataResultSet::ORow aRow(19);
// We support four types: char, timestamp, integer, float
@ -781,27 +781,29 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTypeInfo( )
aRow[17] = ODatabaseMetaDataResultSet::getEmptyValue();
aRow[18] = new ORowSetValueDecorator(sal_Int32(10));
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("TIMESTAMP"));
aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
aRow[3] = new ORowSetValueDecorator(sal_Int32(19));
aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("INTEGER"));
aRow[2] = new ORowSetValueDecorator(DataType::INTEGER);
aRow[3] = new ORowSetValueDecorator(sal_Int32(20));
aRow[15] = new ORowSetValueDecorator(sal_Int32(20));
aRows.push_back(aRow);
tmp.push_back(aRow);
aRow[1] = new ORowSetValueDecorator(OUString("FLOAT"));
aRow[2] = new ORowSetValueDecorator(DataType::FLOAT);
aRow[3] = new ORowSetValueDecorator(sal_Int32(20));
aRow[15] = new ORowSetValueDecorator(sal_Int32(15));
aRows.push_back(aRow);
}
tmp.push_back(aRow);
return tmp;
}();
pResult->setRows(aRows);
return xRef;
}
@ -943,10 +945,9 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables(
if (!bTableFound)
return xRef;
static ODatabaseMetaDataResultSet::ORows aRows;
if (aRows.empty())
static ODatabaseMetaDataResultSet::ORows aRows = [&]()
{
ODatabaseMetaDataResultSet::ORows tmp;
ODatabaseMetaDataResultSet::ORow aRow(6);
MacabRecords *xRecords = m_xConnection->getAddressBook()->getMacabRecords();
@ -960,14 +961,15 @@ Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables(
aRow[3] = new ORowSetValueDecorator(xRecords->getName());
aRow[4] = new ORowSetValueDecorator(OUString(aTable));
aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue();
aRows.push_back(aRow);
tmp.push_back(aRow);
for(i = 0; i < nGroups; i++)
{
aRow[3] = new ORowSetValueDecorator(xGroups[i]->getName());
aRows.push_back(aRow);
tmp.push_back(aRow);
}
}
return tmp;
}();
pResult->setRows(aRows);
return xRef;
}

View File

@ -839,10 +839,9 @@ Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
// in special the metadata of the resultset already returns the right columns
ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
Reference< XResultSet > xResultSet = pResultSet;
static ODatabaseMetaDataResultSet::ORows aRows;
if(aRows.empty())
static ODatabaseMetaDataResultSet::ORows aRows = [&]()
{
ODatabaseMetaDataResultSet::ORows tmp;
ODatabaseMetaDataResultSet::ORow aRow;
aRow.reserve(19);
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
@ -866,9 +865,9 @@ Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
aRow.push_back(new ORowSetValueDecorator(sal_Int32(10)));
aRows.push_back(aRow);
}
tmp.push_back(aRow);
return tmp;
}();
pResultSet->setRows(aRows);
return xResultSet;
}

View File

@ -111,8 +111,7 @@ static ::cppu::IPropertyArrayHelper & getResultSetPropertyArrayHelper()
"ResultSetType", 6,
::cppu::UnoType<sal_Int32>::get() , 0 )},
true );
static ::cppu::IPropertyArrayHelper *pArrayHelper = &arrayHelper;
return *pArrayHelper;
return arrayHelper;
}
BaseResultSet::BaseResultSet(

View File

@ -138,9 +138,7 @@ static ::cppu::IPropertyArrayHelper & getStatementPropertyArrayHelper()
::cppu::UnoType<sal_Int32>::get() , 0 )},
true );
static ::cppu::IPropertyArrayHelper *pArrayHelper = &arrayHelper;
return *pArrayHelper;
return arrayHelper;
}
Statement::Statement( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,

View File

@ -40,9 +40,7 @@ namespace cppu
// this is used to lock all instances of OWeakConnectionPoint and OWeakRefListener as well as OWeakObject::m_pWeakConnectionPoint
static Mutex & getWeakMutex()
{
static Mutex * s_pMutex = nullptr;
if (! s_pMutex)
s_pMutex = new Mutex();
static Mutex * s_pMutex = new Mutex();
return *s_pMutex;
}

View File

@ -156,17 +156,16 @@ static bool lcl_IsNumFmtSet(SvxNumRule const * pNum, sal_uInt16 nLevelMask)
static const vcl::Font& lcl_GetDefaultBulletFont()
{
static bool bInit = false;
static vcl::Font aDefBulletFont("OpenSymbol", "", Size(0, 14));
if(!bInit)
static vcl::Font aDefBulletFont = [&]()
{
aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
aDefBulletFont.SetPitch( PITCH_DONTKNOW );
aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
aDefBulletFont.SetTransparent( true );
bInit = true;
}
vcl::Font tmp("OpenSymbol", "", Size(0, 14));
tmp.SetCharSet( RTL_TEXTENCODING_SYMBOL );
tmp.SetFamily( FAMILY_DONTKNOW );
tmp.SetPitch( PITCH_DONTKNOW );
tmp.SetWeight( WEIGHT_DONTKNOW );
tmp.SetTransparent( true );
return tmp;
}();
return aDefBulletFont;
}