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 : : #include <com/sun/star/uno/XInterface.hpp>
30 : : #include <vcl/svapp.hxx>
31 : :
32 : : #include <svx/unoshtxt.hxx>
33 : : #include <editeng/unoedhlp.hxx>
34 : : #include <svl/lstner.hxx>
35 : : #include <rtl/ref.hxx>
36 : : #include <osl/mutex.hxx>
37 : : #include <svl/hint.hxx>
38 : : #include <svl/style.hxx>
39 : : #include <svx/svdmodel.hxx>
40 : : #include <svx/svdoutl.hxx>
41 : : #include <svx/svdobj.hxx>
42 : : #include <svx/svdview.hxx>
43 : : #include <svx/svdetc.hxx>
44 : : #include <editeng/outliner.hxx>
45 : : #include <editeng/unoforou.hxx>
46 : : #include <editeng/unoviwou.hxx>
47 : : #include <editeng/outlobj.hxx>
48 : : #include <svx/svdotext.hxx>
49 : : #include <svx/svdpage.hxx>
50 : : #include <editeng/editeng.hxx>
51 : : #include <editeng/editobj.hxx>
52 : :
53 : : #include <editeng/unotext.hxx>
54 : : #include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
55 : : #include <comphelper/processfactory.hxx>
56 : : #include <svx/sdrpaintwindow.hxx>
57 : :
58 : : using namespace ::osl;
59 : : using namespace ::rtl;
60 : :
61 : : using ::com::sun::star::uno::XInterface;
62 : :
63 : : namespace css = ::com::sun::star;
64 : :
65 : :
66 : : //------------------------------------------------------------------------
67 : : // SvxTextEditSourceImpl
68 : : //------------------------------------------------------------------------
69 : :
70 : : /** @descr
71 : : <p>This class essentially provides the text and view forwarders. If
72 : : no SdrView is given, this class handles the UNO objects, which are
73 : : currently not concerned with view issues. In this case,
74 : : GetViewForwarder() always returns NULL and the underlying
75 : : EditEngine of the SvxTextForwarder is a background one (i.e. not
76 : : the official DrawOutliner, but one created exclusively for this
77 : : object, with no relation to a view).
78 : : </p>
79 : :
80 : : <p>If a SdrView is given at construction time, the caller is
81 : : responsible for destroying this object when the view becomes
82 : : invalid (the views cannot notify). If GetViewForwarder(sal_True)
83 : : is called, the underlying shape is put into edit mode, the view
84 : : forwarder returned encapsulates the OutlinerView and the next call
85 : : to GetTextForwarder() yields a forwarder encapsulating the actual
86 : : DrawOutliner. Thus, changes on that Outliner are immediately
87 : : reflected on the screen. If the object leaves edit mode, the old
88 : : behaviour is restored.</p>
89 : : */
90 : : class SvxTextEditSourceImpl : public SfxListener, public SfxBroadcaster, public sdr::ObjectUser
91 : : {
92 : : private:
93 : : oslInterlockedCount maRefCount;
94 : :
95 : : SdrObject* mpObject;
96 : : SdrText* mpText;
97 : : SdrView* mpView;
98 : : const Window* mpWindow;
99 : : SdrModel* mpModel;
100 : : SdrOutliner* mpOutliner;
101 : : SvxOutlinerForwarder* mpTextForwarder;
102 : : SvxDrawOutlinerViewForwarder* mpViewForwarder; // if non-NULL, use GetViewModeTextForwarder text forwarder
103 : : css::uno::Reference< css::linguistic2::XLinguServiceManager > m_xLinguServiceManager;
104 : : Point maTextOffset;
105 : : sal_Bool mbDataValid;
106 : : sal_Bool mbDestroyed;
107 : : sal_Bool mbIsLocked;
108 : : sal_Bool mbNeedsUpdate;
109 : : sal_Bool mbOldUndoMode;
110 : : sal_Bool mbForwarderIsEditMode; // have to reflect that, since ENDEDIT can happen more often
111 : : sal_Bool mbShapeIsEditMode; // #104157# only true, if HINT_BEGEDIT was received
112 : : sal_Bool mbNotificationsDisabled; // prevent EditEngine/Outliner notifications (e.g. when setting up forwarder)
113 : :
114 : : XInterface* mpOwner;
115 : : SvxUnoTextRangeBaseList maTextRanges;
116 : :
117 : : SvxTextForwarder* GetBackgroundTextForwarder();
118 : : SvxTextForwarder* GetEditModeTextForwarder();
119 : : SvxDrawOutlinerViewForwarder* CreateViewForwarder();
120 : :
121 : : void SetupOutliner();
122 : :
123 [ - + ]: 309327 : sal_Bool HasView() const { return mpView ? sal_True : sal_False; }
124 : 0 : sal_Bool IsEditMode() const
125 : : {
126 [ # # ][ # # ]: 0 : SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
127 [ # # ][ # # ]: 0 : return mbShapeIsEditMode && pTextObj && pTextObj->IsTextEditActive() ? sal_True : sal_False;
[ # # ]
128 : : }
129 : :
130 : : void dispose();
131 : :
132 : : public:
133 : : SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText, XInterface* pOwner );
134 : : SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText, SdrView& rView, const Window& rWindow );
135 : : ~SvxTextEditSourceImpl();
136 : :
137 : : void SAL_CALL acquire();
138 : : void SAL_CALL release();
139 : :
140 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
141 : :
142 : : SvxEditSource* Clone() const;
143 : : SvxTextForwarder* GetTextForwarder();
144 : : SvxEditViewForwarder* GetEditViewForwarder( sal_Bool );
145 : : void UpdateData();
146 : :
147 : : void addRange( SvxUnoTextRangeBase* pNewRange );
148 : : void removeRange( SvxUnoTextRangeBase* pOldRange );
149 : : const SvxUnoTextRangeBaseList& getRanges() const;
150 : :
151 : : SdrObject* GetSdrObject() const { return mpObject; }
152 : :
153 : : void lock();
154 : : void unlock();
155 : :
156 : : sal_Bool IsValid() const;
157 : :
158 : : Rectangle GetVisArea();
159 : : Point LogicToPixel( const Point&, const MapMode& rMapMode );
160 : : Point PixelToLogic( const Point&, const MapMode& rMapMode );
161 : :
162 : : DECL_LINK( NotifyHdl, EENotify* );
163 : :
164 : : virtual void ObjectInDestruction(const SdrObject& rObject);
165 : :
166 : : void ChangeModel( SdrModel* pNewModel );
167 : :
168 : : void UpdateOutliner();
169 : : };
170 : :
171 : : //------------------------------------------------------------------------
172 : :
173 : 94043 : SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText, XInterface* pOwner )
174 : : : maRefCount ( 0 ),
175 : : mpObject ( pObject ),
176 : : mpText ( pText ),
177 : : mpView ( NULL ),
178 : : mpWindow ( NULL ),
179 : : mpModel ( pObject ? pObject->GetModel() : NULL ),
180 : : mpOutliner ( NULL ),
181 : : mpTextForwarder ( NULL ),
182 : : mpViewForwarder ( NULL ),
183 : : mbDataValid ( sal_False ),
184 : : mbDestroyed ( sal_False ),
185 : : mbIsLocked ( sal_False ),
186 : : mbNeedsUpdate ( sal_False ),
187 : : mbOldUndoMode ( sal_False ),
188 : : mbForwarderIsEditMode ( sal_False ),
189 : : mbShapeIsEditMode ( sal_False ),
190 : : mbNotificationsDisabled ( sal_False ),
191 [ + - ][ + - ]: 94043 : mpOwner( pOwner )
[ + - ][ + - ]
192 : : {
193 : : DBG_ASSERT( mpObject, "invalid pObject!" );
194 : :
195 [ + + ]: 94043 : if( !mpText )
196 : : {
197 [ - + ]: 93995 : SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
198 [ + - ]: 93995 : if( pTextObj )
199 [ + - ]: 93995 : mpText = pTextObj->getText( 0 );
200 : : }
201 : :
202 [ + - ]: 94043 : if( mpModel )
203 [ + - ]: 94043 : StartListening( *mpModel );
204 : :
205 [ + - ]: 94043 : if( mpObject )
206 [ + - ]: 94043 : mpObject->AddObjectUser( *this );
207 : 94043 : }
208 : :
209 : : //------------------------------------------------------------------------
210 : :
211 : 0 : SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText, SdrView& rView, const Window& rWindow )
212 : : : maRefCount ( 0 ),
213 : : mpObject ( &rObject ),
214 : : mpText ( pText ),
215 : : mpView ( &rView ),
216 : : mpWindow ( &rWindow ),
217 [ # # ]: 0 : mpModel ( rObject.GetModel() ),
218 : : mpOutliner ( NULL ),
219 : : mpTextForwarder ( NULL ),
220 : : mpViewForwarder ( NULL ),
221 : : mbDataValid ( sal_False ),
222 : : mbDestroyed ( sal_False ),
223 : : mbIsLocked ( sal_False ),
224 : : mbNeedsUpdate ( sal_False ),
225 : : mbOldUndoMode ( sal_False ),
226 : : mbForwarderIsEditMode ( sal_False ),
227 : : mbShapeIsEditMode ( sal_True ),
228 : : mbNotificationsDisabled ( sal_False ),
229 [ # # ][ # # ]: 0 : mpOwner(0)
230 : : {
231 [ # # ]: 0 : if( !mpText )
232 : : {
233 [ # # ]: 0 : SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
234 [ # # ]: 0 : if( pTextObj )
235 [ # # ]: 0 : mpText = pTextObj->getText( 0 );
236 : : }
237 : :
238 [ # # ]: 0 : if( mpModel )
239 [ # # ]: 0 : StartListening( *mpModel );
240 [ # # ]: 0 : if( mpView )
241 [ # # ]: 0 : StartListening( *mpView );
242 [ # # ]: 0 : if( mpObject )
243 [ # # ]: 0 : mpObject->AddObjectUser( *this );
244 : :
245 : : // #104157# Init edit mode state from shape info (IsTextEditActive())
246 [ # # ]: 0 : mbShapeIsEditMode = IsEditMode();
247 : 0 : }
248 : :
249 : : //------------------------------------------------------------------------
250 : :
251 [ + - ]: 94043 : SvxTextEditSourceImpl::~SvxTextEditSourceImpl()
252 : : {
253 : : DBG_ASSERT( mbIsLocked == sal_False, "text edit source was not unlocked before dispose!" );
254 [ + + ]: 94043 : if( mpObject )
255 [ + - ]: 84004 : mpObject->RemoveObjectUser( *this );
256 : :
257 [ + - ]: 94043 : dispose();
258 [ - + ]: 188086 : }
259 : :
260 : : //------------------------------------------------------------------------
261 : :
262 : 97393 : void SvxTextEditSourceImpl::addRange( SvxUnoTextRangeBase* pNewRange )
263 : : {
264 [ + - ]: 97393 : if( pNewRange )
265 [ + - ][ + - ]: 97393 : if( std::find( maTextRanges.begin(), maTextRanges.end(), pNewRange ) == maTextRanges.end() )
[ + - ]
266 : 97393 : maTextRanges.push_back( pNewRange );
267 : 97393 : }
268 : :
269 : : //------------------------------------------------------------------------
270 : :
271 : 97393 : void SvxTextEditSourceImpl::removeRange( SvxUnoTextRangeBase* pOldRange )
272 : : {
273 [ + - ]: 97393 : if( pOldRange )
274 : 97393 : maTextRanges.remove( pOldRange );
275 : 97393 : }
276 : :
277 : : //------------------------------------------------------------------------
278 : :
279 : 213 : const SvxUnoTextRangeBaseList& SvxTextEditSourceImpl::getRanges() const
280 : : {
281 : 213 : return maTextRanges;
282 : : }
283 : :
284 : : //------------------------------------------------------------------------
285 : :
286 : 967559 : void SAL_CALL SvxTextEditSourceImpl::acquire()
287 : : {
288 : 967559 : osl_incrementInterlockedCount( &maRefCount );
289 : 967559 : }
290 : :
291 : : //------------------------------------------------------------------------
292 : :
293 : 967559 : void SAL_CALL SvxTextEditSourceImpl::release()
294 : : {
295 [ + + ]: 967559 : if( ! osl_decrementInterlockedCount( &maRefCount ) )
296 [ + - ]: 94043 : delete this;
297 : 967559 : }
298 : :
299 : 0 : void SvxTextEditSourceImpl::ChangeModel( SdrModel* pNewModel )
300 : : {
301 [ # # ]: 0 : if( mpModel != pNewModel )
302 : : {
303 [ # # ]: 0 : if( mpModel )
304 : 0 : EndListening( *mpModel );
305 : :
306 [ # # ]: 0 : if( mpOutliner )
307 : : {
308 [ # # ]: 0 : if( mpModel )
309 : 0 : mpModel->disposeOutliner( mpOutliner );
310 : : else
311 [ # # ]: 0 : delete mpOutliner;
312 : 0 : mpOutliner = 0;
313 : : }
314 : :
315 [ # # ]: 0 : if( mpView )
316 : : {
317 : 0 : EndListening( *mpView );
318 : 0 : mpView = 0;
319 : : }
320 : :
321 : 0 : mpWindow = 0;
322 : 0 : m_xLinguServiceManager.clear();
323 : 0 : mpOwner = 0;
324 : :
325 : 0 : mpModel = pNewModel;
326 : :
327 [ # # ]: 0 : if( mpTextForwarder )
328 : : {
329 [ # # ]: 0 : delete mpTextForwarder;
330 : 0 : mpTextForwarder = 0;
331 : : }
332 : :
333 [ # # ]: 0 : if( mpViewForwarder )
334 : : {
335 [ # # ]: 0 : delete mpViewForwarder;
336 : 0 : mpViewForwarder = 0;
337 : : }
338 : :
339 [ # # ]: 0 : if( mpModel )
340 : 0 : StartListening( *mpModel );
341 : : }
342 : 0 : }
343 : :
344 : : //------------------------------------------------------------------------
345 : :
346 : 869955 : void SvxTextEditSourceImpl::Notify( SfxBroadcaster&, const SfxHint& rHint )
347 : : {
348 : : // #i105988 keep reference to this object
349 [ + - ]: 869955 : rtl::Reference< SvxTextEditSourceImpl > xThis( this );
350 : :
351 [ + - ][ + - ]: 869955 : const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
[ + - ][ + + ]
352 [ + - ][ + - ]: 869955 : const SvxViewHint* pViewHint = PTR_CAST( SvxViewHint, &rHint );
[ + - ][ - + ]
353 : :
354 [ - + ]: 869955 : if( pViewHint )
355 : : {
356 [ # # ][ # # ]: 0 : switch( pViewHint->GetHintType() )
357 : : {
358 : : case SvxViewHint::SVX_HINT_VIEWCHANGED:
359 [ # # ]: 0 : Broadcast( *pViewHint );
360 : 0 : break;
361 : : }
362 : : }
363 [ + + ]: 869955 : else if( pSdrHint )
364 : : {
365 [ + - ][ + - : 869951 : switch( pSdrHint->GetKind() )
- + + ]
366 : : {
367 : : case HINT_OBJCHG:
368 : : {
369 : 112661 : mbDataValid = sal_False; // Text muss neu geholt werden
370 : :
371 [ - + ]: 112661 : if( HasView() )
372 : : {
373 : : // #104157# Update maTextOffset, object has changed
374 : : // #105196#, #105203#: Cannot call that // here,
375 : : // since TakeTextRect() (called from there) //
376 : : // changes outliner content.
377 : : // UpdateOutliner();
378 : :
379 : : // #101029# Broadcast object changes, as they might change visible attributes
380 [ # # ]: 0 : SvxViewHint aHint(SvxViewHint::SVX_HINT_VIEWCHANGED);
381 [ # # ][ # # ]: 0 : Broadcast( aHint );
382 : : }
383 : 112661 : break;
384 : : }
385 : :
386 : : case HINT_BEGEDIT:
387 [ # # ][ # # ]: 0 : if( mpObject == pSdrHint->GetObject() )
388 : : {
389 : : // invalidate old forwarder
390 [ # # ]: 0 : if( !mbForwarderIsEditMode )
391 : : {
392 [ # # ][ # # ]: 0 : delete mpTextForwarder;
393 : 0 : mpTextForwarder = NULL;
394 : : }
395 : :
396 : : // register as listener - need to broadcast state change messages
397 [ # # ][ # # ]: 0 : if( mpView && mpView->GetTextEditOutliner() )
[ # # ]
398 [ # # ][ # # ]: 0 : mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
399 : :
400 : : // #104157# Only now we're really in edit mode
401 : 0 : mbShapeIsEditMode = sal_True;
402 : :
403 [ # # ]: 0 : Broadcast( *pSdrHint );
404 : : }
405 : 0 : break;
406 : :
407 : : case HINT_ENDEDIT:
408 [ # # ][ # # ]: 0 : if( mpObject == pSdrHint->GetObject() )
409 : : {
410 [ # # ]: 0 : Broadcast( *pSdrHint );
411 : :
412 : : // #104157# We're no longer in edit mode
413 : 0 : mbShapeIsEditMode = sal_False;
414 : :
415 : : // remove as listener - outliner might outlive ourselves
416 [ # # ][ # # ]: 0 : if( mpView && mpView->GetTextEditOutliner() )
[ # # ]
417 [ # # ][ # # ]: 0 : mpView->GetTextEditOutliner()->SetNotifyHdl( Link() );
418 : :
419 : : // destroy view forwarder, OutlinerView no longer
420 : : // valid (no need for UpdateData(), it's been
421 : : // synched on SdrEndTextEdit)
422 [ # # ][ # # ]: 0 : delete mpViewForwarder;
423 : 0 : mpViewForwarder = NULL;
424 : :
425 : : // #100424# Invalidate text forwarder, we might
426 : : // not be called again before entering edit mode a
427 : : // second time! Then, the old outliner might be
428 : : // invalid.
429 [ # # ]: 0 : if( mbForwarderIsEditMode )
430 : : {
431 : 0 : mbForwarderIsEditMode = sal_False;
432 [ # # ][ # # ]: 0 : delete mpTextForwarder;
433 : 0 : mpTextForwarder = NULL;
434 : : }
435 : : }
436 : 0 : break;
437 : :
438 : : case HINT_MODELCLEARED:
439 [ + - ]: 661 : dispose();
440 : 661 : break;
441 : : default:
442 : 869951 : break;
443 : : }
444 [ + - ]: 869955 : }
445 : 869955 : }
446 : :
447 : : /* this is a callback from the attached SdrObject when it is actually deleted */
448 : 9378 : void SvxTextEditSourceImpl::ObjectInDestruction(const SdrObject&)
449 : : {
450 : 9378 : mpObject = 0;
451 : 9378 : dispose();
452 [ + - ]: 9378 : Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
453 : 9378 : }
454 : :
455 : : /* unregister at all objects and set all references to 0 */
456 : 104082 : void SvxTextEditSourceImpl::dispose()
457 : : {
458 [ + + ]: 104082 : if( mpTextForwarder )
459 : : {
460 [ + - ]: 23101 : delete mpTextForwarder;
461 : 23101 : mpTextForwarder = 0;
462 : : }
463 : :
464 [ - + ]: 104082 : if( mpViewForwarder )
465 : : {
466 [ # # ]: 0 : delete mpViewForwarder;
467 : 0 : mpViewForwarder = 0;
468 : : }
469 : :
470 [ + + ]: 104082 : if( mpOutliner )
471 : : {
472 [ + - ]: 23101 : if( mpModel )
473 : : {
474 : 23101 : mpModel->disposeOutliner( mpOutliner );
475 : : }
476 : : else
477 : : {
478 [ # # ]: 0 : delete mpOutliner;
479 : : }
480 : 23101 : mpOutliner = 0;
481 : : }
482 : :
483 [ + + ]: 104082 : if( mpModel )
484 : : {
485 : 94043 : EndListening( *mpModel );
486 : 94043 : mpModel = 0;
487 : : }
488 : :
489 [ - + ]: 104082 : if( mpView )
490 : : {
491 : 0 : EndListening( *mpView );
492 : 0 : mpView = 0;
493 : : }
494 : :
495 [ + + ]: 104082 : if( mpObject )
496 : : {
497 : 84665 : mpObject->RemoveObjectUser( *this );
498 : 84665 : mpObject = 0;
499 : : }
500 : 104082 : mpWindow = 0;
501 : 104082 : }
502 : :
503 : : //------------------------------------------------------------------------
504 : :
505 : 0 : void SvxTextEditSourceImpl::SetupOutliner()
506 : : {
507 : : // #101029#
508 : : // only for UAA edit source: setup outliner equivalently as in
509 : : // SdrTextObj::Paint(), such that formatting equals screen
510 : : // layout
511 [ # # ][ # # ]: 0 : if( mpObject && mpOutliner )
512 : : {
513 [ # # ][ # # ]: 0 : SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
[ # # ][ # # ]
514 [ # # ]: 0 : Rectangle aPaintRect;
515 [ # # ]: 0 : if( pTextObj )
516 : : {
517 [ # # ]: 0 : Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
518 [ # # ]: 0 : pTextObj->SetupOutlinerFormatting( *mpOutliner, aPaintRect );
519 : :
520 : : // #101029# calc text offset from shape anchor
521 : 0 : maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft();
522 : : }
523 : : }
524 : 0 : }
525 : :
526 : : //------------------------------------------------------------------------
527 : :
528 : 0 : void SvxTextEditSourceImpl::UpdateOutliner()
529 : : {
530 : : // #104157#
531 : : // only for UAA edit source: update outliner equivalently as in
532 : : // SdrTextObj::Paint(), such that formatting equals screen
533 : : // layout
534 [ # # ][ # # ]: 0 : if( mpObject && mpOutliner )
535 : : {
536 [ # # ][ # # ]: 0 : SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
[ # # ][ # # ]
537 [ # # ]: 0 : Rectangle aPaintRect;
538 [ # # ]: 0 : if( pTextObj )
539 : : {
540 [ # # ]: 0 : Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
541 [ # # ]: 0 : pTextObj->UpdateOutlinerFormatting( *mpOutliner, aPaintRect );
542 : :
543 : : // #101029# calc text offset from shape anchor
544 : 0 : maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft();
545 : : }
546 : : }
547 : 0 : }
548 : :
549 : : //------------------------------------------------------------------------
550 : :
551 : :
552 : :
553 : 125161 : SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
554 : : {
555 : 125161 : sal_Bool bCreated = sal_False;
556 : :
557 : : // #99840#: prevent EE/Outliner notifications during setup
558 : 125161 : mbNotificationsDisabled = sal_True;
559 : :
560 [ + + ]: 125161 : if (!mpTextForwarder)
561 : : {
562 [ + - ]: 23101 : if( mpOutliner == NULL )
563 : : {
564 [ + - ][ + - ]: 23101 : SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
565 : 23101 : sal_uInt16 nOutlMode = OUTLINERMODE_TEXTOBJECT;
566 [ + - ][ + + ]: 23101 : if( pTextObj && pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_OUTLINETEXT )
[ + + ][ + + ]
567 : 7 : nOutlMode = OUTLINERMODE_OUTLINEOBJECT;
568 : :
569 : 23101 : mpOutliner = mpModel->createOutliner( nOutlMode );
570 : :
571 : : // #109151# Do the setup after outliner creation, would be useless otherwise
572 [ - + ]: 23101 : if( HasView() )
573 : : {
574 : : // #101029#, #104157# Setup outliner _before_ filling it
575 : 0 : SetupOutliner();
576 : : }
577 : :
578 : 23101 : mpOutliner->SetTextObjNoInit( pTextObj );
579 [ + + ]: 23101 : if( mbIsLocked )
580 : : {
581 : 335 : ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_False );
582 : 335 : mbOldUndoMode = ((EditEngine*)&(mpOutliner->GetEditEngine()))->IsUndoEnabled();
583 : 335 : ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( sal_False );
584 : : }
585 : :
586 [ + - ]: 23101 : if ( !m_xLinguServiceManager.is() )
587 : : {
588 [ + - ]: 23101 : css::uno::Reference< css::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
589 : : m_xLinguServiceManager = css::uno::Reference< css::linguistic2::XLinguServiceManager >(
590 [ + - ][ + - ]: 23101 : xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.linguistic2.LinguServiceManager" ))), css::uno::UNO_QUERY );
[ + - ][ + - ]
[ + - ]
591 : : }
592 : :
593 [ + + ]: 23101 : if ( m_xLinguServiceManager.is() )
594 : : {
595 [ + - ][ + - ]: 22426 : css::uno::Reference< css::linguistic2::XHyphenator > xHyphenator( m_xLinguServiceManager->getHyphenator(), css::uno::UNO_QUERY );
[ + - ]
596 [ + - ]: 22426 : if( xHyphenator.is() )
597 [ + - ]: 22426 : mpOutliner->SetHyphenator( xHyphenator );
598 : : }
599 : : }
600 : :
601 : :
602 [ + - ][ + + ]: 23101 : mpTextForwarder = new SvxOutlinerForwarder( *mpOutliner, (mpObject->GetObjInventor() == SdrInventor) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) );
[ + - ]
603 : : // delay listener subscription and UAA initialization until Outliner is fully setup
604 : 23101 : bCreated = sal_True;
605 : :
606 : 23101 : mbForwarderIsEditMode = sal_False;
607 : : }
608 : :
609 [ + - ][ + - ]: 125161 : if( mpObject && mpText && !mbDataValid && mpObject->IsInserted() && mpObject->GetPage() )
[ + + ][ + - ]
[ + - ][ + + ]
610 : : {
611 : 23101 : mpTextForwarder->flushCache();
612 : :
613 : 23101 : OutlinerParaObject* pOutlinerParaObject = NULL;
614 [ + - ][ + - ]: 23101 : SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
615 [ + - ][ + - ]: 23101 : if( pTextObj && pTextObj->getActiveText() == mpText )
[ + - ]
616 : 23101 : pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
617 : 23101 : bool bOwnParaObj(false);
618 : :
619 [ - + ]: 23101 : if( pOutlinerParaObject )
620 : 0 : bOwnParaObj = true; // text edit active
621 : : else
622 : 23101 : pOutlinerParaObject = mpText->GetOutlinerParaObject();
623 : :
624 [ + + ][ + - ]: 23101 : if( pOutlinerParaObject && ( bOwnParaObj || !mpObject->IsEmptyPresObj() || mpObject->GetPage()->IsMasterPage() ) )
[ + + ][ + + ]
[ + + ]
625 : : {
626 : 191 : mpOutliner->SetText( *pOutlinerParaObject );
627 : :
628 : : // #91254# put text to object and set EmptyPresObj to FALSE
629 [ - + ][ # # ]: 191 : if( mpText && bOwnParaObj && pOutlinerParaObject && mpObject->IsEmptyPresObj() && pTextObj->IsRealyEdited() )
[ # # ][ # # ]
[ - + ][ + - ]
630 : : {
631 : 0 : mpObject->SetEmptyPresObj( sal_False );
632 : 0 : static_cast< SdrTextObj* >( mpObject)->NbcSetOutlinerParaObjectForText( pOutlinerParaObject, mpText );
633 : :
634 : : // #i103982# Here, due to mpObject->NbcSetOutlinerParaObjectForText, we LOSE ownership of the
635 : : // OPO, so do NOT delete it when leaving this method (!)
636 : 0 : bOwnParaObj = false;
637 : : }
638 : : }
639 : : else
640 : : {
641 [ + + ]: 22910 : sal_Bool bVertical = pOutlinerParaObject ? pOutlinerParaObject->IsVertical() : sal_False;
642 : :
643 : : // set objects style sheet on empty outliner
644 : 22910 : SfxStyleSheetPool* pPool = (SfxStyleSheetPool*)mpObject->GetModel()->GetStyleSheetPool();
645 [ + + ]: 22910 : if( pPool )
646 : 505 : mpOutliner->SetStyleSheetPool( pPool );
647 : :
648 : 22910 : SfxStyleSheet* pStyleSheet = mpObject->GetPage()->GetTextStyleSheetForObject( mpObject );
649 [ + + ]: 22910 : if( pStyleSheet )
650 : 499 : mpOutliner->SetStyleSheet( 0, pStyleSheet );
651 : :
652 [ - + ]: 22910 : if( bVertical )
653 : 0 : mpOutliner->SetVertical( sal_True );
654 : : }
655 : :
656 : : // evtually we have to set the border attributes
657 [ + + ]: 23101 : if (mpOutliner->GetParagraphCount()==1)
658 : : {
659 : : // if we only have one paragraph we check if it is empty
660 [ + - ][ + - ]: 23097 : rtl::OUString aStr(mpOutliner->GetText(mpOutliner->GetParagraph(0)));
[ + - ][ + - ]
661 : :
662 [ + + ]: 23097 : if (aStr.isEmpty())
663 : : {
664 : : // its empty, so we have to force the outliner to initialise itself
665 [ + - ][ + - ]: 22919 : mpOutliner->SetText( String(), mpOutliner->GetParagraph( 0 ) );
[ + - ][ + - ]
666 : :
667 [ + - ][ + + ]: 22919 : if(mpObject->GetStyleSheet())
668 [ + - ][ + - ]: 505 : mpOutliner->SetStyleSheet( 0, mpObject->GetStyleSheet());
669 : 23097 : }
670 : : }
671 : :
672 : 23101 : mbDataValid = sal_True;
673 : :
674 [ - + ]: 23101 : if( bOwnParaObj )
675 [ # # ]: 0 : delete pOutlinerParaObject;
676 : : }
677 : :
678 [ + + ][ + - ]: 125161 : if( bCreated && mpOutliner && HasView() )
[ - + ][ - + ]
679 : : {
680 : : // register as listener - need to broadcast state change messages
681 : : // registration delayed until outliner is completely set up
682 [ # # ]: 0 : mpOutliner->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
683 : : }
684 : :
685 : : // #99840#: prevent EE/Outliner notifications during setup
686 : 125161 : mbNotificationsDisabled = sal_False;
687 : :
688 : 125161 : return mpTextForwarder;
689 : : }
690 : :
691 : : //------------------------------------------------------------------------
692 : :
693 : 0 : SvxTextForwarder* SvxTextEditSourceImpl::GetEditModeTextForwarder()
694 : : {
695 [ # # ][ # # ]: 0 : if( !mpTextForwarder && HasView() )
[ # # ]
696 : : {
697 : 0 : SdrOutliner* pEditOutliner = mpView->GetTextEditOutliner();
698 : :
699 [ # # ]: 0 : if( pEditOutliner )
700 : : {
701 [ # # ][ # # ]: 0 : mpTextForwarder = new SvxOutlinerForwarder( *pEditOutliner, (mpObject->GetObjInventor() == SdrInventor) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) );
[ # # ]
702 : 0 : mbForwarderIsEditMode = sal_True;
703 : : }
704 : : }
705 : :
706 : 0 : return mpTextForwarder;
707 : : }
708 : :
709 : : //------------------------------------------------------------------------
710 : :
711 : 125161 : SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder()
712 : : {
713 [ + - ][ - + ]: 125161 : if( mbDestroyed || mpObject == NULL )
714 : 0 : return NULL;
715 : :
716 [ - + ]: 125161 : if( mpModel == NULL )
717 : 0 : mpModel = mpObject->GetModel();
718 : :
719 [ - + ]: 125161 : if( mpModel == NULL )
720 : 0 : return NULL;
721 : :
722 : : // distinguish the cases
723 : : // a) connected to view, maybe edit mode is active, can work directly on the EditOutliner
724 : : // b) background Outliner, reflect changes into ParaOutlinerObject (this is exactly the old UNO code)
725 [ - + ]: 125161 : if( HasView() )
726 : : {
727 [ # # ]: 0 : if( IsEditMode() != mbForwarderIsEditMode )
728 : : {
729 : : // forwarder mismatch - create new
730 [ # # ]: 0 : delete mpTextForwarder;
731 : 0 : mpTextForwarder = NULL;
732 : : }
733 : :
734 [ # # ]: 0 : if( IsEditMode() )
735 : 0 : return GetEditModeTextForwarder();
736 : : else
737 : 0 : return GetBackgroundTextForwarder();
738 : : }
739 : : else
740 : 125161 : return GetBackgroundTextForwarder();
741 : : }
742 : :
743 : : //------------------------------------------------------------------------
744 : :
745 : 0 : SvxDrawOutlinerViewForwarder* SvxTextEditSourceImpl::CreateViewForwarder()
746 : : {
747 [ # # ][ # # ]: 0 : if( mpView->GetTextEditOutlinerView() && mpObject )
[ # # ]
748 : : {
749 : : // register as listener - need to broadcast state change messages
750 [ # # ]: 0 : mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
751 : :
752 [ # # ][ # # ]: 0 : SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
753 [ # # ]: 0 : if( pTextObj )
754 : : {
755 [ # # ]: 0 : Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
756 : 0 : OutlinerView& rOutlView = *mpView->GetTextEditOutlinerView();
757 : :
758 [ # # ][ # # ]: 0 : return new SvxDrawOutlinerViewForwarder( rOutlView, aBoundRect.TopLeft() );
759 : : }
760 : : }
761 : :
762 : 0 : return NULL;
763 : : }
764 : :
765 : 0 : SvxEditViewForwarder* SvxTextEditSourceImpl::GetEditViewForwarder( sal_Bool bCreate )
766 : : {
767 [ # # ][ # # ]: 0 : if( mbDestroyed || mpObject == NULL )
768 : 0 : return NULL;
769 : :
770 [ # # ]: 0 : if( mpModel == NULL )
771 : 0 : mpModel = mpObject->GetModel();
772 : :
773 [ # # ]: 0 : if( mpModel == NULL )
774 : 0 : return NULL;
775 : :
776 : : // shall we delete?
777 [ # # ]: 0 : if( mpViewForwarder )
778 : : {
779 [ # # ]: 0 : if( !IsEditMode() )
780 : : {
781 : : // destroy all forwarders (no need for UpdateData(),
782 : : // it's been synched on SdrEndTextEdit)
783 [ # # ]: 0 : delete mpViewForwarder;
784 : 0 : mpViewForwarder = NULL;
785 : : }
786 : : }
787 : : // which to create? Directly in edit mode, create new, or none?
788 [ # # ]: 0 : else if( mpView )
789 : : {
790 [ # # ]: 0 : if( IsEditMode() )
791 : : {
792 : : // create new view forwarder
793 : 0 : mpViewForwarder = CreateViewForwarder();
794 : : }
795 [ # # ]: 0 : else if( bCreate )
796 : : {
797 : : // dispose old text forwarder
798 : 0 : UpdateData();
799 : :
800 [ # # ]: 0 : delete mpTextForwarder;
801 : 0 : mpTextForwarder = NULL;
802 : :
803 : : // enter edit mode
804 : 0 : mpView->SdrEndTextEdit();
805 : :
806 [ # # ]: 0 : if(mpView->SdrBeginTextEdit(mpObject, 0L, 0L, sal_False, (SdrOutliner*)0L, 0L, sal_False, sal_False))
807 : : {
808 [ # # ][ # # ]: 0 : SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
809 [ # # ]: 0 : if( pTextObj->IsTextEditActive() )
810 : : {
811 : : // create new view forwarder
812 : 0 : mpViewForwarder = CreateViewForwarder();
813 : : }
814 : : else
815 : : {
816 : : // failure. Somehow, SdrBeginTextEdit did not set
817 : : // our SdrTextObj into edit mode
818 : 0 : mpView->SdrEndTextEdit();
819 : : }
820 : : }
821 : : }
822 : : }
823 : :
824 : 0 : return mpViewForwarder;
825 : : }
826 : :
827 : : //------------------------------------------------------------------------
828 : :
829 : 25303 : void SvxTextEditSourceImpl::UpdateData()
830 : : {
831 : : // if we have a view and in edit mode, we're working with the
832 : : // DrawOutliner. Thus, all changes made on the text forwarder are
833 : : // reflected on the view and committed to the model on
834 : : // SdrEndTextEdit(). Thus, no need for explicit updates here.
835 [ - + ][ # # ]: 25303 : if( !HasView() || !IsEditMode() )
[ + - ]
836 : : {
837 [ + + ]: 25303 : if( mbIsLocked )
838 : : {
839 : 1613 : mbNeedsUpdate = sal_True;
840 : : }
841 : : else
842 : : {
843 [ + - ][ + - ]: 23690 : if( mpOutliner && mpObject && mpText && !mbDestroyed )
[ + - ][ + - ]
844 : : {
845 [ - + ]: 23690 : SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
846 [ + - ]: 23690 : if( pTextObj )
847 : : {
848 [ + + ][ + + ]: 23690 : if( mpOutliner->GetParagraphCount() != 1 || mpOutliner->GetEditEngine().GetTextLen( 0 ) )
[ + + ]
849 : : {
850 [ + + ]: 23400 : if( mpOutliner->GetParagraphCount() > 1 )
851 : : {
852 [ + - ][ + - ]: 1054 : if( pTextObj && pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_TITLETEXT )
[ - + ][ - + ]
853 : : {
854 [ # # ]: 0 : while( mpOutliner->GetParagraphCount() > 1 )
855 : : {
856 [ # # ]: 0 : ESelection aSel( 0,mpOutliner->GetEditEngine().GetTextLen( 0 ), 1,0 );
857 [ # # ]: 0 : mpOutliner->QuickInsertLineBreak( aSel );
858 : : }
859 : : }
860 : : }
861 : :
862 : 23400 : pTextObj->NbcSetOutlinerParaObjectForText( mpOutliner->CreateParaObject(), mpText );
863 : : }
864 : : else
865 : : {
866 : 290 : pTextObj->NbcSetOutlinerParaObjectForText( NULL,mpText );
867 : : }
868 : : }
869 : :
870 [ + + ]: 23690 : if( mpObject->IsEmptyPresObj() )
871 : 9 : mpObject->SetEmptyPresObj(sal_False);
872 : : }
873 : : }
874 : : }
875 : 25303 : }
876 : :
877 : 495 : void SvxTextEditSourceImpl::lock()
878 : : {
879 : 495 : mbIsLocked = sal_True;
880 [ - + ]: 495 : if( mpOutliner )
881 : : {
882 : 0 : ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_False );
883 : 0 : mbOldUndoMode = ((EditEngine*)&(mpOutliner->GetEditEngine()))->IsUndoEnabled();
884 : 0 : ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( sal_False );
885 : : }
886 : 495 : }
887 : :
888 : 495 : void SvxTextEditSourceImpl::unlock()
889 : : {
890 : 495 : mbIsLocked = sal_False;
891 : :
892 [ + + ]: 495 : if( mbNeedsUpdate )
893 : : {
894 : 335 : UpdateData();
895 : 335 : mbNeedsUpdate = sal_False;
896 : : }
897 : :
898 [ + + ]: 495 : if( mpOutliner )
899 : : {
900 : 335 : ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_True );
901 : 335 : ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( mbOldUndoMode );
902 : : }
903 : 495 : }
904 : :
905 : 0 : sal_Bool SvxTextEditSourceImpl::IsValid() const
906 : : {
907 [ # # ][ # # ]: 0 : return mpView && mpWindow ? sal_True : sal_False;
908 : : }
909 : :
910 : 0 : Rectangle SvxTextEditSourceImpl::GetVisArea()
911 : : {
912 [ # # ]: 0 : if( IsValid() )
913 : : {
914 [ # # ]: 0 : SdrPaintWindow* pPaintWindow = mpView->FindPaintWindow(*mpWindow);
915 [ # # ]: 0 : Rectangle aVisArea;
916 : :
917 [ # # ]: 0 : if(pPaintWindow)
918 : : {
919 [ # # ]: 0 : aVisArea = pPaintWindow->GetVisibleArea();
920 : : }
921 : :
922 : : // offset vis area by edit engine left-top position
923 [ # # ][ # # ]: 0 : SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
[ # # ][ # # ]
924 [ # # ]: 0 : if( pTextObj )
925 : : {
926 [ # # ]: 0 : Rectangle aAnchorRect;
927 [ # # ]: 0 : pTextObj->TakeTextAnchorRect( aAnchorRect );
928 [ # # ]: 0 : aVisArea.Move( -aAnchorRect.Left(), -aAnchorRect.Top() );
929 : :
930 [ # # ]: 0 : MapMode aMapMode(mpWindow->GetMapMode());
931 [ # # ]: 0 : aMapMode.SetOrigin(Point());
932 [ # # ][ # # ]: 0 : return mpWindow->LogicToPixel( aVisArea, aMapMode );
933 : : }
934 : : }
935 : :
936 : 0 : return Rectangle();
937 : : }
938 : :
939 : 0 : Point SvxTextEditSourceImpl::LogicToPixel( const Point& rPoint, const MapMode& rMapMode )
940 : : {
941 : : // #101029#: The responsibilities of ViewForwarder happen to be
942 : : // somewhat mixed in this case. On the one hand, we need the
943 : : // different interface queries on the SvxEditSource interface,
944 : : // since we need both VisAreas. On the other hand, if an
945 : : // EditViewForwarder exists, maTextOffset does not remain static,
946 : : // but may change with every key press.
947 [ # # ]: 0 : if( IsEditMode() )
948 : : {
949 : 0 : SvxEditViewForwarder* pForwarder = GetEditViewForwarder(sal_False);
950 : :
951 [ # # ]: 0 : if( pForwarder )
952 : 0 : return pForwarder->LogicToPixel( rPoint, rMapMode );
953 : : }
954 [ # # ][ # # ]: 0 : else if( IsValid() && mpModel )
[ # # ]
955 : : {
956 : : // #101029#
957 : 0 : Point aPoint1( rPoint );
958 : 0 : aPoint1.X() += maTextOffset.X();
959 : 0 : aPoint1.Y() += maTextOffset.Y();
960 : :
961 : : Point aPoint2( OutputDevice::LogicToLogic( aPoint1, rMapMode,
962 [ # # ][ # # ]: 0 : MapMode(mpModel->GetScaleUnit()) ) );
[ # # ]
963 [ # # ]: 0 : MapMode aMapMode(mpWindow->GetMapMode());
964 [ # # ]: 0 : aMapMode.SetOrigin(Point());
965 [ # # ][ # # ]: 0 : return mpWindow->LogicToPixel( aPoint2, aMapMode );
966 : : }
967 : :
968 : 0 : return Point();
969 : : }
970 : :
971 : 0 : Point SvxTextEditSourceImpl::PixelToLogic( const Point& rPoint, const MapMode& rMapMode )
972 : : {
973 : : // #101029#: The responsibilities of ViewForwarder happen to be
974 : : // somewhat mixed in this case. On the one hand, we need the
975 : : // different interface queries on the SvxEditSource interface,
976 : : // since we need both VisAreas. On the other hand, if an
977 : : // EditViewForwarder exists, maTextOffset does not remain static,
978 : : // but may change with every key press.
979 [ # # ]: 0 : if( IsEditMode() )
980 : : {
981 : 0 : SvxEditViewForwarder* pForwarder = GetEditViewForwarder(sal_False);
982 : :
983 [ # # ]: 0 : if( pForwarder )
984 : 0 : return pForwarder->PixelToLogic( rPoint, rMapMode );
985 : : }
986 [ # # ][ # # ]: 0 : else if( IsValid() && mpModel )
[ # # ]
987 : : {
988 [ # # ]: 0 : MapMode aMapMode(mpWindow->GetMapMode());
989 [ # # ]: 0 : aMapMode.SetOrigin(Point());
990 [ # # ]: 0 : Point aPoint1( mpWindow->PixelToLogic( rPoint, aMapMode ) );
991 : : Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
992 : : MapMode(mpModel->GetScaleUnit()),
993 [ # # ][ # # ]: 0 : rMapMode ) );
[ # # ]
994 : : // #101029#
995 : 0 : aPoint2.X() -= maTextOffset.X();
996 : 0 : aPoint2.Y() -= maTextOffset.Y();
997 : :
998 [ # # ]: 0 : return aPoint2;
999 : : }
1000 : :
1001 : 0 : return Point();
1002 : : }
1003 : :
1004 : 0 : IMPL_LINK(SvxTextEditSourceImpl, NotifyHdl, EENotify*, aNotify)
1005 : : {
1006 [ # # ][ # # ]: 0 : if( aNotify && !mbNotificationsDisabled )
1007 : : {
1008 [ # # ][ # # ]: 0 : ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( aNotify) );
1009 : :
1010 [ # # ]: 0 : if( aHint.get() )
1011 [ # # ][ # # ]: 0 : Broadcast( *aHint.get() );
1012 : : }
1013 : :
1014 : 0 : return 0;
1015 : : }
1016 : :
1017 : : //------------------------------------------------------------------------
1018 : :
1019 : : // --------------------------------------------------------------------
1020 : : // SvxTextEditSource
1021 : : // --------------------------------------------------------------------
1022 : :
1023 : 94043 : SvxTextEditSource::SvxTextEditSource( SdrObject* pObject, SdrText* pText, XInterface* pOwner )
1024 : : {
1025 [ + - ][ + - ]: 94043 : mpImpl = new SvxTextEditSourceImpl( pObject, pText, pOwner );
1026 [ + - ]: 94043 : mpImpl->acquire();
1027 : 94043 : }
1028 : :
1029 : : // --------------------------------------------------------------------
1030 : 0 : SvxTextEditSource::SvxTextEditSource( SdrObject& rObj, SdrText* pText, SdrView& rView, const Window& rWindow )
1031 : : {
1032 [ # # ][ # # ]: 0 : mpImpl = new SvxTextEditSourceImpl( rObj, pText, rView, rWindow );
1033 [ # # ]: 0 : mpImpl->acquire();
1034 : 0 : }
1035 : :
1036 : : // --------------------------------------------------------------------
1037 : :
1038 : 3561 : SvxTextEditSource::SvxTextEditSource( SvxTextEditSourceImpl* pImpl )
1039 : : {
1040 : 3561 : mpImpl = pImpl;
1041 [ + - ]: 3561 : mpImpl->acquire();
1042 : 3561 : }
1043 : :
1044 : : //------------------------------------------------------------------------
1045 [ + - ]: 97604 : SvxTextEditSource::~SvxTextEditSource()
1046 : : {
1047 [ + - ]: 97604 : ::SolarMutexGuard aGuard;
1048 : :
1049 [ + - ][ + - ]: 97604 : mpImpl->release();
1050 [ - + ]: 195208 : }
1051 : :
1052 : : //------------------------------------------------------------------------
1053 : 3561 : SvxEditSource* SvxTextEditSource::Clone() const
1054 : : {
1055 [ + - ]: 3561 : return new SvxTextEditSource( mpImpl );
1056 : : }
1057 : :
1058 : : //------------------------------------------------------------------------
1059 : 125161 : SvxTextForwarder* SvxTextEditSource::GetTextForwarder()
1060 : : {
1061 : 125161 : return mpImpl->GetTextForwarder();
1062 : : }
1063 : :
1064 : : //------------------------------------------------------------------------
1065 : 0 : SvxEditViewForwarder* SvxTextEditSource::GetEditViewForwarder( sal_Bool bCreate )
1066 : : {
1067 : 0 : return mpImpl->GetEditViewForwarder( bCreate );
1068 : : }
1069 : :
1070 : : //------------------------------------------------------------------------
1071 : 0 : SvxViewForwarder* SvxTextEditSource::GetViewForwarder()
1072 : : {
1073 : 0 : return this;
1074 : : }
1075 : :
1076 : : //------------------------------------------------------------------------
1077 : 24968 : void SvxTextEditSource::UpdateData()
1078 : : {
1079 : 24968 : mpImpl->UpdateData();
1080 : 24968 : }
1081 : :
1082 : 0 : SfxBroadcaster& SvxTextEditSource::GetBroadcaster() const
1083 : : {
1084 : 0 : return *mpImpl;
1085 : : }
1086 : :
1087 : 495 : void SvxTextEditSource::lock()
1088 : : {
1089 : 495 : mpImpl->lock();
1090 : 495 : }
1091 : :
1092 : 495 : void SvxTextEditSource::unlock()
1093 : : {
1094 : 495 : mpImpl->unlock();
1095 : 495 : }
1096 : :
1097 : 0 : sal_Bool SvxTextEditSource::IsValid() const
1098 : : {
1099 : 0 : return mpImpl->IsValid();
1100 : : }
1101 : :
1102 : 0 : Rectangle SvxTextEditSource::GetVisArea() const
1103 : : {
1104 : 0 : return mpImpl->GetVisArea();
1105 : : }
1106 : :
1107 : 0 : Point SvxTextEditSource::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
1108 : : {
1109 : 0 : return mpImpl->LogicToPixel( rPoint, rMapMode );
1110 : : }
1111 : :
1112 : 0 : Point SvxTextEditSource::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
1113 : : {
1114 : 0 : return mpImpl->PixelToLogic( rPoint, rMapMode );
1115 : : }
1116 : :
1117 : 97393 : void SvxTextEditSource::addRange( SvxUnoTextRangeBase* pNewRange )
1118 : : {
1119 : 97393 : mpImpl->addRange( pNewRange );
1120 : 97393 : }
1121 : :
1122 : 97393 : void SvxTextEditSource::removeRange( SvxUnoTextRangeBase* pOldRange )
1123 : : {
1124 : 97393 : mpImpl->removeRange( pOldRange );
1125 : 97393 : }
1126 : :
1127 : 213 : const SvxUnoTextRangeBaseList& SvxTextEditSource::getRanges() const
1128 : : {
1129 : 213 : return mpImpl->getRanges();
1130 : : }
1131 : :
1132 : 0 : void SvxTextEditSource::ChangeModel( SdrModel* pNewModel )
1133 : : {
1134 : 0 : mpImpl->ChangeModel( pNewModel );
1135 : 0 : }
1136 : :
1137 : 0 : void SvxTextEditSource::UpdateOutliner()
1138 : : {
1139 : 0 : mpImpl->UpdateOutliner();
1140 : 0 : }
1141 : :
1142 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|