Kaydet (Commit) cfcfc5e9 authored tarafından Michael Meeks's avatar Michael Meeks

VclBuilder - use VclPtr more consistently internally.

Fixes a number of TabPage related leaks.

Change-Id: I7b904e9bbbce652d2dc645952e266cde102ed194
üst fc8c282e
...@@ -901,7 +901,7 @@ namespace ...@@ -901,7 +901,7 @@ namespace
pButton->SetCommandHandler(aCommand); pButton->SetCommandHandler(aCommand);
} }
Button* extractStockAndBuildPushButton(vcl::Window *pParent, VclBuilder::stringmap &rMap) VclPtr<Button> extractStockAndBuildPushButton(vcl::Window *pParent, VclBuilder::stringmap &rMap)
{ {
WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER; WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER;
...@@ -909,45 +909,45 @@ namespace ...@@ -909,45 +909,45 @@ namespace
bool bIsStock = extractStock(rMap); bool bIsStock = extractStock(rMap);
Button *pWindow = NULL; VclPtr<Button> xWindow;
if (bIsStock) if (bIsStock)
{ {
OString sType = extractLabel(rMap); OString sType = extractLabel(rMap);
if (sType == "gtk-ok") if (sType == "gtk-ok")
pWindow = new OKButton(pParent, nBits); xWindow = VclPtr<OKButton>::Create(pParent, nBits);
else if (sType == "gtk-cancel") else if (sType == "gtk-cancel")
pWindow = new CancelButton(pParent, nBits); xWindow = VclPtr<CancelButton>::Create(pParent, nBits);
else if (sType == "gtk-close") else if (sType == "gtk-close")
pWindow = new CloseButton(pParent, nBits); xWindow = VclPtr<CloseButton>::Create(pParent, nBits);
else if (sType == "gtk-help") else if (sType == "gtk-help")
pWindow = new HelpButton(pParent, nBits); xWindow = VclPtr<HelpButton>::Create(pParent, nBits);
else else
{ {
pWindow = new PushButton(pParent, nBits); xWindow = VclPtr<PushButton>::Create(pParent, nBits);
pWindow->SetText(getStockText(sType)); xWindow->SetText(getStockText(sType));
} }
} }
if (!pWindow) if (!xWindow)
pWindow = new PushButton(pParent, nBits); xWindow = VclPtr<PushButton>::Create(pParent, nBits);
return pWindow; return xWindow;
} }
Button * extractStockAndBuildMenuButton(vcl::Window *pParent, VclBuilder::stringmap &rMap) VclPtr<Button> extractStockAndBuildMenuButton(vcl::Window *pParent, VclBuilder::stringmap &rMap)
{ {
WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK; WinBits nBits = WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_3DLOOK;
nBits |= extractRelief(rMap); nBits |= extractRelief(rMap);
Button *pWindow = new MenuButton(pParent, nBits); VclPtr<Button> xWindow = VclPtr<MenuButton>::Create(pParent, nBits);
if (extractStock(rMap)) if (extractStock(rMap))
{ {
pWindow->SetText(getStockText(extractLabel(rMap))); xWindow->SetText(getStockText(extractLabel(rMap)));
} }
return pWindow; return xWindow;
} }
OString extractUnit(const OString& sPattern) OString extractUnit(const OString& sPattern)
...@@ -1285,7 +1285,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1285,7 +1285,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
if (!bIsPlaceHolder) if (!bIsPlaceHolder)
{ {
TabPage* pPage = new TabPage(pTabControl); VclPtrInstance<TabPage> pPage(pTabControl);
pPage->Show(); pPage->Show();
//Make up a name for it //Make up a name for it
...@@ -1297,7 +1297,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1297,7 +1297,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
//And give the page one container as a child to make it a layout enabled //And give the page one container as a child to make it a layout enabled
//tab page //tab page
VclBin* pContainer = new VclBin(pPage); VclPtrInstance<VclBin> pContainer(pPage);
pContainer->Show(); pContainer->Show();
m_aChildren.push_back(WinAndId(OString(), pContainer, false)); m_aChildren.push_back(WinAndId(OString(), pContainer, false));
pContainer->SetHelpId(m_sHelpRoot + sTabPageId + OString("-bin")); pContainer->SetHelpId(m_sHelpRoot + sTabPageId + OString("-bin"));
...@@ -1312,71 +1312,71 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1312,71 +1312,71 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
extractButtonImage(id, rMap, name == "GtkRadioButton"); extractButtonImage(id, rMap, name == "GtkRadioButton");
vcl::Window *pWindow = NULL; VclPtr<vcl::Window> xWindow;
if (name == "GtkDialog") if (name == "GtkDialog")
{ {
WinBits nBits = WB_CLIPCHILDREN|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; WinBits nBits = WB_CLIPCHILDREN|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE;
if (extractResizable(rMap)) if (extractResizable(rMap))
nBits |= WB_SIZEABLE; nBits |= WB_SIZEABLE;
pWindow = new Dialog(pParent, nBits); xWindow = VclPtr<Dialog>::Create(pParent, nBits);
} }
else if (name == "GtkMessageDialog") else if (name == "GtkMessageDialog")
{ {
WinBits nBits = WB_CLIPCHILDREN|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE; WinBits nBits = WB_CLIPCHILDREN|WB_MOVEABLE|WB_3DLOOK|WB_CLOSEABLE;
if (extractResizable(rMap)) if (extractResizable(rMap))
nBits |= WB_SIZEABLE; nBits |= WB_SIZEABLE;
pWindow = new MessageDialog(pParent, nBits); xWindow = VclPtr<MessageDialog>(new MessageDialog(pParent, nBits), SAL_NO_ACQUIRE);
} }
else if (name == "GtkBox") else if (name == "GtkBox")
{ {
bVertical = extractOrientation(rMap); bVertical = extractOrientation(rMap);
if (bVertical) if (bVertical)
pWindow = new VclVBox(pParent); xWindow = VclPtr<VclVBox>::Create(pParent);
else else
pWindow = new VclHBox(pParent); xWindow = VclPtr<VclHBox>::Create(pParent);
} }
else if (name == "GtkHBox") else if (name == "GtkHBox")
pWindow = new VclHBox(pParent); xWindow = VclPtr<VclHBox>::Create(pParent);
else if (name == "GtkVBox") else if (name == "GtkVBox")
pWindow = new VclVBox(pParent); xWindow = VclPtr<VclVBox>::Create(pParent);
else if (name == "GtkButtonBox") else if (name == "GtkButtonBox")
{ {
bVertical = extractOrientation(rMap); bVertical = extractOrientation(rMap);
if (bVertical) if (bVertical)
pWindow = new VclVButtonBox(pParent); xWindow = VclPtr<VclVButtonBox>::Create(pParent);
else else
pWindow = new VclHButtonBox(pParent); xWindow = VclPtr<VclHButtonBox>::Create(pParent);
} }
else if (name == "GtkHButtonBox") else if (name == "GtkHButtonBox")
pWindow = new VclHButtonBox(pParent); xWindow = VclPtr<VclHButtonBox>::Create(pParent);
else if (name == "GtkVButtonBox") else if (name == "GtkVButtonBox")
pWindow = new VclVButtonBox(pParent); xWindow = VclPtr<VclVButtonBox>::Create(pParent);
else if (name == "GtkGrid") else if (name == "GtkGrid")
pWindow = new VclGrid(pParent); xWindow = VclPtr<VclGrid>::Create(pParent);
else if (name == "GtkFrame") else if (name == "GtkFrame")
pWindow = new VclFrame(pParent); xWindow = VclPtr<VclFrame>::Create(pParent);
else if (name == "GtkExpander") else if (name == "GtkExpander")
{ {
VclExpander *pExpander = new VclExpander(pParent); VclPtrInstance<VclExpander> pExpander(pParent);
m_pParserState->m_aExpanderWidgets.push_back(pExpander); m_pParserState->m_aExpanderWidgets.push_back(pExpander);
pWindow = pExpander; xWindow = pExpander;
} }
else if (name == "GtkAlignment") else if (name == "GtkAlignment")
pWindow = new VclAlignment(pParent); xWindow = VclPtr<VclAlignment>::Create(pParent);
else if (name == "GtkButton") else if (name == "GtkButton")
{ {
Button *pButton; VclPtr<Button> xButton;
OString sMenu = extractCustomProperty(rMap); OString sMenu = extractCustomProperty(rMap);
if (sMenu.isEmpty()) if (sMenu.isEmpty())
pButton = extractStockAndBuildPushButton(pParent, rMap); xButton = extractStockAndBuildPushButton(pParent, rMap);
else else
{ {
pButton = extractStockAndBuildMenuButton(pParent, rMap); xButton = extractStockAndBuildMenuButton(pParent, rMap);
m_pParserState->m_aButtonMenuMaps.push_back(ButtonMenuMap(id, sMenu)); m_pParserState->m_aButtonMenuMaps.push_back(ButtonMenuMap(id, sMenu));
} }
pButton->SetImageAlign(IMAGEALIGN_LEFT); //default to left xButton->SetImageAlign(IMAGEALIGN_LEFT); //default to left
setupFromActionName(pButton, rMap, m_xFrame); setupFromActionName(xButton, rMap, m_xFrame);
pWindow = pButton; xWindow = xButton;
} }
else if (name == "GtkRadioButton") else if (name == "GtkRadioButton")
{ {
...@@ -1385,9 +1385,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1385,9 +1385,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
OString sWrap = extractCustomProperty(rMap); OString sWrap = extractCustomProperty(rMap);
if (!sWrap.isEmpty()) if (!sWrap.isEmpty())
nBits |= WB_WORDBREAK; nBits |= WB_WORDBREAK;
RadioButton *pButton = new RadioButton(pParent, nBits); VclPtr<RadioButton> xButton = VclPtr<RadioButton>::Create(pParent, nBits);
pButton->SetImageAlign(IMAGEALIGN_LEFT); //default to left xButton->SetImageAlign(IMAGEALIGN_LEFT); //default to left
pWindow = pButton; xWindow = xButton;
} }
else if (name == "GtkCheckButton") else if (name == "GtkCheckButton")
{ {
...@@ -1397,13 +1397,15 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1397,13 +1397,15 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
nBits |= WB_WORDBREAK; nBits |= WB_WORDBREAK;
//maybe always import as TriStateBox and enable/disable tristate //maybe always import as TriStateBox and enable/disable tristate
bool bIsTriState = extractInconsistent(rMap); bool bIsTriState = extractInconsistent(rMap);
CheckBox *pCheckBox = bIsTriState ? VclPtr<CheckBox> xCheckBox;
new TriStateBox(pParent, nBits) :
new CheckBox(pParent, nBits);
if (bIsTriState) if (bIsTriState)
pCheckBox->SetState(TRISTATE_INDET); xCheckBox = VclPtr<TriStateBox>::Create(pParent, nBits);
pCheckBox->SetImageAlign(IMAGEALIGN_LEFT); //default to left else
pWindow = pCheckBox; xCheckBox = VclPtr<CheckBox>::Create(pParent, nBits);
if (bIsTriState)
xCheckBox->SetState(TRISTATE_INDET);
xCheckBox->SetImageAlign(IMAGEALIGN_LEFT); //default to left
xWindow = xCheckBox;
} }
else if (name == "GtkSpinButton") else if (name == "GtkSpinButton")
{ {
...@@ -1419,7 +1421,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1419,7 +1421,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
{ {
connectNumericFormatterAdjustment(id, sAdjustment); connectNumericFormatterAdjustment(id, sAdjustment);
SAL_INFO("vcl.layout", "making numeric field for " << name.getStr() << " " << sUnit.getStr()); SAL_INFO("vcl.layout", "making numeric field for " << name.getStr() << " " << sUnit.getStr());
pWindow = new NumericField(pParent, nBits); xWindow = VclPtr<NumericField>::Create(pParent, nBits);
} }
else else
{ {
...@@ -1427,31 +1429,29 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1427,31 +1429,29 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
{ {
connectTimeFormatterAdjustment(id, sAdjustment); connectTimeFormatterAdjustment(id, sAdjustment);
SAL_INFO("vcl.layout", "making time field for " << name.getStr() << " " << sUnit.getStr()); SAL_INFO("vcl.layout", "making time field for " << name.getStr() << " " << sUnit.getStr());
TimeField *pField = new TimeField(pParent, nBits); xWindow = VclPtr<TimeField>::Create(pParent, nBits);
pWindow = pField;
} }
else if (sPattern == "yy:mm:dd") else if (sPattern == "yy:mm:dd")
{ {
connectDateFormatterAdjustment(id, sAdjustment); connectDateFormatterAdjustment(id, sAdjustment);
SAL_INFO("vcl.layout", "making date field for " << name.getStr() << " " << sUnit.getStr()); SAL_INFO("vcl.layout", "making date field for " << name.getStr() << " " << sUnit.getStr());
DateField *pField = new DateField(pParent, nBits); xWindow = VclPtr<DateField>::Create(pParent, nBits);
pWindow = pField;
} }
else else
{ {
connectNumericFormatterAdjustment(id, sAdjustment); connectNumericFormatterAdjustment(id, sAdjustment);
FieldUnit eUnit = detectMetricUnit(sUnit); FieldUnit eUnit = detectMetricUnit(sUnit);
SAL_INFO("vcl.layout", "making metric field for " << name.getStr() << " " << sUnit.getStr()); SAL_INFO("vcl.layout", "making metric field for " << name.getStr() << " " << sUnit.getStr());
MetricField *pField = new MetricField(pParent, nBits); VclPtrInstance<MetricField> xField(pParent, nBits);
pField->SetUnit(eUnit); xField->SetUnit(eUnit);
if (eUnit == FUNIT_CUSTOM) if (eUnit == FUNIT_CUSTOM)
pField->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8)); xField->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8));
pWindow = pField; xWindow = xField;
} }
} }
} }
else if (name == "GtkLinkButton") else if (name == "GtkLinkButton")
pWindow = new FixedHyperlink(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK|WB_NOLABEL); xWindow = VclPtr<FixedHyperlink>::Create(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK|WB_NOLABEL);
else if ((name == "GtkComboBox") || (name == "GtkComboBoxText") || (name == "VclComboBoxText")) else if ((name == "GtkComboBox") || (name == "GtkComboBoxText") || (name == "VclComboBoxText"))
{ {
OString sPattern = extractCustomProperty(rMap); OString sPattern = extractCustomProperty(rMap);
...@@ -1474,25 +1474,25 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1474,25 +1474,25 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
<< " unit: " << sUnit.getStr() << " unit: " << sUnit.getStr()
<< " name: " << id.getStr() << " name: " << id.getStr()
<< " use a VclComboBoxNumeric instead"); << " use a VclComboBoxNumeric instead");
MetricBox *pBox = new MetricBox(pParent, nBits); VclPtrInstance<MetricBox> xBox(pParent, nBits);
pBox->EnableAutoSize(true); xBox->EnableAutoSize(true);
pBox->SetUnit(eUnit); xBox->SetUnit(eUnit);
pBox->SetDecimalDigits(extractDecimalDigits(sPattern)); xBox->SetDecimalDigits(extractDecimalDigits(sPattern));
if (eUnit == FUNIT_CUSTOM) if (eUnit == FUNIT_CUSTOM)
pBox->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8)); xBox->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8));
pWindow = pBox; xWindow = xBox;
} }
else if (extractEntry(rMap)) else if (extractEntry(rMap))
{ {
ComboBox* pComboBox = new ComboBox(pParent, nBits); VclPtrInstance<ComboBox> xComboBox(pParent, nBits);
pComboBox->EnableAutoSize(true); xComboBox->EnableAutoSize(true);
pWindow = pComboBox; xWindow = xComboBox;
} }
else else
{ {
ListBox *pListBox = new ListBox(pParent, nBits|WB_SIMPLEMODE); VclPtrInstance<ListBox> xListBox(pParent, nBits|WB_SIMPLEMODE);
pListBox->EnableAutoSize(true); xListBox->EnableAutoSize(true);
pWindow = pListBox; xWindow = xListBox;
} }
} }
else if (name == "VclComboBoxNumeric") else if (name == "VclComboBoxNumeric")
...@@ -1514,22 +1514,22 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1514,22 +1514,22 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
OString sUnit = extractUnit(sPattern); OString sUnit = extractUnit(sPattern);
FieldUnit eUnit = detectMetricUnit(sUnit); FieldUnit eUnit = detectMetricUnit(sUnit);
SAL_INFO("vcl.layout", "making metric box for " << name.getStr() << " " << sUnit.getStr()); SAL_INFO("vcl.layout", "making metric box for " << name.getStr() << " " << sUnit.getStr());
MetricBox *pBox = new MetricBox(pParent, nBits); VclPtrInstance<MetricBox> xBox(pParent, nBits);
pBox->EnableAutoSize(true); xBox->EnableAutoSize(true);
pBox->SetUnit(eUnit); xBox->SetUnit(eUnit);
pBox->SetDecimalDigits(extractDecimalDigits(sPattern)); xBox->SetDecimalDigits(extractDecimalDigits(sPattern));
if (eUnit == FUNIT_CUSTOM) if (eUnit == FUNIT_CUSTOM)
pBox->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8)); xBox->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8));
pWindow = pBox; xWindow = xBox;
} }
else else
{ {
SAL_INFO("vcl.layout", "making numeric box for " << name.getStr()); SAL_INFO("vcl.layout", "making numeric box for " << name.getStr());
connectNumericFormatterAdjustment(id, sAdjustment); connectNumericFormatterAdjustment(id, sAdjustment);
NumericBox* pBox = new NumericBox(pParent, nBits); VclPtrInstance<NumericBox> xBox(pParent, nBits);
if (bDropdown) if (bDropdown)
pBox->EnableAutoSize(true); xBox->EnableAutoSize(true);
pWindow = pBox; xWindow = xBox;
} }
} }
else if (name == "GtkTreeView") else if (name == "GtkTreeView")
...@@ -1547,9 +1547,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1547,9 +1547,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
nWinStyle |= WB_BORDER; nWinStyle |= WB_BORDER;
//ListBox manages its own scrolling, //ListBox manages its own scrolling,
vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle); vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle);
pWindow = new ListBox(pRealParent, nWinStyle); xWindow = VclPtr<ListBox>::Create(pRealParent, nWinStyle);
if (pRealParent != pParent) if (pRealParent != pParent)
cleanupWidgetOwnScrolling(pParent, pWindow, rMap); cleanupWidgetOwnScrolling(pParent, xWindow, rMap);
} }
else if (name == "GtkLabel") else if (name == "GtkLabel")
{ {
...@@ -1559,14 +1559,14 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1559,14 +1559,14 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
nWinStyle |= WB_BORDER; nWinStyle |= WB_BORDER;
extractMnemonicWidget(id, rMap); extractMnemonicWidget(id, rMap);
if (extractSelectable(rMap)) if (extractSelectable(rMap))
pWindow = new SelectableFixedText(pParent, nWinStyle); xWindow = VclPtr<SelectableFixedText>::Create(pParent, nWinStyle);
else else
pWindow = new FixedText(pParent, nWinStyle); xWindow = VclPtr<FixedText>::Create(pParent, nWinStyle);
} }
else if (name == "GtkImage") else if (name == "GtkImage")
{ {
extractStock(id, rMap); extractStock(id, rMap);
pWindow = new FixedImage(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK|WB_SCALE); xWindow = VclPtr<FixedImage>::Create(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK|WB_SCALE);
//such parentless GtkImages are temps used to set icons on buttons //such parentless GtkImages are temps used to set icons on buttons
//default them to hidden to stop e.g. insert->index entry flicking temp //default them to hidden to stop e.g. insert->index entry flicking temp
//full screen windows //full screen windows
...@@ -1579,52 +1579,45 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1579,52 +1579,45 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
else if (name == "GtkSeparator") else if (name == "GtkSeparator")
{ {
bVertical = extractOrientation(rMap); bVertical = extractOrientation(rMap);
if (bVertical) xWindow = VclPtr<FixedLine>::Create(pParent, bVertical ? WB_VERT : WB_HORZ);
pWindow = new FixedLine(pParent, WB_VERT);
else
pWindow = new FixedLine(pParent, WB_HORZ);
} }
else if (name == "GtkScrollbar") else if (name == "GtkScrollbar")
{ {
extractAdjustmentToMap(id, rMap, m_pParserState->m_aScrollAdjustmentMaps); extractAdjustmentToMap(id, rMap, m_pParserState->m_aScrollAdjustmentMaps);
bVertical = extractOrientation(rMap); bVertical = extractOrientation(rMap);
if (bVertical) xWindow = VclPtr<ScrollBar>::Create(pParent, bVertical ? WB_VERT : WB_HORZ);
pWindow = new ScrollBar(pParent, WB_VERT);
else
pWindow = new ScrollBar(pParent, WB_HORZ);
} }
else if (name == "GtkProgressBar") else if (name == "GtkProgressBar")
{ {
extractAdjustmentToMap(id, rMap, m_pParserState->m_aScrollAdjustmentMaps); extractAdjustmentToMap(id, rMap, m_pParserState->m_aScrollAdjustmentMaps);
bVertical = extractOrientation(rMap); bVertical = extractOrientation(rMap);
if (bVertical) xWindow = VclPtr<ProgressBar>::Create(pParent, bVertical ? WB_VERT : WB_HORZ);
pWindow = new ProgressBar(pParent, WB_VERT);
else
pWindow = new ProgressBar(pParent, WB_HORZ);
} }
else if (name == "GtkScrolledWindow") else if (name == "GtkScrolledWindow")
{ {
pWindow = new VclScrolledWindow(pParent); xWindow = VclPtr<VclScrolledWindow>::Create(pParent);
} }
else if (name == "GtkViewport") else if (name == "GtkViewport")
{ {
pWindow = new VclViewport(pParent); xWindow = VclPtr<VclViewport>::Create(pParent);
} }
else if (name == "GtkEventBox") else if (name == "GtkEventBox")
{ {
pWindow = new VclEventBox(pParent); xWindow = VclPtr<VclEventBox>::Create(pParent);
} }
else if (name == "GtkEntry") else if (name == "GtkEntry")
{ {
pWindow = new Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK); xWindow = VclPtr<Edit>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
ensureDefaultWidthChars(rMap); ensureDefaultWidthChars(rMap);
} }
else if (name == "GtkNotebook") else if (name == "GtkNotebook")
pWindow = new TabControl(pParent, WB_STDTABCONTROL|WB_3DLOOK); {
xWindow = VclPtr<TabControl>::Create(pParent, WB_STDTABCONTROL|WB_3DLOOK);
}
else if (name == "GtkDrawingArea") else if (name == "GtkDrawingArea")
{ {
OString sBorder = extractCustomProperty(rMap); OString sBorder = extractCustomProperty(rMap);
pWindow = new vcl::Window(pParent, sBorder.isEmpty() ? 0 : WB_BORDER); xWindow = VclPtr<vcl::Window>::Create(pParent, sBorder.isEmpty() ? 0 : WB_BORDER);
} }
else if (name == "GtkTextView") else if (name == "GtkTextView")
{ {
...@@ -1636,13 +1629,13 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1636,13 +1629,13 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
nWinStyle |= WB_BORDER; nWinStyle |= WB_BORDER;
//VclMultiLineEdit manages its own scrolling, //VclMultiLineEdit manages its own scrolling,
vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle); vcl::Window *pRealParent = prepareWidgetOwnScrolling(pParent, nWinStyle);
pWindow = new VclMultiLineEdit(pRealParent, nWinStyle); xWindow = VclPtr<VclMultiLineEdit>::Create(pRealParent, nWinStyle);
if (pRealParent != pParent) if (pRealParent != pParent)
cleanupWidgetOwnScrolling(pParent, pWindow, rMap); cleanupWidgetOwnScrolling(pParent, xWindow, rMap);
} }
else if (name == "GtkSpinner") else if (name == "GtkSpinner")
{ {
pWindow = new Throbber(pParent, WB_3DLOOK); xWindow = VclPtr<Throbber>::Create(pParent, WB_3DLOOK);
} }
else if (name == "GtkScale") else if (name == "GtkScale")
{ {
...@@ -1657,11 +1650,11 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1657,11 +1650,11 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
WinBits nWinStyle = bVertical ? WB_VERT : WB_HORZ; WinBits nWinStyle = bVertical ? WB_VERT : WB_HORZ;
pWindow = new Slider(pParent, nWinStyle); xWindow = VclPtr<Slider>::Create(pParent, nWinStyle);
} }
else if (name == "GtkToolbar") else if (name == "GtkToolbar")
{ {
pWindow = new ToolBox(pParent, WB_3DLOOK | WB_TABSTOP); xWindow = VclPtr<ToolBox>::Create(pParent, WB_3DLOOK | WB_TABSTOP);
} }
else if (name == "GtkToolButton" || name == "GtkMenuToolButton") else if (name == "GtkToolButton" || name == "GtkMenuToolButton")
{ {
...@@ -1719,9 +1712,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1719,9 +1712,9 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
{ {
WinBits nBits = extractDeferredBits(rMap); WinBits nBits = extractDeferredBits(rMap);
if (nBits & WB_DOCKABLE) if (nBits & WB_DOCKABLE)
pWindow = new DockingWindow(pParent, nBits|WB_MOVEABLE); xWindow = VclPtr<DockingWindow>::Create(pParent, nBits|WB_MOVEABLE);
else else
pWindow = new FloatingWindow(pParent, nBits|WB_MOVEABLE); xWindow = VclPtr<FloatingWindow>::Create(pParent, nBits|WB_MOVEABLE);
} }
else else
{ {
...@@ -1764,23 +1757,22 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & ...@@ -1764,23 +1757,22 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
customMakeWidget pFunction = reinterpret_cast<customMakeWidget>(osl_getFunctionSymbol((oslModule) RTLD_DEFAULT, sFunction.pData)); customMakeWidget pFunction = reinterpret_cast<customMakeWidget>(osl_getFunctionSymbol((oslModule) RTLD_DEFAULT, sFunction.pData));
#endif #endif
if (pFunction) if (pFunction)
pWindow = (*pFunction)(pParent, rMap); xWindow = VclPtr<vcl::Window>(pFunction(pParent, rMap), SAL_NO_ACQUIRE);
} }
} }
SAL_WARN_IF(!pWindow, "vcl.layout", "probably need to implement " << name.getStr() << " or add a make" << name.getStr() << " function"); SAL_WARN_IF(!xWindow, "vcl.layout", "probably need to implement " << name.getStr() << " or add a make" << name.getStr() << " function");
if (pWindow) if (xWindow)
{ {
VclPtr< vcl::Window > xWindow( pWindow ); xWindow->SetHelpId(m_sHelpRoot + id);
pWindow->SetHelpId(m_sHelpRoot + id);
SAL_INFO("vcl.layout", "for " << name.getStr() << SAL_INFO("vcl.layout", "for " << name.getStr() <<
", created " << pWindow << " child of " << ", created " << xWindow.get() << " child of " <<
pParent << "(" << pWindow->mpWindowImpl->mpParent.get() << "/" << pParent << "(" << xWindow->mpWindowImpl->mpParent.get() << "/" <<
pWindow->mpWindowImpl->mpRealParent.get() << "/" << xWindow->mpWindowImpl->mpRealParent.get() << "/" <<
pWindow->mpWindowImpl->mpBorderWindow.get() << ") with helpid " << xWindow->mpWindowImpl->mpBorderWindow.get() << ") with helpid " <<
pWindow->GetHelpId().getStr()); xWindow->GetHelpId().getStr());
m_aChildren.push_back(WinAndId(id, xWindow, bVertical)); m_aChildren.push_back(WinAndId(id, xWindow, bVertical));
} }
return VclPtr<vcl::Window>(pWindow, SAL_NO_ACQUIRE); return xWindow;
} }
namespace namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment