[Libreoffice-commits] .: Branch 'libreoffice-3-6' - 2 commits - svtools/source sw/qa sw/source
Michael Stahl
mst at kemper.freedesktop.org
Fri Jul 6 07:47:46 PDT 2012
svtools/source/control/ctrlbox.cxx | 9 +++-
sw/qa/complex/writer/CheckCrossReferences.java | 50 ++++++++++---------------
sw/source/core/doc/number.cxx | 35 ++++++++++++++---
3 files changed, 54 insertions(+), 40 deletions(-)
New commits:
commit cae7775794f87a3b179451cedc584958c6215432
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jul 6 16:11:25 2012 +0200
BorderWidthImpl: let's try if this is a better way to convert to int
Change-Id: Ib374998199afff347786764716646e73dd12de2a
(cherry picked from commit 3c6bc3cb6a673c552e2839e421656341151bf12e)
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index a1d8906..5665858 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -325,7 +325,8 @@ long BorderWidthImpl::GetLine1( long nWidth ) const
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));
+ static_cast<long>((m_nRate1 * nWidth) + 0.5)
+ - (nConstant2 + nConstantD));
}
return result;
}
@@ -338,7 +339,8 @@ long BorderWidthImpl::GetLine2( long nWidth ) const
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));
+ static_cast<long>((m_nRate2 * nWidth) + 0.5)
+ - (nConstant1 + nConstantD));
}
return result;
}
@@ -351,7 +353,8 @@ long BorderWidthImpl::GetGap( long nWidth ) const
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));
+ static_cast<long>((m_nRateGap * nWidth) + 0.5)
+ - (nConstant1 + nConstant2));
}
// Avoid having too small distances (less than 0.1pt)
commit a8651a4bf3031bdf16a84ddf774eaf699a617426
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jul 6 15:57:32 2012 +0200
fdo#33960: fix cross reference number test failure
(cherry picked from commit 190ca072fc1c8679c586867582c816d98016f343)
Conflicts:
sw/source/core/doc/number.cxx
Change-Id: If50a09a14ad30fa3dcb587d6e59a5a0d161394b1
diff --git a/sw/qa/complex/writer/CheckCrossReferences.java b/sw/qa/complex/writer/CheckCrossReferences.java
index 0f74a11..4f436ce 100644
--- a/sw/qa/complex/writer/CheckCrossReferences.java
+++ b/sw/qa/complex/writer/CheckCrossReferences.java
@@ -145,9 +145,9 @@ public class CheckCrossReferences {
final String FldResult1 = "*i*";
final String FldResult2 = "+b+*i*";
final String FldResult3 = "-1-+b+*i*";
- final String FldResult4 = "1.";
- final String FldResult5 = " 1.";
- final String FldResult6 = "A. 1.";
+ final String FldResult4 = "1";
+ final String FldResult5 = "1";
+ final String FldResult6 = "A.1";
// variables for current field
com.sun.star.text.XTextField xField = null;
@@ -171,33 +171,23 @@ public class CheckCrossReferences {
checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult1 );
checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult3 );
- // The following tests currently fail due to a regression introduced
- // with the fix for
- // <https://bugs.freedesktop.org/show_bug.cgi?id=33960> "cross
- // reference to a list number, dot bug," see thread starting at
- // <http://lists.freedesktop.org/archives/libreoffice/
- // 2011-September/017797.html> "[Libreoffice] fix for fdo#33960
- // 'cross reference to a list number, dot bug' makes
- // sw/qa/complex/writer fail":
- if (false) {
- xField = getNextField();
- xProps = getFieldProps( xField );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult5 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
-
- xField = getNextField();
- xProps = getFieldProps( xField );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult4 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
-
- xField = getNextField();
- xProps = getFieldProps( xField );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult6 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
- checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
- }
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult5 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
+
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult4 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
+
+ xField = getNextField();
+ xProps = getFieldProps( xField );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult6 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
+ checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
}
// insert a certain cross-reference bookmark and a reference field to this bookmark
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 41fc670..c6e26fe 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -752,6 +752,8 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
if ( rNodeNum.GetLevelInListTree() >= 0 )
{
sal_Bool bOldHadPrefix = sal_True;
+ bool bFirstIteration = true;
+ ::rtl::OUString sOldPrefix;
const SwNodeNum* pWorkingNodeNum( &rNodeNum );
do
@@ -787,26 +789,44 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
if (nStrip)
{
- aPrevStr.Erase( 0, nStrip );
- aExtremities.nPrefixChars -= nStrip;
- nLen -= nStrip;
+ aPrevStr.Erase( 0, nStrip );
+ aExtremities.nPrefixChars -= nStrip;
+ nLen -= nStrip;
}
- if ( bOldHadPrefix &&
+ if ((bFirstIteration || bOldHadPrefix) &&
aExtremities.nSuffixChars &&
!aExtremities.nPrefixChars
)
{
- aPrevStr.Erase( nLen - aExtremities.nSuffixChars, aExtremities.nSuffixChars );
+ int nStrip2 = aPrevStr.Len();
+ while (aPrevStr.Len() - nStrip2 < aExtremities.nSuffixChars)
+ {
+ char const cur = aPrevStr.GetChar(nStrip2);
+ if (!bFirstIteration && '\t' != cur && ' ' != cur)
+ {
+ break;
+ }
+ --nStrip2;
+ }
+ if (nStrip2 < aPrevStr.Len())
+ {
+ aPrevStr.Erase(nStrip2, aPrevStr.Len() - nStrip2);
+ }
+ }
+ else if (sOldPrefix.getLength())
+ {
+ aRefNumStr.Insert(sOldPrefix, 0);
}
+ sOldPrefix = ::rtl::OUString();
+
bOldHadPrefix = ( aExtremities.nPrefixChars > 0);
aRefNumStr.Insert( aPrevStr, 0 );
-
}
else if ( aRefNumStr.Len() > 0 )
{
- aRefNumStr.Insert( String::CreateFromAscii(" "), 0 );
+ sOldPrefix += " ";
bOldHadPrefix = true;
}
@@ -825,6 +845,7 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
{
break;
}
+ bFirstIteration = false;
} while ( pWorkingNodeNum &&
pWorkingNodeNum->GetLevelInListTree() >= 0 &&
static_cast<sal_uInt8>(pWorkingNodeNum->GetLevelInListTree()) >= nRestrictInclToThisLevel );
More information about the Libreoffice-commits
mailing list