[Libreoffice-commits] .: 5 commits - l10ntools/inc l10ntools/source sdext/source

Andras Timar timar at kemper.freedesktop.org
Fri Sep 30 14:49:21 PDT 2011


 l10ntools/inc/tokens.h                        |   22 ++-
 l10ntools/source/directory.cxx                |    4 
 l10ntools/source/xrmlex.l                     |   25 ++++
 l10ntools/source/xrmmerge.cxx                 |  147 ++++++++++++++++----------
 sdext/source/minimizer/description.xml        |    4 
 sdext/source/minimizer/manifest.xml           |    2 
 sdext/source/pdfimport/config/description.xml |    4 
 sdext/source/pdfimport/config/manifest.xml    |    2 
 sdext/source/presenter/description.xml        |    4 
 sdext/source/presenter/manifest.xml           |    2 
 10 files changed, 145 insertions(+), 71 deletions(-)

New commits:
commit a91a7567e7a2ee3db87b0f9a9523be3f55ac93b2
Author: Andras Timar <atimar at suse.com>
Date:   Fri Sep 30 23:47:55 2011 +0200

    extract strings for l10n from description.xml files
    
    Merging is to be implemented...

diff --git a/l10ntools/inc/tokens.h b/l10ntools/inc/tokens.h
index 8898f34..0c69d0e 100644
--- a/l10ntools/inc/tokens.h
+++ b/l10ntools/inc/tokens.h
@@ -98,6 +98,18 @@
 #define XRM_TEXT_END                508
 #define XML_TEXTCHAR                600
 
+/*------------------------------------------------------                    */
+/*------------------------------------------------------                    */
+/* Tokens for parsing description.xml files                                 */
+/*------------------------------------------------------                    */
+/*------------------------------------------------------                    */
+#define DESC_DISPLAY_NAME_START          700
+#define DESC_DISPLAY_NAME_END            701
+#define DESC_TEXT_START                  702
+#define DESC_TEXT_END                    703
+#define DESC_EXTENSION_DESCRIPTION_START 704
+#define DESC_EXTENSION_DESCRIPTION_END   705
+#define DESC_EXTENSION_DESCRIPTION_SRC   706
 
 #endif
 
diff --git a/l10ntools/source/xrmlex.l b/l10ntools/source/xrmlex.l
index de5b5df..b7dccbd 100644
--- a/l10ntools/source/xrmlex.l
+++ b/l10ntools/source/xrmlex.l
@@ -99,8 +99,33 @@ int bText=0;
 	WorkOnTokenSet( XRM_TEXT_END, yytext );
 }
 
+"<display-name>" {
+	WorkOnTokenSet( DESC_DISPLAY_NAME_START , yytext );
+}
+
+"</display-name>" {
+	WorkOnTokenSet( DESC_DISPLAY_NAME_END, yytext );
+}
 
+"<name "[^\>]*lang[^\>]*\> {
+	WorkOnTokenSet( DESC_TEXT_START , yytext );
+}
+
+"</name>" {
+	WorkOnTokenSet( DESC_TEXT_END, yytext );
+}
 
+"<extension-description>" {
+	WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_START , yytext );
+}
+
+"</extension-description>" {
+	WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_END , yytext );
+}
+
+"<src "[^\>]*lang[^\>]*\> {
+	WorkOnTokenSet( DESC_EXTENSION_DESCRIPTION_SRC , yytext );
+}
 
 
 
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index a17ecf2..8a0ca98 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -37,6 +37,7 @@
 #include "xrmmerge.hxx"
 #include "tokens.h"
 #include <iostream>
+#include <fstream>
 #include <vector>
 
 using namespace std;
@@ -59,12 +60,16 @@ sal_Bool bEnableExport;
 sal_Bool bMergeMode;
 sal_Bool bErrorLog;
 sal_Bool bUTF8;
+sal_Bool bDisplayName;
+sal_Bool bExtensionDescription;
 ByteString sPrj;
 ByteString sPrjRoot;
 ByteString sInputFileName;
 ByteString sActFileName;
 ByteString sOutputFile;
 ByteString sMergeSrc;
+ByteString sLangAttribute;
+ByteString sResourceType;
 String sUsedTempFile;
 XRMResParser *pParser = NULL;
 
@@ -79,6 +84,8 @@ extern char *GetOutputFile( int argc, char* argv[])
     bMergeMode = sal_False;
     bErrorLog = sal_True;
     bUTF8 = sal_True;
+    bDisplayName = sal_False;
+    bExtensionDescription = sal_False;
     sPrj = "";
     sPrjRoot = "";
     sInputFileName = "";
