merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / ribbar / tbxmgr.cxx
blob516b2a97e27a829845fd7a0cbf84bf74d4baeaa4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tbxmgr.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include "cmdid.h"
37 #include "swtypes.hxx" // nur wegen aEmptyString??
38 #include "errhdl.hxx"
39 #include "wdocsh.hxx"
40 #include "tbxmgr.hxx"
43 /*************************************************************************
47 \************************************************************************/
49 SwPopupWindowTbxMgr::SwPopupWindowTbxMgr( USHORT nId, WindowAlign eAlign,
50 ResId aRIdWin, ResId aRIdTbx,
51 SfxBindings& rBindings ) :
52 SvxPopupWindowTbxMgr( nId, eAlign, aRIdWin, aRIdTbx ),
53 bWeb(FALSE),
54 aRIdWinTemp(aRIdWin),
55 aRIdTbxTemp(aRIdTbx),
56 eAlignment( eAlign ),
57 mrBindings( rBindings )
59 SfxObjectShell* pObjShell = SfxObjectShell::Current();
60 if(PTR_CAST(SwWebDocShell, pObjShell))
62 bWeb = TRUE;
63 ToolBox& rTbx = GetTbxMgr().GetToolBox();
64 // jetzt muessen ein paar Items aus der Toolbox versteckt werden:
65 switch(nId)
67 case FN_INSERT_CTRL:
68 rTbx.ShowItem(FN_INSERT_FRAME_INTERACT_NOCOL);
69 rTbx.HideItem(FN_INSERT_FRAME_INTERACT);
70 rTbx.HideItem(FN_INSERT_FOOTNOTE);
71 rTbx.HideItem(FN_INSERT_ENDNOTE);
72 rTbx.HideItem(FN_PAGE_STYLE_SET_COLS);
73 rTbx.HideItem(FN_INSERT_IDX_ENTRY_DLG);
75 break;
76 case FN_INSERT_FIELD_CTRL:
77 rTbx.HideItem(FN_INSERT_FLD_PGNUMBER);
78 rTbx.HideItem(FN_INSERT_FLD_PGCOUNT);
79 rTbx.HideItem(FN_INSERT_FLD_TOPIC);
80 rTbx.HideItem(FN_INSERT_FLD_TITLE);
81 break;
84 else if( FN_INSERT_CTRL == nId)
86 ToolBox& rTbx = GetTbxMgr().GetToolBox();
87 rTbx.ShowItem(FN_INSERT_FRAME_INTERACT);
88 rTbx.HideItem(FN_INSERT_FRAME_INTERACT_NOCOL);
91 Size aSize = GetTbxMgr().CalcWindowSizePixel();
92 GetTbxMgr().SetPosSizePixel( Point(), aSize );
93 SetOutputSizePixel( aSize );
96 /*************************************************************************
100 \************************************************************************/
102 void SwPopupWindowTbxMgr::StateChanged(USHORT nSID, SfxItemState eState,
103 const SfxPoolItem* pState)
105 static USHORT __READONLY_DATA aInsertCtrl[] =
107 FN_INSERT_FRAME_INTERACT,
108 FN_INSERT_FOOTNOTE,
109 FN_INSERT_ENDNOTE,
110 FN_PAGE_STYLE_SET_COLS,
111 FN_INSERT_IDX_ENTRY_DLG,
114 static USHORT __READONLY_DATA aInsertFld[] =
116 FN_INSERT_FLD_PGNUMBER,
117 FN_INSERT_FLD_PGCOUNT,
118 FN_INSERT_FLD_TOPIC,
119 FN_INSERT_FLD_TITLE,
123 SfxObjectShell* pObjShell = SfxObjectShell::Current();
124 BOOL bNewWeb = 0 != PTR_CAST(SwWebDocShell, pObjShell);
126 if(bWeb != bNewWeb)
128 bWeb = bNewWeb;
129 ToolBox& rTbx = GetTbxMgr().GetToolBox();
130 // jetzt muessen ein paar Items aus der Toolbox versteckt werden:
131 const USHORT* pSid = 0;
133 switch(nSID)
135 case FN_INSERT_CTRL:
136 pSid = &aInsertCtrl[0];
137 if(bWeb)
138 rTbx.ShowItem(FN_INSERT_FRAME_INTERACT_NOCOL);
139 else
140 rTbx.HideItem(FN_INSERT_FRAME_INTERACT_NOCOL);
141 break;
142 case FN_INSERT_FIELD_CTRL:
143 pSid = & aInsertFld[0];
144 break;
146 if(pSid)
148 if(bWeb)
149 while(*pSid)
151 rTbx.HideItem(*pSid);
152 pSid++;
154 else
155 while(*pSid)
157 rTbx.ShowItem(*pSid);
158 pSid++;
160 Size aSize = GetTbxMgr().CalcWindowSizePixel();
161 GetTbxMgr().SetPosSizePixel( Point(), aSize );
162 SetOutputSizePixel( aSize );
166 SfxPopupWindow::StateChanged(nSID, eState, pState);
170 SfxPopupWindow* SwPopupWindowTbxMgr::Clone() const
172 return new SwPopupWindowTbxMgr(
173 GetId(),
174 eAlignment,
175 // ((SwPopupWindowTbxMgr*)this)->GetTbxMgr().GetToolBox().GetAlign(),
176 aRIdWinTemp,
177 aRIdTbxTemp,
178 mrBindings
179 // (SfxBindings&)GetBindings()