Commit afa0ff34 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

локализация числового форматирования Excel.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55722 954022d7-b5bf-4e40-9824-e11837661b57
parent 34ca8670

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.30110.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParseAllCultureInfo", "ParseAllCultureInfo\ParseAllCultureInfo.csproj", "{03F2AE57-3F3E-4429-9E12-D8D71CC38F0A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{03F2AE57-3F3E-4429-9E12-D8D71CC38F0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03F2AE57-3F3E-4429-9E12-D8D71CC38F0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03F2AE57-3F3E-4429-9E12-D8D71CC38F0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03F2AE57-3F3E-4429-9E12-D8D71CC38F0A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{03F2AE57-3F3E-4429-9E12-D8D71CC38F0A}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ParseAllCultureInfo</RootNamespace>
<AssemblyName>ParseAllCultureInfo</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Parser.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Reflection;
namespace ParseAllCultureInfo
{
class Parser
{
[DataContract]
class ParamsSerializable
{
[DataMember]
public int LCID;
[DataMember]
public string Name;
[DataMember]
public int CurrencyNegativePattern;
[DataMember]
public string CurrencySymbol;
[DataMember]
public string NumberDecimalSeparator;
[DataMember]
public string NumberGroupSeparator;
[DataMember]
public int[] NumberGroupSizes;
[DataMember]
public string[] DayNames;
[DataMember]
public string[] AbbreviatedDayNames;
[DataMember]
public string[] MonthNames;
[DataMember]
public string[] AbbreviatedMonthNames;
[DataMember]
public string[] MonthGenitiveNames;
[DataMember]
public string[] AbbreviatedMonthGenitiveNames;
[DataMember]
public string AMDesignator;
[DataMember]
public string PMDesignator;
[DataMember]
public string DateSeparator;
[DataMember]
public string TimeSeparator;
[DataMember]
public string ShortDatePattern;
public ParamsSerializable(CultureInfo ci)
{
LCID = ci.LCID;
Name = ci.Name;
NumberFormatInfo ni = ci.NumberFormat;
CurrencyNegativePattern = ni.CurrencyNegativePattern;
CurrencySymbol = ni.CurrencySymbol;
NumberDecimalSeparator = ni.NumberDecimalSeparator;
//replace Non-breaking space(0xA0) with White-space(0x20)
NumberGroupSeparator = ni.NumberGroupSeparator.Replace((char)0xA0, (char)0x20);
NumberGroupSizes = ni.NumberGroupSizes;
DateTimeFormatInfo di = ci.DateTimeFormat;
AbbreviatedDayNames = di.AbbreviatedDayNames;
AbbreviatedMonthNames = di.AbbreviatedMonthNames;
bool bAbbreviatedMonthGenitiveNamesEqual = true;
for (int i = 0; i < di.AbbreviatedMonthNames.Length; ++i)
{
if (di.AbbreviatedMonthGenitiveNames[i] != di.AbbreviatedMonthNames[i])
bAbbreviatedMonthGenitiveNamesEqual = false;
}
if (!bAbbreviatedMonthGenitiveNamesEqual)
AbbreviatedMonthGenitiveNames = di.AbbreviatedMonthGenitiveNames;
else
AbbreviatedMonthGenitiveNames = null;
AMDesignator = di.AMDesignator;
DateSeparator = di.DateSeparator;
DayNames = di.DayNames;
MonthNames = di.MonthNames;
bool bMonthGenitiveNamesEqual = true;
for (int i = 0; i < di.MonthNames.Length; ++i)
{
if (di.MonthGenitiveNames[i] != di.MonthNames[i])
bMonthGenitiveNamesEqual = false;
}
if (!bMonthGenitiveNamesEqual)
MonthGenitiveNames = di.MonthGenitiveNames;
else
MonthGenitiveNames = null;
PMDesignator = di.PMDesignator;
TimeSeparator = di.TimeSeparator;
string ShortDatePatternLower = di.ShortDatePattern.ToLower();
int nIndexD = ShortDatePatternLower.IndexOf("d");
int nIndexM = ShortDatePatternLower.IndexOf("m");
int nIndexY = ShortDatePatternLower.IndexOf("y");
int[] aTemp = new int[] {nIndexD, nIndexM, nIndexY};
Array.Sort(aTemp);
string sShortDatePattern = "";
for (int i = 0; i < aTemp.Length; ++i)
{
var index = aTemp[i];
if(nIndexD == index)
sShortDatePattern += "0";
else if (nIndexM == index)
sShortDatePattern += "1";
else if (nIndexY == index)
sShortDatePattern += "2";
}
ShortDatePattern = sShortDatePattern;
}
}
public static void parse()
{
List<int> aLcid = new List<int>();
Dictionary<int, CultureInfo> aInfos = new Dictionary<int, CultureInfo>();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
if (!aInfos.ContainsKey(ci.LCID))
{
aLcid.Add(ci.LCID);
aInfos[ci.LCID] = ci;
}
}
aLcid.Sort();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("{{");
foreach (int index in aLcid)
{
ParamsSerializable elem = new ParamsSerializable(aInfos[index]);
sb.AppendFormat("{0}:{{", elem.LCID);
Type type = elem.GetType();
FieldInfo[] fieldInfos = type.GetFields();
for (int i = 0, length = fieldInfos.Length; i < length; ++i)
{
if (0 != i)
sb.Append(",");
FieldInfo info = fieldInfos[i];
object value = info.GetValue(elem);
if (info.FieldType.IsArray)
{
sb.AppendFormat("{0}:[", info.Name);
if (value is int[])
{
int[] aElems = (int[])value;
for (int j = 0, length2 = aElems.Length; j < length2; ++j)
{
if (0 != j)
sb.AppendFormat(",");
sb.AppendFormat("{0}", aElems[j]);
}
}
else if (value is string[])
{
string[] aElems = (string[])value;
for (int j = 0, length2 = aElems.Length; j < length2; ++j)
{
if (0 != j)
sb.AppendFormat(",");
sb.AppendFormat("\"{0}\"", aElems[j]);
}
}
sb.AppendFormat("]");
}
else
{
sb.AppendFormat("{0}:", info.Name);
parseValue(sb, value);
}
}
sb.Append("},\r\n");
}
sb.AppendFormat("}}");
string sAll = sb.ToString();
}
public static void parseValue(StringBuilder sb, object value)
{
if (value is string)
sb.AppendFormat("\"{0}\"", value);
else
sb.AppendFormat("{0}", value);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ParseAllCultureInfo
{
class Program
{
static void Main(string[] args)
{
Parser.parse();
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ParseAllCultureInfo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ParseAllCultureInfo")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1a263536-afa2-4895-b902-c9dea2b36eff")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment