/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void SwTextGridPage::PutGridItem(SfxItemSet& rSet)
{
SwTextGridItem aGridItem;
aGridItem.SetGridType(m_xNoGridRB->get_active() ? SwTextGrid::NONE :
m_xLinesGridRB->get_active() ? SwTextGrid::LinesOnly : SwTextGrid::LinesAndChars );
aGridItem.SetSnapToChars(m_xSnapToCharsCB->get_active());
aGridItem.SetLines(m_xLinesPerPageNF->get_value());
aGridItem.SetBaseHeight( static_cast< sal_uInt16 >(
m_bRubyUserValue ? m_nRubyUserValue :
m_xTextSizeMF->denormalize(m_xTextSizeMF->get_value(FieldUnit::TWIP))) ); // Tdf#151544: set ruby height from the value get from UI only when in square page mode. // When in normal mode, the ruby height should be zero. if (m_bSquaredMode)
aGridItem.SetRubyHeight(static_cast<sal_uInt16>(m_xRubySizeMF->denormalize(m_xRubySizeMF->get_value(FieldUnit::TWIP)))); else
aGridItem.SetRubyHeight(0);
aGridItem.SetBaseWidth( static_cast< sal_uInt16 >(m_xCharWidthMF->denormalize(m_xCharWidthMF->get_value(FieldUnit::TWIP))) );
aGridItem.SetRubyTextBelow(m_xRubyBelowCB->get_active());
aGridItem.SetSquaredMode(m_bSquaredMode);
aGridItem.SetDisplayGrid(m_xDisplayCB->get_active());
aGridItem.SetPrintGrid(m_xPrintCB->get_active());
aGridItem.SetColor(m_xColorLB->GetSelectEntryColor());
rSet.Put(aGridItem);
IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, weld::SpinButton&, rField, void)
{ //if in squared mode if ( m_bSquaredMode )
{ if (m_xCharsPerLineNF.get() == &rField)
{ auto nValue = m_xCharsPerLineNF->get_value();
assert(nValue && "div-by-zero"); auto nWidth = m_aPageSize.Width() / nValue;
m_xTextSizeMF->set_value(m_xTextSizeMF->normalize(nWidth), FieldUnit::TWIP); //prevent rounding errors in the MetricField by saving the used value
m_nRubyUserValue = nWidth;
m_bRubyUserValue = true;
} //set maximum line per page
{
sal_Int32 nMaxLines = static_cast< sal_Int32 >(m_aPageSize.Height() /
( m_xTextSizeMF->denormalize(m_xTextSizeMF->get_value(FieldUnit::TWIP)) +
m_xRubySizeMF->denormalize(m_xRubySizeMF->get_value(FieldUnit::TWIP))));
m_xLinesPerPageNF->set_max(nMaxLines);
m_xLinesPerPageNF->set_sensitive(nMaxLines != 0);
}
SetLinesOrCharsRanges( *m_xLinesRangeFT , m_xLinesPerPageNF->get_max() );
SetLinesOrCharsRanges( *m_xCharsRangeFT , m_xCharsPerLineNF->get_max() );
} else//in normal mode
{ if (m_xLinesPerPageNF.get() == &rField)
{ auto nValue = m_xLinesPerPageNF->get_value();
assert(nValue && "div-by-zero"); auto nHeight = m_aPageSize.Height() / nValue;
m_xTextSizeMF->set_value(m_xTextSizeMF->normalize(nHeight), FieldUnit::TWIP);
SetLinesOrCharsRanges( *m_xLinesRangeFT , m_xLinesPerPageNF->get_max() );
IMPL_LINK(SwTextGridPage, GridTypeHdl, weld::Toggleable&, rButton, void)
{ if (!rButton.get_active()) return;
if (m_xNoGridRB.get() == &rButton)
{ // GRID_NONE mode: // "Layout" and "Display" sections should all be disabled.
m_xLayoutFL->set_sensitive(false);
m_xDisplayFL->set_sensitive(false);
} else
{ // GRID_LINES_ONLY or GRID_LINES_CHARS mode: // "Layout" and "Display" sections should all be enabled; // DisplayGridHdl should be executed;
m_xLayoutFL->set_sensitive(true);
m_xDisplayFL->set_sensitive(true);
DisplayGridHdl(*m_xDisplayCB);
}
if (m_xCharsGridRB.get() == &rButton)
{ // GRID_LINES_CHARS mode: // "Snap to character" should be enabled; // "Characters per line" should be enabled; // "Characters range" should be enabled;
m_xSnapToCharsCB->set_sensitive(true);
m_xCharsPerLineFT->set_sensitive(true);
m_xCharsPerLineNF->set_sensitive(true);
m_xCharsRangeFT->set_sensitive(true);
m_xCharWidthFT->set_sensitive(true);
m_xCharWidthMF->set_sensitive(true);
} else
{ // GRID_NONE or GRID_LINES_ONLY mode: // "Snap to character" should be disabled; // "Characters per line" should be disabled; // "Characters range" should be disabled;
m_xSnapToCharsCB->set_sensitive(false);
m_xCharsPerLineFT->set_sensitive(false);
m_xCharsPerLineNF->set_sensitive(false);
m_xCharsRangeFT->set_sensitive(false);
m_xCharWidthFT->set_sensitive(false);
m_xCharWidthMF->set_sensitive(false);
}
if (m_xNoGridRB.get() != &rButton)
{ // GRID_LINES_ONLY or GRID_LINES_CHARS mode: (additionally) // TextSizeChangedHdl should be executed to recalculate which dependencies are sensitive.
TextSizeChangedHdl(*m_xTextSizeMF);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.