1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #include <svx/dialmgr.hxx>
32 #include <svx/dialogs.hrc>
33 #include <svx/verttexttbxctrl.hxx>
34 #include <svl/languageoptions.hxx>
35 #include <sfx2/app.hxx>
36 #include <svl/eitem.hxx>
37 #include <vcl/toolbox.hxx>
38 #include <rtl/ustring.hxx>
39 
40 SFX_IMPL_TOOLBOX_CONTROL(SvxCTLTextTbxCtrl, SfxBoolItem);
41 SFX_IMPL_TOOLBOX_CONTROL(SvxVertTextTbxCtrl, SfxBoolItem);
42 
43 // -----------------------------27.04.01 15:50--------------------------------
44 
45 SvxCTLTextTbxCtrl::SvxCTLTextTbxCtrl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
46     SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx )
47 {
48     SetVert(sal_False);
49     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CTLFontState" )));
50 }
51 
52 SvxVertTextTbxCtrl::SvxVertTextTbxCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
53     SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx )
54 {
55     SetVert(sal_True);
56     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:VerticalTextState" )));
57 }
58 
59 /* ---------------------------------------------------------------------------*/
60 SvxVertCTLTextTbxCtrl::SvxVertCTLTextTbxCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
61     SfxToolBoxControl( nSlotId, nId, rTbx ),
62     bCheckVertical(sal_True)
63 {
64 }
65 
66 /* -----------------------------27.04.01 15:53--------------------------------
67 
68  ---------------------------------------------------------------------------*/
69 SvxVertCTLTextTbxCtrl::~SvxVertCTLTextTbxCtrl( )
70 {
71 }
72 /* -----------------------------27.04.01 15:50--------------------------------
73 
74  ---------------------------------------------------------------------------*/
75 void SvxVertCTLTextTbxCtrl::StateChanged(
76     sal_uInt16 nSID,
77     SfxItemState eState,
78     const SfxPoolItem* pState )
79 {
80 	SvtLanguageOptions aLangOptions;
81     sal_Bool bCalc = sal_False;
82     sal_Bool bVisible = GetToolBox().IsItemVisible(GetId());
83 	sal_Bool bEnabled = sal_False;
84 	if ( nSID == SID_VERTICALTEXT_STATE )
85 		bEnabled = aLangOptions.IsVerticalTextEnabled();
86 	else if ( nSID == SID_CTLFONT_STATE )
87 		bEnabled = aLangOptions.IsCTLFontEnabled();
88 	else
89 	{
90 		SfxToolBoxControl::StateChanged(nSID, eState, pState);
91 		return;
92 	}
93 
94     if(bEnabled)
95     {
96         if(!bVisible)
97         {
98             GetToolBox().ShowItem( GetId(), sal_True );
99             bCalc = sal_True;
100         }
101     }
102     else if(bVisible)
103     {
104         GetToolBox().HideItem( GetId() );
105         bCalc = sal_True;
106     }
107     if(bCalc)
108     {
109         ToolBox& rTbx = GetToolBox();
110 		Window* pParent = rTbx.GetParent();
111 		WindowType nWinType = pParent->GetType();
112         if(WINDOW_FLOATINGWINDOW == nWinType)
113 		{
114 			Size aSize(rTbx.CalcWindowSizePixel());
115 			rTbx.SetPosSizePixel( Point(), aSize );
116             pParent->SetOutputSizePixel( aSize );
117 		}
118     }
119 }
120 /* -----------------------------27.04.01 15:50--------------------------------
121 
122  ---------------------------------------------------------------------------*/
123 
124