2012-03-26 12:15:22 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.)
|
2012-03-27 14:20:17 +01:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2012 the
|
2012-03-26 12:15:22 +01:00
|
|
|
* Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Caolán McNamara <caolanm@redhat.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
|
|
|
|
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
|
|
|
|
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
|
|
|
|
* instead of those above.
|
|
|
|
*/
|
|
|
|
|
2012-08-29 14:16:04 +01:00
|
|
|
#include <osl/module.hxx>
|
2012-09-25 11:35:47 +01:00
|
|
|
#include <sal/log.hxx>
|
2012-03-26 12:15:22 +01:00
|
|
|
#include <vcl/builder.hxx>
|
|
|
|
#include <vcl/button.hxx>
|
|
|
|
#include <vcl/dialog.hxx>
|
2012-03-27 14:32:24 +01:00
|
|
|
#include <vcl/edit.hxx>
|
2012-04-04 09:30:41 +01:00
|
|
|
#include <vcl/field.hxx>
|
2012-03-26 12:15:22 +01:00
|
|
|
#include <vcl/fixed.hxx>
|
|
|
|
#include <vcl/layout.hxx>
|
2012-04-04 09:30:41 +01:00
|
|
|
#include <vcl/lstbox.hxx>
|
2012-08-07 15:27:51 +01:00
|
|
|
#include <vcl/svapp.hxx>
|
2012-06-07 15:11:02 +01:00
|
|
|
#include <vcl/tabctrl.hxx>
|
|
|
|
#include <vcl/tabpage.hxx>
|
2012-08-29 22:08:56 +01:00
|
|
|
#include <svdata.hxx>
|
|
|
|
#include <svids.hrc>
|
2012-05-22 12:33:28 +01:00
|
|
|
#include <window.h>
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-08-16 14:04:00 +01:00
|
|
|
VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUIDir, rtl::OUString sUIFile, rtl::OString sID)
|
2012-04-25 11:12:55 +01:00
|
|
|
: m_sID(sID)
|
2012-08-16 14:04:00 +01:00
|
|
|
, m_sHelpRoot(rtl::OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8))
|
2012-04-25 11:12:55 +01:00
|
|
|
, m_pParent(pParent)
|
2012-08-23 15:38:30 +01:00
|
|
|
, m_pParserState(new ParserState)
|
2012-03-26 12:15:22 +01:00
|
|
|
{
|
2012-08-16 14:04:00 +01:00
|
|
|
sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.');
|
|
|
|
if (nIdx != -1)
|
|
|
|
m_sHelpRoot = m_sHelpRoot.copy(0, nIdx);
|
|
|
|
m_sHelpRoot = m_sHelpRoot + rtl::OString('/');
|
|
|
|
|
|
|
|
rtl::OUString sUri = sUIDir + sUIFile;
|
|
|
|
|
2012-08-07 15:27:51 +01:00
|
|
|
::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
|
|
|
|
for (int i = aLocale.Country.isEmpty() ? 1 : 0; i < 2; ++i)
|
|
|
|
{
|
|
|
|
rtl::OUStringBuffer aTransBuf;
|
|
|
|
sal_Int32 nLastSlash = sUri.lastIndexOf('/');
|
|
|
|
aTransBuf.append(sUri.copy(0, nLastSlash)).append("/res/").append(aLocale.Language);
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
aTransBuf.append('-').append(aLocale.Country);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
aTransBuf.append(sUri.copy(nLastSlash));
|
|
|
|
|
|
|
|
rtl::OUString sTransUri = aTransBuf.makeStringAndClear();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xmlreader::XmlReader reader(sTransUri);
|
|
|
|
handleTranslations(reader);
|
|
|
|
}
|
|
|
|
catch (const ::com::sun::star::uno::Exception &)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
xmlreader::XmlReader reader(sUri);
|
|
|
|
|
2012-03-27 14:20:17 +01:00
|
|
|
handleChild(pParent, reader);
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-04-30 10:19:19 +01:00
|
|
|
//Set radiobutton groups when everything has been imported
|
2012-08-23 15:38:30 +01:00
|
|
|
for (std::vector<RadioButtonGroupMap>::iterator aI = m_pParserState->m_aGroupMaps.begin(),
|
|
|
|
aEnd = m_pParserState->m_aGroupMaps.end(); aI != aEnd; ++aI)
|
2012-04-30 10:19:19 +01:00
|
|
|
{
|
2012-08-22 21:18:52 +01:00
|
|
|
RadioButton *pOne = get<RadioButton>(aI->m_sID);
|
|
|
|
RadioButton *pOther = get<RadioButton>(aI->m_sValue);
|
2012-04-30 10:19:19 +01:00
|
|
|
SAL_WARN_IF(!pOne || !pOther, "vcl", "missing member of radiobutton group");
|
|
|
|
if (pOne && pOther)
|
|
|
|
pOne->group(*pOther);
|
|
|
|
}
|
2012-06-06 08:56:46 +01:00
|
|
|
|
|
|
|
//Set ComboBox models when everything has been imported
|
2012-08-23 15:38:30 +01:00
|
|
|
for (std::vector<ComboBoxModelMap>::iterator aI = m_pParserState->m_aModelMaps.begin(),
|
|
|
|
aEnd = m_pParserState->m_aModelMaps.end(); aI != aEnd; ++aI)
|
2012-06-06 08:56:46 +01:00
|
|
|
{
|
2012-08-22 21:18:52 +01:00
|
|
|
ListBox *pTarget = get<ListBox>(aI->m_sID);
|
2012-06-14 14:20:49 +01:00
|
|
|
ListStore *pStore = get_model_by_name(aI->m_sValue);
|
2012-06-06 08:56:46 +01:00
|
|
|
SAL_WARN_IF(!pTarget || !pStore, "vcl", "missing elements of combobox/liststore");
|
|
|
|
if (pTarget && pStore)
|
|
|
|
mungemodel(*pTarget, *pStore);
|
|
|
|
}
|
2012-08-23 15:38:30 +01:00
|
|
|
for (std::vector<ModelAndId>::iterator aI = m_pParserState->m_aModels.begin(),
|
|
|
|
aEnd = m_pParserState->m_aModels.end(); aI != aEnd; ++aI)
|
2012-06-06 08:56:46 +01:00
|
|
|
{
|
|
|
|
delete aI->m_pModel;
|
|
|
|
}
|
2012-04-30 10:19:19 +01:00
|
|
|
|
2012-06-14 14:20:49 +01:00
|
|
|
//Set SpinButton adjustments when everything has been imported
|
2012-08-23 15:38:30 +01:00
|
|
|
for (std::vector<SpinButtonAdjustmentMap>::iterator aI = m_pParserState->m_aAdjustmentMaps.begin(),
|
|
|
|
aEnd = m_pParserState->m_aAdjustmentMaps.end(); aI != aEnd; ++aI)
|
2012-06-14 14:20:49 +01:00
|
|
|
{
|
2012-08-23 13:33:53 +01:00
|
|
|
NumericFormatter *pTarget = dynamic_cast<NumericFormatter*>(get<Window>(aI->m_sID));
|
2012-06-14 14:20:49 +01:00
|
|
|
Adjustment *pAdjustment = get_adjustment_by_name(aI->m_sValue);
|
|
|
|
SAL_WARN_IF(!pTarget || !pAdjustment, "vcl", "missing elements of spinbutton/adjustment");
|
|
|
|
if (pTarget && pAdjustment)
|
|
|
|
mungeadjustment(*pTarget, *pAdjustment);
|
|
|
|
}
|
|
|
|
|
2012-08-23 15:38:30 +01:00
|
|
|
//drop maps, etc. now
|
|
|
|
delete m_pParserState;
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VclBuilder::~VclBuilder()
|
|
|
|
{
|
2012-04-25 11:12:55 +01:00
|
|
|
for (std::vector<WinAndId>::reverse_iterator aI = m_aChildren.rbegin(),
|
2012-03-26 12:15:22 +01:00
|
|
|
aEnd = m_aChildren.rend(); aI != aEnd; ++aI)
|
|
|
|
{
|
2012-05-22 12:33:28 +01:00
|
|
|
if (aI->m_bOwned)
|
|
|
|
delete aI->m_pWindow;
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 15:27:51 +01:00
|
|
|
void VclBuilder::handleTranslations(xmlreader::XmlReader &reader)
|
|
|
|
{
|
|
|
|
xmlreader::Span name;
|
|
|
|
int nsId;
|
|
|
|
rtl::OString sType;
|
|
|
|
|
|
|
|
rtl::OString sID, sProperty;
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
xmlreader::XmlReader::Result res = reader.nextItem(
|
2012-08-29 22:08:56 +01:00
|
|
|
xmlreader::XmlReader::TEXT_RAW, &name, &nsId);
|
2012-08-07 15:27:51 +01:00
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_BEGIN)
|
|
|
|
{
|
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("e")))
|
|
|
|
{
|
|
|
|
while (reader.nextAttribute(&nsId, &name))
|
|
|
|
{
|
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("g")))
|
|
|
|
{
|
|
|
|
name = reader.getAttributeValue(false);
|
|
|
|
sID = rtl::OString(name.begin, name.length);
|
2012-08-29 15:06:48 +01:00
|
|
|
sal_Int32 nDelim = sID.indexOf(':');
|
|
|
|
if (nDelim != -1)
|
|
|
|
sID = sID.copy(nDelim);
|
2012-08-07 15:27:51 +01:00
|
|
|
}
|
|
|
|
else if (name.equals(RTL_CONSTASCII_STRINGPARAM("i")))
|
|
|
|
{
|
|
|
|
name = reader.getAttributeValue(false);
|
|
|
|
sProperty = rtl::OString(name.begin, name.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_TEXT && !sID.isEmpty())
|
|
|
|
{
|
|
|
|
rtl::OString sTranslation(name.begin, name.length);
|
2012-08-23 15:38:30 +01:00
|
|
|
m_pParserState->m_aTranslations[sID][sProperty] = sTranslation;
|
2012-08-07 15:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_END)
|
|
|
|
sID = rtl::OString();
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_DONE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-16 11:33:57 +01:00
|
|
|
namespace
|
|
|
|
{
|
2012-08-17 13:49:40 +01:00
|
|
|
rtl::OString extractPattern(VclBuilder::stringmap &rMap)
|
|
|
|
{
|
|
|
|
rtl::OString sPattern;
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("pattern")));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
|
|
|
sPattern = aFind->second;
|
|
|
|
rMap.erase(aFind);
|
|
|
|
}
|
|
|
|
return sPattern;
|
|
|
|
}
|
|
|
|
|
2012-04-16 11:33:57 +01:00
|
|
|
bool extractOrientation(VclBuilder::stringmap &rMap)
|
|
|
|
{
|
|
|
|
bool bVertical = false;
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("orientation")));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
|
|
|
bVertical = aFind->second.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("vertical"));
|
|
|
|
rMap.erase(aFind);
|
|
|
|
}
|
|
|
|
return bVertical;
|
|
|
|
}
|
|
|
|
|
2012-09-19 10:14:00 +01:00
|
|
|
bool extractInconsistent(VclBuilder::stringmap &rMap)
|
|
|
|
{
|
|
|
|
bool bInconsistent = false;
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("inconsistent")));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
|
|
|
bInconsistent = toBool(aFind->second);
|
|
|
|
rMap.erase(aFind);
|
|
|
|
}
|
|
|
|
return bInconsistent;
|
|
|
|
}
|
|
|
|
|
2012-04-16 11:33:57 +01:00
|
|
|
Window * extractStockAndBuildButton(Window *pParent, VclBuilder::stringmap &rMap)
|
|
|
|
{
|
|
|
|
WinBits nBits = WB_CENTER|WB_VCENTER|WB_3DLOOK;
|
|
|
|
|
|
|
|
bool bIsStock = false;
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("use-stock")));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
|
|
|
bIsStock = toBool(aFind->second);
|
|
|
|
rMap.erase(aFind);
|
|
|
|
}
|
|
|
|
|
|
|
|
Window *pWindow = NULL;
|
|
|
|
|
|
|
|
if (bIsStock)
|
|
|
|
{
|
|
|
|
rtl::OString sType;
|
|
|
|
aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("label")));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
|
|
|
sType = aFind->second;
|
|
|
|
rMap.erase(aFind);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-ok")))
|
|
|
|
pWindow = new OKButton(pParent, nBits);
|
|
|
|
else if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-cancel")))
|
|
|
|
pWindow = new CancelButton(pParent, nBits);
|
|
|
|
else if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-help")))
|
|
|
|
pWindow = new HelpButton(pParent, nBits);
|
2012-08-23 12:40:01 +01:00
|
|
|
else if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-media-next")))
|
|
|
|
{
|
|
|
|
PushButton *pBtn = new PushButton(pParent, nBits);
|
|
|
|
pBtn->SetSymbol(SYMBOL_NEXT);
|
|
|
|
pWindow = pBtn;
|
|
|
|
}
|
|
|
|
else if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-media-previous")))
|
|
|
|
{
|
|
|
|
PushButton *pBtn = new PushButton(pParent, nBits);
|
|
|
|
pBtn->SetSymbol(SYMBOL_PREV);
|
|
|
|
pWindow = pBtn;
|
|
|
|
}
|
2012-08-29 22:17:02 +01:00
|
|
|
else if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-close")))
|
|
|
|
{
|
|
|
|
PushButton *pBtn = new PushButton(pParent, nBits);
|
|
|
|
pBtn->SetText(VclResId(SV_BUTTONTEXT_CLOSE).toString());
|
|
|
|
pWindow = pBtn;
|
|
|
|
}
|
2012-09-18 10:35:46 +01:00
|
|
|
else if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-revert-to-saved")))
|
|
|
|
{
|
|
|
|
PushButton *pBtn = new PushButton(pParent, nBits);
|
|
|
|
pBtn->SetText(VclResId(SV_BUTTONTEXT_RESET).toString());
|
|
|
|
pWindow = pBtn;
|
|
|
|
}
|
2012-09-25 11:35:47 +01:00
|
|
|
else if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-add")))
|
|
|
|
{
|
|
|
|
PushButton *pBtn = new PushButton(pParent, nBits);
|
|
|
|
pBtn->SetText(VclResId(SV_BUTTONTEXT_ADD).toString());
|
|
|
|
pWindow = pBtn;
|
|
|
|
}
|
|
|
|
else if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("gtk-delete")))
|
|
|
|
{
|
|
|
|
PushButton *pBtn = new PushButton(pParent, nBits);
|
|
|
|
pBtn->SetText(VclResId(SV_BUTTONTEXT_DELETE).toString());
|
|
|
|
pWindow = pBtn;
|
|
|
|
}
|
2012-04-16 11:33:57 +01:00
|
|
|
else
|
2012-09-25 11:35:47 +01:00
|
|
|
{
|
|
|
|
SAL_WARN("vcl.layout", "unknown stock type: " << sType.getStr());
|
|
|
|
}
|
2012-04-16 11:33:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pWindow)
|
|
|
|
pWindow = new PushButton(pParent, nBits);
|
|
|
|
return pWindow;
|
|
|
|
}
|
2012-08-17 13:49:40 +01:00
|
|
|
|
|
|
|
FieldUnit detectMetricUnit(rtl::OString sUnit)
|
|
|
|
{
|
|
|
|
FieldUnit eUnit = FUNIT_NONE;
|
|
|
|
|
|
|
|
if (sUnit == "mm")
|
|
|
|
eUnit = FUNIT_MM;
|
|
|
|
else if (sUnit == "cm")
|
|
|
|
eUnit = FUNIT_CM;
|
|
|
|
else if (sUnit == "m")
|
|
|
|
eUnit = FUNIT_M;
|
|
|
|
else if (sUnit == "km")
|
|
|
|
eUnit = FUNIT_KM;
|
|
|
|
else if ((sUnit == "twips") || (sUnit == "twip"))
|
|
|
|
eUnit = FUNIT_TWIP;
|
|
|
|
else if (sUnit == "pt")
|
|
|
|
eUnit = FUNIT_POINT;
|
|
|
|
else if (sUnit == "pc")
|
|
|
|
eUnit = FUNIT_PICA;
|
|
|
|
else if (sUnit == "\"" || (sUnit == "in") || (sUnit == "inch"))
|
|
|
|
eUnit = FUNIT_INCH;
|
|
|
|
else if ((sUnit == "'") || (sUnit == "ft") || (sUnit == "foot") || (sUnit == "feet"))
|
|
|
|
eUnit = FUNIT_FOOT;
|
|
|
|
else if (sUnit == "mile" || (sUnit == "miles"))
|
|
|
|
eUnit = FUNIT_MILE;
|
|
|
|
else if (sUnit == "ch")
|
|
|
|
eUnit = FUNIT_CHAR;
|
|
|
|
else if (sUnit == "line")
|
|
|
|
eUnit = FUNIT_LINE;
|
|
|
|
else if (sUnit == "%")
|
|
|
|
eUnit = FUNIT_PERCENT;
|
|
|
|
|
|
|
|
return eUnit;
|
|
|
|
}
|
2012-09-04 14:14:55 +01:00
|
|
|
|
|
|
|
void ensureDefaultWidthChars(VclBuilder::stringmap &rMap)
|
|
|
|
{
|
|
|
|
rtl::OString sWidthChars(RTL_CONSTASCII_STRINGPARAM("width-chars"));
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(sWidthChars);
|
|
|
|
if (aFind == rMap.end())
|
|
|
|
rMap[sWidthChars] = "25";
|
|
|
|
}
|
2012-04-16 11:33:57 +01:00
|
|
|
}
|
|
|
|
|
2012-04-30 10:19:19 +01:00
|
|
|
bool VclBuilder::extractGroup(const rtl::OString &id, stringmap &rMap)
|
|
|
|
{
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("group")));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
2012-08-23 15:38:30 +01:00
|
|
|
m_pParserState->m_aGroupMaps.push_back(RadioButtonGroupMap(id, aFind->second));
|
2012-06-06 08:56:46 +01:00
|
|
|
rMap.erase(aFind);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-06-14 14:20:49 +01:00
|
|
|
bool VclBuilder::extractAdjustment(const rtl::OString &id, stringmap &rMap)
|
|
|
|
{
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("adjustment")));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
2012-08-23 15:38:30 +01:00
|
|
|
m_pParserState->m_aAdjustmentMaps.push_back(SpinButtonAdjustmentMap(id, aFind->second));
|
2012-06-14 14:20:49 +01:00
|
|
|
rMap.erase(aFind);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
bool VclBuilder::extractModel(const rtl::OString &id, stringmap &rMap)
|
|
|
|
{
|
|
|
|
VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("model")));
|
|
|
|
if (aFind != rMap.end())
|
|
|
|
{
|
2012-08-23 15:38:30 +01:00
|
|
|
m_pParserState->m_aModelMaps.push_back(ComboBoxModelMap(id, aFind->second));
|
2012-04-30 10:19:19 +01:00
|
|
|
rMap.erase(aFind);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-08-29 14:16:04 +01:00
|
|
|
extern "C" { static void SAL_CALL thisModule() {} }
|
|
|
|
|
2012-04-30 10:19:19 +01:00
|
|
|
Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const rtl::OString &id, stringmap &rMap)
|
2012-03-26 12:15:22 +01:00
|
|
|
{
|
2012-08-23 12:10:56 +01:00
|
|
|
bool bIsPlaceHolder = name.isEmpty();
|
|
|
|
|
2012-06-09 10:33:31 +01:00
|
|
|
if (pParent && pParent->GetType() == WINDOW_TABCONTROL)
|
2012-06-07 15:11:02 +01:00
|
|
|
{
|
|
|
|
//We have to add a page
|
|
|
|
|
2012-06-12 16:02:26 +01:00
|
|
|
//make default pageid == -position. Partitioning the
|
|
|
|
//id space into negative numbers for auto-generated
|
|
|
|
//ids and positive numbers for the handleTabChild
|
|
|
|
//derived ids
|
|
|
|
TabControl *pTabControl = static_cast<TabControl*>(pParent);
|
2012-09-05 14:27:59 +01:00
|
|
|
sal_uInt16 nNewPageCount = pTabControl->GetPageCount()+1;
|
|
|
|
sal_uInt16 nNewPageId = -nNewPageCount;
|
2012-06-07 15:11:02 +01:00
|
|
|
pTabControl->InsertPage(nNewPageId, rtl::OUString());
|
|
|
|
pTabControl->SetCurPageId(nNewPageId);
|
2012-06-12 16:02:26 +01:00
|
|
|
|
|
|
|
if (!bIsPlaceHolder)
|
|
|
|
{
|
|
|
|
TabPage* pPage = new TabPage(pTabControl);
|
2012-08-30 13:03:44 +01:00
|
|
|
pPage->Show();
|
2012-09-05 14:27:59 +01:00
|
|
|
|
|
|
|
//Make up a name for it
|
|
|
|
rtl::OString sTabPageId = get_by_window(pParent) +
|
|
|
|
rtl::OString("-page") +
|
|
|
|
rtl::OString::valueOf(static_cast<sal_Int32>(nNewPageCount));
|
|
|
|
m_aChildren.push_back(WinAndId(sTabPageId, pPage));
|
|
|
|
pPage->SetHelpId(m_sHelpRoot + sTabPageId);
|
2012-06-12 16:02:26 +01:00
|
|
|
|
|
|
|
//And give the page one container as a child to make it a layout enabled
|
|
|
|
//tab page
|
|
|
|
VclBin* pContainer = new VclBin(pPage);
|
2012-08-30 13:03:44 +01:00
|
|
|
pContainer->Show();
|
2012-06-12 16:02:26 +01:00
|
|
|
m_aChildren.push_back(WinAndId(rtl::OString(), pContainer));
|
2012-09-11 10:31:34 +01:00
|
|
|
pContainer->SetHelpId(m_sHelpRoot + sTabPageId + rtl::OString("-bin"));
|
2012-06-12 16:02:26 +01:00
|
|
|
pParent = pContainer;
|
|
|
|
|
|
|
|
pTabControl->SetTabPage(nNewPageId, pPage);
|
|
|
|
}
|
2012-06-07 15:11:02 +01:00
|
|
|
}
|
|
|
|
|
2012-08-23 12:10:56 +01:00
|
|
|
if (bIsPlaceHolder)
|
|
|
|
return NULL;
|
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
Window *pWindow = NULL;
|
2012-03-27 14:20:17 +01:00
|
|
|
if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkDialog")))
|
2012-04-05 21:28:08 +01:00
|
|
|
pWindow = new Dialog(pParent, WB_SIZEMOVE|WB_3DLOOK|WB_CLOSEABLE);
|
2012-03-27 14:20:17 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkBox")))
|
|
|
|
{
|
2012-04-16 11:33:57 +01:00
|
|
|
if (extractOrientation(rMap))
|
2012-03-27 14:20:17 +01:00
|
|
|
pWindow = new VclVBox(pParent);
|
|
|
|
else
|
|
|
|
pWindow = new VclHBox(pParent);
|
|
|
|
}
|
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkButtonBox")))
|
|
|
|
{
|
2012-04-16 11:33:57 +01:00
|
|
|
if (extractOrientation(rMap))
|
2012-03-27 14:20:17 +01:00
|
|
|
pWindow = new VclVButtonBox(pParent);
|
|
|
|
else
|
|
|
|
pWindow = new VclHButtonBox(pParent);
|
|
|
|
}
|
2012-04-05 20:43:33 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkGrid")))
|
|
|
|
pWindow = new VclGrid(pParent);
|
2012-04-11 11:41:54 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkFrame")))
|
|
|
|
pWindow = new VclFrame(pParent);
|
2012-08-23 11:54:40 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkExpander")))
|
|
|
|
pWindow = new VclExpander(pParent);
|
2012-04-16 10:12:57 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkAlignment")))
|
|
|
|
pWindow = new VclAlignment(pParent);
|
2012-03-27 14:20:17 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkButton")))
|
2012-04-16 11:33:57 +01:00
|
|
|
pWindow = extractStockAndBuildButton(pParent, rMap);
|
2012-03-27 14:20:17 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkRadioButton")))
|
2012-04-30 10:19:19 +01:00
|
|
|
{
|
|
|
|
extractGroup(id, rMap);
|
2012-04-04 09:30:41 +01:00
|
|
|
pWindow = new RadioButton(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK);
|
2012-04-30 10:19:19 +01:00
|
|
|
}
|
2012-03-27 14:32:24 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkCheckButton")))
|
2012-09-19 10:14:00 +01:00
|
|
|
{
|
|
|
|
//maybe always import as TriStateBox and enable/disable tristate
|
|
|
|
bool bIsTriState = extractInconsistent(rMap);
|
|
|
|
CheckBox *pCheckBox = bIsTriState ?
|
|
|
|
new TriStateBox(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK) :
|
|
|
|
new CheckBox(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK);
|
|
|
|
if (bIsTriState)
|
|
|
|
pCheckBox->SetState(STATE_DONTKNOW);
|
|
|
|
pWindow = pCheckBox;
|
|
|
|
}
|
2012-03-27 16:32:28 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkSpinButton")))
|
2012-06-14 14:20:49 +01:00
|
|
|
{
|
|
|
|
extractAdjustment(id, rMap);
|
2012-08-17 13:49:40 +01:00
|
|
|
rtl::OString sPattern = extractPattern(rMap);
|
|
|
|
rtl::OString sUnit = sPattern;
|
|
|
|
|
|
|
|
for (sal_Int32 i = 0; i < sPattern.getLength(); ++i)
|
|
|
|
{
|
|
|
|
if (sPattern[i] != '.' && sPattern[i] != ',' && sPattern[i] != '0')
|
|
|
|
{
|
|
|
|
sUnit = sPattern.copy(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FieldUnit eUnit = detectMetricUnit(sUnit);
|
|
|
|
|
2012-09-10 14:57:55 +01:00
|
|
|
WinBits nBits = WB_RIGHT|WB_BORDER|WB_3DLOOK;
|
|
|
|
if (!id.endsWith("-nospin"))
|
|
|
|
nBits |= WB_SPIN;
|
|
|
|
|
2012-08-17 13:49:40 +01:00
|
|
|
if (sPattern.isEmpty())
|
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
SAL_INFO("vcl.layout", "making numeric field for " << name.getStr() << " " << sUnit.getStr());
|
2012-09-10 14:57:55 +01:00
|
|
|
pWindow = new NumericField(pParent, nBits);
|
2012-08-17 13:49:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
SAL_INFO("vcl.layout", "making metric field for " << name.getStr() << " " << sUnit.getStr());
|
2012-09-10 14:57:55 +01:00
|
|
|
MetricField *pField = new MetricField(pParent, nBits);
|
2012-08-17 13:49:40 +01:00
|
|
|
pField->SetUnit(eUnit);
|
|
|
|
pWindow = pField;
|
|
|
|
}
|
2012-06-14 14:20:49 +01:00
|
|
|
}
|
2012-03-27 16:32:28 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkComboBox")))
|
2012-06-06 08:56:46 +01:00
|
|
|
{
|
|
|
|
extractModel(id, rMap);
|
2012-06-13 16:31:45 +01:00
|
|
|
ListBox *pListBox = new ListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK);
|
2012-09-19 22:01:49 +01:00
|
|
|
pListBox->SetBestDropDownLineCount();
|
2012-06-13 16:31:45 +01:00
|
|
|
pWindow = pListBox;
|
2012-06-06 08:56:46 +01:00
|
|
|
}
|
2012-09-18 09:42:28 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkComboBoxText")))
|
|
|
|
{
|
|
|
|
extractModel(id, rMap);
|
|
|
|
ComboBox* pComboBox = new ComboBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK);
|
2012-09-19 22:01:49 +01:00
|
|
|
pComboBox->SetBestDropDownLineCount();
|
2012-09-18 09:42:28 +01:00
|
|
|
pWindow = pComboBox;
|
|
|
|
}
|
2012-06-08 20:59:06 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkTreeView")))
|
|
|
|
{
|
|
|
|
extractModel(id, rMap);
|
|
|
|
pWindow = new ListBox(pParent, WB_LEFT|WB_VCENTER|WB_3DLOOK);
|
|
|
|
}
|
2012-03-27 14:20:17 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkLabel")))
|
2012-04-04 09:30:41 +01:00
|
|
|
pWindow = new FixedText(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK);
|
2012-08-23 12:21:28 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkImage")))
|
|
|
|
pWindow = new FixedImage(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK);
|
2012-08-23 12:29:26 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkSeparator")))
|
|
|
|
{
|
|
|
|
if (extractOrientation(rMap))
|
|
|
|
pWindow = new FixedLine(pParent, WB_VERT);
|
|
|
|
else
|
|
|
|
pWindow = new FixedLine(pParent, WB_HORZ);
|
|
|
|
}
|
2012-03-27 14:32:24 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkEntry")))
|
2012-09-04 14:14:55 +01:00
|
|
|
{
|
2012-06-07 15:11:02 +01:00
|
|
|
pWindow = new Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
|
2012-09-04 14:14:55 +01:00
|
|
|
ensureDefaultWidthChars(rMap);
|
|
|
|
}
|
2012-06-07 15:11:02 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkNotebook")))
|
|
|
|
pWindow = new TabControl(pParent, WB_STDTABCONTROL|WB_3DLOOK);
|
2012-06-07 23:03:18 +01:00
|
|
|
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkDrawingArea")))
|
|
|
|
pWindow = new Window(pParent);
|
2012-03-26 12:15:22 +01:00
|
|
|
else
|
2012-08-20 10:50:32 +01:00
|
|
|
{
|
2012-08-29 14:16:04 +01:00
|
|
|
sal_Int32 nDelim = name.indexOf(':');
|
|
|
|
if (nDelim != -1)
|
|
|
|
{
|
|
|
|
rtl::OUStringBuffer sModule;
|
|
|
|
#ifdef SAL_DLLPREFIX
|
|
|
|
sModule.append(SAL_DLLPREFIX);
|
|
|
|
#endif
|
|
|
|
sModule.append(rtl::OStringToOUString(name.copy(0, nDelim), RTL_TEXTENCODING_UTF8));
|
|
|
|
#ifdef SAL_DLLEXTENSION
|
|
|
|
sModule.append(SAL_DLLEXTENSION);
|
|
|
|
#endif
|
|
|
|
rtl::OUString sFunction(rtl::OStringToOUString(rtl::OString("make") + name.copy(nDelim+1), RTL_TEXTENCODING_UTF8));
|
|
|
|
osl::Module aModule;
|
|
|
|
aModule.loadRelative(&thisModule, sModule.makeStringAndClear());
|
|
|
|
customMakeWidget pFunction = (customMakeWidget)aModule.getFunctionSymbol(sFunction);
|
|
|
|
if (pFunction)
|
2012-09-19 22:01:49 +01:00
|
|
|
pWindow = (*pFunction)(pParent, rMap);
|
2012-08-29 14:16:04 +01:00
|
|
|
}
|
2012-08-20 10:50:32 +01:00
|
|
|
}
|
2012-09-25 11:35:47 +01:00
|
|
|
SAL_WARN_IF(!pWindow, "vcl.layout", "implement " << name.getStr() << "or add a make" << name.getStr() << " function");
|
2012-05-23 13:32:19 +01:00
|
|
|
if (pWindow)
|
|
|
|
{
|
2012-08-16 14:04:00 +01:00
|
|
|
pWindow->SetHelpId(m_sHelpRoot + id);
|
2012-09-25 11:35:47 +01:00
|
|
|
SAL_INFO("vcl.layout", "for " << name.getStr() <<
|
|
|
|
", created << " << pWindow << " child of " <<
|
|
|
|
pParent << "(" << pWindow->mpWindowImpl->mpParent << "/" <<
|
|
|
|
pWindow->mpWindowImpl->mpRealParent << "/" <<
|
|
|
|
pWindow->mpWindowImpl->mpBorderWindow << ") with helpid " <<
|
|
|
|
pWindow->GetHelpId().getStr());
|
2012-06-07 15:11:02 +01:00
|
|
|
m_aChildren.push_back(WinAndId(id, pWindow));
|
2012-05-23 13:32:19 +01:00
|
|
|
}
|
2012-03-26 12:15:22 +01:00
|
|
|
return pWindow;
|
|
|
|
}
|
|
|
|
|
2012-06-13 14:24:01 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
//return true for window types which exist in vcl but are not themselves
|
|
|
|
//represented in the .ui format, i.e. only their children exist.
|
|
|
|
bool isConsideredPseudo(Window *pWindow)
|
|
|
|
{
|
|
|
|
return pWindow->GetType() == WINDOW_TABPAGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-25 11:12:55 +01:00
|
|
|
Window *VclBuilder::insertObject(Window *pParent, const rtl::OString &rClass, const rtl::OString &rID, stringmap &rMap)
|
2012-03-26 12:15:22 +01:00
|
|
|
{
|
2012-04-25 11:12:55 +01:00
|
|
|
Window *pCurrentChild = NULL;
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-06-13 14:24:01 +01:00
|
|
|
if (m_pParent && !isConsideredPseudo(m_pParent) && !m_sID.isEmpty() && rID.equals(m_sID))
|
2012-03-27 14:20:17 +01:00
|
|
|
{
|
2012-04-25 11:12:55 +01:00
|
|
|
pCurrentChild = m_pParent;
|
|
|
|
//toplevels default to resizable
|
|
|
|
if (pCurrentChild->IsDialog())
|
2012-05-18 14:05:20 +01:00
|
|
|
pCurrentChild->SetStyle(pCurrentChild->GetStyle() | WB_SIZEMOVE | WB_3DLOOK);
|
2012-08-20 09:59:16 +01:00
|
|
|
if (pCurrentChild->GetHelpId().isEmpty())
|
2012-08-30 12:41:18 +01:00
|
|
|
{
|
2012-08-20 09:59:16 +01:00
|
|
|
pCurrentChild->SetHelpId(m_sHelpRoot + m_sID);
|
2012-08-30 12:41:18 +01:00
|
|
|
fprintf(stderr, "for toplevel dialog %p %s, set helpid %s\n", this, rID.getStr(), pCurrentChild->GetHelpId().getStr());
|
|
|
|
}
|
2012-04-25 11:12:55 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-30 10:19:19 +01:00
|
|
|
pCurrentChild = makeObject(pParent, rClass, rID, rMap);
|
2012-04-25 11:12:55 +01:00
|
|
|
}
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-04-25 11:12:55 +01:00
|
|
|
if (pCurrentChild)
|
|
|
|
{
|
2012-03-27 14:20:17 +01:00
|
|
|
for (stringmap::iterator aI = rMap.begin(), aEnd = rMap.end(); aI != aEnd; ++aI)
|
2012-03-26 12:15:22 +01:00
|
|
|
{
|
2012-03-27 14:20:17 +01:00
|
|
|
const rtl::OString &rKey = aI->first;
|
|
|
|
const rtl::OString &rValue = aI->second;
|
2012-04-16 10:50:23 +01:00
|
|
|
pCurrentChild->set_property(rKey, rValue);
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-16 10:50:23 +01:00
|
|
|
rMap.clear();
|
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
if (!pCurrentChild)
|
2012-04-25 11:12:55 +01:00
|
|
|
pCurrentChild = m_aChildren.empty() ? pParent : m_aChildren.back().m_pWindow;
|
2012-03-27 14:20:17 +01:00
|
|
|
return pCurrentChild;
|
|
|
|
}
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-05-23 13:17:44 +01:00
|
|
|
sal_uInt16 VclBuilder::getPositionWithinParent(Window &rWindow)
|
|
|
|
{
|
|
|
|
if (rWindow.mpWindowImpl->mpParent != rWindow.mpWindowImpl->mpRealParent)
|
|
|
|
{
|
|
|
|
assert(rWindow.mpWindowImpl->mpBorderWindow ==
|
|
|
|
rWindow.mpWindowImpl->mpParent);
|
2012-08-20 09:59:16 +01:00
|
|
|
assert(rWindow.mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent ==
|
2012-05-23 13:17:44 +01:00
|
|
|
rWindow.mpWindowImpl->mpRealParent);
|
|
|
|
return getPositionWithinParent(*rWindow.mpWindowImpl->mpBorderWindow);
|
|
|
|
}
|
|
|
|
|
2012-08-20 09:59:16 +01:00
|
|
|
assert(rWindow.GetParent() == rWindow.mpWindowImpl->mpRealParent);
|
2012-05-23 13:17:44 +01:00
|
|
|
|
|
|
|
sal_uInt16 nPosition = 0;
|
|
|
|
Window* pChild = rWindow.GetParent()->mpWindowImpl->mpFirstChild;
|
|
|
|
while (pChild)
|
|
|
|
{
|
|
|
|
if (pChild == &rWindow)
|
|
|
|
break;
|
|
|
|
pChild = pChild->mpWindowImpl->mpNext;
|
|
|
|
++nPosition;
|
|
|
|
}
|
|
|
|
return nPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VclBuilder::reorderWithinParent(Window &rWindow, sal_uInt16 nNewPosition)
|
|
|
|
{
|
|
|
|
if (rWindow.mpWindowImpl->mpParent != rWindow.mpWindowImpl->mpRealParent)
|
|
|
|
{
|
|
|
|
assert(rWindow.mpWindowImpl->mpBorderWindow ==
|
|
|
|
rWindow.mpWindowImpl->mpParent);
|
2012-08-20 09:59:16 +01:00
|
|
|
assert(rWindow.mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent ==
|
2012-05-23 13:17:44 +01:00
|
|
|
rWindow.mpWindowImpl->mpRealParent);
|
|
|
|
reorderWithinParent(*rWindow.mpWindowImpl->mpBorderWindow, nNewPosition);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rWindow.reorderWithinParent(nNewPosition);
|
|
|
|
}
|
|
|
|
|
2012-06-07 15:11:02 +01:00
|
|
|
void VclBuilder::handleTabChild(Window *pParent, xmlreader::XmlReader &reader)
|
2012-03-27 14:20:17 +01:00
|
|
|
{
|
2012-06-12 16:02:26 +01:00
|
|
|
rtl::OString sID;
|
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
int nLevel = 1;
|
2012-06-07 15:11:02 +01:00
|
|
|
stringmap aProperties;
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
xmlreader::Span name;
|
|
|
|
int nsId;
|
|
|
|
|
|
|
|
xmlreader::XmlReader::Result res = reader.nextItem(
|
|
|
|
xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_BEGIN)
|
|
|
|
{
|
|
|
|
++nLevel;
|
2012-08-07 15:27:51 +01:00
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("object")))
|
2012-06-12 16:02:26 +01:00
|
|
|
{
|
|
|
|
while (reader.nextAttribute(&nsId, &name))
|
|
|
|
{
|
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("id")))
|
|
|
|
{
|
|
|
|
name = reader.getAttributeValue(false);
|
|
|
|
sID = rtl::OString(name.begin, name.length);
|
2012-08-29 15:06:48 +01:00
|
|
|
sal_Int32 nDelim = sID.indexOf(':');
|
|
|
|
if (nDelim != -1)
|
|
|
|
{
|
|
|
|
rtl::OString sPattern = sID.copy(nDelim+1);
|
|
|
|
aProperties[rtl::OString("pattern")] = sPattern;
|
|
|
|
sID = sID.copy(0, nDelim);
|
|
|
|
}
|
2012-06-12 16:02:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-07 15:27:51 +01:00
|
|
|
else if (name.equals(RTL_CONSTASCII_STRINGPARAM("property")))
|
|
|
|
collectProperty(reader, sID, aProperties);
|
2012-06-07 15:11:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_END)
|
|
|
|
--nLevel;
|
|
|
|
|
|
|
|
if (!nLevel)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_DONE)
|
|
|
|
break;
|
|
|
|
}
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-06-12 13:05:14 +01:00
|
|
|
TabControl *pTabControl = static_cast<TabControl*>(pParent);
|
2012-06-07 15:11:02 +01:00
|
|
|
VclBuilder::stringmap::iterator aFind = aProperties.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("label")));
|
|
|
|
if (aFind != aProperties.end())
|
2012-06-12 16:02:26 +01:00
|
|
|
{
|
2012-06-07 15:11:02 +01:00
|
|
|
pTabControl->SetPageText(pTabControl->GetCurPageId(), rtl::OStringToOUString(aFind->second, RTL_TEXTENCODING_UTF8));
|
2012-06-12 16:02:26 +01:00
|
|
|
|
|
|
|
sal_Int32 nID = 0;
|
|
|
|
//To make it easier to retro fit pre-builder dialog code we take the
|
|
|
|
//notebook child id (falling back to notebook label id) and if its a
|
|
|
|
//positive number use that as the page id so existing code can find the
|
|
|
|
//right tabpage by id
|
|
|
|
TabPage *pPage = pTabControl->GetTabPage(pTabControl->GetCurPageId());
|
|
|
|
if (pPage)
|
|
|
|
{
|
|
|
|
VclBin *pContainer = static_cast<VclBin*>(pPage->GetWindow(WINDOW_FIRSTCHILD));
|
|
|
|
Window *pChild = pContainer->get_child();
|
|
|
|
nID = pChild ? get_by_window(pChild).toInt32() : 0;
|
|
|
|
}
|
|
|
|
if (nID == 0)
|
|
|
|
nID = sID.toInt32();
|
|
|
|
if (nID > 0)
|
|
|
|
pTabControl->ReassignPageId(pTabControl->GetCurPageId(), nID);
|
|
|
|
}
|
2012-06-12 13:05:14 +01:00
|
|
|
else
|
|
|
|
pTabControl->RemovePage(pTabControl->GetCurPageId());
|
2012-06-07 15:11:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader)
|
|
|
|
{
|
2012-03-27 16:32:28 +01:00
|
|
|
Window *pCurrentChild = NULL;
|
|
|
|
|
2012-06-07 15:11:02 +01:00
|
|
|
xmlreader::Span name;
|
|
|
|
int nsId;
|
|
|
|
rtl::OString sType;
|
|
|
|
|
|
|
|
while (reader.nextAttribute(&nsId, &name))
|
|
|
|
{
|
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("type")))
|
|
|
|
{
|
|
|
|
name = reader.getAttributeValue(false);
|
|
|
|
sType = rtl::OString(name.begin, name.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sType.equalsL(RTL_CONSTASCII_STRINGPARAM("tab")))
|
|
|
|
{
|
|
|
|
handleTabChild(pParent, reader);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int nLevel = 1;
|
2012-03-26 12:15:22 +01:00
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
xmlreader::XmlReader::Result res = reader.nextItem(
|
|
|
|
xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
|
|
|
|
|
2012-03-27 14:20:17 +01:00
|
|
|
if (res == xmlreader::XmlReader::RESULT_BEGIN)
|
|
|
|
{
|
2012-06-12 13:05:14 +01:00
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("object")) || name.equals(RTL_CONSTASCII_STRINGPARAM("placeholder")))
|
2012-03-27 14:20:17 +01:00
|
|
|
{
|
2012-03-27 16:32:28 +01:00
|
|
|
pCurrentChild = handleObject(pParent, reader);
|
2012-03-28 14:10:13 +01:00
|
|
|
|
2012-06-12 16:02:26 +01:00
|
|
|
bool bObjectInserted = pCurrentChild && pParent != pCurrentChild;
|
|
|
|
|
|
|
|
if (bObjectInserted)
|
2012-03-28 14:10:13 +01:00
|
|
|
{
|
2012-06-07 15:11:02 +01:00
|
|
|
//Select the first page if its a notebook
|
2012-06-09 10:33:31 +01:00
|
|
|
if (pCurrentChild->GetType() == WINDOW_TABCONTROL)
|
2012-03-28 14:10:13 +01:00
|
|
|
{
|
2012-06-07 15:11:02 +01:00
|
|
|
TabControl *pTabControl = static_cast<TabControl*>(pCurrentChild);
|
2012-06-12 16:02:26 +01:00
|
|
|
pTabControl->SetCurPageId(pTabControl->GetPageId(0));
|
2012-03-28 14:10:13 +01:00
|
|
|
|
2012-06-07 15:11:02 +01:00
|
|
|
//To-Do add reorder capability to the TabControl
|
2012-03-28 14:10:13 +01:00
|
|
|
}
|
2012-06-07 15:11:02 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
//To-Do make reorder a virtual in Window, move this foo
|
|
|
|
//there and see above
|
|
|
|
|
|
|
|
rtl::OString sPosition(RTL_CONSTASCII_STRINGPARAM("position"));
|
|
|
|
std::vector<Window*> aChilds;
|
|
|
|
for (Window* pChild = pCurrentChild->GetWindow(WINDOW_FIRSTCHILD); pChild;
|
|
|
|
pChild = pChild->GetWindow(WINDOW_NEXT))
|
|
|
|
{
|
|
|
|
aChilds.push_back(pChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < aChilds.size(); ++i)
|
|
|
|
{
|
2012-08-15 11:19:06 +01:00
|
|
|
sal_Int32 nPosition = get_window_packing_position(aChilds[i]);
|
|
|
|
if (nPosition == -1)
|
2012-06-07 15:11:02 +01:00
|
|
|
continue;
|
|
|
|
reorderWithinParent(*aChilds[i], nPosition);
|
|
|
|
}
|
2012-05-22 12:33:28 +01:00
|
|
|
|
|
|
|
#if TODO
|
|
|
|
//sort by ltr ttb
|
2012-06-07 15:11:02 +01:00
|
|
|
rtl::OString sLeftAttach(RTL_CONSTASCII_STRINGPARAM("left-attach"));
|
|
|
|
rtl::OString sTopAttach(RTL_CONSTASCII_STRINGPARAM("top-attach"));
|
|
|
|
for (size_t i = 0; i < aChilds.size(); ++i)
|
|
|
|
{
|
|
|
|
sal_uInt16 nPosition = aChilds[i]->getWidgetProperty<sal_uInt16>(sPosition, 0xFFFF);
|
|
|
|
if (nPosition == 0xFFFF)
|
|
|
|
continue;
|
|
|
|
reorderWithinParent(*aChilds[i], nPosition);
|
|
|
|
}
|
2012-05-22 12:33:28 +01:00
|
|
|
#endif
|
2012-06-07 15:11:02 +01:00
|
|
|
}
|
2012-03-28 14:10:13 +01:00
|
|
|
}
|
2012-03-27 16:32:28 +01:00
|
|
|
}
|
|
|
|
else if (name.equals(RTL_CONSTASCII_STRINGPARAM("packing")))
|
|
|
|
{
|
|
|
|
handlePacking(pCurrentChild, reader);
|
2012-03-27 14:20:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
++nLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_END)
|
|
|
|
--nLevel;
|
|
|
|
|
|
|
|
if (!nLevel)
|
|
|
|
break;
|
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
if (res == xmlreader::XmlReader::RESULT_DONE)
|
|
|
|
break;
|
2012-03-27 14:20:17 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-06-14 14:20:49 +01:00
|
|
|
void VclBuilder::handleAdjustment(const rtl::OString &rID, stringmap &rProperties)
|
|
|
|
{
|
2012-08-23 15:38:30 +01:00
|
|
|
m_pParserState->m_aAdjustments.push_back(AdjustmentAndId(rID, rProperties));
|
2012-06-14 14:20:49 +01:00
|
|
|
}
|
|
|
|
|
2012-08-30 12:41:18 +01:00
|
|
|
void VclBuilder::handleRow(xmlreader::XmlReader &reader, const rtl::OString &rID, sal_Int32 nRowIndex)
|
2012-06-06 08:56:46 +01:00
|
|
|
{
|
|
|
|
int nLevel = 1;
|
2012-08-30 12:41:18 +01:00
|
|
|
|
|
|
|
ListStore::row aRow;
|
2012-06-06 08:56:46 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
++nLevel;
|
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("col")))
|
|
|
|
{
|
2012-08-07 15:27:51 +01:00
|
|
|
bool bTranslated = false;
|
|
|
|
rtl::OString sProperty, sValue;
|
2012-08-30 12:41:18 +01:00
|
|
|
sal_uInt32 nId = 0;
|
2012-08-07 15:27:51 +01:00
|
|
|
|
|
|
|
while (reader.nextAttribute(&nsId, &name))
|
|
|
|
{
|
2012-08-30 12:41:18 +01:00
|
|
|
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")))
|
2012-08-07 15:27:51 +01:00
|
|
|
{
|
2012-08-30 12:41:18 +01:00
|
|
|
sValue = getTranslation(rID, rtl::OString::valueOf(nRowIndex));
|
2012-08-07 15:27:51 +01:00
|
|
|
bTranslated = !sValue.isEmpty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
reader.nextItem(
|
2012-08-29 22:08:56 +01:00
|
|
|
xmlreader::XmlReader::TEXT_RAW, &name, &nsId);
|
2012-08-07 15:27:51 +01:00
|
|
|
|
|
|
|
if (!bTranslated)
|
|
|
|
sValue = rtl::OString(name.begin, name.length);
|
|
|
|
|
2012-08-30 12:41:18 +01:00
|
|
|
if (aRow.size() < nId+1)
|
|
|
|
aRow.resize(nId+1);
|
|
|
|
aRow[nId] = sValue;
|
2012-06-06 08:56:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_END)
|
|
|
|
{
|
|
|
|
--nLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nLevel)
|
|
|
|
break;
|
|
|
|
}
|
2012-08-30 12:41:18 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2012-06-06 08:56:46 +01:00
|
|
|
}
|
|
|
|
|
2012-03-27 16:32:28 +01:00
|
|
|
Window* VclBuilder::handleObject(Window *pParent, xmlreader::XmlReader &reader)
|
2012-03-27 14:20:17 +01:00
|
|
|
{
|
|
|
|
rtl::OString sClass;
|
2012-04-25 11:12:55 +01:00
|
|
|
rtl::OString sID;
|
2012-08-29 15:06:48 +01:00
|
|
|
rtl::OString sPattern;
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-03-27 14:20:17 +01:00
|
|
|
xmlreader::Span name;
|
|
|
|
int nsId;
|
|
|
|
|
|
|
|
while (reader.nextAttribute(&nsId, &name))
|
|
|
|
{
|
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("class")))
|
2012-03-26 12:15:22 +01:00
|
|
|
{
|
2012-03-27 14:20:17 +01:00
|
|
|
name = reader.getAttributeValue(false);
|
|
|
|
sClass = rtl::OString(name.begin, name.length);
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
2012-04-25 11:12:55 +01:00
|
|
|
else if (name.equals(RTL_CONSTASCII_STRINGPARAM("id")))
|
|
|
|
{
|
|
|
|
name = reader.getAttributeValue(false);
|
|
|
|
sID = rtl::OString(name.begin, name.length);
|
2012-08-29 15:06:48 +01:00
|
|
|
sal_Int32 nDelim = sID.indexOf(':');
|
|
|
|
if (nDelim != -1)
|
|
|
|
{
|
|
|
|
sPattern = sID.copy(nDelim+1);
|
|
|
|
sID = sID.copy(0, nDelim);
|
|
|
|
}
|
2012-04-25 11:12:55 +01:00
|
|
|
}
|
2012-03-27 14:20:17 +01:00
|
|
|
}
|
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
if (sClass.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkListStore")))
|
|
|
|
{
|
|
|
|
handleListStore(reader, sID);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-27 14:20:17 +01:00
|
|
|
int nLevel = 1;
|
|
|
|
|
|
|
|
stringmap aProperties;
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-08-29 15:06:48 +01:00
|
|
|
if (!sPattern.isEmpty())
|
|
|
|
aProperties[rtl::OString("pattern")] = sPattern;
|
|
|
|
|
2012-03-27 14:20:17 +01:00
|
|
|
Window *pCurrentChild = NULL;
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
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)
|
2012-03-26 12:15:22 +01:00
|
|
|
{
|
2012-03-27 14:20:17 +01:00
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("child")))
|
|
|
|
{
|
|
|
|
if (!pCurrentChild)
|
2012-04-25 11:12:55 +01:00
|
|
|
pCurrentChild = insertObject(pParent, sClass, sID, aProperties);
|
2012-03-27 14:20:17 +01:00
|
|
|
handleChild(pCurrentChild, reader);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++nLevel;
|
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("property")))
|
2012-08-07 15:27:51 +01:00
|
|
|
collectProperty(reader, sID, aProperties);
|
2012-03-27 14:20:17 +01:00
|
|
|
}
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_END)
|
|
|
|
{
|
|
|
|
--nLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nLevel)
|
|
|
|
break;
|
|
|
|
}
|
2012-03-27 14:20:17 +01:00
|
|
|
|
2012-06-14 14:20:49 +01:00
|
|
|
if (sClass.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkAdjustment")))
|
|
|
|
{
|
|
|
|
handleAdjustment(sID, aProperties);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-03-27 14:20:17 +01:00
|
|
|
if (!pCurrentChild)
|
2012-04-25 11:12:55 +01:00
|
|
|
pCurrentChild = insertObject(pParent, sClass, sID, aProperties);
|
2012-03-27 14:20:17 +01:00
|
|
|
|
2012-03-27 16:32:28 +01:00
|
|
|
return pCurrentChild;
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
|
|
|
|
2012-03-27 16:32:28 +01:00
|
|
|
void VclBuilder::handlePacking(Window *pCurrent, xmlreader::XmlReader &reader)
|
|
|
|
{
|
|
|
|
xmlreader::Span name;
|
|
|
|
int nsId;
|
|
|
|
|
|
|
|
int nLevel = 1;
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
++nLevel;
|
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("property")))
|
|
|
|
applyPackingProperty(pCurrent, reader);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res == xmlreader::XmlReader::RESULT_END)
|
|
|
|
{
|
|
|
|
--nLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nLevel)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VclBuilder::applyPackingProperty(Window *pCurrent,
|
|
|
|
xmlreader::XmlReader &reader)
|
2012-03-26 12:15:22 +01:00
|
|
|
{
|
2012-03-27 16:32:28 +01:00
|
|
|
if (!pCurrent)
|
|
|
|
return;
|
|
|
|
|
2012-06-07 23:03:18 +01:00
|
|
|
xmlreader::Span name;
|
|
|
|
int nsId;
|
|
|
|
|
2012-03-27 14:20:17 +01:00
|
|
|
while (reader.nextAttribute(&nsId, &name))
|
|
|
|
{
|
2012-03-27 16:32:28 +01:00
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("name")))
|
|
|
|
{
|
|
|
|
name = reader.getAttributeValue(false);
|
|
|
|
rtl::OString sKey(name.begin, name.length);
|
2012-04-05 20:43:33 +01:00
|
|
|
sKey = sKey.replace('_', '-');
|
2012-03-27 16:32:28 +01:00
|
|
|
reader.nextItem(
|
2012-08-29 22:08:56 +01:00
|
|
|
xmlreader::XmlReader::TEXT_RAW, &name, &nsId);
|
2012-03-27 16:32:28 +01:00
|
|
|
rtl::OString sValue(name.begin, name.length);
|
|
|
|
|
2012-08-15 11:19:06 +01:00
|
|
|
if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("expand")))
|
2012-03-27 16:32:28 +01:00
|
|
|
{
|
|
|
|
bool bTrue = (sValue[0] == 't' || sValue[0] == 'T' || sValue[0] == '1');
|
2012-08-15 11:19:06 +01:00
|
|
|
pCurrent->set_expand(bTrue);
|
2012-03-27 16:32:28 +01:00
|
|
|
}
|
2012-08-15 11:19:06 +01:00
|
|
|
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("fill")))
|
2012-03-28 14:10:13 +01:00
|
|
|
{
|
2012-08-15 11:19:06 +01:00
|
|
|
bool bTrue = (sValue[0] == 't' || sValue[0] == 'T' || sValue[0] == '1');
|
|
|
|
pCurrent->set_fill(bTrue);
|
2012-03-28 14:10:13 +01:00
|
|
|
}
|
2012-04-05 20:43:33 +01:00
|
|
|
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("pack-type")))
|
2012-03-29 10:27:27 +01:00
|
|
|
{
|
2012-08-15 11:19:06 +01:00
|
|
|
VclPackType ePackType = (sValue[0] == 'e' || sValue[0] == 'e') ? VCL_PACK_END : VCL_PACK_START;
|
|
|
|
pCurrent->set_pack_type(ePackType);
|
|
|
|
}
|
|
|
|
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("left-attach")))
|
|
|
|
{
|
|
|
|
pCurrent->set_grid_left_attach(sValue.toInt32());
|
|
|
|
}
|
|
|
|
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("top-attach")))
|
|
|
|
{
|
|
|
|
pCurrent->set_grid_top_attach(sValue.toInt32());
|
2012-04-05 20:43:33 +01:00
|
|
|
}
|
2012-08-15 11:19:06 +01:00
|
|
|
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("width")))
|
2012-04-05 20:43:33 +01:00
|
|
|
{
|
2012-08-15 11:19:06 +01:00
|
|
|
pCurrent->set_grid_width(sValue.toInt32());
|
|
|
|
}
|
|
|
|
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("height")))
|
|
|
|
{
|
|
|
|
pCurrent->set_grid_height(sValue.toInt32());
|
|
|
|
}
|
|
|
|
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("padding")))
|
|
|
|
{
|
|
|
|
pCurrent->set_padding(sValue.toInt32());
|
|
|
|
}
|
|
|
|
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("position")))
|
|
|
|
{
|
|
|
|
set_window_packing_position(pCurrent, sValue.toInt32());
|
2012-03-29 10:27:27 +01:00
|
|
|
}
|
2012-03-27 16:32:28 +01:00
|
|
|
else
|
2012-09-25 11:35:47 +01:00
|
|
|
{
|
|
|
|
SAL_WARN("vcl.layout", "unknown packing: " << sKey.getStr());
|
|
|
|
}
|
2012-03-27 16:32:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 15:27:51 +01:00
|
|
|
rtl::OString VclBuilder::getTranslation(const rtl::OString &rID, const rtl::OString &rProperty) const
|
|
|
|
{
|
2012-08-23 15:38:30 +01:00
|
|
|
Translations::const_iterator aWidgetFind = m_pParserState->m_aTranslations.find(rID);
|
|
|
|
if (aWidgetFind != m_pParserState->m_aTranslations.end())
|
2012-08-07 15:27:51 +01:00
|
|
|
{
|
|
|
|
const WidgetTranslations &rWidgetTranslations = aWidgetFind->second;
|
|
|
|
WidgetTranslations::const_iterator aPropertyFind = rWidgetTranslations.find(rProperty);
|
|
|
|
if (aPropertyFind != rWidgetTranslations.end())
|
|
|
|
return aPropertyFind->second;
|
|
|
|
}
|
|
|
|
return rtl::OString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VclBuilder::collectProperty(xmlreader::XmlReader &reader, const rtl::OString &rID, stringmap &rMap)
|
2012-03-27 16:32:28 +01:00
|
|
|
{
|
|
|
|
xmlreader::Span name;
|
|
|
|
int nsId;
|
2012-03-26 12:15:22 +01:00
|
|
|
|
2012-08-07 15:27:51 +01:00
|
|
|
rtl::OString sProperty;
|
|
|
|
rtl::OString sValue;
|
|
|
|
|
|
|
|
bool bTranslated = false;
|
|
|
|
|
2012-03-27 16:32:28 +01:00
|
|
|
while (reader.nextAttribute(&nsId, &name))
|
|
|
|
{
|
2012-03-26 12:15:22 +01:00
|
|
|
if (name.equals(RTL_CONSTASCII_STRINGPARAM("name")))
|
|
|
|
{
|
|
|
|
name = reader.getAttributeValue(false);
|
2012-08-07 15:27:51 +01:00
|
|
|
sProperty = rtl::OString(name.begin, name.length);
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
2012-08-07 15:27:51 +01:00
|
|
|
else if (name.equals(RTL_CONSTASCII_STRINGPARAM("translatable")) && reader.getAttributeValue(false).equals(RTL_CONSTASCII_STRINGPARAM("yes")))
|
|
|
|
{
|
|
|
|
sValue = getTranslation(rID, sProperty);
|
|
|
|
bTranslated = !sValue.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-29 22:08:56 +01:00
|
|
|
reader.nextItem(xmlreader::XmlReader::TEXT_RAW, &name, &nsId);
|
2012-08-07 15:27:51 +01:00
|
|
|
if (!bTranslated)
|
|
|
|
sValue = rtl::OString(name.begin, name.length);
|
|
|
|
|
|
|
|
if (!sProperty.isEmpty())
|
|
|
|
{
|
|
|
|
sProperty = sProperty.replace('_', '-');
|
|
|
|
//replace '_' with '-' except for property values that
|
|
|
|
//refer to widget ids themselves. TO-DO, drop conversion
|
|
|
|
//and just use foo_bar properties throughout
|
|
|
|
if (sProperty.equalsL(RTL_CONSTASCII_STRINGPARAM("group")))
|
|
|
|
rMap[sProperty] = sValue;
|
|
|
|
else
|
|
|
|
rMap[sProperty] = sValue.replace('_', '-');
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Window *VclBuilder::get_widget_root()
|
|
|
|
{
|
2012-04-25 11:12:55 +01:00
|
|
|
return m_aChildren.empty() ? NULL : m_aChildren[0].m_pWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window *VclBuilder::get_by_name(rtl::OString sID)
|
|
|
|
{
|
|
|
|
for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
|
|
|
|
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
|
|
|
|
{
|
|
|
|
if (aI->m_sID.equals(sID))
|
|
|
|
return aI->m_pWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2012-03-26 12:15:22 +01:00
|
|
|
}
|
|
|
|
|
2012-08-15 11:19:06 +01:00
|
|
|
rtl::OString VclBuilder::get_by_window(const Window *pWindow) const
|
2012-06-12 16:02:26 +01:00
|
|
|
{
|
2012-08-15 11:19:06 +01:00
|
|
|
for (std::vector<WinAndId>::const_iterator aI = m_aChildren.begin(),
|
2012-06-12 16:02:26 +01:00
|
|
|
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
|
|
|
|
{
|
|
|
|
if (aI->m_pWindow == pWindow)
|
|
|
|
return aI->m_sID;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rtl::OString();
|
|
|
|
}
|
|
|
|
|
2012-08-15 11:19:06 +01:00
|
|
|
sal_Int32 VclBuilder::get_window_packing_position(const Window *pWindow) const
|
|
|
|
{
|
|
|
|
for (std::vector<WinAndId>::const_iterator aI = m_aChildren.begin(),
|
|
|
|
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
|
|
|
|
{
|
|
|
|
if (aI->m_pWindow == pWindow)
|
|
|
|
return aI->m_nPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VclBuilder::set_window_packing_position(const Window *pWindow, sal_Int32 nPosition)
|
|
|
|
{
|
|
|
|
for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
|
|
|
|
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
|
|
|
|
{
|
|
|
|
if (aI->m_pWindow == pWindow)
|
|
|
|
aI->m_nPosition = nPosition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
VclBuilder::ListStore *VclBuilder::get_model_by_name(rtl::OString sID)
|
|
|
|
{
|
2012-08-23 15:38:30 +01:00
|
|
|
for (std::vector<ModelAndId>::iterator aI = m_pParserState->m_aModels.begin(),
|
|
|
|
aEnd = m_pParserState->m_aModels.end(); aI != aEnd; ++aI)
|
2012-06-06 08:56:46 +01:00
|
|
|
{
|
|
|
|
if (aI->m_sID.equals(sID))
|
|
|
|
return aI->m_pModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-14 14:20:49 +01:00
|
|
|
VclBuilder::Adjustment *VclBuilder::get_adjustment_by_name(rtl::OString sID)
|
|
|
|
{
|
2012-08-23 15:38:30 +01:00
|
|
|
for (std::vector<AdjustmentAndId>::iterator aI = m_pParserState->m_aAdjustments.begin(),
|
|
|
|
aEnd = m_pParserState->m_aAdjustments.end(); aI != aEnd; ++aI)
|
2012-06-14 14:20:49 +01:00
|
|
|
{
|
|
|
|
if (aI->m_sID.equals(sID))
|
|
|
|
return &(aI->m_aAdjustment);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-05-22 12:33:28 +01:00
|
|
|
void VclBuilder::swapGuts(Window &rOrig, Window &rReplacement)
|
|
|
|
{
|
|
|
|
sal_uInt16 nPosition = getPositionWithinParent(rOrig);
|
|
|
|
|
|
|
|
rReplacement.take_properties(rOrig);
|
|
|
|
|
2012-05-23 13:17:44 +01:00
|
|
|
reorderWithinParent(rReplacement, nPosition);
|
2012-05-22 12:33:28 +01:00
|
|
|
|
|
|
|
assert(nPosition == getPositionWithinParent(rReplacement));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VclBuilder::replace(rtl::OString sID, Window &rReplacement)
|
|
|
|
{
|
|
|
|
for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
|
|
|
|
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
|
|
|
|
{
|
|
|
|
if (aI->m_sID.equals(sID))
|
|
|
|
{
|
|
|
|
Window *pOrig = aI->m_pWindow;
|
|
|
|
swapGuts(*pOrig, rReplacement);
|
|
|
|
delete pOrig;
|
|
|
|
|
|
|
|
aI->m_pWindow = &rReplacement;
|
|
|
|
aI->m_bOwned = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2012-09-25 11:35:47 +01:00
|
|
|
SAL_WARN("vcl.layout", "no sign of :" << sID.getStr());
|
2012-05-22 12:33:28 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-06-06 08:56:46 +01:00
|
|
|
void VclBuilder::mungemodel(ListBox &rTarget, ListStore &rStore)
|
|
|
|
{
|
2012-08-30 12:41:18 +01:00
|
|
|
for (std::vector<ListStore::row>::iterator aI = rStore.m_aEntries.begin(), aEnd = rStore.m_aEntries.end();
|
2012-06-06 08:56:46 +01:00
|
|
|
aI != aEnd; ++aI)
|
|
|
|
{
|
2012-08-30 12:41:18 +01:00
|
|
|
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);
|
|
|
|
}
|
2012-06-06 08:56:46 +01:00
|
|
|
}
|
2012-06-06 10:29:16 +01:00
|
|
|
if (!rStore.m_aEntries.empty())
|
|
|
|
rTarget.SelectEntryPos(0);
|
2012-06-06 08:56:46 +01:00
|
|
|
}
|
|
|
|
|
2012-08-17 13:49:40 +01:00
|
|
|
void VclBuilder::mungeadjustment(NumericFormatter &rTarget, Adjustment &rAdjustment)
|
2012-06-14 14:20:49 +01:00
|
|
|
{
|
|
|
|
int nMul = rtl_math_pow10Exp(1, rTarget.GetDecimalDigits());
|
|
|
|
|
|
|
|
for (stringmap::iterator aI = rAdjustment.begin(), aEnd = rAdjustment.end(); aI != aEnd; ++aI)
|
|
|
|
{
|
|
|
|
const rtl::OString &rKey = aI->first;
|
|
|
|
const rtl::OString &rValue = aI->second;
|
|
|
|
|
|
|
|
if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("upper")))
|
|
|
|
{
|
|
|
|
sal_Int64 nUpper = rValue.toDouble() * nMul;
|
|
|
|
rTarget.SetMax(nUpper);
|
|
|
|
rTarget.SetLast(nUpper);
|
|
|
|
}
|
|
|
|
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("lower")))
|
|
|
|
{
|
|
|
|
sal_Int64 nLower = rValue.toDouble() * nMul;
|
|
|
|
rTarget.SetMin(nLower);
|
|
|
|
rTarget.SetFirst(nLower);
|
|
|
|
}
|
|
|
|
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("value")))
|
|
|
|
{
|
|
|
|
sal_Int64 nValue = rValue.toDouble() * nMul;
|
|
|
|
rTarget.SetValue(nValue);
|
|
|
|
}
|
|
|
|
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("step-increment")))
|
|
|
|
{
|
|
|
|
sal_Int64 nSpinSize = rValue.toDouble() * nMul;
|
|
|
|
rTarget.SetSpinSize(nSpinSize);
|
|
|
|
}
|
|
|
|
else
|
2012-09-25 11:35:47 +01:00
|
|
|
{
|
|
|
|
SAL_WARN("vcl.layout", "unhandled property :" << rKey.getStr());
|
|
|
|
}
|
2012-06-14 14:20:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-26 12:15:22 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|