summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-05-03 15:26:01 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-05-03 15:26:01 +0200
commit0b1e4a306705d8c25db6e233244101ba6c4c16b6 (patch)
treee3ce34a2d884bb5469aa0e15e8d66b6aa08a876e /unotools
parentab3d2e568fe1595584c66c2ff07843e72f608944 (diff)
Prevent Any::setValue from reinterpreting bool* as sal_Bool*
...which only happens ot work in environments where sizeof (bool) == 1. The simpler alternative is to use the operator <<= template without passing explicit UNO type information, anyway. The std::nullptr_t overloads are needed to disambiguate calls with a nullptr argument. (Which can at least be meaningful for VOID, but for other types what it happens to do is store a default value of the given type.) As std::nullptr_t is only C++11, this all needs to be LIBO_INTERNAL_ONLY. Change-Id: Iff06a6ba94250bd4ae4afc937c2a2bfa75f0888f
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/fltrcfg.cxx14
-rw-r--r--unotools/source/config/lingucfg.cxx41
-rw-r--r--unotools/source/config/misccfg.cxx7
-rw-r--r--unotools/source/config/saveopt.cxx5
4 files changed, 27 insertions, 40 deletions
diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx
index 93127a2005ef..ad19c6b3d856 100644
--- a/unotools/source/config/fltrcfg.cxx
+++ b/unotools/source/config/fltrcfg.cxx
@@ -93,18 +93,8 @@ SvtAppFilterOptions_Impl::~SvtAppFilterOptions_Impl()
void SvtAppFilterOptions_Impl::ImplCommit()
{
- Sequence<OUString> aNames(2);
- OUString* pNames = aNames.getArray();
- pNames[0] = "Load";
- pNames[1] = "Save";
- Sequence<Any> aValues(aNames.getLength());
- Any* pValues = aValues.getArray();
-
- const Type& rType = cppu::UnoType<bool>::get();
- pValues[0].setValue(&bLoadVBA, rType);
- pValues[1].setValue(&bSaveVBA, rType);
-
- PutProperties(aNames, aValues);
+ PutProperties(
+ {"Load", "Save"}, {css::uno::Any(bLoadVBA), css::uno::Any(bSaveVBA)});
}
void SvtAppFilterOptions_Impl::Notify( const Sequence< OUString >& )
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index cab762af4d91..03b2275cc2be 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -671,7 +671,6 @@ bool SvtLinguConfigItem::SaveOptions( const uno::Sequence< OUString > &rProperyN
osl::MutexGuard aGuard(theSvtLinguConfigItemMutex::get());
bool bRet = false;
- const uno::Type &rBOOL = cppu::UnoType<bool>::get();
const uno::Type &rINT16 = cppu::UnoType<sal_Int16>::get();
const uno::Type &rINT32 = cppu::UnoType<sal_Int32>::get();
@@ -686,41 +685,41 @@ bool SvtLinguConfigItem::SaveOptions( const uno::Sequence< OUString > &rProperyN
OUString aTmp( lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage ) );
*pValue++ = uno::makeAny( aTmp ); // 0
*pValue++ = uno::makeAny( rOpt.aActiveDics ); // 1
- pValue++->setValue( &rOpt.bIsUseDictionaryList, rBOOL ); // 2
- pValue++->setValue( &rOpt.bIsIgnoreControlCharacters, rBOOL ); // 3
+ *pValue++ <<= rOpt.bIsUseDictionaryList; // 2
+ *pValue++ <<= rOpt.bIsIgnoreControlCharacters; // 3
aTmp = lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage_CJK );
*pValue++ = uno::makeAny( aTmp ); // 5
aTmp = lcl_LanguageToCfgLocaleStr( rOpt.nDefaultLanguage_CTL );
*pValue++ = uno::makeAny( aTmp ); // 6
- pValue++->setValue( &rOpt.bIsSpellUpperCase, rBOOL ); // 7
- pValue++->setValue( &rOpt.bIsSpellWithDigits, rBOOL ); // 8
- pValue++->setValue( &rOpt.bIsSpellCapitalization, rBOOL ); // 9
- pValue++->setValue( &rOpt.bIsSpellAuto, rBOOL ); // 10
- pValue++->setValue( &rOpt.bIsSpellSpecial, rBOOL ); // 11
- pValue++->setValue( &rOpt.bIsSpellReverse, rBOOL ); // 14
+ *pValue++ <<= rOpt.bIsSpellUpperCase; // 7
+ *pValue++ <<= rOpt.bIsSpellWithDigits; // 8
+ *pValue++ <<= rOpt.bIsSpellCapitalization; // 9
+ *pValue++ <<= rOpt.bIsSpellAuto; // 10
+ *pValue++ <<= rOpt.bIsSpellSpecial; // 11
+ *pValue++ <<= rOpt.bIsSpellReverse; // 14
pValue++->setValue( &rOpt.nHyphMinLeading, rINT16 ); // 15
pValue++->setValue( &rOpt.nHyphMinTrailing, rINT16 ); // 16
pValue++->setValue( &rOpt.nHyphMinWordLength, rINT16 ); // 17
- pValue++->setValue( &rOpt.bIsHyphSpecial, rBOOL ); // 18
- pValue++->setValue( &rOpt.bIsHyphAuto, rBOOL ); // 19
+ *pValue++ <<= rOpt.bIsHyphSpecial; // 18
+ *pValue++ <<= rOpt.bIsHyphAuto; // 19
*pValue++ = uno::makeAny( rOpt.aActiveConvDics ); // 20
- pValue++->setValue( &rOpt.bIsIgnorePostPositionalWord, rBOOL ); // 21
- pValue++->setValue( &rOpt.bIsAutoCloseDialog, rBOOL ); // 22
- pValue++->setValue( &rOpt.bIsShowEntriesRecentlyUsedFirst, rBOOL ); // 23
- pValue++->setValue( &rOpt.bIsAutoReplaceUniqueEntries, rBOOL ); // 24
+ *pValue++ <<= rOpt.bIsIgnorePostPositionalWord; // 21
+ *pValue++ <<= rOpt.bIsAutoCloseDialog; // 22
+ *pValue++ <<= rOpt.bIsShowEntriesRecentlyUsedFirst; // 23
+ *pValue++ <<= rOpt.bIsAutoReplaceUniqueEntries; // 24
- pValue++->setValue( &rOpt.bIsDirectionToSimplified, rBOOL ); // 25
- pValue++->setValue( &rOpt.bIsUseCharacterVariants, rBOOL ); // 26
- pValue++->setValue( &rOpt.bIsTranslateCommonTerms, rBOOL ); // 27
- pValue++->setValue( &rOpt.bIsReverseMapping, rBOOL ); // 28
+ *pValue++ <<= rOpt.bIsDirectionToSimplified; // 25
+ *pValue++ <<= rOpt.bIsUseCharacterVariants; // 26
+ *pValue++ <<= rOpt.bIsTranslateCommonTerms; // 27
+ *pValue++ <<= rOpt.bIsReverseMapping; // 28
pValue++->setValue( &rOpt.nDataFilesChangedCheckValue, rINT32 ); // 29
- pValue++->setValue( &rOpt.bIsGrammarAuto, rBOOL ); // 30
- pValue++->setValue( &rOpt.bIsGrammarInteractive, rBOOL ); // 31
+ *pValue++ <<= rOpt.bIsGrammarAuto; // 30
+ *pValue++ <<= rOpt.bIsGrammarInteractive; // 31
bRet |= PutProperties( rProperyNames, aValues );
}
diff --git a/unotools/source/config/misccfg.cxx b/unotools/source/config/misccfg.cxx
index c32a90cb565d..e2ef188fdea3 100644
--- a/unotools/source/config/misccfg.cxx
+++ b/unotools/source/config/misccfg.cxx
@@ -161,14 +161,13 @@ void SfxMiscCfg::ImplCommit()
Sequence<Any> aValues(rNames.getLength());
Any* pValues = aValues.getArray();
- const Type& rType = cppu::UnoType<bool>::get();
for(int nProp = 0; nProp < rNames.getLength(); nProp++)
{
switch(nProp)
{
- case 0: pValues[nProp].setValue(&bPaperSize, rType);break; //"Print/Warning/PaperSize",
- case 1: pValues[nProp].setValue(&bPaperOrientation, rType);break; //"Print/Warning/PaperOrientation",
- case 2: pValues[nProp].setValue(&bNotFound, rType);break; //"Print/Warning/NotFound",
+ case 0: pValues[nProp] <<= bPaperSize;break; //"Print/Warning/PaperSize",
+ case 1: pValues[nProp] <<= bPaperOrientation;break; //"Print/Warning/PaperOrientation",
+ case 2: pValues[nProp] <<= bNotFound;break; //"Print/Warning/NotFound",
case 3: pValues[nProp] <<= nYear2000;break; //"DateFormat/TwoDigitYear",
}
}
diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx
index 84b0e979c9c7..9a340748989c 100644
--- a/unotools/source/config/saveopt.cxx
+++ b/unotools/source/config/saveopt.cxx
@@ -799,9 +799,8 @@ SvtLoadOptions_Impl::~SvtLoadOptions_Impl()
void SvtLoadOptions_Impl::ImplCommit()
{
- Sequence< OUString > aNames { cUserDefinedSettings };
- Sequence< Any > aValues { Any(bLoadUserDefinedSettings) };
- PutProperties( aNames, aValues );
+ PutProperties(
+ {cUserDefinedSettings}, {css::uno::Any(bLoadUserDefinedSettings)});
}
void SvtLoadOptions_Impl::Notify( const Sequence<OUString>& )