示例#1
0
 public virtual void FixtureSetup()
 {
     // This needs to be set for ICU
     RegistryHelper.CompanyName = "SIL";
     Icu.InitIcuDataDir();
     m_DebugProcs = new DebugProcs();
 }
示例#2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Member AddUnicodeProp
        /// </summary>
        /// <param name="tag">tag</param>
        /// <param name="ws">ws</param>
        /// <param name="_vwvc">_vwvc</param>
        /// ------------------------------------------------------------------------------------
        public override void AddUnicodeProp(int tag, int ws, IVwViewConstructor _vwvc)
        {
            CurrentContext ccOld = WriteFieldStartTag(tag);
            string         sText = DataAccess.get_UnicodeProp(CurrentObject(), tag);

            // Need to ensure that sText is NFC for export.
            Icu.InitIcuDataDir();
            if (!Icu.IsNormalized(sText, Icu.UNormalizationMode.UNORM_NFC))
            {
                sText = Icu.Normalize(sText, Icu.UNormalizationMode.UNORM_NFC);
            }
            string sWs = WritingSystemId(ws);

            IndentLine();
            if (String.IsNullOrEmpty(sWs))
            {
                m_writer.WriteLine("<Uni>{0}</Uni>", XmlUtils.MakeSafeXml(sText));
            }
            else
            {
                m_writer.WriteLine("<AUni ws=\"{0}\">{1}</AUni>",
                                   sWs, XmlUtils.MakeSafeXml(sText));
            }
            WriteFieldEndTag(tag, ccOld);
        }
