Page 1 of 1

DocX table empty cells get wrong style

Posted: Tue Jan 09, 2024 9:20 am
by a.weber
Hello Sergey,
loading a docx (maybe rtf too?) with a complex table results in empty cell's assigned a default style - but in the original document these cells have a assigned style with different font and small size. The wrong font / style changes the height of the row - thats the real problem / bug.

In the load process the table cells are dynamicly splitted and merged as needed - but in case of empty cells this doesn't happen properly so that a default style stays assigned.

So please have a look into RVTable.pas and TRVTableRows.Do_MergeCells( )
- Victim.HasData(False) does only copy the content of the Cell Victim if its content is <>"" but a assigned style is also some content - so I changed
the if from:

Code: Select all

if Victim.HasData(False) then
to

Code: Select all

if Victim.HasData(False) or (Vampire.IsEmpty and Victim.HasData(true)) then
to fix it?

Thanks
André

Re: DocX table empty cells get wrong style

Posted: Tue Jan 09, 2024 1:31 pm
by Sergey Tkachenko
I changed

Code: Select all

        if Victim.HasData(False) then
to

Code: Select all

        if Victim.HasData(Vampire.ItemCount = 0) then

Re: DocX table empty cells get wrong style

Posted: Tue Jan 09, 2024 2:03 pm
by a.weber
Looks too easy and simple... :?:

But Vampire.ItemCount = 0 is not the same as Vampire.IsEmpty() - does that really work? / give the same result?

Or do I miss something?

Code: Select all

if Victim.HasData(Vampire.IsEmpty) then
vs.

Code: Select all

if Victim.HasData(Vampire.ItemCount = 0) then

Re: DocX table empty cells get wrong style

Posted: Tue Jan 09, 2024 2:06 pm
by Sergey Tkachenko
I changed your Vampire.IsEmpty to Vampire.ItemCount = 0, so this change affects loading from DocX, but does not affect cell merging initiated by the user.

Re: DocX table empty cells get wrong style

Posted: Tue Jan 09, 2024 2:20 pm
by a.weber
Ok - I understand - the same code is also used for the GUI - I didn't see that.

I think the decision shouldn't be necessary and the loader has to tell the function what is merged in that case - which cell is the existing one that should stay ? (kept) - instead haveing a decision based on the content or not... ?

For the moment I think it works only that way - without changing your API. (may be if you do some refactoring that you remember this posting)

Re: DocX table empty cells get wrong style

Posted: Tue Jan 09, 2024 5:10 pm
by Sergey Tkachenko
When merging, the resulting cell contains combined content of non-empty merged cells.
When merging while reading DocX/RTF, only one cell may contain meaningful content (and changed text/paragraph style must be counted as meaningful content).
When merging cells as an operation, empty cells are not counted as meaningful content, even if they have changed text/paragraph style.

So, I think this change is OK.

Re: DocX table empty cells get wrong style

Posted: Sun Jan 28, 2024 12:18 pm
by Sergey Tkachenko
Fixed in TRichView 22.2

Re: DocX table empty cells get wrong style

Posted: Tue Apr 02, 2024 7:06 am
by a.weber
Ok - tested - works - one point less on the list.