summaryrefslogtreecommitdiff
path: root/office
diff options
context:
space:
mode:
authorWilly Sudiarto Raharjo <willysr@slackbuilds.org>2014-05-27 08:07:53 -0500
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2014-05-29 06:30:07 +0700
commit7589a91a81b5db507aa0e966f719a5a37792dc32 (patch)
treefad6d0f448f8f977ca71a9a29c2c97dcc94dfe6b /office
parentebd8b7fd7274e4984d0fcace02cf1df2aa6f8af8 (diff)
downloadslackbuilds-7589a91a81b5db507aa0e966f719a5a37792dc32.tar.gz
office/Ted: Updated for version 2.23, new maintainer.
Signed-off-by: Erik Hanson <erik@slackbuilds.org>
Diffstat (limited to 'office')
-rw-r--r--office/Ted/README6
-rw-r--r--office/Ted/Ted.SlackBuild66
-rw-r--r--office/Ted/Ted.desktop17
-rw-r--r--office/Ted/Ted.info12
-rw-r--r--office/Ted/docSectProperties.c1105
5 files changed, 40 insertions, 1166 deletions
diff --git a/office/Ted/README b/office/Ted/README
index 36d2faa814..a7bbcdbbc2 100644
--- a/office/Ted/README
+++ b/office/Ted/README
@@ -5,10 +5,4 @@ is easily compiled.
Additional packages with spellcheckers for different languages exist and
can be downloaded from the Ted homepage.
-Ted can be compiled with different toolkits, which defaults to GTK. To
-define another toolkit (Choices are GTK, MOTIF and QT), you can specify
-this on the commandline:
-
-TOOLKIT=MOTIF ./Ted.SlackBuild
-
Note: This application doesn't work with Windowmaker
diff --git a/office/Ted/Ted.SlackBuild b/office/Ted/Ted.SlackBuild
index 18d6962745..4b5f511e03 100644
--- a/office/Ted/Ted.SlackBuild
+++ b/office/Ted/Ted.SlackBuild
@@ -1,10 +1,9 @@
#!/bin/sh
# Slackware build script for Ted
-# and edited by Hannes Worst <hannesworst@gmail.com>.
-# Copyright by Hannes Worst
-#--
-# Last edited: 01-05-2012
+# Originally written by Hannes Worst <hannesworst@gmail.com>.
+# Copyright 2014 Willy Sudiarto Raharjo <willysr@slackbuilds.org>
+# All right reserved
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
@@ -12,7 +11,7 @@
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR IMPLIED
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@@ -23,11 +22,8 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# 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.22}
+VERSION=${VERSION:-2.23}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
@@ -44,18 +40,20 @@ TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
-TOOLKIT=${TOOLKIT:-GTK}
SRCNAM=$(echo $PRGNAM | tr T t)
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
+ MARCH=i386
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
+ MARCH=i386
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
+ MARCH=amd64
fi
set -e
@@ -65,18 +63,13 @@ 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 -L . \
- \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
- -exec chmod 755 {} \; -o \
- \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
- -exec chmod 644 {} \;
-
-# 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
+ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
+ -o -perm 511 \) -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
+ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
# Set the right ARCH
sed \
@@ -86,27 +79,36 @@ sed \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
-make
-make package.shared DESTDIR=$PKG CONFIGURE_OPTIONS="--with-$TOOLKIT \
- --prefix=/usr/share/$PRGNAM --bindir=/usr/bin \
- --build=$ARCH-slackware-linux"
-
-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
+make -j1
+make -j1 package
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
+# Extract the created package by make package
+tar -xvf $TMP/$PRGNAM-$VERSION/${SRCNAM}Package/$SRCNAM-$VERSION-linux-$MARCH.tar.gz -C $PKG/
+
+mkdir -p $PKG/usr/man/man1/
+mv $PKG/usr/share/Ted/doc/*.1 $PKG/usr/man/man1/
+rm -rf $PKG/usr/share/Ted/doc/
+
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
+
+# This one is already in .gz format
+mv $PKG/usr/share/man/man1/Ted.1.gz $PKG/usr/man/man1/
+rm -rf $PKG/usr/share/man/
+
+# a couple of useful scripts to fix and convert documents
+for F in `ls $PKG/usr/share/Ted/examples/`
+do
+ mv $PKG/usr/share/Ted/examples/$F $PKG/usr/bin/$(basename -s .sh $F)
+done
+rm -rf $PKG/usr/share/Ted/examples
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
-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
+mv $PKG/usr/share/Ted/config/ $PKG/usr/doc/$PRGNAM-$VERSION/
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
diff --git a/office/Ted/Ted.desktop b/office/Ted/Ted.desktop
deleted file mode 100644
index 2471ce9943..0000000000
--- a/office/Ted/Ted.desktop
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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 2066d64f84..f135c6bac6 100644
--- a/office/Ted/Ted.info
+++ b/office/Ted/Ted.info
@@ -1,10 +1,10 @@
PRGNAM="Ted"
-VERSION="2.22"
+VERSION="2.23"
HOMEPAGE="http://www.nllgg.nl/Ted/"
-DOWNLOAD="ftp://ftp.nluug.nl/pub/editors/ted/ted-2.22.src.tar.gz"
-MD5SUM="08162c9164dfdde1d46e41ae64df16be"
+DOWNLOAD="http://ftp.nluug.nl/pub/editors/ted/ted-2.23.src.tar.gz"
+MD5SUM="4199df0deb82a90450135ec3f2b7d915"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
-REQUIRES=""
-MAINTAINER="Hannes Worst"
-EMAIL="hannesworst@gmail.com"
+REQUIRES="libpaper"
+MAINTAINER="Willy Sudiarto Raharjo"
+EMAIL="willysr@slackbuilds.org"
diff --git a/office/Ted/docSectProperties.c b/office/Ted/docSectProperties.c
deleted file mode 100644
index e85ae188e3..0000000000
--- a/office/Ted/docSectProperties.c
+++ /dev/null
@@ -1,1105 +0,0 @@
-/************************************************************************/
-/* */
-/* 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;
- }