Proper fix for multiply defined SfxEnumItem<sal_uInt16> with MSVC
With --disable-pch the original hack from
f091259ad2
"convert SfxEnumItem to type-safe
template class" doesn't happen to work: When linking sd, the occurrences of
SfxEnumItem<sal_uInt16> in sd/inc/sdattr.hxx clash with those from editeng
(where LanguageType is a typedef for sal_uInt16) and svl (as the respective
include files from editeng and svl happen to not be included). For whatever
reason, the explicit instantiation declaration without a __declspec(...) in
include/svl/eitem.hxx doesn't seem to make a difference (at least with MSVC 2015
Update 3).
Change-Id: I51b5943fe19a7184db9414192c6364f7c26b79eb
Reviewed-on: https://gerrit.libreoffice.org/34903
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -2345,7 +2345,7 @@ bool SvxEscapementItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
|
|||||||
// class SvxLanguageItem -------------------------------------------------
|
// class SvxLanguageItem -------------------------------------------------
|
||||||
|
|
||||||
SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const sal_uInt16 nId )
|
SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const sal_uInt16 nId )
|
||||||
: SfxEnumItem( nId , eLang )
|
: SvxLanguageItem_Base( nId , eLang )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,7 +32,15 @@ class SvXMLUnitConverter;
|
|||||||
This item describes a Language.
|
This item describes a Language.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class EDITENG_DLLPUBLIC SvxLanguageItem : public SfxEnumItem<LanguageType>
|
// MSVC hack:
|
||||||
|
class SvxLanguageItem_Base: public SfxEnumItem<LanguageType> {
|
||||||
|
protected:
|
||||||
|
explicit SvxLanguageItem_Base(sal_uInt16 nWhich, LanguageType nValue):
|
||||||
|
SfxEnumItem(nWhich, nValue)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
class EDITENG_DLLPUBLIC SvxLanguageItem : public SvxLanguageItem_Base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static SfxPoolItem* CreateDefault();
|
static SfxPoolItem* CreateDefault();
|
||||||
|
@@ -26,7 +26,19 @@
|
|||||||
|
|
||||||
class SfxAllEnumValueArr;
|
class SfxAllEnumValueArr;
|
||||||
|
|
||||||
class SVL_DLLPUBLIC SfxAllEnumItem: public SfxEnumItem<sal_uInt16>
|
// MSVC hack:
|
||||||
|
class SfxAllEnumItem_Base: public SfxEnumItem<sal_uInt16> {
|
||||||
|
protected:
|
||||||
|
explicit SfxAllEnumItem_Base(sal_uInt16 nWhich, sal_uInt16 nValue):
|
||||||
|
SfxEnumItem(nWhich, nValue)
|
||||||
|
{}
|
||||||
|
|
||||||
|
explicit SfxAllEnumItem_Base(sal_uInt16 const nWhich, SvStream & rStream):
|
||||||
|
SfxEnumItem(nWhich, rStream)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SVL_DLLPUBLIC SfxAllEnumItem: public SfxAllEnumItem_Base
|
||||||
{
|
{
|
||||||
SfxAllEnumValueArr* pValues;
|
SfxAllEnumValueArr* pValues;
|
||||||
std::vector<sal_uInt16>* pDisabledValues;
|
std::vector<sal_uInt16>* pDisabledValues;
|
||||||
|
@@ -82,14 +82,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// We need to have this one instantiated only once to prevent LNK2005 "already defined" on 32-bit MSVC.
|
|
||||||
// But then we run into the problem that "extern" and SVL_DLLPUBLIC are mutually exclusive on templates for MSVC.
|
|
||||||
#ifdef _WIN32
|
|
||||||
extern template class SfxEnumItem<sal_uInt16>;
|
|
||||||
#else
|
|
||||||
extern template class SVL_DLLPUBLIC SfxEnumItem<sal_uInt16>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class SVL_DLLPUBLIC SfxBoolItem
|
class SVL_DLLPUBLIC SfxBoolItem
|
||||||
: public SfxPoolItem
|
: public SfxPoolItem
|
||||||
{
|
{
|
||||||
|
@@ -35,14 +35,14 @@ class SfxAllEnumValueArr : public std::vector<SfxAllEnumValue_Impl> {};
|
|||||||
|
|
||||||
|
|
||||||
SfxAllEnumItem::SfxAllEnumItem() :
|
SfxAllEnumItem::SfxAllEnumItem() :
|
||||||
SfxEnumItem<sal_uInt16>(0, 0),
|
SfxAllEnumItem_Base(0, 0),
|
||||||
pValues( nullptr ),
|
pValues( nullptr ),
|
||||||
pDisabledValues( nullptr )
|
pDisabledValues( nullptr )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which, sal_uInt16 nVal):
|
SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which, sal_uInt16 nVal):
|
||||||
SfxEnumItem(which, nVal),
|
SfxAllEnumItem_Base(which, nVal),
|
||||||
pValues( nullptr ),
|
pValues( nullptr ),
|
||||||
pDisabledValues( nullptr )
|
pDisabledValues( nullptr )
|
||||||
{
|
{
|
||||||
@@ -50,7 +50,7 @@ SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which, sal_uInt16 nVal):
|
|||||||
}
|
}
|
||||||
|
|
||||||
SfxAllEnumItem::SfxAllEnumItem( sal_uInt16 which, SvStream &rStream ):
|
SfxAllEnumItem::SfxAllEnumItem( sal_uInt16 which, SvStream &rStream ):
|
||||||
SfxEnumItem(which, rStream),
|
SfxAllEnumItem_Base(which, rStream),
|
||||||
pValues( nullptr ),
|
pValues( nullptr ),
|
||||||
pDisabledValues( nullptr )
|
pDisabledValues( nullptr )
|
||||||
{
|
{
|
||||||
@@ -58,14 +58,14 @@ SfxAllEnumItem::SfxAllEnumItem( sal_uInt16 which, SvStream &rStream ):
|
|||||||
}
|
}
|
||||||
|
|
||||||
SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which):
|
SfxAllEnumItem::SfxAllEnumItem(sal_uInt16 which):
|
||||||
SfxEnumItem(which, 0),
|
SfxAllEnumItem_Base(which, 0),
|
||||||
pValues( nullptr ),
|
pValues( nullptr ),
|
||||||
pDisabledValues( nullptr )
|
pDisabledValues( nullptr )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
|
SfxAllEnumItem::SfxAllEnumItem(const SfxAllEnumItem &rCopy):
|
||||||
SfxEnumItem(rCopy),
|
SfxAllEnumItem_Base(rCopy),
|
||||||
pValues(nullptr),
|
pValues(nullptr),
|
||||||
pDisabledValues( nullptr )
|
pDisabledValues( nullptr )
|
||||||
{
|
{
|
||||||
|
@@ -101,9 +101,6 @@ bool SfxEnumItemInterface::GetBoolValue() const
|
|||||||
void SfxEnumItemInterface::SetBoolValue(bool)
|
void SfxEnumItemInterface::SetBoolValue(bool)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template class SfxEnumItem<sal_uInt16>;
|
|
||||||
|
|
||||||
SfxPoolItem* SfxBoolItem::CreateDefault()
|
SfxPoolItem* SfxBoolItem::CreateDefault()
|
||||||
{
|
{
|
||||||
return new SfxBoolItem();
|
return new SfxBoolItem();
|
||||||
|
Reference in New Issue
Block a user