diff options
-rw-r--r-- | cui/source/inc/align.hxx | 3 | ||||
-rw-r--r-- | cui/source/tabpages/align.cxx | 106 | ||||
-rw-r--r-- | cui/source/tabpages/align.hrc | 11 | ||||
-rw-r--r-- | cui/source/tabpages/align.src | 3 |
4 files changed, 117 insertions, 6 deletions
diff --git a/cui/source/inc/align.hxx b/cui/source/inc/align.hxx index 9766a1b5130f..605faebbeb88 100644 --- a/cui/source/inc/align.hxx +++ b/cui/source/inc/align.hxx @@ -54,6 +54,7 @@ public: static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet ); static USHORT* GetRanges(); + virtual BOOL FillItemSet( SfxItemSet& rSet ); virtual void Reset( const SfxItemSet& rSet ); virtual int DeactivatePage( SfxItemSet* pSet ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); @@ -64,6 +65,8 @@ private: void InitVsRefEgde(); void UpdateEnableControls(); + bool HasAlignmentChanged( const SfxItemSet& rNew, USHORT nWhich ) const; + DECL_LINK( UpdateEnableHdl, void* ); private: 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(); diff --git a/cui/source/tabpages/align.hrc b/cui/source/tabpages/align.hrc index f67d3f666bae..f58e9ac221bc 100644 --- a/cui/source/tabpages/align.hrc +++ b/cui/source/tabpages/align.hrc @@ -63,11 +63,14 @@ #define ALIGNDLG_HORALIGN_RIGHT 3 #define ALIGNDLG_HORALIGN_BLOCK 4 #define ALIGNDLG_HORALIGN_FILL 5 +#define ALIGNDLG_HORALIGN_DISTRIBUTED 6 -#define ALIGNDLG_VERALIGN_STD 0 -#define ALIGNDLG_VERALIGN_TOP 1 -#define ALIGNDLG_VERALIGN_MID 2 -#define ALIGNDLG_VERALIGN_BOTTOM 3 +#define ALIGNDLG_VERALIGN_STD 0 +#define ALIGNDLG_VERALIGN_TOP 1 +#define ALIGNDLG_VERALIGN_MID 2 +#define ALIGNDLG_VERALIGN_BOTTOM 3 +#define ALIGNDLG_VERALIGN_BLOCK 4 +#define ALIGNDLG_VERALIGN_DISTRIBUTED 5 // image list for ValueSets: #define IL_LOCK_BMPS 1100 diff --git a/cui/source/tabpages/align.src b/cui/source/tabpages/align.src index 807bfdb56132..d7d267991073 100644 --- a/cui/source/tabpages/align.src +++ b/cui/source/tabpages/align.src @@ -70,6 +70,7 @@ TabPage RID_SVXPAGE_ALIGNMENT < "Right" ; ALIGNDLG_HORALIGN_RIGHT ; > ; < "Justified" ; ALIGNDLG_HORALIGN_BLOCK ; > ; < "Filled" ; ALIGNDLG_HORALIGN_FILL ; > ; + < "Distributed" ; ALIGNDLG_HORALIGN_DISTRIBUTED ; > ; }; }; FixedText FT_INDENT @@ -109,6 +110,8 @@ TabPage RID_SVXPAGE_ALIGNMENT < "Top" ; ALIGNDLG_VERALIGN_TOP ; > ; < "Middle" ; ALIGNDLG_VERALIGN_MID ; > ; < "Bottom" ; ALIGNDLG_VERALIGN_BOTTOM ; > ; + < "Justified" ; ALIGNDLG_VERALIGN_BLOCK ; > ; + < "Distributed" ; ALIGNDLG_VERALIGN_DISTRIBUTED ; > ; }; }; FixedLine FL_ORIENTATION |