https://issues.apache.org/ooo/show_bug.cgi?id=120077

--- Comment #16 from ChaoHuang <[email protected]> ---
(In reply to comment #12)
> (In reply to comment #10)
> > ALG: in principle, the whole SfxStyleSheetBasePool::CreateIterator is not
> > needed; a SfxStyleSheetIterator can be created by everyone
> 

confirmed the issue. Thanks for your testing and reporting!

> This breaks the styles in Writer:
> 
> - Create a new Writer document
> - Press F11
> - There are no styles for any style family
> 
> ----------------------------------------------------------------
> The UNO layer is affected too.
> Run the following macro:
> 
> REM  *****  BASIC  *****
> 
> Option Explicit
> 
> Sub Main
>       Dim oDoc as Object
>       oDoc = ThisComponent
>       
>       Dim sStyleFamilies$()
>       Dim oStyleFamilies as Object
>       oStyleFamilies = oDoc.getStyleFamilies()
>       sStyleFamilies = oStyleFamilies.getElementNames()
>       
>       Dim sStyleFamily$
>       Dim oFamily as Object
>       For Each sStyleFamily in sStyleFamilies
>               oFamily = oStyleFamilies.getByName(sStyleFamily)
>               
>               Dim sStyleNames$()
>               Dim sStyle$, sStyleName$
>               Dim oStyle as Object
>               sStyleNames = oFamily.getElementNames()
>               For Each sStyle In sStyleNames
>                       oStyle = oFamily.getByName(sStyle)
>                       sStyleName = oStyle.Name
>               Next
>       Next
> End Sub
> 
> Style families are empty
> 
> ----------------------------------------------------------------
> 
> You cannot simply replace SfxStyleSheetBasePool::CreateIterator with
> creating a SfxStyleSheetIterator.
> Writer sub-classes SfxStyleSheetBasePool in SwDocStyleSheetPool and
> overrides this function to return an SwStyleSheetIterator, derived from
> SfxStyleSheetIterator; and obviously SfxStyleSheetIterator and
> SwStyleSheetIterator are not exchangeable (without breaking functionality,
> like in this case).
> 
> This happens in SwXStyleFamily::getElementNames(), where the pBasePool is
> likely (== I didn't debug this code) an SwDocStyleSheetPool and the iterator
> should be a SwStyleSheetIterator, not a SfxStyleSheetIterator. This is why
> the UNO layer is broken.
> 
> And it happens in the "Style and Formatting" window, in all the code in
> sfx2/source/dialog/templdlg.cxx the SfxStyleSheetBasePool is really a
> SwDocStyleSheetPool when we have a Writer document:
> 
> in void SfxCommonTemplateDialog_Impl::Update_Impl() 
> - SfxObjectShell is really a SwDocShell
> - pDocShell->GetStyleSheetPool() will be returning an SwDocStyleSheetPool
> (SfxStyleSheetBasePool*       SwDocShell::GetStyleSheetPool())
> - this means SfxStyleSheetBasePool::GetIterator_Impl cannot simply create a
> SfxStyleSheetIterator, and CreateIterator was there with the idea to return
> a SwDocStyleSheetPool in this case.

Thanks for your analysis ! It's very useful for us to solver the problem.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to