LibreOffice Module cui (master)  1
dstribut.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 <sfx2/basedlgs.hxx>
21 #include <dstribut.hxx>
22 
23 /*************************************************************************
24 |*
25 |* Dialog
26 |*
27 \************************************************************************/
28 
30  const SfxItemSet& rInAttrs, SvxDistributeHorizontal eHor,
32  : SfxSingleTabDialogController(pParent, &rInAttrs, "cui/ui/distributiondialog.ui",
33  "DistributionDialog")
34 {
35  SetTabPage(std::make_unique<SvxDistributePage>(get_content_area(), this, rInAttrs, eHor, eVer));
36  mpPage = static_cast<SvxDistributePage*>(GetTabPage());
37 }
38 
40 {
41 }
42 
43 /*************************************************************************
44 |*
45 |* Tabpage
46 |*
47 \************************************************************************/
48 
50  const SfxItemSet& rInAttrs, SvxDistributeHorizontal eHor,
52  : SfxTabPage(pPage, pController, "cui/ui/distributionpage.ui", "DistributionPage",
53  &rInAttrs)
54  , m_eDistributeHor(eHor)
55  , m_eDistributeVer(eVer)
56  , m_xBtnHorNone(m_xBuilder->weld_radio_button("hornone"))
57  , m_xBtnHorLeft(m_xBuilder->weld_radio_button("horleft"))
58  , m_xBtnHorCenter(m_xBuilder->weld_radio_button("horcenter"))
59  , m_xBtnHorDistance(m_xBuilder->weld_radio_button("hordistance"))
60  , m_xBtnHorRight(m_xBuilder->weld_radio_button("horright"))
61  , m_xBtnVerNone(m_xBuilder->weld_radio_button("vernone"))
62  , m_xBtnVerTop(m_xBuilder->weld_radio_button("vertop"))
63  , m_xBtnVerCenter(m_xBuilder->weld_radio_button("vercenter"))
64  , m_xBtnVerDistance(m_xBuilder->weld_radio_button("verdistance"))
65  , m_xBtnVerBottom(m_xBuilder->weld_radio_button("verbottom"))
66 {
67 }
68 
70 {
71 }
72 
73 /*************************************************************************
74 |*
75 |* read the delivered Item-Set
76 |*
77 \************************************************************************/
78 
80 {
81  m_xBtnHorNone->set_active(false);
82  m_xBtnHorLeft->set_active(false);
83  m_xBtnHorCenter->set_active(false);
84  m_xBtnHorDistance->set_active(false);
85  m_xBtnHorRight->set_active(false);
86 
87  switch(m_eDistributeHor)
88  {
89  case SvxDistributeHorizontal::NONE : m_xBtnHorNone->set_active(true); break;
90  case SvxDistributeHorizontal::Left : m_xBtnHorLeft->set_active(true); break;
91  case SvxDistributeHorizontal::Center : m_xBtnHorCenter->set_active(true); break;
92  case SvxDistributeHorizontal::Distance : m_xBtnHorDistance->set_active(true); break;
93  case SvxDistributeHorizontal::Right : m_xBtnHorRight->set_active(true); break;
94  }
95 
96  m_xBtnVerNone->set_active(false);
97  m_xBtnVerTop->set_active(false);
98  m_xBtnVerCenter->set_active(false);
99  m_xBtnVerDistance->set_active(false);
100  m_xBtnVerBottom->set_active(false);
101 
102  switch(m_eDistributeVer)
103  {
104  case SvxDistributeVertical::NONE : m_xBtnVerNone->set_active(true); break;
105  case SvxDistributeVertical::Top : m_xBtnVerTop->set_active(true); break;
106  case SvxDistributeVertical::Center : m_xBtnVerCenter->set_active(true); break;
107  case SvxDistributeVertical::Distance : m_xBtnVerDistance->set_active(true); break;
108  case SvxDistributeVertical::Bottom : m_xBtnVerBottom->set_active(true); break;
109  }
110 }
111 
112 /*************************************************************************
113 |*
114 |* Fill the delivered Item-Set with dialogbox-attributes
115 |*
116 \************************************************************************/
117 
119 {
120  SvxDistributeHorizontal eDistributeHor(SvxDistributeHorizontal::NONE);
121  SvxDistributeVertical eDistributeVer(SvxDistributeVertical::NONE);
122 
123  if(m_xBtnHorLeft->get_active())
124  eDistributeHor = SvxDistributeHorizontal::Left;
125  else if(m_xBtnHorCenter->get_active())
126  eDistributeHor = SvxDistributeHorizontal::Center;
127  else if(m_xBtnHorDistance->get_active())
128  eDistributeHor = SvxDistributeHorizontal::Distance;
129  else if(m_xBtnHorRight->get_active())
130  eDistributeHor = SvxDistributeHorizontal::Right;
131 
132  if(m_xBtnVerTop->get_active())
133  eDistributeVer = SvxDistributeVertical::Top;
134  else if(m_xBtnVerCenter->get_active())
135  eDistributeVer = SvxDistributeVertical::Center;
136  else if(m_xBtnVerDistance->get_active())
137  eDistributeVer = SvxDistributeVertical::Distance;
138  else if(m_xBtnVerBottom->get_active())
139  eDistributeVer = SvxDistributeVertical::Bottom;
140 
141  if(eDistributeHor != m_eDistributeHor || eDistributeVer != m_eDistributeVer)
142  {
143  m_eDistributeHor = eDistributeHor;
144  m_eDistributeVer = eDistributeVer;
145  return true;
146  }
147 
148  return false;
149 }
150 
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvxDistributePage * mpPage
Definition: dstribut.hxx:57
std::unique_ptr< weld::RadioButton > m_xBtnHorNone
Definition: dstribut.hxx:31
std::unique_ptr< weld::RadioButton > m_xBtnHorCenter
Definition: dstribut.hxx:33
weld::Container * get_content_area()
virtual void Reset(const SfxItemSet *) override
Definition: dstribut.cxx:79
SvxDistributeHorizontal m_eDistributeHor
Definition: dstribut.hxx:28
std::unique_ptr< weld::RadioButton > m_xBtnHorLeft
Definition: dstribut.hxx:32
SvxDistributeDialog(weld::Window *pParent, const SfxItemSet &rAttr, SvxDistributeHorizontal eHor, SvxDistributeVertical eVer)
Definition: dstribut.cxx:29
std::unique_ptr< weld::RadioButton > m_xBtnHorDistance
Definition: dstribut.hxx:34
virtual ~SvxDistributePage() override
Definition: dstribut.cxx:69
std::unique_ptr< weld::RadioButton > m_xBtnVerDistance
Definition: dstribut.hxx:39
virtual bool FillItemSet(SfxItemSet *) override
Definition: dstribut.cxx:118
SvxDistributeVertical
virtual ~SvxDistributeDialog() override
Definition: dstribut.cxx:39
void SetTabPage(std::unique_ptr< SfxTabPage > xTabPage)
std::unique_ptr< weld::RadioButton > m_xBtnVerCenter
Definition: dstribut.hxx:38
std::unique_ptr< weld::RadioButton > m_xBtnVerNone
Definition: dstribut.hxx:36
SvxDistributePage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rInAttrs, SvxDistributeHorizontal eHor, SvxDistributeVertical eVer)
Definition: dstribut.cxx:49
std::unique_ptr< weld::RadioButton > m_xBtnHorRight
Definition: dstribut.hxx:35
SvxDistributeVertical m_eDistributeVer
Definition: dstribut.hxx:29
std::unique_ptr< weld::RadioButton > m_xBtnVerBottom
Definition: dstribut.hxx:40
SfxTabPage * GetTabPage() const
SvxDistributeHorizontal
std::unique_ptr< weld::RadioButton > m_xBtnVerTop
Definition: dstribut.hxx:37