summaryrefslogtreecommitdiff
path: root/cui/source/tabpages/align.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/tabpages/align.cxx')
-rw-r--r--cui/source/tabpages/align.cxx106
1 files changed, 104 insertions, 2 deletions
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index 65d0cad3dfd1..6e23abea215e 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -40,6 +40,7 @@
#include <svx/algitem.hxx>
#include <editeng/frmdiritem.hxx>
+#include <editeng/justifyitem.hxx>
#include <dialmgr.hxx>
#include <svx/dlgutil.hxx>
#include <tools/shl.hxx>
@@ -70,6 +71,7 @@ static const HorJustConnection::MapEntryType s_pHorJustMap[] =
{ ALIGNDLG_HORALIGN_RIGHT, SVX_HOR_JUSTIFY_RIGHT },
{ ALIGNDLG_HORALIGN_BLOCK, SVX_HOR_JUSTIFY_BLOCK },
{ ALIGNDLG_HORALIGN_FILL, SVX_HOR_JUSTIFY_REPEAT },
+ { ALIGNDLG_HORALIGN_DISTRIBUTED, SVX_HOR_JUSTIFY_BLOCK },
{ LISTBOX_ENTRY_NOTFOUND, SVX_HOR_JUSTIFY_STANDARD }
};
@@ -84,6 +86,8 @@ static const VerJustConnection::MapEntryType s_pVerJustMap[] =
{ ALIGNDLG_VERALIGN_TOP, SVX_VER_JUSTIFY_TOP },
{ ALIGNDLG_VERALIGN_MID, SVX_VER_JUSTIFY_CENTER },
{ ALIGNDLG_VERALIGN_BOTTOM, SVX_VER_JUSTIFY_BOTTOM },
+ { ALIGNDLG_VERALIGN_BLOCK, SVX_VER_JUSTIFY_BLOCK },
+ { ALIGNDLG_VERALIGN_DISTRIBUTED, SVX_VER_JUSTIFY_BLOCK },
{ LISTBOX_ENTRY_NOTFOUND, SVX_VER_JUSTIFY_STANDARD }
};
@@ -118,6 +122,48 @@ static USHORT s_pRanges[] =
// ============================================================================
+namespace {
+
+template<typename _JustContainerType, typename _JustEnumType>
+void lcl_MaybeResetAlignToDistro(
+ ListBox& rLB, USHORT nListPos, const SfxItemSet& rCoreAttrs, USHORT nWhichAlign, USHORT nWhichJM, _JustEnumType eBlock)
+{
+ const SfxPoolItem* pItem;
+ if (rCoreAttrs.GetItemState(nWhichAlign, TRUE, &pItem) != SFX_ITEM_SET)
+ // alignment not set.
+ return;
+
+ const SfxEnumItem* p = static_cast<const SfxEnumItem*>(pItem);
+ _JustContainerType eVal = static_cast<_JustContainerType>(p->GetEnumValue());
+ if (eVal != eBlock)
+ // alignment is not 'justify'. No need to go further.
+ return;
+
+ if (rCoreAttrs.GetItemState(nWhichJM, TRUE, &pItem) != SFX_ITEM_SET)
+ // justification method is not set.
+ return;
+
+ p = static_cast<const SfxEnumItem*>(pItem);
+ SvxCellJustifyMethod eMethod = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
+ if (eMethod == SVX_JUSTIFY_METHOD_DISTRIBUTE)
+ // Select the 'distribute' entry in the specified list box.
+ rLB.SelectEntryPos(nListPos);
+}
+
+void lcl_SetJustifyMethodToItemSet(SfxItemSet& rSet, USHORT nWhichJM, const ListBox& rLB, USHORT nListPos)
+{
+ SvxCellJustifyMethod eJM = SVX_JUSTIFY_METHOD_AUTO;
+ if (rLB.GetSelectEntryPos() == nListPos)
+ eJM = SVX_JUSTIFY_METHOD_DISTRIBUTE;
+
+ SvxJustifyMethodItem aItem(eJM, nWhichJM);
+ rSet.Put(aItem);
+}
+
+}
+
+// ============================================================================
+
AlignmentTabPage::AlignmentTabPage( Window* pParent, const SfxItemSet& rCoreAttrs ) :
SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_ALIGNMENT ), rCoreAttrs ),
@@ -213,9 +259,43 @@ USHORT* AlignmentTabPage::GetRanges()
return s_pRanges;
}
+BOOL AlignmentTabPage::FillItemSet( SfxItemSet& rSet )
+{
+ bool bChanged = SfxTabPage::FillItemSet(rSet);
+
+ // Special treatment for distributed alignment; we need to set the justify
+ // method to 'distribute' to distinguish from the normal justification.
+
+ USHORT nWhichHorJM = GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD);
+ lcl_SetJustifyMethodToItemSet(rSet, nWhichHorJM, maLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED);
+ if (!bChanged)
+ bChanged = HasAlignmentChanged(rSet, nWhichHorJM);
+
+ USHORT nWhichVerJM = GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD);
+ lcl_SetJustifyMethodToItemSet(rSet, nWhichVerJM, maLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED);
+ if (!bChanged)
+ bChanged = HasAlignmentChanged(rSet, nWhichVerJM);
+
+ return bChanged;
+}
+
void AlignmentTabPage::Reset( const SfxItemSet& rCoreAttrs )
{
SfxTabPage::Reset( rCoreAttrs );
+
+ // Special treatment for distributed alignment; we need to set the justify
+ // method to 'distribute' to distinguish from the normal justification.
+
+ lcl_MaybeResetAlignToDistro<SvxCellHorJustify, SvxCellHorJustify>(
+ maLbHorAlign, ALIGNDLG_HORALIGN_DISTRIBUTED, rCoreAttrs,
+ GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY), GetWhich(SID_ATTR_ALIGN_HOR_JUSTIFY_METHOD),
+ SVX_HOR_JUSTIFY_BLOCK);
+
+ lcl_MaybeResetAlignToDistro<SvxCellVerJustify, SvxCellVerJustify>(
+ maLbVerAlign, ALIGNDLG_VERALIGN_DISTRIBUTED, rCoreAttrs,
+ GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY), GetWhich(SID_ATTR_ALIGN_VER_JUSTIFY_METHOD),
+ SVX_VER_JUSTIFY_BLOCK);
+
UpdateEnableControls();
}
@@ -264,6 +344,7 @@ void AlignmentTabPage::UpdateEnableControls()
bool bHorLeft = (nHorAlign == ALIGNDLG_HORALIGN_LEFT);
bool bHorBlock = (nHorAlign == ALIGNDLG_HORALIGN_BLOCK);
bool bHorFill = (nHorAlign == ALIGNDLG_HORALIGN_FILL);
+ bool bHorDist = (nHorAlign == ALIGNDLG_HORALIGN_DISTRIBUTED);
// indent edit field only for left alignment
maFtIndent.Enable( bHorLeft );
@@ -275,8 +356,8 @@ void AlignmentTabPage::UpdateEnableControls()
// hyphenation only for automatic line breaks or for block alignment
maBtnHyphen.Enable( maBtnWrap.IsChecked() || bHorBlock );
- // shrink only without automatic line break, and not for block and fill
- maBtnShrink.Enable( (maBtnWrap.GetState() == STATE_NOCHECK) && !bHorBlock && !bHorFill );
+ // shrink only without automatic line break, and not for block, fill or distribute.
+ maBtnShrink.Enable( (maBtnWrap.GetState() == STATE_NOCHECK) && !bHorBlock && !bHorFill && !bHorDist );
// visibility of fixed lines
maFlAlignment.Show( maLbHorAlign.IsVisible() || maEdIndent.IsVisible() || maLbVerAlign.IsVisible() );
@@ -284,6 +365,27 @@ void AlignmentTabPage::UpdateEnableControls()
maFlProperties.Show( maBtnWrap.IsVisible() || maBtnHyphen.IsVisible() || maBtnShrink.IsVisible() || maLbFrameDir.IsVisible() );
}
+bool AlignmentTabPage::HasAlignmentChanged( const SfxItemSet& rNew, USHORT nWhich ) const
+{
+ const SfxItemSet& rOld = GetItemSet();
+ const SfxPoolItem* pItem;
+ SvxCellJustifyMethod eMethodOld = SVX_JUSTIFY_METHOD_AUTO;
+ SvxCellJustifyMethod eMethodNew = SVX_JUSTIFY_METHOD_AUTO;
+ if (rOld.GetItemState(nWhich, TRUE, &pItem) == SFX_ITEM_SET)
+ {
+ const SfxEnumItem* p = static_cast<const SfxEnumItem*>(pItem);
+ eMethodOld = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
+ }
+
+ if (rNew.GetItemState(nWhich, TRUE, &pItem) == SFX_ITEM_SET)
+ {
+ const SfxEnumItem* p = static_cast<const SfxEnumItem*>(pItem);
+ eMethodNew = static_cast<SvxCellJustifyMethod>(p->GetEnumValue());
+ }
+
+ return eMethodOld != eMethodNew;
+}
+
IMPL_LINK( AlignmentTabPage, UpdateEnableHdl, void*, EMPTYARG )
{
UpdateEnableControls();