[Libreoffice-commits] core.git: 5 commits - framework/source
Stephan Bergmann
sbergman at redhat.com
Tue Sep 27 13:50:47 UTC 2016
framework/source/services/substitutepathvars.cxx | 107 ++++++++++-------------
1 file changed, 49 insertions(+), 58 deletions(-)
New commits:
commit 120d8fc75c164555058d63ef7dca8bfbd8316a5a
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Sep 27 15:45:20 2016 +0200
Use FixedVariable::bAbsPath to check for special path vars
Change-Id: I526c45ecf3c7e21b87c16eef5047707f74da7668
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index cd6bead..4d02998 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -1091,9 +1091,7 @@ throw ( RuntimeException )
if ( nPos >= 0 )
{
bool bMatch = true;
- if ( i.eVariable == PREDEFVAR_USERNAME ||
- i.eVariable == PREDEFVAR_LANGID ||
- i.eVariable == PREDEFVAR_VLANG )
+ if ( !aFixedVarTable[i.eVariable].bAbsPath )
{
// Special path variables as they can occur in the middle of a path. Only match if they
// describe a whole directory and not only a substring of a directory!
commit 02f114096d56f717da4b1665b1d2d3a9dac20f4e
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Sep 27 15:39:28 2016 +0200
Remove redundant FixedVariable::nEnumValue
Change-Id: I39a2a65e06cdf421786fbbfedecad604fcb3abd2
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index 833c6d4..cd6bead 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -184,6 +184,40 @@ enum PreDefVariable
PREDEFVAR_COUNT
};
+struct FixedVariable
+{
+ const char* pVarName;
+ bool bAbsPath;
+};
+
+// Table with all fixed/predefined variables supported.
+static const FixedVariable aFixedVarTable[PREDEFVAR_COUNT] =
+{
+ { "$(inst)", true }, // PREDEFVAR_INST
+ { "$(prog)", true }, // PREDEFVAR_PROG
+ { "$(user)", true }, // PREDEFVAR_USER
+ { "$(work)", true }, // PREDEFVAR_WORK, special variable
+ // (transient)
+ { "$(home)", true }, // PREDEFVAR_HOME
+ { "$(temp)", true }, // PREDEFVAR_TEMP
+ { "$(path)", true }, // PREDEFVAR_PATH
+ { "$(username)", false }, // PREDEFVAR_USERNAME
+ { "$(langid)", false }, // PREDEFVAR_LANGID
+ { "$(vlang)", false }, // PREDEFVAR_VLANG
+ { "$(instpath)", true }, // PREDEFVAR_INSTPATH
+ { "$(progpath)", true }, // PREDEFVAR_PROGPATH
+ { "$(userpath)", true }, // PREDEFVAR_USERPATH
+ { "$(insturl)", true }, // PREDEFVAR_INSTURL
+ { "$(progurl)", true }, // PREDEFVAR_PROGURL
+ { "$(userurl)", true }, // PREDEFVAR_USERURL
+ { "$(workdirurl)", true }, // PREDEFVAR_WORKDIRURL, special variable
+ // (transient) and don't use for
+ // resubstitution
+ { "$(baseinsturl)", true }, // PREDEFVAR_BASEINSTURL
+ { "$(userdataurl)", true }, // PREDEFVAR_USERDATAURL
+ { "$(brandbaseurl)", true } // PREDEFVAR_BRANDBASEURL
+};
+
struct PredefinedPathVariables
{
// Predefined variables supported by substitute variables
@@ -288,13 +322,6 @@ private:
css::uno::Reference< css::uno::XComponentContext > m_xContext;
};
-struct FixedVariable
-{
- const char* pVarName;
- PreDefVariable nEnumValue;
- bool bAbsPath;
-};
-
struct TableEntry
{
const char* pOSString;
@@ -339,31 +366,6 @@ static const sal_Int16 aEnvPrioTable[ET_COUNT] =
99, // ET_UNKNOWN
};
-// Table with all fixed/predefined variables supported.
-static const FixedVariable aFixedVarTable[] =
-{
- { "$(inst)", PREDEFVAR_INST, true },
- { "$(prog)", PREDEFVAR_PROG, true },
- { "$(user)", PREDEFVAR_USER, true },
- { "$(work)", PREDEFVAR_WORK, true }, // Special variable (transient)!
- { "$(home)", PREDEFVAR_HOME, true },
- { "$(temp)", PREDEFVAR_TEMP, true },
- { "$(path)", PREDEFVAR_PATH, true },
- { "$(username)", PREDEFVAR_USERNAME, false },
- { "$(langid)", PREDEFVAR_LANGID, false },
- { "$(vlang)", PREDEFVAR_VLANG, false },
- { "$(instpath)", PREDEFVAR_INSTPATH, true },
- { "$(progpath)", PREDEFVAR_PROGPATH, true },
- { "$(userpath)", PREDEFVAR_USERPATH, true },
- { "$(insturl)", PREDEFVAR_INSTURL, true },
- { "$(progurl)", PREDEFVAR_PROGURL, true },
- { "$(userurl)", PREDEFVAR_USERURL, true },
- { "$(workdirurl)", PREDEFVAR_WORKDIRURL, true }, // Special variable (transient) and don't use for resubstitution!
- { "$(baseinsturl)", PREDEFVAR_BASEINSTURL, true },
- { "$(userdataurl)", PREDEFVAR_USERDATAURL, true },
- { "$(brandbaseurl)",PREDEFVAR_BRANDBASEURL, true }
-};
-
// Implementation helper classes
OperatingSystem SubstitutePathVariables_Impl::GetOperatingSystemFromString( const OUString& aOSString )
@@ -723,7 +725,7 @@ SubstitutePathVariables::SubstitutePathVariables( const Reference< XComponentCon
// Create hash map entry
m_aPreDefVarMap.insert( VarNameToIndexMap::value_type(
- m_aPreDefVars.m_FixedVarNames[i], aFixedVarTable[i].nEnumValue ) );
+ m_aPreDefVars.m_FixedVarNames[i], PreDefVariable(i) ) );
}
// Sort predefined/fixed variable to path length
@@ -736,7 +738,7 @@ SubstitutePathVariables::SubstitutePathVariables( const Reference< XComponentCon
// and it could be possible that it will be resubstituted by itself!!
// Example: WORK_PATH=c:\test, $(workdirurl)=WORK_PATH => WORK_PATH=$(workdirurl) and this cannot be substituted!
ReSubstFixedVarOrder aFixedVar;
- aFixedVar.eVariable = aFixedVarTable[i].nEnumValue;
+ aFixedVar.eVariable = PreDefVariable(i);
aFixedVar.nVarValueLength = m_aPreDefVars.m_FixedVar[(sal_Int32)aFixedVar.eVariable].getLength();
m_aReSubstFixedVarOrder.push_back( aFixedVar );
}
commit 02c079fc4f111865252fb89d705361792b289caf
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Sep 27 15:26:20 2016 +0200
Remove unnecessary typedefs
Change-Id: I0c65720a3db88242bdf36338864f6961478f547f
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index 05324ad..833c6d4 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -216,8 +216,6 @@ struct ReSubstUserVarOrder
}
};
-typedef std::list< ReSubstFixedVarOrder > ReSubstFixedVarOrderVector;
-typedef std::list< ReSubstUserVarOrder > ReSubstUserVarOrderVector;
typedef ::cppu::WeakComponentImplHelper<
css::util::XStringSubstitution,
css::lang::XServiceInfo > SubstitutePathVariables_BASE;
@@ -285,8 +283,8 @@ private:
SubstituteVariables m_aSubstVarMap; // Active rule set map indexed by variable name!
PredefinedPathVariables m_aPreDefVars; // All predefined variables
SubstitutePathVariables_Impl m_aImpl; // Implementation class that access the configuration
- ReSubstFixedVarOrderVector m_aReSubstFixedVarOrder; // To speed up resubstitution fixed variables (order for lookup)
- ReSubstUserVarOrderVector m_aReSubstUserVarOrder; // To speed up resubstitution user variables
+ std::list<ReSubstFixedVarOrder> m_aReSubstFixedVarOrder; // To speed up resubstitution fixed variables (order for lookup)
+ std::list<ReSubstUserVarOrder> m_aReSubstUserVarOrder; // To speed up resubstitution user variables
css::uno::Reference< css::uno::XComponentContext > m_xContext;
};
commit da2e1ea7d4a919a13caf159d1afce13843f7a621
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Sep 27 15:24:35 2016 +0200
Use range-based for
Change-Id: If112967db4828f8570692af5dbbbd9e3c2a837aa
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index bc94563..05324ad 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -746,12 +746,11 @@ SubstitutePathVariables::SubstitutePathVariables( const Reference< XComponentCon
m_aReSubstFixedVarOrder.sort();
// Sort user variables to path length
- SubstituteVariables::const_iterator pIter;
- for ( pIter = m_aSubstVarMap.begin(); pIter != m_aSubstVarMap.end(); ++pIter )
+ for (auto const & i: m_aSubstVarMap)
{
ReSubstUserVarOrder aUserOrderVar;
- aUserOrderVar.aVarName = "$(" + pIter->second.aSubstVariable + ")";
- aUserOrderVar.nVarValueLength = pIter->second.aSubstVariable.getLength();
+ aUserOrderVar.aVarName = "$(" + i.second.aSubstVariable + ")";
+ aUserOrderVar.nVarValueLength = i.second.aSubstVariable.getLength();
m_aReSubstUserVarOrder.push_back( aUserOrderVar );
}
m_aReSubstUserVarOrder.sort();
@@ -1085,18 +1084,16 @@ throw ( RuntimeException )
{
bool bVariableFound = false;
- for (ReSubstFixedVarOrderVector::const_iterator i(
- m_aReSubstFixedVarOrder.begin());
- i != m_aReSubstFixedVarOrder.end(); ++i)
+ for (auto const & i: m_aReSubstFixedVarOrder)
{
- OUString aValue = m_aPreDefVars.m_FixedVar[i->eVariable];
+ OUString aValue = m_aPreDefVars.m_FixedVar[i.eVariable];
sal_Int32 nPos = aURL.indexOf( aValue );
if ( nPos >= 0 )
{
bool bMatch = true;
- if ( i->eVariable == PREDEFVAR_USERNAME ||
- i->eVariable == PREDEFVAR_LANGID ||
- i->eVariable == PREDEFVAR_VLANG )
+ if ( i.eVariable == PREDEFVAR_USERNAME ||
+ i.eVariable == PREDEFVAR_LANGID ||
+ i.eVariable == PREDEFVAR_VLANG )
{
// Special path variables as they can occur in the middle of a path. Only match if they
// describe a whole directory and not only a substring of a directory!
@@ -1123,7 +1120,7 @@ throw ( RuntimeException )
{
aURL = aURL.replaceAt(
nPos, aValue.getLength(),
- m_aPreDefVars.m_FixedVarNames[i->eVariable]);
+ m_aPreDefVars.m_FixedVarNames[i.eVariable]);
bVariableFound = true; // Resubstitution not finished yet!
break;
}
@@ -1131,11 +1128,9 @@ throw ( RuntimeException )
}
// This part can be iterated more than one time as variables can contain variables again!
- for (ReSubstUserVarOrderVector::const_iterator i(
- m_aReSubstUserVarOrder.begin());
- i != m_aReSubstUserVarOrder.end(); ++i)
+ for (auto const & i: m_aReSubstUserVarOrder)
{
- OUString aVarValue = i->aVarName;
+ OUString aVarValue = i.aVarName;
sal_Int32 nPos = aURL.indexOf( aVarValue );
if ( nPos >= 0 )
{
commit 2c5934b1a10f36525be1220db062d1738b6aac62
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Sep 27 15:24:12 2016 +0200
Reduce var scope
Change-Id: I5b5ea9968c7648e38a5cacda5e1f6ba8bea78749
diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index dd1747a..bc94563 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -714,13 +714,11 @@ SubstitutePathVariables::SubstitutePathVariables( const Reference< XComponentCon
SubstitutePathVariables_BASE(m_aMutex),
m_xContext( xContext )
{
- int i;
-
SetPredefinedPathVariables();
m_aImpl.GetSharePointsRules( m_aSubstVarMap );
// Init the predefined/fixed variable to index hash map
- for ( i = 0; i < PREDEFVAR_COUNT; i++ )
+ for ( int i = 0; i < PREDEFVAR_COUNT; i++ )
{
// Store variable name into struct of predefined/fixed variables
m_aPreDefVars.m_FixedVarNames[i] = OUString::createFromAscii( aFixedVarTable[i].pVarName );
@@ -731,7 +729,7 @@ SubstitutePathVariables::SubstitutePathVariables( const Reference< XComponentCon
}
// Sort predefined/fixed variable to path length
- for ( i = 0; i < PREDEFVAR_COUNT; i++ )
+ for ( int i = 0; i < PREDEFVAR_COUNT; i++ )
{
if (( i != PREDEFVAR_WORKDIRURL ) && ( i != PREDEFVAR_PATH ))
{
More information about the Libreoffice-commits
mailing list