From d3d9292a0fb414e6721b2f3b12b7e283caed946d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 19 Jul 2017 15:57:05 +0200 Subject: connectivity: merge OCalcColumns and OWriterColumns Turns out createObject() only needs the base class OFileTable, and then these can be shared. Change-Id: I6e8a83155dbbbc3d85794e190c2e710d01902017 Reviewed-on: https://gerrit.libreoffice.org/40183 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- connectivity/Library_calc.mk | 1 - connectivity/Library_file.mk | 1 + connectivity/Library_writer.mk | 1 - connectivity/source/drivers/calc/CColumns.cxx | 46 --------------------- connectivity/source/drivers/calc/CTable.cxx | 4 +- connectivity/source/drivers/component/CColumns.cxx | 45 ++++++++++++++++++++ connectivity/source/drivers/writer/WColumns.cxx | 48 ---------------------- connectivity/source/drivers/writer/WTable.cxx | 4 +- connectivity/source/inc/calc/CColumns.hxx | 46 --------------------- connectivity/source/inc/component/CColumns.hxx | 47 +++++++++++++++++++++ connectivity/source/inc/writer/WColumns.hxx | 46 --------------------- 11 files changed, 97 insertions(+), 192 deletions(-) delete mode 100644 connectivity/source/drivers/calc/CColumns.cxx create mode 100644 connectivity/source/drivers/component/CColumns.cxx delete mode 100644 connectivity/source/drivers/writer/WColumns.cxx delete mode 100644 connectivity/source/inc/calc/CColumns.hxx create mode 100644 connectivity/source/inc/component/CColumns.hxx delete mode 100644 connectivity/source/inc/writer/WColumns.hxx (limited to 'connectivity') diff --git a/connectivity/Library_calc.mk b/connectivity/Library_calc.mk index 30e16d29a3d2..5f734f8c2401 100644 --- a/connectivity/Library_calc.mk +++ b/connectivity/Library_calc.mk @@ -41,7 +41,6 @@ $(eval $(call gb_Library_use_libraries,calc,\ $(eval $(call gb_Library_add_exception_objects,calc,\ connectivity/source/drivers/calc/CDatabaseMetaData \ connectivity/source/drivers/calc/CCatalog \ - connectivity/source/drivers/calc/CColumns \ connectivity/source/drivers/calc/CTable \ connectivity/source/drivers/calc/CTables \ connectivity/source/drivers/calc/CConnection \ diff --git a/connectivity/Library_file.mk b/connectivity/Library_file.mk index 30cd6ae6a97a..9a36e1a21e2e 100644 --- a/connectivity/Library_file.mk +++ b/connectivity/Library_file.mk @@ -41,6 +41,7 @@ $(eval $(call gb_Library_use_libraries,file,\ )) $(eval $(call gb_Library_add_exception_objects,file,\ + connectivity/source/drivers/component/CColumns \ connectivity/source/drivers/component/CPreparedStatement \ connectivity/source/drivers/component/CResultSet \ connectivity/source/drivers/component/CStatement \ diff --git a/connectivity/Library_writer.mk b/connectivity/Library_writer.mk index 4fab8bf043d9..d07f572a3227 100644 --- a/connectivity/Library_writer.mk +++ b/connectivity/Library_writer.mk @@ -38,7 +38,6 @@ $(eval $(call gb_Library_use_libraries,writer,\ $(eval $(call gb_Library_add_exception_objects,writer,\ connectivity/source/drivers/writer/WCatalog \ - connectivity/source/drivers/writer/WColumns \ connectivity/source/drivers/writer/WConnection \ connectivity/source/drivers/writer/WDatabaseMetaData \ connectivity/source/drivers/writer/WDriver \ diff --git a/connectivity/source/drivers/calc/CColumns.cxx b/connectivity/source/drivers/calc/CColumns.cxx deleted file mode 100644 index 3cd002cd3681..000000000000 --- a/connectivity/source/drivers/calc/CColumns.cxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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 "calc/CColumns.hxx" -#include "calc/CTable.hxx" -#include - -using namespace connectivity::calc; -using namespace connectivity; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::container; - - -sdbcx::ObjectType OCalcColumns::createObject(const OUString& _rName) -{ - OCalcTable* pTable = static_cast(m_pTable); - ::rtl::Reference aCols = pTable->getTableColumns(); - - OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive())); - sdbcx::ObjectType xRet; - if(aIter != aCols->get().end()) - xRet = sdbcx::ObjectType(*aIter,UNO_QUERY); - return xRet; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index f1d7d7f17b7c..73c73c1327bd 100644 --- a/connectivity/source/drivers/calc/CTable.cxx +++ b/connectivity/source/drivers/calc/CTable.cxx @@ -36,7 +36,7 @@ #include #include #include "calc/CConnection.hxx" -#include "calc/CColumns.hxx" +#include "component/CColumns.hxx" #include #include #include @@ -622,7 +622,7 @@ void OCalcTable::refreshColumns() if(m_pColumns) m_pColumns->reFill(aVector); else - m_pColumns = new OCalcColumns(this,m_aMutex,aVector); + m_pColumns = new component::OComponentColumns(this,m_aMutex,aVector); } void OCalcTable::refreshIndexes() diff --git a/connectivity/source/drivers/component/CColumns.cxx b/connectivity/source/drivers/component/CColumns.cxx new file mode 100644 index 000000000000..68dcba53d9f4 --- /dev/null +++ b/connectivity/source/drivers/component/CColumns.cxx @@ -0,0 +1,45 @@ +/* -*- 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 "component/CColumns.hxx" +#include "file/FTable.hxx" +#include + +using namespace connectivity::component; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; + + +sdbcx::ObjectType OComponentColumns::createObject(const OUString& _rName) +{ + ::rtl::Reference aCols = m_pTable->getTableColumns(); + + OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive())); + sdbcx::ObjectType xRet; + if(aIter != aCols->get().end()) + xRet = sdbcx::ObjectType(*aIter,UNO_QUERY); + return xRet; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/WColumns.cxx b/connectivity/source/drivers/writer/WColumns.cxx deleted file mode 100644 index 73945b9e2ca8..000000000000 --- a/connectivity/source/drivers/writer/WColumns.cxx +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- 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 "writer/WColumns.hxx" - -#include - -#include "writer/WTable.hxx" - -using namespace ::com::sun::star; - -namespace connectivity -{ -namespace writer -{ - -sdbcx::ObjectType OWriterColumns::createObject(const OUString& _rName) -{ - OWriterTable* pTable = static_cast(m_pTable); - ::rtl::Reference aCols = pTable->getTableColumns(); - - OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive())); - sdbcx::ObjectType xRet; - if (aIter != aCols->get().end()) - xRet = sdbcx::ObjectType(*aIter, uno::UNO_QUERY); - return xRet; -} - -} // namespace writer -} // namespace connectivity - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/writer/WTable.cxx b/connectivity/source/drivers/writer/WTable.cxx index 9c558701a1e1..1562059379bc 100644 --- a/connectivity/source/drivers/writer/WTable.cxx +++ b/connectivity/source/drivers/writer/WTable.cxx @@ -30,7 +30,7 @@ #include #include #include "writer/WConnection.hxx" -#include "writer/WColumns.hxx" +#include "component/CColumns.hxx" #include #include #include @@ -231,7 +231,7 @@ void OWriterTable::refreshColumns() if (m_pColumns) m_pColumns->reFill(aVector); else - m_pColumns = new OWriterColumns(this, m_aMutex, aVector); + m_pColumns = new component::OComponentColumns(this, m_aMutex, aVector); } void OWriterTable::refreshIndexes() diff --git a/connectivity/source/inc/calc/CColumns.hxx b/connectivity/source/inc/calc/CColumns.hxx deleted file mode 100644 index f178e80a396c..000000000000 --- a/connectivity/source/inc/calc/CColumns.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCOLUMNS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCOLUMNS_HXX - -#include "file/FColumns.hxx" - -namespace connectivity -{ - namespace calc - { - class OCalcColumns : public file::OColumns - { - protected: - virtual sdbcx::ObjectType createObject(const OUString& _rName) override; - public: - OCalcColumns(file::OFileTable* _pTable, - ::osl::Mutex& _rMutex, - const TStringVector &_rVector - ) : file::OColumns(_pTable,_rMutex,_rVector) - {} - - }; - } -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_CALC_CCOLUMNS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/component/CColumns.hxx b/connectivity/source/inc/component/CColumns.hxx new file mode 100644 index 000000000000..3ecec1d0b637 --- /dev/null +++ b/connectivity/source/inc/component/CColumns.hxx @@ -0,0 +1,47 @@ +/* -*- 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 . + */ + +#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CCOLUMNS_HXX +#define INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CCOLUMNS_HXX + +#include "file/FColumns.hxx" + +namespace connectivity +{ + namespace component + { + /// Columns implementation for Writer tables and Calc sheets. + class OOO_DLLPUBLIC_FILE OComponentColumns : public file::OColumns + { + protected: + virtual sdbcx::ObjectType createObject(const OUString& _rName) override; + public: + OComponentColumns(file::OFileTable* _pTable, + ::osl::Mutex& _rMutex, + const TStringVector &_rVector + ) : file::OColumns(_pTable,_rMutex,_rVector) + {} + + }; + } +} + +#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_COMPONENT_CCOLUMNS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/inc/writer/WColumns.hxx b/connectivity/source/inc/writer/WColumns.hxx deleted file mode 100644 index 8b59851999eb..000000000000 --- a/connectivity/source/inc/writer/WColumns.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- 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 . - */ - -#ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCOLUMNS_HXX -#define INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCOLUMNS_HXX - -#include "file/FColumns.hxx" - -namespace connectivity -{ -namespace writer -{ -class OWriterColumns : public file::OColumns -{ -protected: - virtual sdbcx::ObjectType createObject(const OUString& _rName) override; -public: - OWriterColumns(file::OFileTable* _pTable, - ::osl::Mutex& _rMutex, - const TStringVector& _rVector - ) : file::OColumns(_pTable,_rMutex,_rVector) - {} - -}; -} -} - -#endif // INCLUDED_CONNECTIVITY_SOURCE_INC_WRITER_WCOLUMNS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit