[Libreoffice-commits] core.git: oox/source svx/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 16 10:27:37 UTC 2018


 oox/source/drawingml/shape.cxx                          |    8 ++++++++
 svx/source/customshapes/EnhancedCustomShapeFontWork.cxx |   11 ++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit a643c8353754c6ce8b318e37cbbc60c3425e9d32
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Aug 14 13:22:33 2018 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Aug 16 12:27:16 2018 +0200

    tdf#116350 Better text layout for big shapes
    
    Added some horizontal padding - for bigger shapes
    and vertical adjustment for multi-line labels.
    
    Change-Id: I665b238b0d08a499cd846952d831fe449f72f575
    Reviewed-on: https://gerrit.libreoffice.org/58975
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 4f11186254f0..e58d54bf863c 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -527,6 +527,14 @@ static inline void lcl_createPresetShape( uno::Reference<drawing::XShape>& xShap
         }
     }
 
+    // Apply vertical adjustment for text on arc
+    SvxShape* pShape = SvxShape::getImplementation(xShape);
+    assert(pShape);
+    if (rClass == "fontwork-arch-up-curve")
+        pShape->GetSdrObject()->SetMergedItem( SdrTextVertAdjustItem( SdrTextVertAdjust::SDRTEXTVERTADJUST_BOTTOM ) );
+    else if (rClass == "fontwork-arch-down-curve")
+        pShape->GetSdrObject()->SetMergedItem( SdrTextVertAdjustItem( SdrTextVertAdjust::SDRTEXTVERTADJUST_TOP ) );
+
     // Apply preset shape
     xDefaulter->createCustomShapeDefaults( rClass );
 
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index 5ce861bc0407..bee68428313a 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -252,6 +252,10 @@ void CalculateHorizontalScalingFactor(
 
     if (nFontSize > 1)
         rFWData.fVerticalTextScaling = static_cast<double>(nFontSize) / rFontHeight.GetHeight();
+    // Add some padding
+    if (rFWData.bScaleX)
+        fScalingFactor *= 1.1;
+
     rFWData.fHorizontalTextScaling = fScalingFactor;
 }
 
@@ -531,11 +535,16 @@ bool GetFontWorkOutline(
         }
         else if (rFWData.bScaleX)
         {
+            const SdrTextVertAdjust nVertJustify = rSdrObjCustomShape.GetMergedItem( SDRATTR_TEXT_VERTADJUST ).GetValue();
+            double fFactor = nVertJustify == SdrTextVertAdjust::SDRTEXTVERTADJUST_BOTTOM ? -0.5 : ( nVertJustify == SdrTextVertAdjust::SDRTEXTVERTADJUST_TOP ? 0.5 : 0 );
+
             std::vector< FWParagraphData >::iterator aParagraphIter( aTextAreaIter->vParagraphs.begin() );
             std::vector< FWParagraphData >::const_iterator aParagraphIEnd( aTextAreaIter->vParagraphs.end() );
             while ( aParagraphIter != aParagraphIEnd )
             {
                 sal_Int32 nHorzDiff = 0;
+                sal_Int32 nVertDiff = static_cast<double>( rFWData.nSingleLineHeight ) * fFactor * ( aTextAreaIter->vParagraphs.size() - 1 );
+
                 if ( eHorzAdjust == SDRTEXTHORZADJUST_CENTER )
                     nHorzDiff = ( rFWData.fHorizontalTextScaling * aTextAreaIter->aBoundRect.GetWidth() - aParagraphIter->aBoundRect.GetWidth() ) / 2;
                 else if ( eHorzAdjust == SDRTEXTHORZADJUST_RIGHT )
@@ -551,7 +560,7 @@ bool GetFontWorkOutline(
                         std::vector< tools::PolyPolygon >::const_iterator aOutlineIEnd = aCharacterIter->vOutlines.end();
                         while( aOutlineIter != aOutlineIEnd )
                         {
-                            aOutlineIter->Move( nHorzDiff, 0 );
+                            aOutlineIter->Move( nHorzDiff, nVertDiff );
                             ++aOutlineIter;
                         }
                         ++aCharacterIter;


More information about the Libreoffice-commits mailing list