diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-12-15 20:33:03 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-12-17 09:35:25 +0000 |
commit | cbcb304b8be5d0824872625b5373729a79042f0f (patch) | |
tree | 284c4285e53df9d99dfc41d8842b9333c5370f93 /vcl | |
parent | 98818ee54e3555e2ed8fe3a2160095a1fe84b818 (diff) |
allow tabpageids to have names which can be queried
and in the .ui builder set that name from the name of the
label widget matching that tab
which allows human understandable names to be used in looking
up the pageids for a given tab page rather than fragile
by_position so tab pages can be freely moved around without
busting the code
Change-Id: Ieaff1408b25545c561a0b28c51ec205af6e1400f
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/tabctrl.hxx | 18 | ||||
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 46 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 4 |
3 files changed, 52 insertions, 16 deletions
diff --git a/vcl/inc/vcl/tabctrl.hxx b/vcl/inc/vcl/tabctrl.hxx index 649ac315cc8d..39cbad314c48 100644 --- a/vcl/inc/vcl/tabctrl.hxx +++ b/vcl/inc/vcl/tabctrl.hxx @@ -128,11 +128,12 @@ public: void Clear(); void EnablePage( sal_uInt16 nPageId, bool bEnable = true ); - sal_uInt16 GetPageCount() const; - sal_uInt16 GetPageId( sal_uInt16 nPos ) const; - sal_uInt16 GetPagePos( sal_uInt16 nPageId ) const; - sal_uInt16 GetPageId( const Point& rPos ) const; - sal_uInt16 GetPageId( const TabPage& rPage ) const; + sal_uInt16 GetPagePos( sal_uInt16 nPageId ) const; + sal_uInt16 GetPageCount() const; + sal_uInt16 GetPageId( sal_uInt16 nPos ) const; + sal_uInt16 GetPageId( const Point& rPos ) const; + sal_uInt16 GetPageId( const TabPage& rPage ) const; + sal_uInt16 GetPageId( const OString& rName ) const; void SetCurPageId( sal_uInt16 nPageId ); sal_uInt16 GetCurPageId() const; @@ -153,8 +154,11 @@ public: void SetHelpText( sal_uInt16 nPageId, const XubString& rText ); const XubString& GetHelpText( sal_uInt16 nPageId ) const; - void SetHelpId( sal_uInt16 nPageId, const rtl::OString& rId ) const; - rtl::OString GetHelpId( sal_uInt16 nPageId ) const; + void SetHelpId( sal_uInt16 nPageId, const OString& rId ) const; + OString GetHelpId( sal_uInt16 nPageId ) const; + + void SetPageName( sal_uInt16 nPageId, const OString& rName ) const; + OString GetPageName( sal_uInt16 nPageId ) const; void SetPageImage( sal_uInt16 nPageId, const Image& rImage ); diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index d0cd3bf7c47b..e5eb0ce74f06 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -42,14 +42,15 @@ struct ImplTabItem { - sal_uInt16 mnId; + sal_uInt16 mnId; TabPage* mpTabPage; String maText; String maFormatText; String maHelpText; - rtl::OString maHelpId; + OString maHelpId; + OString maTabName; Rectangle maRect; - sal_uInt16 mnLine; + sal_uInt16 mnLine; bool mbFullVisible; bool mbEnabled; Image maTabImage; @@ -1855,6 +1856,18 @@ sal_uInt16 TabControl::GetPageId( const TabPage& rPage ) const return 0; } +sal_uInt16 TabControl::GetPageId( const OString& rName ) const +{ + for( std::vector< ImplTabItem >::const_iterator it = mpTabCtrlData->maItemList.begin(); + it != mpTabCtrlData->maItemList.end(); ++it ) + { + if ( it->maTabName == rName ) + return it->mnId; + } + + return 0; +} + // ----------------------------------------------------------------------- void TabControl::SetCurPageId( sal_uInt16 nPageId ) @@ -2036,7 +2049,7 @@ const XubString& TabControl::GetHelpText( sal_uInt16 nPageId ) const // ----------------------------------------------------------------------- -void TabControl::SetHelpId( sal_uInt16 nPageId, const rtl::OString& rId ) const +void TabControl::SetHelpId( sal_uInt16 nPageId, const OString& rId ) const { ImplTabItem* pItem = ImplGetItem( nPageId ); @@ -2044,15 +2057,32 @@ void TabControl::SetHelpId( sal_uInt16 nPageId, const rtl::OString& rId ) const pItem->maHelpId = rId; } -rtl::OString TabControl::GetHelpId( sal_uInt16 nPageId ) const +OString TabControl::GetHelpId( sal_uInt16 nPageId ) const +{ + ImplTabItem* pItem = ImplGetItem( nPageId ); + + if (pItem) + return pItem->maHelpId; + + return OString(); +} + +void TabControl::SetPageName( sal_uInt16 nPageId, const OString& rName ) const { - rtl::OString aRet; ImplTabItem* pItem = ImplGetItem( nPageId ); if ( pItem ) - aRet = pItem->maHelpId; + pItem->maTabName = rName; +} - return aRet; +OString TabControl::GetPageName( sal_uInt16 nPageId ) const +{ + ImplTabItem* pItem = ImplGetItem( nPageId ); + + if (pItem) + return pItem->maTabName; + + return OString(); } // ----------------------------------------------------------------------- diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index a328bb30ec36..9a6b91102512 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1137,8 +1137,10 @@ void VclBuilder::handleTabChild(Window *pParent, xmlreader::XmlReader &reader) VclBuilder::stringmap::iterator aFind = aProperties.find(OString("label")); if (aFind != aProperties.end()) { - pTabControl->SetPageText(pTabControl->GetCurPageId(), + sal_uInt16 nPageId = pTabControl->GetCurPageId(); + pTabControl->SetPageText(nPageId, OStringToOUString(aFind->second, RTL_TEXTENCODING_UTF8)); + pTabControl->SetPageName(nPageId, sID); } else pTabControl->RemovePage(pTabControl->GetCurPageId()); |