diff options
author | Vladimir Glazunov <vg@openoffice.org> | 2010-05-28 08:57:30 +0200 |
---|---|---|
committer | Vladimir Glazunov <vg@openoffice.org> | 2010-05-28 08:57:30 +0200 |
commit | dd508f5004b7a26b085e6f6f51c8f4b4bc16c75c (patch) | |
tree | 9f0a4a8c943d5d486da4a33a4de60593bb535224 /sc/source | |
parent | 26e3759b7ccaf51aaeab955bbddb6a80c934be5d (diff) | |
parent | d425ae8cf3bc880d6902e5b10081b1516ec425f1 (diff) |
CWS-TOOLING: integrate CWS koheiautodecimal
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/column2.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 12 | ||||
-rw-r--r-- | sc/source/core/data/documen4.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/docoptio.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh8.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/optdlg.hrc | 1 | ||||
-rw-r--r-- | sc/source/ui/inc/output.hxx | 23 | ||||
-rw-r--r-- | sc/source/ui/inc/tpcalc.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpcalc.cxx | 59 | ||||
-rw-r--r-- | sc/source/ui/src/optdlg.src | 38 | ||||
-rw-r--r-- | sc/source/ui/unoobj/defltuno.cxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 466 |
13 files changed, 431 insertions, 202 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 9e3ed1c7ef5e..4c8de67ba271 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -193,6 +193,7 @@ long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev, double nPPT = bWidth ? nPPTX : nPPTY; if (Search(nRow,nIndex)) { + ScBaseCell* pCell = pItems[nIndex].pCell; const ScPatternAttr* pPattern = rOptions.pPattern; if (!pPattern) pPattern = pAttrArray->GetPattern( nRow ); @@ -233,22 +234,26 @@ long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev, else eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&) pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue(); - BOOL bBreak; + bool bBreak; if ( eHorJust == SVX_HOR_JUSTIFY_BLOCK ) - bBreak = TRUE; + bBreak = true; else if ( pCondSet && pCondSet->GetItemState(ATTR_LINEBREAK, TRUE, &pCondItem) == SFX_ITEM_SET) bBreak = ((const SfxBoolItem*)pCondItem)->GetValue(); else bBreak = ((const SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue(); + if (pCell->HasValueData()) + // Cell has a value. Disable line break. + bBreak = false; + // get other attributes from pattern and conditional formatting SvxCellOrientation eOrient = pPattern->GetCellOrientation( pCondSet ); BOOL bAsianVertical = ( eOrient == SVX_ORIENTATION_STACKED && ((const SfxBoolItem&)pPattern->GetItem( ATTR_VERTICAL_ASIAN, pCondSet )).GetValue() ); if ( bAsianVertical ) - bBreak = FALSE; + bBreak = false; if ( bWidth && bBreak ) // after determining bAsianVertical (bBreak may be reset) return 0; @@ -300,7 +305,6 @@ long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev, nIndent = ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue(); } - ScBaseCell* pCell = pItems[nIndex].pCell; BYTE nScript = pDocument->GetScriptType( nCol, nRow, nTab, pCell ); if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 22b75b8d4a6a..65076e7c529c 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -1920,11 +1920,15 @@ sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCh } -xub_StrLen ScColumn::GetMaxNumberStringLen( USHORT& nPrecision, - SCROW nRowStart, SCROW nRowEnd ) const +xub_StrLen ScColumn::GetMaxNumberStringLen( + sal_uInt16& nPrecision, SCROW nRowStart, SCROW nRowEnd ) const { xub_StrLen nStringLen = 0; nPrecision = pDocument->GetDocOptions().GetStdPrecision(); + if ( nPrecision == SvNumberFormatter::UNLIMITED_PRECISION ) + // In case of unlimited precision, use 2 instead. + nPrecision = 2; + if ( pItems ) { String aString; @@ -1947,8 +1951,8 @@ xub_StrLen ScColumn::GetMaxNumberStringLen( USHORT& nPrecision, { if ( nFormat ) { // more decimals than standard? - USHORT nPrec = pNumFmt->GetFormatPrecision( nFormat ); - if ( nPrec > nPrecision ) + sal_uInt16 nPrec = pNumFmt->GetFormatPrecision( nFormat ); + if ( nPrec != SvNumberFormatter::UNLIMITED_PRECISION && nPrec > nPrecision ) nPrecision = nPrec; } if ( nPrecision ) diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index bb6b4cd295ce..148cc367534c 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -430,7 +430,7 @@ sal_Int32 ScDocument::GetMaxStringLen( SCTAB nTab, SCCOL nCol, return 0; } -xub_StrLen ScDocument::GetMaxNumberStringLen( USHORT& nPrecision, SCTAB nTab, +xub_StrLen ScDocument::GetMaxNumberStringLen( sal_uInt16& nPrecision, SCTAB nTab, SCCOL nCol, SCROW nRowStart, SCROW nRowEnd ) const { diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 90993367dde6..7d295b6286a8 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -1913,8 +1913,8 @@ sal_Int32 ScTable::GetMaxStringLen( SCCOL nCol, SCROW nRowStart, return 0; } -xub_StrLen ScTable::GetMaxNumberStringLen( USHORT& nPrecision, SCCOL nCol, - SCROW nRowStart, SCROW nRowEnd ) const +xub_StrLen ScTable::GetMaxNumberStringLen( + sal_uInt16& nPrecision, SCCOL nCol, SCROW nRowStart, SCROW nRowEnd ) const { if ( ValidCol(nCol) ) return aCol[nCol].GetMaxNumberStringLen( nPrecision, nRowStart, nRowEnd ); diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx index a99b3c01dd1f..95ce357b3217 100644 --- a/sc/source/core/tool/docoptio.cxx +++ b/sc/source/core/tool/docoptio.cxx @@ -115,7 +115,7 @@ void ScDocOptions::ResetDocOptions() bIsIter = FALSE; nIterCount = 100; fIterEps = 1.0E-3; - nPrecStandardFormat = 2; + nPrecStandardFormat = SvNumberFormatter::UNLIMITED_PRECISION; nDay = 30; nMonth = 12; nYear = 1899; diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx index b761dd75d9df..cb9d625da70c 100644 --- a/sc/source/ui/docshell/docsh8.cxx +++ b/sc/source/ui/docshell/docsh8.cxx @@ -597,7 +597,7 @@ void lcl_GetColumnTypes( ScDocShell& rDocShell, else if ( nDbType == sdbc::DataType::DECIMAL ) { // maximale Feldbreite und Nachkommastellen bestimmen xub_StrLen nLen; - USHORT nPrec; + sal_uInt16 nPrec; nLen = pDoc->GetMaxNumberStringLen( nPrec, nTab, nCol, nFirstDataRow, nLastRow ); // dBaseIII Limit Nachkommastellen: 15 diff --git a/sc/source/ui/inc/optdlg.hrc b/sc/source/ui/inc/optdlg.hrc index 00cfdb2c6d5a..27b8976e3541 100644 --- a/sc/source/ui/inc/optdlg.hrc +++ b/sc/source/ui/inc/optdlg.hrc @@ -70,6 +70,7 @@ #define BTN_MATCH 18 #define BTN_LOOKUP 19 #define BTN_REGEX 20 +#define BTN_GENERAL_PREC 21 // TP_VIEW: #define BTN_VSCROLL 1 diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx index 8d512898afd3..42844513af92 100644 --- a/sc/source/ui/inc/output.hxx +++ b/sc/source/ui/inc/output.hxx @@ -73,6 +73,15 @@ class ScOutputData { friend class ScDrawStringsVars; private: + struct OutputAreaParam + { + Rectangle maAlignRect; + Rectangle maClipRect; + long mnColWidth; + bool mbLeftClip; + bool mbRightClip; + }; + OutputDevice* pDev; // Device OutputDevice* pRefDevice; // printer if used for preview OutputDevice* pFmtDevice; // reference for text formatting @@ -152,19 +161,19 @@ private: void GetVisibleCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell*& rpCell ); BOOL IsAvailable( SCCOL nX, SCROW nY ); + void GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY, - SCCOL nCellX, SCROW nCellY, long nNeeded, - const ScPatternAttr& rPattern, - USHORT nHorJustify, BOOL bCellIsValue, - BOOL bBreak, BOOL bOverwrite, - Rectangle& rAlignRect, Rectangle& rClipRect, - BOOL& rLeftClip, BOOL& rRightClip ); + SCCOL nCellX, SCROW nCellY, long nNeeded, + const ScPatternAttr& rPattern, + USHORT nHorJustify, bool bCellIsValue, + bool bBreak, bool bOverwrite, + OutputAreaParam& rParam ); void ShrinkEditEngine( EditEngine& rEngine, const Rectangle& rAlignRect, long nLeftM, long nTopM, long nRightM, long nBottomM, BOOL bWidth, USHORT nOrient, long nAttrRotate, BOOL bPixelToLogic, long& rEngineWidth, long& rEngineHeight, long& rNeededPixel, - BOOL& rLeftClip, BOOL& rRightClip ); + bool& rLeftClip, bool& rRightClip ); void SetSyntaxColor( Font* pFont, ScBaseCell* pCell ); void SetEditSyntaxColor( EditEngine& rEngine, ScBaseCell* pCell ); diff --git a/sc/source/ui/inc/tpcalc.hxx b/sc/source/ui/inc/tpcalc.hxx index ea9e53a23ee4..31f2c9458c83 100644 --- a/sc/source/ui/inc/tpcalc.hxx +++ b/sc/source/ui/inc/tpcalc.hxx @@ -76,6 +76,7 @@ private: CheckBox aBtnMatch; CheckBox aBtnRegex; CheckBox aBtnLookUp; + CheckBox aBtnGeneralPrec; FixedText aFtPrec; NumericField aEdPrec; diff --git a/sc/source/ui/optdlg/tpcalc.cxx b/sc/source/ui/optdlg/tpcalc.cxx index c6423ea73b23..5b5920e904fc 100644 --- a/sc/source/ui/optdlg/tpcalc.cxx +++ b/sc/source/ui/optdlg/tpcalc.cxx @@ -88,6 +88,7 @@ ScTpCalcOptions::ScTpCalcOptions( Window* pParent, aBtnMatch ( this, ScResId( BTN_MATCH ) ), aBtnRegex ( this, ScResId( BTN_REGEX ) ), aBtnLookUp ( this, ScResId( BTN_LOOKUP ) ), + aBtnGeneralPrec ( this, ScResId( BTN_GENERAL_PREC ) ), aFtPrec ( this, ScResId( FT_PREC ) ), aEdPrec ( this, ScResId( ED_PREC ) ), pOldOptions ( new ScDocOptions( @@ -116,6 +117,7 @@ __EXPORT ScTpCalcOptions::~ScTpCalcOptions() void ScTpCalcOptions::Init() { aBtnIterate .SetClickHdl( LINK( this, ScTpCalcOptions, CheckClickHdl ) ); + aBtnGeneralPrec.SetClickHdl( LINK(this, ScTpCalcOptions, CheckClickHdl) ); aBtnDateStd .SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) ); aBtnDateSc10.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) ); aBtnDate1904.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) ); @@ -150,7 +152,6 @@ void __EXPORT ScTpCalcOptions::Reset( const SfxItemSet& /* rCoreAttrs */ ) aBtnLookUp .Check( pLocalOptions->IsLookUpColRowNames() ); aBtnIterate.Check( pLocalOptions->IsIter() ); aEdSteps .SetValue( pLocalOptions->GetIterCount() ); - aEdPrec .SetValue( pLocalOptions->GetStdPrecision() ); aEdEps .SetValue( pLocalOptions->GetIterEps(), 6 ); pLocalOptions->GetDate( d, m, y ); @@ -168,6 +169,21 @@ void __EXPORT ScTpCalcOptions::Reset( const SfxItemSet& /* rCoreAttrs */ ) break; } + sal_uInt16 nPrec = pLocalOptions->GetStdPrecision(); + if (nPrec == SvNumberFormatter::UNLIMITED_PRECISION) + { + aFtPrec.Disable(); + aEdPrec.Disable(); + aBtnGeneralPrec.Check(false); + } + else + { + aBtnGeneralPrec.Check(); + aFtPrec.Enable(); + aEdPrec.Enable(); + aEdPrec.SetValue(nPrec); + } + CheckClickHdl( &aBtnIterate ); } @@ -178,13 +194,18 @@ BOOL __EXPORT ScTpCalcOptions::FillItemSet( SfxItemSet& rCoreAttrs ) { // alle weiteren Optionen werden in den Handlern aktualisiert pLocalOptions->SetIterCount( (USHORT)aEdSteps.GetValue() ); - pLocalOptions->SetStdPrecision( (USHORT)aEdPrec.GetValue() ); pLocalOptions->SetIgnoreCase( !aBtnCase.IsChecked() ); pLocalOptions->SetCalcAsShown( aBtnCalc.IsChecked() ); pLocalOptions->SetMatchWholeCell( aBtnMatch.IsChecked() ); pLocalOptions->SetFormulaRegexEnabled( aBtnRegex.IsChecked() ); pLocalOptions->SetLookUpColRowNames( aBtnLookUp.IsChecked() ); + if (aBtnGeneralPrec.IsChecked()) + pLocalOptions->SetStdPrecision( + static_cast<sal_uInt16>(aEdPrec.GetValue()) ); + else + pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION ); + if ( *pLocalOptions != *pOldOptions ) { rCoreAttrs.Put( ScTpCalcItem( nWhichCalc, *pLocalOptions ) ); @@ -245,19 +266,35 @@ IMPL_LINK( ScTpCalcOptions, RadioClickHdl, RadioButton*, pBtn ) //----------------------------------------------------------------------- -IMPL_LINK( ScTpCalcOptions, CheckClickHdl, CheckBox*, pBtn ) +IMPL_LINK( ScTpCalcOptions, CheckClickHdl, CheckBox*, pBtn ) { - if ( pBtn->IsChecked() ) + if (pBtn == &aBtnGeneralPrec) { - pLocalOptions->SetIter( TRUE ); - aFtSteps.Enable(); aEdSteps.Enable(); - aFtEps .Enable(); aEdEps .Enable(); + if (pBtn->IsChecked()) + { + aEdPrec.Enable(); + aFtPrec.Enable(); + } + else + { + aEdPrec.Disable(); + aFtPrec.Disable(); + } } - else + else if (pBtn == &aBtnIterate) { - pLocalOptions->SetIter( FALSE ); - aFtSteps.Disable(); aEdSteps.Disable(); - aFtEps .Disable(); aEdEps .Disable(); + if ( pBtn->IsChecked() ) + { + pLocalOptions->SetIter( TRUE ); + aFtSteps.Enable(); aEdSteps.Enable(); + aFtEps .Enable(); aEdEps .Enable(); + } + else + { + pLocalOptions->SetIter( FALSE ); + aFtSteps.Disable(); aEdSteps.Disable(); + aFtEps .Disable(); aEdEps .Disable(); + } } return 0; diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src index 856463e27e40..ea7cabf7716d 100644 --- a/sc/source/ui/src/optdlg.src +++ b/sc/source/ui/src/optdlg.src @@ -119,22 +119,6 @@ TabPage RID_SCPAGE_CALC Pos = MAP_APPFONT ( 6 , 64 ) ; Size = MAP_APPFONT ( 248 , 8 ) ; }; - FixedText FT_PREC - { - Pos = MAP_APPFONT ( 150 , 77 ) ; - Size = MAP_APPFONT ( 72 , 8 ) ; - Text [ en-US ] = "~Decimal places" ; - Right = TRUE ; - }; - NumericField ED_PREC - { - Border = TRUE ; - Pos = MAP_APPFONT ( 226 , 75 ) ; - Size = MAP_APPFONT ( 25 , 12 ) ; - Maximum = 20 ; - Spin = TRUE ; - Repeat = TRUE ; - }; CheckBox BTN_CASE { Pos = MAP_APPFONT ( 12 , 77 ) ; @@ -165,6 +149,28 @@ TabPage RID_SCPAGE_CALC Size = MAP_APPFONT ( 239 , 10 ) ; Text [ en-US ] = "~Automatically find column and row labels " ; }; + CheckBox BTN_GENERAL_PREC + { + Pos = MAP_APPFONT ( 12 , 147 ) ; + Size = MAP_APPFONT ( 136 , 10 ) ; + Text [ en-US ] = "Limit decimals for general number format" ; + }; + FixedText FT_PREC + { + Pos = MAP_APPFONT ( 150 , 148 ) ; + Size = MAP_APPFONT ( 72 , 8 ) ; + Text [ en-US ] = "~Decimal places" ; + Right = TRUE ; + }; + NumericField ED_PREC + { + Border = TRUE ; + Pos = MAP_APPFONT ( 226 , 146 ) ; + Size = MAP_APPFONT ( 25 , 12 ) ; + Maximum = 20 ; + Spin = TRUE ; + Repeat = TRUE ; + }; }; /**************************************************************************/ diff --git a/sc/source/ui/unoobj/defltuno.cxx b/sc/source/ui/unoobj/defltuno.cxx index 141a7d0abb73..f3f76685e5cb 100644 --- a/sc/source/ui/unoobj/defltuno.cxx +++ b/sc/source/ui/unoobj/defltuno.cxx @@ -46,6 +46,8 @@ #include "unonames.hxx" #include "docoptio.hxx" +#include <limits> + using namespace ::com::sun::star; //------------------------------------------------------------------------ @@ -157,7 +159,7 @@ void SAL_CALL ScDocDefaultsObj::setPropertyValue( sal_Int16 nValue = 0; if (aValue >>= nValue) { - aDocOpt.SetStdPrecision(static_cast<sal_uInt8> (nValue)); + aDocOpt.SetStdPrecision(static_cast<sal_uInt16> (nValue)); pDoc->SetDocOptions(aDocOpt); } } @@ -250,7 +252,12 @@ uno::Any SAL_CALL ScDocDefaultsObj::getPropertyValue( const rtl::OUString& aProp if (pDoc) { const ScDocOptions& aDocOpt = pDoc->GetDocOptions(); - aRet <<= static_cast<sal_Int16> (aDocOpt.GetStdPrecision()); + sal_uInt16 nPrec = aDocOpt.GetStdPrecision(); + // the max value of unsigned 16-bit integer is used as the flag + // value for unlimited precision, c.f. + // SvNumberFormatter::UNLIMITED_PRECISION. + if (nPrec <= ::std::numeric_limits<sal_Int16>::max()) + aRet <<= static_cast<sal_Int16> (nPrec); } else throw uno::RuntimeException(); diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 53851f0e3cf0..102bb56463b6 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -53,6 +53,7 @@ #include <editeng/udlnitem.hxx> #include <editeng/unolingu.hxx> #include <svl/zforlist.hxx> +#include <svl/zformat.hxx> #include <vcl/svapp.hxx> #include <vcl/metric.hxx> #include <vcl/outdev.hxx> @@ -74,6 +75,8 @@ #include "scmod.hxx" #include "fillinfo.hxx" +#include <boost/ptr_container/ptr_vector.hpp> + #include <math.h> //! Autofilter-Breite mit column.cxx zusammenfassen @@ -108,6 +111,9 @@ class ScDrawStringsVars String aString; // Inhalte Size aTextSize; long nOriginalWidth; + long nMaxDigitWidth; + long nSignWidth; + long nDotWidth; ScBaseCell* pLastCell; ULONG nValueFormat; @@ -132,7 +138,7 @@ public: void SetPatternSimple( const ScPatternAttr* pNew, const SfxItemSet* pSet ); BOOL SetText( ScBaseCell* pCell ); // TRUE -> pOldPattern vergessen - void SetHashText(); + void SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ); void SetAutoText( const String& rAutoText ); const ScPatternAttr* GetPattern() const { return pPattern; } @@ -161,6 +167,14 @@ public: pCondSet->GetItemState( ATTR_FONT_HEIGHT, TRUE ); } BOOL HasEditCharacters() const; + +private: + void SetHashText(); + long GetMaxDigitWidth(); + long GetSignWidth(); + long GetDotWidth(); + void TextChanged(); + long ConvertWidthLogicToPixel( long nWidth ) const; }; //================================================================== @@ -176,6 +190,9 @@ ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, BOOL bPTL) : nIndent ( 0 ), bRotated ( FALSE ), nOriginalWidth( 0 ), + nMaxDigitWidth( 0 ), + nSignWidth( 0 ), + nDotWidth( 0 ), pLastCell ( NULL ), nValueFormat( 0 ), bLineBreak ( FALSE ), @@ -242,6 +259,10 @@ void ScDrawStringsVars::SetShrinkScale( long nScale, BYTE nScript ) void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* pSet, ScBaseCell* pCell, BYTE nScript ) { + nMaxDigitWidth = 0; + nSignWidth = 0; + nDotWidth = 0; + pPattern = pNew; pCondSet = pSet; @@ -393,6 +414,9 @@ void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxItemSet* pSet ) { + nMaxDigitWidth = 0; + nSignWidth = 0; + nDotWidth = 0; // wird gerufen, wenn sich die Font-Variablen nicht aendern (!StringDiffer) pPattern = pNew; @@ -467,28 +491,7 @@ BOOL ScDrawStringsVars::SetText( ScBaseCell* pCell ) pLastCell = NULL; // naechstes Mal wieder hierherkommen } - OutputDevice* pRefDevice = pOutput->pRefDevice; - OutputDevice* pFmtDevice = pOutput->pFmtDevice; - aTextSize.Width() = pFmtDevice->GetTextWidth( aString ); - aTextSize.Height() = pFmtDevice->GetTextHeight(); - - if ( !pRefDevice->GetConnectMetaFile() || pRefDevice->GetOutDevType() == OUTDEV_PRINTER ) - { - double fMul = pOutput->GetStretch(); - aTextSize.Width() = (long)(aTextSize.Width() / fMul + 0.5); - } - - aTextSize.Height() = aMetric.GetAscent() + aMetric.GetDescent(); - if ( GetOrient() != SVX_ORIENTATION_STANDARD ) - { - long nTemp = aTextSize.Height(); - aTextSize.Height() = aTextSize.Width(); - aTextSize.Width() = nTemp; - } - - nOriginalWidth = aTextSize.Width(); - if ( bPixelToLogic ) - aTextSize = pRefDevice->LogicToPixel( aTextSize ); + TextChanged(); } // sonst String/Groesse behalten } @@ -508,6 +511,82 @@ void ScDrawStringsVars::SetHashText() SetAutoText( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("###")) ); } +void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) +{ + if (!pCell) + return; + + CellType eType = pCell->GetCellType(); + if (eType != CELLTYPE_VALUE && eType != CELLTYPE_FORMULA) + // must be a value or formula cell. + return; + + if (eType == CELLTYPE_FORMULA && !static_cast<ScFormulaCell*>(pCell)->IsValue()) + // If it's formula, the result must be a value. + return; + + ULONG nFormat = GetValueFormat(); + if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0) + { + // Not 'General' number format. Set hash text and bail out. + SetHashText(); + return; + } + + double fVal = (eType == CELLTYPE_VALUE) ? + static_cast<ScValueCell*>(pCell)->GetValue() : static_cast<ScFormulaCell*>(pCell)->GetValue(); + + const SvNumberformat* pNumFormat = pOutput->pDoc->GetFormatTable()->GetEntry(nFormat); + if (!pNumFormat) + return; + + long nMaxDigit = GetMaxDigitWidth(); + sal_uInt16 nNumDigits = static_cast<sal_uInt16>(nWidth / nMaxDigit); + + if (!pNumFormat->GetOutputString(fVal, nNumDigits, aString)) + // Failed to get output string. Bail out. + return; + + sal_uInt8 nSignCount = 0, nDecimalCount = 0; + xub_StrLen nLen = aString.Len(); + sal_Unicode cDecSep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator.getStr()[0]; + for (xub_StrLen i = 0; i < nLen; ++i) + { + sal_Unicode c = aString.GetChar(i); + if (c == sal_Unicode('-')) + ++nSignCount; + else if (c == cDecSep) + ++nDecimalCount; + } + if (nDecimalCount) + nWidth += (nMaxDigit - GetDotWidth()) * nDecimalCount; + if (nSignCount) + nWidth += (nMaxDigit - GetSignWidth()) * nSignCount; + + if (nDecimalCount || nSignCount) + { + // Re-calculate. + nNumDigits = static_cast<sal_uInt16>(nWidth / nMaxDigit); + if (!pNumFormat->GetOutputString(fVal, nNumDigits, aString)) + // Failed to get output string. Bail out. + return; + } + + long nActualTextWidth = pOutput->pFmtDevice->GetTextWidth(aString); + + if (bPixelToLogic) + nActualTextWidth = ConvertWidthLogicToPixel(nActualTextWidth); + + if (nActualTextWidth > nWidth) + { + // Even after the decimal adjustment the text doesn't fit. Give up. + SetHashText(); + return; + } + + TextChanged(); +} + void ScDrawStringsVars::SetAutoText( const String& rAutoText ) { aString = rAutoText; @@ -538,6 +617,80 @@ void ScDrawStringsVars::SetAutoText( const String& rAutoText ) pLastCell = NULL; // derselbe Text kann in der naechsten Zelle wieder passen } +long ScDrawStringsVars::GetMaxDigitWidth() +{ + if (nMaxDigitWidth > 0) + return nMaxDigitWidth; + + sal_Char cZero = '0'; + for (int i = 0; i < 10; ++i) + { + sal_Char cDigit = cZero + i; + long n = pOutput->pFmtDevice->GetTextWidth(String(cDigit)); + nMaxDigitWidth = ::std::max(nMaxDigitWidth, n); + } + + if (bPixelToLogic) + nMaxDigitWidth = ConvertWidthLogicToPixel(nMaxDigitWidth); + return nMaxDigitWidth; +} + +long ScDrawStringsVars::GetSignWidth() +{ + if (nSignWidth > 0) + return nSignWidth; + + nSignWidth = pOutput->pFmtDevice->GetTextWidth(String('-')); + if (bPixelToLogic) + nSignWidth = ConvertWidthLogicToPixel(nSignWidth); + return nSignWidth; +} + +long ScDrawStringsVars::GetDotWidth() +{ + if (nDotWidth > 0) + return nDotWidth; + + const ::rtl::OUString& sep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator; + nDotWidth = pOutput->pFmtDevice->GetTextWidth(sep); + if (bPixelToLogic) + nDotWidth = ConvertWidthLogicToPixel(nDotWidth); + return nDotWidth; +} + +void ScDrawStringsVars::TextChanged() +{ + OutputDevice* pRefDevice = pOutput->pRefDevice; + OutputDevice* pFmtDevice = pOutput->pFmtDevice; + aTextSize.Width() = pFmtDevice->GetTextWidth( aString ); + aTextSize.Height() = pFmtDevice->GetTextHeight(); + + if ( !pRefDevice->GetConnectMetaFile() || pRefDevice->GetOutDevType() == OUTDEV_PRINTER ) + { + double fMul = pOutput->GetStretch(); + aTextSize.Width() = (long)(aTextSize.Width() / fMul + 0.5); + } + + aTextSize.Height() = aMetric.GetAscent() + aMetric.GetDescent(); + if ( GetOrient() != SVX_ORIENTATION_STANDARD ) + { + long nTemp = aTextSize.Height(); + aTextSize.Height() = aTextSize.Width(); + aTextSize.Width() = nTemp; + } + + nOriginalWidth = aTextSize.Width(); + if ( bPixelToLogic ) + aTextSize = pRefDevice->LogicToPixel( aTextSize ); +} + +long ScDrawStringsVars::ConvertWidthLogicToPixel( long nWidth ) const +{ + Size aSize(nWidth, pOutput->pFmtDevice->GetTextHeight()); + aSize = pOutput->pRefDevice->LogicToPixel(aSize); + return aSize.Width(); +} + BOOL ScDrawStringsVars::HasEditCharacters() const { static const sal_Unicode pChars[] = @@ -919,18 +1072,14 @@ BOOL ScOutputData::IsAvailable( SCCOL nX, SCROW nY ) // bCellIsValue: if set, don't extend into empty cells // bBreak: if set, don't extend, and don't set clip marks (but rLeftClip/rRightClip is set) // bOverwrite: if set, also extend into non-empty cells (for rotated text) -// rAlignRect: output: single or merged cell, used for alignment (visual rectangle) -// rClipRect: output: total output area, for clipping (visual) -// rLeftClip: output: need to clip at rClipRect left (visual) edge -// rRightClip: output: same for right +// rParam output: various area parameters. void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY, - SCCOL nCellX, SCROW nCellY, long nNeeded, - const ScPatternAttr& rPattern, - USHORT nHorJustify, BOOL bCellIsValue, - BOOL bBreak, BOOL bOverwrite, - Rectangle& rAlignRect, Rectangle& rClipRect, - BOOL& rLeftClip, BOOL& rRightClip ) + SCCOL nCellX, SCROW nCellY, long nNeeded, + const ScPatternAttr& rPattern, + USHORT nHorJustify, bool bCellIsValue, + bool bBreak, bool bOverwrite, + OutputAreaParam& rParam ) { // rThisRowInfo may be for a different row than nCellY, is still used for clip marks RowInfo& rThisRowInfo = pRowInfo[nArrY]; @@ -1009,21 +1158,23 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY --nMergeSizeX; // leave out the grid horizontally, also for alignment (align between grid lines) + rParam.mnColWidth = nMergeSizeX; // store the actual column width. + // // construct the rectangles using logical left/right values (justify is called at the end) // // rAlignRect is the single cell or merged area, used for alignment. - rAlignRect.Left() = nCellPosX; - rAlignRect.Right() = nCellPosX + ( nMergeSizeX - 1 ) * nLayoutSign; - rAlignRect.Top() = nCellPosY; - rAlignRect.Bottom() = nCellPosY + nMergeSizeY - 1; + rParam.maAlignRect.Left() = nCellPosX; + rParam.maAlignRect.Right() = nCellPosX + ( nMergeSizeX - 1 ) * nLayoutSign; + rParam.maAlignRect.Top() = nCellPosY; + rParam.maAlignRect.Bottom() = nCellPosY + nMergeSizeY - 1; // rClipRect is all cells that are used for output. // For merged cells this is the same as rAlignRect, otherwise neighboring cells can also be used. - rClipRect = rAlignRect; + rParam.maClipRect = rParam.maAlignRect; if ( nNeeded > nMergeSizeX ) { SvxCellHorJustify eHorJust = (SvxCellHorJustify)nHorJustify; @@ -1064,7 +1215,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY ++nRightX; long nAdd = (long) ( pDoc->GetColWidth( nRightX, nTab ) * nPPTX ); nRightMissing -= nAdd; - rClipRect.Right() += nAdd * nLayoutSign; + rParam.maClipRect.Right() += nAdd * nLayoutSign; if ( rThisRowInfo.nRowNo == nCellY && nRightX >= nX1 && nRightX <= nX2 ) rThisRowInfo.pCellInfo[nRightX].bHideGrid = TRUE; @@ -1078,7 +1229,7 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY --nLeftX; long nAdd = (long) ( pDoc->GetColWidth( nLeftX, nTab ) * nPPTX ); nLeftMissing -= nAdd; - rClipRect.Left() -= nAdd * nLayoutSign; + rParam.maClipRect.Left() -= nAdd * nLayoutSign; } } @@ -1089,22 +1240,22 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY rThisRowInfo.pCellInfo[nRightX+1].nClipMark |= SC_CLIPMARK_RIGHT; bAnyClipped = TRUE; long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX ); - rClipRect.Right() -= nMarkPixel * nLayoutSign; + rParam.maClipRect.Right() -= nMarkPixel * nLayoutSign; } if ( nLeftMissing > 0 && bMarkClipped && nLeftX >= nX1 && nLeftX <= nX2 && !bBreak && !bCellIsValue ) { rThisRowInfo.pCellInfo[nLeftX+1].nClipMark |= SC_CLIPMARK_LEFT; bAnyClipped = TRUE; long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX ); - rClipRect.Left() += nMarkPixel * nLayoutSign; + rParam.maClipRect.Left() += nMarkPixel * nLayoutSign; } - rLeftClip = ( nLeftMissing > 0 ); - rRightClip = ( nRightMissing > 0 ); + rParam.mbLeftClip = ( nLeftMissing > 0 ); + rParam.mbRightClip = ( nRightMissing > 0 ); } else { - rLeftClip = rRightClip = FALSE; + rParam.mbLeftClip = rParam.mbRightClip = FALSE; // leave space for AutoFilter on screen // (for automatic line break: only if not formatting for printer, as in ScColumn::GetNeededSize) @@ -1120,30 +1271,30 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY // content fits even in the remaining area without the filter button // -> align within that remaining area - rAlignRect.Right() -= nFilter * nLayoutSign; - rClipRect.Right() -= nFilter * nLayoutSign; + rParam.maAlignRect.Right() -= nFilter * nLayoutSign; + rParam.maClipRect.Right() -= nFilter * nLayoutSign; // if a number doesn't fit, don't hide part of the number behind the button // -> set clip flags, so "###" replacement is used (but also within the smaller area) if ( !bFit ) - rLeftClip = rRightClip = TRUE; + rParam.mbLeftClip = rParam.mbRightClip = TRUE; } } } // justify both rectangles for alignment calculation, use with DrawText etc. - rAlignRect.Justify(); - rClipRect.Justify(); + rParam.maAlignRect.Justify(); + rParam.maClipRect.Justify(); #if 0 //! Test !!! pDev->Push(); pDev->SetLineColor(); pDev->SetFillColor( COL_LIGHTGREEN ); - pDev->DrawRect( pDev->PixelToLogic(rClipRect) ); - pDev->DrawRect( rClipRect ); // print preview + pDev->DrawRect( pDev->PixelToLogic(rParam.maClipRect) ); + pDev->DrawRect( rParam.maClipRect ); // print preview pDev->Pop(); //! Test !!! #endif @@ -1164,10 +1315,6 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) ScDrawStringsVars aVars( this, bPixelToLogic ); - const ScPatternAttr* pOldPattern = NULL; - const SfxItemSet* pOldCondSet = NULL; - BYTE nOldScript = 0; - BOOL bProgress = FALSE; long nInitPosX = nScrX; @@ -1184,15 +1331,19 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) --nLoopStartX; // start before nX1 for rest of long text to the left // variables for GetOutputArea + OutputAreaParam aAreaParam; BOOL bCellIsValue = FALSE; - BOOL bLeftClip = FALSE; - BOOL bRightClip = FALSE; long nNeededWidth = 0; - Rectangle aAlignRect; - Rectangle aClipRect; SvxCellHorJustify eOutHorJust = SVX_HOR_JUSTIFY_STANDARD; const ScPatternAttr* pPattern = NULL; const SfxItemSet* pCondSet = NULL; + const ScPatternAttr* pOldPattern = NULL; + const SfxItemSet* pOldCondSet = NULL; + BYTE nOldScript = 0; + + // alternative pattern instances in case we need to modify the pattern + // before processing the cell value. + ::boost::ptr_vector<ScPatternAttr> aAltPatterns; long nPosY = nScrY; for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++) @@ -1330,6 +1481,18 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) pCondSet = pDoc->GetCondResult( nCellX, nCellY, nTab ); } + if (pCell->HasValueData() && + static_cast<const SfxBoolItem&>( + pPattern->GetItem(ATTR_LINEBREAK, pCondSet)).GetValue()) + { + // Disable line break when the cell content is numeric. + aAltPatterns.push_back(new ScPatternAttr(*pPattern)); + ScPatternAttr* pAltPattern = &aAltPatterns.back(); + SfxBoolItem aLineBreak(ATTR_LINEBREAK, false); + pAltPattern->GetItemSet().Put(aLineBreak); + pPattern = pAltPattern; + } + BYTE nScript = GetScriptType( pDoc, pCell, pPattern, pCondSet ); if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); if ( pPattern != pOldPattern || pCondSet != pOldCondSet || @@ -1360,6 +1523,7 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) bNeedEdit = aVars.HasEditCharacters() || (bFormulaCell && ((ScFormulaCell*)pCell)->IsMultilineResult()); } + long nTotalMargin = 0; if (bDoCell && !bNeedEdit) { CellType eCellType = pCell->GetCellType(); @@ -1381,14 +1545,17 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) BOOL bRepeat = aVars.IsRepeat() && !bBreak; BOOL bShrink = aVars.IsShrink() && !bBreak && !bRepeat; - long nTotalMargin = (long) ( aVars.GetLeftTotal() * nPPTX ) + - (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ); + nTotalMargin = + static_cast<long>(aVars.GetLeftTotal() * nPPTX) + + static_cast<long>(aVars.GetMargin()->GetRightMargin() * nPPTX); + nNeededWidth = aVars.GetTextSize().Width() + nTotalMargin; + // GetOutputArea gives justfied rectangles GetOutputArea( nX, nArrY, nPosX, nPosY, nCellX, nCellY, nNeededWidth, - *pPattern, sal::static_int_cast<USHORT>(eOutHorJust), - bCellIsValue || bRepeat || bShrink, bBreak, FALSE, - aAlignRect, aClipRect, bLeftClip, bRightClip ); + *pPattern, sal::static_int_cast<USHORT>(eOutHorJust), + bCellIsValue || bRepeat || bShrink, bBreak, FALSE, + aAreaParam ); if ( bShrink ) { @@ -1398,9 +1565,9 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) // DrawEdit is used to vertically scale 90 deg rotated text. bNeedEdit = TRUE; } - else if ( bLeftClip || bRightClip ) // horizontal + else if ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip ) // horizontal { - long nAvailable = aAlignRect.GetWidth() - nTotalMargin; + long nAvailable = aAreaParam.maAlignRect.GetWidth() - nTotalMargin; long nScaleSize = aVars.GetTextSize().Width(); // without margin if ( nScaleSize > 0 ) // 0 if the text is empty (formulas, number formats) @@ -1424,16 +1591,16 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) // If even at half the size the font still isn't rendered smaller, // fall back to normal clipping (showing ### for numbers). if ( nNewSize <= nAvailable ) - bLeftClip = bRightClip = FALSE; + aAreaParam.mbLeftClip = aAreaParam.mbRightClip = FALSE; pOldPattern = NULL; } } } - if ( bRepeat && !bLeftClip && !bRightClip ) + if ( bRepeat && !aAreaParam.mbLeftClip && !aAreaParam.mbRightClip ) { - long nAvailable = aAlignRect.GetWidth() - nTotalMargin; + long nAvailable = aAreaParam.maAlignRect.GetWidth() - nTotalMargin; long nRepeatSize = aVars.GetTextSize().Width(); // without margin // When formatting for the printer, the text sizes don't always add up. // Round down (too few repetitions) rather than exceeding the cell size then: @@ -1457,13 +1624,13 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) if ( bBreak ) { if ( aVars.GetOrient() == SVX_ORIENTATION_STANDARD ) - bNeedEdit = ( bLeftClip || bRightClip ); + bNeedEdit = ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip ); else { long nHeight = aVars.GetTextSize().Height() + (long)(aVars.GetMargin()->GetTopMargin()*nPPTY) + (long)(aVars.GetMargin()->GetBottomMargin()*nPPTY); - bNeedEdit = ( nHeight > aClipRect.GetHeight() ); + bNeedEdit = ( nHeight > aAreaParam.maClipRect.GetHeight() ); } } } @@ -1479,48 +1646,49 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) } if ( bDoCell ) { - if ( bCellIsValue && ( bLeftClip || bRightClip ) ) + if ( bCellIsValue && ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip ) ) { - aVars.SetHashText(); + // Adjust the decimals to fit the available column width. + aVars.SetTextToWidthOrHash(pCell, aAreaParam.mnColWidth - nTotalMargin); nNeededWidth = aVars.GetTextSize().Width() + (long) ( aVars.GetLeftTotal() * nPPTX ) + (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ); - if ( nNeededWidth <= aClipRect.GetWidth() ) - bLeftClip = bRightClip = FALSE; + if ( nNeededWidth <= aAreaParam.maClipRect.GetWidth() ) + aAreaParam.mbLeftClip = aAreaParam.mbRightClip = FALSE; // If the "###" replacement doesn't fit into the cells, no clip marks // are shown, as the "###" already denotes too little space. // The rectangles from the first GetOutputArea call remain valid. } - long nJustPosX = aAlignRect.Left(); // "justified" - effect of alignment will be added - long nJustPosY = aAlignRect.Top(); - long nAvailWidth = aAlignRect.GetWidth(); - long nOutHeight = aAlignRect.GetHeight(); + long nJustPosX = aAreaParam.maAlignRect.Left(); // "justified" - effect of alignment will be added + long nJustPosY = aAreaParam.maAlignRect.Top(); + long nAvailWidth = aAreaParam.maAlignRect.GetWidth(); + long nOutHeight = aAreaParam.maAlignRect.GetHeight(); - BOOL bOutside = ( aClipRect.Right() < nScrX || aClipRect.Left() >= nScrX + nScrW ); - if ( aClipRect.Left() < nScrX ) + BOOL bOutside = ( aAreaParam.maClipRect.Right() < nScrX || aAreaParam.maClipRect.Left() >= nScrX + nScrW ); + if ( aAreaParam.maClipRect.Left() < nScrX ) { - aClipRect.Left() = nScrX; - bLeftClip = TRUE; + aAreaParam.maClipRect.Left() = nScrX; + aAreaParam.mbLeftClip = TRUE; } - if ( aClipRect.Right() > nScrX + nScrW ) + if ( aAreaParam.maClipRect.Right() > nScrX + nScrW ) { - aClipRect.Right() = nScrX + nScrW; //! minus one? - bRightClip = TRUE; + aAreaParam.maClipRect.Right() = nScrX + nScrW; //! minus one? + aAreaParam.mbRightClip = TRUE; } - BOOL bHClip = bLeftClip || bRightClip; + BOOL bHClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip; BOOL bVClip = FALSE; - if ( aClipRect.Top() < nScrY ) + if ( aAreaParam.maClipRect.Top() < nScrY ) { - aClipRect.Top() = nScrY; + aAreaParam.maClipRect.Top() = nScrY; bVClip = TRUE; } - if ( aClipRect.Bottom() > nScrY + nScrH ) + if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH ) { - aClipRect.Bottom() = nScrY + nScrH; //! minus one? + aAreaParam.maClipRect.Bottom() = nScrY + nScrH; //! minus one? bVClip = TRUE; } @@ -1603,27 +1771,27 @@ void ScOutputData::DrawStrings( BOOL bPixelToLogic ) if (!bHClip) { - aClipRect.Left() = nScrX; - aClipRect.Right() = nScrX+nScrW; + aAreaParam.maClipRect.Left() = nScrX; + aAreaParam.maClipRect.Right() = nScrX+nScrW; } if (!bVClip) { - aClipRect.Top() = nScrY; - aClipRect.Bottom() = nScrY+nScrH; + aAreaParam.maClipRect.Top() = nScrY; + aAreaParam.maClipRect.Bottom() = nScrY+nScrH; } // aClipRect is not used after SetClipRegion/IntersectClipRegion, // so it can be modified here if (bPixelToLogic) - aClipRect = pRefDevice->PixelToLogic( aClipRect ); + aAreaParam.maClipRect = pRefDevice->PixelToLogic( aAreaParam.maClipRect ); if (bMetaFile) { pDev->Push(); - pDev->IntersectClipRegion( aClipRect ); + pDev->IntersectClipRegion( aAreaParam.maClipRect ); } else - pDev->SetClipRegion( Region( aClipRect ) ); + pDev->SetClipRegion( Region( aAreaParam.maClipRect ) ); } Point aURLStart( nJustPosX, nJustPosY ); // copy before modifying for orientation @@ -1827,7 +1995,7 @@ long lcl_GetEditSize( EditEngine& rEngine, BOOL bWidth, BOOL bSwap, long nAttrRo void ScOutputData::ShrinkEditEngine( EditEngine& rEngine, const Rectangle& rAlignRect, long nLeftM, long nTopM, long nRightM, long nBottomM, BOOL bWidth, USHORT nOrient, long nAttrRotate, BOOL bPixelToLogic, - long& rEngineWidth, long& rEngineHeight, long& rNeededPixel, BOOL& rLeftClip, BOOL& rRightClip ) + long& rEngineWidth, long& rEngineHeight, long& rNeededPixel, bool& rLeftClip, bool& rRightClip ) { if ( !bWidth ) { @@ -2149,10 +2317,7 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) nPosY = nScrY; } - Rectangle aAlignRect; - Rectangle aClipRect; - BOOL bLeftClip = FALSE; - BOOL bRightClip = FALSE; + OutputAreaParam aAreaParam; // // Initial page size - large for normal text, cell size for automatic line breaks @@ -2167,23 +2332,22 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) //! handle nArrY == 0 GetOutputArea( nXForPos, nArrYForPos, nPosX, nPosY, nCellX, nCellY, 0, - *pPattern, sal::static_int_cast<USHORT>(eOutHorJust), - bCellIsValue, TRUE, FALSE, - aAlignRect, aClipRect, bLeftClip, bRightClip ); + *pPattern, sal::static_int_cast<USHORT>(eOutHorJust), + bCellIsValue, true, false, aAreaParam ); //! special ScEditUtil handling if formatting for printer if ( eOrient == SVX_ORIENTATION_TOPBOTTOM || eOrient == SVX_ORIENTATION_BOTTOMTOP ) - aPaperSize.Width() = aAlignRect.GetHeight() - nTopM - nBottomM; + aPaperSize.Width() = aAreaParam.maAlignRect.GetHeight() - nTopM - nBottomM; else - aPaperSize.Width() = aAlignRect.GetWidth() - nLeftM - nRightM; + aPaperSize.Width() = aAreaParam.maAlignRect.GetWidth() - nLeftM - nRightM; if (bAsianVertical && bBreak) { // add some extra height (default margin value) for safety // as long as GetEditArea isn't used below long nExtraHeight = (long)( 20 * nPPTY ); - aPaperSize.Height() = aAlignRect.GetHeight() - nTopM - nBottomM + nExtraHeight; + aPaperSize.Height() = aAreaParam.maAlignRect.GetHeight() - nTopM - nBottomM + nExtraHeight; } } if (bPixelToLogic) @@ -2372,26 +2536,26 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) { // for break, the first GetOutputArea call is sufficient GetOutputArea( nXForPos, nArrYForPos, nPosX, nPosY, nCellX, nCellY, nNeededPixel, - *pPattern, sal::static_int_cast<USHORT>(eOutHorJust), - bCellIsValue || bRepeat || bShrink, FALSE, FALSE, - aAlignRect, aClipRect, bLeftClip, bRightClip ); + *pPattern, sal::static_int_cast<USHORT>(eOutHorJust), + bCellIsValue || bRepeat || bShrink, false, false, aAreaParam ); if ( bShrink ) { BOOL bWidth = ( eOrient == SVX_ORIENTATION_STANDARD && !bAsianVertical ); - ShrinkEditEngine( *pEngine, aAlignRect, + ShrinkEditEngine( *pEngine, aAreaParam.maAlignRect, nLeftM, nTopM, nRightM, nBottomM, bWidth, sal::static_int_cast<USHORT>(eOrient), 0, bPixelToLogic, - nEngineWidth, nEngineHeight, nNeededPixel, bLeftClip, bRightClip ); + nEngineWidth, nEngineHeight, nNeededPixel, + aAreaParam.mbLeftClip, aAreaParam.mbRightClip ); } - if ( bRepeat && !bLeftClip && !bRightClip && pEngine->GetParagraphCount() == 1 ) + if ( bRepeat && !aAreaParam.mbLeftClip && !aAreaParam.mbRightClip && pEngine->GetParagraphCount() == 1 ) { // First check if twice the space for the formatted text is available // (otherwise just keep it unchanged). long nFormatted = nNeededPixel - nLeftM - nRightM; // without margin - long nAvailable = aAlignRect.GetWidth() - nLeftM - nRightM; + long nAvailable = aAreaParam.maAlignRect.GetWidth() - nLeftM - nRightM; if ( nAvailable >= 2 * nFormatted ) { // "repeat" is handled with unformatted text (for performance reasons) @@ -2425,7 +2589,7 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) } } - if ( bCellIsValue && ( bLeftClip || bRightClip ) ) + if ( bCellIsValue && ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip ) ) { pEngine->SetText( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("###")) ); nEngineWidth = (long) pEngine->CalcTextWidth(); @@ -2448,11 +2612,11 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) } } - long nStartX = aAlignRect.Left(); - long nStartY = aAlignRect.Top(); - long nCellWidth = aAlignRect.GetWidth(); + long nStartX = aAreaParam.maAlignRect.Left(); + long nStartY = aAreaParam.maAlignRect.Top(); + long nCellWidth = aAreaParam.maAlignRect.GetWidth(); long nOutWidth = nCellWidth - 1 - nLeftM - nRightM; - long nOutHeight = aAlignRect.GetHeight() - nTopM - nBottomM; + long nOutHeight = aAreaParam.maAlignRect.GetHeight() - nTopM - nBottomM; if ( bBreak || eOrient != SVX_ORIENTATION_STANDARD || bAsianVertical ) { @@ -2472,21 +2636,21 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) nStartX += nLeftM; } - BOOL bOutside = ( aClipRect.Right() < nScrX || aClipRect.Left() >= nScrX + nScrW ); - if ( aClipRect.Left() < nScrX ) + BOOL bOutside = ( aAreaParam.maClipRect.Right() < nScrX || aAreaParam.maClipRect.Left() >= nScrX + nScrW ); + if ( aAreaParam.maClipRect.Left() < nScrX ) { - aClipRect.Left() = nScrX; - bLeftClip = TRUE; + aAreaParam.maClipRect.Left() = nScrX; + aAreaParam.mbLeftClip = true; } - if ( aClipRect.Right() > nScrX + nScrW ) + if ( aAreaParam.maClipRect.Right() > nScrX + nScrW ) { - aClipRect.Right() = nScrX + nScrW; //! minus one? - bRightClip = TRUE; + aAreaParam.maClipRect.Right() = nScrX + nScrW; //! minus one? + aAreaParam.mbRightClip = true; } if ( !bHidden && !bOutside ) { - BOOL bClip = bLeftClip || bRightClip; + bool bClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip; BOOL bSimClip = FALSE; if ( bWrapFields ) @@ -2495,14 +2659,14 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) bClip = TRUE; } - if ( aClipRect.Top() < nScrY ) + if ( aAreaParam.maClipRect.Top() < nScrY ) { - aClipRect.Top() = nScrY; + aAreaParam.maClipRect.Top() = nScrY; bClip = TRUE; } - if ( aClipRect.Bottom() > nScrY + nScrH ) + if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH ) { - aClipRect.Bottom() = nScrY + nScrH; //! minus one? + aAreaParam.maClipRect.Bottom() = nScrY + nScrH; //! minus one? bClip = TRUE; } @@ -2554,8 +2718,8 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) bAnyClipped = TRUE; long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX ); - if ( aClipRect.Right() - nMarkPixel > aClipRect.Left() ) - aClipRect.Right() -= nMarkPixel; + if ( aAreaParam.maClipRect.Right() - nMarkPixel > aAreaParam.maClipRect.Left() ) + aAreaParam.maClipRect.Right() -= nMarkPixel; } } @@ -2579,9 +2743,9 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic) // Clip marks are already handled in GetOutputArea if (bPixelToLogic) - aLogicClip = pRefDevice->PixelToLogic( aClipRect ); + aLogicClip = pRefDevice->PixelToLogic( aAreaParam.maClipRect ); else - aLogicClip = aClipRect; + aLogicClip = aAreaParam.maClipRect; if (bClip) // bei bSimClip nur aClipRect initialisieren { @@ -3215,10 +3379,7 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) // use GetOutputArea to hide the grid // (clip region is done manually below) - BOOL bLeftClip = FALSE; - BOOL bRightClip = FALSE; - Rectangle aAlignRect; - Rectangle aClipRect; + OutputAreaParam aAreaParam; SCCOL nCellX = nX; SCROW nCellY = nY; @@ -3231,8 +3392,7 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) GetOutputArea( nX, nArrY, nCellStartX, nPosY, nCellX, nCellY, nNeededWidth, *pPattern, sal::static_int_cast<USHORT>(eOutHorJust), - FALSE, FALSE, TRUE, - aAlignRect, aClipRect, bLeftClip, bRightClip ); + FALSE, FALSE, TRUE, aAreaParam ); if ( bShrink ) { @@ -3240,19 +3400,19 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) pRefDevice->LogicToPixel(Size(nEngineWidth,0)).Width() : nEngineWidth; long nNeededPixel = nPixelWidth + nLeftM + nRightM; - bLeftClip = bRightClip = TRUE; + aAreaParam.mbLeftClip = aAreaParam.mbRightClip = TRUE; // always do height - ShrinkEditEngine( *pEngine, aAlignRect, nLeftM, nTopM, nRightM, nBottomM, + ShrinkEditEngine( *pEngine, aAreaParam.maAlignRect, nLeftM, nTopM, nRightM, nBottomM, FALSE, sal::static_int_cast<USHORT>(eOrient), nAttrRotate, bPixelToLogic, - nEngineWidth, nEngineHeight, nNeededPixel, bLeftClip, bRightClip ); + nEngineWidth, nEngineHeight, nNeededPixel, aAreaParam.mbLeftClip, aAreaParam.mbRightClip ); if ( eRotMode == SVX_ROTATE_MODE_STANDARD ) { // do width only if rotating within the cell (standard mode) - ShrinkEditEngine( *pEngine, aAlignRect, nLeftM, nTopM, nRightM, nBottomM, + ShrinkEditEngine( *pEngine, aAreaParam.maAlignRect, nLeftM, nTopM, nRightM, nBottomM, TRUE, sal::static_int_cast<USHORT>(eOrient), nAttrRotate, bPixelToLogic, - nEngineWidth, nEngineHeight, nNeededPixel, bLeftClip, bRightClip ); + nEngineWidth, nEngineHeight, nNeededPixel, aAreaParam.mbLeftClip, aAreaParam.mbRightClip ); } // nEngineWidth/nEngineHeight is updated in ShrinkEditEngine @@ -3306,19 +3466,19 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) } if (bPixelToLogic) - aClipRect = pRefDevice->PixelToLogic( Rectangle( + aAreaParam.maClipRect = pRefDevice->PixelToLogic( Rectangle( Point(nClipStartX,nClipStartY), aClipSize ) ); else - aClipRect = Rectangle(Point(nClipStartX, nClipStartY), + aAreaParam.maClipRect = Rectangle(Point(nClipStartX, nClipStartY), aClipSize ); // Scale = 1 if (bMetaFile) { pDev->Push(); - pDev->IntersectClipRegion( aClipRect ); + pDev->IntersectClipRegion( aAreaParam.maClipRect ); } else - pDev->SetClipRegion( Region( aClipRect ) ); + pDev->SetClipRegion( Region( aAreaParam.maClipRect ) ); } Point aLogicStart; |