Skip to content

Commit 6763a6e

Browse files
committed
Clean up old ExcelVersion < 12.0 support
1 parent d128f4d commit 6763a6e

File tree

6 files changed

+47
-73
lines changed

6 files changed

+47
-73
lines changed

Source/ExcelDna.Integration/AssemblyLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void ProcessAssemblies(
3636
List<Type> rtdServerTypes,
3737
List<ExcelComClassType> comClassTypes)
3838
{
39-
bool loadRibbons = (ExcelDnaUtil.ExcelVersion >= 12.0);
39+
bool loadRibbons = true;
4040

4141
foreach (ExportedAssembly assembly in assemblies)
4242
{

Source/ExcelDna.Integration/DnaLibrary.cs

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -394,50 +394,48 @@ internal void AutoClose()
394394
internal void LoadCustomUI()
395395
{
396396
bool uiLoaded = false;
397-
if (ExcelDnaUtil.ExcelVersion >= 12.0)
397+
398+
// Load ComAddIns
399+
foreach (AssemblyLoader.ExcelAddInInfo addIn in _addIns)
398400
{
399-
// Load ComAddIns
400-
foreach (AssemblyLoader.ExcelAddInInfo addIn in _addIns)
401+
if (addIn.IsCustomUI)
401402
{
402-
if (addIn.IsCustomUI)
403-
{
404-
// Load ExcelRibbon classes
405-
ExcelRibbon excelRibbon = addIn.Instance as ExcelRibbon;
406-
excelRibbon.DnaLibrary = addIn.ParentDnaLibrary;
407-
ExcelComAddInHelper.LoadComAddIn(excelRibbon);
408-
uiLoaded = true;
409-
}
403+
// Load ExcelRibbon classes
404+
ExcelRibbon excelRibbon = addIn.Instance as ExcelRibbon;
405+
excelRibbon.DnaLibrary = addIn.ParentDnaLibrary;
406+
ExcelComAddInHelper.LoadComAddIn(excelRibbon);
407+
uiLoaded = true;
410408
}
411-
412-
// CONSIDER: Really not sure if this is a good idea - seems to interfere with unloading somehow.
413-
//if (uiLoaded == false && CustomUIs != null)
414-
//{
415-
// // Check whether we should add an empty ExcelCustomUI instance to load a Ribbon interface?
416-
// bool loadEmptyAddIn = false;
417-
// if (CustomUIs != null)
418-
// {
419-
// foreach (XmlNode xmlCustomUI in CustomUIs)
420-
// {
421-
// if (xmlCustomUI.LocalName == "customUI" &&
422-
// (xmlCustomUI.NamespaceURI == ExcelRibbon.NamespaceCustomUI2007 ||
423-
// (ExcelDnaUtil.ExcelVersion >= 14.0 &&
424-
// xmlCustomUI.NamespaceURI == ExcelRibbon.NamespaceCustomUI2010)))
425-
// {
426-
// loadEmptyAddIn = true;
427-
// }
428-
// if (loadEmptyAddIn)
429-
// {
430-
// // There will be Ribbon xml to load. Make a temp add-in and load it.
431-
// ExcelRibbon customUI = new ExcelRibbon();
432-
// customUI.DnaLibrary = this;
433-
// ExcelComAddInHelper.LoadComAddIn(customUI);
434-
// uiLoaded = true;
435-
// }
436-
// }
437-
// }
438-
//}
439409
}
440410

411+
// CONSIDER: Really not sure if this is a good idea - seems to interfere with unloading somehow.
412+
//if (uiLoaded == false && CustomUIs != null)
413+
//{
414+
// // Check whether we should add an empty ExcelCustomUI instance to load a Ribbon interface?
415+
// bool loadEmptyAddIn = false;
416+
// if (CustomUIs != null)
417+
// {
418+
// foreach (XmlNode xmlCustomUI in CustomUIs)
419+
// {
420+
// if (xmlCustomUI.LocalName == "customUI" &&
421+
// (xmlCustomUI.NamespaceURI == ExcelRibbon.NamespaceCustomUI2007 ||
422+
// (ExcelDnaUtil.ExcelVersion >= 14.0 &&
423+
// xmlCustomUI.NamespaceURI == ExcelRibbon.NamespaceCustomUI2010)))
424+
// {
425+
// loadEmptyAddIn = true;
426+
// }
427+
// if (loadEmptyAddIn)
428+
// {
429+
// // There will be Ribbon xml to load. Make a temp add-in and load it.
430+
// ExcelRibbon customUI = new ExcelRibbon();
431+
// customUI.DnaLibrary = this;
432+
// ExcelComAddInHelper.LoadComAddIn(customUI);
433+
// uiLoaded = true;
434+
// }
435+
// }
436+
// }
437+
//}
438+
441439
// should we load CommandBars?
442440
if (uiLoaded == false && CustomUIs != null)
443441
{

Source/ExcelDna.Integration/Excel.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -746,20 +746,11 @@ public static ExcelLimits ExcelLimits
746746
if (_xlLimits == null)
747747
{
748748
_xlLimits = new ExcelLimits();
749-
if (ExcelVersion < 12.0)
750-
{
751-
_xlLimits.MaxRows = 65536;
752-
_xlLimits.MaxColumns = 256;
753-
_xlLimits.MaxArguments = 30;
754-
_xlLimits.MaxStringLength = 255;
755-
}
756-
else
757-
{
758-
_xlLimits.MaxRows = 1048576;
759-
_xlLimits.MaxColumns = 16384;
760-
_xlLimits.MaxArguments = 256;
761-
_xlLimits.MaxStringLength = 32767;
762-
}
749+
750+
_xlLimits.MaxRows = 1048576;
751+
_xlLimits.MaxColumns = 16384;
752+
_xlLimits.MaxArguments = 256;
753+
_xlLimits.MaxStringLength = 32767;
763754
}
764755
return _xlLimits;
765756
}

Source/ExcelDna.Integration/ExcelRibbon.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,11 @@ public virtual string GetCustomUI(string RibbonID)
5656
}
5757
return null;
5858
}
59-
if (ExcelDnaUtil.ExcelVersion >= 12.0)
59+
if (customUIs.ContainsKey(NamespaceCustomUI2007))
6060
{
61-
if (customUIs.ContainsKey(NamespaceCustomUI2007))
62-
{
63-
return customUIs[NamespaceCustomUI2007];
64-
}
65-
return null;
61+
return customUIs[NamespaceCustomUI2007];
6662
}
67-
throw new InvalidOperationException("Not expected to provide CustomUI string for Excel version < 12.0");
63+
return null;
6864
}
6965

7066
// LoadImage helper - to use need to mark loadImage='LoadImage' in the xml.

Source/ExcelDna.Integration/Registration/ParamsRegistration.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,8 @@ static LambdaExpression WrapMethodParams(LambdaExpression functionLambda)
144144
*
145145
*/
146146

147-
int maxArguments;
148-
if (ExcelDnaUtil.ExcelVersion >= 12.0)
149-
{
150-
maxArguments = 125; // Constrained by 255 char registration string, take off 3 type chars, use up to 2 chars per param (before we start doing object...) (& also return)
147+
int maxArguments = 125; // Constrained by 255 char registration string, take off 3 type chars, use up to 2 chars per param (before we start doing object...) (& also return)
151148
// CONSIDER: Might improve this if we generate the delegate based on the max length...
152-
}
153-
else
154-
{
155-
maxArguments = 29; // Or maybe 30?
156-
}
157149

158150
var normalParams = functionLambda.Parameters.Take(functionLambda.Parameters.Count() - 1).ToList();
159151
var normalParamCount = normalParams.Count;

Source/ExcelDna.Integration/RegistrationInfo.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ static class RegistrationInfo
1919
// In both cases the XXXX is replaced with the Guid from the .xll path
2020
internal static void Register()
2121
{
22-
// RegistrationInfo is supported for Excel 2007+ only
23-
if (ExcelDnaUtil.ExcelVersion < 12.0) return;
24-
2522
_registrationInfoName = RegistrationInfoName(ExcelDnaUtil.XllPath);
2623

2724
object[] registerParameters = new object[6];

0 commit comments

Comments
 (0)