[Libreoffice-commits] core.git: include/xmloff sc/source xmloff/source
Mohammed Abdul Azeem
azeemmysore at gmail.com
Mon Jul 10 18:05:40 UTC 2017
include/xmloff/xmltoken.hxx | 5 +++++
sc/source/filter/xml/XMLCalculationSettingsContext.cxx | 12 ++++++------
sc/source/filter/xml/XMLConsolidationContext.cxx | 2 +-
sc/source/filter/xml/datastreamimport.cxx | 4 ++--
sc/source/filter/xml/xmlbodyi.cxx | 2 +-
sc/source/filter/xml/xmlcelli.cxx | 4 ++--
sc/source/filter/xml/xmldrani.cxx | 14 +++++++-------
sc/source/filter/xml/xmlexternaltabi.cxx | 2 +-
sc/source/filter/xml/xmlrowi.cxx | 2 +-
sc/source/filter/xml/xmltabi.cxx | 4 ++--
xmloff/source/core/xmltoken.cxx | 11 +++++++++++
11 files changed, 39 insertions(+), 23 deletions(-)
New commits:
commit 5364990831a7d5773ddbc2f35842c7b3a8d5534a
Author: Mohammed Abdul Azeem <azeemmysore at gmail.com>
Date: Sun Jul 9 22:37:00 2017 +0530
Adding an overloaded IsXMLToken method:
Passing FastAttributeIter to the method makes the
code much cleaner and easy to read.
Change-Id: I227e9dc378dfba51168c29452667576a779dc215
Reviewed-on: https://gerrit.libreoffice.org/39730
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index d746ae78c5d0..976ffeea583f 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -24,6 +24,7 @@
#include <xmloff/dllapi.h>
#include <sal/types.h>
#include <rtl/ustring.hxx>
+#include <sax/fastattribs.hxx>
/**
* Handling of tokens in XML:
@@ -3302,6 +3303,10 @@ namespace xmloff { namespace token {
XMLOFF_DLLPUBLIC bool IsXMLToken(
const char* pCString,
enum XMLTokenEnum eToken );
+
+ XMLOFF_DLLPUBLIC bool IsXMLToken(
+ const sax_fastparser::FastAttributeList::FastAttributeIter& aIter,
+ enum XMLTokenEnum eToken );
} }
#endif
diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
index f39ccebe5eb6..e885d737de33 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
@@ -58,19 +58,19 @@ ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& r
switch( aIter.getToken() )
{
case XML_ELEMENT( TABLE, XML_CASE_SENSITIVE ):
- if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
+ if( IsXMLToken( aIter, XML_FALSE ) )
bIgnoreCase = true;
break;
case XML_ELEMENT( TABLE, XML_PRECISION_AS_SHOWN ):
- if( IsXMLToken( aIter.toCString(), XML_TRUE ) )
+ if( IsXMLToken( aIter, XML_TRUE ) )
bCalcAsShown = true;
break;
case XML_ELEMENT( TABLE, XML_SEARCH_CRITERIA_MUST_APPLY_TO_WHOLE_CELL ):
- if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
+ if( IsXMLToken( aIter, XML_FALSE ) )
bMatchWholeCell = false;
break;
case XML_ELEMENT( TABLE, XML_AUTOMATIC_FIND_LABELS ):
- if( IsXMLToken( aIter.toCString(), XML_FALSE ) )
+ if( IsXMLToken( aIter, XML_FALSE ) )
bLookUpLabels = false;
break;
case XML_ELEMENT( TABLE, XML_NULL_YEAR ):
@@ -80,11 +80,11 @@ ScXMLCalculationSettingsContext::ScXMLCalculationSettingsContext( ScXMLImport& r
break;
case XML_ELEMENT( TABLE, XML_USE_REGULAR_EXPRESSIONS ):
// Overwrite only the default (regex true) value, not wildcard.
- if( eSearchType == utl::SearchParam::SearchType::Regexp && IsXMLToken( aIter.toCString(), XML_FALSE ) )
+ if( eSearchType == utl::SearchParam::SearchType::Regexp && IsXMLToken( aIter, XML_FALSE ) )
eSearchType = utl::SearchParam::SearchType::Normal;
break;
case XML_ELEMENT( TABLE, XML_USE_WILDCARDS ):
- if( IsXMLToken( aIter.toCString(), XML_TRUE ) )
+ if( IsXMLToken( aIter, XML_TRUE ) )
eSearchType = utl::SearchParam::SearchType::Wildcard;
break;
}
diff --git a/sc/source/filter/xml/XMLConsolidationContext.cxx b/sc/source/filter/xml/XMLConsolidationContext.cxx
index 8e27b573de7b..092f561cec99 100644
--- a/sc/source/filter/xml/XMLConsolidationContext.cxx
+++ b/sc/source/filter/xml/XMLConsolidationContext.cxx
@@ -65,7 +65,7 @@ ScXMLConsolidationContext::ScXMLConsolidationContext(
sUseLabel = aIter.toString();
break;
case XML_ELEMENT( TABLE, XML_LINK_TO_SOURCE_DATA ):
- bLinkToSource = IsXMLToken( aIter.toCString(), XML_TRUE );
+ bLinkToSource = IsXMLToken( aIter, XML_TRUE );
break;
}
}
diff --git a/sc/source/filter/xml/datastreamimport.cxx b/sc/source/filter/xml/datastreamimport.cxx
index 5e19c5215c15..4b61ae9398e5 100644
--- a/sc/source/filter/xml/datastreamimport.cxx
+++ b/sc/source/filter/xml/datastreamimport.cxx
@@ -49,10 +49,10 @@ ScXMLDataStreamContext::ScXMLDataStreamContext(
}
break;
case XML_ELEMENT( CALC_EXT, XML_EMPTY_LINE_REFRESH ):
- mbRefreshOnEmpty = IsXMLToken( aIter.toCString(), XML_TRUE );
+ mbRefreshOnEmpty = IsXMLToken( aIter, XML_TRUE );
break;
case XML_ELEMENT( CALC_EXT, XML_INSERTION_POSITION ):
- meInsertPos = IsXMLToken( aIter.toCString(), XML_TOP ) ?
+ meInsertPos = IsXMLToken( aIter, XML_TOP ) ?
sc::ImportPostProcessData::DataStream::InsertTop :
sc::ImportPostProcessData::DataStream::InsertBottom;
break;
diff --git a/sc/source/filter/xml/xmlbodyi.cxx b/sc/source/filter/xml/xmlbodyi.cxx
index e6f7bdfa8e7b..b8ad60262c87 100644
--- a/sc/source/filter/xml/xmlbodyi.cxx
+++ b/sc/source/filter/xml/xmlbodyi.cxx
@@ -102,7 +102,7 @@ ScXMLBodyContext::ScXMLBodyContext( ScXMLImport& rImport,
{
const sal_Int32 nLocalToken = nToken & TOKEN_MASK;
if( nLocalToken == XML_STRUCTURE_PROTECTED )
- bProtected = IsXMLToken( it.toCString(), XML_TRUE );
+ bProtected = IsXMLToken( it, XML_TRUE );
else if ( nLocalToken == XML_PROTECTION_KEY )
sPassword = it.toString();
else if ( nLocalToken == XML_PROTECTION_KEY_DIGEST_ALGORITHM )
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index da912fa76523..36e174804372 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -254,9 +254,9 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
{
if (!it.isEmpty())
{
- if ( IsXMLToken( it.toCString(), XML_TRUE ) )
+ if ( IsXMLToken( it, XML_TRUE ) )
fValue = 1.0;
- else if ( IsXMLToken( it.toCString(), XML_FALSE ) )
+ else if ( IsXMLToken( it, XML_FALSE ) )
fValue = 0.0;
else
::sax::Converter::convertDouble(fValue, it.toString() );
diff --git a/sc/source/filter/xml/xmldrani.cxx b/sc/source/filter/xml/xmldrani.cxx
index f75322824351..2e3dbb2147e7 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -133,39 +133,39 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( ScXMLImport& rImport,
break;
case XML_ELEMENT( TABLE, XML_IS_SELECTION ):
{
- bIsSelection = IsXMLToken( aIter.toCString(), XML_TRUE );
+ bIsSelection = IsXMLToken( aIter, XML_TRUE );
}
break;
case XML_ELEMENT( TABLE, XML_ON_UPDATE_KEEP_STYLES ):
{
- bKeepFormats = IsXMLToken( aIter.toCString(), XML_TRUE );
+ bKeepFormats = IsXMLToken( aIter, XML_TRUE );
}
break;
case XML_ELEMENT( TABLE, XML_ON_UPDATE_KEEP_SIZE ):
{
- bMoveCells = !IsXMLToken( aIter.toCString(), XML_TRUE );
+ bMoveCells = !IsXMLToken( aIter, XML_TRUE );
}
break;
case XML_ELEMENT( TABLE, XML_HAS_PERSISTENT_DATA ):
{
- bStripData = !IsXMLToken( aIter.toCString(), XML_TRUE );
+ bStripData = !IsXMLToken( aIter, XML_TRUE );
}
break;
case XML_ELEMENT( TABLE, XML_ORIENTATION ):
{
- bByRow = !IsXMLToken( aIter.toCString(), XML_COLUMN );
+ bByRow = !IsXMLToken( aIter, XML_COLUMN );
mpQueryParam->bByRow = bByRow;
}
break;
case XML_ELEMENT( TABLE, XML_CONTAINS_HEADER ):
{
- bHasHeader = IsXMLToken( aIter.toCString(), XML_TRUE );
+ bHasHeader = IsXMLToken( aIter, XML_TRUE );
mpQueryParam->bHasHeader = bHasHeader;
}
break;
case XML_ELEMENT( TABLE, XML_DISPLAY_FILTER_BUTTONS ):
{
- bAutoFilter = IsXMLToken( aIter.toCString(), XML_TRUE );
+ bAutoFilter = IsXMLToken( aIter, XML_TRUE );
}
break;
case XML_ELEMENT( TABLE, XML_TARGET_RANGE_ADDRESS ):
diff --git a/sc/source/filter/xml/xmlexternaltabi.cxx b/sc/source/filter/xml/xmlexternaltabi.cxx
index e6edaa66461b..9ce7d4e57121 100644
--- a/sc/source/filter/xml/xmlexternaltabi.cxx
+++ b/sc/source/filter/xml/xmlexternaltabi.cxx
@@ -315,7 +315,7 @@ ScXMLExternalRefCellContext::ScXMLExternalRefCellContext(
{
if ( !it.isEmpty() )
{
- mfCellValue = IsXMLToken( it.toCString(), XML_TRUE ) ? 1.0 : 0.0;
+ mfCellValue = IsXMLToken( it, XML_TRUE ) ? 1.0 : 0.0;
mbIsNumeric = true;
mbIsEmpty = false;
}
diff --git a/sc/source/filter/xml/xmlrowi.cxx b/sc/source/filter/xml/xmlrowi.cxx
index 8903287504ac..41c6defe29fd 100644
--- a/sc/source/filter/xml/xmlrowi.cxx
+++ b/sc/source/filter/xml/xmlrowi.cxx
@@ -233,7 +233,7 @@ ScXMLTableRowsContext::ScXMLTableRowsContext( ScXMLImport& rImport,
static_cast< sax_fastparser::FastAttributeList *>( xAttrList.get() );
auto &aIter( pAttribList->find( XML_ELEMENT( TABLE, XML_DISPLAY ) ) );
if( aIter != pAttribList->end() )
- bGroupDisplay = IsXMLToken( aIter.toCString(), XML_TRUE );
+ bGroupDisplay = IsXMLToken( aIter, XML_TRUE );
}
}
}
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index c9cdb1b00a5b..c1bef215d008 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -160,7 +160,7 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport,
sStyleName = it.toString();
break;
case XML_ELEMENT( TABLE, XML_PROTECTED ):
- aProtectData.mbProtected = IsXMLToken( it.toCString(), XML_TRUE );
+ aProtectData.mbProtected = IsXMLToken( it, XML_TRUE );
break;
case XML_ELEMENT( TABLE, XML_PRINT_RANGES ):
sPrintRanges = it.toString();
@@ -177,7 +177,7 @@ ScXMLTableContext::ScXMLTableContext( ScXMLImport& rImport,
break;
case XML_ELEMENT( TABLE, XML_PRINT ):
{
- if (IsXMLToken( it.toCString(), XML_FALSE) )
+ if ( IsXMLToken( it, XML_FALSE) )
bPrintEntireSheet = false;
}
break;
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index a7d242b366dd..c7f0dc673caf 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3345,6 +3345,17 @@ namespace xmloff { namespace token {
const XMLTokenEntry* pToken = &aTokenList[(sal_uInt16)eToken];
return !strcmp( pCString, pToken->pChar );
}
+
+ bool IsXMLToken(
+ const sax_fastparser::FastAttributeList::FastAttributeIter& aIter,
+ enum XMLTokenEnum eToken )
+ {
+ assert(XML_TOKEN_INVALID < eToken);
+ assert(eToken < XML_TOKEN_END);
+
+ const XMLTokenEntry* pToken = &aTokenList[(sal_uInt16)eToken];
+ return aIter.isString( pToken->pChar );
+ }
}
}
More information about the Libreoffice-commits
mailing list