LibreOffice Module svx (master) 1
verttexttbxctrl.cxx
Go to the documentation of this file.
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
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>
27
29 const css::uno::Reference<css::uno::XComponentContext>& rContext)
30 : SvxVertCTLTextTbxCtrl(rContext)
31{
32 addStatusListener(".uno:CTLFontState");
33}
34
36{
37 return "com.sun.star.comp.svx.CTLToolBoxControl";
38}
39
40extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
42 css::uno::Sequence<css::uno::Any> const&)
43{
44 return cppu::acquire(new SvxCTLTextTbxCtrl(rContext));
45}
46
48 const css::uno::Reference<css::uno::XComponentContext>& rContext)
49 : SvxVertCTLTextTbxCtrl(rContext)
50{
51 addStatusListener(".uno:VerticalTextState");
52}
53
55{
56 return "com.sun.star.comp.svx.VertTextToolBoxControl";
57}
58
59extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
61 css::uno::XComponentContext* rContext, css::uno::Sequence<css::uno::Any> const&)
62{
63 return cppu::acquire(new SvxVertTextTbxCtrl(rContext));
64}
65
67 const css::uno::Reference<css::uno::XComponentContext>& rContext)
68 : SvxVertCTLTextTbxCtrl_Base(rContext, nullptr, OUString())
69 , m_bVisible(false)
70{
71}
72
74
75void SAL_CALL SvxVertCTLTextTbxCtrl::initialize(const css::uno::Sequence<css::uno::Any>& rArguments)
76{
77 SvxVertCTLTextTbxCtrl_Base::initialize(rArguments);
78 // fdo#83320 Hide vertical text commands early
79 setFastPropertyValue_NoBroadcast(1, css::uno::Any(true));
80
81 if (m_pToolbar)
82 {
83 m_bVisible = m_pToolbar->get_item_visible(m_aCommandURL);
84 return;
85 }
86
87 ToolBox* pToolBox = nullptr;
88 ToolBoxItemId nItemId;
89 if (getToolboxId(nItemId, &pToolBox))
90 m_bVisible = pToolBox->IsItemVisible(nItemId);
91}
92
93void SAL_CALL SvxVertCTLTextTbxCtrl::statusChanged(const css::frame::FeatureStateEvent& rEvent)
94{
95 ToolBox* pToolBox = nullptr;
96 ToolBoxItemId nItemId;
97 bool bVclToolBox = getToolboxId(nItemId, &pToolBox);
98
99 bool bEnabled = false;
100 if (rEvent.FeatureURL.Complete == ".uno:VerticalTextState")
101 {
103 }
104 else if (rEvent.FeatureURL.Complete == ".uno:CTLFontState")
105 {
107 }
108 else
109 {
110 // normal command
111 bool bValue = false;
112 rEvent.State >>= bValue;
113
114 if (m_pToolbar)
115 {
116 m_pToolbar->set_item_active(m_aCommandURL, bValue);
117 m_pToolbar->set_item_sensitive(m_aCommandURL, rEvent.IsEnabled);
118 }
119
120 if (bVclToolBox)
121 {
122 pToolBox->CheckItem(nItemId, bValue);
123 pToolBox->EnableItem(nItemId, rEvent.IsEnabled);
124 }
125
126 return;
127 }
128
129 if (m_pToolbar)
130 {
131 m_pToolbar->set_item_visible(m_aCommandURL, bEnabled);
132 return;
133 }
134
135 if (bVclToolBox)
136 {
137 pToolBox->ShowItem(nItemId, bEnabled);
138
139 vcl::Window* pParent = pToolBox->GetParent();
140 if (WindowType::FLOATINGWINDOW == pParent->GetType())
141 {
142 Size aSize(pToolBox->CalcWindowSizePixel());
143 pToolBox->SetPosSizePixel(Point(), aSize);
144 pParent->SetOutputSizePixel(aSize);
145 }
146 }
147}
148
149// XServiceInfo
150sal_Bool SAL_CALL SvxVertCTLTextTbxCtrl::supportsService(const OUString& ServiceName)
151{
153}
154
156{
157 return { "com.sun.star.frame.ToolbarController" };
158}
159
160/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsCTLFontEnabled()
virtual OUString SAL_CALL getImplementationName() override
SvxCTLTextTbxCtrl(const css::uno::Reference< css::uno::XComponentContext > &rContext)
virtual ~SvxVertCTLTextTbxCtrl() override
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &rEvent) override
SvxVertCTLTextTbxCtrl(const css::uno::Reference< css::uno::XComponentContext > &rContext)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArguments) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
SvxVertTextTbxCtrl(const css::uno::Reference< css::uno::XComponentContext > &rContext)
virtual OUString SAL_CALL getImplementationName() override
Size CalcWindowSizePixel()
void EnableItem(ToolBoxItemId nItemId, bool bEnable=true)
bool IsItemVisible(ToolBoxItemId nItemId) const
void CheckItem(ToolBoxItemId nItemId, bool bCheck=true)
void ShowItem(ToolBoxItemId nItemId, bool bVisible=true)
vcl::Window * GetParent() const
WindowType GetType() const
virtual void SetOutputSizePixel(const Size &rNewSize)
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
bool IsVerticalTextEnabled()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_CTLToolBoxControl_get_implementation(css::uno::XComponentContext *rContext, css::uno::Sequence< css::uno::Any > const &)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_VertTextToolBoxControl_get_implementation(css::uno::XComponentContext *rContext, css::uno::Sequence< css::uno::Any > const &)