summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-11-18 22:26:32 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2015-11-18 22:26:32 +0200
commit78214c982e1fab18b9f6c694a3b56c520da1724d (patch)
treec1e2ee01c2fb70338c0da1430d05fb2478d1b12e /vcl/source/window
parenteedcc2c45c09e3180061ae1dfa0eb9d64afc3f39 (diff)
Revert "ToolBox: Remove unused methods"
The ImplLoadRes method *is* used in ToolBox::ToolBox( vcl::Window* pParent, const ResId& rResId ). This change breaks the navigator panel, and therefore the JunitTest_toolkit_unoapi_1 test. This reverts commit 99648095012187ef284d0a9399a8e12878b2a370.
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/toolbox.cxx55
-rw-r--r--vcl/source/window/toolbox2.cxx90
2 files changed, 145 insertions, 0 deletions
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index b9ad577a41fc..01a73059611c 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -1540,6 +1540,61 @@ void ToolBox::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
}
}
+void ToolBox::ImplLoadRes( const ResId& rResId )
+{
+ ResMgr* pMgr = rResId.GetResMgr();
+ if( ! pMgr )
+ return;
+
+ DockingWindow::ImplLoadRes( rResId );
+
+ sal_uLong nObjMask;
+
+ nObjMask = ReadLongRes();
+
+ if ( nObjMask & RSC_TOOLBOX_BUTTONTYPE )
+ SetButtonType( (ButtonType)ReadLongRes() );
+
+ if ( nObjMask & RSC_TOOLBOX_ALIGN )
+ SetAlign( (WindowAlign)ReadLongRes() );
+
+ if ( nObjMask & RSC_TOOLBOX_LINECOUNT )
+ SetLineCount( sal::static_int_cast<sal_uInt16>(ReadLongRes()) );
+
+ if ( nObjMask & RSC_TOOLBOX_CUSTOMIZE )
+ {
+ bool bCust = ReadShortRes();
+ EnableCustomize( bCust );
+ }
+
+ if ( nObjMask & RSC_TOOLBOX_MENUSTRINGS )
+ {
+ bool bCust = ReadShortRes();
+ EnableMenuStrings( bCust );
+ }
+
+ if ( nObjMask & RSC_TOOLBOX_FLOATLINES )
+ SetFloatingLines( ReadShortRes() );
+
+ if ( nObjMask & RSC_TOOLBOX_ITEMIMAGELIST )
+ {
+ maImageList = ImageList( ResId( static_cast<RSHEADER_TYPE*>(GetClassRes()), *pMgr ) );
+ IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE*>(GetClassRes()) ) );
+ }
+
+ if ( nObjMask & RSC_TOOLBOX_ITEMLIST )
+ {
+ sal_uLong nEle = ReadLongRes();
+
+ // insert item
+ for ( sal_uLong i = 0; i < nEle; i++ )
+ {
+ InsertItem( ResId( static_cast<RSHEADER_TYPE *>(GetClassRes()), *pMgr ) );
+ IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE *>(GetClassRes()) ) );
+ }
+ }
+}
+
ToolBox::ToolBox( vcl::Window* pParent, WinBits nStyle ) :
DockingWindow( WINDOW_TOOLBOX )
{
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 7833345eca0e..88995776f914 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -448,6 +448,96 @@ void ToolBox::Select()
pWrapper->GetFloatingWindow()->EndPopupMode();
}
+void ToolBox::InsertItem( const ResId& rResId, sal_uInt16 nPos )
+{
+ sal_uLong nObjMask;
+ bool bImage = false; // has image
+
+ // create item
+ ImplToolItem aItem;
+
+ GetRes( rResId.SetRT( RSC_TOOLBOXITEM ) );
+ nObjMask = ReadLongRes();
+
+ if ( nObjMask & RSC_TOOLBOXITEM_ID )
+ aItem.mnId = sal::static_int_cast<sal_uInt16>(ReadLongRes());
+ else
+ aItem.mnId = 1;
+
+ if ( nObjMask & RSC_TOOLBOXITEM_TYPE )
+ aItem.meType = (ToolBoxItemType)ReadLongRes();
+
+ if ( nObjMask & RSC_TOOLBOXITEM_STATUS )
+ aItem.mnBits = (ToolBoxItemBits)ReadLongRes();
+
+ if( nObjMask & RSC_TOOLBOXITEM_HELPID )
+ aItem.maHelpId = ReadByteStringRes();
+
+ if ( nObjMask & RSC_TOOLBOXITEM_TEXT )
+ {
+ aItem.maText = ReadStringRes();
+ aItem.maText = ImplConvertMenuString( aItem.maText );
+ }
+ if ( nObjMask & RSC_TOOLBOXITEM_HELPTEXT )
+ aItem.maHelpText = ReadStringRes();
+
+ if ( nObjMask & RSC_TOOLBOXITEM_BITMAP )
+ {
+ Bitmap aBmp = Bitmap( ResId( static_cast<RSHEADER_TYPE*>(GetClassRes()), *rResId.GetResMgr() ) );
+ IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE*>(GetClassRes()) ) );
+ aItem.maImage = Image( aBmp, IMAGE_STDBTN_COLOR );
+ bImage = true;
+ }
+ if ( nObjMask & RSC_TOOLBOXITEM_IMAGE )
+ {
+ aItem.maImage = Image( ResId( static_cast<RSHEADER_TYPE*>(GetClassRes()), *rResId.GetResMgr() ) );
+ IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE*>(GetClassRes()) ) );
+ bImage = true;
+ }
+ if ( nObjMask & RSC_TOOLBOXITEM_DISABLE )
+ aItem.mbEnabled = ReadShortRes() == 0;
+
+ if ( nObjMask & RSC_TOOLBOXITEM_STATE )
+ aItem.meState = (TriState)ReadLongRes();
+
+ if ( nObjMask & RSC_TOOLBOXITEM_HIDE )
+ aItem.mbVisible = ReadShortRes() == 0;
+
+ if ( nObjMask & RSC_TOOLBOXITEM_COMMAND )
+ aItem.maCommandStr = ReadStringRes();
+
+ // if no image is loaded, try to load one from the image list
+ if ( !bImage && aItem.mnId )
+ aItem.maImage = maImageList.GetImage( aItem.mnId );
+
+ // if this is a ButtonItem, check ID
+ bool bNewCalc;
+ if ( aItem.meType != ToolBoxItemType::BUTTON )
+ {
+ bNewCalc = false;
+ aItem.mnId = 0;
+ }
+ else
+ {
+ bNewCalc = true;
+
+ DBG_ASSERT( aItem.mnId, "ToolBox::InsertItem(): ItemId == 0" );
+ DBG_ASSERT( GetItemPos( aItem.mnId ) == TOOLBOX_ITEM_NOTFOUND,
+ "ToolBox::InsertItem(): ItemId already exists" );
+ }
+
+ // create item and add to list
+ mpData->m_aItems.insert( (nPos < mpData->m_aItems.size()) ? mpData->m_aItems.begin()+nPos : mpData->m_aItems.end(), aItem );
+ mpData->ImplClearLayoutData();
+
+ // recalculate ToolBox and redraw
+ ImplInvalidate( bNewCalc );
+
+ // Notify
+ sal_uInt16 nNewPos = sal::static_int_cast<sal_uInt16>(( nPos == TOOLBOX_APPEND ) ? ( mpData->m_aItems.size() - 1 ) : nPos);
+ CallEventListeners( VCLEVENT_TOOLBOX_ITEMADDED, reinterpret_cast< void* >( nNewPos ) );
+}
+
void ToolBox::InsertItem( sal_uInt16 nItemId, const Image& rImage,
ToolBoxItemBits nBits, sal_uInt16 nPos )
{