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>
12 #include "quartz/utils.h"
14 #include "CTRunData.hxx"
16 CTRunData::CTRunData( CTRunRef pRun
, int start
)
23 CFDictionaryRef pRunAttributes
= CTRunGetAttributes( m_pRun
);
24 m_pFont
= static_cast<CTFontRef
>(CFDictionaryGetValue( pRunAttributes
, kCTFontAttributeName
));
26 m_nGlyphs
= CTRunGetGlyphCount(m_pRun
);
27 m_EndPos
= m_StartPos
+ m_nGlyphs
;
28 const CFRange aAll
= CFRangeMake( 0, m_nGlyphs
);
30 m_pAdvances
= CTRunGetAdvancesPtr( pRun
);
33 m_pAdvances
= new CGSize
[m_nGlyphs
];
34 ownership_flags
|= CTRUNDATA_F_OWN_ADVANCES
;
35 CTRunGetAdvances( pRun
, aAll
, const_cast<CGSize
*>(m_pAdvances
) );
38 m_pGlyphs
= CTRunGetGlyphsPtr( m_pRun
);
41 m_pGlyphs
= new CGGlyph
[m_nGlyphs
];
42 ownership_flags
|= CTRUNDATA_F_OWN_GLYPHS
;
43 CTRunGetGlyphs( pRun
, aAll
, const_cast<CGGlyph
*>(m_pGlyphs
));
46 m_pStringIndices
= CTRunGetStringIndicesPtr( pRun
);
47 if( !m_pStringIndices
)
49 m_pStringIndices
= new CFIndex
[m_nGlyphs
];
50 ownership_flags
|= CTRUNDATA_F_OWN_INDICES
;
51 CTRunGetStringIndices( pRun
, aAll
, const_cast<CFIndex
*>(m_pStringIndices
) );
54 m_pPositions
= CTRunGetPositionsPtr( pRun
);
57 m_pPositions
= new CGPoint
[m_nGlyphs
];
58 ownership_flags
|= CTRUNDATA_F_OWN_POSITIONS
;
59 CTRunGetPositions( pRun
, aAll
, const_cast<CGPoint
*>(m_pPositions
) );
61 for(int i
= 0; i
< m_nGlyphs
; i
++)
63 SAL_INFO( "vcl.ct", "CTRunData Adv:" << (double)m_pAdvances
[i
].width
<< " s-idx:" << m_pStringIndices
[i
] << " pos:(" <<
64 m_pPositions
[i
].x
<< ":" << m_pPositions
[i
].y
<< ")");
68 CTRunData::~CTRunData()
70 if(ownership_flags
& CTRUNDATA_F_OWN_ADVANCES
)
72 delete [] m_pAdvances
;
75 if(ownership_flags
& CTRUNDATA_F_OWN_GLYPHS
)
80 if(ownership_flags
& CTRUNDATA_F_OWN_INDICES
)
82 delete [] m_pStringIndices
;
85 if(ownership_flags
& CTRUNDATA_F_OWN_POSITIONS
)
87 delete [] m_pPositions
;
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */