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