Re: commit - Word importer improvements

Paul Rohr (paul@abisource.com)
Fri, 23 Jul 1999 11:49:08 -0700


At 03:50 AM 7/23/99 -0500, Justin Bradford wrote:
>I've added support for more paragraph properties in the Word importer,
>so it will now handle line spacing (such as double-spaced text), and
>should handle margins on the paragraph, including indentation and the top
>margin. I don't know what the Abiword property is for bottom margins (or
>whether it exists at all).

Uh, that would be the cleverly named margin-bottom property. ;-)

M src/wp/impexp/xp/ie_imp_MsWord_97.cpp

Fixed, I think. Unfortunately, of the two importer test cases in
abi/test/wp, Word97Test.doc is a meager subset of rtftest.rtf, and without a
copy of Word on this machine, I wasn't able to test the change.

Could someone with access to a copy of Word update the test case for a more
complete set of paragraph properties (see below)?

For future reference, the default values for all defined properties are
listed in the following file:

abi/src/text/ptbl/xp/pp_Property.cpp

>I believe that covers the current Abiword functionality in paragraph
>properties,

Actually, from a quick look at fl_BlockLayout::_lookupProperties(), you
probably also want to add support for non-default values of the following
properties:

orphans
widows
keep-together
keep-with-next
tabstops
default-tab-interval

In addition, when you're ready to start supporting named styles in the
importer, each block also has an optional PT_STYLE_ATTRIBUTE_NAME (==
"style") attribute. We don't have a UI for editing styles yet, but I'm
fairly sure the property lookup and inheritance mechanisms work just fine.
For a sample document, see:

abi/test/wp/Styles.abw

Finally, I also noticed the following fragment at line 193 of the importer:

// line spacing (single-spaced, double-spaced, etc.)
if (apap->lspd.fMultLinespace) {
strcat(propBuffer, "line-height:");
sprintf(propBuffer + strlen(propBuffer),
"%1.1f;", (((float)apap->lspd.dyaLine) / 240));
} else {
// I'm not sure Abiword currently handles the other method
// which requires setting the height of the lines exactly
}

You're quite right, but it shouldn't be hard to deal with. At the moment,
the matching fragments of code would be:

abi/src/text/fmt/xp/fl_BlockLayout.cpp, line 334:

// for now, just allow fixed multiples
// TODO: if units were used, convert to exact spacing required
m_dLineSpacing = atof(getProperty("line-height"));
m_bExactSpacing = UT_FALSE;

abi/src/text/fmt/xp/fp_Line.cpp, line 331:

{
// adjust line height to include leading
double dLineSpace;
UT_Bool bExact;
m_pBlock->getLineSpacing(dLineSpace, bExact);

if (bExact)
iNewHeight += (UT_sint32) dLineSpace;
else
iNewHeight = (UT_sint32) (iNewHeight * dLineSpace);
}

Fix that first TODO, and you'll be all set. :-)

>so section properties are next...

Cool. :-) I'm suspect that the section properties may be skimpier than
they should be, so if you run across properties that we're missing, post a
summary to the list and Eric or I will show you where and how to add them to
AbiWord.

Even if the formatter doesn't support them yet, we may as well define what
the relevant properties are so that they'll be in the file format and we
won't lose the information.

Wherever possible, it'd be nice if importing wasn't a lossy process. (Ditto
for exporting.) It even puts pressure where it belongs -- on the missing
layout and UI code. :-)

Paul
motto -- grep is my friend, I use it every day



This archive was generated by hypermail 1.03b2.