summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-07-04 17:47:22 +0200
committerMichael Stahl <mstahl@redhat.com>2012-07-04 18:06:10 +0200
commite4fc7e777fbfa600dcfe8914da81e89329279e7b (patch)
tree3c17633491fbf236692fb9cd3ec05d05673d42a2 /svtools
parent549cf1ab08fc5ee78730c139781ad53805e4717d (diff)
refactor handling of double border widths:
Word uses a completely different definition of "width" of a double border than OOo and ODF: for Word the width is apparently the largest of the 3 component widths, while OOo and ODF define the width as the total with of all 3 components. The new border implementation in LO 3.4 was apparently inspired by Word's double border definition, which resulted in various import filter regressions, see the previous fixes: 36e43b52992735c622833e923faa63774b9e2f76 e2ffb71305c5f085eec6d396651c76d6daee3406 70a6a4d425558340bb49507975343a3e0a1bdde8 These fixes set the ScaleMetrics, which actually seems sub-optimal as there is a ScaleItemSet function somewhere that apparently re-scales all items in an itemset, which could undo the fixes. Also, one of the fixes actually managed to break RTF/DOCX import of double borders, as that ended up in the same code via the API. This commit now reverses the change, so that the width of a border is now always the total with of all components, which is (imho) much more intutitive, and also leads to a consistent UI where selecting say 3pt width has predictable results, no matter what the border style. The border widths are now converted in the Word format import/export filters (writerfilter and sw/source/filter/ww8), and various tests were adapted to the new handling. (cherry picked from commit 2d045cdb69176b280812dda0b813371cf1ac72e2) Conflicts: sw/qa/extras/ooxmltok/ooxmltok.cxx Change-Id: I50456c49b1a298569607e6c88f19f18441348ac3
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/ctrlbox.cxx31
1 files changed, 25 insertions, 6 deletions
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 15eae11b366e..a1d8906c0919 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -321,7 +321,12 @@ long BorderWidthImpl::GetLine1( long nWidth ) const
{
long result = static_cast<long>(m_nRate1);
if ( ( m_nFlags & CHANGE_LINE1 ) > 0 )
- result = static_cast<long>(m_nRate1 * nWidth);
+ {
+ long const nConstant2 = (m_nFlags & CHANGE_LINE2) ? 0 : m_nRate2;
+ long const nConstantD = (m_nFlags & CHANGE_DIST ) ? 0 : m_nRateGap;
+ result = std::max<long>(0,
+ static_cast<long>(m_nRate1 * nWidth) - (nConstant2 + nConstantD));
+ }
return result;
}
@@ -329,7 +334,12 @@ long BorderWidthImpl::GetLine2( long nWidth ) const
{
long result = static_cast<long>(m_nRate2);
if ( ( m_nFlags & CHANGE_LINE2 ) > 0 )
- result = static_cast<long>(m_nRate2 * nWidth);
+ {
+ long const nConstant1 = (m_nFlags & CHANGE_LINE1) ? 0 : m_nRate1;
+ long const nConstantD = (m_nFlags & CHANGE_DIST ) ? 0 : m_nRateGap;
+ result = std::max<long>(0,
+ static_cast<long>(m_nRate2 * nWidth) - (nConstant1 + nConstantD));
+ }
return result;
}
@@ -337,7 +347,12 @@ long BorderWidthImpl::GetGap( long nWidth ) const
{
long result = static_cast<long>(m_nRateGap);
if ( ( m_nFlags & CHANGE_DIST ) > 0 )
- result = static_cast<long>(m_nRateGap * nWidth);
+ {
+ long const nConstant1 = (m_nFlags & CHANGE_LINE1) ? 0 : m_nRate1;
+ long const nConstant2 = (m_nFlags & CHANGE_LINE2) ? 0 : m_nRate2;
+ result = std::max<long>(0,
+ static_cast<long>(m_nRateGap * nWidth) - (nConstant1 + nConstant2));
+ }
// Avoid having too small distances (less than 0.1pt)
if ( result < MINGAPWIDTH && m_nRate1 > 0 && m_nRate2 > 0 )
@@ -386,6 +401,11 @@ long BorderWidthImpl::GuessWidth( long nLine1, long nLine2, long nGap )
else if ( !bGapChange && nWidthGap < 0 )
bInvalid = true;
+ // non-constant line width factors must sum to 1
+ assert((((bLine1Change) ? m_nRate1 : 0) +
+ ((bLine2Change) ? m_nRate2 : 0) +
+ ((bGapChange) ? m_nRateGap : 0)) - 1.0 < 0.00001 );
+
double nWidth = 0.0;
if ( (!bInvalid) && (!aToCompare.empty()) )
{
@@ -396,11 +416,10 @@ long BorderWidthImpl::GuessWidth( long nLine1, long nLine2, long nGap )
bInvalid = ( nWidth != *pIt );
pIt++;
}
- if ( bInvalid )
- nWidth = 0.0;
+ nWidth = (bInvalid) ? 0.0 : nLine1 + nLine2 + nGap;
}
- return long( nWidth );
+ return nWidth;
}
/** Utility class storing the border line width, style and colors. The widths