This is an automated email from the ASF dual-hosted git repository. mseidel pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/trunk by this push: new 3436fcd2f4 Fixed typos (numering -> numbering), removed whitespace 3436fcd2f4 is described below commit 3436fcd2f4b4461b228de82395123a71e5e8bc13 Author: mseidel <msei...@apache.org> AuthorDate: Wed Jun 14 16:57:32 2023 +0200 Fixed typos (numering -> numbering), removed whitespace --- main/sw/source/core/text/txtdrop.cxx | 1247 +++++++++++++++++----------------- main/sw/source/core/text/txtfld.cxx | 643 +++++++++--------- 2 files changed, 943 insertions(+), 947 deletions(-) diff --git a/main/sw/source/core/text/txtdrop.cxx b/main/sw/source/core/text/txtdrop.cxx index 2d71fff70e..327f4bfb42 100644 --- a/main/sw/source/core/text/txtdrop.cxx +++ b/main/sw/source/core/text/txtdrop.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -30,13 +30,13 @@ #include <vcl/window.hxx> #include <vcl/svapp.hxx> #include <paratr.hxx> -#include <txtfrm.hxx> // Format() +#include <txtfrm.hxx> // Format() #include <charfmt.hxx> -#include <viewopt.hxx> // SwViewOption +#include <viewopt.hxx> // SwViewOption #include <viewsh.hxx> // ViewShell #include <pordrop.hxx> #include <itrform2.hxx> -#include <txtpaint.hxx> // SwSaveClip +#include <txtpaint.hxx> // SwSaveClip #include <blink.hxx> // pBlink #include <breakit.hxx> #include <com/sun/star/i18n/ScriptType.hdl> @@ -50,299 +50,299 @@ using namespace ::com::sun::star::i18n; using namespace ::com::sun::star; /************************************************************************* - * lcl_IsDropFlyInter + * lcl_IsDropFlyInter * - * Calculates if a drop caps portion intersects with a fly - * The width and height of the drop caps portion are passed as arguments, - * the position is calculated from the values in rInf + * Calculates if a drop caps portion intersects with a fly + * The width and height of the drop caps portion are passed as arguments, + * the position is calculated from the values in rInf *************************************************************************/ sal_Bool lcl_IsDropFlyInter( const SwTxtFormatInfo &rInf, - sal_uInt16 nWidth, sal_uInt16 nHeight ) + sal_uInt16 nWidth, sal_uInt16 nHeight ) { - const SwTxtFly *pTxtFly = rInf.GetTxtFly(); - if( pTxtFly && pTxtFly->IsOn() ) - { - SwRect aRect( rInf.GetTxtFrm()->Frm().Pos(), Size( nWidth, nHeight) ); - aRect.Pos() += rInf.GetTxtFrm()->Prt().Pos(); - aRect.Pos().X() += rInf.X(); - aRect.Pos().Y() = rInf.Y(); - aRect = pTxtFly->GetFrm( aRect ); - return aRect.HasArea(); - } - - return sal_False; + const SwTxtFly *pTxtFly = rInf.GetTxtFly(); + if( pTxtFly && pTxtFly->IsOn() ) + { + SwRect aRect( rInf.GetTxtFrm()->Frm().Pos(), Size( nWidth, nHeight) ); + aRect.Pos() += rInf.GetTxtFrm()->Prt().Pos(); + aRect.Pos().X() += rInf.X(); + aRect.Pos().Y() = rInf.Y(); + aRect = pTxtFly->GetFrm( aRect ); + return aRect.HasArea(); + } + + return sal_False; } /************************************************************************* - * class SwDropSave + * class SwDropSave *************************************************************************/ class SwDropSave { - SwTxtPaintInfo* pInf; - xub_StrLen nIdx; - xub_StrLen nLen; - long nX; - long nY; + SwTxtPaintInfo* pInf; + xub_StrLen nIdx; + xub_StrLen nLen; + long nX; + long nY; public: - SwDropSave( const SwTxtPaintInfo &rInf ); - ~SwDropSave(); + SwDropSave( const SwTxtPaintInfo &rInf ); + ~SwDropSave(); }; SwDropSave::SwDropSave( const SwTxtPaintInfo &rInf ) : - pInf( ((SwTxtPaintInfo*)&rInf) ), nIdx( rInf.GetIdx() ), - nLen( rInf.GetLen() ), nX( rInf.X() ), nY( rInf.Y() ) + pInf( ((SwTxtPaintInfo*)&rInf) ), nIdx( rInf.GetIdx() ), + nLen( rInf.GetLen() ), nX( rInf.X() ), nY( rInf.Y() ) { } SwDropSave::~SwDropSave() { - pInf->SetIdx( nIdx ); - pInf->SetLen( nLen ); - pInf->X( nX ); - pInf->Y( nY ); + pInf->SetIdx( nIdx ); + pInf->SetLen( nLen ); + pInf->X( nX ); + pInf->Y( nY ); } /************************************************************************* - * SwDropPortionPart DTor + * SwDropPortionPart DTor *************************************************************************/ SwDropPortionPart::~SwDropPortionPart() { - if ( pFollow ) - delete pFollow; - delete pFnt; + if ( pFollow ) + delete pFollow; + delete pFnt; } /************************************************************************* - * SwDropPortion CTor, DTor + * SwDropPortion CTor, DTor *************************************************************************/ SwDropPortion::SwDropPortion( const MSHORT nLineCnt, - const KSHORT nDrpHeight, - const KSHORT nDrpDescent, - const KSHORT nDist ) + const KSHORT nDrpHeight, + const KSHORT nDrpDescent, + const KSHORT nDist ) : pPart( 0 ), - nLines( nLineCnt ), - nDropHeight(nDrpHeight), - nDropDescent(nDrpDescent), - nDistance(nDist), - nFix(0), - nX(0) + nLines( nLineCnt ), + nDropHeight(nDrpHeight), + nDropDescent(nDrpDescent), + nDistance(nDist), + nFix(0), + nX(0) { - SetWhichPor( POR_DROP ); + SetWhichPor( POR_DROP ); } SwDropPortion::~SwDropPortion() { - delete pPart; + delete pPart; if( pBlink ) pBlink->Delete( this ); } sal_Bool SwTxtSizeInfo::_HasHint( const SwTxtNode* pTxtNode, xub_StrLen nPos ) { - return 0 != pTxtNode->GetTxtAttrForCharAt(nPos); + return 0 != pTxtNode->GetTxtAttrForCharAt(nPos); } /************************************************************************* - * SwTxtNode::GetDropLen() + * SwTxtNode::GetDropLen() * * nWishLen = 0 indicates that we want a whole word *************************************************************************/ MSHORT SwTxtNode::GetDropLen( MSHORT nWishLen ) const { - xub_StrLen nEnd = GetTxt().Len(); - if( nWishLen && nWishLen < nEnd ) - nEnd = nWishLen; - - if ( ! nWishLen && pBreakIt->GetBreakIter().is() ) - { - // find first word - const SwAttrSet& rAttrSet = GetSwAttrSet(); - const sal_uInt16 nTxtScript = pBreakIt->GetRealScriptOfText( GetTxt(), 0 ); - - LanguageType eLanguage; - - switch ( nTxtScript ) - { - case i18n::ScriptType::ASIAN : - eLanguage = rAttrSet.GetCJKLanguage().GetLanguage(); - break; - case i18n::ScriptType::COMPLEX : - eLanguage = rAttrSet.GetCTLLanguage().GetLanguage(); - break; - default : - eLanguage = rAttrSet.GetLanguage().GetLanguage(); - break; - } - - Boundary aBound = - pBreakIt->GetBreakIter()->getWordBoundary( GetTxt(), 0, - pBreakIt->GetLocale( eLanguage ), WordType::DICTIONARY_WORD, sal_True ); - - nEnd = (xub_StrLen)aBound.endPos; - } - - xub_StrLen i = 0; - for( ; i < nEnd; ++i ) - { - xub_Unicode cChar = GetTxt().GetChar( i ); - if( CH_TAB == cChar || CH_BREAK == cChar || - (( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar ) - && SwTxtSizeInfo::_HasHint( this, i ) ) ) - break; - } - return i; + xub_StrLen nEnd = GetTxt().Len(); + if( nWishLen && nWishLen < nEnd ) + nEnd = nWishLen; + + if ( ! nWishLen && pBreakIt->GetBreakIter().is() ) + { + // find first word + const SwAttrSet& rAttrSet = GetSwAttrSet(); + const sal_uInt16 nTxtScript = pBreakIt->GetRealScriptOfText( GetTxt(), 0 ); + + LanguageType eLanguage; + + switch ( nTxtScript ) + { + case i18n::ScriptType::ASIAN : + eLanguage = rAttrSet.GetCJKLanguage().GetLanguage(); + break; + case i18n::ScriptType::COMPLEX : + eLanguage = rAttrSet.GetCTLLanguage().GetLanguage(); + break; + default : + eLanguage = rAttrSet.GetLanguage().GetLanguage(); + break; + } + + Boundary aBound = + pBreakIt->GetBreakIter()->getWordBoundary( GetTxt(), 0, + pBreakIt->GetLocale( eLanguage ), WordType::DICTIONARY_WORD, sal_True ); + + nEnd = (xub_StrLen)aBound.endPos; + } + + xub_StrLen i = 0; + for( ; i < nEnd; ++i ) + { + xub_Unicode cChar = GetTxt().GetChar( i ); + if( CH_TAB == cChar || CH_BREAK == cChar || + (( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar ) + && SwTxtSizeInfo::_HasHint( this, i ) ) ) + break; + } + return i; } /************************************************************************* - * SwTxtNode::GetDropSize() + * SwTxtNode::GetDropSize() * - * If a dropcap is found the return value is true otherwise false. The - * drop cap sizes passed back by reference are font height, drop height - * and drop descent. + * If a dropcap is found the return value is true otherwise false. The + * drop cap sizes passed back by reference are font height, drop height + * and drop descent. *************************************************************************/ bool SwTxtNode::GetDropSize(int& rFontHeight, int& rDropHeight, int& rDropDescent) const { - rFontHeight = 0; - rDropHeight = 0; - rDropDescent =0; - - const SwAttrSet& rSet = GetSwAttrSet(); - const SwFmtDrop& rDrop = rSet.GetDrop(); - - // Return (0,0) if there is no drop cap at this paragraph - if( 1 >= rDrop.GetLines() || - ( !rDrop.GetChars() && !rDrop.GetWholeWord() ) ) - { - return false; - } - - // get text frame - SwIterator<SwTxtFrm,SwTxtNode> aIter( *this ); - for( SwTxtFrm* pLastFrm = aIter.First(); pLastFrm; pLastFrm = aIter.Next() ) - { - // Only (master-) text frames can have a drop cap. - if ( !pLastFrm->IsFollow() ) - { - - if( !pLastFrm->HasPara() ) - pLastFrm->GetFormatted(); - - if ( !pLastFrm->IsEmpty() ) - { - const SwParaPortion* pPara = pLastFrm->GetPara(); - ASSERT( pPara, "GetDropSize could not find the ParaPortion, I'll guess the drop cap size" ) - - if ( pPara ) - { - const SwLinePortion* pFirstPor = pPara->GetFirstPortion(); - if (pFirstPor && pFirstPor->IsDropPortion()) - { - const SwDropPortion* pDrop = (const SwDropPortion*)pFirstPor; - rDropHeight = pDrop->GetDropHeight(); - rDropDescent = pDrop->GetDropDescent(); - if (const SwFont *pFont = pDrop->GetFnt()) - rFontHeight = pFont->GetSize(pFont->GetActual()).Height(); - else - { - const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get(RES_CHRATR_FONTSIZE); - rFontHeight = rItem.GetHeight(); - } - } - } - } - break; - } - } - - if (rFontHeight==0 && rDropHeight==0 && rDropDescent==0) - { - const sal_uInt16 nLines = rDrop.GetLines(); - - const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( RES_CHRATR_FONTSIZE ); - rFontHeight = rItem.GetHeight(); - rDropHeight = nLines * rFontHeight; - rDropDescent = rFontHeight / 5; - return false; - } - - return true; + rFontHeight = 0; + rDropHeight = 0; + rDropDescent =0; + + const SwAttrSet& rSet = GetSwAttrSet(); + const SwFmtDrop& rDrop = rSet.GetDrop(); + + // Return (0,0) if there is no drop cap at this paragraph + if( 1 >= rDrop.GetLines() || + ( !rDrop.GetChars() && !rDrop.GetWholeWord() ) ) + { + return false; + } + + // get text frame + SwIterator<SwTxtFrm,SwTxtNode> aIter( *this ); + for( SwTxtFrm* pLastFrm = aIter.First(); pLastFrm; pLastFrm = aIter.Next() ) + { + // Only (master-) text frames can have a drop cap. + if ( !pLastFrm->IsFollow() ) + { + + if( !pLastFrm->HasPara() ) + pLastFrm->GetFormatted(); + + if ( !pLastFrm->IsEmpty() ) + { + const SwParaPortion* pPara = pLastFrm->GetPara(); + ASSERT( pPara, "GetDropSize could not find the ParaPortion, I'll guess the drop cap size" ) + + if ( pPara ) + { + const SwLinePortion* pFirstPor = pPara->GetFirstPortion(); + if (pFirstPor && pFirstPor->IsDropPortion()) + { + const SwDropPortion* pDrop = (const SwDropPortion*)pFirstPor; + rDropHeight = pDrop->GetDropHeight(); + rDropDescent = pDrop->GetDropDescent(); + if (const SwFont *pFont = pDrop->GetFnt()) + rFontHeight = pFont->GetSize(pFont->GetActual()).Height(); + else + { + const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get(RES_CHRATR_FONTSIZE); + rFontHeight = rItem.GetHeight(); + } + } + } + } + break; + } + } + + if (rFontHeight==0 && rDropHeight==0 && rDropDescent==0) + { + const sal_uInt16 nLines = rDrop.GetLines(); + + const SvxFontHeightItem& rItem = (SvxFontHeightItem&)rSet.Get( RES_CHRATR_FONTSIZE ); + rFontHeight = rItem.GetHeight(); + rDropHeight = nLines * rFontHeight; + rDropDescent = rFontHeight / 5; + return false; + } + + return true; } /************************************************************************* - * SwDropPortion::PaintTxt() + * SwDropPortion::PaintTxt() *************************************************************************/ // Die Breite manipulieren, sonst werden die Buchstaben gestretcht void SwDropPortion::PaintTxt( const SwTxtPaintInfo &rInf ) const { - if ( rInf.OnWin() && - !rInf.GetOpt().IsPagePreview() && !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() ) - rInf.DrawBackground( *this ); + if ( rInf.OnWin() && + !rInf.GetOpt().IsPagePreview() && !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() ) + rInf.DrawBackground( *this ); - ASSERT( nDropHeight && pPart && nLines != 1, "Drop Portion painted twice" ); + ASSERT( nDropHeight && pPart && nLines != 1, "Drop Portion painted twice" ); - const SwDropPortionPart* pCurrPart = GetPart(); - const xub_StrLen nOldLen = GetLen(); + const SwDropPortionPart* pCurrPart = GetPart(); + const xub_StrLen nOldLen = GetLen(); - const SwTwips nBasePosY = rInf.Y(); - ((SwTxtPaintInfo&)rInf).Y( nBasePosY + nY ); - SwDropSave aSave( rInf ); - // for text inside drop portions we let vcl handle the text directions - SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); - aLayoutModeModifier.SetAuto(); + const SwTwips nBasePosY = rInf.Y(); + ((SwTxtPaintInfo&)rInf).Y( nBasePosY + nY ); + SwDropSave aSave( rInf ); + // for text inside drop portions we let vcl handle the text directions + SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); + aLayoutModeModifier.SetAuto(); - while ( pCurrPart ) - { - ((SwDropPortion*)this)->SetLen( pCurrPart->GetLen() ); - ((SwTxtPaintInfo&)rInf).SetLen( pCurrPart->GetLen() ); - SwFontSave aFontSave( rInf, &pCurrPart->GetFont() ); + while ( pCurrPart ) + { + ((SwDropPortion*)this)->SetLen( pCurrPart->GetLen() ); + ((SwTxtPaintInfo&)rInf).SetLen( pCurrPart->GetLen() ); + SwFontSave aFontSave( rInf, &pCurrPart->GetFont() ); - SwTxtPortion::Paint( rInf ); + SwTxtPortion::Paint( rInf ); - ((SwTxtPaintInfo&)rInf).SetIdx( rInf.GetIdx() + pCurrPart->GetLen() ); - ((SwTxtPaintInfo&)rInf).X( rInf.X() + pCurrPart->GetWidth() ); - pCurrPart = pCurrPart->GetFollow(); - } + ((SwTxtPaintInfo&)rInf).SetIdx( rInf.GetIdx() + pCurrPart->GetLen() ); + ((SwTxtPaintInfo&)rInf).X( rInf.X() + pCurrPart->GetWidth() ); + pCurrPart = pCurrPart->GetFollow(); + } - ((SwTxtPaintInfo&)rInf).Y( nBasePosY ); - ((SwDropPortion*)this)->SetLen( nOldLen ); + ((SwTxtPaintInfo&)rInf).Y( nBasePosY ); + ((SwDropPortion*)this)->SetLen( nOldLen ); } /************************************************************************* - * SwDropPortion::Paint() + * SwDropPortion::Paint() *************************************************************************/ void SwDropPortion::PaintDrop( const SwTxtPaintInfo &rInf ) const { - // ganz normale Ausgabe wird w?hrend des normalen Paints erledigt - if( ! nDropHeight || ! pPart || nLines == 1 ) + // ganz normale Ausgabe wird w?hrend des normalen Paints erledigt + if( ! nDropHeight || ! pPart || nLines == 1 ) return; // Luegenwerte einstellen! - const KSHORT nOldHeight = Height(); - const KSHORT nOldWidth = Width(); - const KSHORT nOldAscent = GetAscent(); - const SwTwips nOldPosY = rInf.Y(); - const KSHORT nOldPosX = (KSHORT)rInf.X(); + const KSHORT nOldHeight = Height(); + const KSHORT nOldWidth = Width(); + const KSHORT nOldAscent = GetAscent(); + const SwTwips nOldPosY = rInf.Y(); + const KSHORT nOldPosX = (KSHORT)rInf.X(); const SwParaPortion *pPara = rInf.GetParaPortion(); const Point aOutPos( nOldPosX + nX, nOldPosY - pPara->GetAscent() - pPara->GetRealHeight() + pPara->Height() ); // Retusche nachholen. - // Set baseline - ((SwTxtPaintInfo&)rInf).Y( aOutPos.Y() + nDropHeight ); + // Set baseline + ((SwTxtPaintInfo&)rInf).Y( aOutPos.Y() + nDropHeight ); - // for background - ((SwDropPortion*)this)->Height( nDropHeight + nDropDescent ); - ((SwDropPortion*)this)->Width( Width() - nX ); - ((SwDropPortion*)this)->SetAscent( nDropHeight ); + // for background + ((SwDropPortion*)this)->Height( nDropHeight + nDropDescent ); + ((SwDropPortion*)this)->Width( Width() - nX ); + ((SwDropPortion*)this)->SetAscent( nDropHeight ); // Clipregion auf uns einstellen! // Und zwar immer, und nie mit dem bestehenden ClipRect @@ -355,50 +355,50 @@ void SwDropPortion::PaintDrop( const SwTxtPaintInfo &rInf ) const aClipRect.Intersection( rInf.GetPaintRect() ); } SwSaveClip aClip( (OutputDevice*)rInf.GetOut() ); - aClip.ChgClip( aClipRect, rInf.GetTxtFrm() ); - // Das machen, was man sonst nur macht ... - PaintTxt( rInf ); - - // Alte Werte sichern - ((SwDropPortion*)this)->Height( nOldHeight ); - ((SwDropPortion*)this)->Width( nOldWidth ); - ((SwDropPortion*)this)->SetAscent( nOldAscent ); - ((SwTxtPaintInfo&)rInf).Y( nOldPosY ); + aClip.ChgClip( aClipRect, rInf.GetTxtFrm() ); + // Das machen, was man sonst nur macht ... + PaintTxt( rInf ); + + // Alte Werte sichern + ((SwDropPortion*)this)->Height( nOldHeight ); + ((SwDropPortion*)this)->Width( nOldWidth ); + ((SwDropPortion*)this)->SetAscent( nOldAscent ); + ((SwTxtPaintInfo&)rInf).Y( nOldPosY ); } /************************************************************************* - * virtual SwDropPortion::Paint() + * virtual SwDropPortion::Paint() *************************************************************************/ void SwDropPortion::Paint( const SwTxtPaintInfo &rInf ) const { // ganz normale Ausgabe wird hier erledigt. - if( ! nDropHeight || ! pPart || 1 == nLines ) - { - if ( rInf.OnWin() && - !rInf.GetOpt().IsPagePreview() && !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() ) - rInf.DrawBackground( *this ); + if( ! nDropHeight || ! pPart || 1 == nLines ) + { + if ( rInf.OnWin() && + !rInf.GetOpt().IsPagePreview() && !rInf.GetOpt().IsReadonly() && SwViewOption::IsFieldShadings() ) + rInf.DrawBackground( *this ); // make sure that font is not rotated SwFont* pTmpFont = 0; - if ( rInf.GetFont()->GetOrientation( rInf.GetTxtFrm()->IsVertical() ) ) + if ( rInf.GetFont()->GetOrientation( rInf.GetTxtFrm()->IsVertical() ) ) { pTmpFont = new SwFont( *rInf.GetFont() ); pTmpFont->SetVertical( 0, rInf.GetTxtFrm()->IsVertical() ); } - SwFontSave aFontSave( rInf, pTmpFont ); - // for text inside drop portions we let vcl handle the text directions - SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); - aLayoutModeModifier.SetAuto(); + SwFontSave aFontSave( rInf, pTmpFont ); + // for text inside drop portions we let vcl handle the text directions + SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); + aLayoutModeModifier.SetAuto(); SwTxtPortion::Paint( rInf ); - delete pTmpFont; - } + delete pTmpFont; + } } /************************************************************************* - * virtual Format() + * virtual Format() *************************************************************************/ @@ -409,7 +409,7 @@ sal_Bool SwDropPortion::FormatTxt( SwTxtFormatInfo &rInf ) const sal_Bool bFull = SwTxtPortion::Format( rInf ); if( bFull ) { - // sieht zwar Scheisse aus, aber was soll man schon machen? + // sieht zwar nicht gut aus, aber was soll man schon machen? rInf.SetUnderFlow( 0 ); Truncate(); SetLen( nOldLen ); @@ -419,44 +419,44 @@ sal_Bool SwDropPortion::FormatTxt( SwTxtFormatInfo &rInf ) } /************************************************************************* - * virtual GetTxtSize() + * virtual GetTxtSize() *************************************************************************/ SwPosSize SwDropPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const { - sal_uInt16 nMyX = 0; - xub_StrLen nIdx = 0; + sal_uInt16 nMyX = 0; + xub_StrLen nIdx = 0; - const SwDropPortionPart* pCurrPart = GetPart(); + const SwDropPortionPart* pCurrPart = GetPart(); - // skip parts - while ( pCurrPart && nIdx + pCurrPart->GetLen() < rInf.GetLen() ) - { - nMyX = nMyX + pCurrPart->GetWidth(); - nIdx = nIdx + pCurrPart->GetLen(); - pCurrPart = pCurrPart->GetFollow(); - } + // skip parts + while ( pCurrPart && nIdx + pCurrPart->GetLen() < rInf.GetLen() ) + { + nMyX = nMyX + pCurrPart->GetWidth(); + nIdx = nIdx + pCurrPart->GetLen(); + pCurrPart = pCurrPart->GetFollow(); + } - xub_StrLen nOldIdx = rInf.GetIdx(); - xub_StrLen nOldLen = rInf.GetLen(); + xub_StrLen nOldIdx = rInf.GetIdx(); + xub_StrLen nOldLen = rInf.GetLen(); - ((SwTxtSizeInfo&)rInf).SetIdx( nIdx ); - ((SwTxtSizeInfo&)rInf).SetLen( rInf.GetLen() - nIdx ); + ((SwTxtSizeInfo&)rInf).SetIdx( nIdx ); + ((SwTxtSizeInfo&)rInf).SetLen( rInf.GetLen() - nIdx ); - // robust - SwFontSave aFontSave( rInf, pCurrPart ? &pCurrPart->GetFont() : 0 ); - SwPosSize aPosSize( SwTxtPortion::GetTxtSize( rInf ) ); - aPosSize.Width( aPosSize.Width() + nMyX ); + // robust + SwFontSave aFontSave( rInf, pCurrPart ? &pCurrPart->GetFont() : 0 ); + SwPosSize aPosSize( SwTxtPortion::GetTxtSize( rInf ) ); + aPosSize.Width( aPosSize.Width() + nMyX ); - ((SwTxtSizeInfo&)rInf).SetIdx( nOldIdx ); - ((SwTxtSizeInfo&)rInf).SetLen( nOldLen ); + ((SwTxtSizeInfo&)rInf).SetIdx( nOldIdx ); + ((SwTxtSizeInfo&)rInf).SetLen( nOldLen ); - return aPosSize; + return aPosSize; } /************************************************************************* - * virtual GetCrsrOfst() + * virtual GetCrsrOfst() *************************************************************************/ xub_StrLen SwDropPortion::GetCrsrOfst( const KSHORT ) const @@ -465,7 +465,7 @@ xub_StrLen SwDropPortion::GetCrsrOfst( const KSHORT ) const } /************************************************************************* - * SwTxtFormatter::CalcDropHeight() + * SwTxtFormatter::CalcDropHeight() *************************************************************************/ void SwTxtFormatter::CalcDropHeight( const MSHORT nLines ) @@ -527,10 +527,10 @@ void SwTxtFormatter::CalcDropHeight( const MSHORT nLines ) } /************************************************************************* - * SwTxtFormatter::GuessDropHeight() + * SwTxtFormatter::GuessDropHeight() * - * Wir schaetzen mal, dass die Fonthoehe sich nicht aendert und dass - * erst mindestens soviele Zeilen gibt, wie die DropCap-Einstellung angibt. + * Wir schaetzen mal, dass die Fonthoehe sich nicht aendert und dass + * erst mindestens soviele Zeilen gibt, wie die DropCap-Einstellung angibt. * *************************************************************************/ @@ -552,7 +552,7 @@ void SwTxtFormatter::GuessDropHeight( const MSHORT nLines ) } /************************************************************************* - * SwTxtFormatter::NewDropPortion + * SwTxtFormatter::NewDropPortion *************************************************************************/ SwDropPortion *SwTxtFormatter::NewDropPortion( SwTxtFormatInfo &rInf ) @@ -561,7 +561,7 @@ SwDropPortion *SwTxtFormatter::NewDropPortion( SwTxtFormatInfo &rInf ) return 0; xub_StrLen nPorLen = pDropFmt->GetWholeWord() ? 0 : pDropFmt->GetChars(); - nPorLen = pFrm->GetTxtNode()->GetDropLen( nPorLen ); + nPorLen = pFrm->GetTxtNode()->GetDropLen( nPorLen ); if( !nPorLen ) { ((SwTxtFormatter*)this)->ClearDropFmt(); @@ -574,78 +574,78 @@ SwDropPortion *SwTxtFormatter::NewDropPortion( SwTxtFormatInfo &rInf ) if ( !( GetDropHeight() || IsOnceMore() ) ) { if ( GetNext() ) - CalcDropHeight( pDropFmt->GetLines() ); + CalcDropHeight( pDropFmt->GetLines() ); else - GuessDropHeight( pDropFmt->GetLines() ); + GuessDropHeight( pDropFmt->GetLines() ); } - // the DropPortion - if( GetDropHeight() ) - pDropPor = new SwDropPortion( GetDropLines(), GetDropHeight(), - GetDropDescent(), pDropFmt->GetDistance() ); + // the DropPortion + if( GetDropHeight() ) + pDropPor = new SwDropPortion( GetDropLines(), GetDropHeight(), + GetDropDescent(), pDropFmt->GetDistance() ); else - pDropPor = new SwDropPortion( 0,0,0,pDropFmt->GetDistance() ); - - pDropPor->SetLen( nPorLen ); - - // If it was not possible to create a proper drop cap portion - // due to avoiding endless loops. We return a drop cap portion - // with an empty SwDropCapPart. For these portions the current - // font is used. - if ( GetDropLines() < 2 ) - { - ((SwTxtFormatter*)this)->SetPaintDrop( sal_True ); - return pDropPor; - } - - // build DropPortionParts: - ASSERT( ! rInf.GetIdx(), "Drop Portion not at 0 position!" ); - xub_StrLen nNextChg = 0; - const SwCharFmt* pFmt = pDropFmt->GetCharFmt(); - SwDropPortionPart* pCurrPart = 0; - - while ( nNextChg < nPorLen ) - { - // check for attribute changes and if the portion has to split: - Seek( nNextChg ); - - // the font is deleted in the destructor of the drop portion part - SwFont* pTmpFnt = new SwFont( *rInf.GetFont() ); - if ( pFmt ) - { - const SwAttrSet& rSet = pFmt->GetAttrSet(); - pTmpFnt->SetDiffFnt( &rSet, pFrm->GetTxtNode()->getIDocumentSettingAccess() ); - } - - // we do not allow a vertical font for the drop portion - pTmpFnt->SetVertical( 0, rInf.GetTxtFrm()->IsVertical() ); - - // find next attribute change / script change - const xub_StrLen nTmpIdx = nNextChg; - xub_StrLen nNextAttr = Min( GetNextAttr(), rInf.GetTxt().Len() ); - nNextChg = pScriptInfo->NextScriptChg( nTmpIdx ); - if( nNextChg > nNextAttr ) - nNextChg = nNextAttr; - if ( nNextChg > nPorLen ) - nNextChg = nPorLen; - - SwDropPortionPart* pPart = - new SwDropPortionPart( *pTmpFnt, nNextChg - nTmpIdx ); - - if ( ! pCurrPart ) - pDropPor->SetPart( pPart ); - else - pCurrPart->SetFollow( pPart ); - - pCurrPart = pPart; - } + pDropPor = new SwDropPortion( 0,0,0,pDropFmt->GetDistance() ); + + pDropPor->SetLen( nPorLen ); + + // If it was not possible to create a proper drop cap portion + // due to avoiding endless loops. We return a drop cap portion + // with an empty SwDropCapPart. For these portions the current + // font is used. + if ( GetDropLines() < 2 ) + { + ((SwTxtFormatter*)this)->SetPaintDrop( sal_True ); + return pDropPor; + } + + // build DropPortionParts: + ASSERT( ! rInf.GetIdx(), "Drop Portion not at 0 position!" ); + xub_StrLen nNextChg = 0; + const SwCharFmt* pFmt = pDropFmt->GetCharFmt(); + SwDropPortionPart* pCurrPart = 0; + + while ( nNextChg < nPorLen ) + { + // check for attribute changes and if the portion has to split: + Seek( nNextChg ); + + // the font is deleted in the destructor of the drop portion part + SwFont* pTmpFnt = new SwFont( *rInf.GetFont() ); + if ( pFmt ) + { + const SwAttrSet& rSet = pFmt->GetAttrSet(); + pTmpFnt->SetDiffFnt( &rSet, pFrm->GetTxtNode()->getIDocumentSettingAccess() ); + } + + // we do not allow a vertical font for the drop portion + pTmpFnt->SetVertical( 0, rInf.GetTxtFrm()->IsVertical() ); + + // find next attribute change / script change + const xub_StrLen nTmpIdx = nNextChg; + xub_StrLen nNextAttr = Min( GetNextAttr(), rInf.GetTxt().Len() ); + nNextChg = pScriptInfo->NextScriptChg( nTmpIdx ); + if( nNextChg > nNextAttr ) + nNextChg = nNextAttr; + if ( nNextChg > nPorLen ) + nNextChg = nPorLen; + + SwDropPortionPart* pPart = + new SwDropPortionPart( *pTmpFnt, nNextChg - nTmpIdx ); + + if ( ! pCurrPart ) + pDropPor->SetPart( pPart ); + else + pCurrPart->SetFollow( pPart ); + + pCurrPart = pPart; + } ((SwTxtFormatter*)this)->SetPaintDrop( sal_True ); return pDropPor; } /************************************************************************* - * SwTxtPainter::PaintDropPortion() + * SwTxtPainter::PaintDropPortion() *************************************************************************/ @@ -661,10 +661,10 @@ void SwTxtPainter::PaintDropPortion() Top(); - GetInfo().SetpSpaceAdd( pCurr->GetpLLSpaceAdd() ); + GetInfo().SetpSpaceAdd( pCurr->GetpLLSpaceAdd() ); GetInfo().ResetSpaceIdx(); - GetInfo().SetKanaComp( pCurr->GetpKanaComp() ); - GetInfo().ResetKanaIdx(); + GetInfo().SetKanaComp( pCurr->GetpKanaComp() ); + GetInfo().ResetKanaIdx(); // 8047: Drops und Dummies while( !pCurr->GetLen() && Next() ) @@ -685,7 +685,7 @@ void SwTxtPainter::PaintDropPortion() if( nX ) { const Point aPoint( Left(), Y() ); - const Size aSize( nX - 1, GetDropHeight()+GetDropDescent() ); + const Size aSize( nX - 1, GetDropHeight()+GetDropDescent() ); SwRect aRetouche( aPoint, aSize ); GetInfo().DrawRect( aRetouche ); } @@ -705,7 +705,7 @@ void SwTxtPainter::PaintDropPortion() } /************************************************************************* - * clas SwDropCapCache + * class SwDropCapCache * * Da die Berechnung der Fontgroesse der Initialen ein teures Geschaeft ist, * wird dies durch einen DropCapCache geschleust. @@ -717,7 +717,7 @@ class SwDropCapCache { long aMagicNo[ DROP_CACHE_SIZE ]; XubString aTxt[ DROP_CACHE_SIZE ]; - sal_uInt16 aFactor[ DROP_CACHE_SIZE ]; + sal_uInt16 aFactor[ DROP_CACHE_SIZE ]; KSHORT aWishedHeight[ DROP_CACHE_SIZE ]; short aDescent[ DROP_CACHE_SIZE ]; MSHORT nIndex; @@ -728,7 +728,7 @@ public: }; /************************************************************************* - * SwDropCapCache Ctor / Dtor + * SwDropCapCache Ctor / Dtor *************************************************************************/ SwDropCapCache::SwDropCapCache() : nIndex( 0 ) @@ -743,339 +743,339 @@ void SwDropPortion::DeleteDropCapCache() } /************************************************************************* - * SwDropCapCache::CalcFontSize + * SwDropCapCache::CalcFontSize *************************************************************************/ void SwDropCapCache::CalcFontSize( SwDropPortion* pDrop, SwTxtFormatInfo &rInf ) { const void* pFntNo = 0; - MSHORT nTmpIdx = 0; - - ASSERT( pDrop->GetPart(),"DropPortion without part during font calculation"); - - SwDropPortionPart* pCurrPart = pDrop->GetPart(); - const sal_Bool bUseCache = ! pCurrPart->GetFollow(); - xub_StrLen nIdx = rInf.GetIdx(); - XubString aStr( rInf.GetTxt(), nIdx, pCurrPart->GetLen() ); - - long nAscent = 0; - long nDescent = 0; - long nFactor = -1; - - if ( bUseCache ) - { - SwFont& rFnt = pCurrPart->GetFont(); - rFnt.ChkMagic( rInf.GetVsh(), rFnt.GetActual() ); - rFnt.GetMagic( pFntNo, nTmpIdx, rFnt.GetActual() ); - - nTmpIdx = 0; - - while( nTmpIdx < DROP_CACHE_SIZE && - ( aTxt[ nTmpIdx ] != aStr || aMagicNo[ nTmpIdx ] != long(pFntNo) || - aWishedHeight[ nTmpIdx ] != pDrop->GetDropHeight() ) ) - ++nTmpIdx; - } - - // we have to calculate a new font scaling factor if - // 1. we did not find a scaling factor in the cache or - // 2. we are not allowed to use the cache because the drop portion - // consists of more than one part - if( nTmpIdx >= DROP_CACHE_SIZE || ! bUseCache ) - { - ++nIndex; - nIndex %= DROP_CACHE_SIZE; - nTmpIdx = nIndex; - - long nWishedHeight = pDrop->GetDropHeight(); - - // find out biggest font size for initial scaling factor - long nMaxFontHeight = 0; - while ( pCurrPart ) - { - const SwFont& rFnt = pCurrPart->GetFont(); - const long nCurrHeight = rFnt.GetHeight( rFnt.GetActual() ); - if ( nCurrHeight > nMaxFontHeight ) - nMaxFontHeight = nCurrHeight; - - pCurrPart = pCurrPart->GetFollow(); - } - - nFactor = ( 1000 * nWishedHeight ) / nMaxFontHeight; - - if ( bUseCache ) - { - // save keys for cache - aMagicNo[ nTmpIdx ] = long(pFntNo); - aTxt[ nTmpIdx ] = aStr; - aWishedHeight[ nTmpIdx ] = KSHORT(nWishedHeight); - // save initial scaling factor - aFactor[ nTmpIdx ] = (sal_uInt16)nFactor; - } - - sal_Bool bGrow = ( pDrop->GetLen() != 0 ); - - // for growing control - long nMax = KSHRT_MAX; - long nMin = nFactor / 2; + MSHORT nTmpIdx = 0; + + ASSERT( pDrop->GetPart(),"DropPortion without part during font calculation"); + + SwDropPortionPart* pCurrPart = pDrop->GetPart(); + const sal_Bool bUseCache = ! pCurrPart->GetFollow(); + xub_StrLen nIdx = rInf.GetIdx(); + XubString aStr( rInf.GetTxt(), nIdx, pCurrPart->GetLen() ); + + long nAscent = 0; + long nDescent = 0; + long nFactor = -1; + + if ( bUseCache ) + { + SwFont& rFnt = pCurrPart->GetFont(); + rFnt.ChkMagic( rInf.GetVsh(), rFnt.GetActual() ); + rFnt.GetMagic( pFntNo, nTmpIdx, rFnt.GetActual() ); + + nTmpIdx = 0; + + while( nTmpIdx < DROP_CACHE_SIZE && + ( aTxt[ nTmpIdx ] != aStr || aMagicNo[ nTmpIdx ] != long(pFntNo) || + aWishedHeight[ nTmpIdx ] != pDrop->GetDropHeight() ) ) + ++nTmpIdx; + } + + // we have to calculate a new font scaling factor if + // 1. we did not find a scaling factor in the cache or + // 2. we are not allowed to use the cache because the drop portion + // consists of more than one part + if( nTmpIdx >= DROP_CACHE_SIZE || ! bUseCache ) + { + ++nIndex; + nIndex %= DROP_CACHE_SIZE; + nTmpIdx = nIndex; + + long nWishedHeight = pDrop->GetDropHeight(); + + // find out biggest font size for initial scaling factor + long nMaxFontHeight = 0; + while ( pCurrPart ) + { + const SwFont& rFnt = pCurrPart->GetFont(); + const long nCurrHeight = rFnt.GetHeight( rFnt.GetActual() ); + if ( nCurrHeight > nMaxFontHeight ) + nMaxFontHeight = nCurrHeight; + + pCurrPart = pCurrPart->GetFollow(); + } + + nFactor = ( 1000 * nWishedHeight ) / nMaxFontHeight; + + if ( bUseCache ) + { + // save keys for cache + aMagicNo[ nTmpIdx ] = long(pFntNo); + aTxt[ nTmpIdx ] = aStr; + aWishedHeight[ nTmpIdx ] = KSHORT(nWishedHeight); + // save initial scaling factor + aFactor[ nTmpIdx ] = (sal_uInt16)nFactor; + } + + sal_Bool bGrow = ( pDrop->GetLen() != 0 ); + + // for growing control + long nMax = KSHRT_MAX; + long nMin = nFactor / 2; #if OSL_DEBUG_LEVEL > 1 - long nGrow = 0; + long nGrow = 0; #endif - sal_Bool bWinUsed = sal_False; - Font aOldFnt; - MapMode aOldMap( MAP_TWIP ); - OutputDevice* pOut = rInf.GetOut(); - OutputDevice* pWin; - if( rInf.GetVsh() && rInf.GetVsh()->GetWin() ) - pWin = rInf.GetVsh()->GetWin(); - else - pWin = GetpApp()->GetDefaultDevice(); - - while( bGrow ) - { - // reset pCurrPart to first part - pCurrPart = pDrop->GetPart(); - sal_Bool bFirstGlyphRect = sal_True; - sal_Bool bHaveGlyphRect = sal_False; - Rectangle aCommonRect, aRect; - - while ( pCurrPart ) - { - // current font - SwFont& rFnt = pCurrPart->GetFont(); - - // Get height including proportion - const sal_uInt16 nCurrHeight = - (sal_uInt16)rFnt.GetHeight( rFnt.GetActual() ); - - // Get without proportion - const sal_uInt8 nOldProp = rFnt.GetPropr(); - rFnt.SetProportion( 100 ); - Size aOldSize = Size( 0, rFnt.GetHeight( rFnt.GetActual() ) ); - - Size aNewSize( 0, ( nFactor * nCurrHeight ) / 1000 ); - rFnt.SetSize( aNewSize, rFnt.GetActual() ); - rFnt.ChgPhysFnt( rInf.GetVsh(), *pOut ); - - nAscent = rFnt.GetAscent( rInf.GetVsh(), *pOut ); - - // Wir besorgen uns das alle Buchstaben umfassende Rechteck: - bHaveGlyphRect = pOut->GetTextBoundRect( aRect, rInf.GetTxt(), 0, - nIdx, pCurrPart->GetLen() ) && - ! aRect.IsEmpty(); - - if ( ! bHaveGlyphRect ) - { - // getting glyph boundaries failed for some reason, - // we take the window for calculating sizes - if ( pWin ) - { - if ( ! bWinUsed ) - { - bWinUsed = sal_True; - aOldMap = pWin->GetMapMode( ); - pWin->SetMapMode( MapMode( MAP_TWIP ) ); - aOldFnt = pWin->GetFont(); - } - pWin->SetFont( rFnt.GetActualFont() ); - - bHaveGlyphRect = pWin->GetTextBoundRect( aRect, rInf.GetTxt(), 0, - nIdx, pCurrPart->GetLen() ) && - ! aRect.IsEmpty(); - } - if ( bHaveGlyphRect ) - { - FontMetric aWinMet( pWin->GetFontMetric() ); - nAscent = (KSHORT) aWinMet.GetAscent(); - } - else - // We do not have a window or our window could not - // give us glyph boundaries. - aRect = Rectangle( Point( 0, 0 ), Size( 0, nAscent ) ); - } - - // Now we (hopefully) have a bounding rectangle for the - // glyphs of the current portion and the ascent of the current - // font - - // reset font size and proportion - rFnt.SetSize( aOldSize, rFnt.GetActual() ); - rFnt.SetProportion( nOldProp ); - - if ( bFirstGlyphRect ) - { - aCommonRect = aRect; - bFirstGlyphRect = sal_False; - } - else - aCommonRect.Union( aRect ); - - nIdx = nIdx + pCurrPart->GetLen(); - pCurrPart = pCurrPart->GetFollow(); - } - - // now we have a union ( aCommonRect ) of all glyphs with - // respect to a common baseline : 0 - - // get descent and ascent from union - if ( rInf.GetTxtFrm()->IsVertical() ) - { - nDescent = aCommonRect.Left(); - nAscent = aCommonRect.Right(); - - if ( nDescent < 0 ) - nDescent = -nDescent; - } - else - { - nDescent = aCommonRect.Bottom(); - nAscent = aCommonRect.Top(); - } - if ( nAscent < 0 ) - nAscent = -nAscent; - - const long nHght = nAscent + nDescent; - if ( nHght ) - { - if ( nHght > nWishedHeight ) - nMax = nFactor; - else - { - if ( bUseCache ) - aFactor[ nTmpIdx ] = (sal_uInt16)nFactor; - nMin = nFactor; - } - - nFactor = ( nFactor * nWishedHeight ) / nHght; - bGrow = ( nFactor > nMin ) && ( nFactor < nMax ); + sal_Bool bWinUsed = sal_False; + Font aOldFnt; + MapMode aOldMap( MAP_TWIP ); + OutputDevice* pOut = rInf.GetOut(); + OutputDevice* pWin; + if( rInf.GetVsh() && rInf.GetVsh()->GetWin() ) + pWin = rInf.GetVsh()->GetWin(); + else + pWin = GetpApp()->GetDefaultDevice(); + + while( bGrow ) + { + // reset pCurrPart to first part + pCurrPart = pDrop->GetPart(); + sal_Bool bFirstGlyphRect = sal_True; + sal_Bool bHaveGlyphRect = sal_False; + Rectangle aCommonRect, aRect; + + while ( pCurrPart ) + { + // current font + SwFont& rFnt = pCurrPart->GetFont(); + + // Get height including proportion + const sal_uInt16 nCurrHeight = + (sal_uInt16)rFnt.GetHeight( rFnt.GetActual() ); + + // Get without proportion + const sal_uInt8 nOldProp = rFnt.GetPropr(); + rFnt.SetProportion( 100 ); + Size aOldSize = Size( 0, rFnt.GetHeight( rFnt.GetActual() ) ); + + Size aNewSize( 0, ( nFactor * nCurrHeight ) / 1000 ); + rFnt.SetSize( aNewSize, rFnt.GetActual() ); + rFnt.ChgPhysFnt( rInf.GetVsh(), *pOut ); + + nAscent = rFnt.GetAscent( rInf.GetVsh(), *pOut ); + + // Wir besorgen uns das alle Buchstaben umfassende Rechteck: + bHaveGlyphRect = pOut->GetTextBoundRect( aRect, rInf.GetTxt(), 0, + nIdx, pCurrPart->GetLen() ) && + ! aRect.IsEmpty(); + + if ( ! bHaveGlyphRect ) + { + // getting glyph boundaries failed for some reason, + // we take the window for calculating sizes + if ( pWin ) + { + if ( ! bWinUsed ) + { + bWinUsed = sal_True; + aOldMap = pWin->GetMapMode( ); + pWin->SetMapMode( MapMode( MAP_TWIP ) ); + aOldFnt = pWin->GetFont(); + } + pWin->SetFont( rFnt.GetActualFont() ); + + bHaveGlyphRect = pWin->GetTextBoundRect( aRect, rInf.GetTxt(), 0, + nIdx, pCurrPart->GetLen() ) && + ! aRect.IsEmpty(); + } + if ( bHaveGlyphRect ) + { + FontMetric aWinMet( pWin->GetFontMetric() ); + nAscent = (KSHORT) aWinMet.GetAscent(); + } + else + // We do not have a window or our window could not + // give us glyph boundaries. + aRect = Rectangle( Point( 0, 0 ), Size( 0, nAscent ) ); + } + + // Now we (hopefully) have a bounding rectangle for the + // glyphs of the current portion and the ascent of the current + // font + + // reset font size and proportion + rFnt.SetSize( aOldSize, rFnt.GetActual() ); + rFnt.SetProportion( nOldProp ); + + if ( bFirstGlyphRect ) + { + aCommonRect = aRect; + bFirstGlyphRect = sal_False; + } + else + aCommonRect.Union( aRect ); + + nIdx = nIdx + pCurrPart->GetLen(); + pCurrPart = pCurrPart->GetFollow(); + } + + // now we have a union ( aCommonRect ) of all glyphs with + // respect to a common baseline : 0 + + // get descent and ascent from union + if ( rInf.GetTxtFrm()->IsVertical() ) + { + nDescent = aCommonRect.Left(); + nAscent = aCommonRect.Right(); + + if ( nDescent < 0 ) + nDescent = -nDescent; + } + else + { + nDescent = aCommonRect.Bottom(); + nAscent = aCommonRect.Top(); + } + if ( nAscent < 0 ) + nAscent = -nAscent; + + const long nHght = nAscent + nDescent; + if ( nHght ) + { + if ( nHght > nWishedHeight ) + nMax = nFactor; + else + { + if ( bUseCache ) + aFactor[ nTmpIdx ] = (sal_uInt16)nFactor; + nMin = nFactor; + } + + nFactor = ( nFactor * nWishedHeight ) / nHght; + bGrow = ( nFactor > nMin ) && ( nFactor < nMax ); #if OSL_DEBUG_LEVEL > 1 - if ( bGrow ) - nGrow++; + if ( bGrow ) + nGrow++; #endif - nIdx = rInf.GetIdx(); - } - else - bGrow = sal_False; - } - - if ( bWinUsed ) - { - // reset window if it has been used - pWin->SetMapMode( aOldMap ); - pWin->SetFont( aOldFnt ); - } - - if ( bUseCache ) - aDescent[ nTmpIdx ] = -short( nDescent ); - } - - pCurrPart = pDrop->GetPart(); - - // did made any new calculations or did we use the cache? - if ( -1 == nFactor ) - { - nFactor = aFactor[ nTmpIdx ]; - nDescent = aDescent[ nTmpIdx ]; - } - else - nDescent = -nDescent; - - while ( pCurrPart ) - { - // scale current font - SwFont& rFnt = pCurrPart->GetFont(); - Size aNewSize( 0, ( nFactor * rFnt.GetHeight( rFnt.GetActual() ) ) / 1000 ); - - const sal_uInt8 nOldProp = rFnt.GetPropr(); - rFnt.SetProportion( 100 ); - rFnt.SetSize( aNewSize, rFnt.GetActual() ); - rFnt.SetProportion( nOldProp ); - - pCurrPart = pCurrPart->GetFollow(); - } - pDrop->SetY( (short)nDescent ); + nIdx = rInf.GetIdx(); + } + else + bGrow = sal_False; + } + + if ( bWinUsed ) + { + // reset window if it has been used + pWin->SetMapMode( aOldMap ); + pWin->SetFont( aOldFnt ); + } + + if ( bUseCache ) + aDescent[ nTmpIdx ] = -short( nDescent ); + } + + pCurrPart = pDrop->GetPart(); + + // did we made any new calculations or did we use the cache? + if ( -1 == nFactor ) + { + nFactor = aFactor[ nTmpIdx ]; + nDescent = aDescent[ nTmpIdx ]; + } + else + nDescent = -nDescent; + + while ( pCurrPart ) + { + // scale current font + SwFont& rFnt = pCurrPart->GetFont(); + Size aNewSize( 0, ( nFactor * rFnt.GetHeight( rFnt.GetActual() ) ) / 1000 ); + + const sal_uInt8 nOldProp = rFnt.GetPropr(); + rFnt.SetProportion( 100 ); + rFnt.SetSize( aNewSize, rFnt.GetActual() ); + rFnt.SetProportion( nOldProp ); + + pCurrPart = pCurrPart->GetFollow(); + } + pDrop->SetY( (short)nDescent ); } /************************************************************************* - * virtual Format() + * virtual Format() *************************************************************************/ sal_Bool SwDropPortion::Format( SwTxtFormatInfo &rInf ) { sal_Bool bFull = sal_False; - Fix( (sal_uInt16)rInf.X() ); + Fix( (sal_uInt16)rInf.X() ); - SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); - aLayoutModeModifier.SetAuto(); + SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); + aLayoutModeModifier.SetAuto(); - if( nDropHeight && pPart && nLines!=1 ) + if( nDropHeight && pPart && nLines!=1 ) { if( !pDropCapCache ) pDropCapCache = new SwDropCapCache(); - // adjust font sizes to fit into the rectangle - pDropCapCache->CalcFontSize( this, rInf ); + // adjust font sizes to fit into the rectangle + pDropCapCache->CalcFontSize( this, rInf ); - const long nOldX = rInf.X(); - { - SwDropSave aSave( rInf ); - SwDropPortionPart* pCurrPart = pPart; - - while ( pCurrPart ) - { - rInf.SetLen( pCurrPart->GetLen() ); - SwFont& rFnt = pCurrPart->GetFont(); - { - SwFontSave aFontSave( rInf, &rFnt ); - bFull = FormatTxt( rInf ); - - if ( bFull ) - break; - } - - const SwTwips nTmpWidth = - ( InSpaceGrp() && rInf.GetSpaceAdd() ) ? - Width() + CalcSpacing( rInf.GetSpaceAdd(), rInf ) : - Width(); - - // set values - pCurrPart->SetWidth( (sal_uInt16)nTmpWidth ); + const long nOldX = rInf.X(); + { + SwDropSave aSave( rInf ); + SwDropPortionPart* pCurrPart = pPart; - // Move - rInf.SetIdx( rInf.GetIdx() + pCurrPart->GetLen() ); - rInf.X( rInf.X() + nTmpWidth ); - pCurrPart = pCurrPart->GetFollow(); - } + while ( pCurrPart ) + { + rInf.SetLen( pCurrPart->GetLen() ); + SwFont& rFnt = pCurrPart->GetFont(); + { + SwFontSave aFontSave( rInf, &rFnt ); + bFull = FormatTxt( rInf ); + + if ( bFull ) + break; + } + + const SwTwips nTmpWidth = + ( InSpaceGrp() && rInf.GetSpaceAdd() ) ? + Width() + CalcSpacing( rInf.GetSpaceAdd(), rInf ) : + Width(); + + // set values + pCurrPart->SetWidth( (sal_uInt16)nTmpWidth ); + + // Move + rInf.SetIdx( rInf.GetIdx() + pCurrPart->GetLen() ); + rInf.X( rInf.X() + nTmpWidth ); + pCurrPart = pCurrPart->GetFollow(); + } - Width( (sal_uInt16)(rInf.X() - nOldX) ); - } + Width( (sal_uInt16)(rInf.X() - nOldX) ); + } - // reset my length - SetLen( rInf.GetLen() ); + // reset my length + SetLen( rInf.GetLen() ); - // 7631, 7633: bei Ueberlappungen mit Flys ist Schluss. - if( ! bFull ) - bFull = lcl_IsDropFlyInter( rInf, Width(), nDropHeight ); + // 7631, 7633: bei Ueberlappungen mit Flys ist Schluss. + if( ! bFull ) + bFull = lcl_IsDropFlyInter( rInf, Width(), nDropHeight ); - if( bFull ) + if( bFull ) { // Durch FormatTxt kann nHeight auf 0 gesetzt worden sein if ( !Height() ) Height( rInf.GetTxtHeight() ); - // Jetzt noch einmal der ganze Spass - nDropHeight = nLines = 0; - delete pPart; - pPart = NULL; + // Jetzt noch einmal der ganze Spass + nDropHeight = nLines = 0; + delete pPart; + pPart = NULL; - // meanwhile use normal formatting - bFull = SwTxtPortion::Format( rInf ); + // meanwhile use normal formatting + bFull = SwTxtPortion::Format( rInf ); } else rInf.SetDropInit( sal_True ); - Height( rInf.GetTxtHeight() ); - SetAscent( rInf.GetAscent() ); + Height( rInf.GetTxtHeight() ); + SetAscent( rInf.GetAscent() ); } else bFull = SwTxtPortion::Format( rInf ); @@ -1085,9 +1085,9 @@ sal_Bool SwDropPortion::Format( SwTxtFormatInfo &rInf ) else { const KSHORT nWant = Width() + GetDistance(); - const KSHORT nRest = (sal_uInt16)(rInf.Width() - rInf.X()); - if( ( nWant > nRest ) || - lcl_IsDropFlyInter( rInf, Width() + GetDistance(), nDropHeight ) ) + const KSHORT nRest = (sal_uInt16)(rInf.Width() - rInf.X()); + if( ( nWant > nRest ) || + lcl_IsDropFlyInter( rInf, Width() + GetDistance(), nDropHeight ) ) nDistance = 0; Width( Width() + nDistance ); @@ -1095,3 +1095,4 @@ sal_Bool SwDropPortion::Format( SwTxtFormatInfo &rInf ) return bFull; } +/* vim: set noet sw=4 ts=4: */ diff --git a/main/sw/source/core/text/txtfld.cxx b/main/sw/source/core/text/txtfld.cxx index 77a065bec0..2a0121bc30 100644 --- a/main/sw/source/core/text/txtfld.cxx +++ b/main/sw/source/core/text/txtfld.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -30,33 +30,33 @@ #include <txtfld.hxx> #include <charfmt.hxx> -#include "viewsh.hxx" // NewFldPortion, GetDoc() -#include "doc.hxx" // NewFldPortion, GetSysFldType() -#include "rootfrm.hxx" // Info ueber virt. PageNumber -#include "pagefrm.hxx" // NewFldPortion, GetVirtPageNum() -#include "ndtxt.hxx" // NewNumberPortion, pHints->GetNum() -#include "fldbas.hxx" // SwField +#include "viewsh.hxx" // NewFldPortion, GetDoc() +#include "doc.hxx" // NewFldPortion, GetSysFldType() +#include "rootfrm.hxx" // Info about virt. PageNumber +#include "pagefrm.hxx" // NewFldPortion, GetVirtPageNum() +#include "ndtxt.hxx" // NewNumberPortion, pHints->GetNum() +#include "fldbas.hxx" // SwField #include "viewopt.hxx" // SwViewOptions -#include "flyfrm.hxx" //IsInBody() +#include "flyfrm.hxx" // IsInBody() #include "viewimp.hxx" -#include "txtatr.hxx" // SwTxtFld +#include "txtatr.hxx" // SwTxtFld #include "txtcfg.hxx" -#include "swfont.hxx" // NewFldPortion, new SwFont -#include "fntcache.hxx" // NewFldPortion, SwFntAccess +#include "swfont.hxx" // NewFldPortion, new SwFont +#include "fntcache.hxx" // NewFldPortion, SwFntAccess #include "porfld.hxx" -#include "porftn.hxx" // NewExtraPortion -#include "porref.hxx" // NewExtraPortion -#include "portox.hxx" // NewExtraPortion -#include "porhyph.hxx" // NewExtraPortion -#include "porfly.hxx" // NewExtraPortion -#include "itrform2.hxx" // SwTxtFormatter +#include "porftn.hxx" // NewExtraPortion +#include "porref.hxx" // NewExtraPortion +#include "portox.hxx" // NewExtraPortion +#include "porhyph.hxx" // NewExtraPortion +#include "porfly.hxx" // NewExtraPortion +#include "itrform2.hxx" // SwTxtFormatter #include "chpfld.hxx" #include "dbfld.hxx" #include "expfld.hxx" #include "docufld.hxx" -#include "pagedesc.hxx" // NewFldPortion, GetNum() -#include <pormulti.hxx> // SwMultiPortion -#include "fmtmeta.hxx" // lcl_NewMetaPortion +#include "pagedesc.hxx" // NewFldPortion, GetNum() +#include <pormulti.hxx> // SwMultiPortion +#include "fmtmeta.hxx" // lcl_NewMetaPortion #ifndef _REFFLD_HXX @@ -65,8 +65,10 @@ #ifndef _FLDDAT_HXX #include "flddat.hxx" #endif + + /************************************************************************* - * SwTxtFormatter::NewFldPortion() + * SwTxtFormatter::NewFldPortion() *************************************************************************/ @@ -76,10 +78,10 @@ sal_Bool lcl_IsInBody( SwFrm *pFrm ) return sal_True; else { - const SwFrm *pTmp = pFrm; - const SwFlyFrm *pFly; + const SwFrm *pTmp = pFrm; + const SwFlyFrm *pFly; while ( 0 != (pFly = pTmp->FindFlyFrm()) ) - pTmp = pFly->GetAnchorFrm(); + pTmp = pFly->GetAnchorFrm(); return pTmp->IsInDocBody(); } } @@ -104,13 +106,13 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, pFld->SetLanguage( GetFnt()->GetLanguage() ); // let the visual note know about its new language if (pFld->GetTyp()->Which()==RES_POSTITFLD) - const_cast<SwFmtFld*> (&pHint->GetFmtFld())->Broadcast( SwFmtFldHint( &pHint->GetFmtFld(), SWFMTFLD_LANGUAGE ) ); + const_cast<SwFmtFld*> (&pHint->GetFmtFld())->Broadcast( SwFmtFldHint( &pHint->GetFmtFld(), SWFMTFLD_LANGUAGE ) ); } ViewShell *pSh = rInf.GetVsh(); - SwDoc *const pDoc( (pSh) ? pSh->GetDoc() : 0 ); - bool const bInClipboard( (pDoc) ? pDoc->IsClipBoard() : true ); - sal_Bool bPlaceHolder = sal_False; + SwDoc *const pDoc( (pSh) ? pSh->GetDoc() : 0 ); + bool const bInClipboard( (pDoc) ? pDoc->IsClipBoard() : true ); + sal_Bool bPlaceHolder = sal_False; switch( pFld->GetTyp()->Which() ) { @@ -122,25 +124,25 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, case RES_COMBINED_CHARS: { if( bName ) - { - String const sName( pFld->GetFieldName() ); - pRet = new SwFldPortion(sName); - } + { + String const sName( pFld->GetFieldName() ); + pRet = new SwFldPortion(sName); + } else - { - String const sContent( pFld->ExpandField(bInClipboard) ); - pRet = new SwCombinedPortion(sContent); - } + { + String const sContent( pFld->ExpandField(bInClipboard) ); + pRet = new SwCombinedPortion(sContent); + } } break; case RES_HIDDENTXTFLD: - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwHiddenPortion(str); - } + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwHiddenPortion(str); + } break; case RES_CHAPTERFLD: @@ -149,40 +151,40 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, ((SwChapterField*)pFld)->ChangeExpansion( pFrame, &((SwTxtFld*)pHint)->GetTxtNode() ); } - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion( str ); - } + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion( str ); + } break; case RES_DOCSTATFLD: if( !bName && pSh && !pSh->Imp()->IsUpdateExpFlds() ) - { + { ((SwDocStatField*)pFld)->ChangeExpansion( pFrame ); - } - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion( str ); - } - if(pRet) - ((SwFldPortion*)pRet)->m_nAttrFldType= ATTR_PAGECOOUNTFLD; - break; + } + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion( str ); + } + if(pRet) + ((SwFldPortion*)pRet)->m_nAttrFldType= ATTR_PAGECOOUNTFLD; + break; case RES_PAGENUMBERFLD: { - if( !bName && pSh && pSh->GetLayout() && !pSh->Imp()->IsUpdateExpFlds() )//swmod 080122 + if( !bName && pSh && pSh->GetLayout() && !pSh->Imp()->IsUpdateExpFlds() ) // swmod 080122 { - SwPageNumberFieldType *pPageNr = (SwPageNumberFieldType *)pFld->GetTyp(); + SwPageNumberFieldType *pPageNr = (SwPageNumberFieldType *)pFld->GetTyp(); - const SwRootFrm* pTmpRootFrm = pSh->GetLayout(); - const sal_Bool bVirt = pTmpRootFrm->IsVirtPageNum(); + const SwRootFrm* pTmpRootFrm = pSh->GetLayout(); + const sal_Bool bVirt = pTmpRootFrm->IsVirtPageNum(); - MSHORT nVirtNum = pFrame->GetVirtPageNum(); - MSHORT nNumPages = pTmpRootFrm->GetPageNum(); + MSHORT nVirtNum = pFrame->GetVirtPageNum(); + MSHORT nNumPages = pTmpRootFrm->GetPageNum(); sal_Int16 nNumFmt = -1; if(SVX_NUM_PAGEDESC == pFld->GetFormat()) nNumFmt = pFrame->FindPageFrm()->GetPageDesc()->GetNumType().GetNumberingType(); @@ -190,15 +192,15 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, pPageNr->ChangeExpansion( pDoc, nVirtNum, nNumPages, bVirt, nNumFmt > -1 ? &nNumFmt : 0); } - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion( str ); - } - if(pRet) - ((SwFldPortion*)pRet)->m_nAttrFldType= ATTR_PAGENUMBERFLD; - break; + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion( str ); + } + if(pRet) + ((SwFldPortion*)pRet)->m_nAttrFldType= ATTR_PAGENUMBERFLD; + break; } case RES_GETEXPFLD: { @@ -212,17 +214,17 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, } else if( !pExpFld->IsInBodyTxt() ) { - // war vorher anders, also erst expandieren, dann umsetzen!! + // war vorher anders, also erst expandieren, dann umsetzen! pExpFld->ChangeExpansion( *pFrame, *((SwTxtFld*)pHint) ); pExpFld->ChgBodyTxtFlag( sal_True ); } } - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion( str ); - } + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion( str ); + } break; } case RES_DBFLD: @@ -246,72 +248,72 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, } */ } - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion(str); - } + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion(str); + } break; } case RES_REFPAGEGETFLD: if( !bName && pSh && !pSh->Imp()->IsUpdateExpFlds() ) - { + { ((SwRefPageGetField*)pFld)->ChangeExpansion( pFrame, (SwTxtFld*)pHint ); - } - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion(str); - } + } + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion(str); + } break; case RES_JUMPEDITFLD: if( !bName ) - pChFmt = ((SwJumpEditField*)pFld)->GetCharFmt(); + pChFmt = ((SwJumpEditField*)pFld)->GetCharFmt(); bNewFlyPor = sal_True; - bPlaceHolder = sal_True; + bPlaceHolder = sal_True; break; case RES_GETREFFLD: - subType = ((SwGetRefField*)pFld)->GetSubType(); - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion(str); - } - if(pRet) + subType = ((SwGetRefField*)pFld)->GetSubType(); { - if( subType == REF_BOOKMARK ) - ((SwFldPortion*)pRet)->m_nAttrFldType = ATTR_BOOKMARKFLD; + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion(str); + } + if(pRet) + { + if( subType == REF_BOOKMARK ) + ((SwFldPortion*)pRet)->m_nAttrFldType = ATTR_BOOKMARKFLD; else if( subType == REF_SETREFATTR ) ((SwFldPortion*)pRet)->m_nAttrFldType = ATTR_SETREFATTRFLD; break; } case RES_DATETIMEFLD: subType = ((SwDateTimeField*)pFld)->GetSubType(); - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion(str); - } - if(pRet) { - if( subType & DATEFLD ) + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion(str); + } + if(pRet) + { + if( subType & DATEFLD ) ((SwFldPortion*)pRet)->m_nAttrFldType= ATTR_DATEFLD; else if( subType & TIMEFLD ) ((SwFldPortion*)pRet)->m_nAttrFldType = ATTR_TIMEFLD; break; } default: - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion(str); - } + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion(str); + } } if( bNewFlyPor ) @@ -325,143 +327,143 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, SwAttrPool* pPool = pChFmt->GetAttrSet().GetPool(); SfxItemSet aSet( *pPool, RES_CHRATR_BEGIN, RES_CHRATR_END ); SfxItemSet aTmpSet( aSet ); - pFrm->GetTxtNode()->GetAttr(aSet,rInf.GetIdx(),rInf.GetIdx()+1); + pFrm->GetTxtNode()->GetAttr(aSet,rInf.GetIdx(),rInf.GetIdx()+1); aTmpSet.Set( pChFmt->GetAttrSet() ); aTmpSet.Differentiate( aSet ); if( aTmpSet.Count() ) - pTmpFnt->SetDiffFnt( &aTmpSet, pFrm->GetTxtNode()->getIDocumentSettingAccess() ); + pTmpFnt->SetDiffFnt( &aTmpSet, pFrm->GetTxtNode()->getIDocumentSettingAccess() ); } else - pTmpFnt->SetDiffFnt( &pChFmt->GetAttrSet(), pFrm->GetTxtNode()->getIDocumentSettingAccess() ); + pTmpFnt->SetDiffFnt( &pChFmt->GetAttrSet(), pFrm->GetTxtNode()->getIDocumentSettingAccess() ); + } + { + String const str( (bName) + ? pFld->GetFieldName() + : pFld->ExpandField(bInClipboard) ); + pRet = new SwFldPortion(str, pTmpFnt, bPlaceHolder); } - { - String const str( (bName) - ? pFld->GetFieldName() - : pFld->ExpandField(bInClipboard) ); - pRet = new SwFldPortion(str, pTmpFnt, bPlaceHolder); - } } return pRet; } /************************************************************************* - * SwTxtFormatter::TryNewNoLengthPortion() + * SwTxtFormatter::TryNewNoLengthPortion() *************************************************************************/ SwFldPortion * lcl_NewMetaPortion(SwTxtAttr & rHint, const bool bPrefix) { - ::sw::Meta *const pMeta( - static_cast<SwFmtMeta &>(rHint.GetAttr()).GetMeta() ); - ::rtl::OUString fix; - ::sw::MetaField *const pField( dynamic_cast< ::sw::MetaField * >(pMeta) ); - OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?"); - if (pField) - { - pField->GetPrefixAndSuffix((bPrefix) ? &fix : 0, (bPrefix) ? 0 : &fix); - } - return new SwFldPortion( fix ); + ::sw::Meta *const pMeta( + static_cast<SwFmtMeta &>(rHint.GetAttr()).GetMeta() ); + ::rtl::OUString fix; + ::sw::MetaField *const pField( dynamic_cast< ::sw::MetaField * >(pMeta) ); + OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?"); + if (pField) + { + pField->GetPrefixAndSuffix((bPrefix) ? &fix : 0, (bPrefix) ? 0 : &fix); + } + return new SwFldPortion( fix ); } /** Try to create a new portion with zero length, for an end of a hint - (where there is no CH_TXTATR). Because there may be multiple hint ends at a - given index, m_nHintEndIndex is used to keep track of the already created - portions. But the portions created here may actually be deleted again, - due to UnderFlow. In that case, m_nHintEndIndex must be decremented, - so the portion will be created again on the next line. + (where there is no CH_TXTATR). Because there may be multiple hint ends at a + given index, m_nHintEndIndex is used to keep track of the already created + portions. But the portions created here may actually be deleted again, + due to UnderFlow. In that case, m_nHintEndIndex must be decremented, + so the portion will be created again on the next line. */ SwExpandPortion * SwTxtFormatter::TryNewNoLengthPortion(SwTxtFormatInfo & rInfo) { - if (pHints) - { - const xub_StrLen nIdx(rInfo.GetIdx()); - while (m_nHintEndIndex < pHints->GetEndCount()) - { - SwTxtAttr & rHint( *pHints->GetEnd(m_nHintEndIndex) ); - xub_StrLen const nEnd( *rHint.GetAnyEnd() ); - if (nEnd > nIdx) - { - break; - } - ++m_nHintEndIndex; - if (nEnd == nIdx) - { - if (RES_TXTATR_METAFIELD == rHint.Which()) - { - SwFldPortion *const pPortion( - lcl_NewMetaPortion(rHint, false)); - pPortion->SetNoLength(); // no CH_TXTATR at hint end! - return pPortion; - } - } - } - } - return 0; + if (pHints) + { + const xub_StrLen nIdx(rInfo.GetIdx()); + while (m_nHintEndIndex < pHints->GetEndCount()) + { + SwTxtAttr & rHint( *pHints->GetEnd(m_nHintEndIndex) ); + xub_StrLen const nEnd( *rHint.GetAnyEnd() ); + if (nEnd > nIdx) + { + break; + } + ++m_nHintEndIndex; + if (nEnd == nIdx) + { + if (RES_TXTATR_METAFIELD == rHint.Which()) + { + SwFldPortion *const pPortion( + lcl_NewMetaPortion(rHint, false)); + pPortion->SetNoLength(); // no CH_TXTATR at hint end! + return pPortion; + } + } + } + } + return 0; } /************************************************************************* - * SwTxtFormatter::NewExtraPortion() + * SwTxtFormatter::NewExtraPortion() *************************************************************************/ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) { - SwTxtAttr *pHint = GetAttr( rInf.GetIdx() ); - SwLinePortion *pRet = 0; - if( !pHint ) - { - pRet = new SwTxtPortion; - pRet->SetLen( 1 ); - rInf.SetLen( 1 ); - return pRet; - } - - switch( pHint->Which() ) - { - case RES_TXTATR_FLYCNT : - { - pRet = NewFlyCntPortion( rInf, pHint ); - break; - } - case RES_TXTATR_FTN : - { - pRet = NewFtnPortion( rInf, pHint ); - break; - } - case RES_TXTATR_FIELD : - case RES_TXTATR_ANNOTATION : - { - pRet = NewFldPortion( rInf, pHint ); - break; - } - case RES_TXTATR_REFMARK : - { - pRet = new SwIsoRefPortion; - break; - } - case RES_TXTATR_TOXMARK : - { - pRet = new SwIsoToxPortion; - break; - } - case RES_TXTATR_METAFIELD: - { - pRet = lcl_NewMetaPortion( *pHint, true ); - break; - } - default: ; - } - if( !pRet ) - { - const XubString aNothing; - pRet = new SwFldPortion( aNothing ); - rInf.SetLen( 1 ); - } - return pRet; + SwTxtAttr *pHint = GetAttr( rInf.GetIdx() ); + SwLinePortion *pRet = 0; + if( !pHint ) + { + pRet = new SwTxtPortion; + pRet->SetLen( 1 ); + rInf.SetLen( 1 ); + return pRet; + } + + switch( pHint->Which() ) + { + case RES_TXTATR_FLYCNT : + { + pRet = NewFlyCntPortion( rInf, pHint ); + break; + } + case RES_TXTATR_FTN : + { + pRet = NewFtnPortion( rInf, pHint ); + break; + } + case RES_TXTATR_FIELD : + case RES_TXTATR_ANNOTATION : + { + pRet = NewFldPortion( rInf, pHint ); + break; + } + case RES_TXTATR_REFMARK : + { + pRet = new SwIsoRefPortion; + break; + } + case RES_TXTATR_TOXMARK : + { + pRet = new SwIsoToxPortion; + break; + } + case RES_TXTATR_METAFIELD: + { + pRet = lcl_NewMetaPortion( *pHint, true ); + break; + } + default: ; + } + if( !pRet ) + { + const XubString aNothing; + pRet = new SwFldPortion( aNothing ); + rInf.SetLen( 1 ); + } + return pRet; } /************************************************************************* - * SwTxtFormatter::NewNumberPortion() + * SwTxtFormatter::NewNumberPortion() *************************************************************************/ @@ -476,29 +478,29 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const const SwNumRule* pNumRule = pTxtNd->GetNumRule(); // hat ein "gueltige" Nummer ? - if( pTxtNd->IsNumbered() && pTxtNd->IsCountedInList()) + if( pTxtNd->IsNumbered() && pTxtNd->IsCountedInList()) { - const SwNumFmt &rNumFmt = pNumRule->Get( static_cast<sal_uInt16>(pTxtNd->GetActualListLevel()) ); + const SwNumFmt &rNumFmt = pNumRule->Get( static_cast<sal_uInt16>(pTxtNd->GetActualListLevel()) ); const sal_Bool bLeft = SVX_ADJUST_LEFT == rNumFmt.GetNumAdjust(); const sal_Bool bCenter = SVX_ADJUST_CENTER == rNumFmt.GetNumAdjust(); - // --> OD 2008-01-23 #newlistlevelattrs# - const bool bLabelAlignmentPosAndSpaceModeActive( - rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ); - const KSHORT nMinDist = bLabelAlignmentPosAndSpaceModeActive - ? 0 : rNumFmt.GetCharTextDistance(); - // <-- + // --> OD 2008-01-23 #newlistlevelattrs# + const bool bLabelAlignmentPosAndSpaceModeActive( + rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ); + const KSHORT nMinDist = bLabelAlignmentPosAndSpaceModeActive + ? 0 : rNumFmt.GetCharTextDistance(); + // <-- if( SVX_NUM_BITMAP == rNumFmt.GetNumberingType() ) { - // --> OD 2008-01-23 #newlistlevelattrs# - pRet = new SwGrfNumPortion( (SwFrm*)GetTxtFrm(), - pTxtNd->GetLabelFollowedBy(), - rNumFmt.GetBrush(), - rNumFmt.GetGraphicOrientation(), - rNumFmt.GetGraphicSize(), - bLeft, bCenter, nMinDist, - bLabelAlignmentPosAndSpaceModeActive ); - // <-- + // --> OD 2008-01-23 #newlistlevelattrs# + pRet = new SwGrfNumPortion( (SwFrm*)GetTxtFrm(), + pTxtNd->GetLabelFollowedBy(), + rNumFmt.GetBrush(), + rNumFmt.GetGraphicOrientation(), + rNumFmt.GetGraphicSize(), + bLeft, bCenter, nMinDist, + bLabelAlignmentPosAndSpaceModeActive ); + // <-- long nTmpA = rInf.GetLast()->GetAscent(); long nTmpD = rInf.GetLast()->Height() - nTmpA; if( !rInf.IsTest() ) @@ -511,45 +513,41 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const // Im Dtor vom SwNumberPortion wird der SwFont deletet. SwFont *pNumFnt = 0; const SwAttrSet* pFmt = rNumFmt.GetCharFmt() ? - &rNumFmt.GetCharFmt()->GetAttrSet() : - NULL; - const IDocumentSettingAccess* pIDSA = pTxtNd->getIDocumentSettingAccess(); + &rNumFmt.GetCharFmt()->GetAttrSet() : + NULL; + const IDocumentSettingAccess* pIDSA = pTxtNd->getIDocumentSettingAccess(); - if( SVX_NUM_CHAR_SPECIAL == rNumFmt.GetNumberingType() ) + if( SVX_NUM_CHAR_SPECIAL == rNumFmt.GetNumberingType() ) { const Font *pFmtFnt = rNumFmt.GetBulletFont(); - // - // Build a new bullet font basing on the current paragraph font: - // - pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA ); - - // --> FME 2005-08-11 #i53199# - if ( !pIDSA->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) ) - { - // i18463: - // Underline style of paragraph font should not be considered - // Overline style of paragraph font should not be considered - // Weight style of paragraph font should not be considered - // Posture style of paragraph font should not be considered - pNumFnt->SetUnderline( UNDERLINE_NONE ); - pNumFnt->SetOverline( UNDERLINE_NONE ); - pNumFnt->SetItalic( ITALIC_NONE, SW_LATIN ); - pNumFnt->SetItalic( ITALIC_NONE, SW_CJK ); - pNumFnt->SetItalic( ITALIC_NONE, SW_CTL ); - pNumFnt->SetWeight( WEIGHT_NORMAL, SW_LATIN ); - pNumFnt->SetWeight( WEIGHT_NORMAL, SW_CJK ); - pNumFnt->SetWeight( WEIGHT_NORMAL, SW_CTL ); - } - - // - // Apply the explicit attributes from the character style - // associated with the numering to the new bullet font. - // + // Build a new bullet font basing on the current paragraph font: + pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA ); + + // --> FME 2005-08-11 #i53199# + if ( !pIDSA->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) ) + { + // i18463: + // Underline style of paragraph font should not be considered + // Overline style of paragraph font should not be considered + // Weight style of paragraph font should not be considered + // Posture style of paragraph font should not be considered + pNumFnt->SetUnderline( UNDERLINE_NONE ); + pNumFnt->SetOverline( UNDERLINE_NONE ); + pNumFnt->SetItalic( ITALIC_NONE, SW_LATIN ); + pNumFnt->SetItalic( ITALIC_NONE, SW_CJK ); + pNumFnt->SetItalic( ITALIC_NONE, SW_CTL ); + pNumFnt->SetWeight( WEIGHT_NORMAL, SW_LATIN ); + pNumFnt->SetWeight( WEIGHT_NORMAL, SW_CJK ); + pNumFnt->SetWeight( WEIGHT_NORMAL, SW_CTL ); + } + + // Apply the explicit attributes from the character style + // associated with the numbering to the new bullet font. if( pFmt ) - pNumFnt->SetDiffFnt( pFmt, pIDSA ); + pNumFnt->SetDiffFnt( pFmt, pIDSA ); - if ( pFmtFnt ) + if ( pFmtFnt ) { const sal_uInt8 nAct = pNumFnt->GetActual(); pNumFnt->SetFamily( pFmtFnt->GetFamily(), nAct ); @@ -559,27 +557,27 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const pNumFnt->SetPitch( pFmtFnt->GetPitch(), nAct ); } - // we do not allow a vertical font - pNumFnt->SetVertical( pNumFnt->GetOrientation(), - pFrm->IsVertical() ); - - // --> OD 2008-01-23 #newlistelevelattrs# - pRet = new SwBulletPortion( rNumFmt.GetBulletChar(), - pTxtNd->GetLabelFollowedBy(), - pNumFnt, - bLeft, bCenter, nMinDist, - bLabelAlignmentPosAndSpaceModeActive ); - // <-- + // we do not allow a vertical font + pNumFnt->SetVertical( pNumFnt->GetOrientation(), + pFrm->IsVertical() ); + + // --> OD 2008-01-23 #newlistelevelattrs# + pRet = new SwBulletPortion( rNumFmt.GetBulletChar(), + pTxtNd->GetLabelFollowedBy(), + pNumFnt, + bLeft, bCenter, nMinDist, + bLabelAlignmentPosAndSpaceModeActive ); + // <-- } else { - XubString aTxt( pTxtNd->GetNumString() ); - // --> OD 2008-01-23 #newlistlevelattrs# - if ( aTxt.Len() > 0 ) - { - aTxt.Insert( pTxtNd->GetLabelFollowedBy() ); - } - // <-- + XubString aTxt( pTxtNd->GetNumString() ); + // --> OD 2008-01-23 #newlistlevelattrs# + if ( aTxt.Len() > 0 ) + { + aTxt.Insert( pTxtNd->GetLabelFollowedBy() ); + } + // <-- // 7974: Nicht nur eine Optimierung... // Eine Numberportion ohne Text wird die Breite von 0 @@ -588,37 +586,33 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const // vorliegt! if( aTxt.Len() ) { - // - // Build a new numbering font basing on the current paragraph font: - // - pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA ); - - // --> FME 2005-08-11 #i53199# - if ( !pIDSA->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) ) - { - // i18463: - // Underline style of paragraph font should not be considered - pNumFnt->SetUnderline( UNDERLINE_NONE ); - // Overline style of paragraph font should not be considered - pNumFnt->SetOverline( UNDERLINE_NONE ); - } - - - // - // Apply the explicit attributes from the character style - // associated with the numering to the new bullet font. - // + // Build a new numbering font basing on the current paragraph font: + pNumFnt = new SwFont( &rInf.GetCharAttr(), pIDSA ); + + // --> FME 2005-08-11 #i53199# + if ( !pIDSA->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT) ) + { + // i18463: + // Underline style of paragraph font should not be considered + pNumFnt->SetUnderline( UNDERLINE_NONE ); + // Overline style of paragraph font should not be considered + pNumFnt->SetOverline( UNDERLINE_NONE ); + } + + + // Apply the explicit attributes from the character style + // associated with the numbering to the new bullet font. if( pFmt ) - pNumFnt->SetDiffFnt( pFmt, pIDSA ); + pNumFnt->SetDiffFnt( pFmt, pIDSA ); - // we do not allow a vertical font - pNumFnt->SetVertical( pNumFnt->GetOrientation(), pFrm->IsVertical() ); + // we do not allow a vertical font + pNumFnt->SetVertical( pNumFnt->GetOrientation(), pFrm->IsVertical() ); - // --> OD 2008-01-23 #newlistlevelattrs# - pRet = new SwNumberPortion( aTxt, pNumFnt, - bLeft, bCenter, nMinDist, - bLabelAlignmentPosAndSpaceModeActive ); - // <-- + // --> OD 2008-01-23 #newlistlevelattrs# + pRet = new SwNumberPortion( aTxt, pNumFnt, + bLeft, bCenter, nMinDist, + bLabelAlignmentPosAndSpaceModeActive ); + // <-- } } } @@ -626,3 +620,4 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const return pRet; } +/* vim: set noet sw=4 ts=4: */