forked from amazingfate/loongoffice
...where the get member function is defined on a std::__shared_ptr base class, so loplugin:simplifypointertobool used to miss those until now. (While e.g. using libc++ on macOS found those cases.) 366d08f2f6d4de922f6099c62bb81b49d89e0a68 "new loplugin:simplifypointertobool" was mistaken in breaking isSmartPointerType(const clang::Type* t) out of isSmartPointerType(const Expr* e); c874294ad9fb178df47c66875bfbdec466e39763 "Fix detection of std::unique_ptr/shared_ptr in loplugin:redundantpointerops" had introduced that indivisible two-step algorithm on purpose. The amount of additional hits (on Linux) apparently asked for turning loplugin:simplifypointertobool into a rewriting plugin. Which in turn showed that the naive adivce to just "drop the get()" is not sufficient in places that are not contextually converted to bool, as those places need to be wrapped in a bool(...) functional cast now. If the expression was already wrapped in parentheses, those could be reused as part of the functional cast, but implementing that showed that such cases are not yet found at all by the existing loplugin:simplifypointertobool. Lets leave that TODO for another commit. Besides the changes to compilerplugins/ itself, this change has been generated fully automatically with the rewriting plugin on Linux. Change-Id: I83107d6f634fc9ac232986f49044d7017df83e2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94888 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
164 lines
4.7 KiB
C++
164 lines
4.7 KiB
C++
/* -*- 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 .
|
|
*/
|
|
|
|
#include <ColumnControlWindow.hxx>
|
|
#include <unotools/syslocale.hxx>
|
|
#include <i18nlangtag/languagetag.hxx>
|
|
#include <connectivity/dbtools.hxx>
|
|
#include <UITools.hxx>
|
|
#include <core_resource.hxx>
|
|
#include <strings.hrc>
|
|
#include <com/sun/star/util/NumberFormatter.hpp>
|
|
|
|
using namespace ::dbaui;
|
|
using namespace ::com::sun::star::uno;
|
|
using namespace ::com::sun::star::beans;
|
|
using namespace ::com::sun::star::container;
|
|
using namespace ::com::sun::star::util;
|
|
using namespace ::com::sun::star::sdbc;
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
// OColumnControlWindow
|
|
OColumnControlWindow::OColumnControlWindow(vcl::Window* pParent
|
|
,const Reference<XComponentContext>& _rxContext)
|
|
: OFieldDescControl(nullptr, pParent, nullptr)
|
|
, m_xContext(_rxContext)
|
|
, m_sTypeNames(DBA_RES(STR_TABLEDESIGN_DBFIELDTYPES))
|
|
, m_bAutoIncrementEnabled(true)
|
|
{
|
|
m_aLocale = SvtSysLocale().GetLanguageTag().getLocale();
|
|
}
|
|
|
|
void OColumnControlWindow::ActivateAggregate( EControlType eType )
|
|
{
|
|
switch(eType )
|
|
{
|
|
case tpFormat:
|
|
case tpDefault:
|
|
case tpColumnName:
|
|
break;
|
|
default:
|
|
OFieldDescControl::ActivateAggregate( eType );
|
|
}
|
|
}
|
|
|
|
void OColumnControlWindow::DeactivateAggregate( EControlType eType )
|
|
{
|
|
switch(eType )
|
|
{
|
|
case tpFormat:
|
|
case tpDefault:
|
|
case tpColumnName:
|
|
break;
|
|
default:
|
|
OFieldDescControl::DeactivateAggregate( eType );
|
|
}
|
|
}
|
|
|
|
void OColumnControlWindow::CellModified(long /*nRow*/, sal_uInt16 /*nColId*/ )
|
|
{
|
|
saveCurrentFieldDescData();
|
|
}
|
|
|
|
css::lang::Locale OColumnControlWindow::GetLocale() const
|
|
{
|
|
return m_aLocale;
|
|
}
|
|
|
|
Reference< XNumberFormatter > OColumnControlWindow::GetFormatter() const
|
|
{
|
|
if ( !m_xFormatter.is() )
|
|
try
|
|
{
|
|
Reference< XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(m_xConnection, true, m_xContext));
|
|
|
|
if ( xSupplier.is() )
|
|
{
|
|
// create a new formatter
|
|
m_xFormatter.set( NumberFormatter::create(m_xContext), UNO_QUERY_THROW);
|
|
m_xFormatter->attachNumberFormatsSupplier(xSupplier);
|
|
}
|
|
}
|
|
catch(Exception&)
|
|
{
|
|
}
|
|
return m_xFormatter;
|
|
}
|
|
|
|
TOTypeInfoSP OColumnControlWindow::getTypeInfo(sal_Int32 _nPos)
|
|
{
|
|
return ( _nPos >= 0 && _nPos < static_cast<sal_Int32>(m_aDestTypeInfoIndex.size())) ? m_aDestTypeInfoIndex[_nPos]->second : TOTypeInfoSP();
|
|
}
|
|
|
|
const OTypeInfoMap* OColumnControlWindow::getTypeInfo() const
|
|
{
|
|
return &m_aDestTypeInfo;
|
|
}
|
|
|
|
Reference< XDatabaseMetaData> OColumnControlWindow::getMetaData()
|
|
{
|
|
if ( m_xConnection.is() )
|
|
return m_xConnection->getMetaData();
|
|
return Reference< XDatabaseMetaData>();
|
|
}
|
|
|
|
Reference< XConnection> OColumnControlWindow::getConnection()
|
|
{
|
|
return m_xConnection;
|
|
}
|
|
|
|
void OColumnControlWindow::setConnection(const Reference< XConnection>& _xCon)
|
|
{
|
|
m_xConnection = _xCon;
|
|
m_xFormatter = nullptr;
|
|
m_aDestTypeInfoIndex.clear();
|
|
m_aDestTypeInfo.clear();
|
|
|
|
if ( m_xConnection.is() )
|
|
{
|
|
Init();
|
|
|
|
::dbaui::fillTypeInfo(m_xConnection,m_sTypeNames,m_aDestTypeInfo,m_aDestTypeInfoIndex);
|
|
// read autoincrement value set in the datasource
|
|
::dbaui::fillAutoIncrementValue(m_xConnection,m_bAutoIncrementEnabled,m_sAutoIncrementValue);
|
|
}
|
|
}
|
|
|
|
bool OColumnControlWindow::isAutoIncrementValueEnabled() const
|
|
{
|
|
return m_bAutoIncrementEnabled;
|
|
}
|
|
|
|
OUString OColumnControlWindow::getAutoIncrementValue() const
|
|
{
|
|
return m_sAutoIncrementValue;
|
|
}
|
|
|
|
TOTypeInfoSP const & OColumnControlWindow::getDefaultTyp() const
|
|
{
|
|
if ( !m_pTypeInfo )
|
|
{
|
|
m_pTypeInfo = std::make_shared<OTypeInfo>();
|
|
m_pTypeInfo->aUIName = m_sTypeNames.getToken(TYPE_OTHER, ';');
|
|
}
|
|
return m_pTypeInfo;
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|