Kaydet (Commit) ec240eaf authored tarafından Caolán McNamara's avatar Caolán McNamara

Split construct into bits that depend on showing the window and not

This fixes a horrific a11y problem where Show triggers callbacks
to virtual methods, while the object is not fully constructed,
which means, that the *baseclass* virtual method is called,
not the *derived* virtual method that constructs the a11y wrapper

enable a11y, and run the smoketest with dbg-util before touching
this stuff
üst 20015bfb
...@@ -562,6 +562,27 @@ protected: ...@@ -562,6 +562,27 @@ protected:
virtual void SetZoomFactor( const Fraction &rZoomX, virtual void SetZoomFactor( const Fraction &rZoomX,
const Fraction &rZoomY ); const Fraction &rZoomY );
/**
This must be called after the ctor, but before anything else.
It's the part of construction that is dependent
on showing the top-level window.
Showing a window with a11y enabled causes various callbacks
to be triggered.
Due to the "virtual methods are not virtual during constructors"
problem, this is a disaster to call from the ctor
i.e. construct calls Show, and if a11y is enabled this
reenters the not-fully constructed object and calls
CreateAccessibleDocumentView, so if construct is called
from the ctor then if a derived class is contructed the base-cass
CreateAccessibleDocumentView is used, not the derived
CreateAccessibleDocumentView. i.e. run smoketest under a11y with
debugging assertions enabled
*/
void doShow();
private: private:
::Window* mpParentWindow; ::Window* mpParentWindow;
/** This window updater is used to keep all relevant windows up to date /** This window updater is used to keep all relevant windows up to date
......
...@@ -135,9 +135,6 @@ SlideSorterViewShell::SlideSorterViewShell ( ...@@ -135,9 +135,6 @@ SlideSorterViewShell::SlideSorterViewShell (
{ {
meShellType = ST_SLIDE_SORTER; meShellType = ST_SLIDE_SORTER;
SetPool( &GetDoc()->GetPool() );
SetUndoManager( GetDoc()->GetDocSh()->GetUndoManager() );
if (pFrameViewArgument != NULL) if (pFrameViewArgument != NULL)
mpFrameView = pFrameViewArgument; mpFrameView = pFrameViewArgument;
else else
...@@ -190,6 +187,11 @@ void SlideSorterViewShell::Initialize (void) ...@@ -190,6 +187,11 @@ void SlideSorterViewShell::Initialize (void)
mpScrollBarBox); mpScrollBarBox);
mpView = &mpSlideSorter->GetView(); mpView = &mpSlideSorter->GetView();
ViewShell::doShow();
SetPool( &GetDoc()->GetPool() );
SetUndoManager( GetDoc()->GetDocSh()->GetUndoManager() );
// For accessibility we have to shortly hide the content window. // For accessibility we have to shortly hide the content window.
// This triggers the construction of a new accessibility object for // This triggers the construction of a new accessibility object for
// the new view shell. (One is created earlier while the construtor // the new view shell. (One is created earlier while the construtor
......
...@@ -483,6 +483,8 @@ ToolPanelViewShell::ToolPanelViewShell( SfxViewFrame* pFrame, ViewShellBase& rVi ...@@ -483,6 +483,8 @@ ToolPanelViewShell::ToolPanelViewShell( SfxViewFrame* pFrame, ViewShellBase& rVi
,mpSubShellManager() ,mpSubShellManager()
,mnMenuId(0) ,mnMenuId(0)
{ {
ViewShell::doShow();
meShellType = ST_TASK_PANE; meShellType = ST_TASK_PANE;
mpContentWindow->SetCenterAllowed( false ); mpContentWindow->SetCenterAllowed( false );
......
...@@ -143,6 +143,8 @@ DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBas ...@@ -143,6 +143,8 @@ DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBas
, mbIsLayerModeActive(false) , mbIsLayerModeActive(false)
, mbIsInSwitchPage(false) , mbIsInSwitchPage(false)
{ {
ViewShell::doShow();
if (pFrameViewArgument != NULL) if (pFrameViewArgument != NULL)
mpFrameView = pFrameViewArgument; mpFrameView = pFrameViewArgument;
else else
......
...@@ -225,6 +225,8 @@ OutlineViewShell::OutlineViewShell ( ...@@ -225,6 +225,8 @@ OutlineViewShell::OutlineViewShell (
mbInitialized(false) mbInitialized(false)
{ {
ViewShell::doShow();
if (pFrameViewArgument != NULL) if (pFrameViewArgument != NULL)
mpFrameView = pFrameViewArgument; mpFrameView = pFrameViewArgument;
else else
......
...@@ -218,11 +218,6 @@ void ViewShell::construct(void) ...@@ -218,11 +218,6 @@ void ViewShell::construct(void)
mpContentWindow->SetViewShell(this); mpContentWindow->SetViewShell(this);
mpContentWindow->SetPosSizePixel( mpContentWindow->SetPosSizePixel(
GetParentWindow()->GetPosPixel(),GetParentWindow()->GetSizePixel()); GetParentWindow()->GetPosPixel(),GetParentWindow()->GetSizePixel());
mpContentWindow->Show();
static_cast< ::Window*>(mpContentWindow.get())->Resize();
OSL_TRACE("content window has size %d %d",
mpContentWindow->GetSizePixel().Width(),
mpContentWindow->GetSizePixel().Height());
if ( ! GetDocSh()->IsPreview()) if ( ! GetDocSh()->IsPreview())
{ {
...@@ -231,18 +226,12 @@ void ViewShell::construct(void) ...@@ -231,18 +226,12 @@ void ViewShell::construct(void)
mpHorizontalScrollBar->EnableRTL (sal_False); mpHorizontalScrollBar->EnableRTL (sal_False);
mpHorizontalScrollBar->SetRange(Range(0, 32000)); mpHorizontalScrollBar->SetRange(Range(0, 32000));
mpHorizontalScrollBar->SetScrollHdl(LINK(this, ViewShell, HScrollHdl)); mpHorizontalScrollBar->SetScrollHdl(LINK(this, ViewShell, HScrollHdl));
mpHorizontalScrollBar->Show();
mpVerticalScrollBar.reset (new ScrollBar(GetParentWindow(), WinBits(WB_VSCROLL | WB_DRAG))); mpVerticalScrollBar.reset (new ScrollBar(GetParentWindow(), WinBits(WB_VSCROLL | WB_DRAG)));
mpVerticalScrollBar->SetRange(Range(0, 32000)); mpVerticalScrollBar->SetRange(Range(0, 32000));
mpVerticalScrollBar->SetScrollHdl(LINK(this, ViewShell, VScrollHdl)); mpVerticalScrollBar->SetScrollHdl(LINK(this, ViewShell, VScrollHdl));
mpVerticalScrollBar->Show();
maScrBarWH = Size(
mpVerticalScrollBar->GetSizePixel().Width(),
mpHorizontalScrollBar->GetSizePixel().Height());
mpScrollBarBox.reset(new ScrollBarBox(GetParentWindow(), WB_SIZEABLE)); mpScrollBarBox.reset(new ScrollBarBox(GetParentWindow(), WB_SIZEABLE));
mpScrollBarBox->Show();
} }
String aName( RTL_CONSTASCII_USTRINGPARAM( "ViewShell" )); String aName( RTL_CONSTASCII_USTRINGPARAM( "ViewShell" ));
...@@ -264,12 +253,31 @@ void ViewShell::construct(void) ...@@ -264,12 +253,31 @@ void ViewShell::construct(void)
// Register the sub shell factory. // Register the sub shell factory.
mpImpl->mpSubShellFactory.reset(new ViewShellObjectBarFactory(*this)); mpImpl->mpSubShellFactory.reset(new ViewShellObjectBarFactory(*this));
GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl->mpSubShellFactory); GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl->mpSubShellFactory);
GetParentWindow()->Show();
} }
void ViewShell::doShow(void)
{
mpContentWindow->Show();
static_cast< ::Window*>(mpContentWindow.get())->Resize();
OSL_TRACE("content window has size %d %d",
mpContentWindow->GetSizePixel().Width(),
mpContentWindow->GetSizePixel().Height());
if ( ! GetDocSh()->IsPreview())
{
// Show scroll bars
mpHorizontalScrollBar->Show();
mpVerticalScrollBar->Show();
maScrBarWH = Size(
mpVerticalScrollBar->GetSizePixel().Width(),
mpHorizontalScrollBar->GetSizePixel().Height());
mpScrollBarBox->Show();
}
GetParentWindow()->Show();
}
void ViewShell::Init (bool bIsMainViewShell) void ViewShell::Init (bool bIsMainViewShell)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment