/src/libreoffice/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx
Line | Count | Source (jump to first uncovered line) |
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 "ParaLineSpacingControl.hxx" |
21 | | |
22 | | #include <ParaLineSpacingPopup.hxx> |
23 | | #include <vcl/toolbox.hxx> |
24 | | |
25 | | using namespace svx; |
26 | | |
27 | | SvxLineSpacingToolBoxControl::SvxLineSpacingToolBoxControl( |
28 | | const css::uno::Reference<css::uno::XComponentContext>& rContext) |
29 | 0 | : PopupWindowController(rContext, nullptr, OUString()) |
30 | 0 | { |
31 | 0 | } |
32 | | |
33 | 0 | SvxLineSpacingToolBoxControl::~SvxLineSpacingToolBoxControl() {} |
34 | | |
35 | | void SvxLineSpacingToolBoxControl::initialize(const css::uno::Sequence<css::uno::Any>& rArguments) |
36 | 0 | { |
37 | 0 | PopupWindowController::initialize(rArguments); |
38 | |
|
39 | 0 | if (m_pToolbar) |
40 | 0 | { |
41 | 0 | mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar)); |
42 | 0 | m_pToolbar->set_item_popover(m_aCommandURL, mxPopoverContainer->getTopLevel()); |
43 | 0 | } |
44 | |
|
45 | 0 | ToolBox* pToolBox = nullptr; |
46 | 0 | ToolBoxItemId nId; |
47 | 0 | if (getToolboxId(nId, &pToolBox)) |
48 | 0 | pToolBox->SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | pToolBox->GetItemBits(nId)); |
49 | 0 | } |
50 | | |
51 | | void SAL_CALL SvxLineSpacingToolBoxControl::execute(sal_Int16 /*KeyModifier*/) |
52 | 0 | { |
53 | 0 | if (m_pToolbar) |
54 | 0 | { |
55 | | // Toggle the popup also when toolbutton is activated |
56 | 0 | m_pToolbar->set_menu_item_active(m_aCommandURL, |
57 | 0 | !m_pToolbar->get_menu_item_active(m_aCommandURL)); |
58 | 0 | } |
59 | 0 | else |
60 | 0 | { |
61 | | // Open the popup also when Enter key is pressed. |
62 | 0 | createPopupWindow(); |
63 | 0 | } |
64 | 0 | } |
65 | | |
66 | | std::unique_ptr<WeldToolbarPopup> SvxLineSpacingToolBoxControl::weldPopupWindow() |
67 | 0 | { |
68 | 0 | return std::make_unique<ParaLineSpacingControl>(this, m_pToolbar); |
69 | 0 | } |
70 | | |
71 | | VclPtr<vcl::Window> SvxLineSpacingToolBoxControl::createVclPopupWindow(vcl::Window* pParent) |
72 | 0 | { |
73 | 0 | mxInterimPopover = VclPtr<InterimToolbarPopup>::Create( |
74 | 0 | getFrameInterface(), pParent, |
75 | 0 | std::make_unique<ParaLineSpacingControl>(this, pParent->GetFrameWeld())); |
76 | |
|
77 | 0 | mxInterimPopover->Show(); |
78 | |
|
79 | 0 | return mxInterimPopover; |
80 | 0 | } |
81 | | |
82 | | OUString SvxLineSpacingToolBoxControl::getImplementationName() |
83 | 0 | { |
84 | 0 | return u"com.sun.star.comp.svx.LineSpacingToolBoxControl"_ustr; |
85 | 0 | } |
86 | | |
87 | | css::uno::Sequence<OUString> SvxLineSpacingToolBoxControl::getSupportedServiceNames() |
88 | 0 | { |
89 | 0 | return { u"com.sun.star.frame.ToolbarController"_ustr }; |
90 | 0 | } |
91 | | |
92 | | extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* |
93 | | com_sun_star_comp_svx_LineSpacingToolBoxControl_get_implementation( |
94 | | css::uno::XComponentContext* rContext, css::uno::Sequence<css::uno::Any> const&) |
95 | 0 | { |
96 | 0 | return cppu::acquire(new SvxLineSpacingToolBoxControl(rContext)); |
97 | 0 | } |
98 | | |
99 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |