From 2eb435be2c15a11b2268c6bc64dd1f88684247f4 Mon Sep 17 00:00:00 2001
From: psykose <alice@ayaya.dev>
Date: Fri, 15 Apr 2022 00:44:04 +0000
Subject: [PATCH] community/calligra: backport fixes for modern toolchains

needed to build with new c++ standards, fix fontconfig linking

supercedes fix-linking.patch, (adds a removal of c++11 force)
---
 community/calligra/APKBUILD                 |  8 ++-
 community/calligra/fix-linking.patch        | 33 ----------
 community/calligra/fontconfig-linking.patch | 51 ++++++++++++++
 community/calligra/gcc11.patch              | 73 +++++++++++++++++++++
 community/calligra/modernise-cmake.patch    | 23 +++++++
 5 files changed, 153 insertions(+), 35 deletions(-)
 delete mode 100644 community/calligra/fix-linking.patch
 create mode 100644 community/calligra/fontconfig-linking.patch
 create mode 100644 community/calligra/gcc11.patch
 create mode 100644 community/calligra/modernise-cmake.patch

diff --git a/community/calligra/APKBUILD b/community/calligra/APKBUILD
index b8004c01b710..1aa30fd27210 100644
--- a/community/calligra/APKBUILD
+++ b/community/calligra/APKBUILD
@@ -61,8 +61,10 @@ makedepends="$makedepends
 	"
 checkdepends="xvfb-run"
 source="https://download.kde.org/stable/calligra/$pkgver/calligra-$pkgver.tar.xz
-	fix-linking.patch
 	poppler-22.03.patch
+	gcc11.patch
+	modernise-cmake.patch
+	fontconfig-linking.patch
 	"
 subpackages="$pkgname-doc $pkgname-lang"
 options="!check" # Broken tests https://bugs.kde.org/show_bug.cgi?id=423989
@@ -86,6 +88,8 @@ package() {
 }
 sha512sums="
 e53a939aa1b277c2291cfd626868c77085fc9cc7774df160b5b1afceb33314b4381fa8ffe03636cbde6e35cc2abd170a51e7f9c1a99191339313b9c9c3b1526f  calligra-3.2.1.tar.xz
-bba3cde77ba86388d968b511bb855fb801dd0ea3fd3e617eea10064f9f0104561edced046ced1036f2770cc8c77cc46c71ce0bf62e3b22b15b79417e0da43cd3  fix-linking.patch
 101cafc43865afa7097cf5ba5b754ec6566fefb9084a3589dd5b482231cf991fcea0b4ee4a42159b4ccc3f1234a75854af1008a1f8fa79872d61d3bd73030d1d  poppler-22.03.patch
+8c56ac0e3347f97bb44d6abf4e3c2303898ce7a4556e0264440ba928e159e978f858a730c9ed07dcde2f0fdc32228d3cc5a565574bf52f43a53475501a640bc4  gcc11.patch
+bbf56c7489af184fe3710108ce43b610f9723cbdf49246bc2bdff4d86d9171693afc64d6072680e6f785f8b15aea509ea0e8cfb84424d1ef1b4d3e876630005f  modernise-cmake.patch
+050d8a80cb2827cbd83835e198014a7a2c33b38a7200e9b5b07d80d4c2e801d0ac7879f7ed06ea9454e1eb37d617c1fe39db6f5a50466afddb9cdef18264c4b6  fontconfig-linking.patch
 "
diff --git a/community/calligra/fix-linking.patch b/community/calligra/fix-linking.patch
deleted file mode 100644
index b9d682211923..000000000000
--- a/community/calligra/fix-linking.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index deca38e..4b1e910 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -641,8 +641,8 @@ if(NOT WIN32 AND NOT APPLE)
- 	)
- endif()
- 
--if(NOT FONTCONFIG_FOUND OR NOT FREETYPE_FOUND)
--    set(FONTCONFIG_INCLUDE_DIR "")
-+if(NOT Fontconfig_FOUND OR NOT FREETYPE_FOUND)
-+		set(Fontconfig_INCLUDE_DIR "")
-     set(FREETYPE_INCLUDE_DIRS "")
- else()
-     add_definitions( -DSHOULD_BUILD_FONT_CONVERSION )
-diff --git a/libs/text/CMakeLists.txt b/libs/text/CMakeLists.txt
-index 16d7e06..0ba3024 100644
---- a/libs/text/CMakeLists.txt
-+++ b/libs/text/CMakeLists.txt
-@@ -152,11 +152,11 @@ if( SHOULD_BUILD_FEATURE_RDF )
- endif()
- 
- if( FONTCONFIG_FOUND )
--    target_link_libraries(kotext PRIVATE ${FONTCONFIG_LIBRARIES})
-+    target_link_libraries(kotext PRIVATE Fontconfig::Fontconfig)
- endif()
- 
- if( FREETYPE_FOUND )
--    target_link_libraries(kotext PRIVATE ${FREETYPE_LIBRARIES})
-+		target_link_libraries(kotext PRIVATE Freetype::Freetype)
- endif()
- 
- 
diff --git a/community/calligra/fontconfig-linking.patch b/community/calligra/fontconfig-linking.patch
new file mode 100644
index 000000000000..1886e51147da
--- /dev/null
+++ b/community/calligra/fontconfig-linking.patch
@@ -0,0 +1,51 @@
+Patch-Source: https://raw.githubusercontent.com/archlinux/svntogit-packages/packages/calligra/trunk/62f51070.patch
+From 62f510702ef9c34ac50f8d8601a4290ab558464c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=96mer=20Fad=C4=B1l=20Usta?= <omerusta@gmail.com>
+Date: Sun, 6 Jun 2021 08:41:05 +0000
+Subject: [PATCH] Update Cmake and deps, Fix Freetype and FontConfig Linkage
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index b237f68fcb6..cdcc02f0236 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -89,9 +89,6 @@ if(NOT DEFINED RELEASE_BUILD)
+ endif()
+ message(STATUS "Release build: ${RELEASE_BUILD}")
+
+-# use CPP-11
+-set (CMAKE_CXX_STANDARD 11)
+-
+ ############
+ #############
+ ## Options ##
+@@ -599,8 +593,8 @@ if(NOT WIN32 AND NOT APPLE)
+ 	)
+ endif()
+ 
+-if(NOT FONTCONFIG_FOUND OR NOT FREETYPE_FOUND)
+-    set(FONTCONFIG_INCLUDE_DIR "")
++if(NOT Fontconfig_FOUND OR NOT FREETYPE_FOUND)
++    set(Fontconfig_INCLUDE_DIRS "")
+     set(FREETYPE_INCLUDE_DIRS "")
+ else()
+     add_definitions( -DSHOULD_BUILD_FONT_CONVERSION )
+diff --git a/libs/text/CMakeLists.txt b/libs/text/CMakeLists.txt
+index 16d7e066fa2..429afe79704 100644
+--- a/libs/text/CMakeLists.txt
++++ b/libs/text/CMakeLists.txt
+@@ -152,11 +152,11 @@ if( SHOULD_BUILD_FEATURE_RDF )
+ endif()
+ 
+ if( FONTCONFIG_FOUND )
+-    target_link_libraries(kotext PRIVATE ${FONTCONFIG_LIBRARIES})
++    target_link_libraries(kotext PRIVATE Fontconfig::Fontconfig)
+ endif()
+ 
+ if( FREETYPE_FOUND )
+-    target_link_libraries(kotext PRIVATE ${FREETYPE_LIBRARIES})
++    target_link_libraries(kotext PRIVATE Freetype::Freetype)
+ endif()
+ 
+ 
+-- 
+GitLab
diff --git a/community/calligra/gcc11.patch b/community/calligra/gcc11.patch
new file mode 100644
index 000000000000..9a7046c47d81
--- /dev/null
+++ b/community/calligra/gcc11.patch
@@ -0,0 +1,73 @@
+Patch-Source: https://github.com/archlinux/svntogit-packages/blob/bccf43ed23b3e0e7943c973f20faa1f2dc84d99c/trunk/068cd9ae.patch
+From 068cd9aec11052733e393976142516d2190e4564 Mon Sep 17 00:00:00 2001
+From: Pierre Ducroquet <pinaraf@pinaraf.info>
+Date: Sun, 28 Feb 2021 23:23:02 +0100
+Subject: [PATCH] Fix some more warnings
+
+diff --git a/filters/words/msword-odf/wv2/src/styles.cpp b/filters/words/msword-odf/wv2/src/styles.cpp
+index f47c3dd8d51..d2c96e3d92b 100644
+--- a/filters/words/msword-odf/wv2/src/styles.cpp
++++ b/filters/words/msword-odf/wv2/src/styles.cpp
+@@ -42,7 +42,6 @@ STD::STD()
+ }
+ 
+ STD::STD( U16 baseSize, U16 totalSize, OLEStreamReader* stream, bool preservePos )
+-throw(InvalidFormatException)
+ {
+     clearInternal();
+     if (!read( baseSize, totalSize, stream, preservePos )) {
+@@ -112,7 +111,6 @@ STD& STD::operator=( const STD& rhs )
+ }
+ 
+ bool STD::read( const U16 cbStd, const U16 stdfSize, OLEStreamReader* stream, bool preservePos )
+-throw(InvalidFormatException)
+ {
+     U16 shifterU16;
+     S32 startOffset=stream->tell();  // address where the STD starts
+@@ -938,7 +936,7 @@ void Style::mergeUpechpx( const Style* parentStyle, WordVersion version )
+ }
+ 
+ 
+-StyleSheet::StyleSheet( OLEStreamReader* tableStream, U32 fcStshf, U32 lcbStshf ) throw(InvalidFormatException)
++StyleSheet::StyleSheet( OLEStreamReader* tableStream, U32 fcStshf, U32 lcbStshf )
+     : m_udsNum(0)
+ {
+     WordVersion version = Word8;
+diff --git a/filters/words/msword-odf/wv2/src/styles.h b/filters/words/msword-odf/wv2/src/styles.h
+index ba02def6845..41c8278dd21 100644
+--- a/filters/words/msword-odf/wv2/src/styles.h
++++ b/filters/words/msword-odf/wv2/src/styles.h
+@@ -58,8 +58,9 @@ struct STD
+     STD();
+     /**
+      * Simply calls read(...)
++     * @throw InvalidFormatException
+      */
+-    STD( U16 stdfSize, U16 totalSize, OLEStreamReader* stream, bool preservePos = false ) throw(InvalidFormatException);
++    STD( U16 stdfSize, U16 totalSize, OLEStreamReader* stream, bool preservePos = false );
+     /**
+      * Attention: This struct allocates memory on the heap
+      */
+@@ -74,8 +75,9 @@ struct STD
+      * false the state of stream will be changed!
+      *
+      * @return true - success, false - failed
++     * @throw InvalidFormatException
+      */
+-    bool read( const U16 cbStd, const U16 stdfSize, OLEStreamReader* stream, bool preservePos = false ) throw(InvalidFormatException);
++    bool read( const U16 cbStd, const U16 stdfSize, OLEStreamReader* stream, bool preservePos = false );
+ 
+     /**
+      * Same as reading :)
+@@ -365,7 +367,10 @@ class WV2_EXPORT Style
+ class WV2_EXPORT StyleSheet
+ {
+ public:
+-    StyleSheet( OLEStreamReader* tableStream, U32 fcStshf, U32 lcbStshf ) throw(InvalidFormatException);
++    /**
++     * @throw InvalidFormatException
++     */
++    StyleSheet( OLEStreamReader* tableStream, U32 fcStshf, U32 lcbStshf );
+     ~StyleSheet();
+ 
+     /**
diff --git a/community/calligra/modernise-cmake.patch b/community/calligra/modernise-cmake.patch
new file mode 100644
index 000000000000..c48c04cf5281
--- /dev/null
+++ b/community/calligra/modernise-cmake.patch
@@ -0,0 +1,23 @@
+Patch-Source: https://github.com/archlinux/svntogit-packages/blob/bccf43ed23b3e0e7943c973f20faa1f2dc84d99c/trunk/2ac46db5.patch
+From 2ac46db52c6ad401f67ae5b5fcd859a5872f0311 Mon Sep 17 00:00:00 2001
+From: Pierre Ducroquet <pinaraf@pinaraf.info>
+Date: Sat, 1 May 2021 15:08:57 +0200
+Subject: [PATCH] Small CMake modernization
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index fe6502493ed..b237f68fcb6 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -105,11 +90,7 @@ endif()
+ message(STATUS "Release build: ${RELEASE_BUILD}")
+ 
+ # use CPP-11
+-if (CMAKE_VERSION VERSION_LESS "3.1")
+-    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+-else ()
+-    set (CMAKE_CXX_STANDARD 11)
+-endif ()
++set (CMAKE_CXX_STANDARD 11)
+ 
+ ############
+ #############
-- 
GitLab