[Libreoffice-commits] .: Branch 'feature/cmclayouttrans' - 2 commits - solenv/bin vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 30 04:43:36 PDT 2012


 solenv/bin/uilangfilter.xslt  |   11 +++---
 vcl/inc/vcl/builder.hxx       |    4 +-
 vcl/source/window/builder.cxx |   77 ++++++++++++++++++++++++++++++++++++------
 3 files changed, 75 insertions(+), 17 deletions(-)

New commits:
commit f53b51c3e1b498f1aa9708e81ae45c0880a3e9d5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Aug 30 12:41:18 2012 +0100

    autoconnect multi-column list stores to dropdowns
    
    Default to importing the first column into the list and the second column as
    the additional data and only considering the first column for translation
    
    Change-Id: Ic74a4550167455c83634c4112ab2b698c1d25ea1

diff --git a/solenv/bin/uilangfilter.xslt b/solenv/bin/uilangfilter.xslt
index a202b0e..42d066f 100644
--- a/solenv/bin/uilangfilter.xslt
+++ b/solenv/bin/uilangfilter.xslt
@@ -14,7 +14,7 @@
 <xsl:template match="/">
   <l><xsl:text>
</xsl:text>
   <xsl:apply-templates select="//*[*[not(self::col)]/@translatable='yes']" />
-  <xsl:apply-templates select="interface/object[data/row/col[@translatable='yes']]" />
+  <xsl:apply-templates select="interface/object[data/row/col[@id='0'][@translatable='yes']]" />
   </l>
 </xsl:template>
 
@@ -25,10 +25,10 @@
   </t><xsl:text>
</xsl:text>
 </xsl:template>
 
-<xsl:template match="col">
+<xsl:template match="col[@id='0']">
   <xsl:text> </xsl:text>
   <xsl:variable name="groupid" select="../../../@id"/>
-  <t r="stringlist" g="{str:tokenize($groupid,':')[1]}" l="{count(preceding::col[../../../@id=$groupid])}">
+  <t r="stringlist" g="{str:tokenize($groupid,':')[1]}" l="{count(preceding::col[@id='0'][../../../@id=$groupid])}">
   <xsl:copy-of select="text()" />
   </t><xsl:text>
</xsl:text>
 </xsl:template>
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index 0f6f228..ae0bc7f 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -62,7 +62,8 @@ private:
 
     struct ListStore
     {
-        std::vector<rtl::OString> m_aEntries;
+        typedef std::vector<rtl::OString> row;
+        std::vector<row> m_aEntries;
     };
 
     struct ModelAndId
@@ -189,6 +190,7 @@ private:
     void collectProperty(xmlreader::XmlReader &reader, const rtl::OString &rID, stringmap &rVec);
 
     void handleListStore(xmlreader::XmlReader &reader, const rtl::OString &rID);
+    void handleRow(xmlreader::XmlReader &reader, const rtl::OString &rID, sal_Int32 nRowIndex);
     void handleAdjustment(const rtl::OString &rID, stringmap &rProperties);
     void handleTabChild(Window *pParent, xmlreader::XmlReader &reader);
 
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 49373ee..50e6b94 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -536,7 +536,10 @@ Window *VclBuilder::insertObject(Window *pParent, const rtl::OString &rClass, co
         if (pCurrentChild->IsDialog())
             pCurrentChild->SetStyle(pCurrentChild->GetStyle() | WB_SIZEMOVE | WB_3DLOOK);
         if (pCurrentChild->GetHelpId().isEmpty())
+        {
             pCurrentChild->SetHelpId(m_sHelpRoot + m_sID);
+            fprintf(stderr, "for toplevel dialog %p %s, set helpid %s\n", this, rID.getStr(), pCurrentChild->GetHelpId().getStr());
+        }
     }
     else
     {
@@ -782,12 +785,13 @@ void VclBuilder::handleAdjustment(const rtl::OString &rID, stringmap &rPropertie
     m_pParserState->m_aAdjustments.push_back(AdjustmentAndId(rID, rProperties));
 }
 
-void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const rtl::OString &rID)
+void VclBuilder::handleRow(xmlreader::XmlReader &reader, const rtl::OString &rID, sal_Int32 nRowIndex)
 {
-    m_pParserState->m_aModels.push_back(ModelAndId(rID, new ListStore));
-
     int nLevel = 1;
-    sal_Int32 nIndex = 0;
+
+    fprintf(stderr, "handleRow for %s\n", rID.getStr());
+
+    ListStore::row aRow;
 
     while(1)
     {
@@ -807,12 +811,18 @@ void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const rtl::OStrin
             {
                 bool bTranslated = false;
                 rtl::OString sProperty, sValue;
+                sal_uInt32 nId = 0;
 
                 while (reader.nextAttribute(&nsId, &name))
                 {
-                    if (name.equals(RTL_CONSTASCII_STRINGPARAM("translatable")) && reader.getAttributeValue(false).equals(RTL_CONSTASCII_STRINGPARAM("yes")))
+                    if (name.equals(RTL_CONSTASCII_STRINGPARAM("id")))
+                    {
+                        name = reader.getAttributeValue(false);
+                        nId = rtl::OString(name.begin, name.length).toInt32();
+                    }
+                    else if (nId == 0 && name.equals(RTL_CONSTASCII_STRINGPARAM("translatable")) && reader.getAttributeValue(false).equals(RTL_CONSTASCII_STRINGPARAM("yes")))
                     {
-                        sValue = getTranslation(rID, rtl::OString::valueOf(nIndex));
+                        sValue = getTranslation(rID, rtl::OString::valueOf(nRowIndex));
                         bTranslated = !sValue.isEmpty();
                     }
                 }
@@ -823,9 +833,9 @@ void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const rtl::OStrin
                 if (!bTranslated)
                     sValue = rtl::OString(name.begin, name.length);
 
-                m_pParserState->m_aModels.back().m_pModel->m_aEntries.push_back(sValue);
-
-                ++nIndex;
+                if (aRow.size() < nId+1)
+                    aRow.resize(nId+1);
+                aRow[nId] = sValue;
             }
         }
 
@@ -837,6 +847,45 @@ void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const rtl::OStrin
         if (!nLevel)
             break;
     }
