summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore/unostyle.cxx
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/unostyle.cxx
parent30f1fa9993ee6ac444ab9da412b8a4820b045423 (diff)
remove SwXStyle creation outside of compilation unit
Change-Id: I136822a0ad581d1490fc6f8842c95f2d25dfeba4
Diffstat (limited to 'sw/source/core/unocore/unostyle.cxx')
-rw-r--r--sw/source/core/unocore/unostyle.cxx24
1 files changed, 20 insertions, 4 deletions
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);