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

coverity#1158357 Uncaught exception

Change-Id: I7d93f1c1a4e9c4b91c385d6f9e1aaab2fe635327
üst b9cb27ef
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <toolkit/helper/vclunohelper.hxx> #include <toolkit/helper/vclunohelper.hxx>
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <comphelper/namedvaluecollection.hxx> #include <comphelper/namedvaluecollection.hxx>
#include <boost/bind.hpp> #include <boost/bind.hpp>
...@@ -92,73 +93,86 @@ Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement ( ...@@ -92,73 +93,86 @@ Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
{ {
Reference<ui::XUIElement> xElement; Reference<ui::XUIElement> xElement;
const ::comphelper::NamedValueCollection aArguments (rArguments); try
Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
if ( ! xParentWindow.is() || pParentWindow==NULL)
throw RuntimeException(
"PanelFactory::createUIElement called without ParentWindow",
NULL);
if ( ! xFrame.is())
throw RuntimeException(
"PanelFactory::createUIElement called without Frame",
NULL);
if (pBindings == NULL)
throw RuntimeException(
"PanelFactory::createUIElement called without SfxBindings",
NULL);
#define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
if (DoesResourceEndWith("/AlignmentPropertyPanel"))
{ {
AlignmentPropertyPanel* pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings ); const ::comphelper::NamedValueCollection aArguments (rArguments);
xElement = sfx2::sidebar::SidebarPanelBase::Create( Reference<frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<frame::XFrame>()));
rsResourceURL, Reference<awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<awt::XWindow>()));
xFrame, const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0)));
pPanel, SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
ui::LayoutSize(-1,-1,-1));
} ::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
else if (DoesResourceEndWith("/CellAppearancePropertyPanel")) if ( ! xParentWindow.is() || pParentWindow==NULL)
{ throw RuntimeException(
CellAppearancePropertyPanel* pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings ); "PanelFactory::createUIElement called without ParentWindow",
xElement = sfx2::sidebar::SidebarPanelBase::Create( NULL);
rsResourceURL, if ( ! xFrame.is())
xFrame, throw RuntimeException(
pPanel, "PanelFactory::createUIElement called without Frame",
ui::LayoutSize(-1,-1,-1)); NULL);
} if (pBindings == NULL)
else if (DoesResourceEndWith("/NumberFormatPropertyPanel")) throw RuntimeException(
{ "PanelFactory::createUIElement called without SfxBindings",
NumberFormatPropertyPanel* pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings ); NULL);
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL, #define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
xFrame, if (DoesResourceEndWith("/AlignmentPropertyPanel"))
pPanel, {
ui::LayoutSize(-1,-1,-1)); AlignmentPropertyPanel* pPanel = AlignmentPropertyPanel::Create( pParentWindow, xFrame, pBindings );
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
pPanel,
ui::LayoutSize(-1,-1,-1));
}
else if (DoesResourceEndWith("/CellAppearancePropertyPanel"))
{
CellAppearancePropertyPanel* pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings );
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
pPanel,
ui::LayoutSize(-1,-1,-1));
}
else if (DoesResourceEndWith("/NumberFormatPropertyPanel"))
{
NumberFormatPropertyPanel* pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings );
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
pPanel,
ui::LayoutSize(-1,-1,-1));
}
else if (DoesResourceEndWith("/NavigatorPanel"))
{
Window* pPanel = new ScNavigatorDlg(pBindings, NULL, pParentWindow, false);
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
pPanel,
ui::LayoutSize(0,-1,-1));
}
else if (DoesResourceEndWith("/FunctionsPanel"))
{
Window* pPanel = new ScFunctionDockWin(pBindings, NULL, pParentWindow, ScResId(FID_FUNCTION_BOX));
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
pPanel,
ui::LayoutSize(0,-1,-1));
}
#undef DoesResourceEndWith
} }
else if (DoesResourceEndWith("/NavigatorPanel")) catch (const uno::RuntimeException &)
{ {
Window* pPanel = new ScNavigatorDlg(pBindings, NULL, pParentWindow, false); throw;
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
pPanel,
ui::LayoutSize(0,-1,-1));
} }
else if (DoesResourceEndWith("/FunctionsPanel")) catch (const uno::Exception& e)
{ {
Window* pPanel = new ScFunctionDockWin(pBindings, NULL, pParentWindow, ScResId(FID_FUNCTION_BOX)); throw lang::WrappedTargetRuntimeException(
xElement = sfx2::sidebar::SidebarPanelBase::Create( OUString("ScPanelFactory::createUIElement exception"),
rsResourceURL, 0, uno::makeAny(e));
xFrame,
pPanel,
ui::LayoutSize(0,-1,-1));
} }
#undef DoesResourceEndWith
return xElement; return xElement;
} }
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/ucb/CommandAbortedException.hpp> #include <com/sun/star/ucb/CommandAbortedException.hpp>
#include <com/sun/star/ucb/InteractiveAppException.hpp> #include <com/sun/star/ucb/InteractiveAppException.hpp>
#include <com/sun/star/ucb/XContent.hpp> #include <com/sun/star/ucb/XContent.hpp>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/ucb/CommandAbortedException.hpp> #include <com/sun/star/ucb/CommandAbortedException.hpp>
#include <com/sun/star/ucb/InteractiveAppException.hpp> #include <com/sun/star/ucb/InteractiveAppException.hpp>
#include <com/sun/star/ucb/XContent.hpp> #include <com/sun/star/ucb/XContent.hpp>
......
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