diff options
author | Susobhan Ghosh <susobhang70@gmail.com> | 2016-06-25 20:27:32 +0530 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2016-06-28 07:43:43 +0000 |
commit | be40d4e7102d79d1e3aac5771869585cd1545379 (patch) | |
tree | 4154eed3bcf9a6a3acf173110e8a05defec70886 | |
parent | 0f9666134e58d5b03189636335b3a1f407b968b5 (diff) |
tdf#83830: Add None as Margin Preset in Format Panel
Change-Id: I2ca37fc34bd71d18029f7e43f918143c14d9c85b
Reviewed-on: https://gerrit.libreoffice.org/26657
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r-- | sw/source/uibase/sidebar/PageFormatPanel.cxx | 34 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageMarginUtils.hxx | 21 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/pageformatpanel.ui | 1 |
3 files changed, 43 insertions, 13 deletions
diff --git a/sw/source/uibase/sidebar/PageFormatPanel.cxx b/sw/source/uibase/sidebar/PageFormatPanel.cxx index 5bf359dc69e1..c61e304b05b5 100644 --- a/sw/source/uibase/sidebar/PageFormatPanel.cxx +++ b/sw/source/uibase/sidebar/PageFormatPanel.cxx @@ -244,24 +244,27 @@ IMPL_LINK_NOARG_TYPED(PageFormatPanel, PaperModifyMarginHdl, ListBox&, void) switch ( mpMarginSelectBox->GetSelectEntryPos() ) { case 0: - SetNarrow(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); + SetNone(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); break; case 1: - SetModerate(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); + SetNarrow(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); break; case 2: - SetNormal075(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); + SetModerate(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); break; case 3: - SetNormal100(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); + SetNormal075(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); break; case 4: - SetNormal125(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); + SetNormal100(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); break; case 5: - SetWide(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); + SetNormal125(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); break; case 6: + SetWide(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); + break; + case 7: SetMirrored(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored); break; default: @@ -335,41 +338,46 @@ void PageFormatPanel::UpdateMarginBox() mnPageBottomMargin = mpPageULMarginItem->GetLower(); bool bMirrored = (mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR); - if( IsNarrow(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) + if( IsNone(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) { mpMarginSelectBox->SelectEntryPos(0); mpMarginSelectBox->RemoveEntry(aCustomEntry); } - else if( IsModerate(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) + else if( IsNarrow(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) { mpMarginSelectBox->SelectEntryPos(1); mpMarginSelectBox->RemoveEntry(aCustomEntry); } - else if( IsNormal075(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) + else if( IsModerate(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) { mpMarginSelectBox->SelectEntryPos(2); mpMarginSelectBox->RemoveEntry(aCustomEntry); } - else if( IsNormal100(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) + else if( IsNormal075(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) { mpMarginSelectBox->SelectEntryPos(3); mpMarginSelectBox->RemoveEntry(aCustomEntry); } - else if( IsNormal125(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) + else if( IsNormal100(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) { mpMarginSelectBox->SelectEntryPos(4); mpMarginSelectBox->RemoveEntry(aCustomEntry); } - else if( IsWide(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) + else if( IsNormal125(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) { mpMarginSelectBox->SelectEntryPos(5); mpMarginSelectBox->RemoveEntry(aCustomEntry); } - else if( IsMirrored(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) + else if( IsWide(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) { mpMarginSelectBox->SelectEntryPos(6); mpMarginSelectBox->RemoveEntry(aCustomEntry); } + else if( IsMirrored(mnPageLeftMargin, mnPageRightMargin, mnPageTopMargin, mnPageBottomMargin, bMirrored) ) + { + mpMarginSelectBox->SelectEntryPos(7); + mpMarginSelectBox->RemoveEntry(aCustomEntry); + } else { if(mpMarginSelectBox->GetEntryPos(aCustomEntry) == LISTBOX_ENTRY_NOTFOUND) diff --git a/sw/source/uibase/sidebar/PageMarginUtils.hxx b/sw/source/uibase/sidebar/PageMarginUtils.hxx index da8b73cadbed..7e29cef6d6b4 100644 --- a/sw/source/uibase/sidebar/PageMarginUtils.hxx +++ b/sw/source/uibase/sidebar/PageMarginUtils.hxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include <cmath> +#define SWPAGE_NO_MARGIN 0 #define SWPAGE_NARROW_VALUE 720 #define SWPAGE_MODERATE_LR 1080 #define SWPAGE_NORMAL_VALUE 1136 @@ -27,6 +28,26 @@ namespace sw { namespace sidebar{ +bool IsNone( const long nPageLeftMargin, const long nPageRightMargin, + const long nPageTopMargin, const long nPageBottomMargin, bool bMirrored) +{ + return( std::abs(nPageLeftMargin - SWPAGE_NO_MARGIN) <= SWPAGE_UNIT_THRESHOLD && + std::abs(nPageRightMargin - SWPAGE_NO_MARGIN ) <= SWPAGE_UNIT_THRESHOLD && + std::abs(nPageTopMargin - SWPAGE_NO_MARGIN) <= SWPAGE_UNIT_THRESHOLD && + std::abs(nPageBottomMargin - SWPAGE_NO_MARGIN) <= SWPAGE_UNIT_THRESHOLD && + !bMirrored ); +} + +void SetNone( long& nPageLeftMargin, long& nPageRightMargin, + long& nPageTopMargin, long& nPageBottomMargin, bool& bMirrored) +{ + nPageLeftMargin = SWPAGE_NO_MARGIN; + nPageRightMargin = SWPAGE_NO_MARGIN; + nPageTopMargin = SWPAGE_NO_MARGIN; + nPageBottomMargin = SWPAGE_NO_MARGIN; + bMirrored = false; +} + bool IsNarrow( const long nPageLeftMargin, const long nPageRightMargin, const long nPageTopMargin, const long nPageBottomMargin, bool bMirrored) { diff --git a/sw/uiconfig/swriter/ui/pageformatpanel.ui b/sw/uiconfig/swriter/ui/pageformatpanel.ui index 46fc942d14c8..b1cff199f910 100644 --- a/sw/uiconfig/swriter/ui/pageformatpanel.ui +++ b/sw/uiconfig/swriter/ui/pageformatpanel.ui @@ -154,6 +154,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <items> + <item translatable="yes">None</item> <item translatable="yes">Narrow</item> <item translatable="yes">Moderate</item> <item translatable="yes">Normal 0.75"</item> |