60 #include <osl/diagnose.h>
64 #include <document.hxx>
70 #include <progress.hxx>
73 #include <stlsheet.hxx>
77 #include <com/sun/star/i18n/DirectionProperty.hpp>
91 #define DROPDOWN_BITMAP_SIZE 18
93 #define DRAWTEXT_MAX 32767
153 void SetAutoText(
const OUString& rAutoText );
167 tools::Long GetFmtTextWidth(
const OUString& rString);
186 bool HasEditCharacters()
const;
205 pPattern ( nullptr ),
206 pCondSet ( nullptr ),
221 bLineBreak (
false ),
224 bPixelToLogic( bPTL ),
253 if ( nNewHeight > 0 )
259 if ( pFmtDevice != pDev )
281 template<
typename ItemType,
typename EnumType>
285 return static_cast<EnumType
>(rItem.GetValue());
290 return lcl_GetValue<SfxBoolItem, bool>(rPattern, nWhich, pCondSet);
297 sal_uInt32 nCurrentNumberFormat = pDoc->
GetNumberFormat( nCellX, nCellY, nTab );
299 return pNumberFormatter->
GetType( nCurrentNumberFormat ) == SvNumFormatType::TEXT;
377 case SvxCellOrientation::Standard:
382 case SvxCellOrientation::Stacked:
386 case SvxCellOrientation::TopBottom:
390 case SvxCellOrientation::BottomUp:
395 OSL_FAIL(
"Invalid SvxCellOrientation value");
412 if ( pFmtDevice != pDev )
500 bool bChanged =
false;
579 if ( nCharWidth < 1 || (
bPixelToLogic && nCharWidth < pOutput->mpRefDevice->PixelToLogic(
Size(1,0)).Width()) )
591 if ( nSpaceToFill <= nCharWidth )
594 sal_Int32 nCharsToInsert = nSpaceToFill / nCharWidth;
595 OUStringBuffer aFill(nCharsToInsert);
643 sal_uInt16 nNumDigits =
static_cast<sal_uInt16
>(nWidth / nMaxDigit);
654 sal_uInt8 nSignCount = 0, nDecimalCount = 0, nExpCount = 0;
655 sal_Int32 nLen =
aString.getLength();
657 for( sal_Int32
i = 0;
i < nLen; ++
i )
662 else if (c == cDecSep)
670 if (
aString ==
"0" && fVal != 0.0)
674 nWidth += (nMaxDigit -
GetDotWidth()) * nDecimalCount;
680 if (nDecimalCount || nSignCount || nExpCount)
683 nNumDigits =
static_cast<sal_uInt16
>(nWidth / nMaxDigit);
695 if (nActualTextWidth > nWidth)
722 if (
GetOrient() != SvxCellOrientation::Standard )
741 for (
char i = 0;
i < 10; ++
i)
743 char cDigit =
'0' +
i;
798 if (
GetOrient() != SvxCellOrientation::Standard )
812 for (sal_Int32 nIdx = 0; nIdx <
aString.getLength(); ++nIdx)
854 return static_cast<double>(
aZoomY) / static_cast<double>(
aZoomX);
873 if ( !aURL.isEmpty() && pPDFData )
878 std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->
GetBookmarks();
879 rBookmarks.push_back( aBookmark );
936 bool bVisRowChanged )
938 bool bDoMerge =
false;
939 bool bIsLeft = ( nX ==
nVisX1 );
940 bool bIsTop = ( nY ==
nVisY1 ) || bVisRowChanged;
960 if ( bHOver && bVOver )
961 bDoMerge = bIsLeft && bIsTop;
974 if ( !bDoMerge && !bHidden )
977 if (rOverX >=
nX1 && !bHidden)
994 if ( !bDoMerge && !bHidden )
1000 if (rOverX >=
nX1 && rOverY >=
nY1 &&
1019 OSL_ENSURE( pNewPattern,
"pNewPattern" );
1021 if ( pNewPattern == rpOldPattern )
1023 else if ( !rpOldPattern )
1089 rpOldPattern = pNewPattern;
1097 if ( !bProgress && pFCell->
GetDirty() )
1106 return ( nScript != SvtScriptType::LATIN &&
1107 nScript != SvtScriptType::ASIAN &&
1108 nScript != SvtScriptType::COMPLEX );
1116 if ( pThisRowInfo && nX <=
nX2 )
1124 if ( !bEmpty && ( nX < nX1 || nX >
nX2 || !pThisRowInfo ) )
1188 sal_uInt16 nHorJustify,
bool bCellIsValue,
1189 bool bBreak,
bool bOverwrite,
1198 SCCOL nCompCol = nX;
1199 while ( nCellX > nCompCol )
1203 pRowInfo[0].basicCellInfo(nCompCol).nWidth :
1205 nCellPosX += nColWidth * nLayoutSign;
1208 while ( nCellX < nCompCol )
1212 pRowInfo[0].basicCellInfo(nCompCol).nWidth :
1214 nCellPosX -= nColWidth * nLayoutSign;
1220 while ( nCellY > nCompRow )
1241 if ( nMergeCols == 0 )
1244 if ( nMergeRows == 0 )
1251 pRowInfo[0].basicCellInfo(nCellX+i).nWidth :
1253 nMergeSizeX += nColWidth;
1257 if ( rThisRowInfo.
nRowNo == nCellY )
1260 nMergeSizeY += rThisRowInfo.
nHeight;
1284 if ( nNeeded > nMergeSizeX )
1293 case SvxCellHorJustify::Left:
1294 nRightMissing = nMissing;
1296 case SvxCellHorJustify::Right:
1297 nLeftMissing = nMissing;
1299 case SvxCellHorJustify::Center:
1300 nLeftMissing = nMissing / 2;
1301 nRightMissing = nMissing - nLeftMissing;
1311 ::std::swap( nLeftMissing, nRightMissing );
1313 SCCOL nRightX = nCellX;
1314 SCCOL nLeftX = nCellX;
1315 if ( !bMerged && !bCellIsValue && !bBreak )
1319 while ( nRightMissing > 0 && nRightX < mpDoc->MaxCol() && ( bOverwrite ||
IsAvailable( nRightX+1, nCellY ) ) )
1323 nRightMissing -= nAdd;
1326 if ( rThisRowInfo.
nRowNo == nCellY && nRightX >=
nX1 && nRightX <=
nX2 )
1330 while ( nLeftMissing > 0 && nLeftX > 0 && ( bOverwrite ||
IsAvailable( nLeftX-1, nCellY ) ) )
1332 if ( rThisRowInfo.
nRowNo == nCellY && nLeftX >=
nX1 && nLeftX <=
nX2 )
1337 nLeftMissing -= nAdd;
1344 if ( nRightMissing > 0 &&
bMarkClipped && nRightX >=
nX1 && nRightX <=
nX2 && !bBreak && !bCellIsValue )
1351 if ( nLeftMissing > 0 &&
bMarkClipped && nLeftX >=
nX1 && nLeftX <=
nX2 && !bBreak && !bCellIsValue )
1377 fZoom = fZoom > 1.0 ? fZoom : 1.0;
1379 bool bFit = ( nNeeded + nFilter <= nMergeSizeX );
1399 bool beginsWithRTLCharacter(
const OUString& rStr)
1406 case i18n::DirectionProperty_RIGHT_TO_LEFT:
1407 case i18n::DirectionProperty_RIGHT_TO_LEFT_ARABIC:
1408 case i18n::DirectionProperty_RIGHT_TO_LEFT_EMBEDDING:
1409 case i18n::DirectionProperty_RIGHT_TO_LEFT_OVERRIDE:
1426 bool bCellIsValue,
const OUString& rText,
1431 bool bUseWritingDirection =
false;
1432 if (eInHorJust == SvxCellHorJustify::Standard)
1436 if (beginsWithRTLCharacter( rText))
1439 eHorJustContext = bNumberFormatIsText ? SvxCellHorJustify::Right : SvxCellHorJustify::Left;
1441 eHorJustContext = SvxCellHorJustify::Right;
1443 else if (bCellIsValue)
1444 eHorJustContext = bNumberFormatIsText ? SvxCellHorJustify::Left : SvxCellHorJustify::Right;
1446 bUseWritingDirection =
true;
1449 if (bUseWritingDirection ||
1450 eInHorJust == SvxCellHorJustify::Block || eInHorJust == SvxCellHorJustify::Repeat)
1453 if (nDirection == SvxFrameDirection::Horizontal_LR_TB || nDirection == SvxFrameDirection::Vertical_LR_TB)
1454 eHorJustContext = SvxCellHorJustify::Left;
1455 else if (nDirection == SvxFrameDirection::Environment)
1457 SAL_WARN_IF( !pDoc,
"sc.ui",
"getAlignmentFromContext - pDoc==NULL");
1461 eHorJustContext = (pDoc && pDoc->
IsLayoutRTL(nTab) && (beginsWithRTLCharacter( rText))) ? SvxCellHorJustify::Right : SvxCellHorJustify::Left;
1464 eHorJustContext = SvxCellHorJustify::Right;
1466 return eHorJustContext;
1484 "LayoutStrings: different MapUnits ?!?!" );
1491 bool bProgress =
false;
1499 if ( nX2 < mpDoc->MaxCol() )
1500 nLastContentCol = sal::static_int_cast<
SCCOL>(
1502 SCCOL nLoopStartX =
nX1;
1508 bool bCellIsValue =
false;
1523 std::vector<std::unique_ptr<ScPatternAttr> > aAltPatterns;
1525 std::vector<sal_Int32> aDX;
1531 if ((bPaint && pThisRowInfo->
bChanged) || (!bPaint && rAddress.
Row() == nY))
1534 if ( nLoopStartX <
nX1 )
1536 for (SCCOL nX=nLoopStartX; nX<=
nX2; nX++)
1538 bool bMergeEmpty =
false;
1544 bool bDoCell =
false;
1545 bool bUseEditEngine =
false;
1569 if ( bEmpty && !bMergeEmpty && nX <
nX1 && !bOverlapped )
1575 if ( nTempX <
nX1 &&
1586 if ( bEmpty && !bMergeEmpty && nX ==
nX2 && !bOverlapped )
1591 while (nTempX < nLastContentCol &&
IsEmptyCellText( pThisRowInfo, nTempX, nY ))
1627 if ( nCellY == nY && nCellX == nX && nCellX >=
nX1 && nCellX <=
nX2 )
1634 bUseEditEngine =
true;
1641 bUseEditEngine =
true;
1644 if (bDoCell && !bUseEditEngine)
1646 if ( nCellY == nY && nCellX >=
nX1 && nCellX <=
nX2 )
1667 aAltPatterns.push_back(std::make_unique<ScPatternAttr>(*pPattern));
1682 pPattern = pAltPattern;
1689 aAltPatterns.push_back(std::make_unique<ScPatternAttr>(*pPattern));
1693 pPattern = pAltPattern;
1700 if (nScript == SvtScriptType::NONE)
1703 if ( pPattern != pOldPattern || pCondSet != pOldCondSet ||
1707 pCondSet != pOldCondSet || nScript != nOldScript ||
mbSyntaxMode )
1709 aVars.
SetPattern(pPattern, pCondSet, aCell, nScript);
1713 pOldPattern = pPattern;
1714 pOldCondSet = pCondSet;
1715 nOldScript = nScript;
1719 if ( aVars.
GetOrient() == SvxCellOrientation::Stacked ||
1721 bUseEditEngine =
true;
1723 if (bDoCell && !bUseEditEngine)
1729 pOldPattern =
nullptr;
1734 if (bDoCell && !bUseEditEngine)
1746 *pPattern, pCondSet,
mpDoc,
nTab, bNumberFormatIsText );
1755 bool bRepeat = aVars.
IsRepeat() && !bBreak;
1756 bool bShrink = aVars.
IsShrink() && !bBreak && !bRepeat;
1765 GetOutputArea( nX, nArrY, nPosX, nPosY, nCellX, nCellY, nNeededWidth,
1766 *pPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
1767 bCellIsValue || bRepeat || bShrink, bBreak,
false,
1773 if ( aVars.
GetOrient() != SvxCellOrientation::Standard )
1777 bUseEditEngine =
true;
1784 if ( nAvailable > 0 && nScaleSize > 0 )
1786 tools::Long nScale = ( nAvailable * 100 ) / nScaleSize;
1791 sal_uInt16 nShrinkAgain = 0;
1797 nScale = ( nScale * 9 ) / 10;
1804 if ( nNewSize <= nAvailable )
1811 pOldPattern =
nullptr;
1824 if ( nRepeatSize > 0 )
1826 tools::Long nRepeatCount = nAvailable / nRepeatSize;
1827 if ( nRepeatCount > 1 )
1830 OUStringBuffer aRepeated(aCellStr);
1831 for (
tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
1832 aRepeated.append(aCellStr);
1833 aVars.
SetAutoText( aRepeated.makeStringAndClear() );
1841 if ( aVars.
GetOrient() == SvxCellOrientation::Standard )
1851 if (!bUseEditEngine)
1854 aVars.
GetHorJust() == SvxCellHorJustify::Block &&
1863 SCCOL nMarkX = ( nCellX <=
nX2 ) ? nCellX :
nX2;
1864 RowInfo* pMarkRowInfo = ( nCellY == nY ) ? pThisRowInfo : &
pRowInfo[0];
1907 bool bRightAdjusted =
false;
1908 switch (eOutHorJust)
1910 case SvxCellHorJustify::Left:
1913 case SvxCellHorJustify::Right:
1916 bRightAdjusted =
true;
1918 case SvxCellHorJustify::Center:
1932 case SvxCellVerJustify::Top:
1933 case SvxCellVerJustify::Block:
1937 nTestClipHeight += nTop;
1940 case SvxCellVerJustify::Bottom:
1944 nTestClipHeight += nBot;
1947 case SvxCellVerJustify::Center:
1951 nJustPosY += ( nOutHeight + nTop -
1953 nTestClipHeight += std::abs( nTop - nBot );
1962 if ( nTestClipHeight > nOutHeight )
1972 if ( bHClip || bVClip )
2001 Point aURLStart( nJustPosX, nJustPosY );
2005 case SvxCellOrientation::Standard:
2008 case SvxCellOrientation::TopBottom:
2011 case SvxCellOrientation::BottomUp:
2024 Point aDrawTextPos( nJustPosX, nJustPosY );
2025 if ( bPixelToLogic )
2041 const OUString& aString = aVars.
GetString();
2042 if (!aString.isEmpty())
2048 OUString aShort = aString;
2057 double fVisibleRatio = 1.0;
2059 sal_Int32 nTextLen = aString.getLength();
2063 if (0.0 < fVisibleRatio && fVisibleRatio < 1.0)
2066 sal_Int32 nShortLen = fVisibleRatio*nTextLen + 1;
2067 aShort = aShort.copy(0, nShortLen);
2070 else if (eOutHorJust == SvxCellHorJustify::Right && aAreaParam.
mnLeftClipLength > 0)
2073 if (0.0 < fVisibleRatio && fVisibleRatio < 1.0)
2076 sal_Int32 nShortLen = fVisibleRatio*nTextLen + 1;
2077 aShort = aShort.copy(nTextLen-nShortLen);
2081 double fOffset = fTextWidth - fShortWidth;
2082 aDrawTextPos.Move(fOffset, 0);
2089 if (!bPaint && rAddress.
Col() == nX)
2093 aRect += aDrawTextPos;
2099 size_t nLen = aShort.getLength();
2100 if (aDX.size() < nLen)
2101 aDX.resize(nLen, 0);
2109 for (
size_t i = 0;
i < nLen; ++
i)
2110 aDX[
i] = static_cast<sal_Int32>(aDX[
i] / fMul + 0.5);
2119 mpDev->
DrawText(aDrawTextPos, aShort, 0, -1,
nullptr,
nullptr,
2124 if ( bHClip || bVClip )
2134 if (bPaint && bHasURL)
2155 pEngine->SetUpdateLayout(
false );
2160 nCtrl |= EEControlBits::ONLINESPELLING;
2167 pEngine->SetControlWord( nCtrl );
2213 for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
2215 std::vector<sal_Int32> aPortions;
2218 sal_Int32 nStart = 0;
2219 for (
const sal_Int32 nEnd : aPortions )
2228 nWestern = ( nWestern * nPercent ) / 100;
2229 nCJK = ( nCJK * nPercent ) / 100;
2230 nCTL = ( nCTL * nPercent ) / 100;
2258 double nRealOrient =
toRadians(nAttrRotate);
2259 double nAbsCos = fabs( cos( nRealOrient ) );
2260 double nAbsSin = fabs( sin( nRealOrient ) );
2262 return static_cast<tools::Long>( nRealWidth * nAbsCos + nRealHeight * nAbsSin );
2264 return static_cast<tools::Long>( nRealHeight * nAbsCos + nRealWidth * nAbsSin );
2286 if ( nScaleSize <= rAlignRect.
GetHeight() )
2289 bool bSwap = ( nOrient == SvxCellOrientation::TopBottom || nOrient == SvxCellOrientation::BottomUp );
2291 tools::Long nScale = ( nAvailable * 100 ) / nScaleSize;
2294 rEngineHeight =
lcl_GetEditSize( rEngine,
false, bSwap, nAttrRotate );
2298 sal_uInt16 nShrinkAgain = 0;
2303 rEngineHeight =
lcl_GetEditSize( rEngine,
false, bSwap, nAttrRotate );
2304 nNewSize = bPixelToLogic ?
2313 rNeededPixel = nPixelWidth + nLeftM + nRightM;
2315 else if ( rLeftClip || rRightClip )
2320 tools::Long nScaleSize = rNeededPixel - nLeftM - nRightM;
2322 if ( nScaleSize <= nAvailable )
2325 tools::Long nScale = ( nAvailable * 100 ) / nScaleSize;
2332 sal_uInt16 nShrinkAgain = 0;
2338 nNewSize = bPixelToLogic ?
2342 if ( nNewSize <= nAvailable )
2343 rLeftClip = rRightClip =
false;
2346 rNeededPixel = nNewSize + nLeftM + nRightM;
2347 rEngineHeight =
lcl_GetEditSize( rEngine,
false,
false, nAttrRotate );
2353 meHorJustContext( meHorJustAttr ),
2354 meHorJustResult( meHorJustAttr ),
2358 meOrient( pPattern->GetCellOrientation(pCondSet) ),
2360 mnX(0),
mnCellX(0), mnCellY(0),
2361 mnPosX(0), mnPosY(0), mnInitPosX(0),
2363 mbCellIsValue(bCellIsValue),
2364 mbAsianVertical(
false),
2365 mbPixelToLogic(
false),
2366 mbHyphenatorSet(
false),
2369 mpCondSet(pCondSet),
2370 mpPreviewFontSet(nullptr),
2371 mpOldPattern(nullptr),
2372 mpOldCondSet(nullptr),
2373 mpOldPreviewFontSet(nullptr),
2374 mpThisRowInfo(nullptr),
2375 mpMisspellRanges(nullptr)
2379 const ScDocument* pDoc,
bool bShowNullValues,
bool bShowFormulas,
bool bSyntaxMode,
bool bUseStyleColor,
bool bForceAutoColor,
bool& rWrapFields)
2386 mpEngine->SetTextCurrentDefaults(*pData);
2388 if ( mbBreak && !mbAsianVertical && pData->
HasField() )
2398 OSL_FAIL(
"pData == 0");
2404 sal_uInt32 nFormat =
mpPattern->GetNumberFormat(
2406 const Color* pColor;
2414 mpEngine->SetTextCurrentDefaults(aString);
2415 if ( pColor && !bSyntaxMode && !( bUseStyleColor && bForceAutoColor ) )
2419 if (mpMisspellRanges)
2420 mpEngine->SetAllMisspellRanges(*mpMisspellRanges);
2430 if (
mpPattern == mpOldPattern && mpCondSet == mpOldCondSet && mpPreviewFontSet == mpOldPreviewFontSet )
2434 bool bCellContrast = bUseStyleColor &&
2437 auto pSet = std::make_unique<SfxItemSet>( mpEngine->GetEmptyItemSet() );
2438 mpPattern->FillEditItemSet( pSet.get(), mpCondSet );
2439 if ( mpPreviewFontSet )
2458 mpEngine->SetDefaults( std::move(pSet) );
2460 mpOldCondSet = mpCondSet;
2461 mpOldPreviewFontSet = mpPreviewFontSet;
2464 if (meOrient == SvxCellOrientation::Stacked)
2465 nControl |= EEControlBits::ONECHARPERLINE;
2468 mpEngine->SetControlWord( nControl );
2470 if ( !mbHyphenatorSet && bParaHyphenate )
2474 mpEngine->SetHyphenator( xXHyphenator );
2475 mbHyphenatorSet =
true;
2479 if ( bUseStyleColor && ( aBackCol.
IsTransparent() || bCellContrast ) )
2480 aBackCol = nConfBackColor;
2481 mpEngine->SetBackgroundColor( aBackCol );
2488 sal_uInt16 nIndent = 0;
2489 if (meHorJustAttr == SvxCellHorJustify::Left || meHorJustAttr == SvxCellHorJustify::Right)
2496 if(meHorJustAttr == SvxCellHorJustify::Right)
2507 calcMargins(nTopM, nLeftM, nBottomM, nRightM, nPPTX, nPPTY);
2509 if (isVerticallyOriented())
2520 if (mbAsianVertical)
2533 if (!mbBreak || meOrient == SvxCellOrientation::Stacked || mbAsianVertical)
2538 if (isVerticallyOriented())
2541 nEngineWidth = nEngineHeight;
2542 nEngineHeight = nTemp;
2545 if (meOrient == SvxCellOrientation::Stacked)
2546 nEngineWidth = nEngineWidth * 11 / 10;
2548 rWidth = nEngineWidth;
2549 rHeight = nEngineHeight;
2554 return (mbBreak || (meOrient == SvxCellOrientation::Stacked) || mbAsianVertical);
2562 return maCell.mpFormula->IsHyperLinkCell();
2567 return (meOrient == SvxCellOrientation::TopBottom || meOrient == SvxCellOrientation::BottomUp);
2573 OSL_ENSURE(isVerticallyOriented(),
"Use this only for vertically oriented cell!");
2585 rLogicStart.AdjustY(nTopM );
2587 switch (meHorJustResult)
2589 case SvxCellHorJustify::Center:
2590 rLogicStart.AdjustX((nCellWidth - nEngineWidth) / 2 );
2592 case SvxCellHorJustify::Right:
2593 rLogicStart.AdjustX(nCellWidth - nEngineWidth );
2602 if (isVerticallyOriented() || mbAsianVertical)
2607 case SvxCellVerJustify::Top:
2608 eSvxAdjust = (meOrient == SvxCellOrientation::TopBottom || mbAsianVertical) ?
2609 SvxAdjust::Left : SvxAdjust::Right;
2611 case SvxCellVerJustify::Center:
2612 eSvxAdjust = SvxAdjust::Center;
2614 case SvxCellVerJustify::Bottom:
2615 case SvxCellVerJustify::Standard:
2616 eSvxAdjust = (meOrient == SvxCellOrientation::TopBottom || mbAsianVertical) ?
2617 SvxAdjust::Right : SvxAdjust::Left;
2619 case SvxCellVerJustify::Block:
2620 eSvxAdjust = SvxAdjust::Block;
2627 if (meHorJustResult == SvxCellHorJustify::Block)
2637 if (meOrient == SvxCellOrientation::Stacked)
2638 eSvxAdjust = SvxAdjust::Center;
2641 if (meOrient == SvxCellOrientation::Standard)
2642 switch (meHorJustResult)
2644 case SvxCellHorJustify::Repeat:
2645 case SvxCellHorJustify::Standard:
2646 SAL_WARN(
"sc.ui",
"meHorJustResult does not match getAlignmentFromContext()");
2648 case SvxCellHorJustify::Left:
2649 eSvxAdjust = SvxAdjust::Left;
2651 case SvxCellHorJustify::Center:
2652 eSvxAdjust = SvxAdjust::Center;
2654 case SvxCellHorJustify::Right:
2655 eSvxAdjust = SvxAdjust::Right;
2657 case SvxCellHorJustify::Block:
2658 eSvxAdjust = SvxAdjust::Block;
2664 case SvxCellVerJustify::Top:
2665 eSvxAdjust = SvxAdjust::Right;
2667 case SvxCellVerJustify::Center:
2668 eSvxAdjust = SvxAdjust::Center;
2670 case SvxCellVerJustify::Bottom:
2671 case SvxCellVerJustify::Standard:
2672 eSvxAdjust = SvxAdjust::Left;
2674 case SvxCellVerJustify::Block:
2675 eSvxAdjust = SvxAdjust::Block;
2682 if (mbAsianVertical)
2685 if (meHorJustResult == SvxCellHorJustify::Block)
2691 if (meVerJust == SvxCellVerJustify::Block)
2696 mpEngine->SetVertical(mbAsianVertical);
2704 const_cast<EditTextObject*
>(pData)->SetVertical(mbAsianVertical);
2710 if (meHorJustResult == SvxCellHorJustify::Right || meHorJustResult == SvxCellHorJustify::Center)
2712 SvxAdjust eEditAdjust = (meHorJustResult == SvxCellHorJustify::Center) ?
2713 SvxAdjust::Center : SvxAdjust::Right;
2727 bool bHasURL = pPDFData && isHyperlinkCell();
2732 tools::Long nURLHeight = mpEngine->GetTextHeight();
2735 Size aPaper = mpEngine->GetPaperSize();
2736 if ( mbAsianVertical )
2737 nURLHeight = aPaper.
Height();
2739 nURLWidth = aPaper.
Width();
2741 if (isVerticallyOriented())
2742 std::swap( nURLWidth, nURLHeight );
2743 else if (mbAsianVertical)
2744 aURLStart.AdjustX( -nURLWidth );
2764 bool bVClip =
false;
2785 :mbMetaFile(bMetaFile)
2787 if (!(bClip || bSimClip))
2834 rNeededPixel = nEngineWidth;
2836 rNeededPixel += nAddWidthPixels;
2838 return nEngineWidth;
2843 OSL_ASSERT(rParam.
meOrient == SvxCellOrientation::Standard);
2855 rParam.
meOrient = SvxCellOrientation::Standard;
2856 nAttrRotate = 0_deg100;
2881 if ( nXForPos <
nX1 )
2887 if ( nArrYForPos < 1 )
2897 Size aPaperSize( 1000000, 1000000 );
2904 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
2932 rParam.
meVerJust = SvxCellVerJustify::Top;
2939 || rParam.
meVerJust==SvxCellVerJustify::Standard);
2943 bool bWrapFields =
false;
2963 nNeededPixel += nLeftM + nRightM;
2965 if (!rParam.
mbBreak || bShrink)
2969 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
2970 rParam.
mbCellIsValue || bRepeat || bShrink,
false,
false, aAreaParam );
2975 nLeftM, nTopM, nRightM, nBottomM,
true,
2977 nEngineWidth, nEngineHeight, nNeededPixel,
2985 tools::Long nFormatted = nNeededPixel - nLeftM - nRightM;
2987 if ( nAvailable >= 2 * nFormatted )
2996 if ( nRepeatSize > 0 )
2998 tools::Long nRepeatCount = nAvailable / nRepeatSize;
2999 if ( nRepeatCount > 1 )
3001 OUStringBuffer aRepeated(aCellStr);
3002 for (
tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
3003 aRepeated.append(aCellStr);
3006 nNeededPixel, (nLeftM + nRightM ) );
3022 if (eOutHorJust != SvxCellHorJustify::Left)
3024 aPaperSize.
setWidth( nNeededPixel + 1 );
3035 tools::Long nOutWidth = nCellWidth - 1 - nLeftM - nRightM;
3048 if ( eOutHorJust == SvxCellHorJustify::Right )
3049 nStartX -= nNeededPixel - nCellWidth + nRightM + 1;
3050 else if ( eOutHorJust == SvxCellHorJustify::Center )
3051 nStartX -= ( nNeededPixel - nCellWidth + nRightM + 1 - nLeftM ) / 2;
3062 bool bSimClip =
false;
3068 aCellSize =
Size( nOutWidth, nOutHeight );
3070 if ( nEngineHeight >= aCellSize.
Height() + aRefOne.
Height() )
3080 ( rParam.
mpCondSet && SfxItemState::SET ==
3092 if ( nEngineHeight - aCellSize.
Height() > 100 &&
3115 if (rParam.
meVerJust==SvxCellVerJustify::Standard)
3116 rParam.
meVerJust=SvxCellVerJustify::Top;
3130 aLogicStart =
Point(nStartX, nStartY);
3140 if (rParam.
meVerJust==SvxCellVerJustify::Bottom ||
3141 rParam.
meVerJust==SvxCellVerJustify::Standard)
3152 aLogicStart.AdjustY(nTopM + aCellSize.
Height() - nEngineHeight );
3154 else if (rParam.
meVerJust==SvxCellVerJustify::Center)
3162 aLogicStart.AdjustY(nTopM + (aCellSize.
Height() - nEngineHeight) / 2 );
3169 aLogicStart.AdjustY(nTopM );
3172 aURLStart = aLogicStart;
3180 Point aDocStart = aClip.getRect().TopLeft();
3181 aDocStart -= aLogicStart;
3182 rParam.
mpEngine->
Draw(*mpDev, aClip.getRect(), aDocStart,
false);
3235 bool bWrapFields,
bool bTop)
3239 bool bSimClip =
false;
3242 if ( nEngineWidth >= aCellSize.
Width() + aRefOne.
Width() )
3252 ( rParam.
mpCondSet && SfxItemState::SET ==
3258 ShowClipMarks( rParam, nEngineWidth, aCellSize, bMerged, aAreaParam, bTop);
3269 OSL_ASSERT(rParam.
meHorJustAttr != SvxCellHorJustify::Repeat);
3282 if ( nXForPos <
nX1 )
3288 if ( nArrYForPos < 1 )
3298 Size aPaperSize( 1000000, 1000000 );
3305 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
3326 bool bWrapFields =
false;
3346 nNeededPixel += nLeftM + nRightM;
3348 if (!rParam.
mbBreak || bShrink)
3352 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
3353 rParam.
mbCellIsValue || bRepeat || bShrink,
false,
false, aAreaParam );
3358 nLeftM, nTopM, nRightM, nBottomM,
false,
3360 nEngineWidth, nEngineHeight, nNeededPixel,
3368 const tools::Long nFormatted = nNeededPixel - nLeftM - nRightM;
3370 if ( nAvailable >= 2 * nFormatted )
3379 if ( nRepeatSize > 0 )
3381 const tools::Long nRepeatCount = nAvailable / nRepeatSize;
3382 if ( nRepeatCount > 1 )
3384 OUStringBuffer aRepeated(aCellStr);
3385 for (
tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
3386 aRepeated.append(aCellStr);
3389 nNeededPixel, (nLeftM + nRightM ) );
3407 const tools::Long nOutWidth = nCellWidth - 1 - nLeftM - nRightM;
3420 if ( eOutHorJust == SvxCellHorJustify::Right )
3421 nStartX -= nNeededPixel - nCellWidth + nRightM + 1;
3422 else if ( eOutHorJust == SvxCellHorJustify::Center )
3423 nStartX -= ( nNeededPixel - nCellWidth + nRightM + 1 - nLeftM ) / 2;
3435 :
Size( nOutWidth, nOutHeight );
3440 const auto pClipRegion =
Clip( rParam, aCellSize, aAreaParam, nEngineWidth, bWrapFields,
true );
3442 Point aLogicStart(nStartX, nStartY);
3445 aURLStart = aLogicStart;
3452 aLogicStart.AdjustY(
3481 aLogicStart.AdjustY(aCellSize.
Height() );
3482 aLogicStart.AdjustY(nTopOffset );
3486 case SvxCellVerJustify::Standard:
3487 case SvxCellVerJustify::Bottom:
3490 case SvxCellVerJustify::Center:
3492 aLogicStart.AdjustY( -(nGap / 2) );
3494 case SvxCellVerJustify::Block:
3495 case SvxCellVerJustify::Top:
3497 aLogicStart.AdjustY( -nGap );
3512 OSL_ASSERT(rParam.
meHorJustAttr != SvxCellHorJustify::Repeat);
3525 if ( nXForPos <
nX1 )
3531 if ( nArrYForPos < 1 )
3541 Size aPaperSize( 1000000, 1000000 );
3548 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
3569 bool bWrapFields =
false;
3589 nNeededPixel += nLeftM + nRightM;
3591 if (!rParam.
mbBreak || bShrink)
3595 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
3596 rParam.
mbCellIsValue || bRepeat || bShrink,
false,
false, aAreaParam );
3601 nLeftM, nTopM, nRightM, nBottomM,
false,
3603 nEngineWidth, nEngineHeight, nNeededPixel,
3611 const tools::Long nFormatted = nNeededPixel - nLeftM - nRightM;
3613 if ( nAvailable >= 2 * nFormatted )
3623 if ( nRepeatSize > 0 )
3625 const tools::Long nRepeatCount = nAvailable / nRepeatSize;
3626 if ( nRepeatCount > 1 )
3628 OUStringBuffer aRepeated(aCellStr);
3629 for (
tools::Long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
3630 aRepeated.append(aCellStr);
3633 nNeededPixel, (nLeftM + nRightM ) );
3651 const tools::Long nOutWidth = nCellWidth - 1 - nLeftM - nRightM;
3662 nStartX += aPaperSize.
Height();
3666 if ( eOutHorJust == SvxCellHorJustify::Right )
3667 nStartX -= nNeededPixel - nCellWidth + nRightM + 1;
3668 else if ( eOutHorJust == SvxCellHorJustify::Center )
3669 nStartX -= ( nNeededPixel - nCellWidth + nRightM + 1 - nLeftM ) / 2;
3681 :
Size( nOutWidth, nOutHeight );
3686 const auto pClipRegion =
Clip( rParam, aCellSize, aAreaParam, nEngineWidth, bWrapFields,
false );
3688 Point aLogicStart(nStartX, nStartY);
3691 aURLStart = aLogicStart;
3695 aLogicStart.AdjustX(nEngineWidth );
3716 aLogicStart.AdjustY(nTopOffset );
3720 case SvxCellVerJustify::Standard:
3721 case SvxCellVerJustify::Bottom:
3723 aLogicStart.AdjustY( -nGap );
3725 case SvxCellVerJustify::Center:
3727 aLogicStart.AdjustY( -(nGap / 2) );
3729 case SvxCellVerJustify::Block:
3730 case SvxCellVerJustify::Top:
3749 OSL_ASSERT(rParam.
meHorJustAttr != SvxCellHorJustify::Repeat);
3761 rParam.
meOrient = SvxCellOrientation::Standard;
3774 if ( nXForPos <
nX1 )
3780 if ( nArrYForPos < 1 )
3790 Size aPaperSize( 1000000, 1000000 );
3795 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
3826 bool bWrapFields =
false;
3846 nNeededPixel += nLeftM + nRightM;
3852 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
3853 true,
false,
false, aAreaParam );
3856 nLeftM, nTopM, nRightM, nBottomM,
true,
3858 nEngineWidth, nEngineHeight, nNeededPixel,
3868 if ( eOutHorJust != SvxCellHorJustify::Left )
3870 aPaperSize.
setWidth( nNeededPixel + 1 );
3881 tools::Long nOutWidth = nCellWidth - 1 - nLeftM - nRightM;
3894 if ( eOutHorJust == SvxCellHorJustify::Right )
3895 nStartX -= nNeededPixel - nCellWidth + nRightM + 1;
3896 else if ( eOutHorJust == SvxCellHorJustify::Center )
3897 nStartX -= ( nNeededPixel - nCellWidth + nRightM + 1 - nLeftM ) / 2;
3908 bool bSimClip =
false;
3914 aCellSize =
Size( nOutWidth, nOutHeight );
3916 if ( nEngineHeight >= aCellSize.
Height() + aRefOne.
Height() )
3926 ( rParam.
mpCondSet && SfxItemState::SET ==
3938 if ( nEngineHeight - aCellSize.
Height() > 100 &&
3971 aLogicStart =
Point(nStartX, nStartY);
3973 if (rParam.
meVerJust==SvxCellVerJustify::Bottom ||
3974 rParam.
meVerJust==SvxCellVerJustify::Standard)
3985 aLogicStart.AdjustY(nTopM + aCellSize.
Height() - nEngineHeight );
3987 else if (rParam.
meVerJust==SvxCellVerJustify::Center)
3995 aLogicStart.AdjustY(nTopM + (aCellSize.
Height() - nEngineHeight) / 2 );
4002 aLogicStart.AdjustY(nTopM );
4005 aURLStart = aLogicStart;
4008 aPaperLogic.
setWidth( nEngineWidth );
4017 Point aDocStart = aClip.getRect().TopLeft();
4018 aDocStart -= aLogicStart;
4019 rParam.
mpEngine->
Draw(*mpDev, aClip.getRect(), aDocStart,
false);
4034 OSL_ASSERT(rParam.
meOrient == SvxCellOrientation::Standard);
4036 OSL_ASSERT(rParam.
meHorJustAttr != SvxCellHorJustify::Repeat);
4040 bool bHidden =
false;
4069 if ( nXForPos <
nX1 )
4075 if ( nArrYForPos < 1 )
4085 Size aPaperSize( 1000000, 1000000 );
4090 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
4117 if ( rParam.
meVerJust == SvxCellVerJustify::Standard )
4118 rParam.
meVerJust = SvxCellVerJustify::Top;
4125 bool bWrapFields =
false;
4145 nNeededPixel += nLeftM + nRightM;
4149 *rParam.
mpPattern, sal::static_int_cast<sal_uInt16>(eOutHorJust),
4150 rParam.
mbCellIsValue || bShrink,
false,
false, aAreaParam );
4155 nLeftM, nTopM, nRightM, nBottomM,
false,
4157 nEngineWidth, nEngineHeight, nNeededPixel,
4167 if (eOutHorJust != SvxCellHorJustify::Left)
4169 aPaperSize.
setWidth( nNeededPixel + 1 );
4179 tools::Long nOutWidth = nCellWidth - 1 - nLeftM - nRightM;
4194 bool bSimClip =
false;
4200 aCellSize =
Size( nOutWidth, nOutHeight );
4202 if ( nEngineHeight >= aCellSize.
Height() + aRefOne.
Height() )
4212 ( rParam.
mpCondSet && SfxItemState::SET ==
4224 if ( nEngineHeight - aCellSize.
Height() > 100 &&
4225 ( rParam.
mbBreak || rParam.
meOrient == SvxCellOrientation::Stacked ) &&
4258 aLogicStart =
Point(nStartX, nStartY);
4266 aLogicStart.AdjustX(nAvailWidth - nEngineWidth );
4268 aLogicStart.AdjustX((nAvailWidth - nEngineWidth) / 2 );
4271 aLogicStart.AdjustX(nEngineWidth );
4277 aLogicStart.AdjustY(nTopM );
4279 aURLStart = aLogicStart;
4296 std::unique_ptr<ScFieldEditEngine> pEngine;
4297 bool bHyphenatorSet =
false;
4300 const SfxItemSet* pOldPreviewFontSet =
nullptr;
4312 if ( nX2 < mpDoc->MaxCol() )
4313 nLastContentCol = sal::static_int_cast<
SCCOL>(
4321 if (nArrY==1) nRowPosY =
nScrY;
4323 if ( pThisRowInfo->
bChanged || nArrY==0 )
4326 for (SCCOL nX=0; nX<=
nX2; nX++)
4328 std::unique_ptr< ScPatternAttr > pPreviewPattr;
4329 if (nX==
nX1) nPosX = nInitPosX;
4337 bool bDoCell =
false;