[Libreoffice-commits] core.git: 40 commits - sw/inc sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Sun Nov 29 01:54:28 PST 2015
sw/inc/unostyle.hxx | 61 --
sw/source/core/unocore/unostyle.cxx | 1025 ++++++++++++++++--------------------
2 files changed, 463 insertions(+), 623 deletions(-)
New commits:
commit 13c8fe55de98560e136b741addbf8f78fd934bd5
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sun Nov 29 00:59:50 2015 +0100
our little MSVC cant read C++11 proper and has special needs instead ...
Change-Id: Ibc5ed9406679f469a7d4855f08f1a8c23c7239ef
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 734f075..d789611 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -115,22 +115,23 @@ namespace
{}
};
static const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries;
- constexpr sal_uInt16 nPoolChrNormalRange = RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
- constexpr sal_uInt16 nPoolChrHtmlRange = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN;
- constexpr sal_uInt16 nPoolCollTextRange = RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
- constexpr sal_uInt16 nPoolCollListsRange = RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN;
- constexpr sal_uInt16 nPoolCollExtraRange = RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN;
- constexpr sal_uInt16 nPoolCollRegisterRange = RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN;
- constexpr sal_uInt16 nPoolCollDocRange = RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN;
- constexpr sal_uInt16 nPoolCollHtmlRange = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN;
- constexpr sal_uInt16 nPoolFrameRange = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
- constexpr sal_uInt16 nPoolPageRange = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
- constexpr sal_uInt16 nPoolNumRange = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
- constexpr sal_uInt16 nPoolCollListsStackedStart = nPoolCollTextRange;
- constexpr sal_uInt16 nPoolCollExtraStackedStart = nPoolCollListsStackedStart + nPoolCollListsRange;
- constexpr sal_uInt16 nPoolCollRegisterStackedStart = nPoolCollExtraStackedStart + nPoolCollExtraRange;
- constexpr sal_uInt16 nPoolCollDocStackedStart = nPoolCollRegisterStackedStart + nPoolCollRegisterRange;
- constexpr sal_uInt16 nPoolCollHtmlStackedStart = nPoolCollDocStackedStart + nPoolCollDocRange;
+ // these should really be constexprs, but MSVC still is apparently too stupid for them
+ #define nPoolChrNormalRange (RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN)
+ #define nPoolChrHtmlRange (RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN)
+ #define nPoolCollTextRange ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN)
+ #define nPoolCollListsRange ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN)
+ #define nPoolCollExtraRange ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN)
+ #define nPoolCollRegisterRange ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN)
+ #define nPoolCollDocRange ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN)
+ #define nPoolCollHtmlRange ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN)
+ #define nPoolFrameRange ( RES_POOLFRM_END - RES_POOLFRM_BEGIN)
+ #define nPoolPageRange ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN)
+ #define nPoolNumRange ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN)
+ #define nPoolCollListsStackedStart ( nPoolCollTextRange)
+ #define nPoolCollExtraStackedStart ( nPoolCollListsStackedStart + nPoolCollListsRange)
+ #define nPoolCollRegisterStackedStart ( nPoolCollExtraStackedStart + nPoolCollExtraRange)
+ #define nPoolCollDocStackedStart ( nPoolCollRegisterStackedStart + nPoolCollRegisterRange)
+ #define nPoolCollHtmlStackedStart ( nPoolCollDocStackedStart + nPoolCollDocRange)
}
static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries();
@@ -397,7 +398,7 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc&, OUString*, sal_Int32);
template<>
sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
- constexpr sal_Int32 nBaseCount = nPoolChrHtmlRange + nPoolCollTextRange;
+ const sal_uInt16 nBaseCount = nPoolChrHtmlRange + nPoolCollTextRange;
nIndex -= nBaseCount;
sal_Int32 nCount = 0;
for(auto pFormat : *rDoc.GetCharFormats())
@@ -423,7 +424,7 @@ sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>(const SwDoc& rDoc, OUString*
template<>
sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
- constexpr sal_Int32 nBaseCount = nPoolCollHtmlStackedStart + nPoolCollHtmlRange;
+ const sal_uInt16 nBaseCount = nPoolCollHtmlStackedStart + nPoolCollHtmlRange;
nIndex -= nBaseCount;
sal_Int32 nCount = 0;
for(auto pColl : *rDoc.GetTextFormatColls())
commit 7cb3a2c35e29207008bac44d7ace10ca9e866d99
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 18:01:02 2015 +0100
use a range template for the frame,page,pseudo translations
Change-Id: I50698023c006025bad4ae5d9a632c20b8f897006
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 6d5c4db..734f075 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -551,27 +551,11 @@ sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA>(const sal_uInt16 nIndex)
throw lang::IndexOutOfBoundsException();
}
-template<>
-sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_FRAME>(const sal_uInt16 nIndex)
-{
- if(nIndex < nPoolFrameRange)
- return nIndex + RES_POOLFRM_BEGIN;
- throw lang::IndexOutOfBoundsException();
-}
-
-template<>
-sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PAGE>(const sal_uInt16 nIndex)
-{
- if(nIndex < nPoolPageRange)
- return nIndex + RES_POOLPAGE_BEGIN;
- throw lang::IndexOutOfBoundsException();
-}
-
-template<>
-sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PSEUDO>(const sal_uInt16 nIndex)
+template<sal_uInt16 nRangeBegin, sal_uInt16 nRangeSize>
+static sal_uInt16 lcl_TranslateIndexRange(const sal_uInt16 nIndex)
{
- if(nIndex < nPoolNumRange)
- return nIndex + RES_POOLNUMRULE_BEGIN;
+ if(nIndex < nRangeSize)
+ return nIndex + nRangeBegin;
throw lang::IndexOutOfBoundsException();
}
@@ -758,11 +742,11 @@ static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries()
if(!our_pStyleFamilyEntries)
{
our_pStyleFamilyEntries = new std::vector<StyleFamilyEntry>{
- { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_CHAR> },
- { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA> },
- { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PAGE> },
- { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_FRAME> },
- { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PSEUDO> }
+ { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_CHAR> },
+ { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA> },
+ { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE>, &lcl_TranslateIndexRange<RES_POOLPAGE_BEGIN, nPoolPageRange> },
+ { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>, &lcl_TranslateIndexRange<RES_POOLFRM_BEGIN, nPoolFrameRange> },
+ { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO>, &lcl_TranslateIndexRange<RES_POOLNUMRULE_BEGIN, nPoolNumRange> }
};
}
return our_pStyleFamilyEntries;
commit 939657e7c8beca46f0b84faf7a89cda8b789e2f5
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 17:50:13 2015 +0100
use the entry vector for lcl_TranslateIndex dispatch
Change-Id: I4a8361821b9a5af2a59ad29684ee243d2f4591ed
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 7e57dd8..6d5c4db 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -96,19 +96,22 @@ namespace
{
using GetCountOrName_t = std::function<sal_Int32 (const SwDoc&, OUString*, sal_Int32)>;
using CreateStyle_t = std::function<uno::Reference<css::style::XStyle>(SfxStyleSheetBasePool*, SwDocShell*, const OUString&)>;
+ using TranslateIndex_t = std::function<sal_uInt16(const sal_uInt16)>;
SfxStyleFamily m_eFamily;
SwGetPoolIdFromName m_aPoolId;
OUString m_sName;
sal_uInt32 m_nResId;
GetCountOrName_t m_fGetCountOrName;
CreateStyle_t m_fCreateStyle;
- StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId, GetCountOrName_t fGetCountOrName, CreateStyle_t fCreateStyle)
+ TranslateIndex_t m_fTranslateIndex;
+ StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId, GetCountOrName_t fGetCountOrName, CreateStyle_t fCreateStyle, TranslateIndex_t fTranslateIndex)
: m_eFamily(eFamily)
, m_aPoolId(aPoolId)
, m_sName(sName)
, m_nResId(nResId)
, m_fGetCountOrName(fGetCountOrName)
, m_fCreateStyle(fCreateStyle)
+ , m_fTranslateIndex(fTranslateIndex)
{}
};
static const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries;
@@ -515,6 +518,63 @@ 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); };
+template<enum SfxStyleFamily>
+static sal_uInt16 lcl_TranslateIndex(const sal_uInt16 nIndex);
+
+template<>
+sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_CHAR>(const sal_uInt16 nIndex)
+{
+ static_assert(nPoolChrNormalRange > 0 && nPoolChrHtmlRange > 0, "invalid pool range");
+ if(nIndex < nPoolChrNormalRange)
+ return nIndex + RES_POOLCHR_NORMAL_BEGIN;
+ else if(nIndex < (nPoolChrHtmlRange+nPoolChrNormalRange))
+ return nIndex + RES_POOLCHR_HTML_BEGIN + nPoolChrNormalRange;
+ throw lang::IndexOutOfBoundsException();
+}
+
+template<>
+sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA>(const sal_uInt16 nIndex)
+{
+ static_assert(nPoolCollTextRange > 0 && nPoolCollListsRange > 0 && nPoolCollExtraRange > 0 && nPoolCollRegisterRange > 0 && nPoolCollDocRange > 0 && nPoolCollHtmlRange > 0, "weird pool range");
+ if(nIndex < nPoolCollListsStackedStart)
+ return nIndex + RES_POOLCOLL_TEXT_BEGIN;
+ else if(nIndex < nPoolCollExtraStackedStart)
+ return nIndex + RES_POOLCOLL_LISTS_BEGIN + nPoolCollListsStackedStart;
+ else if(nIndex < nPoolCollRegisterStackedStart)
+ return nIndex + RES_POOLCOLL_EXTRA_BEGIN + nPoolCollExtraStackedStart;
+ else if(nIndex < nPoolCollDocStackedStart)
+ return nIndex + RES_POOLCOLL_REGISTER_BEGIN + nPoolCollRegisterStackedStart;
+ else if(nIndex < nPoolCollHtmlStackedStart)
+ return nIndex + RES_POOLCOLL_DOC_BEGIN + nPoolCollDocStackedStart;
+ else if(nIndex < nPoolCollHtmlStackedStart + nPoolCollTextRange)
+ return nIndex + RES_POOLCOLL_HTML_BEGIN + nPoolCollHtmlStackedStart;
+ throw lang::IndexOutOfBoundsException();
+}
+
+template<>
+sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_FRAME>(const sal_uInt16 nIndex)
+{
+ if(nIndex < nPoolFrameRange)
+ return nIndex + RES_POOLFRM_BEGIN;
+ throw lang::IndexOutOfBoundsException();
+}
+
+template<>
+sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PAGE>(const sal_uInt16 nIndex)
+{
+ if(nIndex < nPoolPageRange)
+ return nIndex + RES_POOLPAGE_BEGIN;
+ throw lang::IndexOutOfBoundsException();
+}
+
+template<>
+sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PSEUDO>(const sal_uInt16 nIndex)
+{
+ if(nIndex < nPoolNumRange)
+ return nIndex + RES_POOLNUMRULE_BEGIN;
+ throw lang::IndexOutOfBoundsException();
+}
+
uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
{
@@ -524,58 +584,10 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
if(!m_pBasePool)
throw uno::RuntimeException();
OUString sStyleName;
- switch(m_rEntry.m_eFamily)
+ try
{
- case SFX_STYLE_FAMILY_CHAR:
- {
- static_assert(nPoolChrNormalRange > 0 && nPoolChrHtmlRange > 0, "invalid pool range");
- const sal_uInt16 nIndex16 = static_cast<sal_uInt16>(nIndex);
- if(nIndex16 < nPoolChrNormalRange)
- SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName);
- else if(nIndex16 < (nPoolChrHtmlRange+nPoolChrNormalRange))
- SwStyleNameMapper::FillUIName(RES_POOLCHR_HTML_BEGIN + nPoolChrNormalRange + nIndex, sStyleName );
- }
- break;
- case SFX_STYLE_FAMILY_PARA:
- {
- static_assert(nPoolCollTextRange > 0 && nPoolCollListsRange > 0 && nPoolCollExtraRange > 0 && nPoolCollRegisterRange > 0 && nPoolCollDocRange > 0 && nPoolCollHtmlRange > 0, "weird pool range");
- const sal_uInt16 nIndex16 = static_cast<sal_uInt16>(nIndex);
- if(nIndex16 < nPoolCollListsStackedStart)
- SwStyleNameMapper::FillUIName(RES_POOLCOLL_TEXT_BEGIN + nIndex16, sStyleName);
- else if(nIndex16 < nPoolCollExtraStackedStart)
- SwStyleNameMapper::FillUIName(RES_POOLCOLL_LISTS_BEGIN + nPoolCollListsStackedStart + nIndex16, sStyleName);
- else if(nIndex16 < nPoolCollRegisterStackedStart)
- SwStyleNameMapper::FillUIName(RES_POOLCOLL_EXTRA_BEGIN + nPoolCollExtraStackedStart + nIndex16, sStyleName);
- else if(nIndex16 < nPoolCollDocStackedStart)
- SwStyleNameMapper::FillUIName(RES_POOLCOLL_REGISTER_BEGIN + nPoolCollRegisterStackedStart + nIndex16, sStyleName);
- else if(nIndex16 < nPoolCollHtmlStackedStart)
- SwStyleNameMapper::FillUIName(RES_POOLCOLL_DOC_BEGIN + nPoolCollDocStackedStart + nIndex16, sStyleName);
- else if(nIndex16 < nPoolCollHtmlStackedStart + nPoolCollTextRange)
- SwStyleNameMapper::FillUIName(RES_POOLCOLL_HTML_BEGIN + nPoolCollHtmlStackedStart + nIndex16, sStyleName);
- }
- break;
- case SFX_STYLE_FAMILY_FRAME:
- {
- if(nIndex < nPoolFrameRange)
- SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLFRM_BEGIN + nIndex), sStyleName);
- }
- break;
- case SFX_STYLE_FAMILY_PAGE:
- {
- if(nIndex < nPoolPageRange)
- SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLPAGE_BEGIN + nIndex), sStyleName);
- }
- break;
- case SFX_STYLE_FAMILY_PSEUDO:
- {
- if(nIndex < nPoolNumRange)
- SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName);
- }
- break;
-
- default:
- ;
- }
+ SwStyleNameMapper::FillUIName(m_rEntry.m_fTranslateIndex(nIndex), sStyleName);
+ } catch(...) {}
if (sStyleName.isEmpty())
GetCountOrName(&sStyleName, nIndex);
@@ -746,11 +758,11 @@ static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries()
if(!our_pStyleFamilyEntries)
{
our_pStyleFamilyEntries = new std::vector<StyleFamilyEntry>{
- { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR> },
- { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA> },
- { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE> },
- { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME> },
- { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO> }
+ { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_CHAR> },
+ { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA> },
+ { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PAGE> },
+ { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_FRAME> },
+ { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PSEUDO> }
};
}
return our_pStyleFamilyEntries;
commit 6521acdabcdceba0b53a6453ec513c3894a8e77a
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 16:09:46 2015 +0100
remove copy patsa
Change-Id: I753786b6d3e92f0ebd609cc4430887fd7e2c2f81
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index d8de4dc..7e57dd8 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -581,13 +581,7 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
if(sStyleName.isEmpty())
throw lang::IndexOutOfBoundsException();
- SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_rEntry.m_eFamily);
- if(!pBase)
- throw uno::RuntimeException();
- uno::Reference<style::XStyle> xStyle = _FindStyle(sStyleName);
- if(!xStyle.is())
- xStyle = m_rEntry.m_fCreateStyle(m_pBasePool, m_pDocShell, m_rEntry.m_eFamily == SFX_STYLE_FAMILY_FRAME ? pBase->GetName() : sStyleName);
- return uno::makeAny(xStyle);
+ return getByName(sStyleName);
}
uno::Any XStyleFamily::getByName(const OUString& rName)
commit e5e3730265431541c1b0d53e1a5c409204c425f4
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 15:48:46 2015 +0100
use entries to create styles
Change-Id: Ie68277b2ca9f4a82d048c7b74ab6705e8ca164b2
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 2be224d..d8de4dc 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -94,18 +94,21 @@ namespace
{
struct StyleFamilyEntry
{
- using GetCountOrName_t = std::function< sal_Int32 (const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)>;
+ using GetCountOrName_t = std::function<sal_Int32 (const SwDoc&, OUString*, sal_Int32)>;
+ using CreateStyle_t = std::function<uno::Reference<css::style::XStyle>(SfxStyleSheetBasePool*, SwDocShell*, const OUString&)>;
SfxStyleFamily m_eFamily;
SwGetPoolIdFromName m_aPoolId;
OUString m_sName;
sal_uInt32 m_nResId;
GetCountOrName_t m_fGetCountOrName;
- StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId, GetCountOrName_t fGetCountOrName)
+ CreateStyle_t m_fCreateStyle;
+ StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId, GetCountOrName_t fGetCountOrName, CreateStyle_t fCreateStyle)
: m_eFamily(eFamily)
, m_aPoolId(aPoolId)
, m_sName(sName)
, m_nResId(nResId)
, m_fGetCountOrName(fGetCountOrName)
+ , m_fCreateStyle(fCreateStyle)
{}
};
static const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries;
@@ -500,6 +503,17 @@ sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUStrin
return nCount + nPoolNumRange;
}
+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); };
+
+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); };
+
+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); };
uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
@@ -572,19 +586,7 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
throw uno::RuntimeException();
uno::Reference<style::XStyle> xStyle = _FindStyle(sStyleName);
if(!xStyle.is())
- {
- switch(m_rEntry.m_eFamily)
- {
- case SFX_STYLE_FAMILY_PAGE:
- xStyle = new SwXPageStyle(*m_pBasePool, m_pDocShell, m_rEntry.m_eFamily, sStyleName);
- break;
- case SFX_STYLE_FAMILY_FRAME:
- xStyle = new SwXFrameStyle(*m_pBasePool, m_pDocShell->GetDoc(), pBase->GetName());
- break;
- default:
- xStyle = new SwXStyle(*m_pBasePool, m_rEntry.m_eFamily, m_pDocShell->GetDoc(), sStyleName);
- }
- }
+ xStyle = m_rEntry.m_fCreateStyle(m_pBasePool, m_pDocShell, m_rEntry.m_eFamily == SFX_STYLE_FAMILY_FRAME ? pBase->GetName() : sStyleName);
return uno::makeAny(xStyle);
}
@@ -602,19 +604,7 @@ uno::Any XStyleFamily::getByName(const OUString& rName)
throw container::NoSuchElementException();
uno::Reference<style::XStyle> xStyle = _FindStyle(sStyleName);
if(!xStyle.is())
- {
- switch(m_rEntry.m_eFamily)
- {
- case SFX_STYLE_FAMILY_PAGE:
- xStyle = new SwXPageStyle(*m_pBasePool, m_pDocShell, m_rEntry.m_eFamily, sStyleName);
- break;
- case SFX_STYLE_FAMILY_FRAME:
- xStyle = new SwXFrameStyle(*m_pBasePool, m_pDocShell->GetDoc(), pBase->GetName());
- break;
- default:
- xStyle = new SwXStyle(*m_pBasePool, m_rEntry.m_eFamily, m_pDocShell->GetDoc(), sStyleName);
- }
- }
+ xStyle = m_rEntry.m_fCreateStyle(m_pBasePool, m_pDocShell, m_rEntry.m_eFamily == SFX_STYLE_FAMILY_FRAME ? pBase->GetName() : sStyleName);
return uno::makeAny(xStyle);
}
@@ -762,11 +752,11 @@ static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries()
if(!our_pStyleFamilyEntries)
{
our_pStyleFamilyEntries = new std::vector<StyleFamilyEntry>{
- { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR> },
- { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA> },
- { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE> },
- { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME> },
- { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO> }
+ { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR> },
+ { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA> },
+ { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE> },
+ { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME> },
+ { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO> }
};
}
return our_pStyleFamilyEntries;
commit 7b72e851e57cdfe4fb5933f539764fcd66bd02fd
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 14:59:18 2015 +0100
use the entry vector for lcl_GetCountOrName dispatch
- since the "entries" gain virtual functions now, it might make sense to
make the entries proper classes. Lets see.
Change-Id: I9ffae682869bc7560ee108c120efe6b65ea6c82f
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 89423c2..2be224d 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -94,15 +94,18 @@ namespace
{
struct StyleFamilyEntry
{
+ using GetCountOrName_t = std::function< sal_Int32 (const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)>;
SfxStyleFamily m_eFamily;
SwGetPoolIdFromName m_aPoolId;
OUString m_sName;
sal_uInt32 m_nResId;
- StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId)
+ GetCountOrName_t m_fGetCountOrName;
+ StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId, GetCountOrName_t fGetCountOrName)
: m_eFamily(eFamily)
, m_aPoolId(aPoolId)
, m_sName(sName)
, m_nResId(nResId)
+ , m_fGetCountOrName(fGetCountOrName)
{}
};
static const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries;
@@ -143,7 +146,8 @@ namespace sw
SwDocShell* m_pDocShell;
SwXStyle* _FindStyle(const OUString& rStyleName) const;
- sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32);
+ sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32)
+ { return m_rEntry.m_fGetCountOrName(*m_pDocShell->GetDoc(), pString, nIndex); };
static const StyleFamilyEntry& InitEntry(SfxStyleFamily eFamily)
{
auto pEntries = lcl_GetStyleFamilyEntries();
@@ -382,10 +386,10 @@ static bool lcl_GetHeaderFooterItem(
}
template<enum SfxStyleFamily>
-static sal_Int32 lcl_GetCountOrNameImpl(const SwDoc&, OUString*, sal_Int32);
+static sal_Int32 lcl_GetCountOrName(const SwDoc&, OUString*, sal_Int32);
template<>
-sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_CHAR>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
+sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
constexpr sal_Int32 nBaseCount = nPoolChrHtmlRange + nPoolCollTextRange;
nIndex -= nBaseCount;
@@ -411,7 +415,7 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_CHAR>(const SwDoc& rDoc, OUStr
}
template<>
-sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PARA>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
+sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
constexpr sal_Int32 nBaseCount = nPoolCollHtmlStackedStart + nPoolCollHtmlRange;
nIndex -= nBaseCount;
@@ -433,7 +437,7 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PARA>(const SwDoc& rDoc, OUStr
}
template<>
-sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_FRAME>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
+sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
nIndex -= nPoolFrameRange;
sal_Int32 nCount = 0;
@@ -454,7 +458,7 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_FRAME>(const SwDoc& rDoc, OUSt
}
template<>
-sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PAGE>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
+sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
nIndex -= nPoolPageRange;
sal_Int32 nCount = 0;
@@ -476,7 +480,7 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PAGE>(const SwDoc& rDoc, OUStr
}
template<>
-sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
+sal_Int32 lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
nIndex -= nPoolNumRange;
sal_Int32 nCount = 0;
@@ -496,25 +500,6 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUS
return nCount + nPoolNumRange;
}
-sal_Int32 XStyleFamily::GetCountOrName(OUString* pString, sal_Int32 nIndex)
-{
- const auto& rDoc = *m_pDocShell->GetDoc();
- switch(m_rEntry.m_eFamily)
- {
- case SFX_STYLE_FAMILY_CHAR:
- return lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_CHAR>(rDoc, pString, nIndex);
- case SFX_STYLE_FAMILY_PARA:
- return lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PARA>(rDoc, pString, nIndex);
- case SFX_STYLE_FAMILY_FRAME:
- return lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_FRAME>(rDoc, pString, nIndex);
- case SFX_STYLE_FAMILY_PAGE:
- return lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PAGE>(rDoc, pString, nIndex);
- case SFX_STYLE_FAMILY_PSEUDO:
- return lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PSEUDO>(rDoc, pString, nIndex);
- default:
- return 0;
- }
-}
uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
@@ -777,11 +762,11 @@ static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries()
if(!our_pStyleFamilyEntries)
{
our_pStyleFamilyEntries = new std::vector<StyleFamilyEntry>{
- { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER },
- { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH },
- { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE },
- { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME },
- { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING }
+ { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR> },
+ { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA> },
+ { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE> },
+ { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME> },
+ { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO> }
};
}
return our_pStyleFamilyEntries;
commit 92d57e6f6dda37696c1211b46af85b8387716f8f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 14:36:45 2015 +0100
tdf#38835: use singleton instead of static
Change-Id: Id200dd245043537d288e30118debe2b338cf1774
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index fd7cd02..89423c2 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -105,13 +105,7 @@ namespace
, m_nResId(nResId)
{}
};
- static const std::vector<StyleFamilyEntry> our_vStyleFamilyEntries {
- { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER },
- { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH },
- { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE },
- { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME },
- { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING }
- };
+ static const std::vector<StyleFamilyEntry>* our_pStyleFamilyEntries;
constexpr sal_uInt16 nPoolChrNormalRange = RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
constexpr sal_uInt16 nPoolChrHtmlRange = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN;
constexpr sal_uInt16 nPoolCollTextRange = RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
@@ -129,6 +123,7 @@ namespace
constexpr sal_uInt16 nPoolCollDocStackedStart = nPoolCollRegisterStackedStart + nPoolCollRegisterRange;
constexpr sal_uInt16 nPoolCollHtmlStackedStart = nPoolCollDocStackedStart + nPoolCollDocRange;
}
+static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries();
using namespace ::com::sun::star;
@@ -151,9 +146,10 @@ namespace sw
sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32);
static const StyleFamilyEntry& InitEntry(SfxStyleFamily eFamily)
{
- const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
+ auto pEntries = lcl_GetStyleFamilyEntries();
+ const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
[eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; });
- assert(pEntry != our_vStyleFamilyEntries.end());
+ assert(pEntry != pEntries->end());
return *pEntry;
}
public:
@@ -262,42 +258,46 @@ uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name)
SolarMutexGuard aGuard;
if(!IsValid())
throw uno::RuntimeException();
- const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
+ auto pEntries(lcl_GetStyleFamilyEntries());
+ const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
[&Name] (const StyleFamilyEntry& e) { return e.m_sName == Name; });
- if(pEntry == our_vStyleFamilyEntries.end())
+ if(pEntry == pEntries->end())
throw container::NoSuchElementException();
- return getByIndex(pEntry-our_vStyleFamilyEntries.begin());
+ return getByIndex(pEntry-pEntries->begin());
}
uno::Sequence< OUString > SwXStyleFamilies::getElementNames() throw( uno::RuntimeException, std::exception )
{
- uno::Sequence< OUString > aNames(our_vStyleFamilyEntries.size());
- std::transform(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
+ auto pEntries(lcl_GetStyleFamilyEntries());
+ uno::Sequence<OUString> aNames(pEntries->size());
+ std::transform(pEntries->begin(), pEntries->end(),
aNames.begin(), [] (const StyleFamilyEntry& e) { return e.m_sName; });
return aNames;
}
sal_Bool SwXStyleFamilies::hasByName(const OUString& Name) throw( uno::RuntimeException, std::exception )
{
- const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
+ auto pEntries(lcl_GetStyleFamilyEntries());
+ const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
[&Name] (const StyleFamilyEntry& e) { return e.m_sName == Name; });
- return pEntry != our_vStyleFamilyEntries.end();
+ return pEntry != pEntries->end();
}
sal_Int32 SwXStyleFamilies::getCount() throw( uno::RuntimeException, std::exception )
{
- return our_vStyleFamilyEntries.size();
+ return lcl_GetStyleFamilyEntries()->size();
}
uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
{
+ auto pEntries(lcl_GetStyleFamilyEntries());
SolarMutexGuard aGuard;
- if(nIndex < 0 || nIndex >= static_cast<sal_Int32>(our_vStyleFamilyEntries.size()))
+ if(nIndex < 0 || nIndex >= static_cast<sal_Int32>(pEntries->size()))
throw lang::IndexOutOfBoundsException();
if(!IsValid())
throw uno::RuntimeException();
- auto eFamily = our_vStyleFamilyEntries[nIndex].m_eFamily;
+ auto eFamily = (*pEntries)[nIndex].m_eFamily;
assert(eFamily != SFX_STYLE_FAMILY_ALL);
auto& rxFamily = m_vFamilies[eFamily];
if(!rxFamily.is())
@@ -772,6 +772,21 @@ SwXStyle* XStyleFamily::_FindStyle(const OUString& rStyleName) const
return nullptr;
}
+static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries()
+{
+ if(!our_pStyleFamilyEntries)
+ {
+ our_pStyleFamilyEntries = new std::vector<StyleFamilyEntry>{
+ { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER },
+ { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH },
+ { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE },
+ { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME },
+ { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING }
+ };
+ }
+ return our_pStyleFamilyEntries;
+}
+
class SwStyleProperties_Impl
{
const PropertyEntryVector_t aPropertyEntries;
@@ -886,9 +901,10 @@ void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const u
static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)
{
- const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
+ auto pEntries(lcl_GetStyleFamilyEntries());
+ const auto pEntry = std::find_if(pEntries->begin(), pEntries->end(),
[eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; });
- if(pEntry != our_vStyleFamilyEntries.end())
+ if(pEntry != pEntries->end())
return pEntry->m_aPoolId;
SAL_WARN("sw.uno", "someone asking for all styles in unostyle.cxx!" );
return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
commit b7ffa8be976a5a6e49bbadf4af80a5fd889c4502
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 14:11:47 2015 +0100
keep a reference to the static entry data for the family
Change-Id: I9171202fb5c6e32016550243a027001e5c910c3c
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 849f4f1..fd7cd02 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -108,9 +108,9 @@ namespace
static const std::vector<StyleFamilyEntry> our_vStyleFamilyEntries {
{ SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER },
{ SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH },
- { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE},
- { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME},
- { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING}
+ { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE },
+ { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME },
+ { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING }
};
constexpr sal_uInt16 nPoolChrNormalRange = RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
constexpr sal_uInt16 nPoolChrHtmlRange = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN;
@@ -143,16 +143,22 @@ namespace sw
>,
public SfxListener
{
- SfxStyleFamily m_eFamily;
- SfxStyleSheetBasePool* m_pBasePool;
- SwDocShell* m_pDocShell;
+ const StyleFamilyEntry& m_rEntry;
+ SfxStyleSheetBasePool* m_pBasePool;
+ SwDocShell* m_pDocShell;
- SwXStyle* _FindStyle(const OUString& rStyleName) const;
+ SwXStyle* _FindStyle(const OUString& rStyleName) const;
sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32);
-
+ static const StyleFamilyEntry& InitEntry(SfxStyleFamily eFamily)
+ {
+ const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
+ [eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; });
+ assert(pEntry != our_vStyleFamilyEntries.end());
+ return *pEntry;
+ }
public:
XStyleFamily(SwDocShell* pDocShell, const SfxStyleFamily eFamily)
- : m_eFamily(eFamily)
+ : m_rEntry(InitEntry(eFamily))
, m_pBasePool(pDocShell->GetStyleSheetPool())
, m_pDocShell(pDocShell)
{
@@ -228,16 +234,6 @@ namespace sw
using sw::XStyleFamily;
-static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)
-{
- const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
- [eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; });
- if(pEntry != our_vStyleFamilyEntries.end())
- return pEntry->m_aPoolId;
- SAL_WARN("sw.uno", "someone asking for all styles in unostyle.cxx!" );
- return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
-}
-
OUString SwXStyleFamilies::getImplementationName() throw( uno::RuntimeException, std::exception )
{ return {"SwXStyleFamilies"}; }
@@ -503,7 +499,7 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUS
sal_Int32 XStyleFamily::GetCountOrName(OUString* pString, sal_Int32 nIndex)
{
const auto& rDoc = *m_pDocShell->GetDoc();
- switch(m_eFamily)
+ switch(m_rEntry.m_eFamily)
{
case SFX_STYLE_FAMILY_CHAR:
return lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_CHAR>(rDoc, pString, nIndex);
@@ -529,7 +525,7 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
if(!m_pBasePool)
throw uno::RuntimeException();
OUString sStyleName;
- switch(m_eFamily)
+ switch(m_rEntry.m_eFamily)
{
case SFX_STYLE_FAMILY_CHAR:
{
@@ -586,22 +582,22 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
if(sStyleName.isEmpty())
throw lang::IndexOutOfBoundsException();
- SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_eFamily);
+ SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName, m_rEntry.m_eFamily);
if(!pBase)
throw uno::RuntimeException();
uno::Reference<style::XStyle> xStyle = _FindStyle(sStyleName);
if(!xStyle.is())
{
- switch(m_eFamily)
+ switch(m_rEntry.m_eFamily)
{
case SFX_STYLE_FAMILY_PAGE:
- xStyle = new SwXPageStyle(*m_pBasePool, m_pDocShell, m_eFamily, sStyleName);
+ xStyle = new SwXPageStyle(*m_pBasePool, m_pDocShell, m_rEntry.m_eFamily, sStyleName);
break;
case SFX_STYLE_FAMILY_FRAME:
xStyle = new SwXFrameStyle(*m_pBasePool, m_pDocShell->GetDoc(), pBase->GetName());
break;
default:
- xStyle = new SwXStyle(*m_pBasePool, m_eFamily, m_pDocShell->GetDoc(), sStyleName);
+ xStyle = new SwXStyle(*m_pBasePool, m_rEntry.m_eFamily, m_pDocShell->GetDoc(), sStyleName);
}
}
return uno::makeAny(xStyle);
@@ -612,26 +608,26 @@ uno::Any XStyleFamily::getByName(const OUString& rName)
{
SolarMutexGuard aGuard;
OUString sStyleName;
- SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum(m_eFamily), true);
+ SwStyleNameMapper::FillUIName(rName, sStyleName, m_rEntry.m_aPoolId, true);
if(!m_pBasePool)
throw uno::RuntimeException();
- m_pBasePool->SetSearchMask(m_eFamily);
+ m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName);
if(!pBase)
throw container::NoSuchElementException();
uno::Reference<style::XStyle> xStyle = _FindStyle(sStyleName);
if(!xStyle.is())
{
- switch(m_eFamily)
+ switch(m_rEntry.m_eFamily)
{
case SFX_STYLE_FAMILY_PAGE:
- xStyle = new SwXPageStyle(*m_pBasePool, m_pDocShell, m_eFamily, sStyleName);
+ xStyle = new SwXPageStyle(*m_pBasePool, m_pDocShell, m_rEntry.m_eFamily, sStyleName);
break;
case SFX_STYLE_FAMILY_FRAME:
xStyle = new SwXFrameStyle(*m_pBasePool, m_pDocShell->GetDoc(), pBase->GetName());
break;
default:
- xStyle = new SwXStyle(*m_pBasePool, m_eFamily, m_pDocShell->GetDoc(), sStyleName);
+ xStyle = new SwXStyle(*m_pBasePool, m_rEntry.m_eFamily, m_pDocShell->GetDoc(), sStyleName);
}
}
return uno::makeAny(xStyle);
@@ -643,11 +639,11 @@ uno::Sequence<OUString> XStyleFamily::getElementNames() throw( uno::RuntimeExcep
if(!m_pBasePool)
throw uno::RuntimeException();
std::vector<OUString> vRet;
- SfxStyleSheetIteratorPtr pIt = m_pBasePool->CreateIterator(m_eFamily, SFXSTYLEBIT_ALL);
+ SfxStyleSheetIteratorPtr pIt = m_pBasePool->CreateIterator(m_rEntry.m_eFamily, SFXSTYLEBIT_ALL);
for (SfxStyleSheetBase* pStyle = pIt->First(); pStyle; pStyle = pIt->Next())
{
OUString sName;
- SwStyleNameMapper::FillProgName(pStyle->GetName(), sName, lcl_GetSwEnumFromSfxEnum(m_eFamily), true);
+ SwStyleNameMapper::FillProgName(pStyle->GetName(), sName, m_rEntry.m_aPoolId, true);
vRet.push_back(sName);
}
return comphelper::containerToSequence(vRet);
@@ -659,8 +655,8 @@ sal_Bool XStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeExcep
if(!m_pBasePool)
throw uno::RuntimeException();
OUString sStyleName;
- SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum(m_eFamily), true);
- m_pBasePool->SetSearchMask(m_eFamily);
+ SwStyleNameMapper::FillUIName(rName, sStyleName, m_rEntry.m_aPoolId, true);
+ m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName);
return nullptr != pBase;
}
@@ -673,8 +669,8 @@ void XStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
if(!m_pBasePool)
throw uno::RuntimeException();
OUString sStyleName;
- SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum(m_eFamily), true);
- m_pBasePool->SetSearchMask(m_eFamily);
+ SwStyleNameMapper::FillUIName(rName, sStyleName, m_rEntry.m_aPoolId, true);
+ m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName);
SfxStyleSheetBase* pUINameBase = m_pBasePool->Find( sStyleName );
if(pBase || pUINameBase)
@@ -689,23 +685,23 @@ void XStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
}
- if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != m_eFamily)
+ if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != m_rEntry.m_eFamily)
throw lang::IllegalArgumentException();
sal_uInt16 nMask = SFXSTYLEBIT_ALL;
- if(m_eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional())
+ if(m_rEntry.m_eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional())
nMask &= ~SWSTYLEBIT_CONDCOLL;
- m_pBasePool->Make(sStyleName, m_eFamily, nMask);
+ m_pBasePool->Make(sStyleName, m_rEntry.m_eFamily, nMask);
pNewStyle->SetDoc(m_pDocShell->GetDoc(), m_pBasePool);
pNewStyle->SetStyleName(sStyleName);
const OUString sParentStyleName(pNewStyle->GetParentStyleName());
if (!sParentStyleName.isEmpty())
{
- m_pBasePool->SetSearchMask(m_eFamily);
+ m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
SfxStyleSheetBase* pParentBase = m_pBasePool->Find(sParentStyleName);
- if(pParentBase && pParentBase->GetFamily() == m_eFamily &&
+ if(pParentBase && pParentBase->GetFamily() == m_rEntry.m_eFamily &&
&pParentBase->GetPool() == m_pBasePool)
- m_pBasePool->SetParent(m_eFamily, sStyleName, sParentStyleName);
+ m_pBasePool->SetParent(m_rEntry.m_eFamily, sStyleName, sParentStyleName);
}
// after all, we still need to apply the properties of the descriptor
pNewStyle->ApplyDescriptorProperties();
@@ -717,7 +713,7 @@ void XStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement
SolarMutexGuard aGuard;
if(!m_pBasePool)
throw uno::RuntimeException();
- m_pBasePool->SetSearchMask(m_eFamily);
+ m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
SfxStyleSheetBase* pBase = m_pBasePool->Find(rName);
// replacements only for userdefined styles
if(!pBase)
@@ -745,9 +741,9 @@ void XStyleFamily::removeByName(const OUString& rName) throw( container::NoSuchE
SolarMutexGuard aGuard;
if(!m_pBasePool)
throw uno::RuntimeException();
- m_pBasePool->SetSearchMask(m_eFamily);
+ m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
OUString sName;
- SwStyleNameMapper::FillUIName(rName, sName, lcl_GetSwEnumFromSfxEnum(m_eFamily), true);
+ SwStyleNameMapper::FillUIName(rName, sName, m_rEntry.m_aPoolId, true);
SfxStyleSheetBase* pBase = m_pBasePool->Find( sName );
if(!pBase)
throw container::NoSuchElementException();
@@ -759,10 +755,7 @@ uno::Any SAL_CALL XStyleFamily::getPropertyValue( const OUString& sPropertyName
if(sPropertyName != "DisplayName")
throw beans::UnknownPropertyException( "unknown property: " + sPropertyName, static_cast<OWeakObject *>(this) );
SolarMutexGuard aGuard;
- const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
- [this] (const StyleFamilyEntry& e) { return m_eFamily == e.m_eFamily; });
- assert(pEntry != our_vStyleFamilyEntries.end()); // invalid family
- return uno::makeAny(SW_RESSTR(pEntry->m_nResId));
+ return uno::makeAny(SW_RESSTR(m_rEntry.m_nResId));
}
@@ -773,7 +766,7 @@ SwXStyle* XStyleFamily::_FindStyle(const OUString& rStyleName) const
{
SfxListener* pListener = m_pBasePool->GetListener(i);
SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>(pListener);
- if(pTempStyle && pTempStyle->GetFamily() == m_eFamily && pTempStyle->GetStyleName() == rStyleName)
+ if(pTempStyle && pTempStyle->GetFamily() == m_rEntry.m_eFamily && pTempStyle->GetStyleName() == rStyleName)
return pTempStyle;
}
return nullptr;
@@ -891,6 +884,16 @@ void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const u
rAny = rxPropertySet->getPropertyValue( rPropertyName );
}
+static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)
+{
+ const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
+ [eFamily] (const StyleFamilyEntry& e) { return e.m_eFamily == eFamily; });
+ if(pEntry != our_vStyleFamilyEntries.end())
+ return pEntry->m_aPoolId;
+ SAL_WARN("sw.uno", "someone asking for all styles in unostyle.cxx!" );
+ return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
+}
+
namespace
{
class theSwXStyleUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXStyleUnoTunnelId > {};
commit 9f030d0898e2b5c91160d4228392797dc1b77ca5
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 12:39:43 2015 +0100
use Families instead of the generic 'Container'
Change-Id: I009002621a5481b91e14a215237278d56d742579
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index 0d2deb7..90807ba 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -66,7 +66,7 @@ class SwXStyleFamilies : public cppu::WeakImplHelper
{
SwDocShell* m_pDocShell;
- std::map<SfxStyleFamily, css::uno::Reference<css::container::XNameContainer>> m_vContainers;
+ std::map<SfxStyleFamily, css::uno::Reference<css::container::XNameContainer>> m_vFamilies;
protected:
virtual ~SwXStyleFamilies();
public:
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 11e2451..849f4f1 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -303,10 +303,10 @@ uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
throw uno::RuntimeException();
auto eFamily = our_vStyleFamilyEntries[nIndex].m_eFamily;
assert(eFamily != SFX_STYLE_FAMILY_ALL);
- auto& rxContainer = m_vContainers[eFamily];
- if(!rxContainer.is())
- rxContainer = new XStyleFamily(m_pDocShell, eFamily);
- return uno::makeAny(rxContainer);
+ auto& rxFamily = m_vFamilies[eFamily];
+ if(!rxFamily.is())
+ rxFamily = new XStyleFamily(m_pDocShell, eFamily);
+ return uno::makeAny(rxFamily);
}
uno::Type SwXStyleFamilies::getElementType()
commit 2056e3123f83a957290098a495d8759c9033eb26
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 04:56:38 2015 +0100
typo: m_nRedId => m_nResId
Change-Id: I0659155b19870117e97f691aa4fdceee8f2d4c08
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 5236631..11e2451 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -97,12 +97,12 @@ namespace
SfxStyleFamily m_eFamily;
SwGetPoolIdFromName m_aPoolId;
OUString m_sName;
- sal_uInt32 m_nRedId;
- StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const & sName, sal_uInt32 nResId)
+ sal_uInt32 m_nResId;
+ StyleFamilyEntry(SfxStyleFamily eFamily, SwGetPoolIdFromName aPoolId, OUString const& sName, sal_uInt32 nResId)
: m_eFamily(eFamily)
, m_aPoolId(aPoolId)
, m_sName(sName)
- , m_nRedId(nResId)
+ , m_nResId(nResId)
{}
};
static const std::vector<StyleFamilyEntry> our_vStyleFamilyEntries {
@@ -762,7 +762,7 @@ uno::Any SAL_CALL XStyleFamily::getPropertyValue( const OUString& sPropertyName
const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
[this] (const StyleFamilyEntry& e) { return m_eFamily == e.m_eFamily; });
assert(pEntry != our_vStyleFamilyEntries.end()); // invalid family
- return uno::makeAny(SW_RESSTR(pEntry->m_nRedId));
+ return uno::makeAny(SW_RESSTR(pEntry->m_nResId));
}
commit bdb6e648d20ec4cb8bbc62308e2368531ea1e42b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 04:55:01 2015 +0100
clean up and reduce indent levels
Change-Id: I5aa38475eff213620b29e89a0df0833c95207a91
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index d3cda09..5236631 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -466,16 +466,14 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PAGE>(const SwDoc& rDoc, OUStr
for(size_t i = 0; i < nArrLen; ++i)
{
const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
-
- if ( IsPoolUserFormat ( rDesc.GetPoolFormatId() ) )
+ if(!IsPoolUserFormat(rDesc.GetPoolFormatId()))
+ continue;
+ if(nIndex == nCount)
{
- if ( nIndex == nCount )
- {
- *pString = rDesc.GetName();
- break;
- }
- ++nCount;
+ *pString = rDesc.GetName();
+ break;
}
+ ++nCount;
}
nCount += nPoolPageRange;
return nCount;
commit 0d05bb47c40566cc183c4c13cc93ad87f167d8f3
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 04:50:28 2015 +0100
add ranges for pages, frames, nums
Change-Id: Id3c0f39b076bd3908d3ac4154e72ee14ca3963ae
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 7159210..d3cda09 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -120,6 +120,9 @@ namespace
constexpr sal_uInt16 nPoolCollRegisterRange = RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN;
constexpr sal_uInt16 nPoolCollDocRange = RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN;
constexpr sal_uInt16 nPoolCollHtmlRange = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN;
+ constexpr sal_uInt16 nPoolFrameRange = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
+ constexpr sal_uInt16 nPoolPageRange = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
+ constexpr sal_uInt16 nPoolNumRange = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
constexpr sal_uInt16 nPoolCollListsStackedStart = nPoolCollTextRange;
constexpr sal_uInt16 nPoolCollExtraStackedStart = nPoolCollListsStackedStart + nPoolCollListsRange;
constexpr sal_uInt16 nPoolCollRegisterStackedStart = nPoolCollExtraStackedStart + nPoolCollExtraRange;
@@ -436,8 +439,7 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PARA>(const SwDoc& rDoc, OUStr
template<>
sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_FRAME>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
- constexpr sal_Int32 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
- nIndex -= nBaseCount;
+ nIndex -= nPoolFrameRange;
sal_Int32 nCount = 0;
for(const auto pFormat : *rDoc.GetFrameFormats())
{
@@ -452,15 +454,14 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_FRAME>(const SwDoc& rDoc, OUSt
}
nCount++;
}
- return nCount + nBaseCount;
+ return nCount + nPoolFrameRange;
}
template<>
sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PAGE>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
+ nIndex -= nPoolPageRange;
sal_Int32 nCount = 0;
- const sal_Int32 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
- nIndex = nIndex - nBaseCount;
const size_t nArrLen = rDoc.GetPageDescCnt();
for(size_t i = 0; i < nArrLen; ++i)
{
@@ -476,15 +477,14 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PAGE>(const SwDoc& rDoc, OUStr
++nCount;
}
}
- nCount += nBaseCount;
+ nCount += nPoolPageRange;
return nCount;
}
template<>
sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
- constexpr sal_Int32 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
- nIndex -= nBaseCount;
+ nIndex -= nPoolNumRange;
sal_Int32 nCount = 0;
for(const auto pRule : rDoc.GetNumRuleTable())
{
@@ -499,7 +499,7 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUS
}
++nCount;
}
- return nCount + nBaseCount;
+ return nCount + nPoolNumRange;
}
sal_Int32 XStyleFamily::GetCountOrName(OUString* pString, sal_Int32 nIndex)
@@ -563,20 +563,20 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
break;
case SFX_STYLE_FAMILY_FRAME:
{
- if(nIndex < (RES_POOLFRM_END - RES_POOLFRM_BEGIN))
+ if(nIndex < nPoolFrameRange)
SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLFRM_BEGIN + nIndex), sStyleName);
}
break;
case SFX_STYLE_FAMILY_PAGE:
{
- if(nIndex < (RES_POOLPAGE_END - RES_POOLPAGE_BEGIN ))
+ if(nIndex < nPoolPageRange)
SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLPAGE_BEGIN + nIndex), sStyleName);
}
break;
case SFX_STYLE_FAMILY_PSEUDO:
{
- if(nIndex < (RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN))
- SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName );
+ if(nIndex < nPoolNumRange)
+ SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName);
}
break;
commit 9c852dd419bc3b30e1e4ed69be3ba8132b4f2e65
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 04:36:50 2015 +0100
make GetCountOrName a private member to reduce args
Change-Id: I72430f032d032f825034ec00d662ceaaa6a4dc62
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 86b1819..7159210 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -145,6 +145,8 @@ namespace sw
SwDocShell* m_pDocShell;
SwXStyle* _FindStyle(const OUString& rStyleName) const;
+ sal_Int32 GetCountOrName(OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32);
+
public:
XStyleFamily(SwDocShell* pDocShell, const SfxStyleFamily eFamily)
: m_eFamily(eFamily)
@@ -157,7 +159,11 @@ namespace sw
virtual ~XStyleFamily() {};
//XIndexAccess
- virtual sal_Int32 SAL_CALL getCount() throw( uno::RuntimeException, std::exception ) override;
+ virtual sal_Int32 SAL_CALL getCount() throw( uno::RuntimeException, std::exception ) override
+ {
+ SolarMutexGuard aGuard;
+ return GetCountOrName(nullptr);
+ };
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
//XElementAccess
@@ -496,9 +502,10 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc& rDoc, OUS
return nCount + nBaseCount;
}
-static sal_Int32 lcl_GetCountOrName(const SwDoc& rDoc, SfxStyleFamily eFamily, OUString* pString, sal_Int32 nIndex = SAL_MAX_INT32)
+sal_Int32 XStyleFamily::GetCountOrName(OUString* pString, sal_Int32 nIndex)
{
- switch(eFamily)
+ const auto& rDoc = *m_pDocShell->GetDoc();
+ switch(m_eFamily)
{
case SFX_STYLE_FAMILY_CHAR:
return lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_CHAR>(rDoc, pString, nIndex);
@@ -515,12 +522,6 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc& rDoc, SfxStyleFamily eFamily, O
}
}
-sal_Int32 XStyleFamily::getCount() throw( uno::RuntimeException, std::exception )
-{
- SolarMutexGuard aGuard;
- return lcl_GetCountOrName(*m_pDocShell->GetDoc(), m_eFamily, nullptr);
-}
-
uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
{
@@ -583,7 +584,7 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
;
}
if (sStyleName.isEmpty())
- lcl_GetCountOrName(*m_pDocShell->GetDoc(), m_eFamily, &sStyleName, nIndex);
+ GetCountOrName(&sStyleName, nIndex);
if(sStyleName.isEmpty())
throw lang::IndexOutOfBoundsException();
commit 71a7e566397773765e2c80a2944d194861cf7e45
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 04:03:47 2015 +0100
consolidate range voodoo
Change-Id: I76c64f15cd94ea281e44ddd488bc7eb7abc1575d
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 8ed8eed..86b1819 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -112,6 +112,19 @@ namespace
{ SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME},
{ SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING}
};
+ constexpr sal_uInt16 nPoolChrNormalRange = RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
+ constexpr sal_uInt16 nPoolChrHtmlRange = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN;
+ constexpr sal_uInt16 nPoolCollTextRange = RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
+ constexpr sal_uInt16 nPoolCollListsRange = RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN;
+ constexpr sal_uInt16 nPoolCollExtraRange = RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN;
+ constexpr sal_uInt16 nPoolCollRegisterRange = RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN;
+ constexpr sal_uInt16 nPoolCollDocRange = RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN;
+ constexpr sal_uInt16 nPoolCollHtmlRange = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN;
+ constexpr sal_uInt16 nPoolCollListsStackedStart = nPoolCollTextRange;
+ constexpr sal_uInt16 nPoolCollExtraStackedStart = nPoolCollListsStackedStart + nPoolCollListsRange;
+ constexpr sal_uInt16 nPoolCollRegisterStackedStart = nPoolCollExtraStackedStart + nPoolCollExtraRange;
+ constexpr sal_uInt16 nPoolCollDocStackedStart = nPoolCollRegisterStackedStart + nPoolCollRegisterRange;
+ constexpr sal_uInt16 nPoolCollHtmlStackedStart = nPoolCollDocStackedStart + nPoolCollDocRange;
}
using namespace ::com::sun::star;
@@ -346,30 +359,6 @@ uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions()
return aSeq;
}
-// Already implemented autostyle families: 3
-#define AUTOSTYLE_FAMILY_COUNT 3
-const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] =
-{
- IStyleAccess::AUTO_STYLE_CHAR,
- IStyleAccess::AUTO_STYLE_RUBY,
- IStyleAccess::AUTO_STYLE_PARA
-};
-
-class SwAutoStylesEnumImpl
-{
- std::vector<SfxItemSet_Pointer_t> mAutoStyles;
- std::vector<SfxItemSet_Pointer_t>::iterator aIter;
- SwDoc* pDoc;
- IStyleAccess::SwAutoStyleFamily eFamily;
-public:
- SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam );
- bool hasMoreElements() { return aIter != mAutoStyles.end(); }
- SfxItemSet_Pointer_t nextElement() { return *(aIter++); }
- IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; }
- SwDoc* getDoc() const { return pDoc; }
-};
-
-
static bool lcl_GetHeaderFooterItem(
SfxItemSet const& rSet, OUString const& rPropName, bool const bFooter,
SvxSetItem const*& o_rpItem)
@@ -393,9 +382,7 @@ static sal_Int32 lcl_GetCountOrNameImpl(const SwDoc&, OUString*, sal_Int32);
template<>
sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_CHAR>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
- constexpr sal_Int32 nBaseCount =
- RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
- RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
+ constexpr sal_Int32 nBaseCount = nPoolChrHtmlRange + nPoolCollTextRange;
nIndex -= nBaseCount;
sal_Int32 nCount = 0;
for(auto pFormat : *rDoc.GetCharFormats())
@@ -421,13 +408,7 @@ sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_CHAR>(const SwDoc& rDoc, OUStr
template<>
sal_Int32 lcl_GetCountOrNameImpl<SFX_STYLE_FAMILY_PARA>(const SwDoc& rDoc, OUString* pString, sal_Int32 nIndex)
{
- constexpr sal_Int32 nBaseCount =
- RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
- RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
- RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
- RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
- RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
- RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
+ constexpr sal_Int32 nBaseCount = nPoolCollHtmlStackedStart + nPoolCollHtmlRange;
nIndex -= nBaseCount;
sal_Int32 nCount = 0;
for(auto pColl : *rDoc.GetTextFormatColls())
@@ -553,29 +534,17 @@ uno::Any XStyleFamily::getByIndex(sal_Int32 nIndex)
{
case SFX_STYLE_FAMILY_CHAR:
{
- constexpr sal_Int32 nPoolChrNormalRange = RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
- constexpr sal_Int32 nPoolChrHtmlRange = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN;
static_assert(nPoolChrNormalRange > 0 && nPoolChrHtmlRange > 0, "invalid pool range");
- if(nIndex < nPoolChrNormalRange)
+ const sal_uInt16 nIndex16 = static_cast<sal_uInt16>(nIndex);
+ if(nIndex16 < nPoolChrNormalRange)
SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName);
- else if(nIndex < (nPoolChrHtmlRange+nPoolChrNormalRange))
+ else if(nIndex16 < (nPoolChrHtmlRange+nPoolChrNormalRange))
SwStyleNameMapper::FillUIName(RES_POOLCHR_HTML_BEGIN + nPoolChrNormalRange + nIndex, sStyleName );
}
break;
case SFX_STYLE_FAMILY_PARA:
{
- constexpr sal_uInt16 nPoolCollTextRange = RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
- constexpr sal_uInt16 nPoolCollListsRange = RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN;
- constexpr sal_uInt16 nPoolCollExtraRange = RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN;
- constexpr sal_uInt16 nPoolCollRegisterRange = RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN;
- constexpr sal_uInt16 nPoolCollDocRange = RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN;
- constexpr sal_uInt16 nPoolCollHtmlRange = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN;
static_assert(nPoolCollTextRange > 0 && nPoolCollListsRange > 0 && nPoolCollExtraRange > 0 && nPoolCollRegisterRange > 0 && nPoolCollDocRange > 0 && nPoolCollHtmlRange > 0, "weird pool range");
- constexpr sal_uInt16 nPoolCollListsStackedStart = nPoolCollTextRange;
- constexpr sal_uInt16 nPoolCollExtraStackedStart = nPoolCollListsStackedStart + nPoolCollListsRange;
- constexpr sal_uInt16 nPoolCollRegisterStackedStart = nPoolCollExtraStackedStart + nPoolCollExtraRange;
- constexpr sal_uInt16 nPoolCollDocStackedStart = nPoolCollRegisterStackedStart + nPoolCollRegisterRange;
- constexpr sal_uInt16 nPoolCollHtmlStackedStart = nPoolCollDocStackedStart + nPoolCollDocRange;
const sal_uInt16 nIndex16 = static_cast<sal_uInt16>(nIndex);
if(nIndex16 < nPoolCollListsStackedStart)
SwStyleNameMapper::FillUIName(RES_POOLCOLL_TEXT_BEGIN + nIndex16, sStyleName);
@@ -3814,6 +3783,29 @@ uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno
return new SwFrameStyleEventDescriptor( *this );
}
+// Already implemented autostyle families: 3
+#define AUTOSTYLE_FAMILY_COUNT 3
+const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] =
+{
+ IStyleAccess::AUTO_STYLE_CHAR,
+ IStyleAccess::AUTO_STYLE_RUBY,
+ IStyleAccess::AUTO_STYLE_PARA
+};
+
+class SwAutoStylesEnumImpl
+{
+ std::vector<SfxItemSet_Pointer_t> mAutoStyles;
+ std::vector<SfxItemSet_Pointer_t>::iterator aIter;
+ SwDoc* pDoc;
+ IStyleAccess::SwAutoStyleFamily eFamily;
+public:
+ SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam );
+ bool hasMoreElements() { return aIter != mAutoStyles.end(); }
+ SfxItemSet_Pointer_t nextElement() { return *(aIter++); }
+ IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; }
+ SwDoc* getDoc() const { return pDoc; }
+};
+
SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) :
SwUnoCollection(rDocShell.GetDoc()), m_pDocShell( &rDocShell )
{
commit 812e92b012569e42c31f70f53e641d4137267623
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 03:52:40 2015 +0100
inline trivial functions
Change-Id: I00a75c846ca86dc05f42211c700561c066f85586
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 1202f04..8ed8eed 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -133,16 +133,29 @@ namespace sw
SwXStyle* _FindStyle(const OUString& rStyleName) const;
public:
- XStyleFamily(SwDocShell* pDocShell, const SfxStyleFamily eFamily);
- virtual ~XStyleFamily();
+ XStyleFamily(SwDocShell* pDocShell, const SfxStyleFamily eFamily)
+ : m_eFamily(eFamily)
+ , m_pBasePool(pDocShell->GetStyleSheetPool())
+ , m_pDocShell(pDocShell)
+ {
+ StartListening(*m_pBasePool);
+ }
+
+ virtual ~XStyleFamily() {};
//XIndexAccess
virtual sal_Int32 SAL_CALL getCount() throw( uno::RuntimeException, std::exception ) override;
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
//XElementAccess
- virtual uno::Type SAL_CALL SAL_CALL getElementType( ) throw(uno::RuntimeException, std::exception) override;
- virtual sal_Bool SAL_CALL SAL_CALL hasElements( ) throw(uno::RuntimeException, std::exception) override;
+ virtual uno::Type SAL_CALL SAL_CALL getElementType( ) throw(uno::RuntimeException, std::exception) override
+ { return cppu::UnoType<style::XStyle>::get(); };
+ virtual sal_Bool SAL_CALL SAL_CALL hasElements( ) throw(uno::RuntimeException, std::exception) override
+ {
+ if(!m_pBasePool)
+ throw uno::RuntimeException();
+ return true;
+ }
//XNameAccess
virtual uno::Any SAL_CALL getByName(const OUString& Name) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
@@ -155,26 +168,43 @@ namespace sw
virtual void SAL_CALL removeByName(const OUString& Name) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
//XPropertySet
- virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
+ virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (uno::RuntimeException, std::exception) override
+ { return {}; };
+ virtual void SAL_CALL setPropertyValue( const OUString&, const uno::Any&) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override
+ { SAL_WARN("sw.uno", "###unexpected!"); };
virtual uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
+ virtual void SAL_CALL addPropertyChangeListener( const OUString&, const uno::Reference<beans::XPropertyChangeListener>&) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override
+ { SAL_WARN("sw.uno", "###unexpected!"); };
+ virtual void SAL_CALL removePropertyChangeListener( const OUString&, const uno::Reference<beans::XPropertyChangeListener>&) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override
+ { SAL_WARN("sw.uno", "###unexpected!"); };
+ virtual void SAL_CALL addVetoableChangeListener(const OUString&, const uno::Reference<beans::XVetoableChangeListener>&) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override
+ { SAL_WARN("sw.uno", "###unexpected!"); };
+ virtual void SAL_CALL removeVetoableChangeListener(const OUString&, const uno::Reference<beans::XVetoableChangeListener>&) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override
+ { SAL_WARN("sw.uno", "###unexpected!"); };
//SfxListener
- virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
+ virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override
+ {
+ const SfxSimpleHint *pHint = dynamic_cast<const SfxSimpleHint*>( &rHint );
+ if(pHint && (pHint->GetId() & SFX_HINT_DYING))
+ {
+ m_pBasePool = nullptr, m_pDocShell = nullptr;
+ EndListening(rBC);
+ }
+ }
//XServiceInfo
- virtual OUString SAL_CALL getImplementationName() throw( uno::RuntimeException, std::exception ) override;
- virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( uno::RuntimeException, std::exception ) override;
- virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( uno::RuntimeException, std::exception ) override;
+ virtual OUString SAL_CALL getImplementationName() throw( uno::RuntimeException, std::exception ) override
+ { return {"XStyleFamily"}; };
+ virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) override
+ { return cppu::supportsService(this, rServiceName); };
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( uno::RuntimeException, std::exception ) override
+ { return { "com.sun.star.style.StyleFamily" }; }
};
}
-using sw::XStyleFamily;
+using sw::XStyleFamily;
static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)
{
@@ -316,17 +346,6 @@ uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions()
return aSeq;
}
-OUString XStyleFamily::getImplementationName() throw( uno::RuntimeException, std::exception )
- { return {"XStyleFamily"}; }
-
-sal_Bool XStyleFamily::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
-{
- return cppu::supportsService(this, rServiceName);
-}
-
-uno::Sequence< OUString > XStyleFamily::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
- { return { "com.sun.star.style.StyleFamily" }; }
-
// Already implemented autostyle families: 3
#define AUTOSTYLE_FAMILY_COUNT 3
const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] =
@@ -350,18 +369,6 @@ public:
SwDoc* getDoc() const { return pDoc; }
};
-XStyleFamily::XStyleFamily(SwDocShell* pDocSh, const SfxStyleFamily eFamily) :
- m_eFamily(eFamily),
- m_pBasePool(pDocSh->GetStyleSheetPool()),
- m_pDocShell(pDocSh)
-{
- StartListening(*m_pBasePool);
-}
-
-XStyleFamily::~XStyleFamily()
-{
-
-}
static bool lcl_GetHeaderFooterItem(
SfxItemSet const& rSet, OUString const& rPropName, bool const bFooter,
@@ -690,15 +697,6 @@ sal_Bool XStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeExcep
return nullptr != pBase;
}
-uno::Type XStyleFamily::getElementType() throw( uno::RuntimeException, std::exception )
- { return cppu::UnoType<style::XStyle>::get(); }
-
-sal_Bool XStyleFamily::hasElements() throw( uno::RuntimeException, std::exception )
-{
- if(!m_pBasePool)
- throw uno::RuntimeException();
- return true;
-}
void XStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
@@ -788,12 +786,6 @@ void XStyleFamily::removeByName(const OUString& rName) throw( container::NoSuchE
m_pBasePool->Remove(pBase);
}
-uno::Reference<beans::XPropertySetInfo> SAL_CALL XStyleFamily::getPropertySetInfo( ) throw (uno::RuntimeException, std::exception)
- { return {}; }
-
-void SAL_CALL XStyleFamily::setPropertyValue( const OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
- { SAL_WARN("sw.uno", "###unexpected!"); }
-
uno::Any SAL_CALL XStyleFamily::getPropertyValue( const OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
{
if(sPropertyName != "DisplayName")
@@ -805,28 +797,6 @@ uno::Any SAL_CALL XStyleFamily::getPropertyValue( const OUString& sPropertyName
return uno::makeAny(SW_RESSTR(pEntry->m_nRedId));
}
-void SAL_CALL XStyleFamily::addPropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
- { SAL_WARN("sw.uno", "###unexpected!"); }
-
-void SAL_CALL XStyleFamily::removePropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
- { SAL_WARN("sw.uno", "###unexpected!"); }
-
-void SAL_CALL XStyleFamily::addVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
- { SAL_WARN("sw.uno", "###unexpected!"); }
-
-void SAL_CALL XStyleFamily::removeVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
- { SAL_WARN("sw.uno", "###unexpected!"); }
-
-void XStyleFamily::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
-{
- const SfxSimpleHint *pHint = dynamic_cast<const SfxSimpleHint*>( &rHint );
- if( pHint && ( pHint->GetId() & SFX_HINT_DYING ) )
- {
- m_pBasePool = nullptr;
- m_pDocShell = nullptr;
- EndListening(rBC);
- }
-}
SwXStyle* XStyleFamily::_FindStyle(const OUString& rStyleName) const
{
commit a8ce94f6283b8bf682ebf9095e8c34b9952eb85f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Sat Nov 28 03:32:29 2015 +0100
SwXStyleFamily=>sw::XStyleFamily
Change-Id: I334c4db5113902668d6967719c65ba403e9dde65
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index b2b2359..0d2deb7 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -49,7 +49,10 @@ class SwStyleProperties_Impl;
class SwAutoStylesEnumImpl;
class IStyleAccess;
class SfxItemSet;
-class SwXStyleFamily;
+namespace sw
+{
+ class XStyleFamily;
+};
typedef std::shared_ptr<SfxItemSet> SfxItemSet_Pointer_t;
class SwXStyleFamilies : public cppu::WeakImplHelper
@@ -109,7 +112,7 @@ class SwXStyle : public cppu::WeakImplHelper
public SfxListener,
public SwClient
{
- friend class SwXStyleFamily;
+ friend class sw::XStyleFamily;
SwDoc* m_pDoc;
OUString m_sStyleName;
SfxStyleSheetBasePool* m_pBasePool;
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index de07866..1202f04 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -113,62 +113,69 @@ namespace
{ SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING}
};
}
-class SwXStyleFamily : public cppu::WeakImplHelper
-<
- css::container::XNameContainer,
- css::lang::XServiceInfo,
- css::container::XIndexAccess,
- css::beans::XPropertySet
->,
- public SfxListener
-{
- SfxStyleFamily m_eFamily;
- SfxStyleSheetBasePool* m_pBasePool;
- SwDocShell* m_pDocShell;
-
- SwXStyle* _FindStyle(const OUString& rStyleName) const;
-public:
- SwXStyleFamily(SwDocShell* pDocShell, const SfxStyleFamily eFamily);
- virtual ~SwXStyleFamily();
-
- //XIndexAccess
- virtual sal_Int32 SAL_CALL getCount() throw( css::uno::RuntimeException, std::exception ) override;
- virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception ) override;
-
- //XElementAccess
- virtual css::uno::Type SAL_CALL SAL_CALL getElementType( ) throw(css::uno::RuntimeException, std::exception) override;
- virtual sal_Bool SAL_CALL SAL_CALL hasElements( ) throw(css::uno::RuntimeException, std::exception) override;
-
- //XNameAccess
- virtual css::uno::Any SAL_CALL getByName(const OUString& Name) throw( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() throw( css::uno::RuntimeException, std::exception ) override;
- virtual sal_Bool SAL_CALL hasByName(const OUString& Name) throw( css::uno::RuntimeException, std::exception ) override;
-
- //XNameContainer
- virtual void SAL_CALL insertByName(const OUString& Name, const css::uno::Any& Element) throw( css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception ) override;
- virtual void SAL_CALL replaceByName(const OUString& Name, const css::uno::Any& Element) throw( css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception ) override;
- virtual void SAL_CALL removeByName(const OUString& Name) throw( css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception ) override;
-
- //XPropertySet
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (css::uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
- virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
-
- //SfxListener
- virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
-
- //XServiceInfo
- 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;
-};
using namespace ::com::sun::star;
+namespace sw
+{
+ class XStyleFamily : public cppu::WeakImplHelper
+ <
+ container::XNameContainer,
+ lang::XServiceInfo,
+ container::XIndexAccess,
+ beans::XPropertySet
+ >,
+ public SfxListener
+ {
+ SfxStyleFamily m_eFamily;
+ SfxStyleSheetBasePool* m_pBasePool;
+ SwDocShell* m_pDocShell;
+
+ SwXStyle* _FindStyle(const OUString& rStyleName) const;
+ public:
+ XStyleFamily(SwDocShell* pDocShell, const SfxStyleFamily eFamily);
+ virtual ~XStyleFamily();
+
+ //XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw( uno::RuntimeException, std::exception ) override;
+ virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
+
+ //XElementAccess
+ virtual uno::Type SAL_CALL SAL_CALL getElementType( ) throw(uno::RuntimeException, std::exception) override;
+ virtual sal_Bool SAL_CALL SAL_CALL hasElements( ) throw(uno::RuntimeException, std::exception) override;
+
+ //XNameAccess
+ virtual uno::Any SAL_CALL getByName(const OUString& Name) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
+ virtual uno::Sequence< OUString > SAL_CALL getElementNames() throw( uno::RuntimeException, std::exception ) override;
+ virtual sal_Bool SAL_CALL hasByName(const OUString& Name) throw( uno::RuntimeException, std::exception ) override;
+
+ //XNameContainer
+ virtual void SAL_CALL insertByName(const OUString& Name, const uno::Any& Element) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
+ virtual void SAL_CALL replaceByName(const OUString& Name, const uno::Any& Element) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
+ virtual void SAL_CALL removeByName(const OUString& Name) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) override;
+
+ //XPropertySet
+ virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (uno::RuntimeException, std::exception) override;
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
+ virtual uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) override;
+
+ //SfxListener
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw( uno::RuntimeException, std::exception ) override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( uno::RuntimeException, std::exception ) override;
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( uno::RuntimeException, std::exception ) override;
+ };
+
+}
+using sw::XStyleFamily;
+
+
static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)
{
const auto pEntry = std::find_if(our_vStyleFamilyEntries.begin(), our_vStyleFamilyEntries.end(),
@@ -246,7 +253,7 @@ uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
assert(eFamily != SFX_STYLE_FAMILY_ALL);
auto& rxContainer = m_vContainers[eFamily];
if(!rxContainer.is())
- rxContainer = new SwXStyleFamily(m_pDocShell, eFamily);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list