summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-12-13 22:02:03 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-12-24 00:02:51 +0100
commit4bc9c291f33d0e64100b12f7011460250a08bcd1 (patch)
treef60b2f5c3d9382cfe142cf7f7ab2337bc07f54d9 /sw/source/core/unocore
parent30f1fa9993ee6ac444ab9da412b8a4820b045423 (diff)
remove SwXStyle creation outside of compilation unit
Change-Id: I136822a0ad581d1490fc6f8842c95f2d25dfeba4
Diffstat (limited to 'sw/source/core/unocore')
-rw-r--r--sw/source/core/unocore/unocoll.cxx13
-rw-r--r--sw/source/core/unocore/unostyle.cxx24
2 files changed, 26 insertions, 11 deletions
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 51f1501a2900..24f9980ae3cb 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 7eb0e9405e21..d0efe3d29461 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);