Branch libreoffice-5-0-4
[LibreOffice.git] / canvas / source / opengl / ogl_textlayout.cxx
blob88e7ebdf37f4e9089a8d4ba583abbfd1bb08978f
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 "ogl_textlayout.hxx"
12 #include <canvas/debug.hxx>
13 #include <canvas/verbosetrace.hxx>
14 #include <tools/diagnose_ex.h>
16 #include <basegfx/matrix/b2dhommatrix.hxx>
17 #include <basegfx/numeric/ftools.hxx>
20 using namespace ::com::sun::star;
22 namespace oglcanvas
24 TextLayout::TextLayout( const rendering::StringContext& aText,
25 sal_Int8 nDirection,
26 sal_Int64 /*nRandomSeed*/,
27 const CanvasFont::ImplRef& rFont ) :
28 TextLayoutBaseT( m_aMutex ),
29 maText( aText ),
30 maLogicalAdvancements(),
31 mpFont( rFont ),
32 mnTextDirection( nDirection )
36 void SAL_CALL TextLayout::disposing()
38 mpFont.clear();
41 // XTextLayout
42 uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( ) throw (uno::RuntimeException, std::exception)
44 ::osl::MutexGuard aGuard( m_aMutex );
46 // TODO
47 return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
50 uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException, std::exception)
52 ::osl::MutexGuard aGuard( m_aMutex );
54 // TODO
55 return uno::Sequence< geometry::RealRectangle2D >();
58 uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException, std::exception)
60 ::osl::MutexGuard aGuard( m_aMutex );
62 // TODO
63 return uno::Sequence< geometry::RealRectangle2D >();
66 uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( ) throw (uno::RuntimeException, std::exception)
68 ::osl::MutexGuard aGuard( m_aMutex );
70 return maLogicalAdvancements;
73 void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
75 ::osl::MutexGuard aGuard( m_aMutex );
77 if( aAdvancements.getLength() != maText.Length )
79 SAL_INFO("canvas.ogl", "TextLayout::applyLogicalAdvancements(): mismatching number of advancements");
80 throw lang::IllegalArgumentException();
83 maLogicalAdvancements = aAdvancements;
86 geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( ) throw (uno::RuntimeException, std::exception)
88 ::osl::MutexGuard aGuard( m_aMutex );
90 ENSURE_OR_THROW( mpFont.get(),
91 "TextLayout::queryTextBounds(): invalid font" );
93 // fake text bounds by either taking the advancement values,
94 // or assuming square glyph boxes (width similar to height)
95 const rendering::FontRequest& rFontRequest( mpFont->getFontRequest() );
96 const double nFontSize( ::std::max( rFontRequest.CellSize,
97 rFontRequest.ReferenceAdvancement ) );
98 if( maLogicalAdvancements.getLength() )
100 return geometry::RealRectangle2D( 0, -nFontSize/2,
101 maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
102 nFontSize/2 );
104 else
106 return geometry::RealRectangle2D( 0, -nFontSize/2,
107 nFontSize * maText.Length,
108 nFontSize/2 );
112 double SAL_CALL TextLayout::justify( double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
114 ::osl::MutexGuard aGuard( m_aMutex );
116 // TODO
117 return 0.0;
120 double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/,
121 double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
123 ::osl::MutexGuard aGuard( m_aMutex );
125 // TODO
126 return 0.0;
129 rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ ) throw (uno::RuntimeException, std::exception)
131 ::osl::MutexGuard aGuard( m_aMutex );
133 // TODO
134 return rendering::TextHit();
137 rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/,
138 sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
140 ::osl::MutexGuard aGuard( m_aMutex );
142 // TODO
143 return rendering::Caret();
146 sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/,
147 sal_Int32 /*nCaretAdvancement*/,
148 sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
150 ::osl::MutexGuard aGuard( m_aMutex );
152 // TODO
153 return 0;
156 uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/,
157 sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
159 ::osl::MutexGuard aGuard( m_aMutex );
161 // TODO
162 return uno::Reference< rendering::XPolyPolygon2D >();
165 uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/,
166 sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
168 ::osl::MutexGuard aGuard( m_aMutex );
170 // TODO
171 return uno::Reference< rendering::XPolyPolygon2D >();
174 double SAL_CALL TextLayout::getBaselineOffset( ) throw (uno::RuntimeException, std::exception)
176 ::osl::MutexGuard aGuard( m_aMutex );
178 // TODO
179 return 0.0;
182 sal_Int8 SAL_CALL TextLayout::getMainTextDirection( ) throw (uno::RuntimeException, std::exception)
184 ::osl::MutexGuard aGuard( m_aMutex );
186 return mnTextDirection;
189 uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( ) throw (uno::RuntimeException, std::exception)
191 ::osl::MutexGuard aGuard( m_aMutex );
193 return mpFont.get();
196 rendering::StringContext SAL_CALL TextLayout::getText( ) throw (uno::RuntimeException, std::exception)
198 ::osl::MutexGuard aGuard( m_aMutex );
200 return maText;
203 bool TextLayout::draw( const rendering::ViewState& /*rViewState*/,
204 const rendering::RenderState& /*rRenderState*/,
205 const uno::Reference< rendering::XGraphicDevice >& /*xGraphicDevice*/ ) const
207 ::osl::MutexGuard aGuard( m_aMutex );
209 // TODO
211 return true;
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */