Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #include "ogl_textlayout.hxx"
11 :
12 : #include <canvas/debug.hxx>
13 : #include <canvas/verbosetrace.hxx>
14 : #include <tools/diagnose_ex.h>
15 :
16 : #include <basegfx/matrix/b2dhommatrix.hxx>
17 : #include <basegfx/numeric/ftools.hxx>
18 :
19 :
20 : using namespace ::com::sun::star;
21 :
22 : namespace oglcanvas
23 : {
24 0 : 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 0 : mnTextDirection( nDirection )
33 : {
34 0 : }
35 :
36 0 : void SAL_CALL TextLayout::disposing()
37 : {
38 0 : mpFont.clear();
39 0 : }
40 :
41 : // XTextLayout
42 0 : uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( ) throw (uno::RuntimeException, std::exception)
43 : {
44 0 : ::osl::MutexGuard aGuard( m_aMutex );
45 :
46 : // TODO
47 0 : return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
48 : }
49 :
50 0 : uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException, std::exception)
51 : {
52 0 : ::osl::MutexGuard aGuard( m_aMutex );
53 :
54 : // TODO
55 0 : return uno::Sequence< geometry::RealRectangle2D >();
56 : }
57 :
58 0 : uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException, std::exception)
59 : {
60 0 : ::osl::MutexGuard aGuard( m_aMutex );
61 :
62 : // TODO
63 0 : return uno::Sequence< geometry::RealRectangle2D >();
64 : }
65 :
66 0 : uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( ) throw (uno::RuntimeException, std::exception)
67 : {
68 0 : ::osl::MutexGuard aGuard( m_aMutex );
69 :
70 0 : return maLogicalAdvancements;
71 : }
72 :
73 0 : void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
74 : {
75 0 : ::osl::MutexGuard aGuard( m_aMutex );
76 :
77 0 : if( aAdvancements.getLength() != maText.Length )
78 : {
79 : SAL_INFO("canvas.ogl", "TextLayout::applyLogicalAdvancements(): mismatching number of advancements");
80 0 : throw lang::IllegalArgumentException();
81 : }
82 :
83 0 : maLogicalAdvancements = aAdvancements;
84 0 : }
85 :
86 0 : geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( ) throw (uno::RuntimeException, std::exception)
87 : {
88 0 : ::osl::MutexGuard aGuard( m_aMutex );
89 :
90 0 : ENSURE_OR_THROW( mpFont.get(),
91 : "TextLayout::queryTextBounds(): invalid font" );
92 :
93 : // fake text bounds by either taking the advancement values,
94 : // or assuming square glyph boxes (width similar to height)
95 0 : const rendering::FontRequest& rFontRequest( mpFont->getFontRequest() );
96 : const double nFontSize( ::std::max( rFontRequest.CellSize,
97 0 : rFontRequest.ReferenceAdvancement ) );
98 0 : if( maLogicalAdvancements.getLength() )
99 : {
100 0 : return geometry::RealRectangle2D( 0, -nFontSize/2,
101 0 : maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
102 0 : nFontSize/2 );
103 : }
104 : else
105 : {
106 0 : return geometry::RealRectangle2D( 0, -nFontSize/2,
107 0 : nFontSize * maText.Length,
108 0 : nFontSize/2 );
109 0 : }
110 : }
111 :
112 0 : double SAL_CALL TextLayout::justify( double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
113 : {
114 0 : ::osl::MutexGuard aGuard( m_aMutex );
115 :
116 : // TODO
117 0 : return 0.0;
118 : }
119 :
120 0 : double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/,
121 : double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
122 : {
123 0 : ::osl::MutexGuard aGuard( m_aMutex );
124 :
125 : // TODO
126 0 : return 0.0;
127 : }
128 :
129 0 : rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ ) throw (uno::RuntimeException, std::exception)
130 : {
131 0 : ::osl::MutexGuard aGuard( m_aMutex );
132 :
133 : // TODO
134 0 : return rendering::TextHit();
135 : }
136 :
137 0 : rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/,
138 : sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
139 : {
140 0 : ::osl::MutexGuard aGuard( m_aMutex );
141 :
142 : // TODO
143 0 : return rendering::Caret();
144 : }
145 :
146 0 : sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/,
147 : sal_Int32 /*nCaretAdvancement*/,
148 : sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
149 : {
150 0 : ::osl::MutexGuard aGuard( m_aMutex );
151 :
152 : // TODO
153 0 : return 0;
154 : }
155 :
156 0 : uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/,
157 : sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
158 : {
159 0 : ::osl::MutexGuard aGuard( m_aMutex );
160 :
161 : // TODO
162 0 : return uno::Reference< rendering::XPolyPolygon2D >();
163 : }
164 :
165 0 : uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/,
166 : sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
167 : {
168 0 : ::osl::MutexGuard aGuard( m_aMutex );
169 :
170 : // TODO
171 0 : return uno::Reference< rendering::XPolyPolygon2D >();
172 : }
173 :
174 0 : double SAL_CALL TextLayout::getBaselineOffset( ) throw (uno::RuntimeException, std::exception)
175 : {
176 0 : ::osl::MutexGuard aGuard( m_aMutex );
177 :
178 : // TODO
179 0 : return 0.0;
180 : }
181 :
182 0 : sal_Int8 SAL_CALL TextLayout::getMainTextDirection( ) throw (uno::RuntimeException, std::exception)
183 : {
184 0 : ::osl::MutexGuard aGuard( m_aMutex );
185 :
186 0 : return mnTextDirection;
187 : }
188 :
189 0 : uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( ) throw (uno::RuntimeException, std::exception)
190 : {
191 0 : ::osl::MutexGuard aGuard( m_aMutex );
192 :
193 0 : return mpFont.get();
194 : }
195 :
196 0 : rendering::StringContext SAL_CALL TextLayout::getText( ) throw (uno::RuntimeException, std::exception)
197 : {
198 0 : ::osl::MutexGuard aGuard( m_aMutex );
199 :
200 0 : return maText;
201 : }
202 :
203 0 : bool TextLayout::draw( const rendering::ViewState& /*rViewState*/,
204 : const rendering::RenderState& /*rRenderState*/,
205 : const uno::Reference< rendering::XGraphicDevice >& /*xGraphicDevice*/ ) const
206 : {
207 0 : ::osl::MutexGuard aGuard( m_aMutex );
208 :
209 : // TODO
210 :
211 0 : return true;
212 : }
213 : }
214 :
215 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|