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