Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <svx/dialmgr.hxx>
22 : #include <svx/dialogs.hrc>
23 : #include <svx/verttexttbxctrl.hxx>
24 : #include <svl/languageoptions.hxx>
25 : #include <sfx2/app.hxx>
26 : #include <svl/eitem.hxx>
27 : #include <vcl/toolbox.hxx>
28 : #include <rtl/ustring.hxx>
29 :
30 2236 : SFX_IMPL_TOOLBOX_CONTROL(SvxCTLTextTbxCtrl, SfxBoolItem);
31 1283 : SFX_IMPL_TOOLBOX_CONTROL(SvxVertTextTbxCtrl, SfxBoolItem);
32 :
33 1972 : SvxCTLTextTbxCtrl::SvxCTLTextTbxCtrl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
34 1972 : SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx )
35 : {
36 1972 : addStatusListener( OUString( ".uno:CTLFontState" ));
37 1972 : }
38 :
39 713 : SvxVertTextTbxCtrl::SvxVertTextTbxCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
40 713 : SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx )
41 : {
42 713 : addStatusListener( OUString( ".uno:VerticalTextState" ));
43 713 : }
44 :
45 2685 : SvxVertCTLTextTbxCtrl::SvxVertCTLTextTbxCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
46 2685 : SfxToolBoxControl( nSlotId, nId, rTbx )
47 : {
48 2685 : }
49 :
50 2685 : SvxVertCTLTextTbxCtrl::~SvxVertCTLTextTbxCtrl( )
51 : {
52 2685 : }
53 :
54 10384 : void SvxVertCTLTextTbxCtrl::StateChanged(
55 : sal_uInt16 nSID,
56 : SfxItemState eState,
57 : const SfxPoolItem* pState )
58 : {
59 10384 : SvtLanguageOptions aLangOptions;
60 10384 : bool bCalc = false;
61 10384 : bool bEnabled = false;
62 10384 : if ( nSID == SID_VERTICALTEXT_STATE )
63 1062 : bEnabled = aLangOptions.IsVerticalTextEnabled();
64 9322 : else if ( nSID == SID_CTLFONT_STATE )
65 4130 : bEnabled = aLangOptions.IsCTLFontEnabled();
66 : else
67 : {
68 5192 : SfxToolBoxControl::StateChanged(nSID, eState, pState);
69 15576 : return;
70 : }
71 :
72 5192 : if(!bEnabled)
73 : {
74 : // always hide if either IsVerticalTextEnabled or IsCTLFontEnabled
75 : // is false
76 0 : GetToolBox().HideItem( GetId() );
77 0 : bCalc = true;
78 : }
79 5192 : if(bCalc)
80 : {
81 0 : ToolBox& rTbx = GetToolBox();
82 0 : vcl::Window* pParent = rTbx.GetParent();
83 0 : WindowType nWinType = pParent->GetType();
84 0 : if(WINDOW_FLOATINGWINDOW == nWinType)
85 : {
86 0 : Size aSize(rTbx.CalcWindowSizePixel());
87 0 : rTbx.SetPosSizePixel( Point(), aSize );
88 0 : pParent->SetOutputSizePixel( aSize );
89 : }
90 5192 : }
91 390 : }
92 :
93 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|