[Libreoffice-commits] .: 2 commits - vcl/coretext vcl/inc

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jan 28 14:41:14 PST 2013


 vcl/coretext/salcoretextfontutils.cxx  |    3 
 vcl/coretext/salcoretextlayout.cxx     |  633 +++++++++++++++++++++------------
 vcl/coretext/salcoretextstyle.cxx      |   18 
 vcl/coretext/salgdi.cxx                |   33 -
 vcl/inc/coretext/salcoretextlayout.hxx |   80 ----
 5 files changed, 438 insertions(+), 329 deletions(-)

New commits:
commit ef7b1133311ad6ff672a423d89c876d67f5f8f4a
Author: Tor Lillqvist <tml at iki.fi>
Date:   Tue Jan 29 00:34:20 2013 +0200

    More work on the CoreText code
    
    It no longer gets stuck in a loop so easily.
    
    The key thing I realized was that there is a fundamental difference to
    how the ATSUI and CoreText APIs handle text buffers and the start
    offsets into them:
    
    ATSUCreateTextLayoutWithTextPtr() takes a pointer to the whole buffer,
    plus start offset and length. These are stored as part of the layout
    object. Other ATSUI calls that use the layout object interpret index
    parameters as relative to the buffer start, not relative to the start
    offset of the layout object.
    
    CTTypesetterCreateWithAttributedString() on the other hand takes an
    attributed string that has been created from a CFString that already
    is based on a potential substring of a buffer. I.e. the CTTypesetter
    has no knowledge of the original buffer. All index parameters are
    relative to that substring of the buffer, as are return values.
    
    Change-Id: I7026f323d90a72e1ae1784a69f521e347baffaea

diff --git a/vcl/coretext/salcoretextfontutils.cxx b/vcl/coretext/salcoretextfontutils.cxx
index a9c0871..0bdb2d4 100644
--- a/vcl/coretext/salcoretextfontutils.cxx
+++ b/vcl/coretext/salcoretextfontutils.cxx
@@ -278,7 +278,6 @@ CoreTextPhysicalFontFace::CoreTextPhysicalFontFace( const ImplDevFontAttributes&
 ,   m_bHasCJKSupport( false )
 ,   m_bFontCapabilitiesRead( false )
 {
-    SAL_INFO( "vcl.coretext.font", "retain " << font << " as " << m_CTFontRef );
 }
 
 CoreTextPhysicalFontFace::~CoreTextPhysicalFontFace()
@@ -287,7 +286,6 @@ CoreTextPhysicalFontFace::~CoreTextPhysicalFontFace()
     {
         m_pCharMap->DeReference();
     }
-    SAL_INFO( "vcl.coretext.font", "release " << m_CTFontRef );
     SafeCFRelease(m_CTFontRef);
 }
 
@@ -301,7 +299,6 @@ PhysicalFontFace* CoreTextPhysicalFontFace::Clone() const
     if( m_CTFontRef )
     {
         pClone->m_CTFontRef = (CTFontRef)CFRetain(m_CTFontRef);
-        SAL_INFO( "vcl.coretext.font", "clone " << m_CTFontRef << " into " << pClone->m_CTFontRef );
     }
     return pClone;
 }
diff --git a/vcl/coretext/salcoretextlayout.cxx b/vcl/coretext/salcoretextlayout.cxx
index 643c893..43abcdc 100644
--- a/vcl/coretext/salcoretextlayout.cxx
+++ b/vcl/coretext/salcoretextlayout.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <iostream>
+#include <iomanip>
+
 #include "coretext/common.h"
 #include "coretext/salcoretextstyle.hxx"
 #include "coretext/salgdi.h"
@@ -44,8 +47,8 @@ public:
     virtual void Simplify( bool bIsBase );
 
 private:
-    void Clean();
-    bool InitGIA() const;
+    void InvalidateMeasurements();
+    bool InitGIA( ImplLayoutArgs &rArgs ) const;
 
     QuartzSalGraphics* mpGraphics;
     CoreTextStyleInfo* mpStyle;
@@ -55,7 +58,6 @@ private:
     // cached details about the resulting layout
     // mutable members since these details are all lazy initialized
     mutable int mnGlyphCount;           // glyph count
-    mutable CGFloat mnCachedWidth;      // cached value of resulting typographical width
 
     mutable CGGlyph* mpGlyphs;          // glyphs
     mutable int* mpCharWidths;          // map relative charpos to charwidth
@@ -65,8 +67,8 @@ private:
     mutable int* mpGlyphAdvances;       // glyph widths for the justified layout
 
     mutable CGPoint* mpGlyphPositions; 
-    CTTypesetterRef mpTypesetter;
-    CTLineRef mpLine;
+    mutable CTTypesetterRef mpTypesetter;
+    mutable CTLineRef mpLine;
     mutable bool mbHasBoundRectangle;
     mutable Rectangle maBoundRectangle;
 
