vcl/inc/vcl/builder.hxx|1
vcl/inc/vcl/tabctrl.hxx|3 +
vcl/source/control/tabctrl.cxx | 30 ++---
vcl/source/window/builder.cxx | 90 +++--
4 files changed, 98 insertions(+), 26 deletions(-)
New commits:
commit 4eab7331684945213897588ae3303be4c1c2453e
Author: Caolán McNamara
Date: Tue Jun 12 16:02:26 2012 +0100
assign tab page ids such that retrofitting existing code is easier
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index f98b552..b44cb3f 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -98,6 +98,7 @@ public:
~VclBuilder();
Window *get_widget_root();
Window *get_by_name(rtl::OString sID);
+rtl::OString get_by_window(const Window *pWindow);
//for the purposes of retrofitting this to the existing code
//look up sID, clone its properties into replacement and
//splice replacement into the tree instead of it, without
diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx
index fd064db..14c68e0 100644
--- a/vcl/inc/vcl/tabctrl.hxx
+++ b/vcl/inc/vcl/tabctrl.hxx
@@ -196,6 +196,9 @@ public:
// returns the rectangle of the tab for page nPageId
Rectangle GetTabBounds( sal_uInt16 nPageId ) const;
+
+// rename nOldId to nNewId);
+void ReassignPageId(sal_uInt16 nOldId, sal_uInt16 nNewId);
};
#endif // _SV_TABCTRL_HXX
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 0ac4060..ccf6b4c 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -2228,7 +2228,20 @@ void TabControl::SetMinimumSizePixel( const Size&
i_rSize )
mpTabCtrlData->maMinSize = i_rSize;
}
-// ---
+void TabControl::ReassignPageId(sal_uInt16 nOldId, sal_uInt16 nNewId)
+{
+for( std::vector< ImplTabItem >::iterator it =
mpTabCtrlData->maItemList.begin();
+ it != mpTabCtrlData->maItemList.end(); ++it )
+{
+if( it->mnId == nOldId )
+it->mnId = nNewId;
+}
+if (mnActPageId == nOldId)
+mnActPageId = nNewId;
+
+if (mnCurPageId == nOldId)
+mnCurPageId = nOldId;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 563322b..2f8e5d2 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -183,21 +183,31 @@ Window *VclBuilder::makeObject(Window *pParent, const
rtl::OString &name, const
if (pParent && pParent->GetType() == WINDOW_TABCONTROL)
{
//We have to add a page
-TabControl *pTabControl = static_cast(pParent);
-TabPage* pPage = new TabPage(pTabControl);
-m_aChildren.push_back(WinAndId(rtl::OString(), pPage));
-
-//And give the page one container as a child to make it a layout
enabled
-//tab page
-VclBin* pContainer = new VclBin(pPage);
-m_aChildren.push_back(WinAndId(rtl::OString(), pContainer));
-pParent = pContainer;
-//keep it simple and make pageid == position
-sal_uInt16 nNewPageId = pTabControl->GetPageCount()+1;
+//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(pParent);
+sal_uInt16 nNewPageId = -(pTabControl->GetPageCount()+1);
pTabControl->InsertPage(nNewPageId, rtl::OUString());
-pTabControl->SetTabPage(nNewPageId, pPage);
pTabControl->SetCurPageId(nNewPageId);
+
+bool bIsPlaceHolder = name.isEmpty();
+
+if (!bIsPlaceHolder)
+{
+TabPage* pPage = new TabPage(pTabControl);
+m_aChildren.push_back(WinAndId(rtl::OString(), pPage));
+
+//And give the page one container as a child to make it a layout
enabled
+//tab page
+VclBin* pContainer = new VclBin(pPage);
+m_aChildren.push_back(WinAndId(rtl::OString(), pContainer));
+pParent = pContainer;
+
+pTabControl->SetTabPage(nNewPageId, pPage);
+}
}
Window *pWindow = NULL;
@@ -341,6 +351,8 @@ void VclBuilder::reorderWithinParent(Window &rWindow,
sal_uInt16 nNewPosition)
void VclBuilder::handleTabChild(Window *pParent, xmlreader::XmlReader &reader)
{
+rtl::OString sID;
+
int nLevel = 1;
stringmap aProperties;
while(1)
@@ -356,6 +368,17 @@ void VclBuilder::handleTabChild(Window *pParent,
xmlreader::XmlReader &reader)
++nLevel;
if (name.equals(RTL_CONSTASCII_STRINGPARAM("property")))
collectProperty(reader, aProperties);
+else if (name.equals(RTL_CONSTASCII_STRINGPARAM("object")))
+{
+while (reader.nextAttribute(&nsId, &name))
+