+
+    if (!aRow.empty())
+        m_pParserState->m_aModels.back().m_pModel->m_aEntries.push_back(aRow);
+}
+
+void VclBuilder::handleListStore(xmlreader::XmlReader &reader, const rtl::OString &rID)
+{
+    m_pParserState->m_aModels.push_back(ModelAndId(rID, new ListStore));
+
+    int nLevel = 1;
+    sal_Int32 nRowIndex = 0;
+
+    while(1)
+    {
+        xmlreader::Span name;
+        int nsId;
+
+        xmlreader::XmlReader::Result res = reader.nextItem(
+            xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+
+        if (res == xmlreader::XmlReader::RESULT_DONE)
+            break;
+
+        if (res == xmlreader::XmlReader::RESULT_BEGIN)
+        {
+            if (name.equals(RTL_CONSTASCII_STRINGPARAM("row")))
+                handleRow(reader, rID, nRowIndex++);
+            else
+                ++nLevel;
+        }
+
+        if (res == xmlreader::XmlReader::RESULT_END)
+        {
+            --nLevel;
+        }
+
+        if (!nLevel)
+            break;
+    }
 }
 
 Window* VclBuilder::handleObject(Window *pParent, xmlreader::XmlReader &reader)
@@ -1188,10 +1237,16 @@ bool VclBuilder::replace(rtl::OString sID, Window &rReplacement)
 
 void VclBuilder::mungemodel(ListBox &rTarget, ListStore &rStore)
 {
-    for (std::vector<rtl::OString>::iterator aI = rStore.m_aEntries.begin(), aEnd = rStore.m_aEntries.end();
+    for (std::vector<ListStore::row>::iterator aI = rStore.m_aEntries.begin(), aEnd = rStore.m_aEntries.end();
         aI != aEnd; ++aI)
     {
-        rTarget.InsertEntry(rtl::OStringToOUString(*aI, RTL_TEXTENCODING_UTF8));
+        const ListStore::row &rRow = *aI;
+        sal_uInt16 nEntry = rTarget.InsertEntry(rtl::OStringToOUString(rRow[0], RTL_TEXTENCODING_UTF8));
+        if (rRow.size() > 1)
+        {
+            sal_IntPtr nValue = rRow[1].toInt32();
+            rTarget.SetEntryData(nEntry, (void*)nValue);
+        }
     }
     if (!rStore.m_aEntries.empty())
         rTarget.SelectEntryPos(0);
commit 544abf340ef9caf8d1f400a7795cb4c15b92da96
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Aug 30 12:36:10 2012 +0100

    substring-before doesn't do what I want, tokenize instead
    
    Change-Id: Id1c05366c429760780ece462db0ad1908fc19da1

diff --git a/solenv/bin/uilangfilter.xslt b/solenv/bin/uilangfilter.xslt
index bf58014..a202b0e 100644
--- a/solenv/bin/uilangfilter.xslt
+++ b/solenv/bin/uilangfilter.xslt
@@ -7,7 +7,8 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
 -->
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+  xmlns:str="http://exslt.org/strings">
   <xsl:output method="xml" encoding="UTF-8"/>
 
 <xsl:template match="/">
@@ -19,7 +20,7 @@
 
 <xsl:template match="*/*[not(self::col)][@translatable]">
   <xsl:text> </xsl:text>
-  <t r="string" g="{substring-before(../@id,':')}" l="{@name}">
+  <t r="string" g="{str:tokenize(../@id,':')[1]}" l="{@name}">
   <xsl:copy-of select="text()" />
   </t><xsl:text>
</xsl:text>
 </xsl:template>
@@ -27,7 +28,7 @@
 <xsl:template match="col">
   <xsl:text> </xsl:text>
   <xsl:variable name="groupid" select="../../../@id"/>
-  <t r="stringlist" g="{substring-before($groupid,':')}" l="{count(preceding::col[../../../@id=$groupid])}">
+  <t r="stringlist" g="{str:tokenize($groupid,':')[1]}" l="{count(preceding::col[../../../@id=$groupid])}">
   <xsl:copy-of select="text()" />
   </t><xsl:text>
</xsl:text>
 </xsl:template>


More information about the Libreoffice-commits mailing list