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 <svl/intitem.hxx>
31 #include <vcl/settings.hxx>
32 #include <svx/pageitem.hxx>
33 #include <svx/svxids.hrc>
34 
35 namespace sw { namespace sidebar {
36 
38  : SfxPopupWindow( nId, pParent, "PageColumnControl", "modules/swriter/ui/pagecolumncontrol.ui" )
39 {
40  get( m_pMoreButton, "moreoptions" );
41 
42  bool bLandscape = false;
43  const SfxPoolItem *pItem;
44  if ( SfxViewFrame::Current() )
45  {
46  SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem );
47  bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape();
48  }
49 
50  if ( bLandscape )
51  {
52  get(m_pOneColumn, "column1L");
53  get(m_pTwoColumns, "column2L");
54  get(m_pThreeColumns, "column3L");
55  get(m_pLeft, "columnleftL");
56  get(m_pRight, "columnrightL");
57  }
58  else
59  {
60  get(m_pOneColumn, "column1");
61  get(m_pTwoColumns, "column2");
62  get(m_pThreeColumns, "column3");
63  get(m_pLeft, "columnleft");
64  get(m_pRight, "columnright");
65  }
66 
67  m_pOneColumn->Show();
70  m_pLeft->Show();
71  m_pRight->Show();
72 
73  m_pOneColumn->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
74  m_pTwoColumns->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
75  m_pThreeColumns->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
76  m_pLeft->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
77  m_pRight->SetClickHdl( LINK( this, PageColumnControl, ColumnButtonClickHdl_Impl ) );
78 
79  m_pMoreButton->SetClickHdl( LINK( this, PageColumnControl, MoreButtonClickHdl_Impl ) );
81 }
82 
84 {
85  disposeOnce();
86 }
87 
89 {
97 }
98 
99 void PageColumnControl::ExecuteColumnChange( const sal_uInt16 nColumnType )
100 {
101  std::unique_ptr<SfxInt16Item> mpPageColumnTypeItem( new SfxInt16Item(SID_ATTR_PAGE_COLUMN) );
102  mpPageColumnTypeItem->SetValue( nColumnType );
103  if ( SfxViewFrame::Current() )
105  SfxCallMode::RECORD, { mpPageColumnTypeItem.get() });
106 }
107 
108 IMPL_LINK( PageColumnControl, ColumnButtonClickHdl_Impl, Button*, pButton, void )
109 {
110  if ( pButton == m_pOneColumn.get() )
111  ExecuteColumnChange( 1 );
112  else if ( pButton == m_pTwoColumns.get() )
113  ExecuteColumnChange( 2 );
114  else if ( pButton == m_pThreeColumns.get() )
115  ExecuteColumnChange( 3 );
116  else if ( pButton == m_pLeft.get() )
117  ExecuteColumnChange( 4 );
118  else if ( pButton == m_pRight.get() )
119  ExecuteColumnChange( 5 );
120 
121  EndPopupMode();
122 }
123 
124 IMPL_LINK_NOARG( PageColumnControl, MoreButtonClickHdl_Impl, Button*, void )
125 {
126  if ( SfxViewFrame::Current() )
128  EndPopupMode();
129 }
130 
131 } } // end of namespace sw::sidebar
132 
133 /* 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:834
void SetClickHdl(const Link< Button *, void > &rLink)
static void ExecuteColumnChange(const sal_uInt16 nColumnType)
Dialog to specify the properties of date 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:296
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)