xref: /aoo42x/main/svx/source/tbxctrls/tbxdrctl.cxx (revision f6e50924)
1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <tools/ref.hxx>
30cdf0e10cSrcweir #include <tools/shl.hxx>
31cdf0e10cSrcweir #include <svl/aeitem.hxx>
32cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
33cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
34cdf0e10cSrcweir #include <sfx2/imagemgr.hxx>
35cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
36cdf0e10cSrcweir #include <vcl/toolbox.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <svx/dialmgr.hxx>
39cdf0e10cSrcweir #include <svx/dialogs.hrc>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "svx/tbxctl.hxx"
42cdf0e10cSrcweir #include "svx/tbxdraw.hxx"
43cdf0e10cSrcweir #include "svx/tbxcolor.hxx"
44cdf0e10cSrcweir #include "tbxdraw.hrc"
45cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxAllEnumItem);
48cdf0e10cSrcweir 
49cdf0e10cSrcweir using namespace ::com::sun::star::uno;
50cdf0e10cSrcweir using namespace ::com::sun::star::frame;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // -----------------------------------------------------------------------
53cdf0e10cSrcweir 
SvxTbxCtlDraw(sal_uInt16 nSlotId,sal_uInt16 nId,ToolBox & rTbx)54cdf0e10cSrcweir SvxTbxCtlDraw::SvxTbxCtlDraw( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     SfxToolBoxControl( nSlotId, nId, rTbx ),
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     m_sToolboxName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/drawbar" ) )
59cdf0e10cSrcweir 
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     rTbx.SetItemBits( nId, TIB_CHECKABLE | rTbx.GetItemBits( nId ) );
62cdf0e10cSrcweir 	rTbx.Invalidate();
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // -----------------------------------------------------------------------
66cdf0e10cSrcweir 
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)67cdf0e10cSrcweir void SvxTbxCtlDraw::StateChanged( sal_uInt16 nSID, SfxItemState eState,
68cdf0e10cSrcweir 								  const SfxPoolItem* pState )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir     GetToolBox().EnableItem( GetId(), ( eState != SFX_ITEM_DISABLED ) );
71cdf0e10cSrcweir     SfxToolBoxControl::StateChanged( nSID, eState, pState );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
74cdf0e10cSrcweir     if ( xLayoutMgr.is() )
75cdf0e10cSrcweir         GetToolBox().CheckItem(
76cdf0e10cSrcweir             GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) != sal_False );
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // -----------------------------------------------------------------------
80cdf0e10cSrcweir 
GetPopupWindowType() const81cdf0e10cSrcweir SfxPopupWindowType SvxTbxCtlDraw::GetPopupWindowType() const
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     return SFX_POPUPWINDOW_ONCLICK;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir // -----------------------------------------------------------------------
87cdf0e10cSrcweir 
toggleToolbox()88cdf0e10cSrcweir void SvxTbxCtlDraw::toggleToolbox()
89cdf0e10cSrcweir {
90cdf0e10cSrcweir     Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
91cdf0e10cSrcweir     if ( xLayoutMgr.is() )
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         sal_Bool bCheck = sal_False;
94cdf0e10cSrcweir         if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
95cdf0e10cSrcweir         {
96cdf0e10cSrcweir             xLayoutMgr->hideElement( m_sToolboxName );
97cdf0e10cSrcweir             xLayoutMgr->destroyElement( m_sToolboxName );
98cdf0e10cSrcweir         }
99cdf0e10cSrcweir         else
100cdf0e10cSrcweir         {
101cdf0e10cSrcweir             bCheck = sal_True;
102cdf0e10cSrcweir             xLayoutMgr->createElement( m_sToolboxName );
103cdf0e10cSrcweir             xLayoutMgr->showElement( m_sToolboxName );
104cdf0e10cSrcweir         }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         GetToolBox().CheckItem( GetId(), bCheck );
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir // -----------------------------------------------------------------------
111cdf0e10cSrcweir 
Select(sal_Bool)112cdf0e10cSrcweir void SvxTbxCtlDraw::Select( sal_Bool )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     toggleToolbox();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117