summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat.ooo@free.fr>2011-10-31 17:39:16 +0100
committerCédric Bosdonnat <cedric.bosdonnat@free.fr>2011-11-02 15:10:24 +0100
commitfd886cdc6a8c047a9fb1bd10a00f901b4adb525e (patch)
treed60515f1141181c9ef0e96de4a0783c2536a0b24 /sw
parentb2e0b5f3f5b9a4c6b8483e6fb9855054c84aab92 (diff)
n#693238: fixed docx import of tabs set after the end margin
Added a new compatibility option to keep the previous behavior, but changed the default to avoid lines insertion for tabs when there are tab stops set beyond the end margin
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/IDocumentSettingAccess.hxx3
-rw-r--r--sw/inc/doc.hxx1
-rw-r--r--sw/source/core/doc/doc.cxx5
-rw-r--r--sw/source/core/doc/docnew.cxx1
-rw-r--r--sw/source/core/text/inftxt.cxx5
-rw-r--r--sw/source/core/text/inftxt.hxx4
-rw-r--r--sw/source/core/text/itrform2.cxx3
-rw-r--r--sw/source/core/text/portab.hxx8
-rw-r--r--sw/source/core/text/txttab.cxx18
-rw-r--r--sw/source/filter/ww8/ww8par.cxx1
-rw-r--r--sw/source/filter/xml/xmlimp.cxx10
-rw-r--r--sw/source/ui/uno/SwXDocumentSettings.cxx16
12 files changed, 63 insertions, 12 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 1dd769912c06..50e80967c5ee 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -79,9 +79,10 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
PROTECT_FORM,
// #i89181#
TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST,
- INVERT_BORDER_SPACING,
+ INVERT_BORDER_SPACING,
COLLAPSE_EMPTY_CELL_PARA,
SMALL_CAPS_PERCENTAGE_66,
+ TAB_OVERFLOW,
// COMPATIBILITY FLAGS END
BROWSE_MODE,
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 3461e6d10b43..656b0b7eb8fe 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -579,6 +579,7 @@ private:
bool mbCollapseEmptyCellPara : 1;
bool mbTabAtLeftIndentForParagraphsInList; // #i89181# - see above
bool mbSmallCapsPercentage66;
+ bool mbTabOverflow;
bool mbLastBrowseMode : 1;
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index aef0e49db0ff..c5128627cf08 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -202,6 +202,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
case INVERT_BORDER_SPACING: return mbInvertBorderSpacing;
case COLLAPSE_EMPTY_CELL_PARA: return mbCollapseEmptyCellPara;
case SMALL_CAPS_PERCENTAGE_66: return mbSmallCapsPercentage66;
+ case TAB_OVERFLOW: return mbTabOverflow;
case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the ViewShell has to be asked!
case HTML_MODE: return mbHTMLMode;
@@ -336,6 +337,10 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
case SMALL_CAPS_PERCENTAGE_66:
mbSmallCapsPercentage66 = value;
break;
+
+ case TAB_OVERFLOW:
+ mbTabOverflow = value;
+ break;
// COMPATIBILITY FLAGS END
case BROWSE_MODE: //can be used temporary (load/save) when no ViewShell is avaiable
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index aa8aa3a85bfd..f8a0ce293d11 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -357,6 +357,7 @@ SwDoc::SwDoc()
mbInvertBorderSpacing = false; // hidden
mbCollapseEmptyCellPara = true; // hidden
mbSmallCapsPercentage66 = false; // hidden
+ mbTabOverflow = true;
//
// COMPATIBILITY FLAGS END
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index a76d74689188..5d84e848b363 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1459,7 +1459,7 @@ void SwTxtFormatInfo::Init()
// Nicht initialisieren: pRest, nLeft, nRight, nFirst, nRealWidth
X(0);
bArrowDone = bFull = bFtnDone = bErgoDone = bNumDone = bNoEndHyph =
- bNoMidHyph = bStop = bNewLine = bUnderFlow = sal_False;
+ bNoMidHyph = bStop = bNewLine = bUnderFlow = bTabOverflow = sal_False;
// generally we do not allow number portions in follows, except...
if ( GetTxtFrm()->IsFollow() )
@@ -1501,7 +1501,8 @@ void SwTxtFormatInfo::Init()
* --------------------------------------------------*/
SwTxtFormatInfo::SwTxtFormatInfo( const SwTxtFormatInfo& rInf,
- SwLineLayout& rLay, SwTwips nActWidth ) : SwTxtPaintInfo( rInf )
+ SwLineLayout& rLay, SwTwips nActWidth ) : SwTxtPaintInfo( rInf ),
+ bTabOverflow( sal_False )
{
pRoot = &rLay;
pLast = &rLay;
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index b549cf42e336..b056612f8284 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -565,6 +565,7 @@ class SwTxtFormatInfo : public SwTxtPaintInfo
sal_Bool bFakeLineStart: 1; // String has been replaced by field portion
// info structure only pretends that we are at
// the beginning of a line
+ sal_Bool bTabOverflow; // Tabs are expanding after the end margin
xub_Unicode cTabDecimal; // das _aktuelle_ Dezimalzeichen
xub_Unicode cHookChar; // fuer Tabs in Feldern etc.
@@ -734,6 +735,9 @@ public:
// friend ostream &operator<<( ostream &rOS, const SwTxtFormatInfo &rInf );
friend SvStream &operator<<( SvStream &rOS, const SwTxtFormatInfo &rInf );
+
+ inline void SetTabOverflow( sal_Bool bOverflow ) { bTabOverflow = bOverflow; }
+ inline sal_Bool IsTabOverflow( ) { return bTabOverflow; }
};
/*************************************************************************
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 965d73e09420..a507526b4188 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -738,6 +738,9 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
// 3260, 3860: Fly auf jeden Fall loeschen!
ClearFly( rInf );
+
+ // Reinit the tab overflow flag after the line
+ rInf.SetTabOverflow( sal_False );
}
/*************************************************************************
diff --git a/sw/source/core/text/portab.hxx b/sw/source/core/text/portab.hxx
index 3cda7b9d1f96..bb5fe9d03968 100644
--- a/sw/source/core/text/portab.hxx
+++ b/sw/source/core/text/portab.hxx
@@ -38,17 +38,19 @@ class SwTabPortion : public SwFixPortion
{
const KSHORT nTabPos;
const xub_Unicode cFill;
+ const bool bAutoTabStop;
// Das Format() verzweigt entweder in Pre- oder PostFormat()
sal_Bool PreFormat( SwTxtFormatInfo &rInf );
public:
- SwTabPortion( const KSHORT nTabPos, const xub_Unicode cFill = '\0' );
+ SwTabPortion( const KSHORT nTabPos, const xub_Unicode cFill = '\0', const bool bAutoTab = true );
virtual void Paint( const SwTxtPaintInfo &rInf ) const;
virtual sal_Bool Format( SwTxtFormatInfo &rInf );
virtual void FormatEOL( SwTxtFormatInfo &rInf );
sal_Bool PostFormat( SwTxtFormatInfo &rInf );
inline sal_Bool IsFilled() const { return 0 != cFill; }
inline KSHORT GetTabPos() const { return nTabPos; }
+ inline sal_Bool IsAutoTabStop() const { return bAutoTabStop; }
// Accessibility: pass information about this portion to the PortionHandler
virtual void HandlePortion( SwPortionHandler& rPH ) const;
@@ -63,8 +65,8 @@ public:
class SwTabLeftPortion : public SwTabPortion
{
public:
- inline SwTabLeftPortion( const KSHORT nTabPosVal, const xub_Unicode cFillChar='\0' )
- : SwTabPortion( nTabPosVal, cFillChar )
+ inline SwTabLeftPortion( const KSHORT nTabPosVal, const xub_Unicode cFillChar='\0', bool bAutoTab = true )
+ : SwTabPortion( nTabPosVal, cFillChar, bAutoTab )
{ SetWhichPor( POR_TABLEFT ); }
OUTPUT_OPERATOR
};
diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index 7ed18741304d..d237873749fc 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -94,6 +94,7 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto )
SvxTabAdjust eAdj;
KSHORT nNewTabPos;
+ bool bAutoTabStop = true;
{
const bool bRTL = pFrm->IsRightToLeft();
// #i24363# tab stops relative to indent
@@ -177,6 +178,7 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto )
//calculate default tab position of default tabs in negative indent
nNextPos = ( nSearchPos / nNextPos ) * nNextPos;
}
+ bAutoTabStop = false;
}
else
{
@@ -312,7 +314,7 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto )
{
OSL_ENSURE( SVX_TAB_ADJUST_LEFT == eAdj || SVX_TAB_ADJUST_DEFAULT == eAdj,
"+SwTxtFormatter::NewTabPortion: unknown adjustment" );
- pTabPor = new SwTabLeftPortion( nNewTabPos, cFill );
+ pTabPor = new SwTabLeftPortion( nNewTabPos, cFill, bAutoTabStop );
break;
}
}
@@ -333,8 +335,8 @@ SwTabPortion *SwTxtFormatter::NewTabPortion( SwTxtFormatInfo &rInf, bool bAuto )
// Die Basisklasse wird erstmal ohne alles initialisiert.
-SwTabPortion::SwTabPortion( const KSHORT nTabPosition, const xub_Unicode cFillChar )
- : SwFixPortion( 0, 0 ), nTabPos(nTabPosition), cFill(cFillChar)
+SwTabPortion::SwTabPortion( const KSHORT nTabPosition, const xub_Unicode cFillChar, const bool bAutoTab )
+ : SwFixPortion( 0, 0 ), nTabPos(nTabPosition), cFill(cFillChar), bAutoTabStop( bAutoTab )
{
nLineLength = 1;
#if OSL_DEBUG_LEVEL > 1
@@ -388,6 +390,7 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf )
Fix( static_cast<sal_uInt16>(rInf.X()) );
const bool bTabCompat = rInf.GetTxtFrm()->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::TAB_COMPAT);
+ const bool bTabOverflow = rInf.GetTxtFrm()->GetTxtNode()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::TAB_OVERFLOW);
// Die Mindestbreite eines Tabs ist immer mindestens ein Blank
// #i37686# In compatibility mode, the minimum width
@@ -419,7 +422,7 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf )
// 1. Minmal width does not fit to line anymore.
// 2. An underflow event was called for the tab portion.
sal_Bool bFull = ( bTabCompat && rInf.IsUnderFlow() ) ||
- rInf.Width() <= rInf.X() + PrtWidth();
+ ( rInf.Width() <= rInf.X() + PrtWidth() && rInf.X() <= rInf.Width() ) ;
// #95477# Rotated tab stops get the width of one blank
const sal_uInt16 nDir = rInf.GetFont()->GetOrientation( rInf.GetTxtFrm()->IsVertical() );
@@ -447,10 +450,15 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf )
// In tabulator compatibility mode, we reset the bFull flag
// if the tabulator is at the end of the paragraph and the
// tab stop position is outside the frame:
+ bool bAtParaEnd = rInf.GetIdx() + GetLen() == rInf.GetTxt().Len();
if ( bFull && bTabCompat &&
- rInf.GetIdx() + GetLen() == rInf.GetTxt().Len() &&
+ ( bTabOverflow && ( rInf.IsTabOverflow() || !IsAutoTabStop() ) || bAtParaEnd ) &&
GetTabPos() >= rInf.GetTxtFrm()->Frm().Width() )
+ {
bFull = sal_False;
+ if ( bTabOverflow && !IsAutoTabStop() )
+ rInf.SetTabOverflow( sal_True );
+ }
break;
}
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 2876172ec21b..0f8f732fe21c 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1579,6 +1579,7 @@ void SwWW8ImplReader::ImportDop()
rDoc.set(IDocumentSettingAccess::INVERT_BORDER_SPACING, true);
rDoc.set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, true);
+ rDoc.set(IDocumentSettingAccess::TAB_OVERFLOW, true);
//
// COMPATIBILITY FLAGS END
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index f47c9df7c9a0..06b95b30a963 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -1191,6 +1191,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
aSet.insert(String("PrinterIndependentLayout", RTL_TEXTENCODING_ASCII_US));
aSet.insert(String("PrintEmptyPages", RTL_TEXTENCODING_ASCII_US));
aSet.insert(String("SmallCapsPercentage66", RTL_TEXTENCODING_ASCII_US));
+ aSet.insert(String("TabOverflow", RTL_TEXTENCODING_ASCII_US));
sal_Int32 nCount = aConfigProps.getLength();
const PropertyValue* pValues = aConfigProps.getConstArray();
@@ -1220,6 +1221,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bool bUnixForceZeroExtLeading = false;
bool bUseOldPrinterMetrics = false;
bool bSmallCapsPercentage66 = false;
+ bool bTabOverflow = false;
OUString sRedlineProtectionKey( RTL_CONSTASCII_USTRINGPARAM( "RedlineProtectionKey" ) );
@@ -1289,6 +1291,8 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
bUseOldPrinterMetrics = true;
else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SmallCapsPercentage66")) )
bSmallCapsPercentage66 = true;
+ else if( pValues->Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TabOverflow")) )
+ bTabOverflow = true;
}
catch( Exception& )
{
@@ -1442,6 +1446,12 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC
OUString( RTL_CONSTASCII_USTRINGPARAM("SmallCapsPercentage66") ), makeAny( true ) );
}
+ if ( !bTabOverflow )
+ {
+ xProps->setPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("TabOverflow") ), makeAny( false ) );
+ }
+
Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
Reference < XText > xText = xTextDoc->getText();
Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx
index b3dbea127dfe..0d42d120c3c6 100644
--- a/sw/source/ui/uno/SwXDocumentSettings.cxx
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
@@ -123,7 +123,8 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_MATH_BASELINE_ALIGNMENT,
HANDLE_INVERT_BORDER_SPACING,
HANDLE_COLLAPSE_EMPTY_CELL_PARA,
- HANDLE_SMALL_CAPS_PERCENTAGE_66
+ HANDLE_SMALL_CAPS_PERCENTAGE_66,
+ HANDLE_TAB_OVERFLOW
};
MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -182,6 +183,7 @@ MasterPropertySetInfo * lcl_createSettingsInfo()
{ RTL_CONSTASCII_STRINGPARAM("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("TabOverflow"), HANDLE_TAB_OVERFLOW, CPPUTYPE_BOOLEAN, 0, 0},
/*
* As OS said, we don't have a view when we need to set this, so I have to
* find another solution before adding them to this property set - MTG
@@ -709,6 +711,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->set(IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66, bTmp);
}
break;
+ case HANDLE_TAB_OVERFLOW:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TAB_OVERFLOW, bTmp);
+ }
+ break;
default:
throw UnknownPropertyException();
}
@@ -1059,6 +1067,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
rValue.setValue( &bTmp, ::getBooleanCppuType() );
}
break;
+ case HANDLE_TAB_OVERFLOW:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVERFLOW );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
default:
throw UnknownPropertyException();
}