Index: unotxdoc.hxx =================================================================== RCS file: /cvs/sw/sw/inc/unotxdoc.hxx,v retrieving revision 1.24 diff -u -r1.24 unotxdoc.hxx --- unotxdoc.hxx 22 Oct 2007 15:09:10 -0000 1.24 +++ unotxdoc.hxx 12 Dec 2007 12:22:41 -0000 @@ -497,7 +497,7 @@ // void Invalidate(); void Reactivate(SwDocShell* pNewDocShell); - SwXDocumentPropertyHelper * GetPropertyHelper (); + SwXDocumentPropertyHelper * GetPropertyHelper() throw(::com::sun::star::uno::RuntimeException); sal_Bool IsValid() const {return bObjectValid;} void InitNewDoc(); Index: unotxdoc.cxx =================================================================== RCS file: /cvs/sw/sw/source/ui/uno/unotxdoc.cxx,v retrieving revision 1.123 diff -u -r1.123 unotxdoc.cxx --- unotxdoc.cxx 12 Nov 2007 16:33:16 -0000 1.123 +++ unotxdoc.cxx 12 Dec 2007 12:22:57 -0000 @@ -472,9 +472,11 @@ } } -uno::Reference< document::XDocumentInfo > SAL_CALL SwXTextDocument::getDocumentInfo() throw (::uno::RuntimeException) +uno::Reference< document::XDocumentInfo > SAL_CALL SwXTextDocument::getDocumentInfo() throw (uno::RuntimeException) { - return pDocShell->GetDoc()->GetDocumentInfo()->GetInfo(); + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); + return pDocShell->GetDoc()->GetDocumentInfo()->GetInfo(); } /*-- 18.12.98 11:55:08--------------------------------------------------- @@ -483,18 +485,20 @@ /* -----------------18.12.98 12:49------------------- * * --------------------------------------------------*/ -SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper () +SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper() throw (uno::RuntimeException) { if(!xPropertyHelper.is()) { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); pPropertyHelper = new SwXDocumentPropertyHelper(*pDocShell->GetDoc()); xPropertyHelper = (cppu::OWeakObject*)pPropertyHelper; } return pPropertyHelper; } -void SwXTextDocument::GetNumberFormatter() +void SwXTextDocument::GetNumberFormatter() throw (uno::RuntimeException) { - if(IsValid()) + if(IsValid()&& pDocShell->GetDoc()) { if(!xNumFmtAgg.is()) { @@ -521,8 +525,10 @@ } DBG_ASSERT(pNumFmt, "No number formatter available"); - if(!pNumFmt->GetNumberFormatter()) + if(!pNumFmt->GetNumberFormatter()&& pDocShell->GetDoc()) + { pNumFmt->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter( sal_True )); + } } } } @@ -532,7 +538,7 @@ Reference< XText > SwXTextDocument::getText(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!xBodyText.is()) { @@ -556,7 +562,7 @@ void SwXTextDocument::lockControllers(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) + if(IsValid()||!pDocShell->GetDoc()) { UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc()); aActionArr.Insert(pContext, 0); @@ -701,7 +707,7 @@ throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) + if(IsValid()||!pDocShell->GetDoc()) { if(!pxXLineNumberingProperties) { @@ -733,7 +739,7 @@ Reference< XIndexAccess > SwXTextDocument::getNumberingRules(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXNumberingRules ) { @@ -749,7 +755,7 @@ Reference< XIndexAccess > SwXTextDocument::getFootnotes(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXFootnotes) { @@ -765,7 +771,7 @@ SwXTextDocument::getFootnoteSettings(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXFootnoteSettings) { @@ -780,7 +786,7 @@ Reference< XIndexAccess > SwXTextDocument::getEndnotes(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXEndnotes) { @@ -795,7 +801,7 @@ Reference< XPropertySet > SwXTextDocument::getEndnoteSettings(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXEndnoteSettings) { @@ -845,7 +851,7 @@ { ::vos::OGuard aGuard(Application::GetSolarMutex()); Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY); - if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId())) + if(!IsValid() || !pDocShell->GetDoc() ||!xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId())) throw RuntimeException(); Reference< XTextCursor > xCrsr; @@ -930,7 +936,8 @@ Reference< XInterface > xLastResult) { Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY); - if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId())) + if(!IsValid() || !pDocShell->GetDoc() || + !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId())) return 0; SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr); @@ -1128,7 +1135,7 @@ { ::vos::OGuard aGuard(Application::GetSolarMutex()); Sequence< beans::PropertyValue > aSeq(9); - if(IsValid()) + if(IsValid() && pDocShell->GetDoc()) { beans::PropertyValue* pArray = aSeq.getArray(); SwPagePreViewPrtData aData; @@ -1212,7 +1219,7 @@ throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) + if(IsValid() && pDocShell->GetDoc()) { SwPagePreViewPrtData aData; //falls nur einige Properties kommen, dann die akt. Einstellungen benutzen @@ -1285,7 +1292,7 @@ throw( IllegalArgumentException, RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(IsValid()) + if(IsValid() && pDocShell->GetDoc()) { SfxViewFrame* pFrame = SfxViewFrame::CreateViewFrame( *pDocShell, 7, sal_True ); SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SFX_CALLMODE_SYNCHRON, @@ -1373,7 +1380,7 @@ throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid() ||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXReferenceMarks) { @@ -1388,7 +1395,7 @@ Reference< XEnumerationAccess > SwXTextDocument::getTextFields(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid() || !pDocShell->GetDoc()) throw RuntimeException(); if(!pxXTextFieldTypes) { @@ -1404,7 +1411,7 @@ throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXTextFieldMasters) { @@ -1419,7 +1426,7 @@ Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXEmbeddedObjects) { @@ -1434,7 +1441,7 @@ Reference< XNameAccess > SwXTextDocument::getBookmarks(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXBookmarks) { @@ -1449,7 +1456,7 @@ Reference< XNameAccess > SwXTextDocument::getTextSections(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXTextSections) { @@ -1464,7 +1471,7 @@ Reference< XNameAccess > SwXTextDocument::getTextTables(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXTextTables) { @@ -1479,7 +1486,7 @@ Reference< XNameAccess > SwXTextDocument::getGraphicObjects(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXGraphicObjects) { @@ -1494,7 +1501,7 @@ Reference< XNameAccess > SwXTextDocument::getTextFrames(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXTextFrames) { @@ -1509,7 +1516,7 @@ Reference< XNameAccess > SwXTextDocument::getStyleFamilies(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXStyleFamilies) { @@ -1541,7 +1548,7 @@ Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXDrawPage) { @@ -1811,7 +1818,7 @@ throw( Exception, RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); Reference< XInterface > xRet; sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName); @@ -2007,7 +2014,7 @@ Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes(void) throw( RuntimeException ) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); if(!pxXDocumentIndexes) { @@ -2060,7 +2067,9 @@ case WID_DOC_CHANGES_SHOW: { sal_Bool bSet = *(sal_Bool*)aValue.getValue(); - sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode(); + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); + sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode(); if(WID_DOC_CHANGES_SHOW == pMap->nWID) { eMode &= ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE); @@ -2080,6 +2089,8 @@ Sequence aNew; if(aValue >>= aNew) { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); SwDoc* pDoc = pDocShell->GetDoc(); pDoc->SetRedlinePassword(aNew); if(aNew.getLength()) @@ -2093,6 +2104,8 @@ break; case WID_DOC_AUTO_MARK_URL : { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); OUString sURL; aValue >>= sURL; pDocShell->GetDoc()->SetTOIAutoMarkURL(sURL); @@ -2103,6 +2116,8 @@ break; case WID_DOC_REDLINE_DISPLAY: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode(); eRedMode = eRedMode & (~nsRedlineMode_t::REDLINE_SHOW_MASK); sal_Int16 nSet = 0; @@ -2122,6 +2137,8 @@ break; case WID_DOC_TWO_DIGIT_YEAR: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); sal_Int16 nYear = 0; aValue >>= nYear; SfxRequest aRequest ( SID_ATTR_YEAR2000, SFX_CALLMODE_SLOT, pDocShell->GetDoc()->GetAttrPool()); @@ -2131,6 +2148,8 @@ break; case WID_DOC_AUTOMATIC_CONTROL_FOCUS: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); SwDrawDocument * pDrawDoc; sal_Bool bAuto = *(sal_Bool*) aValue.getValue(); @@ -2152,6 +2171,8 @@ break; case WID_DOC_APPLY_FORM_DESIGN_MODE: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); SwDrawDocument * pDrawDoc; sal_Bool bMode = *(sal_Bool*)aValue.getValue(); @@ -2176,6 +2197,8 @@ // flag at the document, used during binary import case WID_DOC_LOCK_UPDATES : { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); SwDoc* pDoc = pDocShell->GetDoc(); bool bBool (false); if( aValue >>= bBool ) @@ -2189,6 +2212,8 @@ // --> OD 2006-03-21 #b6375613# case WID_APPLY_WORKAROUND_FOR_B6375613: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); bool bApplyWorkaroundForB6375613( false ); aValue >>= bApplyWorkaroundForB6375613; pDocShell->GetDoc()->SetApplyWorkaroundForB6375613( bApplyWorkaroundForB6375613 ); @@ -2198,6 +2223,8 @@ default: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pMap->nWID); SfxPoolItem* pNewItem = rItem.Clone(); pNewItem->PutValue(aValue, pMap->nMemberId); @@ -2227,6 +2254,8 @@ case WID_DOC_PARA_COUNT : case WID_DOC_WORD_COUNT : { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); SwDocStat aStat(pDocShell->GetDoc()->GetDocStat()); if(aStat.bModified) pDocShell->GetDoc()->UpdateDocStat( aStat ); @@ -2248,6 +2277,8 @@ case WID_DOC_CHANGES_RECORD: case WID_DOC_CHANGES_SHOW: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode(); sal_Bool bSet = sal_False; if(WID_DOC_CHANGES_SHOW == pMap->nWID) @@ -2264,11 +2295,15 @@ break; case WID_DOC_CHANGES_PASSWORD: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); SwDoc* pDoc = pDocShell->GetDoc(); aAny <<= pDoc->GetRedlinePassword(); } break; case WID_DOC_AUTO_MARK_URL : + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); aAny <<= OUString(pDocShell->GetDoc()->GetTOIAutoMarkURL()); break; case WID_DOC_HIDE_TIPS : @@ -2279,6 +2314,8 @@ break; case WID_DOC_REDLINE_DISPLAY: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode(); eRedMode = eRedMode & nsRedlineMode_t::REDLINE_SHOW_MASK; sal_Int16 nRet = RedlineDisplayType::NONE; @@ -2300,11 +2337,15 @@ break; case WID_DOC_TWO_DIGIT_YEAR: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); aAny <<= static_cast < sal_Int16 > (pDocShell->GetDoc()->GetNumberFormatter ( TRUE )->GetYear2000()); } break; case WID_DOC_AUTOMATIC_CONTROL_FOCUS: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); SwDrawDocument * pDrawDoc; sal_Bool bAuto; if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) ) @@ -2316,6 +2357,8 @@ break; case WID_DOC_APPLY_FORM_DESIGN_MODE: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); SwDrawDocument * pDrawDoc; sal_Bool bMode; if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) ) @@ -2335,6 +2378,8 @@ aAny <<= getRuntimeUID(); break; case WID_DOC_LOCK_UPDATES : + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); aAny <<= static_cast( pDocShell->GetDoc()->IsInReading() ); break; case WID_DOC_BUILDID: @@ -2346,6 +2391,8 @@ // --> OD 2006-03-21 #b6375613# case WID_APPLY_WORKAROUND_FOR_B6375613: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); aAny <<= pDocShell->GetDoc()->ApplyWorkaroundForB6375613(); } break; @@ -2353,6 +2400,8 @@ default: { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pMap->nWID); rItem.QueryValue(aAny, pMap->nMemberId); } @@ -2414,6 +2463,8 @@ { if(!pxXRedlines) { + if(!pDocShell->GetDoc()) + throw uno::RuntimeException(); pxXRedlines = new Reference< XEnumerationAccess > ; (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc()); } @@ -2459,7 +2510,7 @@ void SwXTextDocument::updateLinks( ) throw(RuntimeException) { ::vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()||!pDocShell->GetDoc()) throw RuntimeException(); SwDoc* pDoc = pDocShell->GetDoc(); SvxLinkManager& rLnkMan = pDoc->GetLinkManager(); @@ -2897,7 +2948,7 @@ Reference SAL_CALL SwXTextDocument::getXForms() throw( RuntimeException ) { - if ( !pDocShell ) + if ( !pDocShell ||!pDocShell->GetDoc()) throw DisposedException( ::rtl::OUString(), static_cast< XTextDocument* >( this ) ); SwDoc* pDoc = pDocShell->GetDoc(); return pDoc->getXForms();