[Libreoffice-commits] core.git: filter/source include/comphelper sfx2/source
Noel Grandin
noel at peralex.com
Fri Jul 31 02:55:50 PDT 2015
filter/source/config/cache/constant.hxx | 27 ------
filter/source/config/cache/filtercache.cxx | 108 +++++++++++++--------------
filter/source/config/cache/filtercache.hxx | 8 +-
filter/source/config/cache/typedetection.cxx | 6 -
include/comphelper/documentconstants.hxx | 9 +-
sfx2/source/bastyp/fltfnc.cxx | 1
6 files changed, 68 insertions(+), 91 deletions(-)
New commits:
commit dd4befa992300cc068467021c81594ffcea1be0c
Author: Noel Grandin <noel at peralex.com>
Date: Fri Jul 31 11:22:03 2015 +0200
fix crash in writer, thanks to my new assert in typed_flags_set
and clean up the duplication of constants between filter/ and
comphelper/ in the process
Change-Id: I0d1525b559c63a3d39deae51accff5dcdbb0aa82
Reviewed-on: https://gerrit.libreoffice.org/17446
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/filter/source/config/cache/constant.hxx b/filter/source/config/cache/constant.hxx
index 98327f0..c53a748 100644
--- a/filter/source/config/cache/constant.hxx
+++ b/filter/source/config/cache/constant.hxx
@@ -125,33 +125,6 @@
#define FLAGNAME_USESOPTIONS "USESOPTIONS"
#define FLAGNAME_COMBINED "COMBINED"
-/** @short values of filter flags, sorted based on value */
-#define FLAGVAL_IMPORT 0x00000001 // 1
-#define FLAGVAL_EXPORT 0x00000002 // 2
-#define FLAGVAL_TEMPLATE 0x00000004 // 4
-#define FLAGVAL_INTERNAL 0x00000008 // 8
-#define FLAGVAL_TEMPLATEPATH 0x00000010 // 16
-#define FLAGVAL_OWN 0x00000020 // 32
-#define FLAGVAL_ALIEN 0x00000040 // 64
-#define FLAGVAL_USESOPTIONS 0x00000080 // 128
-#define FLAGVAL_DEFAULT 0x00000100 // 256
-#define FLAGVAL_SUPPORTSSELECTION 0x00000400 // 1024
-#define FLAGVAL_NOTINFILEDIALOG 0x00001000 // 4096
-#define FLAGVAL_NOTINCHOOSER 0x00002000 // 8192
-#define FLAGVAL_ASYNCHRON 0x00004000 // 16384
-#define FLAGVAL_READONLY 0x00010000 // 65536
-#define FLAGVAL_NOTINSTALLED 0x00020000 // 131072
-#define FLAGVAL_CONSULTSERVICE 0x00040000 // 262144
-#define FLAGVAL_3RDPARTYFILTER 0x00080000 // 524288
-#define FLAGVAL_PACKED 0x00100000 // 1048576
-#define FLAGVAL_BROWSERPREFERRED 0x00400000 // 4194304
-#define FLAGVAL_COMBINED 0x00800000 // 8388608
-#define FLAGVAL_ENCRYPTION 0x01000000 // 16777216
-#define FLAGVAL_PASSWORDTOMODIFY 0x02000000 // 33554432
-#define FLAGVAL_PREFERRED 0x10000000 // 268435456
-#define FLAGVAL_STARTPRESENTATION 0x20000000 // 268435456
-#define FLAGVAL_ALL 0xffffffff // 4294967295
-
/** @short some uno service names.
*/
#define SERVICE_CONFIGURATIONUPDATEACCESS "com.sun.star.configuration.ConfigurationUpdateAccess"
diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx
index 0fb0173..8e44fc5 100644
--- a/filter/source/config/cache/filtercache.cxx
+++ b/filter/source/config/cache/filtercache.cxx
@@ -1177,7 +1177,7 @@ void FilterCache::impl_validateAndOptimize()
sal_Int32 nFlags = 0;
aPrefFilter[PROPNAME_FLAGS] >>= nFlags;
- if ((nFlags & FLAGVAL_IMPORT) != FLAGVAL_IMPORT)
+ if (!(static_cast<SfxFilterFlags>(nFlags) & SfxFilterFlags::IMPORT))
{
sLog.append("error\t:\t" "The preferred filter \"" + sPrefFilter + "\" of type \"" +
sType + "\" is not an IMPORT filter!\n");
@@ -1707,7 +1707,7 @@ CacheItem FilterCache::impl_loadItem(const css::uno::Reference< css::container::
// int representation ...
css::uno::Sequence< OUString > lFlagNames;
if (aValues[i] >>= lFlagNames)
- aItem[rPropName] <<= FilterCache::impl_convertFlagNames2FlagField(lFlagNames);
+ aItem[rPropName] <<= (sal_Int32) FilterCache::impl_convertFlagNames2FlagField(lFlagNames);
}
}
}
@@ -1881,7 +1881,7 @@ void FilterCache::impl_saveItem(const css::uno::Reference< css::container::XName
sal_Int32 nFlags = 0;
pIt->second >>= nFlags;
css::uno::Any aFlagNameList;
- aFlagNameList <<= FilterCache::impl_convertFlagField2FlagNames(nFlags);
+ aFlagNameList <<= FilterCache::impl_convertFlagField2FlagNames(static_cast<SfxFilterFlags>(nFlags));
xItem->replaceByName(PROPNAME_FLAGS, aFlagNameList);
}
@@ -1911,34 +1911,34 @@ void FilterCache::impl_saveItem(const css::uno::Reference< css::container::XName
/*-----------------------------------------------
static! => no locks necessary
-----------------------------------------------*/
-css::uno::Sequence< OUString > FilterCache::impl_convertFlagField2FlagNames(sal_Int32 nFlags)
+css::uno::Sequence< OUString > FilterCache::impl_convertFlagField2FlagNames(SfxFilterFlags nFlags)
{
OUStringList lFlagNames;
- if ((nFlags & FLAGVAL_3RDPARTYFILTER ) == FLAGVAL_3RDPARTYFILTER ) lFlagNames.push_back(FLAGNAME_3RDPARTYFILTER );
- if ((nFlags & FLAGVAL_ALIEN ) == FLAGVAL_ALIEN ) lFlagNames.push_back(FLAGNAME_ALIEN );
- if ((nFlags & FLAGVAL_ASYNCHRON ) == FLAGVAL_ASYNCHRON ) lFlagNames.push_back(FLAGNAME_ASYNCHRON );
- if ((nFlags & FLAGVAL_BROWSERPREFERRED ) == FLAGVAL_BROWSERPREFERRED ) lFlagNames.push_back(FLAGNAME_BROWSERPREFERRED );
- if ((nFlags & FLAGVAL_CONSULTSERVICE ) == FLAGVAL_CONSULTSERVICE ) lFlagNames.push_back(FLAGNAME_CONSULTSERVICE );
- if ((nFlags & FLAGVAL_DEFAULT ) == FLAGVAL_DEFAULT ) lFlagNames.push_back(FLAGNAME_DEFAULT );
- if ((nFlags & FLAGVAL_ENCRYPTION ) == FLAGVAL_ENCRYPTION ) lFlagNames.push_back(FLAGNAME_ENCRYPTION );
- if ((nFlags & FLAGVAL_EXPORT ) == FLAGVAL_EXPORT ) lFlagNames.push_back(FLAGNAME_EXPORT );
- if ((nFlags & FLAGVAL_IMPORT ) == FLAGVAL_IMPORT ) lFlagNames.push_back(FLAGNAME_IMPORT );
- if ((nFlags & FLAGVAL_INTERNAL ) == FLAGVAL_INTERNAL ) lFlagNames.push_back(FLAGNAME_INTERNAL );
- if ((nFlags & FLAGVAL_NOTINCHOOSER ) == FLAGVAL_NOTINCHOOSER ) lFlagNames.push_back(FLAGNAME_NOTINCHOOSER );
- if ((nFlags & FLAGVAL_NOTINFILEDIALOG ) == FLAGVAL_NOTINFILEDIALOG ) lFlagNames.push_back(FLAGNAME_NOTINFILEDIALOG );
- if ((nFlags & FLAGVAL_NOTINSTALLED ) == FLAGVAL_NOTINSTALLED ) lFlagNames.push_back(FLAGNAME_NOTINSTALLED );
- if ((nFlags & FLAGVAL_OWN ) == FLAGVAL_OWN ) lFlagNames.push_back(FLAGNAME_OWN );
- if ((nFlags & FLAGVAL_PACKED ) == FLAGVAL_PACKED ) lFlagNames.push_back(FLAGNAME_PACKED );
- if ((nFlags & FLAGVAL_PASSWORDTOMODIFY ) == FLAGVAL_PASSWORDTOMODIFY ) lFlagNames.push_back(FLAGNAME_PASSWORDTOMODIFY );
- if ((nFlags & FLAGVAL_PREFERRED ) == FLAGVAL_PREFERRED ) lFlagNames.push_back(FLAGNAME_PREFERRED );
- if ((nFlags & FLAGVAL_STARTPRESENTATION) == FLAGVAL_STARTPRESENTATION) lFlagNames.push_back(FLAGNAME_STARTPRESENTATION);
- if ((nFlags & FLAGVAL_READONLY ) == FLAGVAL_READONLY ) lFlagNames.push_back(FLAGNAME_READONLY );
- if ((nFlags & FLAGVAL_SUPPORTSSELECTION) == FLAGVAL_SUPPORTSSELECTION) lFlagNames.push_back(FLAGNAME_SUPPORTSSELECTION);
- if ((nFlags & FLAGVAL_TEMPLATE ) == FLAGVAL_TEMPLATE ) lFlagNames.push_back(FLAGNAME_TEMPLATE );
- if ((nFlags & FLAGVAL_TEMPLATEPATH ) == FLAGVAL_TEMPLATEPATH ) lFlagNames.push_back(FLAGNAME_TEMPLATEPATH );
- if ((nFlags & FLAGVAL_USESOPTIONS ) == FLAGVAL_USESOPTIONS ) lFlagNames.push_back(FLAGNAME_USESOPTIONS );
- if ((nFlags & FLAGVAL_COMBINED ) == FLAGVAL_COMBINED ) lFlagNames.push_back(FLAGNAME_COMBINED );
+ if (nFlags & SfxFilterFlags::STARONEFILTER ) lFlagNames.push_back(FLAGNAME_3RDPARTYFILTER );
+ if (nFlags & SfxFilterFlags::ALIEN ) lFlagNames.push_back(FLAGNAME_ALIEN );
+ if (nFlags & SfxFilterFlags::ASYNCHRON ) lFlagNames.push_back(FLAGNAME_ASYNCHRON );
+ if (nFlags & SfxFilterFlags::BROWSERPREFERRED ) lFlagNames.push_back(FLAGNAME_BROWSERPREFERRED );
+ if (nFlags & SfxFilterFlags::CONSULTSERVICE ) lFlagNames.push_back(FLAGNAME_CONSULTSERVICE );
+ if (nFlags & SfxFilterFlags::DEFAULT ) lFlagNames.push_back(FLAGNAME_DEFAULT );
+ if (nFlags & SfxFilterFlags::ENCRYPTION ) lFlagNames.push_back(FLAGNAME_ENCRYPTION );
+ if (nFlags & SfxFilterFlags::EXPORT ) lFlagNames.push_back(FLAGNAME_EXPORT );
+ if (nFlags & SfxFilterFlags::IMPORT ) lFlagNames.push_back(FLAGNAME_IMPORT );
+ if (nFlags & SfxFilterFlags::INTERNAL ) lFlagNames.push_back(FLAGNAME_INTERNAL );
+ if (nFlags & SfxFilterFlags::NOTINCHOOSER ) lFlagNames.push_back(FLAGNAME_NOTINCHOOSER );
+ if (nFlags & SfxFilterFlags::NOTINFILEDLG ) lFlagNames.push_back(FLAGNAME_NOTINFILEDIALOG );
+ if (nFlags & SfxFilterFlags::MUSTINSTALL ) lFlagNames.push_back(FLAGNAME_NOTINSTALLED );
+ if (nFlags & SfxFilterFlags::OWN ) lFlagNames.push_back(FLAGNAME_OWN );
+ if (nFlags & SfxFilterFlags::PACKED ) lFlagNames.push_back(FLAGNAME_PACKED );
+ if (nFlags & SfxFilterFlags::PASSWORDTOMODIFY ) lFlagNames.push_back(FLAGNAME_PASSWORDTOMODIFY );
+ if (nFlags & SfxFilterFlags::PREFERED ) lFlagNames.push_back(FLAGNAME_PREFERRED );
+ if (nFlags & SfxFilterFlags::STARTPRESENTATION) lFlagNames.push_back(FLAGNAME_STARTPRESENTATION);
+ if (nFlags & SfxFilterFlags::OPENREADONLY ) lFlagNames.push_back(FLAGNAME_READONLY );
+ if (nFlags & SfxFilterFlags::SUPPORTSSELECTION) lFlagNames.push_back(FLAGNAME_SUPPORTSSELECTION);
+ if (nFlags & SfxFilterFlags::TEMPLATE ) lFlagNames.push_back(FLAGNAME_TEMPLATE );
+ if (nFlags & SfxFilterFlags::TEMPLATEPATH ) lFlagNames.push_back(FLAGNAME_TEMPLATEPATH );
+ if (nFlags & SfxFilterFlags::USESOPTIONS ) lFlagNames.push_back(FLAGNAME_USESOPTIONS );
+ if (nFlags & SfxFilterFlags::COMBINED ) lFlagNames.push_back(FLAGNAME_COMBINED );
return comphelper::containerToSequence(lFlagNames);
}
@@ -1946,9 +1946,9 @@ css::uno::Sequence< OUString > FilterCache::impl_convertFlagField2FlagNames(sal_
/*-----------------------------------------------
static! => no locks necessary
-----------------------------------------------*/
-sal_Int32 FilterCache::impl_convertFlagNames2FlagField(const css::uno::Sequence< OUString >& lNames)
+SfxFilterFlags FilterCache::impl_convertFlagNames2FlagField(const css::uno::Sequence< OUString >& lNames)
{
- sal_Int32 nField = 0;
+ SfxFilterFlags nField = SfxFilterFlags::NONE;
const OUString* pNames = lNames.getConstArray();
sal_Int32 c = lNames.getLength();
@@ -1956,122 +1956,122 @@ sal_Int32 FilterCache::impl_convertFlagNames2FlagField(const css::uno::Sequence<
{
if (pNames[i] == FLAGNAME_3RDPARTYFILTER)
{
- nField |= FLAGVAL_3RDPARTYFILTER;
+ nField |= SfxFilterFlags::STARONEFILTER;
continue;
}
if (pNames[i] == FLAGNAME_ALIEN)
{
- nField |= FLAGVAL_ALIEN;
+ nField |= SfxFilterFlags::ALIEN;
continue;
}
if (pNames[i] == FLAGNAME_ASYNCHRON)
{
- nField |= FLAGVAL_ASYNCHRON;
+ nField |= SfxFilterFlags::ASYNCHRON;
continue;
}
if (pNames[i] == FLAGNAME_BROWSERPREFERRED)
{
- nField |= FLAGVAL_BROWSERPREFERRED;
+ nField |= SfxFilterFlags::BROWSERPREFERRED;
continue;
}
if (pNames[i] == FLAGNAME_CONSULTSERVICE)
{
- nField |= FLAGVAL_CONSULTSERVICE;
+ nField |= SfxFilterFlags::CONSULTSERVICE;
continue;
}
if (pNames[i] == FLAGNAME_DEFAULT)
{
- nField |= FLAGVAL_DEFAULT;
+ nField |= SfxFilterFlags::DEFAULT;
continue;
}
if (pNames[i] == FLAGNAME_ENCRYPTION)
{
- nField |= FLAGVAL_ENCRYPTION;
+ nField |= SfxFilterFlags::ENCRYPTION;
continue;
}
if (pNames[i] == FLAGNAME_EXPORT)
{
- nField |= FLAGVAL_EXPORT;
+ nField |= SfxFilterFlags::EXPORT;
continue;
}
if (pNames[i] == FLAGNAME_IMPORT)
{
- nField |= FLAGVAL_IMPORT;
+ nField |= SfxFilterFlags::IMPORT;
continue;
}
if (pNames[i] == FLAGNAME_INTERNAL)
{
- nField |= FLAGVAL_INTERNAL;
+ nField |= SfxFilterFlags::INTERNAL;
continue;
}
if (pNames[i] == FLAGNAME_NOTINCHOOSER)
{
- nField |= FLAGVAL_NOTINCHOOSER;
+ nField |= SfxFilterFlags::NOTINCHOOSER;
continue;
}
if (pNames[i] == FLAGNAME_NOTINFILEDIALOG)
{
- nField |= FLAGVAL_NOTINFILEDIALOG;
+ nField |= SfxFilterFlags::NOTINFILEDLG;
continue;
}
if (pNames[i] == FLAGNAME_NOTINSTALLED)
{
- nField |= FLAGVAL_NOTINSTALLED;
+ nField |= SfxFilterFlags::MUSTINSTALL;
continue;
}
if (pNames[i] == FLAGNAME_OWN)
{
- nField |= FLAGVAL_OWN;
+ nField |= SfxFilterFlags::OWN;
continue;
}
if (pNames[i] == FLAGNAME_PACKED)
{
- nField |= FLAGVAL_PACKED;
+ nField |= SfxFilterFlags::PACKED;
continue;
}
if (pNames[i] == FLAGNAME_PASSWORDTOMODIFY)
{
- nField |= FLAGVAL_PASSWORDTOMODIFY;
+ nField |= SfxFilterFlags::PASSWORDTOMODIFY;
continue;
}
if (pNames[i] == FLAGNAME_PREFERRED)
{
- nField |= FLAGVAL_PREFERRED;
+ nField |= SfxFilterFlags::PREFERED;
continue;
}
if (pNames[i] == FLAGNAME_STARTPRESENTATION)
{
- nField |= FLAGVAL_STARTPRESENTATION;
+ nField |= SfxFilterFlags::STARTPRESENTATION;
continue;
}
if (pNames[i] == FLAGNAME_READONLY)
{
- nField |= FLAGVAL_READONLY;
+ nField |= SfxFilterFlags::OPENREADONLY;
continue;
}
if (pNames[i] == FLAGNAME_SUPPORTSSELECTION)
{
- nField |= FLAGVAL_SUPPORTSSELECTION;
+ nField |= SfxFilterFlags::SUPPORTSSELECTION;
continue;
}
if (pNames[i] == FLAGNAME_TEMPLATE)
{
- nField |= FLAGVAL_TEMPLATE;
+ nField |= SfxFilterFlags::TEMPLATE;
continue;
}
if (pNames[i] == FLAGNAME_TEMPLATEPATH)
{
- nField |= FLAGVAL_TEMPLATEPATH;
+ nField |= SfxFilterFlags::TEMPLATEPATH;
continue;
}
if (pNames[i] == FLAGNAME_USESOPTIONS)
{
- nField |= FLAGVAL_USESOPTIONS;
+ nField |= SfxFilterFlags::USESOPTIONS;
continue;
}
if (pNames[i] == FLAGNAME_COMBINED)
{
- nField |= FLAGVAL_COMBINED;
+ nField |= SfxFilterFlags::COMBINED;
continue;
}
}
diff --git a/filter/source/config/cache/filtercache.hxx b/filter/source/config/cache/filtercache.hxx
index 2c6b652..7570afb 100644
--- a/filter/source/config/cache/filtercache.hxx
+++ b/filter/source/config/cache/filtercache.hxx
@@ -30,6 +30,7 @@
#include <com/sun/star/util/ChangesEvent.hpp>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Any.h>
+#include <comphelper/documentconstants.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
@@ -959,10 +960,9 @@ class FilterCache : public BaseLock
@param lNames
the list of flag names.
- @return [sal_Int32]
- the converted flag field.
+ @return the converted flag field.
*/
- static sal_Int32 impl_convertFlagNames2FlagField(const css::uno::Sequence< OUString >& lNames);
+ static SfxFilterFlags impl_convertFlagNames2FlagField(const css::uno::Sequence< OUString >& lNames);
@@ -974,7 +974,7 @@ class FilterCache : public BaseLock
@return [seq< string >]
the converted flag name list.
*/
- static css::uno::Sequence< OUString > impl_convertFlagField2FlagNames(sal_Int32 nFlags);
+ static css::uno::Sequence< OUString > impl_convertFlagField2FlagNames(SfxFilterFlags nFlags);
};
} // namespace config
diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx
index ffeab2a..af80416 100644
--- a/filter/source/config/cache/typedetection.cxx
+++ b/filter/source/config/cache/typedetection.cxx
@@ -518,9 +518,9 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes
sal_Int32 nFlags = 0;
aFilter[PROPNAME_FLAGS] >>= nFlags;
- if ((nFlags & FLAGVAL_IMPORT) == FLAGVAL_IMPORT)
+ if (static_cast<SfxFilterFlags>(nFlags) & SfxFilterFlags::IMPORT)
sFilter = *pIt;
- if ((nFlags & FLAGVAL_PREFERRED) == FLAGVAL_PREFERRED)
+ if (static_cast<SfxFilterFlags>(nFlags) & SfxFilterFlags::PREFERED)
break;
}
catch(const css::uno::Exception&) {}
@@ -603,7 +603,7 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes
sal_Int32 nFlags = 0;
aFilter[PROPNAME_FLAGS] >>= nFlags;
- if ((nFlags & FLAGVAL_IMPORT) == FLAGVAL_IMPORT)
+ if (static_cast<SfxFilterFlags>(nFlags) & SfxFilterFlags::IMPORT)
break;
}
catch(const css::uno::Exception&)
diff --git a/include/comphelper/documentconstants.hxx b/include/comphelper/documentconstants.hxx
index d747a9e..9dbbc76 100644
--- a/include/comphelper/documentconstants.hxx
+++ b/include/comphelper/documentconstants.hxx
@@ -113,25 +113,28 @@ enum class SfxFilterFlags
EXECUTABLE = 0x00000200L,
SUPPORTSSELECTION = 0x00000400L,
NOTINFILEDLG = 0x00001000L,
+ NOTINCHOOSER = 0x00002000L,
+ ASYNCHRON = 0x00004000L,
OPENREADONLY = 0x00010000L,
MUSTINSTALL = 0x00020000L,
CONSULTSERVICE = 0x00040000L,
-
STARONEFILTER = 0x00080000L,
+
PACKED = 0x00100000L,
+ BROWSERPREFERRED = 0x00400000L,
+ COMBINED = 0x00800000L,
ENCRYPTION = 0x01000000L,
PASSWORDTOMODIFY = 0x02000000L,
PREFERED = 0x10000000L,
-
STARTPRESENTATION = 0x20000000L,
NONE = 0
};
namespace o3tl
{
- template<> struct typed_flags<SfxFilterFlags> : is_typed_flags<SfxFilterFlags, 0x331f17ffL> {};
+ template<> struct typed_flags<SfxFilterFlags> : is_typed_flags<SfxFilterFlags, 0x33df77ffL> {};
}
#define SFX_FILTER_NOTINSTALLED (SfxFilterFlags::MUSTINSTALL | SfxFilterFlags::CONSULTSERVICE)
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx
index 48bf28d..d00e5f7 100644
--- a/sfx2/source/bastyp/fltfnc.cxx
+++ b/sfx2/source/bastyp/fltfnc.cxx
@@ -1000,6 +1000,7 @@ void SfxFilterContainer::ReadSingleFilter_Impl(
{
sal_Int32 nTmp(0);
lFilterProperties[nFilterProperty].Value >>= nTmp;
+ assert((nTmp & ~o3tl::typed_flags<SfxFilterFlags>::mask) == 0);
nFlags = static_cast<SfxFilterFlags>(nTmp);
}
else if ( lFilterProperties[nFilterProperty].Name == "UIName" )
More information about the Libreoffice-commits
mailing list