1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <sal/types.h>
13 #include "CTRunData.hxx"
15 CTRunData::CTRunData( CTRunRef pRun
, int start
)
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
);
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
);
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
);
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
)
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: */