summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/flatten.cxx36
-rw-r--r--scaddins/source/analysis/analysisdefs.hxx2
-rw-r--r--scaddins/source/analysis/analysishelper.cxx66
-rw-r--r--scaddins/source/analysis/bessel.cxx21
-rw-r--r--scaddins/source/pricing/pricing.hxx2
-rw-r--r--scripting/source/basprov/basmethnode.cxx111
-rw-r--r--scripting/source/dlgprov/dlgevtatt.cxx17
-rw-r--r--scripting/source/provider/MasterScriptProvider.cxx51
-rw-r--r--sd/source/core/stlfamily.cxx22
-rw-r--r--sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx8
-rw-r--r--sd/source/ui/accessibility/AccessibleSlideSorterView.cxx20
-rw-r--r--sd/source/ui/framework/factories/BasicPaneFactory.cxx128
-rw-r--r--sd/source/ui/framework/factories/BasicToolBarFactory.cxx9
-rw-r--r--sd/source/ui/framework/factories/BasicViewFactory.cxx54
-rw-r--r--sd/source/ui/framework/factories/FullScreenPane.cxx36
-rw-r--r--sd/source/ui/presenter/PresenterHelper.cxx42
-rw-r--r--sd/source/ui/slidesorter/shell/SlideSorterService.cxx73
-rw-r--r--sd/source/ui/tools/PropertySet.cxx9
-rw-r--r--sd/source/ui/unoidl/unocpres.cxx18
19 files changed, 347 insertions, 378 deletions
diff --git a/compilerplugins/clang/flatten.cxx b/compilerplugins/clang/flatten.cxx
index ceff258179dd..3ae8b3b7dc45 100644
--- a/compilerplugins/clang/flatten.cxx
+++ b/compilerplugins/clang/flatten.cxx
@@ -39,6 +39,7 @@ private:
SourceRange ignoreMacroExpansions(SourceRange range);
SourceRange extendOverComments(SourceRange range);
std::string getSourceAsString(SourceRange range);
+ std::string invertCondition(Expr const * condExpr, SourceRange conditionRange);
};
static const Stmt * containsSingleThrowExpr(const Stmt * stmt)
@@ -131,14 +132,7 @@ bool Flatten::rewrite(const IfStmt* ifStmt)
// in adjusting the formatting I assume that "{" starts on a new line
- std::string conditionString = getSourceAsString(conditionRange);
- auto condExpr = ifStmt->getCond()->IgnoreImpCasts();
- if (auto exprWithCleanups = dyn_cast<ExprWithCleanups>(condExpr))
- condExpr = exprWithCleanups->getSubExpr()->IgnoreImpCasts();
- if (isa<DeclRefExpr>(condExpr) || isa<CallExpr>(condExpr) || isa<MemberExpr>(condExpr))
- conditionString = "!" + conditionString;
- else
- conditionString = "!(" + conditionString + ")";
+ std::string conditionString = invertCondition(ifStmt->getCond(), conditionRange);
std::string thenString = getSourceAsString(thenRange);
if (auto compoundStmt = dyn_cast<CompoundStmt>(ifStmt->getThen())) {
@@ -166,6 +160,32 @@ bool Flatten::rewrite(const IfStmt* ifStmt)
return true;
}
+std::string Flatten::invertCondition(Expr const * condExpr, SourceRange conditionRange)
+{
+ std::string s = getSourceAsString(conditionRange);
+
+ condExpr = condExpr->IgnoreImpCasts();
+
+ if (auto exprWithCleanups = dyn_cast<ExprWithCleanups>(condExpr))
+ condExpr = exprWithCleanups->getSubExpr()->IgnoreImpCasts();
+
+ if (auto unaryOp = dyn_cast<UnaryOperator>(condExpr))
+ {
+ if (unaryOp->getOpcode() != UO_LNot)
+ return "!(" + s + ")";
+ auto i = s.find("!");
+ assert (i != std::string::npos);
+ s = s.substr(i+1);
+ }
+ else if (isa<CXXOperatorCallExpr>(condExpr))
+ s = "!(" + s + ")";
+ else if (isa<DeclRefExpr>(condExpr) || isa<CallExpr>(condExpr) || isa<MemberExpr>(condExpr))
+ s = "!" + s;
+ else
+ s = "!(" + s + ")";
+ return s;
+}
+
std::string stripOpenAndCloseBrace(std::string s)
{
size_t i = s.find("{");
diff --git a/scaddins/source/analysis/analysisdefs.hxx b/scaddins/source/analysis/analysisdefs.hxx
index 47bd092fd512..9acef5d76108 100644
--- a/scaddins/source/analysis/analysisdefs.hxx
+++ b/scaddins/source/analysis/analysisdefs.hxx
@@ -22,7 +22,7 @@
#define CHK_Freq ( nFreq != 1 && nFreq != 2 && nFreq != 4 )
#define CHK_FINITE(d) if( !::rtl::math::isFinite( d ) ) throw css::lang::IllegalArgumentException()
-#define RETURN_FINITE(d) if( ::rtl::math::isFinite( d ) ) return d; else throw css::lang::IllegalArgumentException()
+#define RETURN_FINITE(d) if( !::rtl::math::isFinite( d ) ) throw css::lang::IllegalArgumentException(); return d;
#endif
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index d8836e82ae79..19ea47cc5ef0 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -686,18 +686,15 @@ double ConvertToDec( const OUString& aStr, sal_uInt16 nBase, sal_uInt16 nCharLim
else
n = nBase;
- if( n < nBase )
+ if( n >= nBase )
+ throw lang::IllegalArgumentException(); // illegal char!
+
+ if( bFirstDig )
{
- if( bFirstDig )
- {
- bFirstDig = false;
- nFirstDig = n;
- }
- fVal = fVal * fBase + double( n );
+ bFirstDig = false;
+ nFirstDig = n;
}
- else
- // illegal char!
- throw lang::IllegalArgumentException();
+ fVal = fVal * fBase + double( n );
p++;
@@ -1504,20 +1501,18 @@ void SortedIndividualInt32List::InsertHolidayList(
if( rHolAny.getValueTypeClass() == uno::TypeClass_SEQUENCE )
{
uno::Sequence< uno::Sequence< uno::Any > > aAnySeq;
- if( rHolAny >>= aAnySeq )
+ if( !(rHolAny >>= aAnySeq) )
+ throw lang::IllegalArgumentException();
+
+ const uno::Sequence< uno::Any >* pSeqArray = aAnySeq.getConstArray();
+ for( sal_Int32 nIndex1 = 0; nIndex1 < aAnySeq.getLength(); nIndex1++ )
{
- const uno::Sequence< uno::Any >* pSeqArray = aAnySeq.getConstArray();
- for( sal_Int32 nIndex1 = 0; nIndex1 < aAnySeq.getLength(); nIndex1++ )
- {
- const uno::Sequence< uno::Any >& rSubSeq = pSeqArray[ nIndex1 ];
- const uno::Any* pAnyArray = rSubSeq.getConstArray();
+ const uno::Sequence< uno::Any >& rSubSeq = pSeqArray[ nIndex1 ];
+ const uno::Any* pAnyArray = rSubSeq.getConstArray();
- for( sal_Int32 nIndex2 = 0; nIndex2 < rSubSeq.getLength(); nIndex2++ )
- InsertHolidayList( rAnyConv, pAnyArray[ nIndex2 ], nNullDate, false/*bInsertOnWeekend*/ );
- }
+ for( sal_Int32 nIndex2 = 0; nIndex2 < rSubSeq.getLength(); nIndex2++ )
+ InsertHolidayList( rAnyConv, pAnyArray[ nIndex2 ], nNullDate, false/*bInsertOnWeekend*/ );
}
- else
- throw lang::IllegalArgumentException();
}
else
InsertHolidayList( rAnyConv, rHolAny, nNullDate, false/*bInsertOnWeekend*/ );
@@ -1751,13 +1746,10 @@ void Complex::Power( double fPower )
{
if( r == 0.0 && i == 0.0 )
{
- if( fPower > 0 )
- {
- r = i = 0.0;
- return;
- }
- else
+ if( fPower <= 0 )
throw lang::IllegalArgumentException();
+ r = i = 0.0;
+ return;
}
double p, phi;
@@ -2102,15 +2094,13 @@ void ComplexList::Append( const uno::Sequence< uno::Any >& aMultPars, ComplListA
case uno::TypeClass_SEQUENCE:
{
uno::Sequence< uno::Sequence< uno::Any > > aValArr;
- if( r >>= aValArr )
- {
- sal_Int32 nE = aValArr.getLength();
- const uno::Sequence< uno::Any >* pArr = aValArr.getConstArray();
- for( sal_Int32 n = 0 ; n < nE ; n++ )
- Append( pArr[ n ], eAH );
- }
- else
+ if( !(r >>= aValArr) )
throw lang::IllegalArgumentException();
+
+ sal_Int32 nE = aValArr.getLength();
+ const uno::Sequence< uno::Any >* pArr = aValArr.getConstArray();
+ for( sal_Int32 n = 0 ; n < nE ; n++ )
+ Append( pArr[ n ], eAH );
}
break;
default:
@@ -2558,10 +2548,10 @@ double ConvertDataList::Convert( double fVal, const OUString& rFrom, const OUStr
++it;
}
- if( pFrom && pTo )
- return pFrom->Convert( fVal, *pTo, nLevelFrom, nLevelTo );
- else
+ if( !pFrom || !pTo )
throw lang::IllegalArgumentException();
+
+ return pFrom->Convert( fVal, *pTo, nLevelFrom, nLevelTo );
}
diff --git a/scaddins/source/analysis/bessel.cxx b/scaddins/source/analysis/bessel.cxx
index b7fb5ab419d9..bc0c1d8a6b0b 100644
--- a/scaddins/source/analysis/bessel.cxx
+++ b/scaddins/source/analysis/bessel.cxx
@@ -74,10 +74,9 @@ double BesselJ( double x, sal_Int32 N )
bool bAsymptoticPossible = pow(fX,0.4) > N;
if (fEstimateIteration > fMaxIteration)
{
- if (bAsymptoticPossible)
- return fSign * sqrt(f_2_DIV_PI/fX)* cos(fX-N*f_PI_DIV_2-f_PI_DIV_4);
- else
+ if (!bAsymptoticPossible)
throw NoConvergenceException();
+ return fSign * sqrt(f_2_DIV_PI/fX)* cos(fX-N*f_PI_DIV_2-f_PI_DIV_4);
}
double const epsilon = 1.0e-15; // relative error
@@ -148,10 +147,10 @@ double BesselJ( double x, sal_Int32 N )
k = k + 1.0;
}
while (!bHasfound && k <= fMaxIteration);
- if (bHasfound)
- return u * fSign;
- else
+ if (!bHasfound)
throw NoConvergenceException(); // unlikely to happen
+
+ return u * fSign;
}
@@ -367,10 +366,9 @@ double Bessely0( double fX )
k=k+1;
}
while (!bHasFound && k<fMaxIteration);
- if (bHasFound)
- return u*f_2_DIV_PI;
- else
+ if (!bHasFound)
throw NoConvergenceException(); // not likely to happen
+ return u*f_2_DIV_PI;
}
// See #i31656# for a commented version of this implementation, attachment #desc6
@@ -423,10 +421,9 @@ double Bessely1( double fX )
k=k+1;
}
while (!bHasFound && k<fMaxIteration);
- if (bHasFound)
- return -u*2.0/f_PI;
- else
+ if (!bHasFound)
throw NoConvergenceException();
+ return -u*2.0/f_PI;
}
double BesselY( double fNum, sal_Int32 nOrder )
diff --git a/scaddins/source/pricing/pricing.hxx b/scaddins/source/pricing/pricing.hxx
index 82fbbb6cacc5..eb353e0a2235 100644
--- a/scaddins/source/pricing/pricing.hxx
+++ b/scaddins/source/pricing/pricing.hxx
@@ -38,7 +38,7 @@
#include <com/sun/star/sheet/addin/XPricingFunctions.hpp>
#include <cppuhelper/implbase.hxx>
-#define RETURN_FINITE(d) if( ::rtl::math::isFinite( d ) ) return d; else throw css::lang::IllegalArgumentException()
+#define RETURN_FINITE(d) if( !::rtl::math::isFinite( d ) ) throw css::lang::IllegalArgumentException(); return d;
namespace sca {
diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx
index e13f149aefcc..a0104f260950 100644
--- a/scripting/source/basprov/basmethnode.cxx
+++ b/scripting/source/basprov/basmethnode.cxx
@@ -185,80 +185,79 @@ namespace basprov
Any BasicMethodNodeImpl::invoke( const OUString& aFunctionName, const Sequence< Any >&,
Sequence< sal_Int16 >&, Sequence< Any >& )
{
- if ( aFunctionName == BASPROV_PROPERTY_EDITABLE )
+ if ( aFunctionName != BASPROV_PROPERTY_EDITABLE )
{
- OUString sDocURL, sLibName, sModName;
- sal_uInt16 nLine1 = 0, nLine2;
+ throw IllegalArgumentException(
+ "BasicMethodNodeImpl::invoke: function name not supported!",
+ Reference< XInterface >(), 1 );
+ }
- if ( !m_bIsAppScript )
- {
- Reference< frame::XModel > xModel = MiscUtils::tDocUrlToModel( m_sScriptingContext );
+ OUString sDocURL, sLibName, sModName;
+ sal_uInt16 nLine1 = 0, nLine2;
+
+ if ( !m_bIsAppScript )
+ {
+ Reference< frame::XModel > xModel = MiscUtils::tDocUrlToModel( m_sScriptingContext );
- if ( xModel.is() )
+ if ( xModel.is() )
+ {
+ sDocURL = xModel->getURL();
+ if ( sDocURL.isEmpty() )
{
- sDocURL = xModel->getURL();
- if ( sDocURL.isEmpty() )
+ Sequence < PropertyValue > aProps = xModel->getArgs();
+ sal_Int32 nProps = aProps.getLength();
+ const PropertyValue* pProps = aProps.getConstArray();
+ for ( sal_Int32 i = 0; i < nProps; ++i )
{
- Sequence < PropertyValue > aProps = xModel->getArgs();
- sal_Int32 nProps = aProps.getLength();
- const PropertyValue* pProps = aProps.getConstArray();
- for ( sal_Int32 i = 0; i < nProps; ++i )
+ // TODO: according to MBA the property 'Title' may change in future
+ if ( pProps[i].Name == "Title" )
{
- // TODO: according to MBA the property 'Title' may change in future
- if ( pProps[i].Name == "Title" )
- {
- pProps[i].Value >>= sDocURL;
- break;
- }
+ pProps[i].Value >>= sDocURL;
+ break;
}
}
}
}
+ }
- if ( m_pMethod )
+ if ( m_pMethod )
+ {
+ m_pMethod->GetLineRange( nLine1, nLine2 );
+ SbModule* pModule = m_pMethod->GetModule();
+ if ( pModule )
{
- m_pMethod->GetLineRange( nLine1, nLine2 );
- SbModule* pModule = m_pMethod->GetModule();
- if ( pModule )
- {
- sModName = pModule->GetName();
- StarBASIC* pBasic = static_cast< StarBASIC* >( pModule->GetParent() );
- if ( pBasic )
- sLibName = pBasic->GetName();
- }
+ sModName = pModule->GetName();
+ StarBASIC* pBasic = static_cast< StarBASIC* >( pModule->GetParent() );
+ if ( pBasic )
+ sLibName = pBasic->GetName();
}
+ }
- if ( m_xContext.is() )
- {
- Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( m_xContext );
+ if ( m_xContext.is() )
+ {
+ Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( m_xContext );
- Reference < frame::XDispatchProvider > xProv( xDesktop->getCurrentFrame(), UNO_QUERY );
+ Reference < frame::XDispatchProvider > xProv( xDesktop->getCurrentFrame(), UNO_QUERY );
- if ( xProv.is() )
- {
- Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create( m_xContext ) );
-
- Sequence < PropertyValue > aArgs(7);
- aArgs[0].Name = "Document";
- aArgs[0].Value <<= sDocURL;
- aArgs[1].Name = "LibName";
- aArgs[1].Value <<= sLibName;
- aArgs[2].Name = "Name";
- aArgs[2].Value <<= sModName;
- aArgs[3].Name = "Type";
- aArgs[3].Value <<= OUString("Module");
- aArgs[4].Name = "Line";
- aArgs[4].Value <<= static_cast< sal_uInt32 >( nLine1 );
- xHelper->executeDispatch( xProv, ".uno:BasicIDEAppear", OUString(), 0, aArgs );
- }
+ if ( xProv.is() )
+ {
+ Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create( m_xContext ) );
+
+ Sequence < PropertyValue > aArgs(7);
+ aArgs[0].Name = "Document";
+ aArgs[0].Value <<= sDocURL;
+ aArgs[1].Name = "LibName";
+ aArgs[1].Value <<= sLibName;
+ aArgs[2].Name = "Name";
+ aArgs[2].Value <<= sModName;
+ aArgs[3].Name = "Type";
+ aArgs[3].Value <<= OUString("Module");
+ aArgs[4].Name = "Line";
+ aArgs[4].Value <<= static_cast< sal_uInt32 >( nLine1 );
+ xHelper->executeDispatch( xProv, ".uno:BasicIDEAppear", OUString(), 0, aArgs );
}
}
- else
- {
- throw IllegalArgumentException(
- "BasicMethodNodeImpl::invoke: function name not supported!",
- Reference< XInterface >(), 1 );
- }
+
return Any();
}
diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx
index 2d41725882ce..d58c7ec0f4e3 100644
--- a/scripting/source/dlgprov/dlgevtatt.cxx
+++ b/scripting/source/dlgprov/dlgevtatt.cxx
@@ -335,19 +335,14 @@ namespace dlgprov
if ( !m_xEventAttacher.is() )
{
Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
- if ( xSMgr.is() )
- {
- m_xEventAttacher.set( xSMgr->createInstanceWithContext(
- "com.sun.star.script.EventAttacher", m_xContext ), UNO_QUERY );
-
- if ( !m_xEventAttacher.is() )
- throw ServiceNotRegisteredException();
- }
- else
- {
+ if ( !xSMgr.is() )
throw RuntimeException();
- }
+ m_xEventAttacher.set( xSMgr->createInstanceWithContext(
+ "com.sun.star.script.EventAttacher", m_xContext ), UNO_QUERY );
+
+ if ( !m_xEventAttacher.is() )
+ throw ServiceNotRegisteredException();
}
}
OUString sDialogCodeName;
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index 972097da4fb1..d9d829197e6c 100644
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -300,23 +300,7 @@ MasterScriptProvider::getScript( const OUString& scriptURI )
buf.append( "com.sun.star.script.provider.ScriptProviderFor");
buf.append( language );
OUString serviceName = buf.makeStringAndClear();
- if ( providerCache() )
- {
- try
- {
- xScriptProvider.set(
- providerCache()->getProvider( serviceName ),
- UNO_QUERY_THROW );
- }
- catch( const Exception& e )
- {
- throw provider::ScriptFrameworkErrorException(
- e.Message, Reference< XInterface >(),
- sfUri->getName(), language,
- provider::ScriptFrameworkErrorType::NOTSUPPORTED );
- }
- }
- else
+ if ( !providerCache() )
{
throw provider::ScriptFrameworkErrorException(
"No LanguageProviders detected",
@@ -324,6 +308,21 @@ MasterScriptProvider::getScript( const OUString& scriptURI )
sfUri->getName(), language,
provider::ScriptFrameworkErrorType::NOTSUPPORTED );
}
+
+ try
+ {
+ xScriptProvider.set(
+ providerCache()->getProvider( serviceName ),
+ UNO_QUERY_THROW );
+ }
+ catch( const Exception& e )
+ {
+ throw provider::ScriptFrameworkErrorException(
+ e.Message, Reference< XInterface >(),
+ sfUri->getName(), language,
+ provider::ScriptFrameworkErrorType::NOTSUPPORTED );
+ }
+
xScript=xScriptProvider->getScript( scriptURI );
}
else
@@ -457,16 +456,13 @@ MasterScriptProvider::insertByName( const OUString& aName, const Any& aElement )
{
if ( !m_bIsPkgMSP )
{
- if ( m_xMSPPkg.is() )
- {
- Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
- xCont->insertByName( aName, aElement );
- }
- else
+ if ( !m_xMSPPkg.is() )
{
throw RuntimeException( "PackageMasterScriptProvider is unitialised" );
}
+ Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
+ xCont->insertByName( aName, aElement );
}
else
{
@@ -529,16 +525,13 @@ MasterScriptProvider::removeByName( const OUString& Name )
{
if ( !m_bIsPkgMSP )
{
- if ( m_xMSPPkg.is() )
- {
- Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
- xCont->removeByName( Name );
- }
- else
+ if ( !m_xMSPPkg.is() )
{
throw RuntimeException( "PackageMasterScriptProvider is unitialised" );
}
+ Reference< container::XNameContainer > xCont( m_xMSPPkg, UNO_QUERY_THROW );
+ xCont->removeByName( Name );
}
else
{
diff --git a/sd/source/core/stlfamily.cxx b/sd/source/core/stlfamily.cxx
index 3f06b27627d7..6bc9a7024f65 100644
--- a/sd/source/core/stlfamily.cxx
+++ b/sd/source/core/stlfamily.cxx
@@ -485,22 +485,20 @@ void SdStyleFamily::setPropertyValue( const OUString& , const Any& )
Any SdStyleFamily::getPropertyValue( const OUString& PropertyName )
{
- if ( PropertyName == "DisplayName" )
+ if ( PropertyName != "DisplayName" )
{
- SolarMutexGuard aGuard;
- OUString sDisplayName;
- switch( mnFamily )
- {
- case SD_STYLE_FAMILY_MASTERPAGE: sDisplayName = getName(); break;
- case SD_STYLE_FAMILY_CELL: sDisplayName = SdResId(STR_CELL_STYLE_FAMILY); break;
- default: sDisplayName = SdResId(STR_GRAPHICS_STYLE_FAMILY); break;
- }
- return Any( sDisplayName );
+ throw UnknownPropertyException( "unknown property: " + PropertyName, static_cast<OWeakObject *>(this) );
}
- else
+
+ SolarMutexGuard aGuard;
+ OUString sDisplayName;
+ switch( mnFamily )
{
- throw UnknownPropertyException( "unknown property: " + PropertyName, static_cast<OWeakObject *>(this) );
+ case SD_STYLE_FAMILY_MASTERPAGE: sDisplayName = getName(); break;
+ case SD_STYLE_FAMILY_CELL: sDisplayName = SdResId(STR_CELL_STYLE_FAMILY); break;
+ default: sDisplayName = SdResId(STR_GRAPHICS_STYLE_FAMILY); break;
}
+ return Any( sDisplayName );
}
void SdStyleFamily::addPropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>& )
diff --git a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx
index 48d8bdc45081..4298e8144af7 100644
--- a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx
+++ b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx
@@ -219,14 +219,12 @@ uno::Reference<XAccessible> SAL_CALL
aGuard.clear();
// Forward request to children manager.
- if (pChildrenManager != nullptr)
- {
- return pChildrenManager->GetChild (nIndex);
- }
- else
+ if (pChildrenManager == nullptr)
throw lang::IndexOutOfBoundsException (
"no accessible child with index " + OUString::number(nIndex),
static_cast<uno::XWeak*>(this));
+
+ return pChildrenManager->GetChild (nIndex);
}
OUString SAL_CALL
diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
index 8268c5506643..59246f036468 100644
--- a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
+++ b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
@@ -499,10 +499,10 @@ void SAL_CALL AccessibleSlideSorterView::selectAccessibleChild (sal_Int32 nChild
const SolarMutexGuard aSolarGuard;
AccessibleSlideSorterObject* pChild = mpImpl->GetAccessibleChild(nChildIndex);
- if (pChild != nullptr)
- mrSlideSorter.GetController().GetPageSelector().SelectPage(pChild->GetPageNumber());
- else
+ if (pChild == nullptr)
throw lang::IndexOutOfBoundsException();
+
+ mrSlideSorter.GetController().GetPageSelector().SelectPage(pChild->GetPageNumber());
}
sal_Bool SAL_CALL AccessibleSlideSorterView::isAccessibleChildSelected (sal_Int32 nChildIndex)
@@ -512,12 +512,12 @@ sal_Bool SAL_CALL AccessibleSlideSorterView::isAccessibleChildSelected (sal_Int3
const SolarMutexGuard aSolarGuard;
AccessibleSlideSorterObject* pChild = mpImpl->GetAccessibleChild(nChildIndex);
- if (pChild != nullptr)
- bIsSelected = mrSlideSorter.GetController().GetPageSelector().IsPageSelected(
- pChild->GetPageNumber());
- else
+ if (pChild == nullptr)
throw lang::IndexOutOfBoundsException();
+ bIsSelected = mrSlideSorter.GetController().GetPageSelector().IsPageSelected(
+ pChild->GetPageNumber());
+
return bIsSelected;
}
@@ -578,10 +578,10 @@ void SAL_CALL AccessibleSlideSorterView::deselectAccessibleChild (sal_Int32 nChi
const SolarMutexGuard aSolarGuard;
AccessibleSlideSorterObject* pChild = mpImpl->GetAccessibleChild(nChildIndex);
- if (pChild != nullptr)
- mrSlideSorter.GetController().GetPageSelector().DeselectPage(pChild->GetPageNumber());
- else
+ if (pChild == nullptr)
throw lang::IndexOutOfBoundsException();
+
+ mrSlideSorter.GetController().GetPageSelector().DeselectPage(pChild->GetPageNumber());
}
// XServiceInfo
diff --git a/sd/source/ui/framework/factories/BasicPaneFactory.cxx b/sd/source/ui/framework/factories/BasicPaneFactory.cxx
index 0660bdabd107..8f0cc742bc61 100644
--- a/sd/source/ui/framework/factories/BasicPaneFactory.cxx
+++ b/sd/source/ui/framework/factories/BasicPaneFactory.cxx
@@ -220,44 +220,7 @@ Reference<XResource> SAL_CALL BasicPaneFactory::createResource (
return rPane.CompareURL(rxPaneId->getResourceURL());
} ));
- if (iDescriptor != mpPaneContainer->end())
- {
- if (iDescriptor->mxPane.is())
- {
- // The pane has already been created and is still active (has
- // not yet been released). This should not happen.
- xPane = iDescriptor->mxPane;
- }
- else
- {
- // Create a new pane.
- switch (iDescriptor->mePaneId)
- {
- case CenterPaneId:
- xPane = CreateFrameWindowPane(rxPaneId);
- break;
-
- case FullScreenPaneId:
- xPane = CreateFullScreenPane(mxComponentContext, rxPaneId);
- break;
-
- case LeftImpressPaneId:
- case LeftDrawPaneId:
- xPane = CreateChildWindowPane(
- rxPaneId,
- *iDescriptor);
- break;
- }
- iDescriptor->mxPane = xPane;
-
- // Listen for the pane being disposed.
- Reference<lang::XComponent> xComponent (xPane, UNO_QUERY);
- if (xComponent.is())
- xComponent->addEventListener(this);
- }
- iDescriptor->mbIsReleased = false;
- }
- else
+ if (iDescriptor == mpPaneContainer->end())
{
// The requested pane can not be created by any of the factories
// managed by the called BasicPaneFactory object.
@@ -266,6 +229,42 @@ Reference<XResource> SAL_CALL BasicPaneFactory::createResource (
0);
}
+ if (iDescriptor->mxPane.is())
+ {
+ // The pane has already been created and is still active (has
+ // not yet been released). This should not happen.
+ xPane = iDescriptor->mxPane;
+ }
+ else
+ {
+ // Create a new pane.
+ switch (iDescriptor->mePaneId)
+ {
+ case CenterPaneId:
+ xPane = CreateFrameWindowPane(rxPaneId);
+ break;
+
+ case FullScreenPaneId:
+ xPane = CreateFullScreenPane(mxComponentContext, rxPaneId);
+ break;
+
+ case LeftImpressPaneId:
+ case LeftDrawPaneId:
+ xPane = CreateChildWindowPane(
+ rxPaneId,
+ *iDescriptor);
+ break;
+ }
+ iDescriptor->mxPane = xPane;
+
+ // Listen for the pane being disposed.
+ Reference<lang::XComponent> xComponent (xPane, UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener(this);
+ }
+ iDescriptor->mbIsReleased = false;
+
+
return xPane;
}
@@ -282,33 +281,7 @@ void SAL_CALL BasicPaneFactory::releaseResource (
mpPaneContainer->end(),
[&] (PaneDescriptor const& rPane) { return rPane.ComparePane(rxPane); } ));
- if (iDescriptor != mpPaneContainer->end())
- {
- // The given pane was created by one of the factories. Child
- // windows are just hidden and will be reused when requested later.
- // Other windows are disposed and their reference is reset so that
- // on the next createPane() call for the same pane type the pane is
- // created anew.
- ChildWindowPane* pChildWindowPane = dynamic_cast<ChildWindowPane*>(rxPane.get());
- if (pChildWindowPane != nullptr)
- {
- iDescriptor->mbIsReleased = true;
- pChildWindowPane->Hide();
- }
- else
- {
- iDescriptor->mxPane = nullptr;
- Reference<XComponent> xComponent (rxPane, UNO_QUERY);
- if (xComponent.is())
- {
- // We are disposing the pane and do not have to be informed of
- // that.
- xComponent->removeEventListener(this);
- xComponent->dispose();
- }
- }
- }
- else
+ if (iDescriptor == mpPaneContainer->end())
{
// The given XPane reference is either empty or the pane was not
// created by any of the factories managed by the called
@@ -317,6 +290,31 @@ void SAL_CALL BasicPaneFactory::releaseResource (
nullptr,
0);
}
+
+ // The given pane was created by one of the factories. Child
+ // windows are just hidden and will be reused when requested later.
+ // Other windows are disposed and their reference is reset so that
+ // on the next createPane() call for the same pane type the pane is
+ // created anew.
+ ChildWindowPane* pChildWindowPane = dynamic_cast<ChildWindowPane*>(rxPane.get());
+ if (pChildWindowPane != nullptr)
+ {
+ iDescriptor->mbIsReleased = true;
+ pChildWindowPane->Hide();
+ }
+ else
+ {
+ iDescriptor->mxPane = nullptr;
+ Reference<XComponent> xComponent (rxPane, UNO_QUERY);
+ if (xComponent.is())
+ {
+ // We are disposing the pane and do not have to be informed of
+ // that.
+ xComponent->removeEventListener(this);
+ xComponent->dispose();
+ }
+ }
+
}
//===== XConfigurationChangeListener ==========================================
diff --git a/sd/source/ui/framework/factories/BasicToolBarFactory.cxx b/sd/source/ui/framework/factories/BasicToolBarFactory.cxx
index 8967d4b4eb72..dab3ba76d491 100644
--- a/sd/source/ui/framework/factories/BasicToolBarFactory.cxx
+++ b/sd/source/ui/framework/factories/BasicToolBarFactory.cxx
@@ -124,15 +124,10 @@ Reference<XResource> SAL_CALL BasicToolBarFactory::createResource (
{
ThrowIfDisposed();
- Reference<XResource> xToolBar;
-
- if (rxToolBarId->getResourceURL() == FrameworkHelper::msViewTabBarURL)
- {
- xToolBar = new ViewTabBar(rxToolBarId, mxController);
- }
- else
+ if (rxToolBarId->getResourceURL() != FrameworkHelper::msViewTabBarURL)
throw lang::IllegalArgumentException();
+ Reference<XResource> xToolBar = new ViewTabBar(rxToolBarId, mxController);;
return xToolBar;
}
diff --git a/sd/source/ui/framework/factories/BasicViewFactory.cxx b/sd/source/ui/framework/factories/BasicViewFactory.cxx
index 4c8cb0203a16..f1ed3d6e8d40 100644
--- a/sd/source/ui/framework/factories/BasicViewFactory.cxx
+++ b/sd/source/ui/framework/factories/BasicViewFactory.cxx
@@ -195,41 +195,39 @@ void SAL_CALL BasicViewFactory::releaseResource (const Reference<XResource>& rxV
[&] (std::shared_ptr<ViewDescriptor> const& pVD) {
return ViewDescriptor::CompareView(pVD, rxView);
} ));
- if (iViewShell != mpViewShellContainer->end())
+ if (iViewShell == mpViewShellContainer->end())
{
- std::shared_ptr<ViewShell> pViewShell ((*iViewShell)->mpViewShell);
+ throw lang::IllegalArgumentException();
+ }
+
+ std::shared_ptr<ViewShell> pViewShell ((*iViewShell)->mpViewShell);
- if ((*iViewShell)->mxViewId->isBoundToURL(
- FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
+ if ((*iViewShell)->mxViewId->isBoundToURL(
+ FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
+ {
+ // Obtain a pointer to and connect to the frame view of the
+ // view. The next view, that is created, will be
+ // initialized with this frame view.
+ if (mpFrameView == nullptr)
{
- // Obtain a pointer to and connect to the frame view of the
- // view. The next view, that is created, will be
- // initialized with this frame view.
- if (mpFrameView == nullptr)
- {
- mpFrameView = pViewShell->GetFrameView();
- if (mpFrameView)
- mpFrameView->Connect();
- }
-
- // With the view in the center pane the sub controller is
- // released, too.
- mpBase->GetDrawController().SetSubController(
- Reference<drawing::XDrawSubController>());
-
- SfxViewShell* pSfxViewShell = pViewShell->GetViewShell();
- if (pSfxViewShell != nullptr)
- pSfxViewShell->DisconnectAllClients();
+ mpFrameView = pViewShell->GetFrameView();
+ if (mpFrameView)
+ mpFrameView->Connect();
}
- ReleaseView(*iViewShell, false);
+ // With the view in the center pane the sub controller is
+ // released, too.
+ mpBase->GetDrawController().SetSubController(
+ Reference<drawing::XDrawSubController>());
- mpViewShellContainer->erase(iViewShell);
- }
- else
- {
- throw lang::IllegalArgumentException();
+ SfxViewShell* pSfxViewShell = pViewShell->GetViewShell();
+ if (pSfxViewShell != nullptr)
+ pSfxViewShell->DisconnectAllClients();
}
+
+ ReleaseView(*iViewShell, false);
+
+ mpViewShellContainer->erase(iViewShell);
}
}
diff --git a/sd/source/ui/framework/factories/FullScreenPane.cxx b/sd/source/ui/framework/factories/FullScreenPane.cxx
index ca992a26ca66..ba2bc482b0ed 100644
--- a/sd/source/ui/framework/factories/FullScreenPane.cxx
+++ b/sd/source/ui/framework/factories/FullScreenPane.cxx
@@ -190,26 +190,24 @@ IMPL_LINK(FullScreenPane, WindowEventHandler, VclWindowEvent&, rEvent, void)
Reference<rendering::XCanvas> FullScreenPane::CreateCanvas()
{
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(mxWindow);
- if (pWindow)
- {
- Sequence<Any> aArg (5);
-
- // common: first any is VCL pointer to window (for VCL canvas)
- aArg[0] <<= reinterpret_cast<sal_Int64>(pWindow.get());
- aArg[1] = Any();
- aArg[2] <<= css::awt::Rectangle();
- aArg[3] <<= false;
- aArg[4] <<= mxWindow;
-
- Reference<lang::XMultiServiceFactory> xFactory (
- mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
- return Reference<rendering::XCanvas>(
- xFactory->createInstanceWithArguments("com.sun.star.rendering.SpriteCanvas.VCL",
- aArg),
- UNO_QUERY);
- }
- else
+ if (!pWindow)
throw RuntimeException();
+
+ Sequence<Any> aArg (5);
+
+ // common: first any is VCL pointer to window (for VCL canvas)
+ aArg[0] <<= reinterpret_cast<sal_Int64>(pWindow.get());
+ aArg[1] = Any();
+ aArg[2] <<= css::awt::Rectangle();
+ aArg[3] <<= false;
+ aArg[4] <<= mxWindow;
+
+ Reference<lang::XMultiServiceFactory> xFactory (
+ mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
+ return Reference<rendering::XCanvas>(
+ xFactory->createInstanceWithArguments("com.sun.star.rendering.SpriteCanvas.VCL",
+ aArg),
+ UNO_QUERY);
}
void FullScreenPane::ExtractArguments (
diff --git a/sd/source/ui/presenter/PresenterHelper.cxx b/sd/source/ui/presenter/PresenterHelper.cxx
index 81222e4e71da..1ddc4296f9e1 100644
--- a/sd/source/ui/presenter/PresenterHelper.cxx
+++ b/sd/source/ui/presenter/PresenterHelper.cxx
@@ -142,29 +142,27 @@ Reference<rendering::XCanvas> SAL_CALL PresenterHelper::createCanvas (
// No shared window is given or an explicit canvas service name is
// specified. Create a new canvas.
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(rxWindow);
- if (pWindow)
- {
- Sequence<Any> aArg (5);
-
- // common: first any is VCL pointer to window (for VCL canvas)
- aArg[0] <<= reinterpret_cast<sal_Int64>(pWindow.get());
- aArg[1] = Any();
- aArg[2] <<= css::awt::Rectangle();
- aArg[3] <<= false;
- aArg[4] <<= rxWindow;
-
- Reference<lang::XMultiServiceFactory> xFactory (
- mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
- return Reference<rendering::XCanvas>(
- xFactory->createInstanceWithArguments(
- !rsOptionalCanvasServiceName.isEmpty()
- ? rsOptionalCanvasServiceName
- : OUString("com.sun.star.rendering.Canvas.VCL"),
- aArg),
- UNO_QUERY);
- }
- else
+ if (!pWindow)
throw RuntimeException();
+
+ Sequence<Any> aArg (5);
+
+ // common: first any is VCL pointer to window (for VCL canvas)
+ aArg[0] <<= reinterpret_cast<sal_Int64>(pWindow.get());
+ aArg[1] = Any();
+ aArg[2] <<= css::awt::Rectangle();
+ aArg[3] <<= false;
+ aArg[4] <<= rxWindow;
+
+ Reference<lang::XMultiServiceFactory> xFactory (
+ mxComponentContext->getServiceManager(), UNO_QUERY_THROW);
+ return Reference<rendering::XCanvas>(
+ xFactory->createInstanceWithArguments(
+ !rsOptionalCanvasServiceName.isEmpty()
+ ? rsOptionalCanvasServiceName
+ : OUString("com.sun.star.rendering.Canvas.VCL"),
+ aArg),
+ UNO_QUERY);
}
void SAL_CALL PresenterHelper::toTop (
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
index 78517c6086f0..b6ce91cc7ba2 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterService.cxx
@@ -68,47 +68,46 @@ void SAL_CALL SlideSorterService::initialize (const Sequence<Any>& rArguments)
{
ThrowIfDisposed();
- if (rArguments.getLength() == 3)
- {
- try
- {
- mxViewId.set(rArguments[0], UNO_QUERY_THROW);
-
- // Get the XController.
- Reference<frame::XController> xController (rArguments[1], UNO_QUERY_THROW);
-
- // Tunnel through the controller to obtain a ViewShellBase.
- ViewShellBase* pBase = nullptr;
- Reference<lang::XUnoTunnel> xTunnel (xController, UNO_QUERY_THROW);
- ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
- xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
- if (pController != nullptr)
- pBase = pController->GetViewShellBase();
-
- // Get the parent window.
- mxParentWindow.set(rArguments[2], UNO_QUERY_THROW);
- VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow(mxParentWindow);
-
- mxParentWindow->addWindowListener(this);
-
- if (pBase != nullptr && pParentWindow)
- mpSlideSorter = SlideSorter::CreateSlideSorter(
- *pBase,
- nullptr,
- *pParentWindow);
-
- Resize();
- }
- catch (RuntimeException&)
- {
- throw;
- }
- }
- else
+ if (rArguments.getLength() != 3)
{
throw RuntimeException("SlideSorterService: invalid number of arguments",
static_cast<drawing::XDrawView*>(this));
}
+
+ try
+ {
+ mxViewId.set(rArguments[0], UNO_QUERY_THROW);
+
+ // Get the XController.
+ Reference<frame::XController> xController (rArguments[1], UNO_QUERY_THROW);
+
+ // Tunnel through the controller to obtain a ViewShellBase.
+ ViewShellBase* pBase = nullptr;
+ Reference<lang::XUnoTunnel> xTunnel (xController, UNO_QUERY_THROW);
+ ::sd::DrawController* pController = reinterpret_cast<sd::DrawController*>(
+ xTunnel->getSomething(sd::DrawController::getUnoTunnelId()));
+ if (pController != nullptr)
+ pBase = pController->GetViewShellBase();
+
+ // Get the parent window.
+ mxParentWindow.set(rArguments[2], UNO_QUERY_THROW);
+ VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow(mxParentWindow);
+
+ mxParentWindow->addWindowListener(this);
+
+ if (pBase != nullptr && pParentWindow)
+ mpSlideSorter = SlideSorter::CreateSlideSorter(
+ *pBase,
+ nullptr,
+ *pParentWindow);
+
+ Resize();
+ }
+ catch (RuntimeException&)
+ {
+ throw;
+ }
+
}
//----- XView -----------------------------------------------------------------
diff --git a/sd/source/ui/tools/PropertySet.cxx b/sd/source/ui/tools/PropertySet.cxx
index d4aa8bd223e1..e7c4c32739b5 100644
--- a/sd/source/ui/tools/PropertySet.cxx
+++ b/sd/source/ui/tools/PropertySet.cxx
@@ -104,14 +104,13 @@ void SAL_CALL PropertySet::removePropertyChangeListener (
return listener.second == rxListener;
}));
- if (iListener != mpChangeListeners->end())
- {
- mpChangeListeners->erase(iListener);
- }
- else
+ if (iListener == mpChangeListeners->end())
{
throw lang::IllegalArgumentException();
}
+
+ mpChangeListeners->erase(iListener);
+
}
void SAL_CALL PropertySet::addVetoableChangeListener (
diff --git a/sd/source/ui/unoidl/unocpres.cxx b/sd/source/ui/unoidl/unocpres.cxx
index b27a8a99db77..a2690534a21f 100644
--- a/sd/source/ui/unoidl/unocpres.cxx
+++ b/sd/source/ui/unoidl/unocpres.cxx
@@ -363,11 +363,11 @@ void SAL_CALL SdXCustomPresentationAccess::removeByName( const OUString& Name )
SdCustomShow* pShow = getSdCustomShow(Name);
SdCustomShowList* pList = GetCustomShowList();
- if(pList && pShow)
- delete pList->Remove( pShow );
- else
+ if(!pList || !pShow)
throw container::NoSuchElementException();
+ delete pList->Remove( pShow );
+
mrModel.SetModified();
}
@@ -383,20 +383,14 @@ uno::Any SAL_CALL SdXCustomPresentationAccess::getByName( const OUString& aName
{
SolarMutexGuard aGuard;
- uno::Any aAny;
-
SdCustomShow* pShow = getSdCustomShow(aName);
- if(pShow)
- {
- uno::Reference< container::XIndexContainer > xRef( pShow->getUnoCustomShow(), uno::UNO_QUERY );
- aAny <<= xRef;
- }
- else
+ if(!pShow)
{
throw container::NoSuchElementException();
}
- return aAny;
+ uno::Reference< container::XIndexContainer > xRef( pShow->getUnoCustomShow(), uno::UNO_QUERY );
+ return uno::Any(xRef);
}
uno::Sequence< OUString > SAL_CALL SdXCustomPresentationAccess::getElementNames()