From 96edd65a89bdedf41c4e921eada0c20c9bde817a Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 23 Jun 2008 19:38:40 +0000 Subject: [PATCH] * Fixed style reading for OOffice documents git-svn-id: trunk@11268 - --- packages/fcl-base/src/rtfpars.pp | 67 ++++++++++++++++---------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/packages/fcl-base/src/rtfpars.pp b/packages/fcl-base/src/rtfpars.pp index 4641f54ee3..0e5437228d 100644 --- a/packages/fcl-base/src/rtfpars.pp +++ b/packages/fcl-base/src/rtfpars.pp @@ -803,6 +803,7 @@ var sp : PRTFStyle; sep,sepLast : PRTFStyleElt; bp : string[rtfBufSiz]; + I : Integer; Begin While true do @@ -823,40 +824,40 @@ While true do FstyleList := sp; if not CheckCM (rtfGroup, rtfBeginGroup) then Error ('SSErr - missing {'); - while (GetToken=rtfControl) or (FTokenClass=rtfControl) do + I:=0; + GetToken; + while (fRTFClass=rtfControl) or (FTokenClass=rtfControl) or (FRTFClass=rtfGroup) do Begin - if rtfClass=rtfUnknown then - continue; - if (CheckMM (rtfParAttr, rtfStyleNum)) then - Begin - sp^.rtfSNum:=rtfParam; - continue; - End; - if (CheckMM (rtfStyleAttr, rtfBasedOn)) then - Begin - sp^.rtfSBasedOn:=rtfParam; - continue; - End; - if (CheckMM (rtfStyleAttr, rtfNext)) then - Begin - sp^.rtfSNextPar:=rtfParam; - Continue; - End; - new(sep); - if sep=nil then - Error ('SSErr - cannot allocate style element'); - sep^.rtfSEClass:=rtfClass; - sep^.rtfSEMajor:=rtfMajor; - sep^.rtfSEMinor:=rtfMinor; - sep^.rtfSEParam:=rtfParam; - sep^.rtfSEText:=rtfTextBuf; - if sepLast=nil then - sp^.rtfSSEList:=sep { first element } - else { add to end } - sepLast^.rtfNextSE:=sep; - sep^.rtfNextSE:=nil; - sepLast:=sep; - End; + If CheckCM(rtfGroup, rtfBeginGroup) then + SkipGroup + else if rtfClass<>rtfUnknown then + begin + if (CheckMM (rtfParAttr, rtfStyleNum)) then + sp^.rtfSNum:=rtfParam + else if (CheckMM (rtfStyleAttr, rtfBasedOn)) then + sp^.rtfSBasedOn:=rtfParam + else if (CheckMM (rtfStyleAttr, rtfNext)) then + sp^.rtfSNextPar:=rtfParam + else + begin + new(sep); + if sep=nil then + Error ('SSErr - cannot allocate style element'); + sep^.rtfSEClass:=rtfClass; + sep^.rtfSEMajor:=rtfMajor; + sep^.rtfSEMinor:=rtfMinor; + sep^.rtfSEParam:=rtfParam; + sep^.rtfSEText:=rtfTextBuf; + if sepLast=nil then + sp^.rtfSSEList:=sep { first element } + else { add to end } + sepLast^.rtfNextSE:=sep; + sep^.rtfNextSE:=nil; + sepLast:=sep; + end; + end; + GetToken; + End; if sp^.rtfSNextPar=-1 then { \snext not given } sp^.rtfSNextPar:=sp^.rtfSNum; { next is itself } if rtfClass<>rtfText then