remove SwXStyle creation outside of compilation unit
Change-Id: I136822a0ad581d1490fc6f8842c95f2d25dfeba4
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index df697fe..ea7f7233 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -96,6 +96,11 @@ public:
virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override;
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( css::uno::RuntimeException, std::exception ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override;
static css::uno::Reference<css::style::XStyle> CreateStyle(SfxStyleFamily eFamily, SwDoc& rDoc);
// FIXME: This is very ugly as is the whole conditional paragraph style
// hackety. Should be folded into CreateStyle hopefully one day
static css::uno::Reference<css::style::XStyle> CreateStyleCondParagraph(SwDoc& rDoc);
};
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 51f1501..24f9980 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -673,12 +673,15 @@ SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc & rDoc)
case SW_SERVICE_STYLE_PAGE_STYLE:
case SW_SERVICE_STYLE_NUMBERING_STYLE:
{
SfxStyleFamily eFamily = SFX_STYLE_FAMILY_CHAR;
SfxStyleFamily eFamily = SFX_STYLE_FAMILY_CHAR;
switch(nObjectType)
{
case SW_SERVICE_STYLE_PARAGRAPH_STYLE:
eFamily = SFX_STYLE_FAMILY_PARA;
break;
case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE:
eFamily = SFX_STYLE_FAMILY_PARA;
xRet = SwXStyleFamilies::CreateStyleCondParagraph(rDoc);
break;
case SW_SERVICE_STYLE_FRAME_STYLE:
eFamily = SFX_STYLE_FAMILY_FRAME;
@@ -690,12 +693,8 @@ SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc & rDoc)
eFamily = SFX_STYLE_FAMILY_PSEUDO;
break;
}
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 = static_cast<cppu::OWeakObject*>(pNewStyle);
if(!xRet.is())
xRet = SwXStyleFamilies::CreateStyle(eFamily, rDoc);
}
break;
case SW_SERVICE_FIELDTYPE_DATETIME:
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 7eb0e94..d0efe3d 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -509,15 +509,30 @@ sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUStrin
template<enum SfxStyleFamily eFamily>
static uno::Reference< css::style::XStyle> lcl_CreateStyle(SfxStyleSheetBasePool* pBasePool, SwDocShell* pDocShell, const OUString& sStyleName)
{ return new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName); };
{ return pBasePool ? new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName) : new SwXStyle(pDocShell->GetDoc(), eFamily, false); };
template<>
uno::Reference< css::style::XStyle> lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>(SfxStyleSheetBasePool* pBasePool, SwDocShell* pDocShell, const OUString& sStyleName)
{ return pBasePool ? new SwXStyle(*pBasePool, SFX_STYLE_FAMILY_PARA, pDocShell->GetDoc(), sStyleName) : new SwXStyle(pDocShell->GetDoc(), SFX_STYLE_FAMILY_PARA, false); };
template<>
uno::Reference< css::style::XStyle> lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>(SfxStyleSheetBasePool* pBasePool, SwDocShell* pDocShell, const OUString& sStyleName)
{ return new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), sStyleName); };
{ return pBasePool ? new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), sStyleName) : new SwXFrameStyle(pDocShell->GetDoc()); };
template<>
uno::Reference< css::style::XStyle> lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE>(SfxStyleSheetBasePool* pBasePool, SwDocShell* pDocShell, const OUString& sStyleName)
{ return new SwXPageStyle(*pBasePool, pDocShell, SFX_STYLE_FAMILY_PAGE, sStyleName); };
{ return pBasePool ? new SwXPageStyle(*pBasePool, pDocShell, SFX_STYLE_FAMILY_PAGE, sStyleName) : new SwXPageStyle(pDocShell); };
uno::Reference<css::style::XStyle> SwXStyleFamilies::CreateStyle(SfxStyleFamily eFamily, SwDoc& rDoc)
{
auto pEntries(lcl_GetStyleFamilyEntries());
const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
[eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; });
return pEntry == pEntries->end() ? nullptr : pEntry->m_fCreateStyle(nullptr, rDoc.GetDocShell(), "");
}
// FIXME: Ugly special casing that should die.
uno::Reference<css::style::XStyle> SwXStyleFamilies::CreateStyleCondParagraph(SwDoc& rDoc)
{ return new SwXStyle(&rDoc, SFX_STYLE_FAMILY_PARA, true); };
template<enum SfxStyleFamily>
static sal_uInt16 lcl_TranslateIndex(const sal_uInt16 nIndex);
@@ -965,7 +980,8 @@ SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam,
m_bIsConditional(false),
m_pPropertiesImpl(nullptr)
{
StartListening(rPool);
if(!m_pBasePool)
return;
if(eFam == SFX_STYLE_FAMILY_PARA)
{
m_pBasePool->SetSearchMask(m_eFamily);