summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-08-30 12:41:18 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-09-28 08:48:43 +0100
commit19863833be0cfc8b72cee5bbc7ebf32f0c423468 (patch)
tree54095c1015911eb7c85017bbb78535c27da687c2
parentb9fbb89eab7ea1f7b5e7b65c95d39f6d67fb269a (diff)
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
-rw-r--r--solenv/bin/uilangfilter.xslt6
-rw-r--r--vcl/inc/vcl/builder.hxx4
-rw-r--r--vcl/source/window/builder.cxx77
3 files changed, 72 insertions, 15 deletions
diff --git a/solenv/bin/uilangfilter.xslt b/solenv/bin/uilangfilter.xslt
index a202b0e96637..42d066faee63 100644
--- a/solenv/bin/uilangfilter.xslt
+++ b/solenv/bin/uilangfilter.xslt
@@ -14,7 +14,7 @@
<xsl:template match="/">
<l><xsl:text>&#10;</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>&#10;</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>&#10;</xsl:text>
</xsl:template>
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index 0f6f2282c2c5..ae0bc7fb7e51 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 49373ee4f39f..50e6b94eb62b 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);