@@ -296,34 +303,115 @@ int XRMResParser::Execute( int nToken, char * pToken )
 
     switch ( nToken ) {
         case XRM_TEXT_START:{
-                //printf("->XRM_TEXT_START\n");
                 ByteString sNewLID = GetAttribute( rToken, "id" );
                 if ( sNewLID != sLID ) {
-                    //EndOfText( sCurrentOpenTag, sCurrentCloseTag );
                     sLID = sNewLID;
                 }
                 bText = sal_True;
                 sCurrentText = "";
                 sCurrentOpenTag = rToken;
                 Output( rToken );
-                //printf("<-XRM_TEXT_START\n");
             }
         break;
 
         case XRM_TEXT_END: {
                 sCurrentCloseTag = rToken;
-                //printf("->XRM_TEXT_END\n");
-                ByteString sLang = GetAttribute( sCurrentOpenTag, "xml:lang" );
+                sResourceType = ByteString ( "readmeitem" );
+                sLangAttribute = ByteString ( "xml:lang" );
+                ByteString sLang = GetAttribute( sCurrentOpenTag, sLangAttribute );
                 WorkOnText( sCurrentOpenTag, sCurrentText );
                 Output( sCurrentText );
                 EndOfText( sCurrentOpenTag, sCurrentCloseTag );
                 bText = sal_False;
                 rToken = ByteString("");
                 sCurrentText  = ByteString("");
-                //printf("<-XRM_TEXT_END");
         }
         break;
 
+        case DESC_DISPLAY_NAME_START:{
+                bDisplayName = sal_True;
+            }
+        break;
+
+        case DESC_DISPLAY_NAME_END:{
+                bDisplayName = sal_False;
+            }
+        break;
+
+        case DESC_TEXT_START:{
+                if (bDisplayName) {
+                    sLID = ByteString("dispname");
+                    bText = sal_True;
+                    sCurrentText = "";
+                    sCurrentOpenTag = rToken;
+                    Output( rToken );
+                }
+            }
+        break;
+
+        case DESC_TEXT_END: {
+                if (bDisplayName) {
+                    sCurrentCloseTag = rToken;
+                    sResourceType = ByteString ( "description" );
+                    sLangAttribute = ByteString ( "lang" );
+                    ByteString sLang = GetAttribute( sCurrentOpenTag, sLangAttribute );
+                    WorkOnText( sCurrentOpenTag, sCurrentText );
+                    Output( sCurrentText );
+                    EndOfText( sCurrentOpenTag, sCurrentCloseTag );
+                    bText = sal_False;
+                    rToken = ByteString("");
+                    sCurrentText  = ByteString("");
+                }
+        }
+        break;
+
+        case DESC_EXTENSION_DESCRIPTION_START: {
+                bExtensionDescription = sal_True;
+            }
+        break;
+
+        case DESC_EXTENSION_DESCRIPTION_END: {
+                bExtensionDescription = sal_False;
+            }
+        break;
+
+        case DESC_EXTENSION_DESCRIPTION_SRC: {
+                if (bExtensionDescription) {
+                    sLID = ByteString("extdesc");
+                    sResourceType = ByteString ( "description" );
+                    sLangAttribute = ByteString ( "lang" );
+                    sCurrentOpenTag = rToken;
+                    sCurrentText  = ByteString("");
+                    Output( rToken );
+                    DirEntry aEntry( String( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
+                    aEntry.ToAbs();
+                    ByteString sDescFileName( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
+                    sDescFileName.SearchAndReplaceAll( "description.xml", "" );
+                    sDescFileName += GetAttribute( sCurrentOpenTag, "xlink:href" );
+                    ifstream::pos_type size;
+                    char * memblock;
+                    ifstream file (sDescFileName.GetBuffer(), ios::in|ios::binary|ios::ate);
+                    if (file.is_open()) {
+                        size = file.tellg();
+                        memblock = new char [size];
+                        file.seekg (0, ios::beg);
+                        file.read (memblock, size);
+                        file.close();
+                        sCurrentText = ByteString(memblock);
+                        sCurrentText.SearchAndReplaceAll( "\n", "\\n" );
+                        delete[] memblock;
+                    }
+                    ByteString sLang = GetAttribute( sCurrentOpenTag, sLangAttribute );
+                    WorkOnText( sCurrentOpenTag, sCurrentText );
+                    sCurrentCloseTag = rToken;
+                    Output( sCurrentText );
+                    EndOfText( sCurrentOpenTag, sCurrentCloseTag );
+                    rToken = ByteString("");
+                    sCurrentText  = ByteString("");
+                }
+            }
+        break;
+
         default:
             if ( bText ) {
                 sCurrentText += rToken;
@@ -461,7 +549,7 @@ void XRMResExport::WorkOnText(
 )
 /*****************************************************************************/
 {
-    ByteString sLang( GetAttribute( rOpenTag, "xml:lang" ));
+    ByteString sLang( GetAttribute( rOpenTag, sLangAttribute ));
 
     if ( !pResData )
     {
@@ -498,7 +586,8 @@ void XRMResExport::EndOfText(
                 ByteString sOutput( sPrj ); sOutput += "\t";
                 sOutput += sPath;
                 sOutput += "\t0\t";
-                sOutput += "readmeitem\t";
+                sOutput += sResourceType;
+                sOutput += "\t";
                 sOutput += pResData->sId;
                 // USE LID AS GID OR MERGE DON'T WORK
                 //sOutput += pResData->sGId;
commit ca2235e871582fe3957d4d18173bb033d1384cd8
Author: Andras Timar <atimar at suse.com>
Date:   Fri Sep 30 16:35:59 2011 +0200

    upgrade to the newer extension description scheme

diff --git a/sdext/source/minimizer/description.xml b/sdext/source/minimizer/description.xml
index e310dc1..b0bc64a 100644
--- a/sdext/source/minimizer/description.xml
+++ b/sdext/source/minimizer/description.xml
@@ -27,4 +27,8 @@
       <default xlink:href="bitmaps/extension_32.png" />
     </icon>
 
+    <extension-description>
+      <src xlink:href="help/component.txt" lang="en-US" />
+    </extension-desciption>
+
 </description>
diff --git a/sdext/source/minimizer/manifest.xml b/sdext/source/minimizer/manifest.xml
index eac1895..5f86b4d 100644
--- a/sdext/source/minimizer/manifest.xml
+++ b/sdext/source/minimizer/manifest.xml
@@ -11,6 +11,4 @@
                        manifest:full-path="registry/data/org/openoffice/Office/Addons.xcu"/>
   <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
                        manifest:full-path="registry/data/org/openoffice/Office/ProtocolHandler.xcu"/>
-  <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description"
-                       manifest:full-path="help/component.txt"/>
 </manifest:manifest>
diff --git a/sdext/source/pdfimport/config/description.xml b/sdext/source/pdfimport/config/description.xml
index 5a88a48..8301167 100644
--- a/sdext/source/pdfimport/config/description.xml
+++ b/sdext/source/pdfimport/config/description.xml
@@ -26,4 +26,8 @@
       <default xlink:href="images/extension_32.png" />
     </icon>
 
+    <extension-description>
+      <src xlink:href="help/component.txt" lang="en-US" />
+    </extension-desciption>
+
 </description>
diff --git a/sdext/source/pdfimport/config/manifest.xml b/sdext/source/pdfimport/config/manifest.xml
index 013f2a1..834526d 100644
--- a/sdext/source/pdfimport/config/manifest.xml
+++ b/sdext/source/pdfimport/config/manifest.xml
@@ -11,6 +11,4 @@
                        manifest:full-path="pdf_types.xcu"/>
   <manifest:file-entry manifest:media-type="application/vnd.sun.star.basic-library"
                        manifest:full-path="basic/"/>
-  <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description"
-                       manifest:full-path="help/component.txt"/>
 </manifest:manifest>
diff --git a/sdext/source/presenter/description.xml b/sdext/source/presenter/description.xml
index 8991954..6435733 100644
--- a/sdext/source/presenter/description.xml
+++ b/sdext/source/presenter/description.xml
@@ -27,4 +27,8 @@
     <default xlink:href="bitmaps/extension_32.png" />
   </icon>
 
+  <extension-description>
+    <src xlink:href="help/component.txt" lang="en-US" />
+  </extension-desciption>
+
 </description>
diff --git a/sdext/source/presenter/manifest.xml b/sdext/source/presenter/manifest.xml
index 7466467..bb79f9e 100644
--- a/sdext/source/presenter/manifest.xml
+++ b/sdext/source/presenter/manifest.xml
@@ -13,6 +13,4 @@
     manifest:full-path="registry/schema/org/openoffice/Office/extension/PresenterScreen.xcs"/>
   <manifest:file-entry manifest:media-type="application/vnd.sun.star.help"
     manifest:full-path="help"/>
-  <manifest:file-entry manifest:media-type="application/vnd.sun.star.package-bundle-description"
-    manifest:full-path="help/component.txt"/>
 </manifest:manifest>
commit 7969f909e2dd524d420aa874c7322f6feb3765e4
Author: Andras Timar <atimar at suse.com>
Date:   Fri Sep 30 15:31:20 2011 +0200

    fix error messages

diff --git a/l10ntools/source/directory.cxx b/l10ntools/source/directory.cxx
index 85663a3..5830d73 100644
--- a/l10ntools/source/directory.cxx
+++ b/l10ntools/source/directory.cxx
@@ -192,7 +192,7 @@ void Directory::readDirectory( const rtl::OUString& sFullpath )
     // stat
     if( stat( sFullpathext.getStr(), &statbuf ) < 0 )
     {
-        printf("warning: Can not stat %s" , sFullpathext.getStr() );
+        printf("warning: Cannot stat %s \n" , sFullpathext.getStr() );
         return;
     }
 
@@ -201,7 +201,7 @@ void Directory::readDirectory( const rtl::OUString& sFullpath )
 
     if( (dir = opendir( sFullpathext.getStr() ) ) == NULL  )
     {
-        printf("readerror 2 in %s \n",sFullpathext.getStr());
+        printf("read error 2 in %s \n",sFullpathext.getStr());
         return;
     }
 
commit 0bb5161900b743b95bc1431674b722d1e8d8ca1a
Author: Andras Timar <atimar at suse.com>
Date:   Fri Sep 30 11:38:07 2011 +0200

    typo in comment

diff --git a/l10ntools/inc/tokens.h b/l10ntools/inc/tokens.h
index 3068c6f..8898f34 100644
--- a/l10ntools/inc/tokens.h
+++ b/l10ntools/inc/tokens.h
@@ -57,7 +57,7 @@
 #define LEVELUP             509         /* {                                */
 #define LEVELDOWN           510         /* };                               */
 #define APPFONTMAPPING      511         /* MAP_APPFONT(10,10)               */
-#define ASSIGNMENT          512         /* Somathing = Anything             */
+#define ASSIGNMENT          512         /* Something = Anything             */
 #define LISTASSIGNMENT      513         /* ...List [xyz]=...                */
 #define LISTTEXT            514         /* < "Text" ... >                   */
 #define RSCDEFINE           515         /* #define MY_TEXT                  */
commit 397a67a7ad8a31f352714099b57a6e0e8eb30434
Author: Andras Timar <atimar at suse.com>
Date:   Fri Sep 30 11:37:44 2011 +0200

    remove unused tokens

diff --git a/l10ntools/inc/tokens.h b/l10ntools/inc/tokens.h
index b8c658e..3068c6f 100644
--- a/l10ntools/inc/tokens.h
+++ b/l10ntools/inc/tokens.h
@@ -94,16 +94,8 @@
 /* Tokens for parsing xrm files                                             */
 /*------------------------------------------------------                    */
 /*------------------------------------------------------                    */
-#define XRM_README_START            501
-#define XRM_README_END              502
-#define XRM_SECTION_START           503
-#define XRM_SECTION_END             504
-#define XRM_PARAGRAPH_START         505
-#define XRM_PARAGRAPH_END           506
 #define XRM_TEXT_START              507
 #define XRM_TEXT_END                508
-#define XRM_LIST_START              509
-#define XRM_LIST_END                510
 #define XML_TEXTCHAR                600
 
 
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 36e888d..a17ecf2 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -295,47 +295,6 @@ int XRMResParser::Execute( int nToken, char * pToken )
     ByteString rToken( pToken );
 
     switch ( nToken ) {
-        case XRM_README_START:
-            sLID = "";
-            sGID = GetAttribute( rToken, "name" );
-        break;
-
-        case XRM_README_END:
-            sGID = "";
-        break;
-
-        case XRM_SECTION_START:
-            sLID = "";
-            sGID += ".";
-            sGID += GetAttribute( rToken, "id" );
-            sLocalized = true;
-        break;
-
-        case XRM_SECTION_END:
-            sGID = sGID.GetToken( 0, '.' );
-            break;
-
-        case XRM_PARAGRAPH_START:
-            sLID = "";
-            sGID += ".";
-            sGID += GetAttribute( rToken, "id" );
-                sLocalized = true;
-        break;
-
-        case XRM_PARAGRAPH_END: {
-            if ( sLID.Len())
-                EndOfText( sCurrentOpenTag, sCurrentCloseTag );
-            ByteString sTmp = sGID;
-            sGID = "";
-            for ( sal_uInt16 i = 0; i + 1 < sTmp.GetTokenCount( '.' ); i++ ) {
-                if ( sGID.Len())
-                    sGID += ".";
-                sGID += sTmp.GetToken( i, '.' );
-            }
-            //sLocalized = sLocalized.Copy( 0, sLocalized.Len() - 1 );
-           }
-        break;
-
         case XRM_TEXT_START:{
                 //printf("->XRM_TEXT_START\n");
                 ByteString sNewLID = GetAttribute( rToken, "id" );
@@ -365,15 +324,6 @@ int XRMResParser::Execute( int nToken, char * pToken )
         }
         break;
 
-        case XRM_LIST_START:
-            sLID = "";
-        break;
-
-        case XRM_LIST_END:
-            if ( sLID.Len())
-                EndOfText( sCurrentOpenTag, sCurrentCloseTag );
-        break;
-
         default:
             if ( bText ) {
                 sCurrentText += rToken;


More information about the Libreoffice-commits mailing list