20#include <osl/diagnose.h>
31const sal_uInt16 SPECIAL_FACTOR = 0xFFFF;
41 return static_cast<sal_uInt16
>(
m_xUserEdit->get_value(FieldUnit::PERCENT));
43 return SPECIAL_FACTOR;
50 if (nButtonId == ZoomButtonId::NONE)
52 if (nNewFactor == 100)
61 m_xUserEdit->set_value(nNewFactor, FieldUnit::PERCENT);
67 m_xUserEdit->set_value(nNewFactor, FieldUnit::PERCENT);
70 case ZoomButtonId::OPTIMAL:
76 case ZoomButtonId::PAGEWIDTH:
82 case ZoomButtonId::WHOLEPAGE:
98 case ZoomButtonId::OPTIMAL:
102 case ZoomButtonId::PAGEWIDTH:
106 case ZoomButtonId::WHOLEPAGE:
111 OSL_FAIL(
"Wrong button number!");
118 m_xUserEdit->set_range(nMin, nMax, FieldUnit::PERCENT);
127 , m_xOptimalBtn(m_xBuilder->weld_radio_button(
"optimal"))
128 , m_xWholePageBtn(m_xBuilder->weld_radio_button(
"fitwandh"))
129 , m_xPageWidthBtn(m_xBuilder->weld_radio_button(
"fitw"))
130 , m_x100Btn(m_xBuilder->weld_radio_button(
"100pc"))
131 , m_xUserBtn(m_xBuilder->weld_radio_button(
"variable"))
132 , m_xUserEdit(m_xBuilder->weld_metric_spin_button(
"zoomsb",
FieldUnit::
PERCENT))
133 , m_xViewFrame(m_xBuilder->weld_widget(
"viewframe"))
134 , m_xAutomaticBtn(m_xBuilder->weld_radio_button(
"automatic"))
135 , m_xSingleBtn(m_xBuilder->weld_radio_button(
"singlepage"))
136 , m_xColumnsBtn(m_xBuilder->weld_radio_button(
"columns"))
137 , m_xColumnsEdit(m_xBuilder->weld_spin_button(
"columnssb"))
138 , m_xBookModeChk(m_xBuilder->weld_check_button(
"bookmode"))
139 , m_xOKBtn(m_xBuilder->weld_button(
"ok"))
166 sal_uInt16 nMin = 10;
167 sal_uInt16 nMax = 1000;
172 pOldUserItem = pShell->GetItem(SID_ATTR_ZOOM_USER);
188 if (
auto pZoomItem =
dynamic_cast<const SvxZoomItem*
>(&rItem))
190 const sal_uInt16 nZoom = pZoomItem->GetValue();
197 case SvxZoomType::OPTIMAL:
198 nButtonId = ZoomButtonId::OPTIMAL;
200 case SvxZoomType::PAGEWIDTH:
201 nButtonId = ZoomButtonId::PAGEWIDTH;
203 case SvxZoomType::WHOLEPAGE:
204 nButtonId = ZoomButtonId::WHOLEPAGE;
206 case SvxZoomType::PERCENT:
208 case SvxZoomType::PAGEWIDTH_NOBORDER:
212 if (!(SvxZoomEnableFlags::N100 & nValSet))
214 if (!(SvxZoomEnableFlags::OPTIMAL & nValSet))
216 if (!(SvxZoomEnableFlags::PAGEWIDTH & nValSet))
218 if (!(SvxZoomEnableFlags::WHOLEPAGE & nValSet))
231 const sal_uInt16 nColumns = pViewLayoutItem->GetValue();
232 const bool bBookMode = pViewLayoutItem->IsBookMode();
241 else if (1 == nColumns)
254 if (nColumns % 2 != 0)
275 if (m_xUserBtn->get_active())
277 m_xUserEdit->set_sensitive(
true);
278 m_xUserEdit->grab_focus();
282 m_xUserEdit->set_sensitive(
false);
288 if (!m_xUserBtn->get_active())
298 if (m_xAutomaticBtn->get_active() || m_xSingleBtn->get_active())
300 m_xColumnsEdit->set_sensitive(
false);
301 m_xBookModeChk->set_sensitive(
false);
303 else if (m_xColumnsBtn->get_active())
305 m_xColumnsEdit->set_sensitive(
true);
306 m_xColumnsEdit->grab_focus();
307 if (m_xColumnsEdit->get_value() % 2 == 0)
308 m_xBookModeChk->set_sensitive(
true);
314 if (!m_xColumnsBtn->get_active())
317 if (m_xColumnsEdit->get_value() % 2 == 0)
319 m_xBookModeChk->set_sensitive(
true);
323 m_xBookModeChk->set_active(
false);
324 m_xBookModeChk->set_sensitive(
false);
332 if (!m_xColumnsBtn->get_active())
342 SvxZoomItem aZoomItem(SvxZoomType::PERCENT, 0, SID_ATTR_ZOOM);
345 sal_uInt16 nFactor = GetFactor();
347 if (SPECIAL_FACTOR == nFactor)
349 if (m_xOptimalBtn->get_active())
350 aZoomItem.
SetType(SvxZoomType::OPTIMAL);
351 else if (m_xPageWidthBtn->get_active())
352 aZoomItem.
SetType(SvxZoomType::PAGEWIDTH);
353 else if (m_xWholePageBtn->get_active())
354 aZoomItem.
SetType(SvxZoomType::WHOLEPAGE);
358 aZoomItem.SetValue(nFactor);
361 if (m_xAutomaticBtn->get_active())
363 aViewLayoutItem.SetValue(0);
366 if (m_xSingleBtn->get_active())
368 aViewLayoutItem.SetValue(1);
371 else if (m_xColumnsBtn->get_active())
373 aViewLayoutItem.SetValue(
static_cast<sal_uInt16
>(m_xColumnsEdit->get_value()));
374 aViewLayoutItem.
SetBookMode(m_xBookModeChk->get_active());
378 m_pOutSet->Put(aZoomItem);
381 if (m_xViewFrame->get_sensitive())
382 m_pOutSet->Put(aViewLayoutItem);
387 sal_uInt16 nZoomValue
388 =
static_cast<sal_uInt16
>(m_xUserEdit->get_value(FieldUnit::PERCENT));
389 pShell->PutItem(
SfxUInt16Item(SID_ATTR_ZOOM_USER, nZoomValue));
Reference< XExecutableDialog > m_xDialog
sal_uInt16 GetValue() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
void SetBookMode(bool bNew)
const SfxItemSet * GetOutputItemSet() const
std::unique_ptr< weld::RadioButton > m_xOptimalBtn
std::unique_ptr< weld::RadioButton > m_xColumnsBtn
std::unique_ptr< weld::Widget > m_xViewFrame
std::unique_ptr< weld::RadioButton > m_xSingleBtn
void HideButton(ZoomButtonId nButtonId)
std::unique_ptr< weld::CheckButton > m_xBookModeChk
std::unique_ptr< weld::RadioButton > m_xUserBtn
SvxZoomDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)
std::unique_ptr< SfxItemSet > m_pOutSet
void SetLimits(sal_uInt16 nMin, sal_uInt16 nMax)
void SetFactor(sal_uInt16 nNewFactor, ZoomButtonId nButtonId=ZoomButtonId::NONE)
std::unique_ptr< weld::MetricSpinButton > m_xUserEdit
std::unique_ptr< weld::Button > m_xOKBtn
std::unique_ptr< weld::RadioButton > m_xPageWidthBtn
std::unique_ptr< weld::SpinButton > m_xColumnsEdit
std::unique_ptr< weld::RadioButton > m_xAutomaticBtn
const SfxItemSet & m_rSet
sal_uInt16 GetFactor() const
std::unique_ptr< weld::RadioButton > m_xWholePageBtn
std::unique_ptr< weld::RadioButton > m_x100Btn
void SetType(SvxZoomType eNewType)
#define DBG_ASSERT(sCon, aError)
virtual tools::Long GetValue() const override
#define LINK(Instance, Class, Member)
constexpr OUStringLiteral PERCENT(u"Percent")
IMPL_LINK_NOARG(SvxZoomDialog, UserHdl, weld::Toggleable &, void)