LCOV - code coverage report
Current view: top level - i18npool/source/localedata - filewriter.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 114 0.0 %
Date: 2014-04-14 Functions: 0 21 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <stdio.h>
      21             : #include <string.h>
      22             : #include "LocaleNode.hxx"
      23             : 
      24             : // The document handler, which is needed for the saxparser
      25             : // The Documenthandler for reading sax
      26             : 
      27           0 : OFileWriter::OFileWriter(const char *pcFile, const char *locale ) {
      28             : 
      29           0 :     strncpy( m_pcFile , pcFile, sizeof(m_pcFile) );
      30           0 :     m_pcFile[sizeof(m_pcFile)-1] = 0;
      31           0 :     printf("file generated=%s\n", m_pcFile);
      32           0 :     m_f = fopen( m_pcFile , "w" );
      33           0 :     strncpy( theLocale, locale, sizeof(theLocale) );
      34           0 :     theLocale[sizeof(theLocale)-1] = 0;
      35           0 : }
      36             : 
      37           0 : OFileWriter::~OFileWriter() {
      38           0 :     if(m_f)
      39           0 :         fclose( m_f );
      40           0 : }
      41             : 
      42           0 : void OFileWriter::writeInt(sal_Int16 nb) const
      43             : {
      44           0 :     fprintf(m_f, "%d", nb);
      45           0 : }
      46             : 
      47           0 : void OFileWriter::writeAsciiString(const char* str) const
      48             : {
      49           0 :     fprintf(m_f, "%s", str);
      50           0 : }
      51             : 
      52           0 : void OFileWriter::writeStringCharacters(const OUString& str) const
      53             : {
      54           0 :     for(int i = 0; i < str.getLength(); i++)
      55           0 :         fprintf(m_f, "0x%x, ", str[i]);
      56           0 : }
      57             : 
      58           0 : void OFileWriter::writeFunction(const char *func, const char *count, const char *array) const
      59             : {
      60           0 :     fprintf(m_f, "sal_Unicode **  SAL_CALL %s%s(sal_Int16& count)\n{\n", func, theLocale);
      61           0 :     fprintf(m_f, "\tcount = %s;\n", count);
      62           0 :     fprintf(m_f, "\treturn (sal_Unicode**)%s;\n}\n", array);
      63           0 : }
      64             : 
      65           0 : void OFileWriter::writeRefFunction(const char *func, const OUString& useLocale) const
      66             : {
      67           0 :     OString aRefLocale( OUStringToOString(useLocale, RTL_TEXTENCODING_ASCII_US) );
      68           0 :     const char* locale = aRefLocale.getStr();
      69           0 :     fprintf(m_f, "extern sal_Unicode **  SAL_CALL %s%s(sal_Int16& count);\n", func, locale);
      70           0 :     fprintf(m_f, "sal_Unicode **  SAL_CALL %s%s(sal_Int16& count)\n{\n", func, theLocale);
      71           0 :     fprintf(m_f, "\treturn %s%s(count);\n}\n", func, locale);
      72           0 : }
      73             : 
      74           0 : void OFileWriter::writeFunction(const char *func, const char *count, const char *array, const char *from, const char *to) const
      75             : {
      76           0 :     fprintf(m_f, "sal_Unicode **  SAL_CALL %s%s(sal_Int16& count, const sal_Unicode*& from, const sal_Unicode*& to)\n{\n", func, theLocale);
      77           0 :     fprintf(m_f, "\tcount = %s;\n", count);
      78           0 :     fprintf(m_f, "\tfrom = %s;\n", from);
      79           0 :     fprintf(m_f, "\tto = %s;\n", to);
      80           0 :     fprintf(m_f, "\treturn (sal_Unicode**)%s;\n}\n", array);
      81           0 : }
      82             : 
      83           0 : void OFileWriter::writeRefFunction(const char *func, const OUString& useLocale, const char *to) const
      84             : {
      85           0 :     OString aRefLocale( OUStringToOString(useLocale, RTL_TEXTENCODING_ASCII_US) );
      86           0 :     const char* locale = aRefLocale.getStr();
      87           0 :     fprintf(m_f, "extern sal_Unicode **  SAL_CALL %s%s(sal_Int16& count, const sal_Unicode*& from, const sal_Unicode*& to);\n", func, locale);
      88           0 :     fprintf(m_f, "sal_Unicode **  SAL_CALL %s%s(sal_Int16& count, const sal_Unicode*& from, const sal_Unicode*& to)\n{\n", func, theLocale);
      89           0 :     fprintf(m_f, "\tto = %s;\n", to);
      90           0 :     fprintf(m_f, "\tconst sal_Unicode* tmp;\n");
      91           0 :     fprintf(m_f, "\treturn %s%s(count, from, tmp);\n}\n", func, locale);
      92           0 : }
      93             : 
      94           0 : void OFileWriter::writeFunction2(const char *func, const char *style, const char* attr, const char *array) const
      95             : {
      96           0 :     fprintf(m_f, "const sal_Unicode ***  SAL_CALL %s%s( sal_Int16& nStyles, sal_Int16& nAttributes )\n{\n", func, theLocale);
      97           0 :     fprintf(m_f, "\tnStyles     = %s;\n", style);
      98           0 :     fprintf(m_f, "\tnAttributes = %s;\n", attr);
      99           0 :     fprintf(m_f, "\treturn %s;\n}\n", array);
     100           0 : }
     101             : 
     102           0 : void OFileWriter::writeRefFunction2(const char *func, const OUString& useLocale) const
     103             : {
     104           0 :     OString aRefLocale( OUStringToOString(useLocale, RTL_TEXTENCODING_ASCII_US) );
     105           0 :     const char* locale = aRefLocale.getStr();
     106           0 :     fprintf(m_f, "extern const sal_Unicode ***  SAL_CALL %s%s(sal_Int16& nStyles, sal_Int16& nAttributes);\n", func, locale);
     107           0 :     fprintf(m_f, "const sal_Unicode ***  SAL_CALL %s%s(sal_Int16& nStyles, sal_Int16& nAttributes)\n{\n", func, theLocale);
     108           0 :     fprintf(m_f, "\treturn %s%s(nStyles, nAttributes);\n}\n", func, locale);
     109           0 : }
     110             : 
     111           0 : void OFileWriter::writeFunction3(const char *func, const char *style, const char* levels, const char* attr, const char *array) const
     112             : {
     113           0 :     fprintf(m_f, "const sal_Unicode ****  SAL_CALL %s%s( sal_Int16& nStyles, sal_Int16& nLevels, sal_Int16& nAttributes )\n{\n", func, theLocale);
     114           0 :     fprintf(m_f, "\tnStyles     = %s;\n", style);
     115           0 :     fprintf(m_f, "\tnLevels     = %s;\n", levels);
     116           0 :     fprintf(m_f, "\tnAttributes = %s;\n", attr);
     117           0 :     fprintf(m_f, "\treturn %s;\n}\n", array);
     118           0 : }
     119             : 
     120           0 : void OFileWriter::writeRefFunction3(const char *func, const OUString& useLocale) const
     121             : {
     122           0 :     OString aRefLocale( OUStringToOString(useLocale, RTL_TEXTENCODING_ASCII_US) );
     123           0 :     const char* locale = aRefLocale.getStr();
     124           0 :     fprintf(m_f, "extern const sal_Unicode ****  SAL_CALL %s%s(sal_Int16& nStyles, sal_Int16& nLevels, sal_Int16& nAttributes);\n", func, locale);
     125           0 :     fprintf(m_f, "const sal_Unicode ****  SAL_CALL %s%s(sal_Int16& nStyles, sal_Int16& nLevels, sal_Int16& nAttributes)\n{\n", func, theLocale);
     126           0 :     fprintf(m_f, "\treturn %s%s(nStyles, nLevels, nAttributes);\n}\n", func, locale);
     127           0 : }
     128             : 
     129           0 : void OFileWriter::writeIntParameter(const sal_Char* pAsciiStr, const sal_Int16 count, sal_Int16 val) const
     130             : {
     131           0 :     fprintf(m_f, "static const sal_Unicode %s%d[] = {%d};\n", pAsciiStr, count, val);
     132           0 : }
     133             : 
     134           0 : bool OFileWriter::writeDefaultParameter(const sal_Char* pAsciiStr, const OUString& str, sal_Int16 count) const
     135             : {
     136           0 :     bool bBool = (str == "true" ? 1 : 0);
     137           0 :     fprintf(m_f,"static const sal_Unicode default%s%d[] = {%d};\n", pAsciiStr, count, bBool);
     138           0 :     return bBool;
     139             : }
     140             : 
     141           0 : void OFileWriter::writeParameter(const sal_Char* pAsciiStr, const OUString& aChars) const
     142             : {
     143           0 :     fprintf(m_f, "static const sal_Unicode %s[] = {", pAsciiStr);
     144           0 :     writeStringCharacters(aChars);
     145           0 :     fprintf(m_f, "0x0};\n");
     146           0 : }
     147             : 
     148           0 : void OFileWriter::writeParameter(const sal_Char* pAsciiStr, const OUString& aChars, sal_Int16 count) const
     149             : {
     150           0 :     fprintf(m_f, "static const sal_Unicode %s%d[] = {", pAsciiStr, count);
     151           0 :     writeStringCharacters(aChars);
     152           0 :     fprintf(m_f, "0x0};\n");
     153           0 : }
     154             : 
     155           0 : void OFileWriter::writeParameter(const sal_Char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const
     156             : {
     157           0 :     fprintf(m_f, "static const sal_Unicode %s%d%d[] = {", pAsciiStr, count0, count1);
     158           0 :     writeStringCharacters(aChars);
     159           0 :     fprintf(m_f, "0x0};\n");
     160           0 : }
     161             : 
     162           0 : void OFileWriter::writeParameter(const sal_Char* pTagStr, const sal_Char* pAsciiStr, const OUString& aChars, const sal_Int16 count) const
     163             : {
     164           0 :     fprintf(m_f, "static const sal_Unicode %s%s%d[] = {", pTagStr, pAsciiStr, count);
     165           0 :     writeStringCharacters(aChars);
     166           0 :     fprintf(m_f, "0x0};\n");
     167           0 : }
     168             : 
     169           0 : void OFileWriter::writeParameter(const sal_Char* pTagStr, const sal_Char* pAsciiStr, const OUString& aChars, sal_Int16 count0, sal_Int16 count1) const
     170             : {
     171           0 :     fprintf(m_f, "static const sal_Unicode %s%s%d%d[] = {", pTagStr, pAsciiStr, count0, count1);
     172           0 :     writeStringCharacters(aChars);
     173           0 :     fprintf(m_f, "0x0};\n");
     174           0 : }
     175             : 
     176           0 : void OFileWriter::closeOutput(void) const
     177             : {
     178           0 :     if(m_f)
     179             :     {
     180           0 :         fclose( m_f );
     181           0 :         const_cast< OFileWriter * > ( this )->m_f = 0;
     182             :     }
     183           0 : }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10