diff options
-rw-r--r-- | basctl/source/basicide/basicrenderable.cxx | 62 | ||||
-rw-r--r-- | chart2/source/model/main/ChartModel.cxx | 30 | ||||
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 10 | ||||
-rw-r--r-- | comphelper/source/container/IndexedPropertyValuesContainer.cxx | 92 | ||||
-rw-r--r-- | comphelper/source/eventattachermgr/eventattachermgr.cxx | 16 | ||||
-rw-r--r-- | comphelper/source/misc/mimeconfighelper.cxx | 17 | ||||
-rw-r--r-- | comphelper/source/streaming/seqinputstreamserv.cxx | 20 | ||||
-rw-r--r-- | comphelper/source/xml/ofopxmlhelper.cxx | 13 | ||||
-rw-r--r-- | compilerplugins/clang/flatten.cxx | 2 | ||||
-rw-r--r-- | configmgr/source/xcuparser.cxx | 29 |
10 files changed, 130 insertions, 161 deletions
diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx index 1e51245735b1..f19d16e8189a 100644 --- a/basctl/source/basicide/basicrenderable.cxx +++ b/basctl/source/basicide/basicrenderable.cxx @@ -92,24 +92,23 @@ sal_Int32 SAL_CALL Renderable::getRendererCount ( sal_Int32 nCount = 0; if( mpWindow ) { - if (VclPtr<Printer> pPrinter = getPrinter()) + VclPtr<Printer> pPrinter = getPrinter(); + if (!pPrinter) + throw lang::IllegalArgumentException(); + + nCount = mpWindow->countPages( pPrinter ); + sal_Int64 nContent = getIntValue( "PrintContent", -1 ); + if( nContent == 1 ) { - nCount = mpWindow->countPages( pPrinter ); - sal_Int64 nContent = getIntValue( "PrintContent", -1 ); - if( nContent == 1 ) + OUString aPageRange( getStringValue( "PageRange" ) ); + if( !aPageRange.isEmpty() ) { - OUString aPageRange( getStringValue( "PageRange" ) ); - if( !aPageRange.isEmpty() ) - { - StringRangeEnumerator aRangeEnum( aPageRange, 0, nCount-1 ); - sal_Int32 nSelCount = aRangeEnum.size(); - if( nSelCount >= 0 ) - nCount = nSelCount; - } + StringRangeEnumerator aRangeEnum( aPageRange, 0, nCount-1 ); + sal_Int32 nSelCount = aRangeEnum.size(); + if( nSelCount >= 0 ) + nCount = nSelCount; } } - else - throw lang::IllegalArgumentException(); } return nCount; @@ -151,31 +150,30 @@ void SAL_CALL Renderable::render ( if( mpWindow ) { - if (VclPtr<Printer> pPrinter = getPrinter()) + VclPtr<Printer> pPrinter = getPrinter(); + if (!pPrinter) + throw lang::IllegalArgumentException(); + + sal_Int64 nContent = getIntValue( "PrintContent", -1 ); + if( nContent == 1 ) { - sal_Int64 nContent = getIntValue( "PrintContent", -1 ); - if( nContent == 1 ) + OUString aPageRange( getStringValue( "PageRange" ) ); + if( !aPageRange.isEmpty() ) { - OUString aPageRange( getStringValue( "PageRange" ) ); - if( !aPageRange.isEmpty() ) - { - sal_Int32 nPageCount = mpWindow->countPages( pPrinter ); - StringRangeEnumerator aRangeEnum( aPageRange, 0, nPageCount-1 ); - StringRangeEnumerator::Iterator it = aRangeEnum.begin(); - for( ; it != aRangeEnum.end() && nRenderer; --nRenderer ) - ++it; - - sal_Int32 nPage = ( it != aRangeEnum.end() ) ? *it : nRenderer; - mpWindow->printPage( nPage, pPrinter ); - } - else - mpWindow->printPage( nRenderer, pPrinter ); + sal_Int32 nPageCount = mpWindow->countPages( pPrinter ); + StringRangeEnumerator aRangeEnum( aPageRange, 0, nPageCount-1 ); + StringRangeEnumerator::Iterator it = aRangeEnum.begin(); + for( ; it != aRangeEnum.end() && nRenderer; --nRenderer ) + ++it; + + sal_Int32 nPage = ( it != aRangeEnum.end() ) ? *it : nRenderer; + mpWindow->printPage( nPage, pPrinter ); } else mpWindow->printPage( nRenderer, pPrinter ); } else - throw lang::IllegalArgumentException(); + mpWindow->printPage( nRenderer, pPrinter ); } } diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index c0289c3af548..37b1f4967588 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -1071,28 +1071,24 @@ embed::VisualRepresentation SAL_CALL ChartModel::getPreferredVisualRepresentatio uno::Any SAL_CALL ChartModel::getTransferData( const datatransfer::DataFlavor& aFlavor ) { uno::Any aResult; - if( isDataFlavorSupported( aFlavor )) + if( !isDataFlavorSupported( aFlavor ) ) + throw datatransfer::UnsupportedFlavorException( + aFlavor.MimeType, static_cast< ::cppu::OWeakObject* >( this )); + + try { - try - { - //get view from old api wrapper - Reference< datatransfer::XTransferable > xTransferable( - createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); - if( xTransferable.is() && - xTransferable->isDataFlavorSupported( aFlavor )) - { - aResult = xTransferable->getTransferData( aFlavor ); - } - } - catch (const uno::Exception& ex) + //get view from old api wrapper + Reference< datatransfer::XTransferable > xTransferable( + createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); + if( xTransferable.is() && + xTransferable->isDataFlavorSupported( aFlavor )) { - ASSERT_EXCEPTION( ex ); + aResult = xTransferable->getTransferData( aFlavor ); } } - else + catch (const uno::Exception& ex) { - throw datatransfer::UnsupportedFlavorException( - aFlavor.MimeType, static_cast< ::cppu::OWeakObject* >( this )); + ASSERT_EXCEPTION( ex ); } return aResult; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 50717889acd9..283dd87f0956 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -3037,14 +3037,10 @@ void SAL_CALL ChartView::setPropertyValue( const OUString& rPropertyName Any SAL_CALL ChartView::getPropertyValue( const OUString& rPropertyName ) { - Any aRet; - if( rPropertyName == "Resolution" ) - { - aRet <<= m_aPageResolution; - } - else + if( rPropertyName != "Resolution" ) throw beans::UnknownPropertyException( "unknown property was tried to get from chart wizard", nullptr ); - return aRet; + + return Any(m_aPageResolution); } void SAL_CALL ChartView::addPropertyChangeListener( diff --git a/comphelper/source/container/IndexedPropertyValuesContainer.cxx b/comphelper/source/container/IndexedPropertyValuesContainer.cxx index d577ebe1ca24..1853ba71918b 100644 --- a/comphelper/source/container/IndexedPropertyValuesContainer.cxx +++ b/comphelper/source/container/IndexedPropertyValuesContainer.cxx @@ -70,47 +70,15 @@ IndexedPropertyValuesContainer::IndexedPropertyValuesContainer() throw() void SAL_CALL IndexedPropertyValuesContainer::insertByIndex( sal_Int32 nIndex, const css::uno::Any& aElement ) { sal_Int32 nSize(maProperties.size()); - if ((nSize >= nIndex) && (nIndex >= 0)) - { - uno::Sequence<beans::PropertyValue> aProps; - if (!(aElement >>= aProps)) - throw lang::IllegalArgumentException(); - if (nSize == nIndex) - maProperties.push_back(aProps); - else - { - IndexedPropertyValues::iterator aItr; - if ((nIndex * 2) < nSize) - { - aItr = maProperties.begin(); - sal_Int32 i(0); - while(i < nIndex) - { - ++i; - ++aItr; - } - } - else - { - aItr = maProperties.end(); - sal_Int32 i(nSize); - while(i > nIndex) - { - --i; - --aItr; - } - } - maProperties.insert(aItr, aProps); - } - } - else + if ((nSize < nIndex) || (nIndex < 0)) throw lang::IndexOutOfBoundsException(); -} -void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex ) -{ - sal_Int32 nSize(maProperties.size()); - if ((nIndex < nSize) && (nIndex >= 0)) + uno::Sequence<beans::PropertyValue> aProps; + if (!(aElement >>= aProps)) + throw lang::IllegalArgumentException(); + if (nSize == nIndex) + maProperties.push_back(aProps); + else { IndexedPropertyValues::iterator aItr; if ((nIndex * 2) < nSize) @@ -133,25 +101,51 @@ void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex ) --aItr; } } - maProperties.erase(aItr); + maProperties.insert(aItr, aProps); } - else - throw lang::IndexOutOfBoundsException(); } -// XIndexReplace -void SAL_CALL IndexedPropertyValuesContainer::replaceByIndex( sal_Int32 nIndex, const css::uno::Any& aElement ) +void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex ) { sal_Int32 nSize(maProperties.size()); - if ((nIndex < nSize) && (nIndex >= 0)) + if ((nIndex >= nSize) || (nIndex < 0)) + throw lang::IndexOutOfBoundsException(); + + IndexedPropertyValues::iterator aItr; + if ((nIndex * 2) < nSize) { - uno::Sequence<beans::PropertyValue> aProps; - if (!(aElement >>= aProps)) - throw lang::IllegalArgumentException(); - maProperties[nIndex] = aProps; + aItr = maProperties.begin(); + sal_Int32 i(0); + while(i < nIndex) + { + ++i; + ++aItr; + } } else + { + aItr = maProperties.end(); + sal_Int32 i(nSize); + while(i > nIndex) + { + --i; + --aItr; + } + } + maProperties.erase(aItr); +} + +// XIndexReplace +void SAL_CALL IndexedPropertyValuesContainer::replaceByIndex( sal_Int32 nIndex, const css::uno::Any& aElement ) +{ + sal_Int32 nSize(maProperties.size()); + if ((nIndex >= nSize) || (nIndex < 0)) throw lang::IndexOutOfBoundsException(); + + uno::Sequence<beans::PropertyValue> aProps; + if (!(aElement >>= aProps)) + throw lang::IllegalArgumentException(); + maProperties[nIndex] = aProps; } // XIndexAccess diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx index 19f755c866b7..578d5fd1a6a9 100644 --- a/comphelper/source/eventattachermgr/eventattachermgr.cxx +++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx @@ -221,10 +221,9 @@ void AttacherAllListener_Impl::convertToEventReturn( Any & rRet, const Type & rR } else if( !rRet.getValueType().equals( rRetType ) ) { - if( mxManager->xConverter.is() ) - rRet = mxManager->xConverter->convertTo( rRet, rRetType ); - else + if( !mxManager->xConverter.is() ) throw CannotConvertException(); + rRet = mxManager->xConverter->convertTo( rRet, rRetType ); } } @@ -541,14 +540,11 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference if( static_cast< std::deque< AttacherIndex_Impl >::size_type>(nIndex) >= aIndex.size() ) { // read older files - if( nVersion == 1 ) - { - insertEntry( nIndex ); - attach( nIndex, xObject, Helper ); - return; - } - else + if( nVersion != 1 ) throw IllegalArgumentException(); + insertEntry( nIndex ); + attach( nIndex, xObject, Helper ); + return; } std::deque< AttacherIndex_Impl >::iterator aCurrentPosition = aIndex.begin() + nIndex; diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx index a923fdcbbcbc..a347072dec66 100644 --- a/comphelper/source/misc/mimeconfighelper.cxx +++ b/comphelper/source/misc/mimeconfighelper.cxx @@ -307,17 +307,14 @@ uno::Sequence< beans::NamedValue > MimeConfigurationHelper::GetObjPropsFromConfi if ( aObjPropNames[nInd] == "ObjectVerbs" ) { uno::Sequence< OUString > aVerbShortcuts; - if ( xObjectProps->getByName( aObjPropNames[nInd] ) >>= aVerbShortcuts ) - { - uno::Sequence< embed::VerbDescriptor > aVerbDescriptors( aVerbShortcuts.getLength() ); - for ( sal_Int32 nVerbI = 0; nVerbI < aVerbShortcuts.getLength(); nVerbI++ ) - if ( !GetVerbByShortcut( aVerbShortcuts[nVerbI], aVerbDescriptors[nVerbI] ) ) - throw uno::RuntimeException(); - - aResult[nInd+1].Value <<= aVerbDescriptors; - } - else + if ( !(xObjectProps->getByName( aObjPropNames[nInd] ) >>= aVerbShortcuts) ) throw uno::RuntimeException(); + uno::Sequence< embed::VerbDescriptor > aVerbDescriptors( aVerbShortcuts.getLength() ); + for ( sal_Int32 nVerbI = 0; nVerbI < aVerbShortcuts.getLength(); nVerbI++ ) + if ( !GetVerbByShortcut( aVerbShortcuts[nVerbI], aVerbDescriptors[nVerbI] ) ) + throw uno::RuntimeException(); + + aResult[nInd+1].Value <<= aVerbDescriptors; } else aResult[nInd+1].Value = xObjectProps->getByName( aObjPropNames[nInd] ); diff --git a/comphelper/source/streaming/seqinputstreamserv.cxx b/comphelper/source/streaming/seqinputstreamserv.cxx index 0bee70b8f303..7fa619442318 100644 --- a/comphelper/source/streaming/seqinputstreamserv.cxx +++ b/comphelper/source/streaming/seqinputstreamserv.cxx @@ -194,20 +194,18 @@ void SAL_CALL SequenceInputStreamService::initialize( const uno::Sequence< css:: 1 ); uno::Sequence< sal_Int8 > aSeq; - if ( aArguments[0] >>= aSeq ) - { - uno::Reference< io::XInputStream > xInputStream( - static_cast< ::cppu::OWeakObject* >( new ::comphelper::SequenceInputStream( aSeq ) ), - uno::UNO_QUERY_THROW ); - uno::Reference< io::XSeekable > xSeekable( xInputStream, uno::UNO_QUERY_THROW ); - m_xInputStream = xInputStream; - m_xSeekable = xSeekable; - m_bInitialized = true; - } - else + if ( !(aArguments[0] >>= aSeq) ) throw lang::IllegalArgumentException( "Unexpected type of argument!", static_cast< ::cppu::OWeakObject* >(this), 1 ); + + uno::Reference< io::XInputStream > xInputStream( + static_cast< ::cppu::OWeakObject* >( new ::comphelper::SequenceInputStream( aSeq ) ), + uno::UNO_QUERY_THROW ); + uno::Reference< io::XSeekable > xSeekable( xInputStream, uno::UNO_QUERY_THROW ); + m_xInputStream = xInputStream; + m_xSeekable = xSeekable; + m_bInitialized = true; } } // anonymous namespace diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx index 58e4a0fbc7a2..0d4e164a2f66 100644 --- a/comphelper/source/xml/ofopxmlhelper.cxx +++ b/comphelper/source/xml/ofopxmlhelper.cxx @@ -145,18 +145,15 @@ void WriteRelationsInfoSequence( uno::Reference< css::xml::sax::XAttributeList > xAttrList( pAttrList ); for( sal_Int32 nSecInd = 0; nSecInd < aSequence[nInd].getLength(); nSecInd++ ) { - if ( aSequence[nInd][nSecInd].First == "Id" - || aSequence[nInd][nSecInd].First == "Type" - || aSequence[nInd][nSecInd].First == "TargetMode" - || aSequence[nInd][nSecInd].First == "Target" ) - { - pAttrList->AddAttribute( aSequence[nInd][nSecInd].First, aCDATAString, aSequence[nInd][nSecInd].Second ); - } - else + if ( !(aSequence[nInd][nSecInd].First == "Id" + || aSequence[nInd][nSecInd].First == "Type" + || aSequence[nInd][nSecInd].First == "TargetMode" + || aSequence[nInd][nSecInd].First == "Target") ) { // TODO/LATER: should the extensions be allowed? throw lang::IllegalArgumentException(); } + pAttrList->AddAttribute( aSequence[nInd][nSecInd].First, aCDATAString, aSequence[nInd][nSecInd].Second ); } xWriter->startElement( aRelElement, xAttrList ); diff --git a/compilerplugins/clang/flatten.cxx b/compilerplugins/clang/flatten.cxx index f3c49591c1a7..4e031ef1f3a5 100644 --- a/compilerplugins/clang/flatten.cxx +++ b/compilerplugins/clang/flatten.cxx @@ -126,7 +126,7 @@ bool Flatten::rewrite(const IfStmt* ifStmt) // in adjusting the formatting I assume that "{" starts on a new line std::string conditionString = getSourceAsString(conditionRange); - conditionString = "(!" + conditionString + ")"; + conditionString = "!(" + conditionString + ")"; std::string thenString = getSourceAsString(thenRange); bool thenIsCompound = false; diff --git a/configmgr/source/xcuparser.cxx b/configmgr/source/xcuparser.cxx index b47a482f3f8b..7db53e3e77fb 100644 --- a/configmgr/source/xcuparser.cxx +++ b/configmgr/source/xcuparser.cxx @@ -93,42 +93,39 @@ bool XcuParser::startElement( } else if (state_.top().ignore) { state_.push(State::Ignore(false)); } else if (!state_.top().node.is()) { - if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && name.equals("item")) + if (nsId != xmlreader::XmlReader::NAMESPACE_NONE || !name.equals("item")) { - handleItem(reader); - } else { throw css::uno::RuntimeException( "bad items node member <" + name.convertFromUtf8() + "> in " + reader.getUrl()); } + handleItem(reader); } else { switch (state_.top().node->kind()) { case Node::KIND_PROPERTY: - if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals("value")) + if (nsId != xmlreader::XmlReader::NAMESPACE_NONE || + !name.equals("value")) { - handlePropValue( - reader, - static_cast< PropertyNode * >(state_.top().node.get())); - } else { throw css::uno::RuntimeException( "bad property node member <" + name.convertFromUtf8() + "> in " + reader.getUrl()); } + handlePropValue( + reader, + static_cast< PropertyNode * >(state_.top().node.get())); break; case Node::KIND_LOCALIZED_PROPERTY: - if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && - name.equals("value")) + if (nsId != xmlreader::XmlReader::NAMESPACE_NONE || + !name.equals("value")) { - handleLocpropValue( - reader, - static_cast< LocalizedPropertyNode * >( - state_.top().node.get())); - } else { throw css::uno::RuntimeException( "bad localized property node member <" + name.convertFromUtf8() + "> in " + reader.getUrl()); } + handleLocpropValue( + reader, + static_cast< LocalizedPropertyNode * >( + state_.top().node.get())); break; case Node::KIND_LOCALIZED_VALUE: throw css::uno::RuntimeException( |