Bug Hunting Session
Bug 70807 - Page Style method isInUse() broken, returns FALSE allways or sometimes when it should not and ...
Summary: Page Style method isInUse() broken, returns FALSE allways or sometimes when i...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: Other All
: medium normal
Assignee: Marcos Souza
URL:
Whiteboard: target:4.3.0 target:4.2.0.2 target:4.1.5
Keywords: regression
Depends on:
Blocks:
 
Reported: 2013-10-23 18:59 UTC by Olivier Hallot
Modified: 2014-01-10 15:14 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
File with macro showing the bug (21.58 KB, application/vnd.oasis.opendocument.text)
2013-10-23 18:59 UTC, Olivier Hallot
Details
File with macro showing the bug (22.16 KB, application/vnd.oasis.opendocument.text)
2013-10-31 23:40 UTC, Olivier Hallot
Details
test file (15.76 KB, application/vnd.oasis.opendocument.text)
2013-12-06 13:34 UTC, Cor Nouws
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Hallot 2013-10-23 18:59:35 UTC
Created attachment 88050 [details]
File with macro showing the bug

Method isInUse() for page styles return FALSE always, even is the page style is used in the document.

The atached document has a simple macro to check the issue. The macro is listed below for convenience.

REM  *****  BASIC  *****

Sub Main
oDocument = ThisComponent
oTablePageStyles=oDocument.StyleFamilies.getbyName("PageStyles")

' set on all page styles

For iL = 0 to oTablePageStyles.Count - 1

    oEstilo = oTablePageStyles(iL)
    msgBox iL & " " & oEstilo.Name & " " & oEstilo.isInUse()
Next
End Sub
Comment 1 Olivier Hallot 2013-10-31 23:40:25 UTC
Created attachment 88455 [details]
File with macro showing the bug

Teste with LO 4.2.0, build b3aadaa58c7a5c28132da3d085ce39378fe69ce8

The macro detect style "Right page" but does not detect styles "pagestyle1" and "pagestyle2"
Comment 2 Olivier Hallot 2013-11-10 21:37:00 UTC
Suspicion:
Bit InUse is not set in custom page styles either at creation time or when the 
custom style is applied to the page of the document.

Styles and formatting window (F11) does not list applied custom styles in the example document
Comment 3 Olivier Hallot 2013-11-13 08:15:41 UTC
Changing component. 

Actually this is a Wrtter bug.
Comment 4 Cor Nouws 2013-12-06 13:33:17 UTC
I confirm this Olivier

Looks as if this is broken since 3.6
4.2.0 differs from 4.0.6 and 4.1.3 but still not OK. Anyway, with the test file that I used.
Will attach that. Looks asif there is some random disorder.
Comment 5 Cor Nouws 2013-12-06 13:34:25 UTC
Created attachment 90359 [details]
test file

as suggested: test the same with different pages and different page orders, will give different results, I guess
Comment 6 Marcos Souza 2013-12-10 02:20:25 UTC
Just a small batktrace after put an breakpoint into SwXStyle::isInUse:

#3  0xa91599a6 in SwDoc::IsUsed (this=0x87c6ae8, rModify=SwModify) at /home/marcos/gitroot/core/sw/source/core/doc/poolfmt.cxx:2328
#4  0xa98d1721 in SwDocStyleSheet::IsUsed (this=0xa88c07c4) at /home/marcos/gitroot/core/sw/source/ui/app/docstyle.cxx:1975
#5  0xa96e70d5 in SwXStyle::isInUse (this=0xa71a60c8) at /home/marcos/gitroot/core/sw/source/core/unocore/unostyle.cxx:1417

Maybe we need to take a look if there is something missing or if something needs to setup after style use or creation.
Comment 7 Marcos Souza 2013-12-18 02:12:47 UTC
I could not reproduce with the current master.

Steps to reproduce:

1 - Open the test document attached by Olivier
2 - insert some text in the first page
3 - Create a new page and insert some text too
4 - Change the page style to landscape
5 - Run the macro.

Here it shows correctly.

My master's HEAD is 0c0258ae9f7adfe17fc2e357b86006dbb4497ff4.
Comment 8 Michael Stahl (CIB) 2014-01-07 13:27:24 UTC
this looks suspicious:

bool SwPageDesc::GetInfo( SfxPoolItem & rInfo ) const
{
    if( !aMaster.GetInfo( rInfo ) )
            return false;       // found
    return aLeft.GetInfo( rInfo );
}

if there is only one page in the document then only the
SwPageDesc::m_FirstMaster (which was added in LO 4.0) is
actually in use, the aMaster [right-page other than first]
and aLeft [left-page other than first] are not.

probably this needs to check m_FirstMaster and
m_FirstLeft too.

Marcos, do you have some time to try this out?
Comment 9 Michael Stahl (CIB) 2014-01-07 15:07:38 UTC
regression in 4.0.0 release, worked in 3.6.7.2
Comment 10 Olivier Hallot 2014-01-07 17:57:27 UTC
Verified in master. Patch OK.
Comment 11 Commit Notification 2014-01-07 18:08:35 UTC
Marcos Paulo de Souza committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6131787afbb32e1e12aac4cf4f65625d11d39f08

Fix fdo#70807: Page Style method isInUse() broken



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2014-01-07 18:13:00 UTC
Marcos Paulo de Souza committed a patch related to this issue.
It has been pushed to "libreoffice-4-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c47f102d8df5e413dbf70e9968ed913f2855787d&h=libreoffice-4-2

Fix fdo#70807: Page Style method isInUse() broken


It will be available in LibreOffice 4.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 13 Commit Notification 2014-01-07 18:18:26 UTC
Marcos Paulo de Souza committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=63c2990d0e67e90f5445dac10c8c1f7919031482&h=libreoffice-4-1

Fix fdo#70807: Page Style method isInUse() broken


It will be available in LibreOffice 4.1.5.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 14 Michael Stahl (CIB) 2014-01-07 18:22:48 UTC
great, Marcos fixed it
Comment 15 Commit Notification 2014-01-10 08:48:42 UTC
Marcos Paulo de Souza committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=16ae82c772cd818316a19ce303d349657f6cb863

fdo#70807: UT to verify used styles in document



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 16 Commit Notification 2014-01-10 15:14:40 UTC
Marcos Paulo de Souza committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b1236dd7e86f40e54b7efb6082fad0967edb92d2

fdo#70807: Improve unit test using custom styles



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.