On Tue, 2011-04-26 at 11:43 +1000, Martin Sevior wrote:
> Hi Ben,
>
> To be clear, do you want a method:
>
> const char * PD_Document::getDefaultStyle()
>
> That returns the name of the default style in the document?
Mostly what I'm wanting is a method that returns the default value for a
given property. So for example I can ask what is the default for
"text-decoration".
If the default style can be obtained for the document as above, and
assuming it explicitly lists each of the property values then I should
be able to use that.
A walk through of a specific case might help. Assuming that an ODF with
change tracking has these two styles, R3 = italic and bold, R5 = bold.
On initial loading I get the following RevisionAttribute:
!3{font-style:italic;font-weight:bold}
!5{ font-weight:bold}
This is because the ODF just cites styles which it wants. Each cited
style is complete and just lists what it has relative to nothing.
What abiword wants here in .abw lingo is however
!3{font-style:italic;font-weight:bold}
!5{font-style:normal}
ie, that in revision 5 the bolding is not changed, but the text is no
longer italic. This is due to the ODF using explicit styles for spans,
instead of just listing the individual changes as abiword wants.
ctSimplifyStyles() will drop out the second font-weight as it is
superfluous. The text remains bold in revision 5 as it was before. The
code will notice that font-style is not listed for revision 5 and then
need to set that property to the default value, in this case
font-style:normal.
So with the above method in PD_Doc, the ctSimplifyStyles() code might do
something like the following (with more error checks added, maybe some
caching etc):
PD_Style* pStyle = 0;
const gchar* szValue = 0;
const char * pStyleName = PD_Document::getDefaultStyle();
pDoc->getStyle( pStyleName, &pStyle );
pStyle->getProperty( "font-style", szValue );
// yay, szValue is something like "normal"
// so use that in rev 5 to negate the italic from rev3.
>
> Cheers
>
> Martin
>
>
> On Mon, Apr 25, 2011 at 2:30 PM, Ben Martin
> <monkeyiq@users.sourceforge.net> wrote:
> > Hi,
> > While hacking away on Change Tracking for ODT, a case snuck up
> > involving styles. Basically, one might have a case where
> > revision 2 = ODF Style2 which == italic + bold
> > revision 3 = ODF Style4 which == bold
> > ie, each revision in the ODF references a style which wants to
> > explicitly set the current style settings to
> > default + {values}
> >
> > Of course, in abiword change tracking the above gets converted to
> > revision 2 = italic + bold
> > revision 3 = remove italic
> > ie, the minimal changes needed to get to Style4 from Style2 become what
> > is to be done for revision 3's abiword change tracking record. This
> > folding is currently done as a postprocess to the ODF load in
> > ctSimplifyStyles() of my git repo.
> >
> > This gives the issue where the "default" for many style related
> > properties is needed by my current code. So I have something like this:
> >
> > std::string getDefaultStyle( std::string s )
> > {
> > if( starts_with( s, "font-style" ))
> > return "font-style:normal";
> > if( starts_with( s, "text-decoration" ))
> > return "text-decoration:none";
> > return s;
> > }
> >
> > which needs expansion. I notice things
> > like ./src/wp/impexp/xp/ie_exp_HTML.cpp / s_prop_list
> >
> > and a string with a similar properties list used in
> > pt_PieceTable::_loadBuiltinStyles(void)
> >
> > but there doesn't seem to be a generic getDefault() like function
> > currently? Sorry if I missed it :(
> >
> > Perhaps such a function as the above getDefaultStyle() with a more
> > appropriate name would be generally useful in other parts of abiword? If
> > so I could expand mine and maybe make it
> > const char* getDefaultValueForProperty( const char* p )
> > to strip it down to a lightweight function.
> >
> >
>
This archive was generated by hypermail 2.1.8 : Tue Apr 26 2011 - 04:32:05 CEST