Issue 79169 - WW8: Import loses font on macro button fields
Summary: WW8: Import loses font on macro button fields
Alias: None
Product: Writer
Classification: Application
Component: open-import (show other issues)
Version: 680m217
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: michael.ruess
QA Contact: issues@sw
Depends on:
Reported: 2007-07-03 16:35 UTC by openoffice
Modified: 2013-08-07 14:42 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

test document (21.50 KB, application/msword)
2007-07-03 16:38 UTC, openoffice
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description openoffice 2007-07-03 16:35:50 UTC
Import attached document. The font of the macro buttons is not imported.
Comment 1 openoffice 2007-07-03 16:38:14 UTC
Created attachment 46492 [details]
test document
Comment 2 openoffice 2007-07-03 16:39:36 UTC
Comment 3 openoffice 2007-07-03 16:45:36 UTC

I tried to fix this in Read_F_Macro by calling ReadTextAttr at the CP of the
macro buttons text - no success. Do you have an idea how to fix this without a
nasty global variable hack?
Comment 4 openoffice 2007-07-03 16:49:12 UTC
Comment 5 caolanm 2007-07-03 17:00:53 UTC
I don't have a solution right now, not even a working copy of msword :-), but
for some hacking possibilities, if you experimentally make
SwWW8ImplReader::Read_F_Macro return FLD_TEXT instead of FLD_OK does the macro
button text appear inline in the document with the correct font then ?, with the
field text visible as plaintext.
Comment 6 fridrich.strba 2007-07-03 17:16:48 UTC
Changing the module
Comment 7 fridrich.strba 2007-07-03 17:17:14 UTC
Comment 8 openoffice 2007-07-04 09:02:07 UTC
hb->cmc: The approach to return FLD_TEXT does not change the result. Further
investigation reveals that there is no field result and the font sprms span only
over the button text. So what needs to be done is to first analyze that all the
button text is attributed with exactly one set of sprms. Second you have to
apply the according SfxItemSet to the PAM of the inserted field. Is there a
function that reads the sprms like ReadTextAttr but returns an SfxItemSet
instead of applying the sprms in the SwDoc? If so, I could save the SfxItemSet
for the button text and apply it after the field was inserted to the SwDoc.
Comment 9 caolanm 2007-07-04 12:19:36 UTC
Maybe setting pAktItemSet to a temporary itemset at the right place, and
deleting it when done with it might help accumulate what you need. Search for
pAktItemSet, it is used for the "dropcap" hack which might be similar enough in
needs to be helpful.
Comment 10 openoffice 2007-07-05 13:12:40 UTC

I tried something like this:

struct WW8PostProcessAttrsInfo
    WW8_CP mnCpStart;
    WW8_CP mnCpEnd;
    SwPaM mPaM;

    WW8PostProcessAttrsInfo(WW8_CP nCpStart, WW8_CP nCpEnd, SwPaM & rPaM);

void SwWW8ImplReader::PostProcessAttrs()
    if (mpPostProcessAttrsInfo != NULL)
        WW8_CP nOldCp = pPlcxMan->Where();

        printf("PostProcessAttrs: %d\n", nOldCp);

        SfxItemSet * pTmpItemSet = pAktItemSet;
        pAktItemSet = new SfxItemSet( rDoc.GetAttrPool(), RES_CHRATR_BEGIN, 
                                      RES_PARATR_END - 1 );                

        printf("PostProcessAttrs before ReadAttrs: %d\n", pPlcxMan->Where());
        bool bStartLine = false;
        WW8_CP nCpStart = mpPostProcessAttrsInfo->mnCpStart;
        WW8_CP nCpEnd = mpPostProcessAttrsInfo->mnCpEnd;
        ReadAttrs(nCpStart, nCpEnd, bStartLine);

        printf("PostProcessAttrs after ReadAttrs: %d\n", nOldCp);
        printf("%d, %d, ", mpPostProcessAttrsInfo->mnCpStart, 

        rDoc.Insert(mpPostProcessAttrsInfo->mPaM, *pAktItemSet, 0);

        delete pAktItemSet;
        pAktItemSet = pTmpItemSet;

        delete mpPostProcessAttrsInfo;
        mpPostProcessAttrsInfo = NULL;

mpPostProcessAttrsInfo is generated in Read_F_Macro and PostProcessAttrs is
called after ReadAttrs is finished. I double-checked with the dumping service of
the new writerfilter, that I get the right CPs in mpPostProcessAttrsInfo to
catch the font attributes over the macro button text. But, the temporary
pAktItemSet resulting from the ReadAttrs in PostProcessAttrs is empty. :-( I
have no clue why that is, do you? 
Comment 11 caolanm 2007-07-05 13:45:06 UTC
The theory looks good, I guess you'll have to debug a sample property like bold
or something simple and break on Read_BoldUsw when pAktItemSet is true to see if
it's getting parsed at all.

Things are sort of designed (I use that word loosely) for streaming through a
document in order of ascending logical character position, not generally for
jumping around the place in logical character position space, because it's
really hard to do "complex format" word document parsing. So the typical model
of use is to go through the document in order of the text and push data on event
start and pop it and use it on event end.

So it *might* be that you need to save the stage of "pPlcxMan" and seek it back
to the starting cp, do your work and restore it. So maybe something like this
might be needed...

WW8PLCFxSaveAll aSave;
pPlcxMan->SaveAllPLCFx( aSave );



pPlcxMan->RestoreAllPLCFx( aSave );

or alternatively, a new pPlcxMan constructed to start at nCpStart. Hope that helps.
Comment 12 openoffice 2007-07-09 14:33:27 UTC
/cvs/sw/sw/source/filter/ww8/ww8par.hxx,v  <--  ww8par.hxx
new revision:; previous revision:
Checking in ww8par.cxx;
/cvs/sw/sw/source/filter/ww8/ww8par.cxx,v  <--  ww8par.cxx
new revision:; previous revision: 1.177
Checking in ww8par5.cxx;
/cvs/sw/sw/source/filter/ww8/ww8par5.cxx,v  <--  ww8par5.cxx
new revision:; previous revision: 1.102
Checking in ww8par6.cxx;
/cvs/sw/sw/source/filter/ww8/ww8par6.cxx,v  <--  ww8par6.cxx
new revision:; previous revision:
Comment 13 openoffice 2007-07-11 13:11:30 UTC
ready for QA
Comment 14 michael.ruess 2007-07-13 09:34:47 UTC
Verified in CWS swqbf100.
Comment 15 michael.ruess 2007-07-26 09:34:09 UTC
Checked fix in SRC680m222.