diff options
author | Miklos Vajna <vmiklos@frugalware.org> | 2011-08-03 16:52:32 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@frugalware.org> | 2011-08-03 19:02:44 +0200 |
commit | 485485441c2ad09c3872e16807b6f8d882d6ca5d (patch) | |
tree | 88c9197e7a0a655324f7bf728e43550b87946a11 | |
parent | 051eb3ae345a29b0ad1011caac8e80379bcd13bd (diff) |
couple of null pointer checks for the unit test
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 8 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 9 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SettingsTable.cxx | 3 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 13 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfsdrimport.cxx | 5 |
6 files changed, 30 insertions, 20 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index b4e1426f7..25c6e4d77 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -160,8 +160,12 @@ DomainMapper::~DomainMapper() try { uno::Reference< text::XDocumentIndexesSupplier> xIndexesSupplier( m_pImpl->GetTextDocument(), uno::UNO_QUERY ); - uno::Reference< container::XIndexAccess > xIndexes = xIndexesSupplier->getDocumentIndexes(); - sal_Int32 nIndexes = xIndexes->getCount(); + sal_Int32 nIndexes = 0; + if( xIndexesSupplier.is() ) + { + uno::Reference< container::XIndexAccess > xIndexes = xIndexesSupplier->getDocumentIndexes(); + nIndexes = xIndexes->getCount(); + } if( nIndexes ) { //index update has to wait until first view is created diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 693b3dd00..2118d7eca 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -242,7 +242,8 @@ uno::Reference< container::XNameContainer > DomainMapper_Impl::GetPageStyles( if(!m_xPageStyles.is()) { uno::Reference< style::XStyleFamiliesSupplier > xSupplier( m_xTextDocument, uno::UNO_QUERY ); - xSupplier->getStyleFamilies()->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageStyles"))) >>= m_xPageStyles; + if (xSupplier.is()) + xSupplier->getStyleFamilies()->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageStyles"))) >>= m_xPageStyles; } return m_xPageStyles; } @@ -260,7 +261,7 @@ uno::Reference< text::XText > DomainMapper_Impl::GetBodyText() uno::Reference< beans::XPropertySet > DomainMapper_Impl::GetDocumentSettings() { - if( !m_xDocumentSettings.is() ) + if( !m_xDocumentSettings.is() && m_xTextFactory.is()) { m_xDocumentSettings = uno::Reference< beans::XPropertySet >( m_xTextFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.Settings"))), uno::UNO_QUERY ); @@ -287,6 +288,8 @@ void DomainMapper_Impl::SetDocumentSettingsProperty( const ::rtl::OUString& rPro void DomainMapper_Impl::RemoveLastParagraph( ) { uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend; + if (!xTextAppend.is()) + return; try { uno::Reference< text::XTextCursor > xCursor = xTextAppend->createTextCursor(); @@ -3265,7 +3268,7 @@ void DomainMapper_Impl::ResetParaRedline( ) void DomainMapper_Impl::ApplySettingsTable() { - if( m_pSettingsTable ) + if( m_pSettingsTable && m_xTextFactory.is() ) { try { diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 866a3a51e..bfe5cffc0 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -390,9 +390,10 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle( m_aFirstPageStyle = uno::Reference< beans::XPropertySet > ( xTextFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.PageStyle") )), uno::UNO_QUERY); - xPageStyles->insertByName( m_sFirstPageStyleName, uno::makeAny(m_aFirstPageStyle) ); + if (xPageStyles.is()) + xPageStyles->insertByName( m_sFirstPageStyleName, uno::makeAny(m_aFirstPageStyle) ); } - else if( !m_aFirstPageStyle.is() ) + else if( !m_aFirstPageStyle.is() && xPageStyles.is() ) { xPageStyles->getByName(m_sFirstPageStyleName) >>= m_aFirstPageStyle; } @@ -400,7 +401,7 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle( } else { - if( !m_sFollowPageStyleName.getLength() ) + if( !m_sFollowPageStyleName.getLength() && xPageStyles.is() ) { uno::Sequence< ::rtl::OUString > aPageStyleNames = xPageStyles->getElementNames(); m_sFollowPageStyleName = lcl_FindUnusedPageStyleName(aPageStyleNames); @@ -409,7 +410,7 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle( uno::UNO_QUERY); xPageStyles->insertByName( m_sFollowPageStyleName, uno::makeAny(m_aFollowPageStyle) ); } - else if(!m_aFollowPageStyle.is() ) + else if(!m_aFollowPageStyle.is() && xPageStyles.is() ) { xPageStyles->getByName(m_sFollowPageStyleName) >>= m_aFollowPageStyle; } @@ -1005,7 +1006,8 @@ void SectionPropertyMap::_ApplyProperties( uno::Reference< beans::XPropertySet > { try { - xStyle->setPropertyValue( rPropNameSupplier.GetName( aMapIter->first.eId ), aMapIter->second ); + if (xStyle.is()) + xStyle->setPropertyValue( rPropNameSupplier.GetName( aMapIter->first.eId ), aMapIter->second ); } catch( const uno::Exception& ) { diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index 2ad94a27f..53ef431bf 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -222,7 +222,8 @@ void SettingsTable::ApplyProperties( uno::Reference< text::XTextDocument > xDoc uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY ); // Record changes value - xDocProps->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RecordChanges")), uno::makeAny( m_pImpl->m_bRecordChanges ) ); + if (xDocProps.is()) + xDocProps->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RecordChanges")), uno::makeAny( m_pImpl->m_bRecordChanges ) ); } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index cdefe9eaf..36f7723a3 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -285,7 +285,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x OSL_ASSERT(m_xModelFactory.is()); uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(m_xDstDoc, uno::UNO_QUERY); - m_xDocumentProperties.set(xDocumentPropertiesSupplier->getDocumentProperties(), uno::UNO_QUERY); + if (xDocumentPropertiesSupplier.is()) + m_xDocumentProperties.set(xDocumentPropertiesSupplier->getDocumentProperties(), uno::UNO_QUERY); m_pGraphicHelper = new oox::GraphicHelper(m_xContext, xFrame, m_xStorage); @@ -2629,15 +2630,15 @@ int RTFDocumentImpl::popState() RTFValue::Pointer_t pDValue(new RTFValue(OStringToOUString(aDefaultText, m_aStates.top().nCurrentEncoding))); m_aFormfieldSprms->push_back(make_pair(NS_ooxml::LN_CT_FFTextInput_default, pDValue)); } - else if (m_aStates.top().nDestinationState == DESTINATION_CREATIONTIME) + else if (m_aStates.top().nDestinationState == DESTINATION_CREATIONTIME && m_xDocumentProperties.is()) m_xDocumentProperties->setCreationDate(lcl_getDateTime(m_aStates)); - else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONTIME) + else if (m_aStates.top().nDestinationState == DESTINATION_REVISIONTIME && m_xDocumentProperties.is()) m_xDocumentProperties->setModificationDate(lcl_getDateTime(m_aStates)); - else if (m_aStates.top().nDestinationState == DESTINATION_PRINTTIME) + else if (m_aStates.top().nDestinationState == DESTINATION_PRINTTIME && m_xDocumentProperties.is()) m_xDocumentProperties->setPrintDate(lcl_getDateTime(m_aStates)); - else if (m_aStates.top().nDestinationState == DESTINATION_AUTHOR) + else if (m_aStates.top().nDestinationState == DESTINATION_AUTHOR && m_xDocumentProperties.is()) m_xDocumentProperties->setAuthor(m_aDestinationText.makeStringAndClear()); - else if (m_aStates.top().nDestinationState == DESTINATION_COMMENT) + else if (m_aStates.top().nDestinationState == DESTINATION_COMMENT && m_xDocumentProperties.is()) m_xDocumentProperties->setGenerator(m_aDestinationText.makeStringAndClear()); else if (m_aStates.top().nDestinationState == DESTINATION_OPERATOR || m_aStates.top().nDestinationState == DESTINATION_COMPANY) diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 888d3213d..dde66d51c 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -63,9 +63,8 @@ RTFSdrImport::RTFSdrImport(RTFDocumentImpl& rDocument, : m_rImport(rDocument) { uno::Reference<drawing::XDrawPageSupplier> xDrawings(xDstDoc, uno::UNO_QUERY); - OSL_ASSERT(xDrawings.is()); - m_xDrawPage.set(xDrawings->getDrawPage(), uno::UNO_QUERY); - OSL_ASSERT(m_xDrawPage.is()); + if (m_xDrawPage.is() && xDrawings.is()) + m_xDrawPage.set(xDrawings->getDrawPage(), uno::UNO_QUERY); } RTFSdrImport::~RTFSdrImport() |