Coverage Report

Created: 2025-11-16 09:57

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