/* -*- 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 .
*/
template<typename JustEnumType> void lcl_MaybeResetAlignToDistro(
weld::ComboBox& rLB, sal_uInt16 nListId, const SfxItemSet& rCoreAttrs, TypedWhichId<SfxEnumItemInterface> nWhichAlign, TypedWhichId<SfxEnumItemInterface> nWhichJM, JustEnumType eBlock)
{ const SfxEnumItemInterface* p = rCoreAttrs.GetItemIfSet(nWhichAlign); if (!p) // alignment not set. return;
JustEnumType eVal = static_cast<JustEnumType>(p->GetEnumValue()); if (eVal != eBlock) // alignment is not 'justify'. No need to go further. return;
p = rCoreAttrs.GetItemIfSet(nWhichJM); if (!p) // justification method is not set. return;
SvxCellJustifyMethod eMethod = static_cast<SvxCellJustifyMethod>(p->GetEnumValue()); if (eMethod == SvxCellJustifyMethod::Distribute)
{ // Select the 'distribute' entry in the specified list box.
rLB.set_active_id(OUString::number(nListId));
}
}
// feature supported , e.g. calc
SvxCellJustifyMethod eJM = SvxCellJustifyMethod::Auto; if (rLB.get_active_id().toInt32() == nListId)
eJM = SvxCellJustifyMethod::Distribute;
// tdf#129300 If it would create no change, don't force it const SvxJustifyMethodItem& rOldItem = static_cast<const SvxJustifyMethodItem&>(rOldSet.Get(nWhichJM)); if (rOldItem.GetValue() == eJM)
{
rSet.InvalidateItem(nWhichJM); return;
}
if (m_xLbFrameDir->get_visible())
{
nWhich = GetWhich(SID_ATTR_FRAMEDIRECTION); if (m_xLbFrameDir->get_value_changed_from_saved())
{
SvxFrameDirection eDir = m_xLbFrameDir->get_active_id();
rSet->Put(SvxFrameDirectionItem(eDir, nWhich));
bChanged = true;
} elseif (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
rSet->InvalidateItem(nWhich);
}
// Special treatment for distributed alignment; we need to set the justify // method to 'distribute' to distinguish from the normal justification.
TypedWhichId<SfxEnumItemInterface> nWhichHorJM(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD));
lcl_SetJustifyMethodToItemSet(*rSet, rOldSet, nWhichHorJM, *m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED); if (!bChanged)
bChanged = HasAlignmentChanged(*rSet, nWhichHorJM);
sal_uInt16 nWhich = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY);
SfxItemState eState = pCoreAttrs->GetItemState(nWhich); switch (eState)
{ case SfxItemState::UNKNOWN:
m_xLbHorAlign->hide(); break; case SfxItemState::DISABLED:
m_xLbHorAlign->set_sensitive(false); break; case SfxItemState::INVALID:
m_xLbHorAlign->set_active(-1); break; case SfxItemState::DEFAULT: case SfxItemState::SET:
{ const SvxHorJustifyItem& rJustifyItem = static_cast<const SvxHorJustifyItem&>(pCoreAttrs->Get(nWhich)); switch (rJustifyItem.GetValue())
{ case SvxCellHorJustify::Standard:
m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_STD)); break; case SvxCellHorJustify::Left:
m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_LEFT)); break; case SvxCellHorJustify::Center:
m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_CENTER)); break; case SvxCellHorJustify::Right:
m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_RIGHT)); break; case SvxCellHorJustify::Block:
m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_BLOCK)); break; case SvxCellHorJustify::Repeat:
m_xLbHorAlign->set_active_id(OUString::number(ALIGNDLG_HORALIGN_FILL)); break;
} break;
}
}
nWhich = GetWhich(SID_ATTR_ALIGN_INDENT);
eState = pCoreAttrs->GetItemState(nWhich); switch (eState)
{ case SfxItemState::UNKNOWN:
m_xEdIndent->hide();
m_xFtIndent->hide(); break; case SfxItemState::DISABLED:
m_xEdIndent->set_sensitive(false); break; case SfxItemState::INVALID:
m_xEdIndent->set_text(u""_ustr); break; case SfxItemState::DEFAULT: case SfxItemState::SET:
{ const SfxUInt16Item& rIndentItem = static_cast<const SfxUInt16Item&>(pCoreAttrs->Get(nWhich));
m_xEdIndent->set_value(rIndentItem.GetValue(), FieldUnit::TWIP); break;
}
}
nWhich = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY);
eState = pCoreAttrs->GetItemState(nWhich); switch (eState)
{ case SfxItemState::UNKNOWN:
m_xLbVerAlign->hide();
m_xFtVerAlign->hide(); break; case SfxItemState::DISABLED:
m_xLbVerAlign->set_sensitive(false); break; case SfxItemState::INVALID:
m_xLbVerAlign->set_active(-1); break; case SfxItemState::DEFAULT: case SfxItemState::SET:
{ const SvxVerJustifyItem& rJustifyItem = static_cast<const SvxVerJustifyItem&>(pCoreAttrs->Get(nWhich)); switch (rJustifyItem.GetValue())
{ case SvxCellVerJustify::Standard:
m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_STD)); break; case SvxCellVerJustify::Top:
m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_TOP)); break; case SvxCellVerJustify::Center:
m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_MID)); break; case SvxCellVerJustify::Bottom:
m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BOTTOM)); break; case SvxCellVerJustify::Block:
m_xLbVerAlign->set_active_id(OUString::number(ALIGNDLG_VERALIGN_BLOCK)); break;
} break;
}
}
nWhich = GetWhich(SID_ATTR_ALIGN_DEGREES);
eState = pCoreAttrs->GetItemState(nWhich); switch (eState)
{ case SfxItemState::UNKNOWN:
m_xNfRotate->hide();
m_xCtrlDialWin->hide(); break; case SfxItemState::DISABLED:
m_xNfRotate->set_sensitive(false);
m_xCtrlDialWin->set_sensitive(false); break; case SfxItemState::INVALID:
m_xCtrlDial->SetNoRotation(); break; case SfxItemState::DEFAULT: case SfxItemState::SET:
{ const SdrAngleItem& rAlignItem = static_cast<const SdrAngleItem&>(pCoreAttrs->Get(nWhich));
m_xCtrlDial->SetRotation(rAlignItem.GetValue()); break;
}
}
nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS);
eState = pCoreAttrs->GetItemState(nWhich); switch (eState)
{ case SfxItemState::UNKNOWN:
m_xVsRefEdge->hide(); break; case SfxItemState::DISABLED:
m_xVsRefEdge->set_sensitive(false); break; case SfxItemState::INVALID:
m_aVsRefEdge.SetNoSelection(); break; case SfxItemState::DEFAULT: case SfxItemState::SET:
{ const SvxRotateModeItem& rRotateModeItem = static_cast<const SvxRotateModeItem&>(pCoreAttrs->Get(nWhich)); switch (rRotateModeItem.GetValue())
{ case SvxRotateMode::SVX_ROTATE_MODE_STANDARD:
m_aVsRefEdge.SelectItem(IID_CELLLOCK); break; case SvxRotateMode::SVX_ROTATE_MODE_TOP:
m_aVsRefEdge.SelectItem(IID_TOPLOCK); break; case SvxRotateMode::SVX_ROTATE_MODE_BOTTOM:
m_aVsRefEdge.SelectItem(IID_BOTTOMLOCK); break; default:
m_aVsRefEdge.SetNoSelection(); break;
} break;
}
}
m_aVsRefEdge.SaveValue();
//text direction
nWhich = GetWhich(SID_ATTR_FRAMEDIRECTION);
eState = pCoreAttrs->GetItemState(nWhich); switch (eState)
{ case SfxItemState::UNKNOWN:
m_xLbFrameDir->hide(); break; case SfxItemState::DISABLED:
m_xLbFrameDir->set_sensitive(false); break; case SfxItemState::INVALID:
m_xLbFrameDir->set_active(-1); break; case SfxItemState::DEFAULT: case SfxItemState::SET:
{ const SvxFrameDirectionItem& rFrameDirItem = static_cast<const SvxFrameDirectionItem&>(pCoreAttrs->Get(nWhich));
m_xLbFrameDir->set_active_id(rFrameDirItem.GetValue()); break;
}
}
// Special treatment for distributed alignment; we need to set the justify // method to 'distribute' to distinguish from the normal justification.
TypedWhichId<SfxEnumItemInterface> nHorJustifyMethodWhich(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD));
SfxItemState eHorJustifyMethodState = pCoreAttrs->GetItemState(nHorJustifyMethodWhich); if (eHorJustifyMethodState == SfxItemState::UNKNOWN)
{ // feature unknown, e.g. dbaccess, remove the option int nDistribId = m_xLbHorAlign->find_id(OUString::number(ALIGNDLG_HORALIGN_DISTRIBUTED)); if (nDistribId != -1)
m_xLbHorAlign->remove(nDistribId);
} else
{ // feature known, e.g. calc
lcl_MaybeResetAlignToDistro(
*m_xLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED, *pCoreAttrs,
TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY)), nHorJustifyMethodWhich,
SvxCellHorJustify::Block);
}
TypedWhichId<SfxEnumItemInterface> nVerJustifyMethodWhich( GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD) );
SfxItemState eVerJustifyMethodState = pCoreAttrs->GetItemState(nVerJustifyMethodWhich); if (eVerJustifyMethodState == SfxItemState::UNKNOWN)
{ // feature unknown, e.g. dbaccess, remove the option int nDistribId = m_xLbVerAlign->find_id(OUString::number(ALIGNDLG_VERALIGN_DISTRIBUTED)); if (nDistribId != -1)
m_xLbVerAlign->remove(nDistribId);
} else
{ // feature known, e.g. calc
lcl_MaybeResetAlignToDistro(
*m_xLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED, *pCoreAttrs,
TypedWhichId<SfxEnumItemInterface>(GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY)), nVerJustifyMethodWhich,
SvxCellVerJustify::Block);
}
// indent edit field only for left alignment
m_xFtIndent->set_sensitive( bHorLeft );
m_xEdIndent->set_sensitive( bHorLeft );
// stacked disabled for fill alignment
m_xCbStacked->set_sensitive(!bHorFill);
// hyphenation only for automatic line breaks or for block alignment
m_xBtnHyphen->set_sensitive( m_xBtnWrap->get_active() || bHorBlock );
// shrink only without automatic line break, and not for block, fill or distribute.
m_xBtnShrink->set_sensitive( (m_xBtnWrap->get_state() == TRISTATE_FALSE) && !bHorBlock && !bHorFill && !bHorDist );
bool bStackedText = m_xCbStacked->get_active(); // windows to be disabled, if stacked text is turned ON
m_xFtRotate->set_sensitive(!bStackedText);
m_xFtRefEdge->set_sensitive(!bStackedText);
m_xVsRefEdge->set_sensitive(!bStackedText); // windows to be disabled, if stacked text is turned OFF
m_xCbAsianMode->set_sensitive(bStackedText); // rotation/stacked disabled for fill alignment/stacked
m_xCtrlDialWin->set_sensitive(!bHorFill && !bStackedText);
m_xNfRotate->set_sensitive(!bHorFill && !bStackedText);
}
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.