Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / vcl / quartz / CTRunData.cxx
blob377615d4f2f28c1f097fb0726d36f0c0ea962c15
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/types.h>
11 #include <cassert>
13 #include "CTRunData.hxx"
15 CTRunData::CTRunData( CTRunRef pRun, int start)
16 : ownership_flags(0)
17 , m_StartPos(start)
18 , m_pRun(pRun)
20 assert(pRun);
22 CFDictionaryRef pRunAttributes = CTRunGetAttributes( m_pRun );
23 m_pFont = (CTFontRef)CFDictionaryGetValue( pRunAttributes, kCTFontAttributeName );
25 m_nGlyphs = CTRunGetGlyphCount(m_pRun);
26 m_EndPos = m_StartPos + m_nGlyphs;
27 const CFRange aAll = CFRangeMake( 0, m_nGlyphs );
29 m_pAdvances = CTRunGetAdvancesPtr( pRun );
30 if( !m_pAdvances )
32 m_pAdvances = new CGSize[m_nGlyphs];
33 ownership_flags |= CTRUNDATA_F_OWN_ADVANCES;
34 CTRunGetAdvances( pRun, aAll, (CGSize*)m_pAdvances );
37 m_pGlyphs = CTRunGetGlyphsPtr( m_pRun );
38 if( !m_pGlyphs )
40 m_pGlyphs = new CGGlyph[m_nGlyphs];
41 ownership_flags |= CTRUNDATA_F_OWN_GLYPHS;
42 CTRunGetGlyphs( pRun, aAll, (CGGlyph*)m_pGlyphs);
45 m_pStringIndices = CTRunGetStringIndicesPtr( pRun );
46 if( !m_pStringIndices )
48 m_pStringIndices = new CFIndex[m_nGlyphs];
49 ownership_flags |= CTRUNDATA_F_OWN_INDICES;
50 CTRunGetStringIndices( pRun, aAll, (CFIndex*)m_pStringIndices );
53 m_pPositions = CTRunGetPositionsPtr( pRun );
54 if( !m_pPositions )
56 m_pPositions = new CGPoint[m_nGlyphs];
57 ownership_flags |= CTRUNDATA_F_OWN_POSITIONS;
58 CTRunGetPositions( pRun, aAll, (CGPoint*)m_pPositions );
62 CTRunData::~CTRunData()
64 if(ownership_flags & CTRUNDATA_F_OWN_ADVANCES)
66 delete [] m_pAdvances;
69 if(ownership_flags & CTRUNDATA_F_OWN_GLYPHS)
71 delete [] m_pGlyphs;
74 if(ownership_flags & CTRUNDATA_F_OWN_INDICES)
76 delete [] m_pStringIndices;
79 if(ownership_flags & CTRUNDATA_F_OWN_POSITIONS)
81 delete [] m_pPositions;
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */