Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <canvas/debug.hxx>
31 : : #include <tools/diagnose_ex.h>
32 : : #include <canvas/verbosetrace.hxx>
33 : :
34 : : #include <basegfx/matrix/b2dhommatrix.hxx>
35 : : #include <basegfx/numeric/ftools.hxx>
36 : :
37 : : #include "null_textlayout.hxx"
38 : : #include "null_spritecanvas.hxx"
39 : :
40 : :
41 : : using namespace ::com::sun::star;
42 : :
43 : : namespace nullcanvas
44 : : {
45 : 0 : TextLayout::TextLayout( const rendering::StringContext& aText,
46 : : sal_Int8 nDirection,
47 : : sal_Int64 /*nRandomSeed*/,
48 : : const CanvasFont::ImplRef& rFont ) :
49 : : TextLayout_Base( m_aMutex ),
50 : : maText( aText ),
51 : : maLogicalAdvancements(),
52 : : mpFont( rFont ),
53 : 0 : mnTextDirection( nDirection )
54 : : {
55 : 0 : }
56 : :
57 : 0 : TextLayout::~TextLayout()
58 : : {
59 : 0 : }
60 : :
61 : 0 : void SAL_CALL TextLayout::disposing()
62 : : {
63 : 0 : mpFont.reset();
64 : 0 : }
65 : :
66 : : // XTextLayout
67 : 0 : uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes( ) throw (uno::RuntimeException)
68 : : {
69 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
70 : :
71 : : // TODO
72 : 0 : return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
73 : : }
74 : :
75 : 0 : uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures( ) throw (uno::RuntimeException)
76 : : {
77 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
78 : :
79 : : // TODO
80 : 0 : return uno::Sequence< geometry::RealRectangle2D >();
81 : : }
82 : :
83 : 0 : uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures( ) throw (uno::RuntimeException)
84 : : {
85 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
86 : :
87 : : // TODO
88 : 0 : return uno::Sequence< geometry::RealRectangle2D >();
89 : : }
90 : :
91 : 0 : uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements( ) throw (uno::RuntimeException)
92 : : {
93 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
94 : :
95 : 0 : return maLogicalAdvancements;
96 : : }
97 : :
98 : 0 : void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException)
99 : : {
100 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
101 : :
102 : 0 : if( aAdvancements.getLength() != maText.Length )
103 : : {
104 : : OSL_TRACE( "TextLayout::applyLogicalAdvancements(): mismatching number of advancements" );
105 : 0 : throw lang::IllegalArgumentException();
106 : : }
107 : :
108 : 0 : maLogicalAdvancements = aAdvancements;
109 : 0 : }
110 : :
111 : 0 : geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds( ) throw (uno::RuntimeException)
112 : : {
113 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
114 : :
115 : 0 : ENSURE_OR_THROW( mpFont.get(),
116 : : "TextLayout::queryTextBounds(): invalid font" );
117 : :
118 : : // fake text bounds by either taking the advancement values,
119 : : // or assuming square glyph boxes (width similar to height)
120 : 0 : const rendering::FontRequest& rFontRequest( mpFont->getFontRequest() );
121 : : const double nFontSize( ::std::max( rFontRequest.CellSize,
122 : 0 : rFontRequest.ReferenceAdvancement ) );
123 : 0 : if( maLogicalAdvancements.getLength() )
124 : : {
125 : : return geometry::RealRectangle2D( 0, -nFontSize/2,
126 : 0 : maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
127 : 0 : nFontSize/2 );
128 : : }
129 : : else
130 : : {
131 : : return geometry::RealRectangle2D( 0, -nFontSize/2,
132 : : nFontSize * maText.Length,
133 : 0 : nFontSize/2 );
134 : 0 : }
135 : : }
136 : :
137 : 0 : double SAL_CALL TextLayout::justify( double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException)
138 : : {
139 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
140 : :
141 : : // TODO
142 : 0 : return 0.0;
143 : : }
144 : :
145 : 0 : double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/,
146 : : double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException)
147 : : {
148 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
149 : :
150 : : // TODO
151 : 0 : return 0.0;
152 : : }
153 : :
154 : 0 : rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ ) throw (uno::RuntimeException)
155 : : {
156 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
157 : :
158 : : // TODO
159 : 0 : return rendering::TextHit();
160 : : }
161 : :
162 : 0 : rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/,
163 : : sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
164 : : {
165 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
166 : :
167 : : // TODO
168 : 0 : return rendering::Caret();
169 : : }
170 : :
171 : 0 : sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/,
172 : : sal_Int32 /*nCaretAdvancement*/,
173 : : sal_Bool /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
174 : : {
175 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
176 : :
177 : : // TODO
178 : 0 : return 0;
179 : : }
180 : :
181 : 0 : uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/,
182 : : sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
183 : : {
184 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
185 : :
186 : : // TODO
187 : 0 : return uno::Reference< rendering::XPolyPolygon2D >();
188 : : }
189 : :
190 : 0 : uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/,
191 : : sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
192 : : {
193 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
194 : :
195 : : // TODO
196 : 0 : return uno::Reference< rendering::XPolyPolygon2D >();
197 : : }
198 : :
199 : 0 : double SAL_CALL TextLayout::getBaselineOffset( ) throw (uno::RuntimeException)
200 : : {
201 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
202 : :
203 : : // TODO
204 : 0 : return 0.0;
205 : : }
206 : :
207 : 0 : sal_Int8 SAL_CALL TextLayout::getMainTextDirection( ) throw (uno::RuntimeException)
208 : : {
209 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
210 : :
211 : 0 : return mnTextDirection;
212 : : }
213 : :
214 : 0 : uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont( ) throw (uno::RuntimeException)
215 : : {
216 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
217 : :
218 : 0 : return mpFont.getRef();
219 : : }
220 : :
221 : 0 : rendering::StringContext SAL_CALL TextLayout::getText( ) throw (uno::RuntimeException)
222 : : {
223 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
224 : :
225 : 0 : return maText;
226 : : }
227 : :
228 : 0 : bool TextLayout::draw( const rendering::ViewState& /*rViewState*/,
229 : : const rendering::RenderState& /*rRenderState*/,
230 : : const uno::Reference< rendering::XGraphicDevice >& /*xGraphicDevice*/ ) const
231 : : {
232 : 0 : ::osl::MutexGuard aGuard( m_aMutex );
233 : :
234 : : // TODO
235 : :
236 : 0 : return true;
237 : : }
238 : :
239 : :
240 : : #define SERVICE_NAME "com.sun.star.rendering.TextLayout"
241 : : #define IMPLEMENTATION_NAME "NullCanvas::TextLayout"
242 : :
243 : 0 : ::rtl::OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException )
244 : : {
245 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
246 : : }
247 : :
248 : 0 : sal_Bool SAL_CALL TextLayout::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
249 : : {
250 : 0 : return ServiceName == SERVICE_NAME;
251 : : }
252 : :
253 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL TextLayout::getSupportedServiceNames() throw( uno::RuntimeException )
254 : : {
255 : 0 : uno::Sequence< ::rtl::OUString > aRet(1);
256 : 0 : aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
257 : :
258 : 0 : return aRet;
259 : : }
260 : 0 : }
261 : :
262 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|