Kaydet (Commit) 6c7b85c2 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Avoid bad downcasts to VclBox

At least in CppunitTest_smoektest there is a case where
SystemWindow::setOptimalLayoutSize tries to downcast a VclGrid as a VclBox
(stack top below), and that even appears to be unnecessary as the only place
that requires the downcast is the Dialog::settingOptimalLayoutSize override.  So
maybe it is guaranteed that GetWindow(WINDOW_FIRSTCHILD) is a VclBox if this is
a Dialog, but need not be the case if this is not a Dialog?  Or the real bug is
elsewhere...

SystemWindow::setOptimalLayoutSize()
SystemWindow::DoInitialLayout()
FloatingWindow::StateChanged(StateChangedType)
SfxFloatingWindow::StateChanged(StateChangedType)
SmToolBoxWindow::StateChanged(StateChangedType)
vcl::Window::ImplCallInitShow()
vcl::Window::Show(bool, unsigned short)
SfxChildWindow::Show(unsigned short)
SfxWorkWindow::HidePopups_Impl(bool, bool, unsigned short)
SfxDispatcher::DoActivate_Impl(bool, SfxViewFrame*)
SfxViewFrame::DoActivate(bool, SfxViewFrame*)
SfxApplication::SetViewFrame_Impl(SfxViewFrame*)
SfxViewFrame::SetViewFrame(SfxViewFrame*)
SfxViewFrame::MakeActive_Impl(bool)
SfxBaseController::ConnectSfxFrame_Impl(SfxBaseController::ConnectSfxFrame)
SfxBaseController::attachFrame(com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&)
(anonymous namespace)::SfxFrameLoader_Impl::impl_createDocumentView(com::sun::star::uno::Reference<com::sun::star::frame::XModel2> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, comphelper::NamedValueCollection const&, rtl::OUString const&)
(anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&)
framework::LoadEnv::impl_loadContent()
framework::LoadEnv::startLoading()
framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)
...

Change-Id: I786ad451fdf73eca22860695a614ee5b889a83cd
üst 18a0d519
......@@ -70,7 +70,7 @@ protected:
explicit Dialog( WindowType nType );
explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType );
virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
virtual void settingOptimalLayoutSize(VclBox *pBox) SAL_OVERRIDE;
virtual void settingOptimalLayoutSize(Window *pBox) SAL_OVERRIDE;
protected:
friend class VclBuilder;
......
......@@ -29,7 +29,6 @@ class ModalDialog;
class MenuBar;
class TaskPaneList;
class VclContainer;
class VclBox;
// - Icon-Types -
#define ICON_LO_DEFAULT 1
......@@ -168,7 +167,7 @@ protected:
void SetWindowStateData( const WindowStateData& rData );
virtual void settingOptimalLayoutSize(VclBox *pBox);
virtual void settingOptimalLayoutSize(Window *pBox);
SAL_DLLPRIVATE void DoInitialLayout();
public:
......
......@@ -523,12 +523,13 @@ void Dialog::set_content_area(VclBox* pContentArea)
mpContentArea = pContentArea;
}
void Dialog::settingOptimalLayoutSize(VclBox *pBox)
void Dialog::settingOptimalLayoutSize(Window *pBox)
{
const DialogStyle& rDialogStyle =
GetSettings().GetStyleSettings().GetDialogStyle();
pBox->set_border_width(rDialogStyle.content_area_border);
pBox->set_spacing(pBox->get_spacing() +
VclBox * pBox2 = static_cast<VclBox*>(pBox);
pBox2->set_border_width(rDialogStyle.content_area_border);
pBox2->set_spacing(pBox2->get_spacing() +
rDialogStyle.content_area_spacing);
VclButtonBox *pActionArea = getActionArea(this);
......
......@@ -1065,7 +1065,7 @@ OUString SystemWindow::GetText() const
return Window::GetText();
}
void SystemWindow::settingOptimalLayoutSize(VclBox* /*pBox*/)
void SystemWindow::settingOptimalLayoutSize(Window* /*pBox*/)
{
}
......@@ -1074,7 +1074,7 @@ void SystemWindow::setOptimalLayoutSize()
maLayoutIdle.Stop();
//resize SystemWindow to fit requisition on initial show
VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD));
Window *pBox = GetWindow(WINDOW_FIRSTCHILD);
settingOptimalLayoutSize(pBox);
......
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