summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author Hannes Worst2012-06-03 01:59:45 +0200
committer Erik Hanson2012-06-03 22:21:15 +0200
commitf0619135ba0b91f0100aa8ff63d71eddfbd8d622 (patch)
tree2209b447f6317aaed35ad855e3cf18dcd083c6a6
parenta54303fdafdfc7a4f1b8d986788d7ba318cf5d17 (diff)
downloadslackbuilds-f0619135ba0b91f0100aa8ff63d71eddfbd8d622.tar.gz
office/Ted: Updated for version 2.22.
Signed-off-by: dsomero <xgizzmo@slackbuilds.org>
-rw-r--r--office/Ted/Ted.SlackBuild44
-rw-r--r--office/Ted/Ted.desktop17
-rw-r--r--office/Ted/Ted.info8
-rw-r--r--office/Ted/docSectProperties.c1105
-rw-r--r--office/Ted/slack-desc2
-rw-r--r--office/Ted/ted-2.21-libpng15.patch423
6 files changed, 1146 insertions, 453 deletions
diff --git a/office/Ted/Ted.SlackBuild b/office/Ted/Ted.SlackBuild
index 8941db6600..18d5267cc3 100644
--- a/office/Ted/Ted.SlackBuild
+++ b/office/Ted/Ted.SlackBuild
@@ -1,10 +1,10 @@
-#!/bin/sh
+#!/bin/sh
# Slackware build script for Ted
# and edited by Hannes Worst <hannesworst@gmail.com>.
# Copyright by Hannes Worst
#--
-# Last edited: 30-dec-2009
+# Last edited: 01-05-2012
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
@@ -24,9 +24,10 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Very heavily edited by the SlackBuilds.org project. --michiel
+# DocSectProperies Bug-fix provided bij Mark de Does, developer of Ted
PRGNAM=Ted
-VERSION=${VERSION:-2.21}
+VERSION=${VERSION:-2.22}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
@@ -46,14 +47,14 @@ OUTPUT=${OUTPUT:-/tmp}
TOOLKIT=${TOOLKIT:-GTK}
SRCNAM=$(echo $PRGNAM | tr T t)
-if [ "$ARCH" = "i486" ]; then
- SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
-elif [ "$ARCH" = "i686" ]; then
- SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
-elif [ "$ARCH" = "x86_64" ]; then
- SLKCFLAGS="-O2 -fPIC"
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
fi
@@ -64,6 +65,7 @@ mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION.src.tar.gz
+cp $CWD/docSectProperties.c $PRGNAM-$VERSION/docBase/docSectProperties.c
cd $PRGNAM-$VERSION
chown -R root:root .
find . \
@@ -72,9 +74,6 @@ find . \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
-# Correct libpng error
-patch -p0 < $CWD/ted-2.21-libpng15.patch
-
# Let's edit Ted's Makefile, so this allows us to package Ted quite properly without
# actually having to need /usr/local/.
sed -i 's#./configure#./configure --prefix=/usr/share#g' $TMP/$PRGNAM-$VERSION/Makefile
@@ -92,31 +91,26 @@ make package.shared DESTDIR=$PKG CONFIGURE_OPTIONS="--with-$TOOLKIT \
--prefix=/usr/share/$PRGNAM --bindir=/usr/bin \
--build=$ARCH-slackware-linux"
-mkdir -p $PKG/usr/share
-tar -xvf $TMP/$PRGNAM-$VERSION/${SRCNAM}Package/$SRCNAM-$VERSION-linux-$ARCH.tar.gz -C $PKG/usr/share/
-mv $PKG/usr/share/bin $PKG/usr/
-
-mkdir -p $PKG/usr/man/man1
-mv $PKG/usr/share/$PRGNAM/{rtf2pdf,rtf2ps,$PRGNAM}.1 $PKG/usr/man/man1
+mkdir -p $PKG/usr/
+tar -xvf $TMP/$PRGNAM-$VERSION/${SRCNAM}Package/$SRCNAM-$VERSION-linux-*$LIBDIRSUFFIX.tar.gz -C $PKG/usr/
+mv $PKG/usr/Ted $PKG/usr/share
mv $PKG/usr/share/$PRGNAM/{rtf2pdf,rtf2ps}.sh $PKG/usr/bin/
+cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
+mkdir -p $PKG/usr/man/man1
+mv $PKG/usr/share/$PRGNAM/{rtf2pdf,rtf2ps,$PRGNAM}.1 $PKG/usr/man/man1
find $PKG/usr/man -type f -exec gzip -9 {} \;
-for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
-cat $PKG/usr/share/$PRGNAM/$PRGNAM.ad.sample > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.ad.sample
+cat $PKG/usr/share/$PRGNAM/config/$PRGNAM.ad.sample > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.ad.sample
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
-mkdir -p $PKG/usr/share/applications
-mv $PKG/usr/share/$PRGNAM/varia/$PRGNAM.desktop $PKG/usr/share/applications/$PRGNAM.desktop
-sed -i 's#/local/#/share/#' $PKG/usr/share/applications/$PRGNAM.desktop
-
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
-cat $CWD/doinst.sh > $PKG/install/doinst.sh
+cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
diff --git a/office/Ted/Ted.desktop b/office/Ted/Ted.desktop
new file mode 100644
index 0000000000..2471ce9943
--- /dev/null
+++ b/office/Ted/Ted.desktop
@@ -0,0 +1,17 @@
+# Desktop entry for Ted.
+# System wide install as /usr/share/applications, or /usr/local/share/applications
+# Private install as $HOME/.local/share/applications
+# See http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html
+# See http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=Ted rtf text processor
+GenericName=rtf text processor
+Comment=A lightweight rtf text processor
+Icon=/usr/share/Ted/Ted.png
+Exec=Ted %F
+Terminal=false
+MimeType=application/rtf;text/rtf;
+Categories=Office;WordProcessor;
+#StartupNotify=false
diff --git a/office/Ted/Ted.info b/office/Ted/Ted.info
index e6ea6d3fbe..4c3b445cbc 100644
--- a/office/Ted/Ted.info
+++ b/office/Ted/Ted.info
@@ -1,10 +1,10 @@
PRGNAM="Ted"
-VERSION="2.21"
+VERSION="2.22"
HOMEPAGE="http://www.nllgg.nl/Ted/"
-DOWNLOAD="ftp://ftp.nluug.nl/pub/editors/ted/ted-2.21.src.tar.gz"
-MD5SUM="34ae855938a3b364eb587cca504ba356"
+DOWNLOAD="ftp://ftp.nluug.nl/pub/editors/ted/ted-2.22.src.tar.gz"
+MD5SUM="08162c9164dfdde1d46e41ae64df16be"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
MAINTAINER="Hannes Worst"
EMAIL="hannesworst@gmail.com"
-APPROVED="BP{k},Niels Horn"
+APPROVED="dsomero"
diff --git a/office/Ted/docSectProperties.c b/office/Ted/docSectProperties.c
new file mode 100644
index 0000000000..e85ae188e3
--- /dev/null
+++ b/office/Ted/docSectProperties.c
@@ -0,0 +1,1105 @@
+/************************************************************************/
+/* */
+/* Manipulate iten properties in a document. */
+/* */
+/************************************************************************/
+
+# include "docBaseConfig.h"
+
+# include <stdlib.h>
+
+# include <appDebugon.h>
+
+# include <utilPropMask.h>
+
+# include "docPropVal.h"
+# include "docSectProperties.h"
+
+# define MIN_COL_WIDE ( 20* 36 )
+# define MIN_GAP_WIDE ( 20* 12 )
+
+# define DEF_GAP_WIDE ( 20* 36 )
+
+/************************************************************************/
+/* */
+/* Translate section property numbers to notes property numbers. */
+/* */
+/************************************************************************/
+
+const int DOCsectNOTE_PROP_MAP[FEPprop_COUNT]=
+{
+ SPpropFOOTNOTE_STARTNR,
+ SPpropFOOTNOTE_JUSTIFICATION,
+ -1, /* No SPpropFOOTNOTE_PLACEMENT, */
+ SPpropFOOTNOTE_RESTART,
+ SPpropFOOTNOTE_STYLE,
+
+ SPpropENDNOTE_STARTNR,
+ -1, /* No SPpropENDNOTE_JUSTIFICATION, */
+ -1, /* No SPpropENDNOTE_PLACEMENT, */
+ SPpropENDNOTE_RESTART,
+ SPpropENDNOTE_STYLE,
+};
+
+const int * const DOCsectFOOTNOTE_PROP_MAP= DOCsectNOTE_PROP_MAP;
+const int * const DOCsectENDNOTE_PROP_MAP= DOCsectNOTE_PROP_MAP+ NOTESprop_COUNT;
+
+static const int DocSectIntProps[]=
+ {
+ DGpropPAGE_WIDTH,
+ DGpropPAGE_HEIGHT,
+ DGpropLEFT_MARGIN,
+ DGpropRIGHT_MARGIN,
+ DGpropTOP_MARGIN,
+ DGpropBOTTOM_MARGIN,
+ DGpropHEADER_POSITION,
+ DGpropFOOTER_POSITION,
+ DGpropGUTTER,
+ DGpropMARGMIR,
+ SPpropSTYLE,
+ SPpropTITLEPG,
+ SPpropBREAK_KIND,
+ SPpropNUMBER_STYLE,
+ SPpropNUMBER_HYPHEN,
+ SPpropPAGE_RESTART,
+ SPpropSTART_PAGE,
+ SPpropCOLUMN_COUNT,
+ SPpropCOLUMN_SPACING,
+ SPpropLINEBETCOL,
+ SPpropFOOTNOTE_STARTNR,
+ SPpropFOOTNOTE_JUSTIFICATION,
+ /* No SPpropFOOTNOTE_PLACEMENT, */
+ SPpropFOOTNOTE_RESTART,
+ SPpropFOOTNOTE_STYLE,
+ SPpropENDNOTE_STARTNR,
+ /* No SPpropENDNOTE_JUSTIFICATION, */
+ /* No SPpropENDNOTE_PLACEMENT, */
+ SPpropENDNOTE_RESTART,
+ SPpropENDNOTE_STYLE,
+ };
+
+static const int DocSectIntPropCount= sizeof(DocSectIntProps)/sizeof(int);
+
+/************************************************************************/
+/* */
+/* Fill a mask with notes properties that are relevant for a section. */
+/* I.E: Set those section properties that are a note property. */
+/* */
+/************************************************************************/
+
+void docFillSectNotesMask( PropertyMask * spMask )
+ {
+ int i;
+
+ for ( i= 0; i < FEPprop_COUNT; i++ )
+ {
+ if ( DOCsectNOTE_PROP_MAP[i] >= 0 )
+ { PROPmaskADD( spMask, DOCsectNOTE_PROP_MAP[i] ); }
+ }
+ }
+
+/************************************************************************/
+/* */
+/* Make sure all column width are zero, or that none of them is. */
+/* */
+/************************************************************************/
+
+static void docSectCheckFixedColumnWidth( SectionProperties * sp )
+ {
+ if ( sp->spColumnCount > 1 )
+ {
+ int haveZero= 0;
+ int haveWidth= 0;
+ int col;
+ SectionColumn * sc;
+
+ sc= sp->spColumns;
+ for ( col= 0; col < sp->spColumnCount; sc++, col++ )
+ {
+ if ( sc->scColumnWidthTwips == 0 )
+ { haveZero++; }
+ else{ haveWidth++; }
+ }
+
+ if ( haveZero && haveWidth )
+ {
+ sc= sp->spColumns;
+ for ( col= 0; col < sp->spColumnCount; sc++, col++ )
+ { sc->scColumnWidthTwips= 0; }
+ }
+ }
+
+ return;
+ }
+
+/************************************************************************/
+/* */
+/* Change section properties and tell what has been changed. */
+/* */
+/************************************************************************/
+
+int docUpdSectProperties( PropertyMask * pSpDoneMask,
+ SectionProperties * spTo,
+ const PropertyMask * spSetMask,
+ const SectionProperties * spSet )
+ {
+ PropertyMask doneMask;
+ int p;
+
+ utilPropMaskClear( &doneMask );
+
+ for ( p= 0; p < DocSectIntPropCount; p++ )
+ {
+ int prop= DocSectIntProps[p];
+ int oval;
+ int nval;
+
+ if ( ! PROPmaskISSET( spSetMask, prop ) )
+ { continue; }
+
+ oval= docGetSectionProperty( spTo, prop );
+ nval= docGetSectionProperty( spSet, prop );
+
+ if ( oval == nval )
+ { continue; }
+
+ if ( docSetSectionProperty( spTo, prop, nval ) )
+ { LLDEB(prop,nval); return -1; }
+
+ PROPmaskADD( &doneMask, prop );
+ }
+
+ if ( PROPmaskISSET( spSetMask, SPpropCOLUMN_COUNT ) )
+ {
+ if ( spTo->spColumnCount != spSet->spColumnCount )
+ {
+ if ( docSectionPropertiesSetColumnCount( spTo,
+ spSet->spColumnCount ) )
+ { LDEB(spSet->spColumnCount); return -1; }
+
+ PROPmaskADD( &doneMask, SPpropCOLUMN_COUNT );
+ }
+ }
+
+ if ( PROPmaskISSET( spSetMask, SPpropCOLUMNS ) )
+ {
+ int count;
+
+ if ( spTo->spColumnCount < spSet->spColumnCount )
+ { count= spTo->spColumnCount; }
+ else{ count= spSet->spColumnCount; }
+
+ if ( count > 1 )
+ {
+ const SectionColumn * scFrom= spSet->spColumns;
+ SectionColumn * scTo= spTo->spColumns;
+ int col;
+
+ for ( col= 0; col < count- 1; scTo++, scFrom++, col++ )
+ {
+ if ( scTo->scColumnWidthTwips != scFrom->scColumnWidthTwips )
+ {
+ scTo->scColumnWidthTwips= scFrom->scColumnWidthTwips;
+ PROPmaskADD( &doneMask, SPpropCOLUMNS );
+ }
+ if ( scTo->scSpaceToRightTwips != scFrom->scSpaceToRightTwips )
+ {
+ scTo->scSpaceToRightTwips= scFrom->scSpaceToRightTwips;
+ PROPmaskADD( &doneMask, SPpropCOLUMNS );
+ }
+ }
+ if ( scTo->scColumnWidthTwips != scFrom->scColumnWidthTwips )
+ {
+ scTo->scColumnWidthTwips= scFrom->scColumnWidthTwips;
+ PROPmaskADD( &doneMask, SPpropCOLUMNS );
+ }
+ }
+ }
+
+ docSectCheckFixedColumnWidth( spTo );
+
+ if ( pSpDoneMask )
+ { *pSpDoneMask= doneMask; }
+
+ return 0;
+ }
+
+void docSectPropertyDifference( PropertyMask * pDiffMask,
+ const SectionProperties * sp1,
+ const PropertyMask * cmpMask,
+ const SectionProperties * sp2 )
+ {
+ PropertyMask diffMask;
+ int p;
+
+ utilPropMaskClear( &diffMask );
+
+ for ( p= 0; p < DocSectIntPropCount; p++ )
+ {
+ int prop= DocSectIntProps[p];
+ int oval;
+ int nval;
+
+ if ( ! PROPmaskISSET( cmpMask, prop ) )
+ { continue; }
+
+ oval= docGetSectionProperty( sp1, prop );
+ nval= docGetSectionProperty( sp2, prop );
+
+ if ( oval == nval )
+ { continue; }
+
+ PROPmaskADD( &diffMask, prop );
+ }
+
+ if ( PROPmaskISSET( cmpMask, SPpropCOLUMNS ) )
+ {
+ int count;
+
+ if ( sp1->spColumnCount < sp2->spColumnCount )
+ { count= sp1->spColumnCount; }
+ else{ count= sp2->spColumnCount; }
+
+ if ( count > 1 )
+ {
+ const SectionColumn * sc1= sp1->spColumns;
+ const SectionColumn * sc2= sp2->spColumns;
+ int col;
+
+ for ( col= 0; col < count- 1; sc1++, sc2++, col++ )
+ {
+ if ( sc1->scColumnWidthTwips != sc2->scColumnWidthTwips )
+ { PROPmaskADD( &diffMask, SPpropCOLUMNS ); }
+ if ( sc1->scSpaceToRightTwips != sc2->scSpaceToRightTwips )
+ { PROPmaskADD( &diffMask, SPpropCOLUMNS ); }
+ }
+ if ( sc1->scColumnWidthTwips != sc2->scColumnWidthTwips )
+ { PROPmaskADD( &diffMask, SPpropCOLUMNS ); }
+ }
+ }
+
+ *pDiffMask= diffMask;
+ return;
+ }
+
+/************************************************************************/
+/* */
+/* Clean, Initialize section properties. */
+/* */
+/************************************************************************/
+
+void docCleanSectionProperties( SectionProperties * sp )
+ {
+ if ( sp->spColumns )
+ { free( sp->spColumns ); }
+
+ return;
+ }
+
+void docInitSectionProperties( SectionProperties * sp )
+ {
+ utilInitDocumentGeometry( &(sp->spDocumentGeometry) );
+
+ sp->spStyle= 0;
+
+ sp->spColumnSpacingTwips= DEF_GAP_WIDE;
+ sp->spLineBetweenColumns= 0;
+
+ sp->spHasTitlePage= 0;
+ sp->spBreakKind= DOCibkPAGE;
+ sp->spPageNumberStyle= DOCpgnDEC;
+ sp->spPageNumberHyphen= DOCpgnhPGNHNSH;
+ sp->spRestartPageNumbers= 0;
+
+ sp->spColumnCount= 1;
+ sp->spColumns= (SectionColumn *)0;
+
+ sp->spStartPageNumber= 0;
+
+ docInitFootEndNotesProperties( &(sp->spNotesProperties) );
+
+ return;
+ }
+
+int docSectionPropertiesSetColumnCount( SectionProperties * sp,
+ int n )
+ {
+ if ( n > 1 && sp->spColumnCount < n )
+ {
+ SectionColumn * sc= (SectionColumn *)realloc( sp->spColumns,
+ n* sizeof(SectionColumn) );
+ if ( ! sc )
+ { LXDEB(n,sc); return -1; }
+
+ sp->spColumns= sc;
+
+ if ( sp->spColumnCount == 1 )
+ {
+ sc->scSpaceToRightTwips= 0;
+ sc->scColumnWidthTwips= 0;
+ }
+
+ sc= sp->spColumns+ sp->spColumnCount;
+ while( sp->spColumnCount < n )
+ {
+ sc->scSpaceToRightTwips= 0;
+ sc->scColumnWidthTwips= 0;
+
+ sc++; sp->spColumnCount++;
+ }
+ }
+
+ sp->spColumnCount= n;
+ return 0;
+ }
+
+/************************************************************************/
+/* */
+/* Copy SectionProperties. */
+/* */
+/* NOTE that the headers and footers are not copied. */
+/* */
+/************************************************************************/
+
+int docCopySectionProperties( SectionProperties * to,
+ const SectionProperties * from )
+ {
+ int i;
+
+ if ( docSectionPropertiesSetColumnCount( to, from->spColumnCount ) )
+ { LDEB(from->spColumnCount); return -1; }
+
+ to->spDocumentGeometry= from->spDocumentGeometry;
+
+ to->spStyle= from->spStyle;
+
+ to->spColumnSpacingTwips= from->spColumnSpacingTwips;
+ to->spLineBetweenColumns= from->spLineBetweenColumns;
+
+ to->spHasTitlePage= from->spHasTitlePage;
+ to->spBreakKind= from->spBreakKind;
+ to->spPageNumberStyle= from->spPageNumberStyle;
+ to->spPageNumberHyphen= from->spPageNumberHyphen;
+ to->spRestartPageNumbers= from->spRestartPageNumbers;
+
+ to->spStartPageNumber= from->spStartPageNumber;
+
+ /* docSectionPropertiesSetColumnCount() has allocated the memory */
+ if ( from->spColumnCount > 1 )
+ {
+ for ( i= 0; i < from->spColumnCount; i++ )
+ { to->spColumns[i]= from->spColumns[i]; }
+ }
+
+ to->spNotesProperties= from->spNotesProperties;
+
+ docSectCheckFixedColumnWidth( to );
+
+ return 0;
+ }
+
+int docSectSetEqualColumnWidth( SectionProperties * sp )
+ {
+ int col;
+ SectionColumn * sc;
+ const DocumentGeometry * dg= &(sp->spDocumentGeometry);
+ int pageWide;
+ int colWide;
+
+ pageWide= dg->dgPageWideTwips-
+ dg->dgLeftMarginTwips- dg->dgRightMarginTwips;
+
+ if ( sp->spColumnCount < 2 )
+ { return pageWide; }
+
+ colWide= ( pageWide- ( sp->spColumnCount- 1 )*
+ sp->spColumnSpacingTwips )/ sp->spColumnCount;
+
+ sc= sp->spColumns;
+ for ( col= 0; col < sp->spColumnCount; sc++, col++ )
+ {
+ sc->scColumnWidthTwips= 0;
+ sc->scSpaceToRightTwips= 0;
+ }
+
+ return colWide;
+ }
+
+int docSectSetExplicitColumnWidth( SectionProperties * sp )
+ {
+ int col;
+ SectionColumn * sc;
+ const DocumentGeometry * dg= &(sp->spDocumentGeometry);
+ int pageWide;
+ int colWide;
+
+ pageWide= dg->dgPageWideTwips-
+ dg->dgLeftMarginTwips- dg->dgRightMarginTwips;
+
+ if ( sp->spColumnCount < 2 )
+ { LDEB(sp->spColumnCount); return -1; }
+
+ colWide= ( pageWide- ( sp->spColumnCount- 1 )*
+ sp->spColumnSpacingTwips )/ sp->spColumnCount;
+
+ if ( colWide < MIN_COL_WIDE )
+ { LLDEB(colWide,MIN_COL_WIDE); return -1; }
+
+ sc= sp->spColumns;
+ for ( col= 0; col < sp->spColumnCount; sc++, col++ )
+ {
+ sc->scColumnWidthTwips= colWide;
+ sc->scSpaceToRightTwips= sp->spColumnSpacingTwips;
+ }
+
+ return 0;
+ }
+
+/************************************************************************/
+/* */
+/* Determine the column margins. */
+/* */
+/* Because of gutters and/or mirrored margins, the page geometry is */
+/* not necessarily identical to that in the section properties. */
+/* */
+/************************************************************************/
+
+void docSectGetColumnX( int * pXLine,
+ int * pX0,
+ int * pX1,
+ const SectionProperties * sp,
+ const DocumentGeometry * dgPage,
+ int column )
+ {
+ int x0= dgPage->dgLeftMarginTwips;
+ int col;
+
+ if ( sp->spColumnCount < 2 )
+ {
+ *pX0= dgPage->dgLeftMarginTwips;
+ *pX1= dgPage->dgPageWideTwips- dgPage->dgRightMarginTwips;
+ return;
+ }
+
+ for ( col= 0; col < column; col++ )
+ {
+ if ( sp->spColumns[col].scColumnWidthTwips == 0 )
+ { break; }
+
+ x0 += sp->spColumns[col].scColumnWidthTwips;
+ x0 += sp->spColumns[col].scSpaceToRightTwips;
+ }
+
+ if ( col < column || sp->spColumns[column].scColumnWidthTwips == 0 )
+ {
+ int pageWide;
+ int colWide;
+
+ pageWide= dgPage->dgPageWideTwips-
+ dgPage->dgLeftMarginTwips- dgPage->dgRightMarginTwips;
+
+ colWide= ( pageWide- ( sp->spColumnCount- 1 )*
+ sp->spColumnSpacingTwips )/ sp->spColumnCount;
+
+ x0= dgPage->dgLeftMarginTwips+
+ column* ( colWide+ sp->spColumnSpacingTwips );
+
+ *pXLine= x0- sp->spColumnSpacingTwips/ 2;
+ *pX0= x0;
+ *pX1= x0+ colWide;
+ }
+ else{
+ if ( column == 0 )
+ {
+ *pXLine= x0- sp->spColumnSpacingTwips/ 2;
+ }
+ else{
+ *pXLine= x0- sp->spColumns[column-1].scSpaceToRightTwips/ 2;
+ }
+
+ *pX0= x0;
+ *pX1= x0+ sp->spColumns[column].scColumnWidthTwips;
+ }
+
+ return;
+ }
+
+/************************************************************************/
+/* */
+/* Set a section property. */
+/* */
+/************************************************************************/
+
+int docSetSectionProperty( SectionProperties * sp,
+ int prop,
+ int arg )
+ {
+ DocumentGeometry * dg= &(sp->spDocumentGeometry);
+
+ switch( prop )
+ {
+ case DGpropPAGE_WIDTH:
+ dg->dgPageWideTwips= arg;
+ break;
+ case DGpropPAGE_HEIGHT:
+ dg->dgPageHighTwips= arg;
+ break;
+
+ case DGpropLEFT_MARGIN:
+ dg->dgLeftMarginTwips= arg;
+ break;
+ case DGpropRIGHT_MARGIN:
+ dg->dgRightMarginTwips= arg;
+ break;
+ case DGpropTOP_MARGIN:
+ dg->dgTopMarginTwips= arg;
+ break;
+ case DGpropBOTTOM_MARGIN:
+ dg->dgBottomMarginTwips= arg;
+ break;
+
+ case DGpropHEADER_POSITION:
+ if ( arg != 0 )
+ { dg->dgHeaderPositionTwips= arg; }
+ break;
+ case DGpropFOOTER_POSITION:
+ if ( arg != 0 )
+ { dg->dgFooterPositionTwips= arg; }
+ break;
+
+ case DGpropGUTTER:
+ dg->dgGutterTwips= arg;
+ break;
+ case DGpropMARGMIR:
+ dg->dgMirrorMargins= arg != 0;
+ break;
+
+ case SPpropSTYLE:
+ sp->spStyle= arg;
+ break;
+
+ case SPpropTITLEPG:
+ sp->spHasTitlePage= ( arg != 0 );
+ break;
+
+ case SPpropBREAK_KIND:
+ sp->spBreakKind= arg;
+ break;
+
+ case SPpropNUMBER_STYLE:
+ sp->spPageNumberStyle= arg;
+ break;
+
+ case SPpropNUMBER_HYPHEN:
+ sp->spPageNumberHyphen= arg;
+ break;
+
+ case SPpropPAGE_RESTART:
+ sp->spRestartPageNumbers= arg;
+ break;
+
+ case SPpropSTART_PAGE:
+ sp->spStartPageNumber= arg;
+ break;
+
+ case SPpropCOLUMN_COUNT:
+ if ( docSectionPropertiesSetColumnCount( sp, arg ) )
+ { LDEB(arg); return -1; }
+ break;
+
+ case SPpropCOLUMN_SPACING:
+ sp->spColumnSpacingTwips= arg;
+ break;
+ case SPpropLINEBETCOL:
+ sp->spLineBetweenColumns= ( arg != 0 );
+ break;
+
+ /* FOOTNOTE */
+ case SPpropFOOTNOTE_STARTNR:
+ docSetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropSTARTNR, arg );
+ return 0;
+ case SPpropFOOTNOTE_JUSTIFICATION:
+ docSetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropJUSTIFICATION, arg );
+ return 0;
+ /* No
+ case SPpropFOOTNOTE_PLACEMENT:
+ docSetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropPLACEMENT, arg );
+ return 0;
+ */
+ case SPpropFOOTNOTE_RESTART:
+ docSetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropRESTART, arg );
+ return 0;
+ case SPpropFOOTNOTE_STYLE:
+ docSetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropSTYLE, arg );
+ return 0;
+
+ /* ENDNOTE */
+ case SPpropENDNOTE_STARTNR:
+ docSetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropSTARTNR, arg );
+ return 0;
+ /* No
+ case SPpropENDNOTE_JUSTIFICATION:
+ docSetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropJUSTIFICATION, arg );
+ return 0;
+ */
+ /* No
+ case SPpropENDNOTE_PLACEMENT:
+ docSetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropPLACEMENT, arg );
+ return 0;
+ */
+ case SPpropENDNOTE_RESTART:
+ docSetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropRESTART, arg );
+ return 0;
+ case SPpropENDNOTE_STYLE:
+ docSetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropSTYLE, arg );
+ return 0;
+
+
+ default:
+ LLDEB(prop,arg); return -1;
+ }
+
+ return 0;
+ }
+
+/************************************************************************/
+/* */
+/* Get a section property. */
+/* */
+/************************************************************************/
+
+int docGetSectionProperty( const SectionProperties * sp,
+ int prop )
+ {
+ const DocumentGeometry * dg= &(sp->spDocumentGeometry);
+
+ switch( prop )
+ {
+ case DGpropPAGE_WIDTH:
+ return dg->dgPageWideTwips;
+ case DGpropPAGE_HEIGHT:
+ return dg->dgPageHighTwips;
+
+ case DGpropLEFT_MARGIN:
+ return dg->dgLeftMarginTwips;
+ case DGpropRIGHT_MARGIN:
+ return dg->dgRightMarginTwips;
+ case DGpropTOP_MARGIN:
+ return dg->dgTopMarginTwips;
+ case DGpropBOTTOM_MARGIN:
+ return dg->dgBottomMarginTwips;
+
+ case DGpropHEADER_POSITION:
+ return dg->dgHeaderPositionTwips;
+ case DGpropFOOTER_POSITION:
+ return dg->dgFooterPositionTwips;
+
+ case DGpropGUTTER:
+ return dg->dgGutterTwips;
+ case DGpropMARGMIR:
+ return dg->dgMirrorMargins;
+
+ case SPpropSTYLE:
+ return sp->spStyle;
+
+ case SPpropTITLEPG:
+ return sp->spHasTitlePage;
+
+ case SPpropBREAK_KIND:
+ return sp->spBreakKind;
+
+ case SPpropNUMBER_STYLE:
+ return sp->spPageNumberStyle;
+
+ case SPpropNUMBER_HYPHEN:
+ return sp->spPageNumberHyphen;
+
+ case SPpropPAGE_RESTART:
+ return sp->spRestartPageNumbers;
+
+ case SPpropSTART_PAGE:
+ return sp->spStartPageNumber;
+
+ case SPpropCOLUMN_COUNT:
+ return sp->spColumnCount;
+
+ case SPpropCOLUMN_SPACING:
+ return sp->spColumnSpacingTwips;
+ break;
+ case SPpropLINEBETCOL:
+ return sp->spLineBetweenColumns;
+ break;
+
+ /* FOOTNOTE */
+ case SPpropFOOTNOTE_STARTNR:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropSTARTNR );
+ return 0;
+ case SPpropFOOTNOTE_JUSTIFICATION:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropJUSTIFICATION );
+ return 0;
+ /* No
+ case SPpropFOOTNOTE_PLACEMENT:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropPLACEMENT );
+ return 0;
+ */
+ case SPpropFOOTNOTE_RESTART:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropRESTART );
+ return 0;
+ case SPpropFOOTNOTE_STYLE:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepFootnotesProps),
+ NOTESpropSTYLE );
+ return 0;
+
+ /* ENDNOTE */
+ case SPpropENDNOTE_STARTNR:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropSTARTNR );
+ return 0;
+ /* No
+ case SPpropENDNOTE_JUSTIFICATION:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropJUSTIFICATION );
+ return 0;
+ */
+ /* No
+ case SPpropENDNOTE_PLACEMENT:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropPLACEMENT );
+ return 0;
+ */
+ case SPpropENDNOTE_RESTART:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropRESTART );
+ return 0;
+ case SPpropENDNOTE_STYLE:
+ return docGetNotesProperty( &(sp->spNotesProperties.fepEndnotesProps),
+ NOTESpropSTYLE );
+ return 0;
+
+
+ default:
+ LDEB(prop); return -1;
+ }
+
+ return 0;
+ }
+/************************************************************************/
+/* */
+/* Return the sum of the other widths in a section with explicit */
+/* column layout. Additionally, assign a victim whose column width can */
+/* be narrowed to allocate extra space. */
+/* */
+/* The maximum value is the value that leaves MIN_COL_WIDE as the */
+/* column width of the victim. */
+/* */
+/************************************************************************/
+
+static int docSectColsSumOthers( int * pVictim,
+ int * pMaxValue,
+ const SectionProperties * sp,
+ int col,
+ int colOther )
+ {
+ const DocumentGeometry * dg= &(sp->spDocumentGeometry);
+ int pageWide;
+
+ int sumOthers= 0;
+ int i;
+
+ int victim;
+ int left;
+
+ pageWide= dg->dgPageWideTwips-
+ dg->dgLeftMarginTwips- dg->dgRightMarginTwips;
+
+ for ( i= 0; i < sp->spColumnCount- 1; i++ )
+ {
+ if ( i == col )
+ { continue; }
+
+ sumOthers += sp->spColumns[i].scColumnWidthTwips;
+ sumOthers += sp->spColumns[i].scSpaceToRightTwips;
+ }
+
+ if ( i != col )
+ { sumOthers += sp->spColumns[i].scColumnWidthTwips; }
+
+ sumOthers += colOther;
+
+ if ( col == sp->spColumnCount- 1 )
+ { victim= sp->spColumnCount-2; }
+ else{ victim= sp->spColumnCount-1; }
+
+ left= sp->spColumns[victim].scColumnWidthTwips- MIN_COL_WIDE;
+
+ if ( pVictim )
+ { *pVictim= victim; }
+ if ( pMaxValue )
+ { *pMaxValue= pageWide- sumOthers+ left; }
+
+ return sumOthers;
+ }
+
+/************************************************************************/
+/* */
+/* Claim extra space by subtracting it from the column width of the */
+/* victim. Applies for explicit column layout only. */
+/* */
+/************************************************************************/
+
+static int docSectReserveWidth( SectionProperties * sp,
+ int victim,
+ int sumValues )
+ {
+ const DocumentGeometry * dg= &(sp->spDocumentGeometry);
+ int pageWide;
+
+ pageWide= dg->dgPageWideTwips-
+ dg->dgLeftMarginTwips- dg->dgRightMarginTwips;
+
+ if ( sumValues > pageWide )
+ {
+ int narrowed;
+
+ narrowed= pageWide- sumValues+ sp->spColumns[victim].scColumnWidthTwips;
+ if ( narrowed < MIN_COL_WIDE )
+ { LDEB(narrowed); return -1; }
+
+ sp->spColumns[victim].scColumnWidthTwips= narrowed;
+ }
+
+ return 0;
+ }
+
+/************************************************************************/
+
+static void docSectGetEqualWidths(
+ int * pColWide,
+ int * pGapWide,
+ int * pMaxColWide,
+ int * pMaxGapWide,
+ const SectionProperties * sp )
+ {
+ const DocumentGeometry * dg= &(sp->spDocumentGeometry);
+ int pageWide;
+
+ int colWide;
+ int maxColWide;
+ int gapWide;
+ int maxGapWide;
+
+ int ncol= sp->spColumnCount;
+ int ngap= sp->spColumnCount- 1;
+
+ pageWide= dg->dgPageWideTwips-
+ dg->dgLeftMarginTwips- dg->dgRightMarginTwips;
+
+ colWide= ( pageWide- ngap* sp->spColumnSpacingTwips )/ ncol;
+ maxColWide= ( pageWide- ngap* MIN_GAP_WIDE )/ ncol;
+
+ gapWide= sp->spColumnSpacingTwips;
+ if ( ngap == 0 )
+ { maxGapWide= 0; }
+ else{ maxGapWide= ( pageWide- ncol* MIN_COL_WIDE )/ ngap; }
+
+ if ( pColWide )
+ { *pColWide= colWide; }
+ if ( pGapWide )
+ { *pGapWide= gapWide; }
+ if ( pMaxColWide )
+ { *pMaxColWide= maxColWide; }
+ if ( pMaxGapWide )
+ { *pMaxGapWide= maxGapWide; }
+
+ return;
+ }
+
+/************************************************************************/
+/* */
+/* Get the spacing right of a column. */
+/* */
+/************************************************************************/
+
+int docSectGetColumnSpacing( int * pMinValue,
+ int * pMaxValue,
+ const SectionProperties * sp,
+ int col )
+ {
+ int value;
+ int maxValue;
+
+ int haveFixedWidth;
+
+ haveFixedWidth= docSectPropsFixedWidthColumns( sp );
+
+ if ( haveFixedWidth )
+ { docSectGetEqualWidths( (int *)0, &value, (int *)0, &maxValue, sp ); }
+ else{
+ docSectColsSumOthers( (int *)0, &maxValue,
+ sp, col, sp->spColumns[col].scColumnWidthTwips );
+
+ value= sp->spColumns[col].scSpaceToRightTwips;
+ }
+
+ if ( pMaxValue )
+ { *pMaxValue= maxValue; }
+ if ( pMinValue )
+ { *pMinValue= MIN_GAP_WIDE; }
+
+ return value;
+ }
+
+/************************************************************************/
+/* */
+/* Set the spacing right of a column. */
+/* */
+/************************************************************************/
+
+int docSectSetColumnSpacing( SectionProperties * sp,
+ int col,
+ int newValue )
+ {
+ int maxValue;
+ int haveFixedWidth;
+
+ haveFixedWidth= docSectPropsFixedWidthColumns( sp );
+
+ if ( haveFixedWidth )
+ {
+ if ( col > 0 )
+ { LLLDEB(haveFixedWidth,col,newValue); return -1; }
+
+ docSectGetEqualWidths( (int *)0, (int *)0, (int *)0, &maxValue, sp );
+ if ( newValue < MIN_GAP_WIDE || newValue > maxValue )
+ { LLDEB(newValue,maxValue); return -1; }
+
+ sp->spColumnSpacingTwips= newValue;
+ }
+ else{
+ int victim;
+ int sumOthers;
+
+ sumOthers= docSectColsSumOthers( &victim, &maxValue,
+ sp, col, sp->spColumns[col].scColumnWidthTwips );
+
+ if ( newValue < MIN_GAP_WIDE || newValue > maxValue )
+ { LLDEB(newValue,maxValue); return -1; }
+ if ( victim == col )
+ { LLDEB(victim,col); return -1; }
+
+ if ( docSectReserveWidth( sp, victim, sumOthers+ newValue ) )
+ { LLDEB(sumOthers,newValue); return -1; }
+
+ sp->spColumns[col].scSpaceToRightTwips= newValue;
+ }
+
+ return 0;
+ }
+
+/************************************************************************/
+/* */
+/* Get the spacing right of a column. */
+/* */
+/************************************************************************/
+
+int docSectGetColumnWidth( int * pMinValue,
+ int * pMaxValue,
+ const SectionProperties * sp,
+ int col )
+ {
+ int value;
+ int maxValue;
+
+ int haveFixedWidth;
+
+ haveFixedWidth= docSectPropsFixedWidthColumns( sp );
+
+ if ( haveFixedWidth )
+ {
+ docSectGetEqualWidths( &value, (int *)0, &maxValue, (int *)0, sp );
+ }
+ else{
+ docSectColsSumOthers( (int *)0, &maxValue,
+ sp, col, sp->spColumns[col].scSpaceToRightTwips );
+
+ value= sp->spColumns[col].scColumnWidthTwips;
+ }
+
+ if ( pMinValue )
+ { *pMinValue= MIN_COL_WIDE; }
+ if ( pMaxValue )
+ { *pMaxValue= maxValue; }
+
+ return value;
+ }
+
+/************************************************************************/
+/* */
+/* Set the spacing right of a column. */
+/* */
+/************************************************************************/
+
+int docSectSetColumnWidth( SectionProperties * sp,
+ int col,
+ int newValue )
+ {
+ int maxValue;
+ int haveFixedWidth;
+
+ haveFixedWidth= docSectPropsFixedWidthColumns( sp );
+
+ if ( haveFixedWidth )
+ {
+ const DocumentGeometry * dg= &(sp->spDocumentGeometry);
+ int pageWide;
+ int gapWide;
+
+ docSectGetEqualWidths( (int *)0, &gapWide, &maxValue, (int *)0, sp );
+
+ if ( newValue < MIN_COL_WIDE || newValue > maxValue )
+ { LLDEB(newValue,maxValue); return -1; }
+
+ pageWide= dg->dgPageWideTwips-
+ dg->dgLeftMarginTwips- dg->dgRightMarginTwips;
+
+ gapWide= ( pageWide- ( sp->spColumnCount* newValue ) )/
+ ( sp->spColumnCount- 1 );
+ if ( gapWide < MIN_GAP_WIDE )
+ { LLDEB(gapWide,MIN_GAP_WIDE); gapWide= MIN_GAP_WIDE; }
+
+ sp->spColumnSpacingTwips= gapWide;
+ }
+ else{
+ int victim;
+ int sumOthers;
+
+ sumOthers= docSectColsSumOthers( &victim, &maxValue,
+ sp, col, sp->spColumns[col].scSpaceToRightTwips );
+
+ if ( newValue < MIN_COL_WIDE || newValue > maxValue )
+ { LLDEB(newValue,maxValue); return -1; }
+ if ( victim == col )
+ { LLDEB(victim,col); return -1; }
+
+ if ( docSectReserveWidth( sp, victim, sumOthers+ newValue ) )
+ { LLDEB(sumOthers,newValue); return -1; }
+
+ sp->spColumns[col].scColumnWidthTwips= newValue;
+ }
+
+ return 0;
+ }
diff --git a/office/Ted/slack-desc b/office/Ted/slack-desc
index f9d6b30491..69a49e26e1 100644
--- a/office/Ted/slack-desc
+++ b/office/Ted/slack-desc
@@ -10,7 +10,7 @@ Ted: Ted (a lightweight WYSIWYG wordprocessor)
Ted:
Ted: Ted is a lightweight wordprocessor that emphasizes simplicity,
Ted: but with many features.
-Ted: There are additional packages for different languages
+Ted: There are additional packages for different languages
Ted: to be found on the hompage. Ted is simple to use and easily compiled.
Ted: It starts up quickly.
Ted:
diff --git a/office/Ted/ted-2.21-libpng15.patch b/office/Ted/ted-2.21-libpng15.patch
deleted file mode 100644
index afd30f9a42..0000000000
--- a/office/Ted/ted-2.21-libpng15.patch
+++ /dev/null
@@ -1,423 +0,0 @@
-This patch is from netbsd pkgsrc
-
-ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/editors/ted/patches/
-
---- bitmap/bmpng.c
-+++ bitmap/bmpng.c
-@@ -20,23 +20,32 @@
- /* */
- /************************************************************************/
-
--static int bpPngiToBitmap( const png_info * pngi,
-+static int bpPngiToBitmap( const png_structp pngp,
-+ png_info * pngi,
- BitmapDescription * bd )
- {
- unsigned int col;
-+ png_uint_32 res_x, res_y;
-+ int unit_type= 0;
-
-- bd->bdPixelsWide= pngi->width;
-- bd->bdPixelsHigh= pngi->height;
-+ bd->bdPixelsWide= png_get_image_width( pngp, pngi );
-+ bd->bdPixelsHigh= png_get_image_height( pngp, pngi );
- bd->bdHasAlpha= 0;
-
-- switch( pngi->color_type )
-+ switch( png_get_color_type( pngp, pngi ) )
- {
- case PNG_COLOR_TYPE_PALETTE:
-+ {
-+ int num_palette;
-+ png_colorp palette;
-+
-+ png_get_PLTE( pngp, pngi, &palette, &num_palette );
-+
- bd->bdColorEncoding= BMcoRGB8PALETTE;
-- bd->bdColorCount= pngi->num_palette;
-+ bd->bdColorCount= num_palette;
- bd->bdBitsPerSample= 8;
- bd->bdSamplesPerPixel= 3;
-- bd->bdBitsPerPixel= pngi->bit_depth;
-+ bd->bdBitsPerPixel= png_get_bit_depth( pngp, pngi );
-
- bd->bdRGB8Palette= (RGB8Color *)
- malloc( bd->bdColorCount* sizeof(RGB8Color) );
-@@ -46,47 +55,51 @@ static int bpPngiToBitmap( const png_inf
-
- for ( col= 0; col < bd->bdColorCount; col++ )
- {
-- bd->bdRGB8Palette[col].rgb8Red= pngi->palette[col].red;
-- bd->bdRGB8Palette[col].rgb8Green= pngi->palette[col].green;
-- bd->bdRGB8Palette[col].rgb8Blue= pngi->palette[col].blue;
-+ bd->bdRGB8Palette[col].rgb8Red= palette[col].red;
-+ bd->bdRGB8Palette[col].rgb8Green= palette[col].green;
-+ bd->bdRGB8Palette[col].rgb8Blue= palette[col].blue;
- bd->bdRGB8Palette[col].rgb8Alpha= 0;
- }
-+ }
- break;
-
- case PNG_COLOR_TYPE_RGB:
- bd->bdColorEncoding= BMcoRGB;
-- bd->bdBitsPerSample= pngi->bit_depth;
-- bd->bdSamplesPerPixel= pngi->channels;
-- bd->bdBitsPerPixel= pngi->pixel_depth;
-+ bd->bdBitsPerSample= png_get_bit_depth( pngp, pngi );
-+ bd->bdSamplesPerPixel= png_get_channels( pngp, pngi );
-+ bd->bdBitsPerPixel= bd->bdSamplesPerPixel* bd->bdBitsPerSample;
- break;
-
- case PNG_COLOR_TYPE_GRAY:
- bd->bdColorEncoding= BMcoWHITEBLACK;
-- bd->bdBitsPerSample= pngi->bit_depth;
-- bd->bdSamplesPerPixel= pngi->channels;
-- bd->bdBitsPerPixel= pngi->pixel_depth;
-+ bd->bdBitsPerSample= png_get_bit_depth( pngp, pngi );
-+ bd->bdSamplesPerPixel= png_get_channels( pngp, pngi );
-+ bd->bdBitsPerPixel= bd->bdSamplesPerPixel* bd->bdBitsPerSample;
- break;
-
- case PNG_COLOR_TYPE_RGB_ALPHA:
- bd->bdHasAlpha= 1;
- bd->bdColorEncoding= BMcoRGB;
-- bd->bdBitsPerSample= pngi->bit_depth;
-- bd->bdSamplesPerPixel= pngi->channels;
-- bd->bdBitsPerPixel= pngi->pixel_depth;
-+ bd->bdBitsPerSample= png_get_bit_depth( pngp, pngi );
-+ bd->bdSamplesPerPixel= png_get_channels( pngp, pngi );
-+ bd->bdBitsPerPixel= bd->bdSamplesPerPixel* bd->bdBitsPerSample;
- break;
-
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- bd->bdHasAlpha= 1;
-- LDEB(pngi->color_type); return -1;
-+ LDEB(png_get_color_type( pngp, pngi )); return -1;
-
- default:
-- LDEB(pngi->color_type); return -1;
-+ LDEB(png_get_color_type( pngp, pngi )); return -1;
- }
-
-- bd->bdBytesPerRow= pngi->rowbytes;
-+ bd->bdBytesPerRow= png_get_rowbytes( pngp, pngi );
- bd->bdBufferLength= bd->bdBytesPerRow* bd->bdPixelsHigh;
-
-- switch( pngi->phys_unit_type )
-+ if ( ! png_get_pHYs( pngp, pngi, &res_x, &res_y, &unit_type ) )
-+ { unit_type= PNG_RESOLUTION_UNKNOWN; }
-+
-+ switch( unit_type )
- {
- case PNG_RESOLUTION_UNKNOWN:
- bd->bdUnit= BMunPIXEL;
-@@ -96,12 +109,12 @@ static int bpPngiToBitmap( const png_inf
-
- case PNG_RESOLUTION_METER:
- bd->bdUnit= BMunM;
-- bd->bdXResolution= pngi->x_pixels_per_unit;
-- bd->bdYResolution= pngi->y_pixels_per_unit;
-+ bd->bdXResolution= res_x;
-+ bd->bdYResolution= res_y;
- break;
-
- default:
-- LDEB(pngi->phys_unit_type);
-+ LDEB(unit_type);
- return -1;
- }
-
-@@ -119,11 +132,11 @@ static int bmPngReadContents( png_info *
- unsigned char * buffer;
-
- numberOfPasses= 1;
-- if ( pngi->interlace_type )
-+ if ( png_get_interlace_type( png, pngi ) )
- { numberOfPasses= png_set_interlace_handling( png ); }
-
-- if ( pngi->color_type == PNG_COLOR_TYPE_RGB &&
-- pngi->bit_depth == 16 )
-+ if ( png_get_color_type( png, pngi ) == PNG_COLOR_TYPE_RGB &&
-+ png_get_bit_depth( png, pngi ) == 16 )
- {
- const unsigned short one= 1;
- const unsigned char * testEndian= (const unsigned char *)&one;
-@@ -133,9 +146,6 @@ static int bmPngReadContents( png_info *
- }
-
- png_start_read_image( png );
-- /*
-- png_read_update_info( png, pngi );
-- */
-
- buffer= (unsigned char *)malloc( bd->bdBufferLength );
- if ( ! buffer )
-@@ -236,9 +246,9 @@ int bmPngReadPng( BitmapDescription * bd
-
- png_read_info( pngp, pngip );
-
-- if ( bpPngiToBitmap( pngip, bd ) )
-+ if ( bpPngiToBitmap( pngp, pngip, bd ) )
- {
-- LLLDEB(pngip->color_type,bd->bdColorCount,bd->bdRGB8Palette);
-+ LLDEB(bd->bdColorCount,bd->bdRGB8Palette);
- png_destroy_read_struct( &pngp, &pngip, (png_infop *)0 );
- return -1;
- }
-@@ -282,44 +292,43 @@ int bmCanWritePngFile( const BitmapDescr
-
- static int bpPngiFromBitmap( png_structp png,
- png_info * pngi,
-+ png_colorp * pPalette,
- const BitmapDescription * bd )
- {
-- png_info_init( pngi );
-- pngi->width= bd->bdPixelsWide;
-- pngi->height= bd->bdPixelsHigh;
-+ int bit_depth;
-+ int color_type;
-+ png_color_8 sig_bit;
-
- switch( bd->bdUnit )
- {
- case BMunM:
-- pngi->phys_unit_type= PNG_RESOLUTION_METER;
-- pngi->x_pixels_per_unit= bd->bdXResolution;
-- pngi->y_pixels_per_unit= bd->bdYResolution;
-- pngi->valid |= PNG_INFO_pHYs;
-+ png_set_pHYs( png, pngi,
-+ bd->bdXResolution,
-+ bd->bdYResolution,
-+ PNG_RESOLUTION_METER);
- break;
-
- case BMunINCH:
-- pngi->phys_unit_type= PNG_RESOLUTION_METER;
-- pngi->x_pixels_per_unit= (int)( 39.37* bd->bdXResolution );
-- pngi->y_pixels_per_unit= (int)( 39.37* bd->bdYResolution );
-- pngi->valid |= PNG_INFO_pHYs;
-+ png_set_pHYs( png, pngi,
-+ (int)( 39.37* bd->bdXResolution ),
-+ (int)( 39.37* bd->bdYResolution ),
-+ PNG_RESOLUTION_METER);
- break;
-
- case BMunPOINT:
-- pngi->phys_unit_type= PNG_RESOLUTION_METER;
-- pngi->x_pixels_per_unit= POINTS_PER_M* bd->bdXResolution;
-- pngi->y_pixels_per_unit= POINTS_PER_M* bd->bdYResolution;
-- pngi->valid |= PNG_INFO_pHYs;
-+ png_set_pHYs( png, pngi,
-+ POINTS_PER_M* bd->bdXResolution,
-+ POINTS_PER_M* bd->bdYResolution,
-+ PNG_RESOLUTION_METER);
- break;
-
- case BMunPIXEL:
-- pngi->phys_unit_type= PNG_RESOLUTION_UNKNOWN;
-- pngi->x_pixels_per_unit= 1;
-- pngi->y_pixels_per_unit= 1;
-+ png_set_pHYs(png, pngi, 1, 1, PNG_RESOLUTION_UNKNOWN);
- break;
-
- default:
- LDEB(bd->bdUnit);
-- pngi->phys_unit_type= PNG_RESOLUTION_UNKNOWN;
-+ png_set_pHYs(png, pngi, 1, 1, PNG_RESOLUTION_UNKNOWN);
- break;
- }
-
-@@ -329,41 +338,48 @@ static int bpPngiFromBitmap( png_structp
-
- case BMcoBLACKWHITE:
- case BMcoWHITEBLACK:
-- pngi->bit_depth= bd->bdBitsPerPixel;
-+ bit_depth= bd->bdBitsPerPixel;
- if ( bd->bdHasAlpha )
-- { pngi->color_type= PNG_COLOR_TYPE_GRAY_ALPHA; }
-- else{ pngi->color_type= PNG_COLOR_TYPE_GRAY; }
-- pngi->sig_bit.gray= bd->bdBitsPerSample;
-+ { color_type= PNG_COLOR_TYPE_GRAY_ALPHA; }
-+ else{ color_type= PNG_COLOR_TYPE_GRAY; }
-+ sig_bit.gray= bd->bdBitsPerSample;
- break;
-
- case BMcoRGB:
-- pngi->bit_depth= bd->bdBitsPerSample;
-+ bit_depth= bd->bdBitsPerSample;
- if ( bd->bdHasAlpha )
-- { pngi->color_type= PNG_COLOR_TYPE_RGB_ALPHA; }
-- else{ pngi->color_type= PNG_COLOR_TYPE_RGB; }
-- pngi->sig_bit.red= bd->bdBitsPerSample;
-- pngi->sig_bit.green= bd->bdBitsPerSample;
-- pngi->sig_bit.blue= bd->bdBitsPerSample;
-+ { color_type= PNG_COLOR_TYPE_RGB_ALPHA; }
-+ else{ color_type= PNG_COLOR_TYPE_RGB; }
-+ sig_bit.red= bd->bdBitsPerSample;
-+ sig_bit.green= bd->bdBitsPerSample;
-+ sig_bit.blue= bd->bdBitsPerSample;
- break;
-
- case BMcoRGB8PALETTE:
-- pngi->bit_depth= bd->bdBitsPerPixel;
-- pngi->color_type= PNG_COLOR_TYPE_PALETTE;
-+ bit_depth= bd->bdBitsPerPixel;
-+ color_type= PNG_COLOR_TYPE_PALETTE;
-
-- pngi->valid |= PNG_INFO_PLTE;
-- pngi->palette= (png_color *)malloc( 256* sizeof( png_color ) );
-- if ( ! pngi->palette )
-- { XDEB(pngi->palette); return -1; }
-- pngi->num_palette= bd->bdColorCount;
-- pngi->sig_bit.red= bd->bdBitsPerSample;
-- pngi->sig_bit.green= bd->bdBitsPerSample;
-- pngi->sig_bit.blue= bd->bdBitsPerSample;
-- for ( i= 0; i < pngi->num_palette; i++ )
-+ if ( bd->bdColorCount > PNG_MAX_PALETTE_LENGTH )
- {
-- pngi->palette[i].red= bd->bdRGB8Palette[i].rgb8Red;
-- pngi->palette[i].green= bd->bdRGB8Palette[i].rgb8Green;
-- pngi->palette[i].blue= bd->bdRGB8Palette[i].rgb8Blue;
-+ LLDEB(bd->bdColorCount,PNG_MAX_PALETTE_LENGTH);
-+ return -1;
- }
-+
-+ *pPalette= (png_color *)malloc( PNG_MAX_PALETTE_LENGTH*
-+ sizeof( png_color ) );
-+ if ( ! *pPalette )
-+ { XDEB(*pPalette); return -1; }
-+ sig_bit.red= bd->bdBitsPerSample;
-+ sig_bit.green= bd->bdBitsPerSample;
-+ sig_bit.blue= bd->bdBitsPerSample;
-+ for ( i= 0; i < bd->bdColorCount; i++ )
-+ {
-+ (*pPalette)[i].red= bd->bdRGB8Palette[i].rgb8Red;
-+ (*pPalette)[i].green= bd->bdRGB8Palette[i].rgb8Green;
-+ (*pPalette)[i].blue= bd->bdRGB8Palette[i].rgb8Blue;
-+ }
-+
-+ png_set_PLTE( png, pngi, (*pPalette), bd->bdColorCount );
- break;
-
- default:
-@@ -371,7 +387,13 @@ static int bpPngiFromBitmap( png_structp
- return -1;
- }
-
-- pngi->interlace_type= 0;
-+ png_set_sBIT( png, pngi, &sig_bit );
-+ png_set_IHDR( png, pngi,
-+ bd->bdPixelsWide, bd->bdPixelsHigh,
-+ bit_depth, color_type,
-+ PNG_INTERLACE_NONE,
-+ PNG_COMPRESSION_TYPE_BASE,
-+ PNG_FILTER_TYPE_BASE );
-
- return 0;
- }
-@@ -395,8 +417,8 @@ static void bmPngWriteContents( png_stru
- }
- }
-
-- if ( pngi->color_type == PNG_COLOR_TYPE_RGB &&
-- bd->bdBitsPerSample == 16 )
-+ if ( png_get_color_type( png, pngi ) == PNG_COLOR_TYPE_RGB &&
-+ bd->bdBitsPerSample == 16 )
- {
- const unsigned short one= 1;
- const unsigned char * testEndian= (const unsigned char *)&one;
-@@ -431,9 +453,9 @@ static void bmPngWriteContents( png_stru
- from= scratch;
- }
-
-- if ( pngi->color_type == PNG_COLOR_TYPE_RGB &&
-- bd->bdBitsPerSample == 16 &&
-- scratch )
-+ if ( png_get_color_type( png, pngi ) == PNG_COLOR_TYPE_RGB &&
-+ bd->bdBitsPerSample == 16 &&
-+ scratch )
- {
- int col;
- const BmUint16 * fr= (const BmUint16 *)from;
-@@ -453,10 +475,6 @@ static void bmPngWriteContents( png_stru
-
- png_write_end( png, pngi );
-
-- if ( bd->bdColorEncoding == BMcoRGB8PALETTE &&
-- pngi->palette )
-- { free( pngi->palette ); }
--
- if ( scratch )
- { free( scratch ); }
-
-@@ -510,50 +528,43 @@ int bmPngWritePng( const BitmapDescript
- const unsigned char * buffer,
- SimpleOutputStream * sos )
- {
-+ int rval= 0;
- png_structp pngp= (png_structp)0;
- png_infop pngip= (png_infop)0;
-+ png_colorp palette= (png_colorp)0;
-
- pngp = png_create_write_struct( PNG_LIBPNG_VER_STRING, (void *)0,
- (png_error_ptr)0, (png_error_ptr)0 );
- if ( ! pngp )
-- { LDEB(1); return -1; }
-+ { XDEB(pngp); rval= -1; goto ready; }
-
- pngip = png_create_info_struct( pngp );
- if ( ! pngip )
-- {
-- LDEB(1);
-- png_destroy_write_struct( &pngp, (png_infop *)0 );
-- return -1;
-- }
-+ { XDEB(pngip); rval= -1; goto ready; }
-+
-+ /*
-+ As the info struct is built by libpng this is not needed:
-+ (The call will disappear from libpng in version 1.4)
-+ png_info_init( pngi );
-+ */
-
- if ( setjmp( png_jmpbuf( pngp ) ) )
-- {
-- LDEB(1);
-- png_destroy_write_struct( &pngp, &pngip );
-- /* Crashes:
-- if ( bd->bdColorEncoding == BMcoRGB8PALETTE &&
-- pngip->palette )
-- { free( pngip->palette ); }
-- */
-- return -1;
-- }
-+ { LDEB(1); rval= -1; goto ready; }
-
- png_init_io( pngp, (FILE *)0 );
- png_set_write_fn( pngp, (void *)sos, bmPngWriteBytes, bmPngFlushBytes );
-
-- if ( bpPngiFromBitmap( pngp, pngip, bd ) )
-- {
-- LDEB(bd->bdColorEncoding);
-- png_destroy_write_struct( &pngp, &pngip );
-- return -1;
-- }
--
-- /*
-- png_write_info( pngp, pngip );
-- */
-+ if ( bpPngiFromBitmap( pngp, pngip, &palette, bd ) )
-+ { LDEB(bd->bdColorEncoding); rval= -1; goto ready; }
-
- bmPngWriteContents( pngp, pngip, buffer, bd );
-
-+ ready:
-+
-+ if ( palette )
-+ { free( palette ); }
-+
- png_destroy_write_struct( &pngp, &pngip );
-- return 0;
-+
-+ return rval;
- }