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 
23 #include <cmdid.h>
24 #include <swtypes.hxx>
25 
27 #include <sfx2/bindings.hxx>
28 #include <sfx2/dispatch.hxx>
29 #include <sfx2/viewfrm.hxx>
30 #include <vcl/settings.hxx>
31 #include <svx/svxids.hrc>
32 
33 namespace sw { namespace sidebar {
34 
36  : SfxPopupWindow( nId, pParent, "PageColumnControl", "modules/swriter/ui/pagecolumncontrol.ui" )
37 {
38  get( m_pMoreButton, "moreoptions" );
39 
40  bool bLandscape = false;
41  const SfxPoolItem *pItem;
42  if ( SfxViewFrame::Current() )
43  {
44  SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem );
45  bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape();
46  }
47 
48  if ( bLandscape )
49  {
50  get(m_pOneColumn, "column1L");
51  get(m_pTwoColumns, "column2L");
52  get(m_pThreeColumns, "column3L");
53  get(m_pLeft, "columnleftL");
54  get(m_pRight, "columnrightL");
55  }
56  else
57  {
58  get(m_pOneColumn, "column1");
59  get(m_pTwoColumns, "column2");
60  get(m_pThreeColumns, "column3");
61  get(m_pLeft, "columnleft");
62  get(m_pRight, "columnright");
63  }
64 
65  m_pOneColumn->Show();
68  m_pLeft->Show();
69  m_pRight->Show();
70 
71  m_pOneColumn->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
72  m_pTwoColumns->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
73  m_pThreeColumns->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
74  m_pLeft->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
75  m_pRight->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
76 
77  m_pMoreButton->SetClickHdl( LINK( this, PageColumnControl, MoreButtonClickHdl_Impl ) );
79 }
80 
82 {
83  disposeOnce();
84 }
85 
87 {
95 }
96 
97 void PageColumnControl::ExecuteColumnChange( const sal_uInt16 nColumnType )
98 {
99  std::unique_ptr<SfxInt16Item> mpPageColumnTypeItem( new SfxInt16Item(SID_ATTR_PAGE_COLUMN) );
100  mpPageColumnTypeItem->SetValue( nColumnType );
101  if ( SfxViewFrame::Current() )
103  SfxCallMode::RECORD, { mpPageColumnTypeItem.get() });
104 }
105 
106 IMPL_LINK( PageColumnControl, ColumnButtonClickHdl_Impl, Button*, pButton, void )
107 {
108  if ( pButton == m_pOneColumn.get() )
109  ExecuteColumnChange( 1 );
110  else if ( pButton == m_pTwoColumns.get() )
111  ExecuteColumnChange( 2 );
112  else if ( pButton == m_pThreeColumns.get() )
113  ExecuteColumnChange( 3 );
114  else if ( pButton == m_pLeft.get() )
115  ExecuteColumnChange( 4 );
116  else if ( pButton == m_pRight.get() )
117  ExecuteColumnChange( 5 );
118 
119  EndPopupMode();
120 }
121 
122 IMPL_LINK_NOARG( PageColumnControl, MoreButtonClickHdl_Impl, Button*, void )
123 {
124  if ( SfxViewFrame::Current() )
126  EndPopupMode();
127 }
128 
129 } } // end of namespace sw::sidebar
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
#define SID_ATTR_PAGE_COLUMN
Definition: cmdid.h:832
void SetClickHdl(const Link< Button *, void > &rLink)
static void ExecuteColumnChange(const sal_uInt16 nColumnType)
Dialog to specify the properties of drop-down form field.
Definition: accfrmobj.cxx:40
IMPL_LINK_NOARG(PageColumnControl, MoreButtonClickHdl_Impl, Button *, void)
SfxBindings & GetBindings()
VclPtr< PushButton > m_pTwoColumns
SfxItemState QueryState(sal_uInt16 nSID, const SfxPoolItem *&rpState)
void GrabFocus()
PageColumnControl(sal_uInt16 nId, vcl::Window *pParent)
static SfxViewFrame * Current()
#define FN_FORMAT_PAGE_COLUMN_DLG
Definition: cmdid.h:295
VclPtr< PushButton > m_pMoreButton
virtual void dispose() override
VclPtr< PushButton > m_pThreeColumns
SfxDispatcher * GetDispatcher() const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
IMPL_LINK(PageColumnControl, ColumnButtonClickHdl_Impl, Button *, pButton, void)
virtual void dispose() override
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)