diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-08-25 15:37:44 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-08-25 21:49:36 +0200 |
commit | 8ad8d878320ad4e3cef1f6c1657781bf003d4e71 (patch) | |
tree | 8fb1a1112a580bc0782bdbea21438ccf74babc60 /sw | |
parent | 1d1d1c62caf2ee6a96946e96d782e03f3ef80439 (diff) |
SwXServiceProvider::MakeInstance() requires a SwDoc
Change-Id: I2522e43100baa691baeb55947bb47ce7ccabb5b4
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unocoll.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 96 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 2 |
4 files changed, 51 insertions, 51 deletions
diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index d5c97bb44d21..c365b7d0dabe 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -256,7 +256,7 @@ class SwXServiceProvider public: static OUString GetProviderName(sal_uInt16 nObjectType); static sal_uInt16 GetProviderType(const OUString& rServiceName); - static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > MakeInstance(sal_uInt16 nObjectType, SwDoc* pDoc); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > MakeInstance(sal_uInt16 nObjectType, SwDoc & rDoc); static ::com::sun::star::uno::Sequence<OUString> GetAllServiceNames(); }; diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index c4de3668a6c3..30604ee1d00c 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -54,7 +54,7 @@ void SwTextBoxHelper::create(SwFrmFmt* pShape) if (!pShape->GetAttrSet().HasItem(RES_CNTNT)) { // Create the associated TextFrame and insert it into the document. - uno::Reference<text::XTextContent> xTextFrame(SwXServiceProvider::MakeInstance(SW_SERVICE_TYPE_TEXTFRAME, pShape->GetDoc()), uno::UNO_QUERY); + uno::Reference<text::XTextContent> xTextFrame(SwXServiceProvider::MakeInstance(SW_SERVICE_TYPE_TEXTFRAME, *pShape->GetDoc()), uno::UNO_QUERY); uno::Reference<text::XTextDocument> xTextDocument(pShape->GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY); uno::Reference<text::XTextContentAppend> xTextContentAppend(xTextDocument->getText(), uno::UNO_QUERY); xTextContentAppend->appendTextContent(xTextFrame, uno::Sequence<beans::PropertyValue>()); diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index c320cfab6252..4e303a06d64b 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -517,7 +517,8 @@ sal_uInt16 SwXServiceProvider::GetProviderType(const OUString& rServiceName) return SW_SERVICE_INVALID; } -uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc* pDoc) +uno::Reference<uno::XInterface> +SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc & rDoc) { SolarMutexGuard aGuard; uno::Reference< uno::XInterface > xRet; @@ -530,40 +531,41 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 break; case SW_SERVICE_TYPE_TEXTFRAME: { - xRet = SwXTextFrame::CreateXTextFrame(*pDoc, 0); + xRet = SwXTextFrame::CreateXTextFrame(rDoc, 0); } break; case SW_SERVICE_TYPE_GRAPHIC : case SW_SERVICE_TYPE_TEXT_GRAPHIC /* #i47503# */ : { - xRet = SwXTextGraphicObject::CreateXTextGraphicObject(*pDoc, 0); + xRet = SwXTextGraphicObject::CreateXTextGraphicObject(rDoc, 0); } break; case SW_SERVICE_TYPE_OLE : { - xRet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*pDoc, 0); + xRet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(rDoc, 0); } break; case SW_SERVICE_TYPE_BOOKMARK : { - xRet = SwXBookmark::CreateXBookmark(*pDoc, 0); + xRet = SwXBookmark::CreateXBookmark(rDoc, 0); } break; case SW_SERVICE_TYPE_FIELDMARK : { - xRet = SwXFieldmark::CreateXFieldmark(*pDoc, 0, false); + xRet = SwXFieldmark::CreateXFieldmark(rDoc, 0, false); } break; case SW_SERVICE_TYPE_FORMFIELDMARK : { - xRet = SwXFieldmark::CreateXFieldmark(*pDoc, 0, true); + xRet = SwXFieldmark::CreateXFieldmark(rDoc, 0, true); } break; case SW_SERVICE_VBAOBJECTPROVIDER : #ifndef DISABLE_SCRIPTING { - SwVbaObjectForCodeNameProvider* pObjProv = new SwVbaObjectForCodeNameProvider( pDoc->GetDocShell() ); + SwVbaObjectForCodeNameProvider* pObjProv = + new SwVbaObjectForCodeNameProvider(rDoc.GetDocShell()); xRet = (cppu::OWeakObject*)pObjProv; } #endif @@ -571,9 +573,9 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 case SW_SERVICE_VBACODENAMEPROVIDER : #ifndef DISABLE_SCRIPTING { - if ( pDoc->GetDocShell() && ooo::vba::isAlienWordDoc( *pDoc->GetDocShell() ) ) + if (rDoc.GetDocShell() && ooo::vba::isAlienWordDoc(*rDoc.GetDocShell())) { - SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider( pDoc->GetDocShell() ); + SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider(rDoc.GetDocShell()); xRet = (cppu::OWeakObject*)pObjProv; } } @@ -582,11 +584,12 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 case SW_SERVICE_VBAPROJECTNAMEPROVIDER : #ifndef DISABLE_SCRIPTING { - uno::Reference< container::XNameContainer > xProjProv = pDoc->GetVBATemplateToProjectCache(); - if ( !xProjProv.is() && pDoc->GetDocShell() && ooo::vba::isAlienWordDoc( *pDoc->GetDocShell() ) ) + uno::Reference< container::XNameContainer > xProjProv = rDoc.GetVBATemplateToProjectCache(); + if (!xProjProv.is() && rDoc.GetDocShell() + && ooo::vba::isAlienWordDoc(*rDoc.GetDocShell())) { xProjProv = new SwVbaProjectNameProvider; - pDoc->SetVBATemplateToProjectCache( xProjProv ); + rDoc.SetVBATemplateToProjectCache(xProjProv); } xRet = xProjProv; } @@ -595,28 +598,25 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 case SW_SERVICE_VBAGLOBALS : #ifndef DISABLE_SCRIPTING { - if ( pDoc ) + uno::Any aGlobs; + BasicManager *pBasicMan = rDoc.GetDocShell()->GetBasicManager(); + if (pBasicMan && !pBasicMan->GetGlobalUNOConstant("VBAGlobals", aGlobs)) { - uno::Any aGlobs; - BasicManager *pBasicMan = pDoc->GetDocShell()->GetBasicManager(); - if (pBasicMan && !pBasicMan->GetGlobalUNOConstant("VBAGlobals", aGlobs)) - { - uno::Sequence< uno::Any > aArgs(1); - aArgs[ 0 ] <<= pDoc->GetDocShell()->GetModel(); - aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( "ooo.vba.word.Globals", aArgs ); - pBasicMan->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); - } - aGlobs >>= xRet; + uno::Sequence< uno::Any > aArgs(1); + aArgs[ 0 ] <<= rDoc.GetDocShell()->GetModel(); + aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( "ooo.vba.word.Globals", aArgs ); + pBasicMan->SetGlobalUNOConstant( "VBAGlobals", aGlobs ); } + aGlobs >>= xRet; } #endif break; case SW_SERVICE_TYPE_FOOTNOTE : - xRet = SwXFootnote::CreateXFootnote(*pDoc, 0, false); + xRet = SwXFootnote::CreateXFootnote(rDoc, 0, false); break; case SW_SERVICE_TYPE_ENDNOTE : - xRet = SwXFootnote::CreateXFootnote(*pDoc, 0, true); + xRet = SwXFootnote::CreateXFootnote(rDoc, 0, true); break; case SW_SERVICE_CONTENT_INDEX_MARK : case SW_SERVICE_USER_INDEX_MARK : @@ -627,7 +627,7 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 eType = TOX_CONTENT; else if(SW_SERVICE_USER_INDEX_MARK == nObjectType) eType = TOX_USER; - xRet = SwXDocumentIndexMark::CreateXDocumentIndexMark(*pDoc, 0, eType); + xRet = SwXDocumentIndexMark::CreateXDocumentIndexMark(rDoc, 0, eType); } break; case SW_SERVICE_CONTENT_INDEX : @@ -659,7 +659,7 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 { eType = TOX_TABLES; } - xRet = SwXDocumentIndex::CreateXDocumentIndex(*pDoc, 0, eType); + xRet = SwXDocumentIndex::CreateXDocumentIndex(rDoc, 0, eType); } break; case SW_SERVICE_INDEX_HEADER_SECTION : @@ -669,7 +669,7 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 break; case SW_SERVICE_REFERENCE_MARK : - xRet = SwXReferenceMark::CreateXReferenceMark(*pDoc, 0); + xRet = SwXReferenceMark::CreateXReferenceMark(rDoc, 0); break; case SW_SERVICE_STYLE_CHARACTER_STYLE: case SW_SERVICE_STYLE_PARAGRAPH_STYLE: @@ -695,11 +695,11 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 eFamily = SFX_STYLE_FAMILY_PSEUDO; break; } - SwXStyle* pNewStyle = SFX_STYLE_FAMILY_PAGE == eFamily ? - new SwXPageStyle(pDoc->GetDocShell()) : - eFamily == SFX_STYLE_FAMILY_FRAME ? - new SwXFrameStyle ( pDoc ): - new SwXStyle( pDoc, eFamily, nObjectType == SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE); + SwXStyle* pNewStyle = (SFX_STYLE_FAMILY_PAGE == eFamily) + ? new SwXPageStyle(rDoc.GetDocShell()) + : (eFamily == SFX_STYLE_FAMILY_FRAME) + ? new SwXFrameStyle(&rDoc) + : new SwXStyle(&rDoc, eFamily, nObjectType == SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE); xRet = (cppu::OWeakObject*)pNewStyle; } break; @@ -759,7 +759,7 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 xRet = SwXTextField::CreateXTextField(0, 0, nObjectType); break; case SW_SERVICE_FIELDTYPE_ANNOTATION: - xRet = SwXTextField::CreateXTextField(pDoc, 0, nObjectType); + xRet = SwXTextField::CreateXTextField(&rDoc, 0, nObjectType); break; case SW_SERVICE_FIELDMASTER_USER: case SW_SERVICE_FIELDMASTER_DDE: @@ -774,31 +774,31 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 case SW_SERVICE_FIELDMASTER_SET_EXP : nResId = RES_SETEXPFLD; break; case SW_SERVICE_FIELDMASTER_DATABASE: nResId = RES_DBFLD; break; } - xRet = SwXFieldMaster::CreateXFieldMaster(pDoc, 0, nResId); + xRet = SwXFieldMaster::CreateXFieldMaster(&rDoc, 0, nResId); } break; case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY: { - SwFieldType* pType = pDoc->getIDocumentFieldsAccess().GetFldType(RES_AUTHORITY, aEmptyOUStr, true); + SwFieldType* pType = rDoc.getIDocumentFieldsAccess().GetFldType(RES_AUTHORITY, aEmptyOUStr, true); if(!pType) { - SwAuthorityFieldType aType(pDoc); - pType = pDoc->getIDocumentFieldsAccess().InsertFldType(aType); + SwAuthorityFieldType aType(&rDoc); + pType = rDoc.getIDocumentFieldsAccess().InsertFldType(aType); } - xRet = SwXFieldMaster::CreateXFieldMaster(pDoc, pType); + xRet = SwXFieldMaster::CreateXFieldMaster(&rDoc, pType); } break; case SW_SERVICE_PARAGRAPH : - xRet = SwXParagraph::CreateXParagraph(*pDoc, 0); + xRet = SwXParagraph::CreateXParagraph(rDoc, 0); break; case SW_SERVICE_NUMBERING_RULES : - xRet = (cppu::OWeakObject*)new SwXNumberingRules(*pDoc); + xRet = (cppu::OWeakObject*)new SwXNumberingRules(rDoc); break; case SW_SERVICE_TEXT_COLUMNS : xRet = (cppu::OWeakObject*)new SwXTextColumns(0); break; case SW_SERVICE_DEFAULTS: - xRet = (cppu::OWeakObject*)new SwXTextDefaults( pDoc ); + xRet = (cppu::OWeakObject*)new SwXTextDefaults(&rDoc); break; case SW_SERVICE_IMAP_RECTANGLE : xRet = SvUnoImageMapRectangleObject_createInstance( sw_GetSupportedMacroItems() ); @@ -814,15 +814,15 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 // paste, there should be no data provider, so that own data is used // This should not happen during copy/paste, as this will unlink // charts using table data. - OSL_ASSERT( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ); - if( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) - xRet = (cppu::OWeakObject*) pDoc->getIDocumentChartDataProviderAccess().GetChartDataProvider( true /* create - if not yet available */ ); + OSL_ASSERT(rDoc.GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED); + if (rDoc.GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED) + xRet = (cppu::OWeakObject*) rDoc.getIDocumentChartDataProviderAccess().GetChartDataProvider( true /* create - if not yet available */ ); break; case SW_SERVICE_TYPE_META: - xRet = SwXMeta::CreateXMeta(*pDoc, false); + xRet = SwXMeta::CreateXMeta(rDoc, false); break; case SW_SERVICE_FIELDTYPE_METAFIELD: - xRet = SwXMeta::CreateXMeta(*pDoc, true); + xRet = SwXMeta::CreateXMeta(rDoc, true); break; default: throw uno::RuntimeException(); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 964a575d4365..09e5c9ace00e 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1642,7 +1642,7 @@ css::uno::Reference<css::uno::XInterface> SwXTextDocument::create( const sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName); if (nType != SW_SERVICE_INVALID) { - return SwXServiceProvider::MakeInstance(nType, pDocShell->GetDoc()); + return SwXServiceProvider::MakeInstance(nType, *pDocShell->GetDoc()); } if (rServiceName == "com.sun.star.drawing.DashTable") { |