示例#3
0
        public virtual void FixtureSetup()
        {
            m_debugProcs = new DebugProcs();
            try
            {
                Icu.InitIcuDataDir();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

#if __MonoCS__
            try
            {
                using (var process = System.Diagnostics.Process.GetCurrentProcess())
                {
                    // try to change PTRACE option so that unmanaged call stacks show more useful
                    // information. Since Ubuntu 10.10 a normal user is no longer allowed to use
                    // PTRACE. This prevents call stacks and assertions from working properly.
                    // However, we can set a flag on the currently running process to allow
                    // it. See also the similar code in Generic/ModuleEntry.cpp
                    prctl(PR_SET_PTRACER, (IntPtr)process.Id, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                }
            }
            catch (Exception e)
            {
                // just ignore any errors we get
            }
#endif
        }
示例#4
0
        public void CharacterPropertyOverrides()
        {
            Icu.InitIcuDataDir();
            var cpe    = LgIcuCharPropEngineClass.Create();
            var result = cpe.get_GeneralCategory('\xF171');

            Assert.That(result, Is.EqualTo(LgGeneralCharCategory.kccMn));
        }
示例#5
0
 protected static void IcuInit()
 {
     Icu.InitIcuDataDir();
     if (!Sldr.IsInitialized)
     {
         Sldr.Initialize();
     }
 }
示例#6
0
        public override void BeforeTest(TestDetails testDetails)
        {
            base.BeforeTest(testDetails);

            string dir = null;

            if (string.IsNullOrEmpty(IcuDataPath))
            {
                var environDataPath = Environment.GetEnvironmentVariable("ICU_DATA");
                if (!string.IsNullOrEmpty(environDataPath))
                {
                    dir = environDataPath;
                }
                else
                {
                    using (RegistryKey userKey = Registry.CurrentUser.OpenSubKey(@"Software\SIL"))
                        using (RegistryKey machineKey = Registry.LocalMachine.OpenSubKey(@"Software\SIL"))
                        {
                            const string icuDirValueName = "Icu54DataDir";
                            if (userKey?.GetValue(icuDirValueName) != null)
                            {
                                dir = userKey.GetValue(icuDirValueName, null) as string;
                            }
                            else if (machineKey?.GetValue(icuDirValueName) != null)
                            {
                                dir = machineKey.GetValue(icuDirValueName, null) as string;
                            }
                        }
                }
            }
            else if (Path.IsPathRooted(IcuDataPath))
            {
                dir = IcuDataPath;
            }
            else
            {
                Uri    uriBase = new Uri(Assembly.GetExecutingAssembly().CodeBase);
                string codeDir = Path.GetDirectoryName(Uri.UnescapeDataString(uriBase.AbsolutePath));
                if (codeDir != null)
                {
                    dir = Path.Combine(codeDir, IcuDataPath);
                }
            }

            if (!string.IsNullOrEmpty(dir))
            {
                Environment.SetEnvironmentVariable("ICU_DATA", dir);
            }

            try
            {
                Icu.InitIcuDataDir();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#7
0
        public void TestFixtureSetup()
        {
            // This needs to be set for ICU
            RegistryHelper.CompanyName = "SIL";

            // Set stub for messagebox so that we don't pop up a message box when running tests.
            MessageBoxUtils.Manager.SetMessageBoxAdapter(new MessageBoxStub());

            Icu.InitIcuDataDir();
        }
示例#8
0
        static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                WriteHelp();
                return(0);
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("The FieldWorks project file could not be found.");
                return(1);
            }

            RegistryHelper.CompanyName = DirectoryFinder.CompanyName;
            Icu.InitIcuDataDir();
            var synchronizeInvoke = new SingleThreadedSynchronizeInvoke();
            var spanFactory       = new ShapeSpanFactory();

            var projectId = new ProjectIdentifier(args[0]);
            var logger    = new ConsoleLogger(synchronizeInvoke);
            var dirs      = new NullFdoDirectories();
            var settings  = new FdoSettings {
                DisableDataMigration = true
            };
            var progress = new NullThreadedProgress(synchronizeInvoke);

            Console.WriteLine("Loading FieldWorks project...");
            try
            {
                using (FdoCache cache = FdoCache.CreateCacheFromExistingData(projectId, "en", logger, dirs, settings, progress))
                {
                    Language language = HCLoader.Load(spanFactory, cache, logger);
                    Console.WriteLine("Loading completed.");
                    Console.WriteLine("Writing HC configuration file...");
                    XmlLanguageWriter.Save(language, args[1]);
                    Console.WriteLine("Writing completed.");
                }
                return(0);
            }
            catch (FdoFileLockedException)
            {
                Console.WriteLine("Loading failed.");
                Console.WriteLine("The FieldWorks project is currently open in another application.");
                Console.WriteLine("Close the application and try to run this command again.");
                return(1);
            }
            catch (FdoDataMigrationForbiddenException)
            {
                Console.WriteLine("Loading failed.");
                Console.WriteLine("The FieldWorks project was created with an older version of FLEx.");
                Console.WriteLine("Migrate the project to the latest version by opening it in FLEx.");
                return(1);
            }
        }
示例#9
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     // initialize ICU
     Icu.InitIcuDataDir();
     RegistryHelper.ProductName = "FieldWorks";             // inorder to find correct Registry keys
     using (var form = new FDOBrowserForm())
     {
         Application.Run(form);
     }
 }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FwLexiconPlugin"/> class.
        /// </summary>
        public FwLexiconPlugin()
        {
            RegistryHelper.CompanyName = DirectoryFinder.CompanyName;
            RegistryHelper.ProductName = "FieldWorks";

            // setup necessary environment variables on Linux
            if (MiscUtils.IsUnix)
            {
                // update ICU_DATA to location of ICU data files
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ICU_DATA")))
                {
                    string codeIcuDataPath = Path.Combine(ParatextLexiconPluginDirectoryFinder.CodeDirectory, "Icu" + Icu.Version);
#if DEBUG
                    string icuDataPath = codeIcuDataPath;
#else
                    string icuDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ".config/fieldworks/Icu" + Icu.Version);
                    if (!Directory.Exists(icuDataPath))
                    {
                        icuDataPath = codeIcuDataPath;
                    }
#endif
                    Environment.SetEnvironmentVariable("ICU_DATA", icuDataPath);
                }
                // update COMPONENTS_MAP_PATH to point to code directory so that COM objects can be loaded properly
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("COMPONENTS_MAP_PATH")))
                {
                    string compMapPath = Path.GetDirectoryName(FileUtils.StripFilePrefix(Assembly.GetExecutingAssembly().CodeBase));
                    Environment.SetEnvironmentVariable("COMPONENTS_MAP_PATH", compMapPath);
                }
                // update FW_ROOTCODE so that strings-en.txt file can be found
                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("FW_ROOTCODE")))
                {
                    Environment.SetEnvironmentVariable("FW_ROOTCODE", ParatextLexiconPluginDirectoryFinder.CodeDirectory);
                }
            }
            Icu.InitIcuDataDir();

            m_syncRoot          = new object();
            m_lexiconCache      = new FdoLexiconCollection();
            m_fdoCacheCache     = new FdoCacheCollection();
            m_activationContext = new ActivationContextHelper("FwParatextLexiconPlugin.dll.manifest");

            // initialize client-server services to use Db4O backend for FDO
            m_ui = new ParatextLexiconPluginFdoUI(m_activationContext);
            var dirs = ParatextLexiconPluginDirectoryFinder.FdoDirectories;
            ClientServerServices.SetCurrentToDb4OBackend(m_ui, dirs);
        }
示例#11
0
 public void SetUp()
 {
     Icu.InitIcuDataDir();
     m_activationContext = new ActivationContextHelper("FwParatextLexiconPlugin.dll.manifest");
     using (m_activationContext.Activate())
     {
         m_threadHelper = new ThreadHelper();
         var ui        = new DummyFdoUI(m_threadHelper);
         var projectId = new ParatextLexiconPluginProjectID(FDOBackendProviderType.kMemoryOnly, "Test.fwdata");
         m_cache = FdoCache.CreateCacheWithNewBlankLangProj(projectId, "en", "fr", "en", ui, ParatextLexiconPluginDirectoryFinder.FdoDirectories, new FdoSettings());
         NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () =>
         {
             m_cache.ServiceLocator.WritingSystems.AddToCurrentAnalysisWritingSystems(m_cache.ServiceLocator.WritingSystemManager.Get("fr"));
             m_cache.ServiceLocator.WritingSystems.AddToCurrentVernacularWritingSystems(m_cache.ServiceLocator.WritingSystemManager.Get("en"));
             m_cache.LangProject.MorphologicalDataOA.ParserParameters = "<ParserParameters><XAmple><MaxNulls>1</MaxNulls><MaxPrefixes>5</MaxPrefixes><MaxInfixes>1</MaxInfixes><MaxSuffixes>5</MaxSuffixes><MaxInterfixes>0</MaxInterfixes><MaxAnalysesToReturn>10</MaxAnalysesToReturn></XAmple><ActiveParser>XAmple</ActiveParser></ParserParameters>";
         });
     }
     m_lexicon = new FdoLexicon("Test", "FieldWorks:Test", m_cache, m_cache.DefaultVernWs, m_activationContext);
 }
示例#12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Displays a dialog that allows the user to choose an FW language project.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool ShowOpenProject(Form owner, ref Rectangle dialogBounds,
                                    ref int dialogSplitterPos, out string name, out string server)
        {
            Icu.InitIcuDataDir();
            RegistryHelper.ProductName = "FieldWorks";             // inorder to find correct Registry keys

            using (var dlg = new ChooseLangProjectDialog(dialogBounds, dialogSplitterPos))
            {
                if (dlg.ShowDialog(owner) == DialogResult.OK)
                {
                    name              = dlg.Project;
                    server            = dlg.Server;
                    dialogBounds      = dlg.Bounds;
                    dialogSplitterPos = dlg.SplitterPosition;
                    return(true);
                }
            }

            name   = null;
            server = null;
            return(false);
        }
