1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <cppuhelper/supportsservice.hxx>
21 #include <verttexttbxctrl.hxx>
22 #include <svl/cjkoptions.hxx>
23 #include <svl/ctloptions.hxx>
24 #include <vcl/toolbox.hxx>
25 #include <vcl/weld.hxx>
26 #include <rtl/ustring.hxx>
28 SvxCTLTextTbxCtrl::SvxCTLTextTbxCtrl(
29 const css::uno::Reference
<css::uno::XComponentContext
>& rContext
)
30 : SvxVertCTLTextTbxCtrl(rContext
)
32 addStatusListener(u
".uno:CTLFontState"_ustr
);
35 OUString
SvxCTLTextTbxCtrl::getImplementationName()
37 return u
"com.sun.star.comp.svx.CTLToolBoxControl"_ustr
;
40 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
41 com_sun_star_comp_svx_CTLToolBoxControl_get_implementation(css::uno::XComponentContext
* rContext
,
42 css::uno::Sequence
<css::uno::Any
> const&)
44 return cppu::acquire(new SvxCTLTextTbxCtrl(rContext
));
47 SvxVertTextTbxCtrl::SvxVertTextTbxCtrl(
48 const css::uno::Reference
<css::uno::XComponentContext
>& rContext
)
49 : SvxVertCTLTextTbxCtrl(rContext
)
51 addStatusListener(u
".uno:VerticalTextState"_ustr
);
54 OUString
SvxVertTextTbxCtrl::getImplementationName()
56 return u
"com.sun.star.comp.svx.VertTextToolBoxControl"_ustr
;
59 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
60 com_sun_star_comp_svx_VertTextToolBoxControl_get_implementation(
61 css::uno::XComponentContext
* rContext
, css::uno::Sequence
<css::uno::Any
> const&)
63 return cppu::acquire(new SvxVertTextTbxCtrl(rContext
));
66 SvxVertCTLTextTbxCtrl::SvxVertCTLTextTbxCtrl(
67 const css::uno::Reference
<css::uno::XComponentContext
>& rContext
)
68 : SvxVertCTLTextTbxCtrl_Base(rContext
, nullptr, OUString())
73 SvxVertCTLTextTbxCtrl::~SvxVertCTLTextTbxCtrl() {}
75 void SAL_CALL
SvxVertCTLTextTbxCtrl::initialize(const css::uno::Sequence
<css::uno::Any
>& rArguments
)
77 SvxVertCTLTextTbxCtrl_Base::initialize(rArguments
);
78 // fdo#83320 Hide vertical text commands early
79 setFastPropertyValue_NoBroadcast(1, css::uno::Any(true));
83 m_bVisible
= m_pToolbar
->get_item_visible(m_aCommandURL
);
87 ToolBox
* pToolBox
= nullptr;
88 ToolBoxItemId nItemId
;
89 if (getToolboxId(nItemId
, &pToolBox
))
90 m_bVisible
= pToolBox
->IsItemVisible(nItemId
);
93 void SAL_CALL
SvxVertCTLTextTbxCtrl::statusChanged(const css::frame::FeatureStateEvent
& rEvent
)
95 ToolBox
* pToolBox
= nullptr;
96 ToolBoxItemId nItemId
;
97 bool bVclToolBox
= getToolboxId(nItemId
, &pToolBox
);
99 bool bEnabled
= false;
100 if (rEvent
.FeatureURL
.Complete
== ".uno:VerticalTextState")
102 bEnabled
= m_bVisible
&& SvtCJKOptions::IsVerticalTextEnabled();
104 else if (rEvent
.FeatureURL
.Complete
== ".uno:CTLFontState")
106 bEnabled
= m_bVisible
&& SvtCTLOptions::IsCTLFontEnabled();
112 rEvent
.State
>>= bValue
;
116 m_pToolbar
->set_item_active(m_aCommandURL
, bValue
);
117 m_pToolbar
->set_item_sensitive(m_aCommandURL
, rEvent
.IsEnabled
);
122 pToolBox
->CheckItem(nItemId
, bValue
);
123 pToolBox
->EnableItem(nItemId
, rEvent
.IsEnabled
);
131 m_pToolbar
->set_item_visible(m_aCommandURL
, bEnabled
);
137 pToolBox
->ShowItem(nItemId
, bEnabled
);
139 vcl::Window
* pParent
= pToolBox
->GetParent();
140 if (WindowType::FLOATINGWINDOW
== pParent
->GetType())
142 Size
aSize(pToolBox
->CalcWindowSizePixel());
143 pToolBox
->SetPosSizePixel(Point(), aSize
);
144 pParent
->SetOutputSizePixel(aSize
);
150 sal_Bool SAL_CALL
SvxVertCTLTextTbxCtrl::supportsService(const OUString
& ServiceName
)
152 return cppu::supportsService(this, ServiceName
);
155 css::uno::Sequence
<OUString
> SvxVertCTLTextTbxCtrl::getSupportedServiceNames()
157 return { u
"com.sun.star.frame.ToolbarController"_ustr
};
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */