1*25ea7f45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*25ea7f45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*25ea7f45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*25ea7f45SAndrew Rist  * distributed with this work for additional information
6*25ea7f45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*25ea7f45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*25ea7f45SAndrew Rist  * "License"); you may not use this file except in compliance
9*25ea7f45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*25ea7f45SAndrew Rist  *
11*25ea7f45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*25ea7f45SAndrew Rist  *
13*25ea7f45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*25ea7f45SAndrew Rist  * software distributed under the License is distributed on an
15*25ea7f45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*25ea7f45SAndrew Rist  * KIND, either express or implied.  See the License for the
17*25ea7f45SAndrew Rist  * specific language governing permissions and limitations
18*25ea7f45SAndrew Rist  * under the License.
19*25ea7f45SAndrew Rist  *
20*25ea7f45SAndrew Rist  *************************************************************/
21*25ea7f45SAndrew Rist 
22*25ea7f45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_canvas.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <canvas/debug.hxx>
28cdf0e10cSrcweir #include <tools/diagnose_ex.h>
29cdf0e10cSrcweir #include <canvas/verbosetrace.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
32cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "null_textlayout.hxx"
35cdf0e10cSrcweir #include "null_spritecanvas.hxx"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using namespace ::com::sun::star;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace nullcanvas
41cdf0e10cSrcweir {
TextLayout(const rendering::StringContext & aText,sal_Int8 nDirection,sal_Int64,const CanvasFont::ImplRef & rFont)42cdf0e10cSrcweir     TextLayout::TextLayout( const rendering::StringContext& 	aText,
43cdf0e10cSrcweir                             sal_Int8                        	nDirection,
44cdf0e10cSrcweir                             sal_Int64                       	/*nRandomSeed*/,
45cdf0e10cSrcweir                             const CanvasFont::ImplRef&      	rFont ) :
46cdf0e10cSrcweir         TextLayout_Base( m_aMutex ),
47cdf0e10cSrcweir         maText( aText ),
48cdf0e10cSrcweir         maLogicalAdvancements(),
49cdf0e10cSrcweir         mpFont( rFont ),
50cdf0e10cSrcweir         mnTextDirection( nDirection )
51cdf0e10cSrcweir     {
52cdf0e10cSrcweir     }
53cdf0e10cSrcweir 
~TextLayout()54cdf0e10cSrcweir     TextLayout::~TextLayout()
55cdf0e10cSrcweir     {
56cdf0e10cSrcweir     }
57cdf0e10cSrcweir 
disposing()58cdf0e10cSrcweir     void SAL_CALL TextLayout::disposing()
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir         mpFont.reset();
61cdf0e10cSrcweir     }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     // XTextLayout
queryTextShapes()64cdf0e10cSrcweir     uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > > SAL_CALL TextLayout::queryTextShapes(  ) throw (uno::RuntimeException)
65cdf0e10cSrcweir     {
66cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         // TODO
69cdf0e10cSrcweir         return uno::Sequence< uno::Reference< rendering::XPolyPolygon2D > >();
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir 
queryInkMeasures()72cdf0e10cSrcweir     uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryInkMeasures(  ) throw (uno::RuntimeException)
73cdf0e10cSrcweir     {
74cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         // TODO
77cdf0e10cSrcweir         return uno::Sequence< geometry::RealRectangle2D >();
78cdf0e10cSrcweir     }
79cdf0e10cSrcweir 
queryMeasures()80cdf0e10cSrcweir     uno::Sequence< geometry::RealRectangle2D > SAL_CALL TextLayout::queryMeasures(  ) throw (uno::RuntimeException)
81cdf0e10cSrcweir     {
82cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         // TODO
85cdf0e10cSrcweir         return uno::Sequence< geometry::RealRectangle2D >();
86cdf0e10cSrcweir     }
87cdf0e10cSrcweir 
queryLogicalAdvancements()88cdf0e10cSrcweir     uno::Sequence< double > SAL_CALL TextLayout::queryLogicalAdvancements(  ) throw (uno::RuntimeException)
89cdf0e10cSrcweir     {
90cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir         return maLogicalAdvancements;
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir 
applyLogicalAdvancements(const uno::Sequence<double> & aAdvancements)95cdf0e10cSrcweir     void SAL_CALL TextLayout::applyLogicalAdvancements( const uno::Sequence< double >& aAdvancements ) throw (lang::IllegalArgumentException, uno::RuntimeException)
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
98cdf0e10cSrcweir 
99cdf0e10cSrcweir         if( aAdvancements.getLength() != maText.Length )
100cdf0e10cSrcweir         {
101cdf0e10cSrcweir             OSL_TRACE( "TextLayout::applyLogicalAdvancements(): mismatching number of advancements" );
102cdf0e10cSrcweir             throw lang::IllegalArgumentException();
103cdf0e10cSrcweir         }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir         maLogicalAdvancements = aAdvancements;
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir 
queryTextBounds()108cdf0e10cSrcweir     geometry::RealRectangle2D SAL_CALL TextLayout::queryTextBounds(  ) throw (uno::RuntimeException)
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir         ENSURE_OR_THROW( mpFont.get(),
113cdf0e10cSrcweir                           "TextLayout::queryTextBounds(): invalid font" );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         // fake text bounds by either taking the advancement values,
116cdf0e10cSrcweir         // or assuming square glyph boxes (width similar to height)
117cdf0e10cSrcweir         const rendering::FontRequest& rFontRequest( mpFont->getFontRequest() );
118cdf0e10cSrcweir         const double nFontSize( ::std::max( rFontRequest.CellSize,
119cdf0e10cSrcweir                                             rFontRequest.ReferenceAdvancement ) );
120cdf0e10cSrcweir         if( maLogicalAdvancements.getLength() )
121cdf0e10cSrcweir         {
122cdf0e10cSrcweir             return geometry::RealRectangle2D( 0, -nFontSize/2,
123cdf0e10cSrcweir                                               maLogicalAdvancements[ maLogicalAdvancements.getLength()-1 ],
124cdf0e10cSrcweir                                               nFontSize/2 );
125cdf0e10cSrcweir         }
126cdf0e10cSrcweir         else
127cdf0e10cSrcweir         {
128cdf0e10cSrcweir             return geometry::RealRectangle2D( 0, -nFontSize/2,
129cdf0e10cSrcweir                                               nFontSize * maText.Length,
130cdf0e10cSrcweir                                               nFontSize/2 );
131cdf0e10cSrcweir         }
132cdf0e10cSrcweir     }
133cdf0e10cSrcweir 
justify(double)134cdf0e10cSrcweir     double SAL_CALL TextLayout::justify( double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException)
135cdf0e10cSrcweir     {
136cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         // TODO
139cdf0e10cSrcweir         return 0.0;
140cdf0e10cSrcweir     }
141cdf0e10cSrcweir 
combinedJustify(const uno::Sequence<uno::Reference<rendering::XTextLayout>> &,double)142cdf0e10cSrcweir     double SAL_CALL TextLayout::combinedJustify( const uno::Sequence< uno::Reference< rendering::XTextLayout > >& /*aNextLayouts*/,
143cdf0e10cSrcweir                                                  double /*nSize*/ ) throw (lang::IllegalArgumentException, uno::RuntimeException)
144cdf0e10cSrcweir     {
145cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         // TODO
148cdf0e10cSrcweir         return 0.0;
149cdf0e10cSrcweir     }
150cdf0e10cSrcweir 
getTextHit(const geometry::RealPoint2D &)151cdf0e10cSrcweir     rendering::TextHit SAL_CALL TextLayout::getTextHit( const geometry::RealPoint2D& /*aHitPoint*/ ) throw (uno::RuntimeException)
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir         // TODO
156cdf0e10cSrcweir         return rendering::TextHit();
157cdf0e10cSrcweir     }
158cdf0e10cSrcweir 
getCaret(sal_Int32,sal_Bool)159cdf0e10cSrcweir     rendering::Caret SAL_CALL TextLayout::getCaret( sal_Int32 /*nInsertionIndex*/,
160cdf0e10cSrcweir                                                     sal_Bool  /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
161cdf0e10cSrcweir     {
162cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         // TODO
165cdf0e10cSrcweir         return rendering::Caret();
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir 
getNextInsertionIndex(sal_Int32,sal_Int32,sal_Bool)168cdf0e10cSrcweir     sal_Int32 SAL_CALL TextLayout::getNextInsertionIndex( sal_Int32 /*nStartIndex*/,
169cdf0e10cSrcweir                                                           sal_Int32 /*nCaretAdvancement*/,
170cdf0e10cSrcweir                                                           sal_Bool  /*bExcludeLigatures*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
171cdf0e10cSrcweir     {
172cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         // TODO
175cdf0e10cSrcweir         return 0;
176cdf0e10cSrcweir     }
177cdf0e10cSrcweir 
queryVisualHighlighting(sal_Int32,sal_Int32)178cdf0e10cSrcweir     uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryVisualHighlighting( sal_Int32 /*nStartIndex*/,
179cdf0e10cSrcweir                                                                                               sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
180cdf0e10cSrcweir     {
181cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir         // TODO
184cdf0e10cSrcweir         return uno::Reference< rendering::XPolyPolygon2D >();
185cdf0e10cSrcweir     }
186cdf0e10cSrcweir 
queryLogicalHighlighting(sal_Int32,sal_Int32)187cdf0e10cSrcweir     uno::Reference< rendering::XPolyPolygon2D > SAL_CALL TextLayout::queryLogicalHighlighting( sal_Int32 /*nStartIndex*/,
188cdf0e10cSrcweir                                                                                                sal_Int32 /*nEndIndex*/ ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir         // TODO
193cdf0e10cSrcweir         return uno::Reference< rendering::XPolyPolygon2D >();
194cdf0e10cSrcweir     }
195cdf0e10cSrcweir 
getBaselineOffset()196cdf0e10cSrcweir     double SAL_CALL TextLayout::getBaselineOffset(  ) throw (uno::RuntimeException)
197cdf0e10cSrcweir     {
198cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir         // TODO
201cdf0e10cSrcweir         return 0.0;
202cdf0e10cSrcweir     }
203cdf0e10cSrcweir 
getMainTextDirection()204cdf0e10cSrcweir     sal_Int8 SAL_CALL TextLayout::getMainTextDirection(  ) throw (uno::RuntimeException)
205cdf0e10cSrcweir     {
206cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
207cdf0e10cSrcweir 
208cdf0e10cSrcweir         return mnTextDirection;
209cdf0e10cSrcweir     }
210cdf0e10cSrcweir 
getFont()211cdf0e10cSrcweir     uno::Reference< rendering::XCanvasFont > SAL_CALL TextLayout::getFont(  ) throw (uno::RuntimeException)
212cdf0e10cSrcweir     {
213cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir         return mpFont.getRef();
216cdf0e10cSrcweir     }
217cdf0e10cSrcweir 
getText()218cdf0e10cSrcweir     rendering::StringContext SAL_CALL TextLayout::getText(  ) throw (uno::RuntimeException)
219cdf0e10cSrcweir     {
220cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
221cdf0e10cSrcweir 
222cdf0e10cSrcweir         return maText;
223cdf0e10cSrcweir     }
224cdf0e10cSrcweir 
draw(const rendering::ViewState &,const rendering::RenderState &,const uno::Reference<rendering::XGraphicDevice> &) const225cdf0e10cSrcweir     bool TextLayout::draw( const rendering::ViewState& 							/*rViewState*/,
226cdf0e10cSrcweir 						   const rendering::RenderState& 						/*rRenderState*/,
227cdf0e10cSrcweir 						   const uno::Reference< rendering::XGraphicDevice >&	/*xGraphicDevice*/ ) const
228cdf0e10cSrcweir     {
229cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
230cdf0e10cSrcweir 
231cdf0e10cSrcweir         // TODO
232cdf0e10cSrcweir 
233cdf0e10cSrcweir         return true;
234cdf0e10cSrcweir     }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 
237cdf0e10cSrcweir #define SERVICE_NAME "com.sun.star.rendering.TextLayout"
238cdf0e10cSrcweir #define IMPLEMENTATION_NAME "NullCanvas::TextLayout"
239cdf0e10cSrcweir 
getImplementationName()240cdf0e10cSrcweir     ::rtl::OUString SAL_CALL TextLayout::getImplementationName() throw( uno::RuntimeException )
241cdf0e10cSrcweir     {
242cdf0e10cSrcweir         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
243cdf0e10cSrcweir     }
244cdf0e10cSrcweir 
supportsService(const::rtl::OUString & ServiceName)245cdf0e10cSrcweir     sal_Bool SAL_CALL TextLayout::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
246cdf0e10cSrcweir     {
247cdf0e10cSrcweir         return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
248cdf0e10cSrcweir     }
249cdf0e10cSrcweir 
getSupportedServiceNames()250cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString > SAL_CALL TextLayout::getSupportedServiceNames()  throw( uno::RuntimeException )
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         uno::Sequence< ::rtl::OUString > aRet(1);
253cdf0e10cSrcweir         aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
254cdf0e10cSrcweir 
255cdf0e10cSrcweir         return aRet;
256cdf0e10cSrcweir     }
257cdf0e10cSrcweir }
258