@@ -85,7 +87,6 @@ CoreTextLayout::CoreTextLayout(QuartzSalGraphics* graphics, CoreTextStyleInfo* s
     mpStyle(style),
     mnCharCount(-1),
     mnGlyphCount(-1),
-    mnCachedWidth(0.0F),
     mpGlyphs(NULL),
     mpCharWidths(NULL),
     mpChars2Glyphs(NULL),
@@ -101,23 +102,90 @@ CoreTextLayout::CoreTextLayout(QuartzSalGraphics* graphics, CoreTextStyleInfo* s
     mnCurrentGlyphRunIndex(0),
     mpRuns(NULL)
 {
+    SAL_INFO( "vcl.coretext.layout", "CoreTextLayout::CoreTextLayout() " << this );
 }
 
 CoreTextLayout::~CoreTextLayout()
 {
-    Clean();
+    InvalidateMeasurements();
+    SAL_INFO( "vcl.coretext.layout", "~CoreTextLayout(" << this << ")" );
+}
+
+std::ostream &operator <<(std::ostream& s, ImplLayoutArgs &rArgs)
+{
+#ifndef SAL_LOG_INFO
+    (void) rArgs;
+    return s;
+#else
+    s << "ImplLayoutArgs{";
+
+    s << "Flags=";
+    if (rArgs.mnFlags == 0)
+        s << 0;
+    else {
+        bool need_or = false;
+        s << "{";
+#define TEST(x) if (rArgs.mnFlags & SAL_LAYOUT_##x) { if (need_or) s << "|"; s << #x; need_or = true; }
+        TEST(BIDI_RTL);
+        TEST(BIDI_STRONG);
+        TEST(RIGHT_ALIGN);
+        TEST(KERNING_PAIRS);
+        TEST(KERNING_ASIAN);
+        TEST(VERTICAL);
+        TEST(COMPLEX_DISABLED);
+        TEST(ENABLE_LIGATURES);
+        TEST(SUBSTITUTE_DIGITS);
+        TEST(KASHIDA_JUSTIFICATON);
+        TEST(DISABLE_GLYPH_PROCESSING);
+        TEST(FOR_FALLBACK);
+#undef TEST
+        s << "}";
+    }
+
+    s << ",Length=" << rArgs.mnLength;
+    s << ",MinCharPos=" << rArgs.mnMinCharPos;
+    s << ",EndCharPos=" << rArgs.mnEndCharPos;
+
+    s << ",Str=\"";
+    int lim = rArgs.mnLength;
+    if (lim > 10)
+        lim = 7;
+    for (int i = 0; i < lim; i++) {
+        if (rArgs.mpStr[i] == '\n')
+            s << "\\n";
+        else if (rArgs.mpStr[i] < ' ' || (rArgs.mpStr[i] >= 0x7F && rArgs.mpStr[i] <= 0xFF))
+            s << "\\0x" << std::hex << std::setw(2) << std::setfill('0') << (int) rArgs.mpStr[i] << std::setfill(' ') << std::setw(1) << std::dec;
+        else if (rArgs.mpStr[i] < 0x7F)
+            s << (char) rArgs.mpStr[i];
+        else
+            s << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (int) rArgs.mpStr[i] << std::setfill(' ') << std::setw(1) << std::dec;
+    }
+    if (rArgs.mnLength > lim)
+        s << "...";
+    s << "\"";
+
+    s << ",LayoutWidth=" << rArgs.mnLayoutWidth;
+
+    s << "}";
+
+    return s;
+#endif
 }
 
-void CoreTextLayout::AdjustLayout( ImplLayoutArgs& /*rArgs*/ )
+void CoreTextLayout::AdjustLayout( ImplLayoutArgs& rArgs )
 {
-    SAL_INFO( "vcl.coretext.layout", "-->" );
-    SAL_INFO( "vcl.coretext.layout", "<--" );
-    /* TODO */
+    SAL_INFO( "vcl.coretext.layout", "AdjustLayout(" << this << ",rArgs=" << rArgs << ")" );
+
+    InvalidateMeasurements();
+    SalLayout::AdjustLayout( rArgs );
+    mnCharCount = mnEndCharPos - mnMinCharPos;
+    InitGIA( rArgs );
 }
 
-void CoreTextLayout::Clean()
+void CoreTextLayout::InvalidateMeasurements()
 {
-    SAL_INFO( "vcl.coretext.layout", "-->" );
+    SAL_INFO( "vcl.coretext.layout", "InvalidateMeasurements(" << this << ")" );
+
     if(mpGlyphs)
     {
         delete[] mpGlyphs;
@@ -151,28 +219,28 @@ void CoreTextLayout::Clean()
     SafeCFRelease(mpTypesetter);
     SafeCFRelease(mpLine);
     mbHasBoundRectangle = false;
-    SAL_INFO( "vcl.coretext.layout", "<--" );
 }
 
 void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
 {
-    SAL_INFO( "vcl.coretext.layout", "-->" );
+    SAL_INFO( "vcl.coretext.layout", "DrawText(" << this << ")" );
+
     QuartzSalGraphics& gr = static_cast<QuartzSalGraphics&>(rGraphics);
     if(mnCharCount <= 0 || !gr.CheckContext())
-    {
         return;
-    }
+
     CGContextSaveGState( gr.mrContext );
     Point pos = GetDrawPosition(Point(0,0));
 #if 0
     SAL_INFO( "vcl.coretext.layout", "at pos (" << pos.X() << "," << pos.Y() << ")" );
+
     CGContextSetTextMatrix(gr.mrContext, CGAffineTransformMakeScale(1.0, -1.0));
     CGContextSetShouldAntialias( gr.mrContext, !gr.mbNonAntialiasedText );
     CGContextSetTextPosition(gr.mrContext, pos.X(), pos.Y());
     CTLineDraw(mpLine, gr.mrContext);
 #else
-    InitGIA();
     SAL_INFO( "vcl.coretext.layout", "at pos (" << pos.X() << "," << pos.Y() <<") ctfont=" << mpStyle->GetFont() );
+
     CGFontRef cg_font = CTFontCopyGraphicsFont(mpStyle->GetFont(), NULL);
     if(!cg_font)
     {
@@ -200,46 +268,47 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
 #endif
     // restore the original graphic context transformations
     CGContextRestoreGState( gr.mrContext );
-    SAL_INFO( "vcl.coretext.layout", "<--" );
-
 }
 
 // not needed. CoreText manage fallback directly
-void CoreTextLayout::DropGlyph( int /*nStart*/ ) {}
+void CoreTextLayout::DropGlyph( int /*nStart*/ )
+{
+}
 
 long CoreTextLayout::FillDXArray( sal_Int32* pDXArray ) const
 {
-    SAL_INFO( "vcl.coretext.layout", "-->" );
+    SAL_INFO( "vcl.coretext.layout", "FillDXArray(" << this << ")" );
+
     // short circuit requests which don't need full details
-    if( !pDXArray )
-    {
+    if( !pDXArray ) {
+        SAL_INFO( "vcl.coretext.layout", "FillDXArray() returning GetTextWidth()" );
         return GetTextWidth();
     }
 
-    // initialize details about the resulting layout
-    InitGIA();
-
     // distribute the widths among the string elements
     long width = 0;
     float scale = mpStyle->GetFontStretchFactor();
-    mnCachedWidth = 0;
+    CGFloat accumulated_width = 0;
 
     for( int i = 0; i < mnCharCount; ++i )
     {
         // convert and adjust for accumulated rounding errors
-        mnCachedWidth += mpCharWidths[i];
+        accumulated_width += mpCharWidths[i];
         const long old_width = width;
-        width = round_to_long(mnCachedWidth * scale);
+        width = round_to_long(accumulated_width * scale);
         pDXArray[i] = width - old_width;
     }
-    SAL_INFO( "vcl.coretext.layout", " width=" << width << " <--" );
+
+    SAL_INFO( "vcl.coretext.layout", "FillDXArrar() returning " << width );
+
     return width;
 }
 
 bool CoreTextLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect ) const
 {
 
-    SAL_INFO( "vcl.coretext.layout", "-->" );
+    SAL_INFO( "vcl.coretext.layout", "GetBoundRect(" << this << ")" );
+
     if ( !mbHasBoundRectangle )
     {
         QuartzSalGraphics& gr = static_cast<QuartzSalGraphics&>(rGraphics);
@@ -254,14 +323,17 @@ bool CoreTextLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect )
         }
         mbHasBoundRectangle = true;
     }
+
     rVCLRect = maBoundRectangle;
-    SAL_INFO( "vcl.coretext.layout", "<--" );
+    SAL_INFO( "vcl.coretext.layout", "GetBoundRect() returning with rVCLRect={" << rVCLRect << "}" );
+
     return true;
 }
 
-void CoreTextLayout::GetCaretPositions( int max_index, sal_Int32* caret_position) const
+void CoreTextLayout::GetCaretPositions( int max_index, sal_Int32* caret_position ) const
 {
-    SAL_INFO( "vcl.coretext.layout", "max_index " << max_index << " -->" );
+    SAL_INFO( "vcl.coretext.layout", "GetCaretPositions(" << this << ",max_index=" << max_index << ")" );
+
     int local_max = max_index < mnCharCount * 2 ? max_index : mnCharCount;
     for(int i = 0 ; i < max_index - 1; i+=2)
     {
@@ -275,17 +347,17 @@ void CoreTextLayout::GetCaretPositions( int max_index, sal_Int32* caret_position
     {
         caret_position[i] = -1;
     }
-    SAL_INFO( "vcl.coretext.layout", "<--" );
 }
 
-bool CoreTextLayout::GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const { return false; }
+bool CoreTextLayout::GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const
+{
+    return false;
+}
 
 int CoreTextLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& nStart,
                                    sal_Int32* pGlyphAdvances, int* pCharIndexes ) const
 {
-    SAL_INFO( "vcl.coretext.layout", "nLen=" << nLen << " nStart=" << nStart << " -->");
-    // get glyph measurements
-    InitGIA();
+    SAL_INFO( "vcl.coretext.layout", "GetNextGlyphs(" << this << ",nLen=" << nLen << ",nStart=" << nStart << ")" );
 
     if( nStart < 0 )                // first glyph requested?
     {
@@ -347,46 +419,146 @@ int CoreTextLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos
         i += 1;
         nStart += 1;
     }
-    SAL_INFO( "vcl.coretext.layout", "i=" << i << " <--" );
+
+    SAL_INFO( "vcl.coretext.layout", "GetNextGlyphs() returning " << i );
+
     return i;
 }
 
-int CoreTextLayout::GetTextBreak( long /*nMaxWidth*/, long /*nCharExtra*/, int /*nFactor*/ ) const
+int CoreTextLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
 {
-    /* TODO */
-    return false;
+    SAL_INFO( "vcl.coretext.layout", "GetTextBreak(" << this << ",nMaxWidth=" << nMaxWidth << ",nCharExtra=" << nCharExtra << ",nFactor=" << nFactor << ")" );
+
+    if( !mpLine ) {
+        SAL_INFO( "vcl.coretext.layout", "GetTextBreak() returning STRING_LEN" );
+        return STRING_LEN;
+    }
+
+    // the semantics of the legacy use case (nCharExtra!=0) cannot be mapped to ATSUBreakLine()
+    if( nCharExtra != 0 )
+    {
+#if 0
+        // prepare the measurement by layouting and measuring the un-expanded/un-condensed text
+        if( !InitGIA() )
+            return STRING_LEN;
+
+        // TODO: use a better way than by testing each the char position
+        ATSUTextMeasurement nATSUSumWidth = 0;
+        const ATSUTextMeasurement nATSUMaxWidth = Vcl2Fixed( nMaxWidth / nFactor );
+        const ATSUTextMeasurement nATSUExtraWidth = Vcl2Fixed( nCharExtra ) / nFactor;
+        for( int i = 0; i < mnCharCount; ++i )
+        {
+            nATSUSumWidth += mpCharWidths[i];
+            if( nATSUSumWidth >= nATSUMaxWidth )
+                return (mnMinCharPos + i);
+            nATSUSumWidth += nATSUExtraWidth;
+            if( nATSUSumWidth >= nATSUMaxWidth )
+                if( i+1 < mnCharCount )
+                    return (mnMinCharPos + i);
+        }
+
+        return STRING_LEN;
+#endif
+    }
+
+    // get a quick overview on what could fit
+    const CGFloat nPixelWidth = (nMaxWidth - (nCharExtra * mnCharCount)) / nFactor;
+    if( nPixelWidth <= 0 ) {
+        SAL_INFO( "vcl.coretext.layout", "GetTextBreak(): nPixelWidth=" << nPixelWidth << ", returning mnMinCharPos=" << mnMinCharPos );
+        return mnMinCharPos;
+    }
+
+    CFIndex nBreakPos = CTTypesetterSuggestLineBreak( mpTypesetter, 0, nPixelWidth ) + mnMinCharPos;
+
+    // upper layers expect STRING_LEN if everything fits
+    if( nBreakPos >= mnEndCharPos ) {
+        SAL_INFO( "vcl.coretext.layout", "GetTextBreak(): nBreakPos=" << nBreakPos << " >= mnEndCharPos=" << mnEndCharPos << ", returning STRING_LEN" );
+        return STRING_LEN;
+    }
+
+    SAL_INFO( "vcl.coretext.layout", "GetTextBreak() returning nBreakPos=" << nBreakPos );
+
+    return nBreakPos;
 }
 
 long CoreTextLayout::GetTextWidth() const
 {
-    SAL_INFO( "vcl.coretext.layout", "-->" );
-
     CGRect bound_rect = CTLineGetImageBounds(mpLine, mpGraphics->GetContext());
     long w = round_to_long(bound_rect.size.width * mpStyle->GetFontStretchFactor());
-    SAL_INFO( "vcl.coretext.layout", "w=" << w << " <--" );
+
+    SAL_INFO( "vcl.coretext.layout", "GetTextWidth(" << this << ") returning " << w );
+
     return w;
 }
 
 // not needed. CoreText manage fallback directly
 void CoreTextLayout::InitFont() const
 {
-    SAL_INFO( "vcl.coretext.layout", "<-->" );
+    SAL_INFO( "vcl.coretext.layout", "InitFont(" << this << ")" );
 }
 
-bool CoreTextLayout::InitGIA() const
+bool CoreTextLayout::InitGIA( ImplLayoutArgs& rArgs ) const
 {
-    SAL_INFO( "vcl.coretext.layout", "count=" << mnCharCount << "-->" );
+    SAL_INFO( "vcl.coretext.layout", "InitGIA(" << this << "): " << mnCharCount << ":" << rArgs.mnMinCharPos << "--" << mnEndCharPos );
 
-    if( mnCharCount <= 0)
-    {
+    if( mnCharCount <= 0) {
+        SAL_INFO( "vcl.coretext.layout", "InitGIA(): mnCharCount is non-positive, returning false" );
         return false;
     }
-    if(mpGlyphs)
-    {
+
+    if( mpGlyphs ) {
+        SAL_INFO( "vcl.coretext.layout", "InitGIA(): mpGlyphs is non-NULL, returning true" );
         return true;
     }
 
-    mpGlyphs = new CGGlyph[mnGlyphCount];
+    // Note that unlike the ATSUI code, we store only the part of the
+    // buffer addressed by mnMinCharPos--mnEndCharPos. Not the whole
+    // buffer. I.e. all indexing of the string as referenced to by
+    // mpTypesetter should be relative to mnMinCharPos.
+    CFStringRef string = CFStringCreateWithCharacters( NULL, &(rArgs.mpStr[rArgs.mnMinCharPos]), mnCharCount );
+    if ( !string ) {
+        SAL_INFO( "vcl.coretext.layout", "InitGIA(): CFStringCreateWithCharacter() returned NULL, returning false" );
+        return false;
+    }
+
+    CFStringRef keys[6];
+    CFTypeRef values[6];
+
+    keys[0] = kCTFontAttributeName;
+    values[0] = CFRetain( mpStyle->GetFont() );
+
+    CFDictionaryRef attributes = CFDictionaryCreate( kCFAllocatorDefault,
+                                                     (const void**)&keys,
+                                                     (const void**)&values,
+                                                     1,
+                                                     &kCFTypeDictionaryKeyCallBacks,
+                                                     &kCFTypeDictionaryValueCallBacks );
+
+    CFAttributedStringRef attributed_string = CFAttributedStringCreate( NULL, string, attributes );
+    CFRelease( string );
+    CFRelease( attributes );
+    if ( !attributed_string ) {
+        SAL_INFO( "vcl.coretext.layout", "InitGIA(): CFAttributedStringCreate() returned NULL, returning false" );
+        return false;
+    }
+
+    mpTypesetter = CTTypesetterCreateWithAttributedString( attributed_string );
+    CFRelease( attributed_string );
+    if( !mpTypesetter ) {
+        SAL_INFO( "vcl.coretext.layout", "InitGIA(): CTTypesetterCreateWithAttributedString() returned NULL, returning false" );
+        return false;
+    }
+
+    mpLine = CTTypesetterCreateLine( mpTypesetter, CFRangeMake( 0, 0 ) );
+    if( !mpLine ) {
+        SAL_INFO( "vcl.coretext.layout", "InitGIA(): CTTypesetterCreateLine() returned NULL, returning false" );
+        return false;
+    }
+
+    mnGlyphCount = CTLineGetGlyphCount( mpLine );
+    SAL_INFO( "vcl.coretext.layout", "InitGIA(): CTLineGetGlyphCount() returned " << mnGlyphCount );
+
+    mpGlyphs = new CGGlyph[ mnGlyphCount ];
     mpCharWidths = new int[ mnCharCount ];
     mpChars2Glyphs = new int[ mnCharCount ];
     for( int i = 0; i < mnCharCount; ++i)
@@ -394,13 +566,13 @@ bool CoreTextLayout::InitGIA() const
         mpCharWidths[i] = 0.0;
         mpChars2Glyphs[i] = -1;
     }
-    mpGlyphs2Chars = new int[mnGlyphCount];
-    mpGlyphAdvances = new int[mnGlyphCount];
-    mpGlyphPositions = new CGPoint[mnGlyphCount];
-
+    mpGlyphs2Chars = new int[ mnGlyphCount ];
+    mpGlyphAdvances = new int[ mnGlyphCount ];
+    mpGlyphPositions = new CGPoint[ mnGlyphCount ];
 
     CFArrayRef runs = CTLineGetGlyphRuns( mpLine );
     CFIndex nb_runs = CFArrayGetCount( runs );
+
     int p = 0;
     for( CFIndex i = 0; i < nb_runs; ++i )
     {
@@ -428,10 +600,12 @@ bool CoreTextLayout::InitGIA() const
 
                     for (CFIndex j = 0 ; j < nb_glyphs; ++p, ++j )
                     {
+                        assert ( p < mnGlyphCount );
                         mpGlyphs[ p ] = glyphs[ j ];
-                        SAL_INFO( "vcl.coretext.layout", "m_glyphys[" << p << "]=glyphs[" << j << "] run " << i << " : 0x" << std::hex << glyphs[j] << std::dec );
+                        // SAL_INFO( "vcl.coretext.layout", "  mpGlyphs[" << p << "]=glyphs[" << j << "]=0x" << std::hex << glyphs[j] << std::dec );
                         CFIndex k = indices[ j ];
                         mpGlyphs2Chars[p] = k;
+                        assert( k < mnCharCount );
                         mpChars2Glyphs[k] = p;
 
                         if ( j < nb_glyphs - 1 )
@@ -447,28 +621,28 @@ bool CoreTextLayout::InitGIA() const
 			}
         }
     }
-    SAL_INFO( "vcl.coretext.layout", "<--" );
+
+    SAL_INFO( "vcl.coretext.layout", "InitGIA() returning normally true" );
     return true;
 }
 
-bool CoreTextLayout::LayoutText(ImplLayoutArgs& args)
+bool CoreTextLayout::LayoutText( ImplLayoutArgs& rArgs)
 {
-    SAL_INFO( "vcl.coretext.layout", "mpStyle=" << mpStyle << " font=" << mpStyle->GetFont() << " -->" );
-    Clean();
+    SAL_INFO( "vcl.coretext.layout", "LayoutText(" << this << ",rArgs=" << rArgs << ")" );
+
     mpStyle->SetColor();
-    /* retreive MinCharPos EndCharPos Flags and Orientation */
-    SalLayout::AdjustLayout(args);
-    mnCharCount = mnEndCharPos - mnMinCharPos;
 
-    /* don't layout emptty (or worse negative size) strings */
-    if(mnCharCount <= 0)
-    {
+    AdjustLayout( rArgs );
+
+    /* don't layout empty (or worse negative size) strings */
+    if(mnCharCount <= 0) {
+        SAL_INFO( "vcl.coretext.layout", "LayoutText(): mnCharCount non-positive, returning false!" );
         return false;
     }
 
 #ifdef IOS
-    // This might be caused by some red herring and be unnecessary
-    // once the CoreText code actually works;)
+    // This might be a red herring and unnecessary once the CoreText
+    // code actually works;)
 
     // If the string contains U+FFFD ("REPLACEMENT CHARACTER"), which
     // happens at least for the ooo80484-1.slk document in
@@ -478,73 +652,30 @@ bool CoreTextLayout::LayoutText(ImplLayoutArgs& args)
     // but play it safe.)
     for (int i = 0; i < mnCharCount; i++)
     {
-        if (args.mpStr[args.mnMinCharPos+i] == 0xFFFD)
+        if ( rArgs.mpStr[rArgs.mnMinCharPos+i] == 0xFFFD)
             return false;
     }
 #endif
 
-    /* c0 and c1 are construction objects */
-    CFStringRef c0 = CFStringCreateWithCharactersNoCopy( NULL, &(args.mpStr[args.mnMinCharPos]), mnCharCount, kCFAllocatorNull );
-    if ( !c0 )
-    {
-        Clean();
-        return false;
-    }
-
-    CFStringRef keys[6];
-    CFTypeRef   values[6];
-    int nb_attributes = 0;
-
-    keys[nb_attributes]= kCTFontAttributeName;
-    values[nb_attributes] = mpStyle->GetFont();
-    nb_attributes += 1;
-
-    CFDictionaryRef attributes = CFDictionaryCreate(kCFAllocatorDefault,
-                                                    (const void**)&keys,
-                                                    (const void**)&values,
-                                                    nb_attributes,
-                                                    &kCFTypeDictionaryKeyCallBacks,
-                                                    &kCFTypeDictionaryValueCallBacks);
-
-
-    CFAttributedStringRef string = CFAttributedStringCreate( NULL, c0, attributes );
-    CFRelease( c0 );
-    CFRelease( attributes );
-    if ( !string )
-    {
-        Clean();
-        return false;
-    }
-    mpTypesetter = CTTypesetterCreateWithAttributedString(string);
-    CFRelease(string);
-    if(!mpTypesetter)
-    {
-        Clean();
-        return false;
-    }
-    mpLine = CTTypesetterCreateLine(mpTypesetter, CFRangeMake(0, 0));
-    if(!mpLine)
-    {
-        Clean();
-        return false;
-    }
-    mnGlyphCount = CTLineGetGlyphCount(mpLine);
+    SAL_INFO( "vcl.coretext.layout", "LayoutText() returning,  mnGlyphCount=" << mnGlyphCount );
 
-    SAL_INFO( "vcl.coretext.layout", "glyph_count=" << mnGlyphCount << " <--" );
     return true;
 }
 
 // not needed. CoreText manage fallback directly
-void CoreTextLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ ) {}
+void CoreTextLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ )
+{
+}
 
 // not needed. CoreText manage fallback directly
-void CoreTextLayout::Simplify( bool /*bIsBase*/ ) {}
+void CoreTextLayout::Simplify( bool /*bIsBase*/ )
+{
+}
 
 SalLayout* QuartzSalGraphics::GetTextLayout( ImplLayoutArgs&, int /*nFallbackLevel*/ )
 {
-    SAL_INFO( "vcl.coretext.gr", "-->" );
     CoreTextLayout* layout = new CoreTextLayout( this, m_style );
-    SAL_INFO( "vcl.coretext.gr", "layout:" << layout << " <--" );
+
     return layout;
 }
 
diff --git a/vcl/coretext/salcoretextstyle.cxx b/vcl/coretext/salcoretextstyle.cxx
index b468b89..5f2c15b 100644
--- a/vcl/coretext/salcoretextstyle.cxx
+++ b/vcl/coretext/salcoretextstyle.cxx
@@ -32,12 +32,13 @@ CoreTextStyleInfo::CoreTextStyleInfo() :
     m_color(NULL),
     m_font_face(NULL)
 {
-    SAL_INFO( "vcl.coretext.style", "create <-->" );
+    SAL_INFO( "vcl.coretext.style", "CoreTextStyleInfo::CoreTextStyleInfo() " << this );
 }
 
 CoreTextStyleInfo::~CoreTextStyleInfo()
 {
-    SAL_INFO( "vcl.coretext.style", "destroy (font:" << m_CTFont << ") <-->" );
+    SAL_INFO( "vcl.coretext.style", "~CoreTextStyleInfo(" << this << "), font=" << m_CTFont );
+
     SafeCFRelease(m_CTFont);
     SafeCFRelease(m_CTParagraphStyle);
     SafeCFRelease(m_color);
@@ -51,7 +52,7 @@ long CoreTextStyleInfo::GetFontStretchedSize() const
 
 void CoreTextStyleInfo::SetFont(FontSelectPattern* requested_font)
 {
-    SAL_INFO( "vcl.coretext.style", "req(" << requested_font << ") release font " << m_CTFont << " -->" );
+    SAL_INFO( "vcl.coretext.style", "SetFont(" << this );
 
     if(!requested_font)
     {
@@ -92,12 +93,14 @@ void CoreTextStyleInfo::SetFont(FontSelectPattern* requested_font)
     /* FIXME: pass attribute to take into accout 'VerticalStyle' */
     /* FIXME: how to deal with 'rendering options' i.e anti-aliasing, does it even matter in CoreText ? */
     m_CTFont = CTFontCreateCopyWithAttributes(m_font_face->GetCTFont(), font_size, &m_matrix, NULL);
-    SAL_INFO( "vcl.coretext.style", "font " << m_CTFont << " <--" );
+
+    SAL_INFO( "vcl.coretext.style", "  font=" << m_CTFont );
 }
 
 void CoreTextStyleInfo::SetColor(SalColor color)
 {
-    SAL_INFO( "vcl.coretext.style", "r:" << SALCOLOR_RED(color) << ",g:" << SALCOLOR_GREEN(color) << ",b:" << SALCOLOR_BLUE(color) );
+    SAL_INFO( "vcl.coretext.style", "SetColor(" << this << ",color={" << SALCOLOR_RED(color) << "," << SALCOLOR_GREEN(color) << "," << SALCOLOR_BLUE(color) << "})" );
+
     SafeCFRelease(m_color);
 #ifdef IOS
     // No CGColorCreateGenericRGB on iOS
@@ -108,14 +111,13 @@ void CoreTextStyleInfo::SetColor(SalColor color)
 #else
     m_color = CGColorCreateGenericRGB(SALCOLOR_RED(color) / 255.0, SALCOLOR_GREEN(color) / 255.0, SALCOLOR_BLUE(color) / 255.0, 1.0);
 #endif
-    SAL_INFO( "vcl.coretext.style", "color=" << m_color << " <--" );
 }
 
 void CoreTextStyleInfo::SetColor(void)
 {
-    SAL_INFO( "vcl.coretext.style",  "null -->" );
+    SAL_INFO( "vcl.coretext.style",  "SetColor(" << this << ",none)" );
+
     SafeCFRelease(m_color);
-    SAL_INFO( "vcl.coretext.style", "color=" << m_color << " <--" );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx
index 64f4b17..05a93a5 100644
--- a/vcl/coretext/salgdi.cxx
+++ b/vcl/coretext/salgdi.cxx
@@ -48,20 +48,20 @@ QuartzSalGraphics::QuartzSalGraphics()
     , mbVirDev( false )
     , mbWindow( false )
 {
-    SAL_INFO( "vcl.coretext.gr", "-->" );
+    SAL_INFO( "vcl.coretext.gr", "QuartzSalGraphics::QuartzSalGraphics() " << this );
+
     m_style = new CoreTextStyleInfo();
-    SAL_INFO( "vcl.coretext.gr", "m_style=" << m_style << " <--" );
 }
 
 QuartzSalGraphics::~QuartzSalGraphics()
 {
-    SAL_INFO( "vcl.coretext.gr", "-->" );
+    SAL_INFO( "vcl.coretext.gr", "~QuartzSalGraphics(" << this << ")" );
+
     if(m_style)
     {
         delete m_style;
         m_style = NULL;
     }
-    SAL_INFO( "vcl.coretext.gr", "<--" );
 }
 
 inline bool QuartzSalGraphics::AddTempDevFont( ImplDevFontList*,
@@ -140,7 +140,14 @@ void QuartzSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbac
     pMetric->mnExtLeading   = nExtDescent + pMetric->mnDescent;
     pMetric->mnIntLeading   = 0;
     pMetric->mnWidth = m_style->GetFontStretchedSize();
-    SAL_INFO( "vcl.coretext.gr", "ascent=" << pMetric->mnAscent<< ", descent=" << pMetric->mnDescent << ", extleading=" << pMetric->mnExtLeading << ", intleading=" << pMetric->mnIntLeading << ", w=" << pMetric->mnWidth );
+
+    SAL_INFO( "vcl.coretext.gr",
+              "GetFontMetric(" << this << ") returning: {ascent=" << pMetric->mnAscent <<
+              ",descent=" << pMetric->mnDescent <<
+              ",extleading=" << pMetric->mnExtLeading <<
+              ",intleading=" << pMetric->mnIntLeading <<
+              ",width=" << pMetric->mnWidth <<
+              "}" );
 }
 
 sal_Bool QuartzSalGraphics::GetGlyphBoundRect( sal_GlyphId /*nGlyphId*/, Rectangle& /*rRect*/ )
@@ -203,7 +210,6 @@ bool QuartzSalGraphics::GetRawFontData( const PhysicalFontFace* pFontFace,
 
 SystemFontData QuartzSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const
 {
-    SAL_INFO( "vcl.coretext.gr", "-->" );
     SystemFontData aSysFontData;
     aSysFontData.nSize = sizeof( SystemFontData );
     aSysFontData.bAntialias = true;
@@ -236,23 +242,19 @@ SystemFontData QuartzSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) con
     aSysFontData.bVerticalCharacterType = vertical_font ? true : false;
     SafeCFRelease(vertical_font);
 
-    SAL_INFO( "vcl.coretext.gr", "<--" );
     return aSysFontData;
 }
 
 sal_uInt16 QuartzSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbackLevel*/ )
 {
-    SAL_INFO( "vcl.coretext.gr", "m_style=" << m_style << " -->" );
     m_style->SetFont(pReqFont);
-    SAL_INFO( "vcl.coretext.gr", "<--" );
+
     return 0;
 }
 
 void QuartzSalGraphics::SetTextColor( SalColor nSalColor )
 {
-    SAL_INFO( "vcl.coretext.gr", "m_style=" << m_style << " -->" );
     m_style->SetColor(nSalColor);
-    SAL_INFO( "vcl.coretext.gr", "<--" );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 654c1e56cb86e85eb5ee9df5bc7894ec24402760
Author: Tor Lillqvist <tml at iki.fi>
Date:   Thu Jan 24 18:20:59 2013 +0200

    Undo pointless field name changes
    
    The CoreTextLayout class is clearly based on the ATSLayout class, so
    in order to make it easier to compare code of the two, rename fields
    back as they are in the latter. Also add the corresponding comments
    where applicable.
    
    Once the CoreText code fully works and has superseded the ATSUI code,
    sure, we can change field naming convention if we want.
    
    Change-Id: I0d47ad0206fa895339506471bb638bd04f426490

diff --git a/vcl/coretext/salcoretextlayout.cxx b/vcl/coretext/salcoretextlayout.cxx
index f57d6c8..643c893 100644
--- a/vcl/coretext/salcoretextlayout.cxx
+++ b/vcl/coretext/salcoretextlayout.cxx
@@ -19,29 +19,87 @@
 
 #include "coretext/common.h"
 #include "coretext/salcoretextstyle.hxx"
-#include "coretext/salcoretextlayout.hxx"
 #include "coretext/salgdi.h"
 
+class CoreTextLayout : public SalLayout
+{
+public:
+    CoreTextLayout( QuartzSalGraphics* graphics, CoreTextStyleInfo* style);
+    virtual         ~CoreTextLayout();
+
+    virtual void AdjustLayout( ImplLayoutArgs& );
+    virtual void DrawText( SalGraphics& ) const;
+    virtual void DropGlyph( int nStart );
+    virtual long FillDXArray( sal_Int32* pDXArray ) const;
+    virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const;
+    virtual void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const;
+    virtual bool GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const;
+    virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&,
+                               sal_Int32* pGlyphAdvances, int* pCharIndexes ) const;
+    virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const;
+    virtual long GetTextWidth() const;
+    virtual void InitFont() const;
+    virtual bool LayoutText( ImplLayoutArgs& );
+    virtual void MoveGlyph( int nStart, long nNewXPos );
+    virtual void Simplify( bool bIsBase );
+
+private:
+    void Clean();
+    bool InitGIA() const;
+
+    QuartzSalGraphics* mpGraphics;
+    CoreTextStyleInfo* mpStyle;
+
+    int mnCharCount;                    // ==mnEndCharPos-mnMinCharPos
+
+    // cached details about the resulting layout
+    // mutable members since these details are all lazy initialized
+    mutable int mnGlyphCount;           // glyph count
+    mutable CGFloat mnCachedWidth;      // cached value of resulting typographical width
+
+    mutable CGGlyph* mpGlyphs;          // glyphs
+    mutable int* mpCharWidths;          // map relative charpos to charwidth
+    mutable int* mpChars2Glyphs;        // map relative charpos to absolute glyphpos
+    mutable int* mpGlyphs2Chars;        // map absolute glyphpos to absolute charpos
+
+    mutable int* mpGlyphAdvances;       // glyph widths for the justified layout
+
+    mutable CGPoint* mpGlyphPositions; 
+    CTTypesetterRef mpTypesetter;
+    CTLineRef mpLine;
+    mutable bool mbHasBoundRectangle;
+    mutable Rectangle maBoundRectangle;
+
+    // x-offset relative to layout origin
+    // currently only used in RTL-layouts
+    CGFloat mnBaseAdvance;
+
+    mutable CFIndex mnCurrentRunIndex;
+    mutable CFIndex mnCurrentGlyphIndex;
+    mutable CFIndex mnCurrentGlyphRunIndex;
+    mutable CFArrayRef mpRuns;
+};
+
 CoreTextLayout::CoreTextLayout(QuartzSalGraphics* graphics, CoreTextStyleInfo* style) :
-    m_graphics(graphics),
-    m_style(style),
-    m_glyphs_count(-1),
-    m_chars_count(-1),
-    m_chars2glyphs(NULL),
-    m_glyphs2chars(NULL),
-    m_glyphs(NULL),
-    m_char_widths(NULL),
-    m_glyph_advances(NULL),
-    m_glyph_positions(NULL),
-    m_typesetter(NULL),
-    m_line(NULL),
-    m_has_bound_rec(false),
-    m_base_advance(0),
-    m_cached_width(0.0F),
-    m_current_run_index(0),
-    m_current_glyph_index(0),
-    m_current_glyphrun_index(0),
-    m_runs(NULL)
+    mpGraphics(graphics),
+    mpStyle(style),
+    mnCharCount(-1),
+    mnGlyphCount(-1),
+    mnCachedWidth(0.0F),
+    mpGlyphs(NULL),
+    mpCharWidths(NULL),
+    mpChars2Glyphs(NULL),
+    mpGlyphs2Chars(NULL),
+    mpGlyphAdvances(NULL),
+    mpGlyphPositions(NULL),
+    mpTypesetter(NULL),
+    mpLine(NULL),
+    mbHasBoundRectangle(false),
+    mnBaseAdvance(0),
+    mnCurrentRunIndex(0),
+    mnCurrentGlyphIndex(0),
+    mnCurrentGlyphRunIndex(0),
+    mpRuns(NULL)
 {
 }
 
@@ -60,39 +118,39 @@ void CoreTextLayout::AdjustLayout( ImplLayoutArgs& /*rArgs*/ )
 void CoreTextLayout::Clean()
 {
     SAL_INFO( "vcl.coretext.layout", "-->" );
-    if(m_glyphs)
+    if(mpGlyphs)
     {
-        delete[] m_glyphs;
-        m_glyphs = NULL;
+        delete[] mpGlyphs;
+        mpGlyphs = NULL;
     }
-    if(m_chars2glyphs)
+    if(mpChars2Glyphs)
     {
-        delete[] m_chars2glyphs;
-        m_chars2glyphs = NULL;
+        delete[] mpChars2Glyphs;
+        mpChars2Glyphs = NULL;
     }
-    if(m_glyphs2chars)
+    if(mpGlyphs2Chars)
     {
-        delete[] m_glyphs2chars;
-        m_glyphs2chars = NULL;
+        delete[] mpGlyphs2Chars;
+        mpGlyphs2Chars = NULL;
     }
-    if(m_char_widths)
+    if(mpCharWidths)
     {
-        delete[] m_char_widths;
-        m_char_widths = NULL;
+        delete[] mpCharWidths;
+        mpCharWidths = NULL;
     }
-    if(m_glyph_advances)
+    if(mpGlyphAdvances)
     {
-        delete[] m_glyph_advances;
-        m_glyph_advances = NULL;
+        delete[] mpGlyphAdvances;
+        mpGlyphAdvances = NULL;
     }
-    if(m_glyph_positions)
+    if(mpGlyphPositions)
     {
-        delete[] m_glyph_positions;
-        m_glyph_positions = NULL;
+        delete[] mpGlyphPositions;
+        mpGlyphPositions = NULL;
     }
-    SafeCFRelease(m_typesetter);
-    SafeCFRelease(m_line);
-    m_has_bound_rec = false;
+    SafeCFRelease(mpTypesetter);
+    SafeCFRelease(mpLine);
+    mbHasBoundRectangle = false;
     SAL_INFO( "vcl.coretext.layout", "<--" );
 }
 
@@ -100,7 +158,7 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
 {
     SAL_INFO( "vcl.coretext.layout", "-->" );
     QuartzSalGraphics& gr = static_cast<QuartzSalGraphics&>(rGraphics);
-    if(m_chars_count <= 0 || !gr.CheckContext())
+    if(mnCharCount <= 0 || !gr.CheckContext())
     {
         return;
     }
@@ -111,24 +169,24 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
     CGContextSetTextMatrix(gr.mrContext, CGAffineTransformMakeScale(1.0, -1.0));
     CGContextSetShouldAntialias( gr.mrContext, !gr.mbNonAntialiasedText );
     CGContextSetTextPosition(gr.mrContext, pos.X(), pos.Y());
-    CTLineDraw(m_line, gr.mrContext);
+    CTLineDraw(mpLine, gr.mrContext);
 #else
     InitGIA();
-    SAL_INFO( "vcl.coretext.layout", "at pos (" << pos.X() << "," << pos.Y() <<") ctfont=" << m_style->GetFont() );
-    CGFontRef cg_font = CTFontCopyGraphicsFont(m_style->GetFont(), NULL);
+    SAL_INFO( "vcl.coretext.layout", "at pos (" << pos.X() << "," << pos.Y() <<") ctfont=" << mpStyle->GetFont() );
+    CGFontRef cg_font = CTFontCopyGraphicsFont(mpStyle->GetFont(), NULL);
     if(!cg_font)
     {
         SAL_INFO( "vcl.coretext.layout", "Error cg_font is NULL" );
         return;
     }
     CGContextSetFont(gr.mrContext, cg_font);
-    CGContextSetFontSize(gr.mrContext, CTFontGetSize(m_style->GetFont()));
+    CGContextSetFontSize(gr.mrContext, CTFontGetSize(mpStyle->GetFont()));
     CGContextSetTextDrawingMode(gr.mrContext, kCGTextFill);
     CGContextSetShouldAntialias( gr.mrContext, true );
-    if(m_style->GetColor())
+    if(mpStyle->GetColor())
     {
-        CGContextSetFillColorWithColor(gr.mrContext, m_style->GetColor());
-        CGContextSetStrokeColorWithColor(gr.mrContext, m_style->GetColor());
+        CGContextSetFillColorWithColor(gr.mrContext, mpStyle->GetColor());
+        CGContextSetStrokeColorWithColor(gr.mrContext, mpStyle->GetColor());
     }
     else
     {
@@ -138,7 +196,7 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
     CGContextSetTextMatrix(gr.mrContext, CGAffineTransformMakeScale(1.0, -1.0));
     CGContextSetShouldAntialias( gr.mrContext, !gr.mbNonAntialiasedText );
     CGContextTranslateCTM(gr.mrContext, pos.X(), pos.Y());
-    CGContextShowGlyphs(gr.mrContext, m_glyphs, m_glyphs_count);
+    CGContextShowGlyphs(gr.mrContext, mpGlyphs, mnGlyphCount);
 #endif
     // restore the original graphic context transformations
     CGContextRestoreGState( gr.mrContext );
@@ -163,15 +221,15 @@ long CoreTextLayout::FillDXArray( sal_Int32* pDXArray ) const
 
     // distribute the widths among the string elements
     long width = 0;
-    float scale = m_style->GetFontStretchFactor();
-    m_cached_width = 0;
+    float scale = mpStyle->GetFontStretchFactor();
+    mnCachedWidth = 0;
 
-    for( int i = 0; i < m_chars_count; ++i )
+    for( int i = 0; i < mnCharCount; ++i )
     {
         // convert and adjust for accumulated rounding errors
-        m_cached_width += m_char_widths[i];
+        mnCachedWidth += mpCharWidths[i];
         const long old_width = width;
-        width = round_to_long(m_cached_width * scale);
+        width = round_to_long(mnCachedWidth * scale);
         pDXArray[i] = width - old_width;
     }
     SAL_INFO( "vcl.coretext.layout", " width=" << width << " <--" );
@@ -182,21 +240,21 @@ bool CoreTextLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect )
 {
 
     SAL_INFO( "vcl.coretext.layout", "-->" );
-    if ( !m_has_bound_rec )
+    if ( !mbHasBoundRectangle )
     {
         QuartzSalGraphics& gr = static_cast<QuartzSalGraphics&>(rGraphics);
-        CGRect bound_rect = CTLineGetImageBounds( m_line, gr.mrContext );
+        CGRect bound_rect = CTLineGetImageBounds( mpLine, gr.mrContext );
         if ( !CGRectIsNull( bound_rect ) )
         {
-            m_bound_rect = Rectangle(
-                Point( round_to_long(bound_rect.origin.x * m_style->GetFontStretchFactor()),
+            maBoundRectangle = Rectangle(
+                Point( round_to_long(bound_rect.origin.x * mpStyle->GetFontStretchFactor()),
                        round_to_long(bound_rect.origin.y - bound_rect.size.height )),
-                Size( round_to_long(bound_rect.size.width * m_style->GetFontStretchFactor()), round_to_long(bound_rect.size.height)));
-            m_bound_rect.Justify();
+                Size( round_to_long(bound_rect.size.width * mpStyle->GetFontStretchFactor()), round_to_long(bound_rect.size.height)));
+            maBoundRectangle.Justify();
         }
-        m_has_bound_rec = true;
+        mbHasBoundRectangle = true;
     }
-    rVCLRect = m_bound_rect;
+    rVCLRect = maBoundRectangle;
     SAL_INFO( "vcl.coretext.layout", "<--" );
     return true;
 }
@@ -204,13 +262,13 @@ bool CoreTextLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect )
 void CoreTextLayout::GetCaretPositions( int max_index, sal_Int32* caret_position) const
 {
     SAL_INFO( "vcl.coretext.layout", "max_index " << max_index << " -->" );
-    int local_max = max_index < m_chars_count * 2 ? max_index : m_chars_count;
+    int local_max = max_index < mnCharCount * 2 ? max_index : mnCharCount;
     for(int i = 0 ; i < max_index - 1; i+=2)
     {
         CGFloat primary, secondary;
-        primary = CTLineGetOffsetForStringIndex(m_line, i >> 1, &secondary);
-        caret_position[i] = round_to_long(m_base_advance + primary);
-        caret_position[i+1] = round_to_long(m_base_advance + secondary);
+        primary = CTLineGetOffsetForStringIndex(mpLine, i >> 1, &secondary);
+        caret_position[i] = round_to_long(mnBaseAdvance + primary);
+        caret_position[i+1] = round_to_long(mnBaseAdvance + secondary);
         i += 2;
     }
     for(int i = local_max ; i < max_index ; ++i)
@@ -232,60 +290,60 @@ int CoreTextLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos
     if( nStart < 0 )                // first glyph requested?
     {
         nStart = 0;
-        m_current_run_index = 0;
-        m_current_glyph_index = 0;
-        m_current_glyphrun_index = 0;
+        mnCurrentRunIndex = 0;
+        mnCurrentGlyphIndex = 0;
+        mnCurrentGlyphRunIndex = 0;
     }
-    else if(nStart >= m_glyphs_count)
+    else if(nStart >= mnGlyphCount)
     {
-        m_current_run_index = 0;
-        m_current_glyph_index = 0;
-        m_current_glyphrun_index = 0;
+        mnCurrentRunIndex = 0;
+        mnCurrentGlyphIndex = 0;
+        mnCurrentGlyphRunIndex = 0;
         return 0;
     }
-    if(!m_runs)
+    if(!mpRuns)
     {
-        m_runs = CTLineGetGlyphRuns(m_line);
+        mpRuns = CTLineGetGlyphRuns(mpLine);
     }
-    CFIndex nb_runs = CFArrayGetCount( m_runs );
-    CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex( m_runs, m_current_run_index );
+    CFIndex nb_runs = CFArrayGetCount( mpRuns );
+    CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex( mpRuns, mnCurrentRunIndex );
     CFIndex nb_glyphs = CTRunGetGlyphCount( run );
 
     int i = 0;
     bool first = true;
     while(i < nLen)
     {
-        if(m_current_glyphrun_index >= nb_glyphs)
+        if(mnCurrentGlyphRunIndex >= nb_glyphs)
         {
-            m_current_run_index += 1;
-            if(m_current_run_index >= nb_runs)
+            mnCurrentRunIndex += 1;
+            if(mnCurrentRunIndex >= nb_runs)
             {
                 break;
             }
-            run = (CTRunRef)CFArrayGetValueAtIndex( m_runs, m_current_run_index );
+            run = (CTRunRef)CFArrayGetValueAtIndex( mpRuns, mnCurrentRunIndex );
             nb_glyphs = CTRunGetGlyphCount( run );
-            m_current_glyphrun_index = 0;
+            mnCurrentGlyphRunIndex = 0;
         }
         if(first)
         {
             CGPoint first_pos;
-            CTRunGetPositions(run, CFRangeMake(m_current_glyphrun_index,1), &first_pos);
+            CTRunGetPositions(run, CFRangeMake(mnCurrentGlyphRunIndex,1), &first_pos);
             Point pos(first_pos.x, first_pos.y);
             rPos = GetDrawPosition(pos);
             SAL_INFO( "vcl.coretext.layout", "rPos(" << rPos.X() << "," << rPos.Y() << ")" );
             first = false;
         }
-        pGlyphIDs[i] = m_glyphs[m_current_glyph_index];
+        pGlyphIDs[i] = mpGlyphs[mnCurrentGlyphIndex];
         if(pGlyphAdvances)
         {
-            pGlyphAdvances[i] = m_glyph_advances[m_current_glyph_index];
+            pGlyphAdvances[i] = mpGlyphAdvances[mnCurrentGlyphIndex];
         }
         if(pCharIndexes)
         {
-            pCharIndexes[i] = m_glyphs2chars[m_current_glyph_index];
+            pCharIndexes[i] = mpGlyphs2Chars[mnCurrentGlyphIndex];
         }
-        m_current_glyph_index += 1;
-        m_current_glyphrun_index += 1;
+        mnCurrentGlyphIndex += 1;
+        mnCurrentGlyphRunIndex += 1;
         i += 1;
         nStart += 1;
     }
@@ -303,8 +361,8 @@ long CoreTextLayout::GetTextWidth() const
 {
     SAL_INFO( "vcl.coretext.layout", "-->" );
 
-    CGRect bound_rect = CTLineGetImageBounds(m_line, m_graphics->GetContext());
-    long w = round_to_long(bound_rect.size.width * m_style->GetFontStretchFactor());
+    CGRect bound_rect = CTLineGetImageBounds(mpLine, mpGraphics->GetContext());
+    long w = round_to_long(bound_rect.size.width * mpStyle->GetFontStretchFactor());
     SAL_INFO( "vcl.coretext.layout", "w=" << w << " <--" );
     return w;
 }
@@ -317,31 +375,31 @@ void CoreTextLayout::InitFont() const
 
 bool CoreTextLayout::InitGIA() const
 {
-    SAL_INFO( "vcl.coretext.layout", "count=" << m_chars_count << "-->" );
+    SAL_INFO( "vcl.coretext.layout", "count=" << mnCharCount << "-->" );
 
-    if( m_chars_count <= 0)
+    if( mnCharCount <= 0)
     {
         return false;
     }
-    if(m_glyphs)
+    if(mpGlyphs)
     {
         return true;
     }
 
-    m_glyphs = new CGGlyph[m_glyphs_count];
-    m_char_widths = new int[ m_chars_count ];
-    m_chars2glyphs = new int[ m_chars_count ];
-    for( int i = 0; i < m_chars_count; ++i)
+    mpGlyphs = new CGGlyph[mnGlyphCount];
+    mpCharWidths = new int[ mnCharCount ];
+    mpChars2Glyphs = new int[ mnCharCount ];
+    for( int i = 0; i < mnCharCount; ++i)
     {
-        m_char_widths[i] = 0.0;
-        m_chars2glyphs[i] = -1;
+        mpCharWidths[i] = 0.0;
+        mpChars2Glyphs[i] = -1;
     }
-    m_glyphs2chars = new int[m_glyphs_count];
-    m_glyph_advances = new int[m_glyphs_count];
-    m_glyph_positions = new CGPoint[m_glyphs_count];
+    mpGlyphs2Chars = new int[mnGlyphCount];
+    mpGlyphAdvances = new int[mnGlyphCount];
+    mpGlyphPositions = new CGPoint[mnGlyphCount];
 
 
-    CFArrayRef runs = CTLineGetGlyphRuns( m_line );
+    CFArrayRef runs = CTLineGetGlyphRuns( mpLine );
     CFIndex nb_runs = CFArrayGetCount( runs );
     int p = 0;
     for( CFIndex i = 0; i < nb_runs; ++i )
@@ -359,7 +417,7 @@ bool CoreTextLayout::InitGIA() const
                     CGGlyph glyphs[ nb_glyphs ];
                     CTRunGetStringIndices( run, CFRangeMake( 0, 0 ), indices );
                     CTRunGetGlyphs( run, CFRangeMake( 0, 0 ), glyphs );
-                    CTRunGetPositions( run, CFRangeMake( 0, 0 ), &m_glyph_positions[p] );
+                    CTRunGetPositions( run, CFRangeMake( 0, 0 ), &mpGlyphPositions[p] );
                     bool is_vertical_run = false;
                     CFDictionaryRef aDict = CTRunGetAttributes( run );
                     if ( aDict )
@@ -370,19 +428,19 @@ bool CoreTextLayout::InitGIA() const
 
                     for (CFIndex j = 0 ; j < nb_glyphs; ++p, ++j )
                     {
-                        m_glyphs[ p ] = glyphs[ j ];
+                        mpGlyphs[ p ] = glyphs[ j ];
                         SAL_INFO( "vcl.coretext.layout", "m_glyphys[" << p << "]=glyphs[" << j << "] run " << i << " : 0x" << std::hex << glyphs[j] << std::dec );
                         CFIndex k = indices[ j ];
-                        m_glyphs2chars[p] = k;
-                        m_chars2glyphs[k] = p;
+                        mpGlyphs2Chars[p] = k;
+                        mpChars2Glyphs[k] = p;
 
                         if ( j < nb_glyphs - 1 )
                         {
-                            m_char_widths[ k ] += m_glyph_positions[ p + 1 ].x - m_glyph_positions[ p ].x;
+                            mpCharWidths[ k ] += mpGlyphPositions[ p + 1 ].x - mpGlyphPositions[ p ].x;
                         }
                         if( p > 0)
                         {
-                            m_glyph_advances[p - 1] = m_glyph_positions[ p ].x - m_glyph_positions[p - 1].x;
+                            mpGlyphAdvances[p - 1] = mpGlyphPositions[ p ].x - mpGlyphPositions[p - 1].x;
                         }
                     }
                 }
@@ -395,15 +453,15 @@ bool CoreTextLayout::InitGIA() const
 
 bool CoreTextLayout::LayoutText(ImplLayoutArgs& args)
 {
-    SAL_INFO( "vcl.coretext.layout", "m_style=" << m_style << " font=" << m_style->GetFont() << " -->" );
+    SAL_INFO( "vcl.coretext.layout", "mpStyle=" << mpStyle << " font=" << mpStyle->GetFont() << " -->" );
     Clean();
-    m_style->SetColor();
+    mpStyle->SetColor();
     /* retreive MinCharPos EndCharPos Flags and Orientation */
     SalLayout::AdjustLayout(args);
-    m_chars_count = mnEndCharPos - mnMinCharPos;
+    mnCharCount = mnEndCharPos - mnMinCharPos;
 
     /* don't layout emptty (or worse negative size) strings */
-    if(m_chars_count <= 0)
+    if(mnCharCount <= 0)
     {
         return false;
     }
@@ -418,7 +476,7 @@ bool CoreTextLayout::LayoutText(ImplLayoutArgs& args)
     // call below crashes, at least in the iOS simulator. Go figure.
     // (In that case the string consists of *only* such characters,
     // but play it safe.)
-    for (int i = 0; i < m_chars_count; i++)
+    for (int i = 0; i < mnCharCount; i++)
     {
         if (args.mpStr[args.mnMinCharPos+i] == 0xFFFD)
             return false;
@@ -426,7 +484,7 @@ bool CoreTextLayout::LayoutText(ImplLayoutArgs& args)
 #endif
 
     /* c0 and c1 are construction objects */
-    CFStringRef c0 = CFStringCreateWithCharactersNoCopy( NULL, &(args.mpStr[args.mnMinCharPos]), m_chars_count, kCFAllocatorNull );
+    CFStringRef c0 = CFStringCreateWithCharactersNoCopy( NULL, &(args.mpStr[args.mnMinCharPos]), mnCharCount, kCFAllocatorNull );
     if ( !c0 )
     {
         Clean();
@@ -438,7 +496,7 @@ bool CoreTextLayout::LayoutText(ImplLayoutArgs& args)
     int nb_attributes = 0;
 
     keys[nb_attributes]= kCTFontAttributeName;
-    values[nb_attributes] = m_style->GetFont();
+    values[nb_attributes] = mpStyle->GetFont();
     nb_attributes += 1;
 
     CFDictionaryRef attributes = CFDictionaryCreate(kCFAllocatorDefault,
@@ -457,22 +515,22 @@ bool CoreTextLayout::LayoutText(ImplLayoutArgs& args)
         Clean();
         return false;
     }
-    m_typesetter = CTTypesetterCreateWithAttributedString(string);
+    mpTypesetter = CTTypesetterCreateWithAttributedString(string);
     CFRelease(string);
-    if(!m_typesetter)
+    if(!mpTypesetter)
     {
         Clean();
         return false;
     }
-    m_line = CTTypesetterCreateLine(m_typesetter, CFRangeMake(0, 0));
-    if(!m_line)
+    mpLine = CTTypesetterCreateLine(mpTypesetter, CFRangeMake(0, 0));
+    if(!mpLine)
     {
         Clean();
         return false;
     }
-    m_glyphs_count = CTLineGetGlyphCount(m_line);
+    mnGlyphCount = CTLineGetGlyphCount(mpLine);
 
-    SAL_INFO( "vcl.coretext.layout", "glyph_count=" << m_glyphs_count << " <--" );
+    SAL_INFO( "vcl.coretext.layout", "glyph_count=" << mnGlyphCount << " <--" );
     return true;
 }
 
@@ -482,4 +540,12 @@ void CoreTextLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ ) {}
 // not needed. CoreText manage fallback directly
 void CoreTextLayout::Simplify( bool /*bIsBase*/ ) {}
 
+SalLayout* QuartzSalGraphics::GetTextLayout( ImplLayoutArgs&, int /*nFallbackLevel*/ )
+{
+    SAL_INFO( "vcl.coretext.gr", "-->" );
+    CoreTextLayout* layout = new CoreTextLayout( this, m_style );
+    SAL_INFO( "vcl.coretext.gr", "layout:" << layout << " <--" );
+    return layout;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx
index ab86491..64f4b17 100644
--- a/vcl/coretext/salgdi.cxx
+++ b/vcl/coretext/salgdi.cxx
@@ -27,7 +27,6 @@
 
 #include "coretext/salgdi.h"
 #include "coretext/salcoretextstyle.hxx"
-#include "coretext/salcoretextlayout.hxx"
 
 QuartzSalGraphics::QuartzSalGraphics()
     : mpFrame( NULL )
@@ -241,14 +240,6 @@ SystemFontData QuartzSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) con
     return aSysFontData;
 }
 
-SalLayout* QuartzSalGraphics::GetTextLayout( ImplLayoutArgs&, int /*nFallbackLevel*/ )
-{
-    SAL_INFO( "vcl.coretext.gr", "-->" );
-    CoreTextLayout* layout = new CoreTextLayout( this, m_style );
-    SAL_INFO( "vcl.coretext.gr", "layout:" << layout << " <--" );
-    return layout;
-}
-
 sal_uInt16 QuartzSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbackLevel*/ )
 {
     SAL_INFO( "vcl.coretext.gr", "m_style=" << m_style << " -->" );
diff --git a/vcl/inc/coretext/salcoretextlayout.hxx b/vcl/inc/coretext/salcoretextlayout.hxx
deleted file mode 100644
index 1a40095..0000000
--- a/vcl/inc/coretext/salcoretextlayout.hxx
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   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 regarding copyright
- *   ownership. The ASF licenses this file 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 .
- */
-
-#ifndef _VCL_CORETEXT_SALCORETEXTLAYOUT_HXX
-#define _VCL_CORETEXT_SALCORETEXTLAYOUT_HXX
-
-#include <tools/poly.hxx>
-
-#include "sallayout.hxx"
-#include "coretext/salgdi.h"
-#include "coretext/salcoretextstyle.hxx"
-
-class CoreTextLayout : public SalLayout
-{
-public:
-    CoreTextLayout( QuartzSalGraphics* graphics, CoreTextStyleInfo* style);
-    virtual         ~CoreTextLayout();
-
-    virtual void AdjustLayout( ImplLayoutArgs& );
-    virtual void DrawText( SalGraphics& ) const;
-    virtual void DropGlyph( int nStart );
-    virtual long FillDXArray( sal_Int32* pDXArray ) const;
-    virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const;
-    virtual void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const;
-    virtual bool GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const;
-    virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&,
-                               sal_Int32* pGlyphAdvances, int* pCharIndexes ) const;
-    virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const;
-    virtual long GetTextWidth() const;
-    virtual void InitFont() const;
-    virtual bool LayoutText( ImplLayoutArgs& );
-    virtual void MoveGlyph( int nStart, long nNewXPos );
-    virtual void Simplify( bool bIsBase );
-
-private:
-    void Clean();
-    bool InitGIA() const;
-
-    QuartzSalGraphics* m_graphics;
-    CoreTextStyleInfo* m_style;
-    mutable int m_glyphs_count;
-    mutable int m_chars_count;
-    mutable int* m_chars2glyphs;
-    mutable int* m_glyphs2chars;
-    mutable CGGlyph* m_glyphs;
-    mutable int* m_char_widths;
-    mutable int* m_glyph_advances;
-    mutable CGPoint* m_glyph_positions;
-    CTTypesetterRef m_typesetter;
-    CTLineRef m_line;
-    mutable bool m_has_bound_rec;
-    mutable Rectangle m_bound_rect;
-    CGFloat m_base_advance;
-    mutable CGFloat m_cached_width;
-    mutable CFIndex m_current_run_index;
-    mutable CFIndex m_current_glyph_index;
-    mutable CFIndex m_current_glyphrun_index;
-    mutable CFArrayRef m_runs;
-
-};
-
-#endif // _VCL_CORETEXT_SALCORETEXTLAYOUT_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list