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 4308 : SFX_IMPL_TOOLBOX_CONTROL(SvxCTLTextTbxCtrl, SfxBoolItem);
31 1726 : SFX_IMPL_TOOLBOX_CONTROL(SvxVertTextTbxCtrl, SfxBoolItem);
32 :
33 3908 : SvxCTLTextTbxCtrl::SvxCTLTextTbxCtrl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
34 3908 : SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx )
35 : {
36 3908 : SetVert(false);
37 3908 : addStatusListener( OUString( ".uno:CTLFontState" ));
38 3908 : }
39 :
40 854 : SvxVertTextTbxCtrl::SvxVertTextTbxCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
41 854 : SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx )
42 : {
43 854 : SetVert(true);
44 854 : addStatusListener( OUString( ".uno:VerticalTextState" ));
45 854 : }
46 :
47 4762 : SvxVertCTLTextTbxCtrl::SvxVertCTLTextTbxCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
48 : SfxToolBoxControl( nSlotId, nId, rTbx ),
49 4762 : bCheckVertical(true)
50 : {
51 4762 : }
52 :
53 4762 : SvxVertCTLTextTbxCtrl::~SvxVertCTLTextTbxCtrl( )
54 : {
55 4762 : }
56 :
57 14160 : void SvxVertCTLTextTbxCtrl::StateChanged(
58 : sal_uInt16 nSID,
59 : SfxItemState eState,
60 : const SfxPoolItem* pState )
61 : {
62 14160 : SvtLanguageOptions aLangOptions;
63 14160 : bool bCalc = false;
64 14160 : bool bEnabled = false;
65 14160 : if ( nSID == SID_VERTICALTEXT_STATE )
66 550 : bEnabled = aLangOptions.IsVerticalTextEnabled();
67 13610 : else if ( nSID == SID_CTLFONT_STATE )
68 6530 : bEnabled = aLangOptions.IsCTLFontEnabled();
69 : else
70 : {
71 7080 : SfxToolBoxControl::StateChanged(nSID, eState, pState);
72 21240 : return;
73 : }
74 :
75 7080 : if(!bEnabled)
76 : {
77 : // always hide if either IsVerticalTextEnabled or IsCTLFontEnabled
78 : // is false
79 0 : GetToolBox().HideItem( GetId() );
80 0 : bCalc = true;
81 : }
82 7080 : if(bCalc)
83 : {
84 0 : ToolBox& rTbx = GetToolBox();
85 0 : vcl::Window* pParent = rTbx.GetParent();
86 0 : WindowType nWinType = pParent->GetType();
87 0 : if(WINDOW_FLOATINGWINDOW == nWinType)
88 : {
89 0 : Size aSize(rTbx.CalcWindowSizePixel());
90 0 : rTbx.SetPosSizePixel( Point(), aSize );
91 0 : pParent->SetOutputSizePixel( aSize );
92 : }
93 7080 : }
94 594 : }
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|