summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorFrank Meies <fme@openoffice.org>2002-01-16 08:50:11 +0000
committerFrank Meies <fme@openoffice.org>2002-01-16 08:50:11 +0000
commitca59483ef0b0cbeb73ff4b198fc0cb347b8b9cf7 (patch)
tree89af969c8442d310fce60957715fd8c1d9e43b8e /sw
parentaea343526945e9f837e384c256dfda259e2f9e6d (diff)
Chg: Vertical Formatting - More work on grid mode
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/text/itrform2.cxx108
-rw-r--r--sw/source/core/text/itrtxt.cxx16
-rw-r--r--sw/source/core/text/porfly.cxx39
-rw-r--r--sw/source/core/text/porrst.cxx19
-rw-r--r--sw/source/core/text/porrst.hxx24
-rw-r--r--sw/source/core/text/txtfly.cxx28
-rw-r--r--sw/source/core/text/txtfrm.cxx10
-rw-r--r--sw/source/core/text/txttab.cxx20
8 files changed, 161 insertions, 103 deletions
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index e83b0e0a9585..8febadc89bfa 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: itrform2.cxx,v $
*
- * $Revision: 1.47 $
+ * $Revision: 1.48 $
*
- * last change: $Author: fme $ $Date: 2002-01-11 14:46:11 $
+ * last change: $Author: fme $ $Date: 2002-01-16 09:50:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -137,6 +137,13 @@
#ifndef _REDLNITR_HXX
#include <redlnitr.hxx> // SwRedlineItr
#endif
+
+#ifdef VERTICAL_LAYOUT
+#ifndef _PAGEFRM_HXX
+#include <pagefrm.hxx> // InvalidateSpelling
+#endif
+#endif
+
#ifndef _DOC_HXX
#include <doc.hxx> // SwDoc
#endif
@@ -148,6 +155,11 @@
#ifndef _UNOTOOLS_CHARCLASS_HXX
#include <unotools/charclass.hxx>
#endif
+#ifdef VERTICAL_LAYOUT
+#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
+#include <com/sun/star/i18n/ScriptType.hdl>
+#endif
+#endif
#ifdef DEBUG
#ifndef _NDTXT_HXX
@@ -156,6 +168,10 @@
#endif
using namespace ::com::sun::star::i18n;
+#ifdef VERTICAL_LAYOUT
+using namespace ::com::sun::star::i18n::ScriptType;
+#endif
+
extern sal_Bool IsUnderlineBreak( const SwLinePortion& rPor, const SwFont& rFnt );
#define MAX_TXTPORLEN 300
@@ -479,9 +495,11 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
SwLinePortion *pPor = NewPortion( rInf );
#ifdef VERTICAL_LAYOUT
+ const USHORT nGridWidth = pFrm->GetGridDist( sal_True );
+ // used for grid mode only:
+ // the pointer is stored, because after formatting of non-asian text,
+ // the width of the kerning portion has to be adjusted
SwKernPortion* pGridKernPortion = 0;
- if ( pPor->IsKernPortion() )
- pGridKernPortion = (SwKernPortion*)pPor;
#endif
sal_Bool bFull;
@@ -501,7 +519,6 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
((SwFldPortion*)pPor)->CheckScript( rInf );
#ifdef VERTICAL_LAYOUT
- const USHORT nGridWidth = pFrm->GetGridDist( sal_True );
if( ! nGridWidth && rInf.HasScriptSpace() &&
rInf.GetLast() && rInf.GetLast()->InTxtGrp()
#else
@@ -575,12 +592,36 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
}
}
#ifdef VERTICAL_LAYOUT
- else if ( nGridWidth && SW_CJK != rInf.GetFont()->GetActual() &&
- ! pGridKernPortion )
+ else if ( nGridWidth && ! pGridKernPortion )
{
// insert a grid kerning portion
- pGridKernPortion = new SwKernPortion( *pCurr );
- InsertPortion( rInf, pGridKernPortion );
+ if ( ! pGridKernPortion )
+ pGridKernPortion = pPor->IsKernPortion() ?
+ (SwKernPortion*)pPor :
+ new SwKernPortion( *pCurr );
+
+ // if we have a new GridKernPortion, we initially calculate
+ // its size so that its ends on the grid
+ const SwPageFrm* pPageFrm = pFrm->FindPageFrm();
+ SWRECTFN( pPageFrm )
+ const long nGridOrigin = (pPageFrm->*fnRect->fnGetPrtLeft)();
+
+ const SwTwips nOfst = rInf.X() + GetLeftMargin() - nGridOrigin;
+ if ( nOfst )
+ {
+ USHORT i = 0;
+ while ( nOfst > i * nGridWidth )
+ ++i;
+
+ const SwTwips nKernWidth = i * nGridWidth - nOfst;
+ const SwTwips nRestWidth = rInf.Width() - rInf.X();
+ if ( nKernWidth <= nRestWidth )
+ pGridKernPortion->Width( (USHORT)nKernWidth );
+// pGridKernPortion->Width( (USHORT)(Min( nKernWidth, nRestWidth )) );
+ }
+
+ if ( pGridKernPortion != pPor )
+ InsertPortion( rInf, pGridKernPortion );
}
#endif
@@ -629,7 +670,7 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
#ifdef VERTICAL_LAYOUT
rInf.GetReformatStart() <= rInf.GetIdx() + pPor->GetLen() ) ||
// 5. Grid Mode
- ( nGridWidth && pGridKernPortion )
+ ( nGridWidth )
#else
rInf.GetReformatStart() <= rInf.GetIdx() + pPor->GetLen() )
#endif
@@ -688,18 +729,25 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
}
#ifdef VERTICAL_LAYOUT
- if ( nGridWidth )
+ if ( nGridWidth && pPor != pGridKernPortion )
{
xub_StrLen nTmp = rInf.GetIdx() + pPor->GetLen();
+ const SwTwips nRestWidth = rInf.Width() - rInf.X();
- // if next position behind portion has ASIAN script we want to
- // snap to our grid
- if ( pGridKernPortion && pGridKernPortion != pPor &&
- ( bFull || nTmp == rInf.GetTxt().Len() ||
- 2 == pScriptInfo->ScriptType( nTmp ) ) )
+ const BYTE nCurrScript = pScriptInfo->ScriptType( rInf.GetIdx() );
+ const BYTE nNextScript = nTmp >= rInf.GetTxt().Len() ?
+ (BYTE)i18n::ScriptType::ASIAN :
+ pScriptInfo->ScriptType( nTmp );
+
+ // snap non-asian text to grid if next portion is ASIAN or
+ // there are no more portions in this line
+ if ( nRestWidth > 0 && i18n::ScriptType::ASIAN != nCurrScript &&
+ ( bFull || ASIAN == nNextScript ) )
{
+ ASSERT( pGridKernPortion, "No GridKernPortion available" )
+
// calculate size
- SwLinePortion* pTmpPor = pGridKernPortion;
+ SwLinePortion* pTmpPor = pGridKernPortion->GetPortion();
USHORT nSumWidth = pPor->Width();
while ( pTmpPor )
{
@@ -711,20 +759,26 @@ void SwTxtFormatter::BuildPortions( SwTxtFormatInfo &rInf )
while ( nSumWidth > i * nGridWidth )
++i;
- const USHORT nKernWidth = i * nGridWidth - nSumWidth;
+ const SwTwips nTmpWidth = i * nGridWidth;
+ const SwTwips nKernWidth = Min( (SwTwips)(nTmpWidth - nSumWidth),
+ nRestWidth );
const USHORT nKernWidth_1 = nKernWidth / 2;
- if ( nKernWidth_1 < rInf.Width() - rInf.X() - pPor->Width() )
- {
- pGridKernPortion->Width( nKernWidth_1 );
- rInf.X( rInf.X() + nKernWidth_1 );
+ ASSERT( nKernWidth <= nRestWidth,
+ "Not enough space left for adjusting non-asian text in grid mode" )
- if ( !bFull )
- new SwKernPortion( *pPor, nKernWidth - nKernWidth_1 );
- }
+ pGridKernPortion->Width( pGridKernPortion->Width() + nKernWidth_1 );
+ rInf.X( rInf.X() + nKernWidth_1 );
+
+ new SwKernPortion( *pPor, nKernWidth - nKernWidth_1,
+ sal_False, sal_True );
pGridKernPortion = 0;
}
+ else if ( pPor->InFixMargGrp() || pPor->IsFlyCntPortion() ||
+ nCurrScript != nNextScript || rInf.IsUnderFlow() )
+ // next portion should snap to grid
+ pGridKernPortion = 0;
}
#endif
@@ -1020,7 +1074,7 @@ SwLinePortion *SwTxtFormatter::WhichFirstPortion(SwTxtFormatInfo &rInf)
#ifdef VERTICAL_LAYOUT
if ( ! pPor && GetTxtFrm()->GetGridDist( sal_True ) &&
- ! pCurr->GetPortion() && SW_CJK != rInf.GetFont()->GetActual() )
+ ! pCurr->GetPortion() )
pPor = new SwKernPortion( *pCurr );
#endif
@@ -1074,7 +1128,7 @@ SwLinePortion *SwTxtFormatter::WhichFirstPortion(SwTxtFormatInfo &rInf)
#ifdef VERTICAL_LAYOUT
if ( ! pPor && GetTxtFrm()->GetGridDist( sal_True ) &&
- ! pCurr->GetPortion() && SW_CJK != rInf.GetFont()->GetActual() )
+ ! pCurr->GetPortion() )
pPor = new SwKernPortion( *pCurr );
#endif
}
diff --git a/sw/source/core/text/itrtxt.cxx b/sw/source/core/text/itrtxt.cxx
index 449968f5e853..619f602ce4d7 100644
--- a/sw/source/core/text/itrtxt.cxx
+++ b/sw/source/core/text/itrtxt.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: itrtxt.cxx,v $
*
- * $Revision: 1.12 $
+ * $Revision: 1.13 $
*
- * last change: $Author: fme $ $Date: 2002-01-11 14:47:34 $
+ * last change: $Author: fme $ $Date: 2002-01-16 09:50:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -166,16 +166,18 @@ void SwTxtIter::CalcRealHeight( sal_Bool bNewLine )
USHORT nGridHeight = pFrm->GetGridDist( sal_False );
if ( nGridHeight )
{
- USHORT i = 1;
+ long i = 100;
const SvxLineSpacingItem *pSpace = aLineInf.GetLineSpacing();
if ( pSpace && SVX_INTER_LINE_SPACE_PROP == pSpace->GetInterLineSpaceRule() )
- i = pSpace->GetPropLineSpace() / 100;
+ i = pSpace->GetPropLineSpace();
- while ( nLineHeight > i * nGridHeight )
- ++i;
+ long nTmpLineHeight = 100 * nLineHeight;
- USHORT nTmpHeight = i * nGridHeight;
+ while ( nTmpLineHeight > i * nGridHeight )
+ i += 100;
+
+ USHORT nTmpHeight = i * nGridHeight / 100;
pCurr->SetLineDescent( ( nTmpHeight - pCurr->Height() ) / 2 );
pCurr->SetRealHeight( nTmpHeight );
diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx
index 0efe01d6776f..e10c1520b9f3 100644
--- a/sw/source/core/text/porfly.cxx
+++ b/sw/source/core/text/porfly.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: porfly.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: fme $ $Date: 2002-01-11 14:48:17 $
+ * last change: $Author: fme $ $Date: 2002-01-16 09:50:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -143,26 +143,8 @@ sal_Bool SwFlyPortion::Format( SwTxtFormatInfo &rInf )
nFirstDiff = 0;
PrtWidth( (Fix() - rInf.X()) + PrtWidth() + nFirstDiff );
#else
-
-#ifdef VERTICAL_LAYOUT
- USHORT nTmpWidth = Fix() - rInf.X() + PrtWidth();
- const USHORT nGridWidth = rInf.GetTxtFrm()->GetGridDist( sal_True );
-
- if ( nGridWidth )
- {
- USHORT i = 1;
- while ( nTmpWidth > i * nGridWidth )
- ++i;
-
- nTmpWidth = i * nGridWidth;
- }
-
- PrtWidth( nTmpWidth );
-#else
PrtWidth( (Fix() - rInf.X()) + PrtWidth() );
#endif
-
-#endif
if( !Width() )
{
ASSERT( Width(), "+SwFlyPortion::Format: a fly is a fly is a fly" );
@@ -670,24 +652,7 @@ void SwFlyCntPortion::SetBase( const Point &rBase, long nLnAscent,
if( nFlags & SETBASE_ROTATE )
SvXSize( aBoundRect.SSize() );
else
-#ifdef VERTICAL_LAYOUT
- {
- const USHORT nGridWidth = rFrm.GetGridDist( sal_True );
-
- if ( nGridWidth )
- {
- USHORT i = 1;
- while ( aBoundRect.Width() > i * nGridWidth )
- ++i;
-
- aBoundRect.Width( i * nGridWidth );
- }
-
SvLSize( aBoundRect.SSize() );
- }
-#else
- SvLSize( aBoundRect.SSize() );
-#endif
if( Height() )
{
if ( nRelPos < 0 )
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index e5ecce1a1e67..716216a6c0d6 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: porrst.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: fme $ $Date: 2002-01-11 14:50:16 $
+ * last change: $Author: fme $ $Date: 2002-01-16 09:50:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -265,8 +265,14 @@ sal_Bool SwBreakPortion::Format( SwTxtFormatInfo &rInf )
return sal_True;
}
+#ifdef VERTICAL_LAYOUT
+SwKernPortion::SwKernPortion( SwLinePortion &rPortion, short nKrn,
+ sal_Bool bBG, sal_Bool bGK ) :
+ nKern( nKrn ), bBackground( bBG ), bGridKern( bGK )
+#else
SwKernPortion::SwKernPortion( SwLinePortion &rPortion, short nKrn, sal_Bool bBG ) :
nKern( nKrn ), bBackground( bBG )
+#endif
{
Height( rPortion.Height() );
SetAscent( rPortion.GetAscent() );
@@ -278,13 +284,13 @@ SwKernPortion::SwKernPortion( SwLinePortion &rPortion, short nKrn, sal_Bool bBG
}
#ifdef VERTICAL_LAYOUT
-SwKernPortion::SwKernPortion( const SwLinePortion& rPortion )
+SwKernPortion::SwKernPortion( const SwLinePortion& rPortion ) :
+ nKern( 0 ), bBackground( sal_False ), bGridKern( sal_True )
{
Height( rPortion.Height() );
SetAscent( rPortion.GetAscent() );
nLineLength = 0;
- bBackground = sal_False;
SetWhichPor( POR_KERN );
}
#endif
@@ -319,6 +325,11 @@ static sal_Char __READONLY_DATA sDoubleSpace[] = " ";
void SwKernPortion::FormatEOL( SwTxtFormatInfo &rInf )
{
+#ifdef VERTICAL_LAYOUT
+ if ( bGridKern )
+ return;
+#endif
+
if( rInf.GetLast() == this )
rInf.SetLast( FindPrevPortion( rInf.GetRoot() ) );
if( nKern < 0 )
diff --git a/sw/source/core/text/porrst.hxx b/sw/source/core/text/porrst.hxx
index abd84b928ca6..eb9e1644959b 100644
--- a/sw/source/core/text/porrst.hxx
+++ b/sw/source/core/text/porrst.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: porrst.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: fme $ $Date: 2002-01-11 14:50:52 $
+ * last change: $Author: fme $ $Date: 2002-01-16 09:50:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -111,12 +111,28 @@ class SwKernPortion : public SwLinePortion
{
short nKern;
sal_Bool bBackground;
+
+#ifdef VERTICAL_LAYOUT
+ sal_Bool bGridKern;
+#endif
+
public:
- SwKernPortion( SwLinePortion &rPortion, short nKrn,
- sal_Bool bBG = sal_False );
#ifdef VERTICAL_LAYOUT
+ // This constructor automatically appends the portion to rPortion
+ // bBG indicates, that the background of the kerning portion has to
+ // be painted, e.g., if the portion if positioned between to fields.
+ // bGridKern indicates, that the kerning portion is used to provide
+ // additional space in grid mode.
+ SwKernPortion( SwLinePortion &rPortion, short nKrn,
+ sal_Bool bBG = sal_False, sal_Bool bGridKern = sal_False );
+
+ // This constructor only sets the height and ascent to the values
+ // of rPortion. It is only used for kerning portions for grid mode
SwKernPortion( const SwLinePortion &rPortion );
+#else
+ SwKernPortion( SwLinePortion &rPortion, short nKrn,
+ sal_Bool bBG = sal_False );
#endif
virtual void FormatEOL( SwTxtFormatInfo &rInf );
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 9b530d7e1422..a7ec478f9e25 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: txtfly.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: fme $ $Date: 2002-01-11 14:52:17 $
+ * last change: $Author: fme $ $Date: 2002-01-16 09:50:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -728,6 +728,30 @@ void SwTxtFormatter::CalcFlyWidth( SwTxtFormatInfo &rInf )
if( pFly->Fix() < rInf.Width() )
rInf.Width( pFly->Fix() );
+
+#ifdef VERTICAL_LAYOUT
+ const USHORT nGridWidth = pFrm->GetGridDist( sal_True );
+
+ if ( nGridWidth )
+ {
+ SwPageFrm* pPageFrm = pFrm->FindPageFrm();
+ SWRECTFN( pPageFrm )
+ const long nGridOrigin = (pPageFrm->*fnRect->fnGetPrtLeft)();
+
+ const SwTwips nOfst = GetLeftMargin() - nGridOrigin;
+ const SwTwips nTmpWidth = rInf.Width() + nOfst;
+
+ USHORT i = 0;
+ while ( nTmpWidth >= i * nGridWidth )
+ ++i;
+
+ const long nNewWidth = ( i - 1 ) * nGridWidth - nOfst;
+ if ( nNewWidth > 0 )
+ rInf.Width( (USHORT)nNewWidth );
+ else
+ rInf.Width( 0 );
+ }
+#endif
}
}
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 9282d187509b..4ba8cc176753 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: txtfrm.cxx,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: fme $ $Date: 2002-01-11 14:55:21 $
+ * last change: $Author: fme $ $Date: 2002-01-16 09:50:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -334,7 +334,7 @@ long SwTxtFrm::SwitchVerticalToHorizontal( long nLimit ) const
return aTmp.Y();
}
-USHORT SwTxtFrm::GetGridDist( sal_Bool bRow ) const
+USHORT SwTxtFrm::GetGridDist( sal_Bool bInRow ) const
{
#ifndef GRID_MODE
return 0;
@@ -344,7 +344,9 @@ USHORT SwTxtFrm::GetGridDist( sal_Bool bRow ) const
SwPageDesc* pDesc = ((SwPageFrm*)pPageFrm)->FindPageDesc();
if( pDesc )
- return bRow ? pDesc->GetRegHeight() : pDesc->GetRegHeight();
+ return ( ( bInRow && ! IsVertical() ) || ( ! bInRow && IsVertical() ) ) ?
+ pDesc->GetRegHeight() :
+ pDesc->GetRegHeight();
return 0;
}
diff --git a/sw/source/core/text/txttab.cxx b/sw/source/core/text/txttab.cxx
index 3081a00d3140..34e22a5a6994 100644
--- a/sw/source/core/text/txttab.cxx
+++ b/sw/source/core/text/txttab.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: txttab.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: fme $ $Date: 2002-01-11 14:56:04 $
+ * last change: $Author: fme $ $Date: 2002-01-16 09:50:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -338,23 +338,7 @@ sal_Bool SwTabPortion::PreFormat( SwTxtFormatInfo &rInf )
}
case POR_TABLEFT:
{
-#ifdef VERTICAL_LAYOUT
- USHORT nTmpWidth = (USHORT)(GetTabPos() - rInf.X());
- const USHORT nGridWidth = rInf.GetTxtFrm()->GetGridDist( sal_True );
-
- if ( nGridWidth )
- {
- USHORT i = 0;
- while ( nTmpWidth > i * nGridWidth )
- ++i;
-
- nTmpWidth = i * nGridWidth;
- }
-
- PrtWidth( nTmpWidth );
-#else
PrtWidth( GetTabPos() - rInf.X() );
-#endif
bFull = rInf.Width() <= rInf.X() + PrtWidth();
break;
}