Kaydet (Commit) 489af4ed authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

Convert insert buttons to the generic controller

Change-Id: If7c6c1c5000893fca4205162526b4b4035637c11
üst dac1be92
......@@ -176,6 +176,48 @@
</node>
</node>
<node oor:name="ToolBar">
<node oor:name="InsertControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:InsertCtrl</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.framework.SubToolBarController</value>
</prop>
<prop oor:name="Value">
<value>insertbar;.uno:InsertGraphic</value>
</prop>
</node>
<node oor:name="InsertObjectControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:InsertObjCtrl</value>
</prop>
<prop oor:name="Module">
<value/>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.framework.SubToolBarController</value>
</prop>
<prop oor:name="Value">
<value>insertobjectbar;.uno:InsertObject</value>
</prop>
</node>
<node oor:name="InsertCellControl" oor:op="replace">
<prop oor:name="Command">
<value>.uno:InsCellsCtrl</value>
</prop>
<prop oor:name="Module">
<value>com.sun.star.sheet.SpreadsheetDocument</value>
</prop>
<prop oor:name="Controller">
<value>com.sun.star.comp.framework.SubToolBarController</value>
</prop>
<prop oor:name="Value">
<value>insertcellsbar;.uno:InsertCellsDown</value>
</prop>
</node>
<node oor:name="c1" oor:op="replace">
<prop oor:name="Command">
<value>.uno:DBNewForm</value>
......
......@@ -381,7 +381,6 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/cctrl/checklistmenu \
sc/source/ui/cctrl/dpcontrol \
sc/source/ui/cctrl/popmenu \
sc/source/ui/cctrl/tbinsert \
sc/source/ui/cctrl/tbzoomsliderctrl \
sc/source/ui/condformat/condformatdlg \
sc/source/ui/condformat/condformatdlgentry \
......
......@@ -3931,7 +3931,7 @@ SfxVoidItem InputLineMatrix FID_INPUTLINE_MATRIX
]
SfxUInt16Item InsCellsCtrl SID_TBXCTL_INSCELLS
SfxVoidItem InsCellsCtrl SID_TBXCTL_INSCELLS
[
/* flags: */
......@@ -4209,7 +4209,7 @@ SfxVoidItem InsertContents FID_INS_CELL_CONTENTS
]
SfxUInt16Item InsertCtrl SID_TBXCTL_INSERT
SfxVoidItem InsertCtrl SID_TBXCTL_INSERT
[
/* flags: */
......
......@@ -267,8 +267,8 @@ shell ScTabViewShell
SID_STATUS_PAGESTYLE [ ExecMethod = Execute; StateMethod = GetState; ]
SID_TBXCTL_INSERT [ ExecMethod = ExecTbx; StateMethod = GetTbxState; ]
SID_TBXCTL_INSCELLS [ ExecMethod = ExecTbx; StateMethod = GetTbxState; ]
SID_TBXCTL_INSERT []
SID_TBXCTL_INSCELLS []
}
......
......@@ -85,7 +85,6 @@
#include <svx/lboxctrl.hxx>
#include <svx/verttexttbxctrl.hxx>
#include <svx/formatpaintbrushctrl.hxx>
#include "tbinsert.hxx"
#include "tbzoomsliderctrl.hxx"
#include <svx/zoomsliderctrl.hxx>
......@@ -154,8 +153,6 @@ void ScDLL::Init()
SfxRecentFilesToolBoxControl::RegisterControl(SID_OPEN_CALC, pMod);
// Own Controller
ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSERT, pMod);
ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSCELLS, pMod);
ScZoomSliderControl ::RegisterControl(SID_PREVIEW_SCALINGFACTOR, pMod);
// SvxToolboxController
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#include <string>
#include <svl/intitem.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/imagemgr.hxx>
#include <vcl/toolbox.hxx>
#include "tbinsert.hxx"
#include "global.hxx"
#include "scmod.hxx"
#include "scresid.hxx"
#include "sc.hrc"
SFX_IMPL_TOOLBOX_CONTROL( ScTbxInsertCtrl, SfxUInt16Item);
// ToolBox - Controller
ScTbxInsertCtrl::ScTbxInsertCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx ),
nLastSlotId(0)
{
rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
}
ScTbxInsertCtrl::~ScTbxInsertCtrl()
{
}
void ScTbxInsertCtrl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eState,
const SfxPoolItem* pState )
{
GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SfxItemState::DISABLED) );
if( eState == SfxItemState::DEFAULT )
{
const SfxUInt16Item* pItem = PTR_CAST( SfxUInt16Item, pState );
if(pItem)
{
nLastSlotId = pItem->GetValue();
sal_uInt16 nImageId = nLastSlotId ? nLastSlotId : GetSlotId();
OUString aSlotURL( "slot:" );
aSlotURL += OUString::number( nImageId);
Image aImage = GetImage( m_xFrame,
aSlotURL,
hasBigImages()
);
GetToolBox().SetItemImage(GetId(), aImage);
}
}
}
VclPtr<SfxPopupWindow> ScTbxInsertCtrl::CreatePopupWindow()
{
sal_uInt16 nSlotId = GetSlotId();
if (nSlotId == SID_TBXCTL_INSERT)
{
OUString aInsertBarResStr( "private:resource/toolbar/insertbar" );
createAndPositionSubToolBar( aInsertBarResStr );
}
else if (nSlotId == SID_TBXCTL_INSCELLS)
{
OUString aInsertCellsBarResStr( "private:resource/toolbar/insertcellsbar" );
createAndPositionSubToolBar( aInsertCellsBarResStr );
}
return NULL;
}
void ScTbxInsertCtrl::Select( sal_uInt16 /*nSelectModifier*/ )
{
SfxViewShell* pCurSh( SfxViewShell::Current() );
SfxDispatcher* pDispatch( 0 );
if ( pCurSh )
{
SfxViewFrame* pViewFrame = pCurSh->GetViewFrame();
if ( pViewFrame )
pDispatch = pViewFrame->GetDispatcher();
}
if ( pDispatch )
pDispatch->Execute(nLastSlotId);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -92,9 +92,6 @@ enum ObjectSelectionType
class ScTabViewShell: public SfxViewShell, public ScDBFunc
{
private:
static sal_uInt16 nInsertCtrlState;
static sal_uInt16 nInsCellsCtrlState;
SvxHtmlOptions aHTMLOpt;
ObjectSelectionType eCurOST;
sal_uInt16 nDrawSfxId;
......@@ -276,9 +273,6 @@ public:
void ExecImageMap( SfxRequest& rReq );
void GetImageMapState( SfxItemSet& rSet );
void ExecTbx( SfxRequest& rReq );
static void GetTbxState( SfxItemSet& rSet );
void ExecuteSave( SfxRequest& rReq );
void GetSaveState( SfxItemSet& rSet );
void ExecSearch( SfxRequest& rReq );
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SC_SOURCE_UI_INC_TBINSERT_HXX
#define INCLUDED_SC_SOURCE_UI_INC_TBINSERT_HXX
#include <sfx2/tbxctrl.hxx>
class ScTbxInsertCtrl : public SfxToolBoxControl
{
sal_uInt16 nLastSlotId;
virtual void Select( sal_uInt16 nSelectModifier ) SAL_OVERRIDE;
public:
SFX_DECL_TOOLBOX_CONTROL();
ScTbxInsertCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rBox );
virtual ~ScTbxInsertCtrl();
virtual VclPtr<SfxPopupWindow> CreatePopupWindow() SAL_OVERRIDE;
virtual void StateChanged( sal_uInt16 nSID,
SfxItemState eState,
const SfxPoolItem* pState ) SAL_OVERRIDE;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -102,11 +102,6 @@ extern SfxViewShell* pScActiveViewShell; // global.cxx
using namespace com::sun::star;
// STATIC DATA -----------------------------------------------------------
sal_uInt16 ScTabViewShell::nInsertCtrlState = SID_INSERT_GRAPHIC;
sal_uInt16 ScTabViewShell::nInsCellsCtrlState = 0;
void ScTabViewShell::Activate(bool bMDI)
{
SfxViewShell::Activate(bMDI);
......@@ -1830,34 +1825,4 @@ ScNavigatorSettings* ScTabViewShell::GetNavigatorSettings()
return pNavSettings;
}
void ScTabViewShell::ExecTbx( SfxRequest& rReq )
{
const SfxItemSet* pReqArgs = rReq.GetArgs();
sal_uInt16 nSlot = rReq.GetSlot();
const SfxPoolItem* pItem = NULL;
if ( pReqArgs )
pReqArgs->GetItemState( nSlot, true, &pItem );
switch ( nSlot )
{
case SID_TBXCTL_INSERT:
if ( pItem )
nInsertCtrlState = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
break;
case SID_TBXCTL_INSCELLS:
if ( pItem )
nInsCellsCtrlState = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
break;
default:
OSL_FAIL("Slot im Wald");
}
GetViewFrame()->GetBindings().Invalidate( nSlot );
}
void ScTabViewShell::GetTbxState( SfxItemSet& rSet )
{
rSet.Put( SfxUInt16Item( SID_TBXCTL_INSERT, nInsertCtrlState ) );
rSet.Put( SfxUInt16Item( SID_TBXCTL_INSCELLS, nInsCellsCtrlState ) );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -156,10 +156,6 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
static VclPtr<SvxSearchDialog> m_pSrchDlg;
static SvxSearchItem *m_pSrchItem;
static sal_uInt16 m_nInsertCtrlState;
static sal_uInt16 m_nWebInsertCtrlState;
static sal_uInt16 m_nInsertObjectCtrlState;
static sal_uInt16 m_nInsertFieldCtrlState;
static sal_uInt16 m_nMoveType; // for buttons below the scrollbar (viewmdi)
static sal_Int32 m_nActMark; // current jump mark for unknown mark
......
......@@ -531,10 +531,8 @@ interface BaseTextEditView
]
FN_INSERT_CTRL
[
ExecMethod = Execute ;
StateMethod = GetState ;
Export = FALSE;
]
]
SID_ATTR_DEFTABSTOP
[
......
......@@ -3710,7 +3710,7 @@ SfxStringItem InsertSection FN_INSERT_REGION
GroupId = GID_INSERT;
]
SfxImageItem InsertCtrl FN_INSERT_CTRL
SfxVoidItem InsertCtrl FN_INSERT_CTRL
[
/* flags: */
......@@ -4133,7 +4133,7 @@ SfxVoidItem InsertNeutralParagraph FN_NUM_BULLET_NONUM
GroupId = GID_ENUMERATION;
]
SfxImageItem InsertObjCtrl FN_INSERT_OBJ_CTRL
SfxVoidItem InsertObjCtrl FN_INSERT_OBJ_CTRL
[
/* flags: */
......
......@@ -46,7 +46,6 @@ interface TextEditView : BaseTextEditView
// Slots, which are not needed in the WebDocShell
FN_INSERT_OBJ_CTRL
[
ExecMethod = Execute ;
StateMethod = GetState ;
Export = FALSE ;
DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
......
......@@ -290,8 +290,6 @@ void SwDLL::RegisterControls()
SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
SvxTbxCtlAlign::RegisterControl(SID_OBJECT_ALIGN, pMod );
SwTbxAnchor::RegisterControl(FN_TOOL_ANCHOR, pMod );
SwTbxInsertCtrl::RegisterControl(FN_INSERT_CTRL, pMod );
SwTbxInsertCtrl::RegisterControl(FN_INSERT_OBJ_CTRL, pMod );
SwTbxFieldCtrl::RegisterControl(FN_INSERT_FIELD_CTRL, pMod );
SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod );
svx::ParaLineSpacingPopup::RegisterControl(SID_ATTR_PARA_LINESPACE, pMod);
......
......@@ -52,26 +52,6 @@ class SwView;
#define NID_TABLE_FORMULA_ERROR 20019
#define NID_COUNT 20
class SwTbxInsertCtrl : public SfxToolBoxControl
{
sal_uInt16 nLastSlotId;
virtual void Select(sal_uInt16 nSelectModifier) SAL_OVERRIDE;
public:
SFX_DECL_TOOLBOX_CONTROL();
SwTbxInsertCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx );
virtual ~SwTbxInsertCtrl();
virtual VclPtr<SfxPopupWindow> CreatePopupWindow() SAL_OVERRIDE;
virtual void StateChanged( sal_uInt16 nSID,
SfxItemState eState,
const SfxPoolItem* pState ) SAL_OVERRIDE;
virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
};
class SwTbxAutoTextCtrl : public SfxToolBoxControl
{
PopupMenu* pPopup;
......
......@@ -64,98 +64,9 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::frame;
SFX_IMPL_TOOLBOX_CONTROL( SwTbxInsertCtrl, SfxImageItem);
SFX_IMPL_TOOLBOX_CONTROL( SwTbxAutoTextCtrl, SfxVoidItem );
SFX_IMPL_TOOLBOX_CONTROL( SwTbxFieldCtrl, SfxBoolItem );
SwTbxInsertCtrl::SwTbxInsertCtrl(
sal_uInt16 nSlotId,
sal_uInt16 nId,
ToolBox& rTbx ) :
SfxToolBoxControl( nSlotId, nId, rTbx ),
nLastSlotId(FN_INSERT_CTRL == nSlotId ? FN_INSERT_TABLE : SID_INSERT_DIAGRAM)
{
rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) );
}
SwTbxInsertCtrl::~SwTbxInsertCtrl()
{
}
void SAL_CALL SwTbxInsertCtrl::update() throw (uno::RuntimeException, std::exception)
{
ToolBox& rTbx = GetToolBox();
OUString aSlotURL = "slot:" + OUString::number( nLastSlotId);
Image aImage = GetImage( m_xFrame, aSlotURL, hasBigImages() );
rTbx.SetItemImage(GetId(), aImage);
rTbx.Invalidate();
SfxToolBoxControl::update();
}
void SwTbxInsertCtrl::StateChanged( sal_uInt16 /*nSID*/,
SfxItemState eState,
const SfxPoolItem* pState )
{
sal_uInt16 nId = GetId();
GetToolBox().EnableItem( nId, (GetItemState(pState) != SfxItemState::DISABLED) );
if( eState == SfxItemState::DEFAULT )
{
const SfxImageItem* pItem = PTR_CAST( SfxImageItem, pState );
if(pItem)
{
nLastSlotId = pItem->GetValue();
if( nLastSlotId )
nId = nLastSlotId;
OUString aSlotURL = "slot:" + OUString::number( nId);
ToolBox& rBox = GetToolBox();
Image aImage = GetImage( m_xFrame, aSlotURL, hasBigImages() );
rBox.SetItemImage(GetId(), aImage);
rBox.SetItemImageMirrorMode( GetId(), false );
rBox.SetItemImageAngle( GetId(), pItem->GetRotation() );
rBox.SetItemImageMirrorMode( GetId(), pItem->IsMirrored() );
}
}
}
VclPtr<SfxPopupWindow> SwTbxInsertCtrl::CreatePopupWindow()
{
if(GetSlotId() == FN_INSERT_CTRL)
{
OUString aToolBarResStr( "private:resource/toolbar/insertbar" );
createAndPositionSubToolBar( aToolBarResStr );
}
else /* FN_INSERT_OBJ_CTRL */
{
OUString aToolBarResStr( "private:resource/toolbar/insertobjectbar" );
createAndPositionSubToolBar( aToolBarResStr );
}
return NULL;
}
void SwTbxInsertCtrl::Select( sal_uInt16 /*nSelectModifier*/ )
{
if( nLastSlotId )
{
SfxViewShell* pCurSh( SfxViewShell::Current() );
SfxDispatcher* pDispatch( 0 );
if ( pCurSh )
{
SfxViewFrame* pViewFrame = pCurSh->GetViewFrame();
if ( pViewFrame )
pDispatch = pViewFrame->GetDispatcher();
}
if ( pDispatch )
pDispatch->Execute(nLastSlotId);
}
}
SwTbxAutoTextCtrl::SwTbxAutoTextCtrl(
sal_uInt16 nSlotId,
sal_uInt16 nId,
......
......@@ -128,10 +128,6 @@ bool bDocSzUpdated = true;
SvxSearchItem* SwView::m_pSrchItem = 0;
sal_uInt16 SwView::m_nInsertCtrlState = FN_INSERT_TABLE;
sal_uInt16 SwView::m_nWebInsertCtrlState = FN_INSERT_TABLE;
sal_uInt16 SwView::m_nInsertObjectCtrlState = SID_INSERT_DIAGRAM;
bool SwView::m_bExtra = false;
bool SwView::m_bFound = false;
bool SwView::m_bJustOpened = false;
......
......@@ -991,30 +991,6 @@ void SwView::Execute(SfxRequest &rReq)
m_pShell->ExecuteSlot(rReq);
}
break;
case FN_INSERT_CTRL:
case FN_INSERT_OBJ_CTRL:
{
if(pArgs && SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem))
{
const sal_uInt16 nValue = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
switch ( nSlot )
{
case FN_INSERT_CTRL:
{
bool bWeb = 0 != PTR_CAST(SwWebView, this);
if(bWeb)
SwView::m_nWebInsertCtrlState = nValue;
else
SwView::m_nInsertCtrlState = nValue;
}
break;
case FN_INSERT_OBJ_CTRL: SwView::m_nInsertObjectCtrlState = nValue ;break;
}
}
GetViewFrame()->GetBindings().Invalidate( nSlot );
}
break;
#if defined WNT || defined UNX
case SID_TWAIN_SELECT:
case SID_TWAIN_TRANSFER:
......
......@@ -191,42 +191,12 @@ void SwView::GetState(SfxItemSet &rSet)
rSet.DisableItem(nWhich);
}
break;
case FN_INSERT_CTRL:
{
SfxImageItem aImgItem(nWhich, bWeb ? SwView::m_nWebInsertCtrlState : SwView::m_nInsertCtrlState);
SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( GetViewFrame() );
const SfxSlot* pSlot = rPool.GetSlot( aImgItem.GetValue() );
if(pSlot && pSlot->IsMode( SfxSlotMode::IMAGEROTATION ))
{
if(m_pWrtShell->IsInVerticalText())
aImgItem.SetRotation(2700);
if(m_pWrtShell->IsInRightToLeftText())
aImgItem.SetMirrored(true);
}
rSet.Put(aImgItem);
}
break;
case FN_INSERT_OBJ_CTRL:
if( bWeb
|| m_pWrtShell->CrsrInsideInputField() )
{
rSet.DisableItem(nWhich);
}
else
{
SfxImageItem aImgItem(nWhich, SwView::m_nInsertObjectCtrlState);
SfxSlotPool& rPool = SfxSlotPool::GetSlotPool( GetViewFrame() );
const SfxSlot* pSlot = rPool.GetSlot( aImgItem.GetValue() );
if(pSlot && pSlot->IsMode( SfxSlotMode::IMAGEROTATION ))
{
if (m_pWrtShell->IsInVerticalText())
aImgItem.SetRotation(2700);
if (m_pWrtShell->IsInRightToLeftText())
aImgItem.SetMirrored(true);
}
rSet.Put(aImgItem);
}
break;
case FN_UPDATE_TOX:
......
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