示例#13
0
        private static void VerifyNewlyCreatedChars()
        {
            Icu.InitIcuDataDir();

            // The commented out methods below use u_getIntPropertyValue(), which doesn't
            // work reliably with the limited number of data files that we modify.
            //Assert.IsTrue(Icu.IsAlphabetic(kChar1));	// now true
            //Assert.IsTrue(Icu.IsAlphabetic(kChar2));	// now true
            //Assert.IsFalse(Icu.IsAlphabetic(kChar3));
            //Assert.IsFalse(Icu.IsAlphabetic(kChar4));
            Assert.IsFalse(Icu.IsControl(kChar1));
            Assert.IsFalse(Icu.IsControl(kChar2));
            Assert.IsFalse(Icu.IsControl(kChar3));
            Assert.IsFalse(Icu.IsControl(kChar4));
            //Assert.IsFalse(Icu.IsDiacritic(kChar1));
            //Assert.IsFalse(Icu.IsDiacritic(kChar2));
            //Assert.IsFalse(Icu.IsDiacritic(kChar3));
            //Assert.IsFalse(Icu.IsDiacritic(kChar4));
            //Assert.IsFalse(Icu.IsIdeographic(kChar1));
            //Assert.IsFalse(Icu.IsIdeographic(kChar2));
            //Assert.IsFalse(Icu.IsIdeographic(kChar3));
            //Assert.IsFalse(Icu.IsIdeographic(kChar4));
            //Assert.IsFalse(Icu.IsNumeric(kChar1));
            //Assert.IsFalse(Icu.IsNumeric(kChar2));
            //Assert.IsFalse(Icu.IsNumeric(kChar3));
            //Assert.IsTrue(Icu.IsNumeric(kChar4));		// now true
            Assert.IsFalse(Icu.IsPunct(kChar1));
            Assert.IsFalse(Icu.IsPunct(kChar2));
            Assert.IsTrue(Icu.IsPunct(kChar3));                                 // now true
            Assert.IsFalse(Icu.IsPunct(kChar4));
            Assert.IsFalse(Icu.IsSpace(kChar1));
            Assert.IsFalse(Icu.IsSpace(kChar2));
            Assert.IsFalse(Icu.IsSpace(kChar3));
            Assert.IsFalse(Icu.IsSpace(kChar4));
            Assert.IsFalse(Icu.IsSymbol(kChar1));
            Assert.IsFalse(Icu.IsSymbol(kChar2));
            Assert.IsFalse(Icu.IsSymbol(kChar3));
            Assert.IsFalse(Icu.IsSymbol(kChar4));

            var cat = Icu.GetCharType(kChar1);

            Assert.AreEqual(Icu.UCharCategory.U_LOWERCASE_LETTER, cat);
            cat = Icu.GetCharType(kChar2);
            Assert.AreEqual(Icu.UCharCategory.U_UPPERCASE_LETTER, cat);
            cat = Icu.GetCharType(kChar3);
            Assert.AreEqual(Icu.UCharCategory.U_OTHER_PUNCTUATION, cat);
            cat = Icu.GetCharType(kChar4);
            Assert.AreEqual(Icu.UCharCategory.U_DECIMAL_DIGIT_NUMBER, cat);
            var decompositionType = Icu.GetDecompositionType(kChar1);

            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = Icu.GetDecompositionType(kChar2);
            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = Icu.GetDecompositionType(kChar3);
            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = Icu.GetDecompositionType(kChar4);
            Assert.AreEqual("[none]", decompositionType.Description);
            var numericType = Icu.GetNumericType(kChar1);

            Assert.AreEqual("[none]", numericType.Description);
            numericType = Icu.GetNumericType(kChar2);
            Assert.AreEqual("[none]", numericType.Description);
            numericType = Icu.GetNumericType(kChar3);
            Assert.AreEqual("[none]", numericType.Description);

            // Current implementation (as of ICU50) is not overriding numeric type since we don't use it anywhere.
            // Enhance silmods.c in icu patch if needed.
            //numericType = Icu.GetNumericType(kChar4);
            //Assert.AreEqual("Decimal Digit", numericType.Description);

            // Current implementation (as of ICU50) is not overriding character names since we don't use them anywhere.
            // Enhance silmods.c in icu patch if needed.
            //var prettyName = Icu.GetPrettyICUCharName("\xE000");
            //Assert.AreEqual("My Special Character", prettyName);
            //prettyName = Icu.GetPrettyICUCharName("\xE001");
            //Assert.AreEqual("My Uppercase Character", prettyName);
            //prettyName = Icu.GetPrettyICUCharName(kChar3S);
            //Assert.AreEqual("New Punctuation Mark", prettyName);
            //var rawName = Icu.GetCharName(kChar4);	// can't pass large character code as 16-bit char.
            //Assert.AreEqual("NEW DIGIT NINE", rawName);
        }
示例#14
0
        private static void VerifyNonexistentChars()
        {
            Icu.InitIcuDataDir();

            Assert.IsFalse(Icu.IsAlphabetic(kChar1));
            Assert.IsFalse(Icu.IsAlphabetic(kChar2));
            Assert.IsFalse(Icu.IsAlphabetic(kChar3));
            Assert.IsFalse(Icu.IsAlphabetic(kChar4));
            Assert.IsFalse(Icu.IsControl(kChar1));
            Assert.IsFalse(Icu.IsControl(kChar2));
            Assert.IsFalse(Icu.IsControl(kChar3));
            Assert.IsFalse(Icu.IsControl(kChar4));
            Assert.IsFalse(Icu.IsDiacritic(kChar1));
            Assert.IsFalse(Icu.IsDiacritic(kChar2));
            Assert.IsFalse(Icu.IsDiacritic(kChar3));
            Assert.IsFalse(Icu.IsDiacritic(kChar4));
            Assert.IsFalse(Icu.IsIdeographic(kChar1));
            Assert.IsFalse(Icu.IsIdeographic(kChar2));
            Assert.IsFalse(Icu.IsIdeographic(kChar3));
            Assert.IsFalse(Icu.IsIdeographic(kChar4));
            Assert.IsFalse(Icu.IsNumeric(kChar1));
            Assert.IsFalse(Icu.IsNumeric(kChar2));
            Assert.IsFalse(Icu.IsNumeric(kChar3));
            Assert.IsFalse(Icu.IsNumeric(kChar4));
            Assert.IsFalse(Icu.IsPunct(kChar1));
            Assert.IsFalse(Icu.IsPunct(kChar2));
            Assert.IsFalse(Icu.IsPunct(kChar3));
            Assert.IsFalse(Icu.IsPunct(kChar4));
            Assert.IsFalse(Icu.IsSpace(kChar1));
            Assert.IsFalse(Icu.IsSpace(kChar2));
            Assert.IsFalse(Icu.IsSpace(kChar3));
            Assert.IsFalse(Icu.IsSpace(kChar4));
            Assert.IsFalse(Icu.IsSymbol(kChar1));
            Assert.IsFalse(Icu.IsSymbol(kChar2));
            Assert.IsFalse(Icu.IsSymbol(kChar3));
            Assert.IsFalse(Icu.IsSymbol(kChar4));

            Assert.AreEqual(Icu.UCharCategory.U_PRIVATE_USE_CHAR, Icu.GetCharType(kChar1));
            Assert.AreEqual(Icu.UCharCategory.U_PRIVATE_USE_CHAR, Icu.GetCharType(kChar2));
            Assert.AreEqual(Icu.UCharCategory.U_UNASSIGNED, Icu.GetCharType(kChar3));
            Assert.AreEqual(Icu.UCharCategory.U_UNASSIGNED, Icu.GetCharType(kChar4));
            var decompositionType = Icu.GetDecompositionType(kChar1);

            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = Icu.GetDecompositionType(kChar2);
            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = Icu.GetDecompositionType(kChar3);
            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = Icu.GetDecompositionType(kChar4);
            Assert.AreEqual("[none]", decompositionType.Description);
            var numericType = Icu.GetNumericType(kChar1);

            Assert.AreEqual("[none]", numericType.Description);
            numericType = Icu.GetNumericType(kChar2);
            Assert.AreEqual("[none]", numericType.Description);
            numericType = Icu.GetNumericType(kChar3);
            Assert.AreEqual("[none]", numericType.Description);
            numericType = Icu.GetNumericType(kChar4);
            Assert.AreEqual("[none]", numericType.Description);
            var prettyName = Icu.GetPrettyICUCharName("\xE000");

            Assert.IsNull(prettyName);
            prettyName = Icu.GetPrettyICUCharName("\xE001");
            Assert.IsNull(prettyName);
            prettyName = Icu.GetPrettyICUCharName(kChar3S);
            Assert.IsNull(prettyName);
            prettyName = Icu.GetPrettyICUCharName("\xDDDDD");
            Assert.IsNull(prettyName);
        }
示例#15
0
 public void Setup()
 {
     Icu.InitIcuDataDir();
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes this instance (must be called before any other methods are called).
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public void  Init()
 {
     Icu.InitIcuDataDir();
 }
示例#17
0
 public void CharacterPropertyOverrides()
 {
     Icu.InitIcuDataDir();
     Icu.UCharCategory result = Icu.GetCharType('\xF171');
     Assert.That(result, Is.EqualTo(Icu.UCharCategory.U_NON_SPACING_MARK));
 }
示例#18
0
 public void TestFixtureSetup()
 {
     Icu.InitIcuDataDir();
 }