[Libreoffice-commits] core.git: include/tools tools/CppunitTest_tools_test.mk tools/Library_tl.mk tools/qa tools/source

Noel Grandin noel.grandin at collabora.co.uk
Sat May 19 11:44:33 UTC 2018


 include/tools/Pair.hxx          |   80 -------------------------
 include/tools/gen.hxx           |   39 ++++++++++++
 tools/CppunitTest_tools_test.mk |    1 
 tools/Library_tl.mk             |    1 
 tools/qa/cppunit/test_pair.cxx  |  126 ----------------------------------------
 tools/source/generic/pair.cxx   |   28 --------
 6 files changed, 38 insertions(+), 237 deletions(-)

New commits:
commit ff590683f9ac5956d95c519cb54b4ea5634dcb63
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 16 08:50:47 2018 +0100

    Revert "tools: test Pair"
    
    This reverts commit 99dbaba70afb91ed3961f9ff627c35bf54d66bef.
    
    Let's land this again once Stephan's comments in
       https://gerrit.libreoffice.org/#/c/54189/
    have been addressed
    
    Change-Id: I4230e4ce59a46379548bb510e433c68b021e896c
    Reviewed-on: https://gerrit.libreoffice.org/54414
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/tools/Pair.hxx b/include/tools/Pair.hxx
deleted file mode 100644
index 87fdd810c88f..000000000000
--- a/include/tools/Pair.hxx
+++ /dev/null
@@ -1,80 +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_TOOLS_PAIR_HXX
-#define INCLUDED_TOOLS_PAIR_HXX
-
-#include <tools/toolsdllapi.h>
-
-class Point;
-class Size;
-class SvStream;
-
-namespace rtl
-{
-class OString;
-}
-
-class SAL_WARN_UNUSED Pair
-{
-public:
-    Pair()
-        : nA(0)
-        , nB(0)
-    {
-    }
-    Pair(long _nA, long _nB)
-        : nA(_nA)
-        , nB(_nB)
-    {
-    }
-
-    long A() const { return nA; }
-    long B() const { return nB; }
-
-    long& A() { return nA; }
-    long& B() { return nB; }
-
-    TOOLS_DLLPUBLIC rtl::OString toString() const;
-    TOOLS_DLLPUBLIC friend SvStream& ReadPair(SvStream& rIStream, Pair& rPair);
-    TOOLS_DLLPUBLIC friend SvStream& WritePair(SvStream& rOStream, const Pair& rPair);
-
-protected:
-    long nA;
-    long nB;
-};
-
-namespace tools
-{
-namespace detail
-{
-// Used to implement operator == for subclasses of Pair:
-inline bool equal(Pair const& p1, Pair const& p2) { return p1.A() == p2.A() && p1.B() == p2.B(); }
-
-} // namespace detail
-} // namespace tools
-
-SAL_DLLPUBLIC_EXPORT SvStream& ReadPair(SvStream& rIStream, Point& v);
-SAL_DLLPUBLIC_EXPORT SvStream& WritePair(SvStream& rOStream, const Point& v);
-SAL_DLLPUBLIC_EXPORT SvStream& ReadPair(SvStream& rIStream, Size& v);
-SAL_DLLPUBLIC_EXPORT SvStream& WritePair(SvStream& rOStream, const Size& v);
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 1b117a642e6b..90486536c401 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -20,7 +20,6 @@
 #define INCLUDED_TOOLS_GEN_HXX
 
 #include <tools/toolsdllapi.h>
-#include <tools/Pair.hxx>
 
 #include <limits.h>
 #include <algorithm>
@@ -35,6 +34,39 @@ namespace rtl
 
 enum TriState { TRISTATE_FALSE, TRISTATE_TRUE, TRISTATE_INDET };
 
+// Pair
+
+class SAL_WARN_UNUSED Pair
+{
+public:
+                        Pair() : nA(0), nB(0) {}
+                        Pair( long _nA, long _nB ) : nA(_nA), nB(_nB) {}
+
+    long                A() const { return nA; }
+    long                B() const { return nB; }
+
+    long&               A() { return nA; }
+    long&               B() { return nB; }
+
+    TOOLS_DLLPUBLIC rtl::OString        toString() const;
+    TOOLS_DLLPUBLIC friend SvStream&    ReadPair( SvStream& rIStream, Pair& rPair );
+    TOOLS_DLLPUBLIC friend SvStream&    WritePair( SvStream& rOStream, const Pair& rPair );
+
+protected:
+    long                nA;
+    long                nB;
+};
+
+namespace tools { namespace detail {
+
+// Used to implement operator == for subclasses of Pair:
+inline bool equal(Pair const & p1, Pair const & p2)
+{
+    return p1.A() == p2.A() && p1.B() == p2.B();
+}
+
+} }
+
 // Point
 
 class Size;
@@ -712,6 +744,11 @@ inline std::basic_ostream<charT, traits> & operator <<(
                       << "@(" << rectangle.getX() << ',' << rectangle.getY() << ")";
 }
 
+inline SvStream& ReadPair( SvStream& rIStream, Point& v ) { return ReadPair(rIStream, v.toPair()); }
+inline SvStream& WritePair( SvStream& rOStream, const Point& v ) { return WritePair(rOStream, v.toPair()); }
+inline SvStream& ReadPair( SvStream& rIStream, Size& v ) { return ReadPair(rIStream, v.toPair()); }
+inline SvStream& WritePair( SvStream& rOStream, const Size& v ) { return WritePair(rOStream, v.toPair()); }
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/CppunitTest_tools_test.mk b/tools/CppunitTest_tools_test.mk
index ad393f8347c6..7cf5657e68ec 100644
--- a/tools/CppunitTest_tools_test.mk
+++ b/tools/CppunitTest_tools_test.mk
@@ -28,7 +28,6 @@ $(eval $(call gb_CppunitTest_add_exception_objects,tools_test, \
     tools/qa/cppunit/test_minmax \
     tools/qa/cppunit/test_100mm2twips \
     tools/qa/cppunit/test_fround \
-    tools/qa/cppunit/test_pair \
 ))
 
 $(eval $(call gb_CppunitTest_use_sdk_api,tools_test))
diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk
index 539bee3e5b2a..c524a38084aa 100644
--- a/tools/Library_tl.mk
+++ b/tools/Library_tl.mk
@@ -57,7 +57,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
     tools/source/generic/config \
     tools/source/generic/fract \
     tools/source/generic/gen \
-	tools/source/generic/pair \
     tools/source/generic/line \
     tools/source/generic/point \
     tools/source/generic/poly \
diff --git a/tools/qa/cppunit/test_pair.cxx b/tools/qa/cppunit/test_pair.cxx
deleted file mode 100644
index 31812963f754..000000000000
--- a/tools/qa/cppunit/test_pair.cxx
+++ /dev/null
@@ -1,126 +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 <sal/types.h>
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/plugin/TestPlugIn.h>
-
-#include <tools/stream.hxx>
-#include <tools/Pair.hxx>
-
-namespace tools
-{
-class PairTest : public CppUnit::TestFixture
-{
-public:
-    void testPair()
-    {
-        long nExpectedA = 0;
-        long nExpectedB = 0;
-        long nActualA = 0;
-        long nActualB = 0;
-
-        {
-            Pair aPair;
-            nActualA = aPair.A();
-            nActualB = aPair.B();
-
-            CPPUNIT_ASSERT_EQUAL(nExpectedA, nActualA);
-            CPPUNIT_ASSERT_EQUAL(nExpectedB, nActualB);
-        }
-
-        {
-            Pair aPair(1, 2);
-            nExpectedA = 1;
-            nExpectedB = 2;
-            nActualA = aPair.A();
-            nActualB = aPair.B();
-
-            CPPUNIT_ASSERT_EQUAL(nExpectedA, nActualA);
-            CPPUNIT_ASSERT_EQUAL(nExpectedB, nActualB);
-        }
-    }
-
-    void testToString()
-    {
-        OString sExpectedString("1, 2");
-        Pair aPair(1, 2);
-        CPPUNIT_ASSERT_EQUAL(sExpectedString, aPair.toString());
-    }
-
-    void testReadStream()
-    {
-        TestPair* pData = new TestPair(1, 2);
-        SvMemoryStream aMemStm(pData, 8, StreamMode::READ);
-
-        Pair aPair;
-        ReadPair(aMemStm, aPair);
-
-        sal_Int32 nExpectedA = 1;
-        sal_Int32 nExpectedB = 2;
-        sal_Int32 nActualA = aPair.A();
-        sal_Int32 nActualB = aPair.B();
-
-        CPPUNIT_ASSERT_EQUAL(nExpectedA, nActualA);
-        CPPUNIT_ASSERT_EQUAL(nExpectedB, nActualB);
-    }
-
-    void testWriteStream()
-    {
-        SvMemoryStream aMemStm;
-
-        WritePair(aMemStm, Pair(1, 2));
-
-        Pair aPair;
-        aMemStm.Seek(0); // reset to the beginning of the stream
-        ReadPair(aMemStm, aPair);
-
-        sal_Int32 nExpectedA = 1;
-        sal_Int32 nExpectedB = 2;
-        sal_Int32 nActualA = aPair.A();
-        sal_Int32 nActualB = aPair.B();
-
-        CPPUNIT_ASSERT_EQUAL(nExpectedA, nActualA);
-        CPPUNIT_ASSERT_EQUAL(nExpectedB, nActualB);
-    }
-
-    CPPUNIT_TEST_SUITE(PairTest);
-    CPPUNIT_TEST(testPair);
-    CPPUNIT_TEST(testToString);
-    CPPUNIT_TEST(testReadStream);
-    CPPUNIT_TEST(testWriteStream);
-    CPPUNIT_TEST_SUITE_END();
-
-private:
-    struct TestPair
-    {
-        sal_Int32 mnA;
-        sal_Int32 mnB;
-
-        TestPair(sal_Int32 nA, sal_Int32 nB)
-            : mnA(nA)
-            , mnB(nB){};
-    };
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(PairTest);
-} // namespace tools
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/generic/pair.cxx b/tools/source/generic/pair.cxx
deleted file mode 100644
index 6e998592ce5d..000000000000
--- a/tools/source/generic/pair.cxx
+++ /dev/null
@@ -1,28 +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 <tools/gen.hxx>
-#include <tools/Pair.hxx>
-
-SvStream& ReadPair(SvStream& rIStream, Point& v) { return ReadPair(rIStream, v.toPair()); }
-SvStream& WritePair(SvStream& rOStream, const Point& v) { return WritePair(rOStream, v.toPair()); }
-SvStream& ReadPair(SvStream& rIStream, Size& v) { return ReadPair(rIStream, v.toPair()); }
-SvStream& WritePair(SvStream& rOStream, const Size& v) { return WritePair(rOStream, v.toPair()); }
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list