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