LibreOffice Module sw (master) 1
PageColumnControl.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
20#include <memory>
21#include "PageColumnControl.hxx"
22#include <PageColumnPopup.hxx>
23
24#include <cmdid.h>
25
26#include <sfx2/bindings.hxx>
27#include <sfx2/dispatch.hxx>
28#include <sfx2/viewfrm.hxx>
29#include <svl/intitem.hxx>
30#include <svx/pageitem.hxx>
31
32namespace sw::sidebar {
33
35 : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "modules/swriter/ui/pagecolumncontrol.ui", "PageColumnControl")
36 , m_xMoreButton(m_xBuilder->weld_button("moreoptions"))
37 , m_xControl(pControl)
38{
39 bool bLandscape = false;
40 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
41 {
42 const SvxPageItem *pPageItem;
43 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem );
44 bLandscape = pPageItem->IsLandscape();
45 }
46
47 if ( bLandscape )
48 {
49 m_xOneColumn = m_xBuilder->weld_button("column1L");
50 m_xTwoColumns = m_xBuilder->weld_button("column2L");
51 m_xThreeColumns = m_xBuilder->weld_button("column3L");
52 m_xLeft = m_xBuilder->weld_button("columnleftL");
53 m_xRight = m_xBuilder->weld_button("columnrightL");
54 }
55 else
56 {
57 m_xOneColumn = m_xBuilder->weld_button("column1");
58 m_xTwoColumns = m_xBuilder->weld_button( "column2");
59 m_xThreeColumns = m_xBuilder->weld_button("column3");
60 m_xLeft = m_xBuilder->weld_button("columnleft");
61 m_xRight = m_xBuilder->weld_button("columnright");
62 }
63
64 m_xOneColumn->show();
65 m_xTwoColumns->show();
66 m_xThreeColumns->show();
67 m_xLeft->show();
68 m_xRight->show();
69
70 m_xOneColumn->connect_clicked( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
71 m_xTwoColumns->connect_clicked( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
72 m_xThreeColumns->connect_clicked( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
73 m_xLeft->connect_clicked( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
74 m_xRight->connect_clicked( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
75
76 m_xMoreButton->connect_clicked( LINK( this, PageColumnControl, MoreButtonClickHdl_Impl ) );
77}
78
80{
81 m_xMoreButton->grab_focus();
82}
83
85{
86}
87
88void PageColumnControl::ExecuteColumnChange( const sal_uInt16 nColumnType )
89{
90 SfxInt16Item aPageColumnTypeItem(SID_ATTR_PAGE_COLUMN);
91 aPageColumnTypeItem.SetValue( nColumnType );
92 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
93 pViewFrm->GetBindings().GetDispatcher()->ExecuteList(SID_ATTR_PAGE_COLUMN,
94 SfxCallMode::RECORD, { &aPageColumnTypeItem });
95}
96
97IMPL_LINK( PageColumnControl, ColumnButtonClickHdl_Impl, weld::Button&, rButton, void )
98{
99 if ( &rButton == m_xOneColumn.get() )
100 ExecuteColumnChange( 1 );
101 else if ( &rButton == m_xTwoColumns.get() )
102 ExecuteColumnChange( 2 );
103 else if ( &rButton == m_xThreeColumns.get() )
104 ExecuteColumnChange( 3 );
105 else if ( &rButton == m_xLeft.get() )
106 ExecuteColumnChange( 4 );
107 else if ( &rButton == m_xRight.get() )
108 ExecuteColumnChange( 5 );
109
110 m_xControl->EndPopupMode();
111}
112
113IMPL_LINK_NOARG( PageColumnControl, MoreButtonClickHdl_Impl, weld::Button&, void )
114{
115 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
116 pViewFrm->GetBindings().GetDispatcher()->Execute( FN_FORMAT_PAGE_COLUMN_DLG, SfxCallMode::ASYNCHRON );
117 m_xControl->EndPopupMode();
118}
119
120} // end of namespace sw::sidebar
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetValue(sal_Int16 nTheValue)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
bool IsLandscape() const
std::unique_ptr< weld::Builder > m_xBuilder
std::unique_ptr< weld::Button > m_xTwoColumns
std::unique_ptr< weld::Button > m_xOneColumn
virtual void GrabFocus() override
std::unique_ptr< weld::Button > m_xRight
std::unique_ptr< weld::Button > m_xMoreButton
std::unique_ptr< weld::Button > m_xThreeColumns
static void ExecuteColumnChange(const sal_uInt16 nColumnType)
PageColumnControl(PageColumnPopup *pControl, weld::Widget *pParent)
std::unique_ptr< weld::Button > m_xLeft
#define SID_ATTR_PAGE_COLUMN
Definition: cmdid.h:896
#define FN_FORMAT_PAGE_COLUMN_DLG
Definition: cmdid.h:348
IMPL_LINK(PageColumnControl, ColumnButtonClickHdl_Impl, weld::Button &, rButton, void)
IMPL_LINK_NOARG(AccessibilityCheckEntry, GotoButtonClicked, weld::LinkButton &, bool)
Reference< XControl > m_xControl