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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <vcl/wrkwin.hxx>
22 : #include <vcl/dialog.hxx>
23 : #include <vcl/msgbox.hxx>
24 : #include <vcl/svapp.hxx>
25 :
26 : #include <svtools/ctrltool.hxx>
27 :
28 : #include <editeng/svxfont.hxx>
29 : #include <impedit.hxx>
30 : #include <editeng/editeng.hxx>
31 : #include <editeng/editview.hxx>
32 : #include <editeng/editstat.hxx>
33 : #include <editdbg.hxx>
34 : #include <eerdll2.hxx>
35 : #include <editeng/eerdll.hxx>
36 : #include <editeng.hrc>
37 : #include <editeng/acorrcfg.hxx>
38 : #include <editeng/flditem.hxx>
39 : #include <editeng/txtrange.hxx>
40 : #include <vcl/graph.hxx>
41 :
42 : #include <editeng/autokernitem.hxx>
43 : #include <editeng/contouritem.hxx>
44 : #include <editeng/colritem.hxx>
45 : #include <editeng/crossedoutitem.hxx>
46 : #include <editeng/escapementitem.hxx>
47 : #include <editeng/fhgtitem.hxx>
48 : #include <editeng/fontitem.hxx>
49 : #include <editeng/kernitem.hxx>
50 : #include <editeng/lrspitem.hxx>
51 : #include <editeng/postitem.hxx>
52 : #include <editeng/shdditem.hxx>
53 : #include <editeng/udlnitem.hxx>
54 : #include <editeng/wghtitem.hxx>
55 : #include <editeng/wrlmitem.hxx>
56 : #include <editeng/brushitem.hxx>
57 : #include <editeng/charsetcoloritem.hxx>
58 : #include <editeng/langitem.hxx>
59 : #include <editeng/emphasismarkitem.hxx>
60 : #include <editeng/charscaleitem.hxx>
61 : #include <editeng/charreliefitem.hxx>
62 :
63 : #include <sot/exchange.hxx>
64 : #include <sot/formats.hxx>
65 :
66 : #include <editeng/numitem.hxx>
67 : #include <editeng/bulletitem.hxx>
68 : #include <editeng/unolingu.hxx>
69 : #include <linguistic/lngprops.hxx>
70 : #include <i18nlangtag/mslangid.hxx>
71 : #include <rtl/strbuf.hxx>
72 : #include <vcl/help.hxx>
73 : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
74 : #include <com/sun/star/i18n/InputSequenceCheckMode.hpp>
75 :
76 : #include <svl/srchdefs.hxx>
77 :
78 : #if OSL_DEBUG_LEVEL > 1
79 : #include <editeng/frmdiritem.hxx>
80 : #endif
81 : #include <basegfx/polygon/b2dpolygon.hxx>
82 :
83 : // later -> TOOLS\STRING.H (for Grep: WS_TARGET)
84 :
85 : using namespace ::com::sun::star;
86 : using namespace ::com::sun::star::uno;
87 : using namespace ::com::sun::star::linguistic2;
88 :
89 : DBG_NAME( EditEngine )
90 : DBG_NAMEEX( EditView )
91 :
92 : #if (OSL_DEBUG_LEVEL > 1) || defined ( DBG_UTIL )
93 : static sal_Bool bDebugPaint = sal_False;
94 : #endif
95 :
96 : static SfxItemPool* pGlobalPool=0;
97 :
98 : // ----------------------------------------------------------------------
99 : // EditEngine
100 : // ----------------------------------------------------------------------
101 19585 : EditEngine::EditEngine( SfxItemPool* pItemPool )
102 : {
103 : DBG_CTOR( EditEngine, 0 );
104 19585 : pImpEditEngine = new ImpEditEngine( this, pItemPool );
105 19585 : }
106 :
107 19550 : EditEngine::~EditEngine()
108 : {
109 : DBG_DTOR( EditEngine, 0 );
110 19526 : delete pImpEditEngine;
111 19550 : }
112 :
113 1538097 : void EditEngine::EnableUndo( sal_Bool bEnable )
114 : {
115 : DBG_CHKTHIS( EditEngine, 0 );
116 1538097 : pImpEditEngine->EnableUndo( bEnable );
117 1538097 : }
118 :
119 1945817 : sal_Bool EditEngine::IsUndoEnabled()
120 : {
121 : DBG_CHKTHIS( EditEngine, 0 );
122 1945817 : return pImpEditEngine->IsUndoEnabled();
123 : }
124 :
125 2298816 : sal_Bool EditEngine::IsInUndo()
126 : {
127 : DBG_CHKTHIS( EditEngine, 0 );
128 2298816 : return pImpEditEngine->IsInUndo();
129 : }
130 :
131 550064 : ::svl::IUndoManager& EditEngine::GetUndoManager()
132 : {
133 : DBG_CHKTHIS( EditEngine, 0 );
134 550064 : return pImpEditEngine->GetUndoManager();
135 : }
136 :
137 0 : ::svl::IUndoManager* EditEngine::SetUndoManager(::svl::IUndoManager* pNew)
138 : {
139 : DBG_CHKTHIS( EditEngine, 0 );
140 0 : return pImpEditEngine->SetUndoManager(pNew);
141 : }
142 :
143 33918 : void EditEngine::UndoActionStart( sal_uInt16 nId )
144 : {
145 : DBG_CHKTHIS( EditEngine, 0 );
146 : DBG_ASSERT( !pImpEditEngine->IsInUndo(), "Calling UndoActionStart in Undomode!" );
147 33918 : if ( !pImpEditEngine->IsInUndo() )
148 33918 : pImpEditEngine->UndoActionStart( nId );
149 33918 : }
150 :
151 0 : void EditEngine::UndoActionStart(sal_uInt16 nId, const ESelection& rSel)
152 : {
153 0 : pImpEditEngine->UndoActionStart(nId, rSel);
154 0 : }
155 :
156 33918 : void EditEngine::UndoActionEnd( sal_uInt16 nId )
157 : {
158 : DBG_CHKTHIS( EditEngine, 0 );
159 : DBG_ASSERT( !pImpEditEngine->IsInUndo(), "Calling UndoActionEnd in Undomode!" );
160 33918 : if ( !pImpEditEngine->IsInUndo() )
161 33918 : pImpEditEngine->UndoActionEnd( nId );
162 33918 : }
163 :
164 0 : bool EditEngine::HasTriedMergeOnLastAddUndo() const
165 : {
166 0 : return pImpEditEngine->mbLastTryMerge;
167 : }
168 :
169 12386 : void EditEngine::SetRefDevice( OutputDevice* pRefDev )
170 : {
171 : DBG_CHKTHIS( EditEngine, 0 );
172 12386 : pImpEditEngine->SetRefDevice( pRefDev );
173 12386 : }
174 :
175 1719 : OutputDevice* EditEngine::GetRefDevice() const
176 : {
177 : DBG_CHKTHIS( EditEngine, 0 );
178 1719 : return pImpEditEngine->GetRefDevice();
179 : }
180 :
181 10657 : void EditEngine::SetRefMapMode( const MapMode& rMapMode )
182 : {
183 : DBG_CHKTHIS( EditEngine, 0 );
184 10657 : pImpEditEngine->SetRefMapMode( rMapMode );
185 10657 : }
186 :
187 190 : MapMode EditEngine::GetRefMapMode()
188 : {
189 : DBG_CHKTHIS( EditEngine, 0 );
190 190 : return pImpEditEngine->GetRefMapMode();
191 : }
192 :
193 24408 : void EditEngine::SetBackgroundColor( const Color& rColor )
194 : {
195 : DBG_CHKTHIS( EditEngine, 0 );
196 24408 : pImpEditEngine->SetBackgroundColor( rColor );
197 24408 : }
198 :
199 58700 : Color EditEngine::GetBackgroundColor() const
200 : {
201 : DBG_CHKTHIS( EditEngine, 0 );
202 58700 : return pImpEditEngine->GetBackgroundColor();
203 : }
204 :
205 1380 : Color EditEngine::GetAutoColor() const
206 : {
207 : DBG_CHKTHIS( EditEngine, 0 );
208 1380 : return pImpEditEngine->GetAutoColor();
209 : }
210 :
211 2935 : void EditEngine::EnableAutoColor( sal_Bool b )
212 : {
213 : DBG_CHKTHIS( EditEngine, 0 );
214 2935 : pImpEditEngine->EnableAutoColor( b );
215 2935 : }
216 :
217 0 : void EditEngine::ForceAutoColor( sal_Bool b )
218 : {
219 : DBG_CHKTHIS( EditEngine, 0 );
220 0 : pImpEditEngine->ForceAutoColor( b );
221 0 : }
222 :
223 17 : sal_Bool EditEngine::IsForceAutoColor() const
224 : {
225 : DBG_CHKTHIS( EditEngine, 0 );
226 17 : return pImpEditEngine->IsForceAutoColor();
227 : }
228 :
229 10631 : const SfxItemSet& EditEngine::GetEmptyItemSet()
230 : {
231 : DBG_CHKTHIS( EditEngine, 0 );
232 10631 : return pImpEditEngine->GetEmptyItemSet();
233 : }
234 :
235 0 : void EditEngine::Draw( OutputDevice* pOutDev, const Rectangle& rOutRect )
236 : {
237 : DBG_CHKTHIS( EditEngine, 0 );
238 0 : Draw( pOutDev, rOutRect, Point( 0, 0 ) );
239 0 : }
240 :
241 745 : void EditEngine::Draw( OutputDevice* pOutDev, const Point& rStartPos, short nOrientation )
242 : {
243 : DBG_CHKTHIS( EditEngine, 0 );
244 : // Create with 2 points, as with positive points it will end up with
245 : // LONGMAX as Size, Bottom and Right in the range > LONGMAX.
246 745 : Rectangle aBigRect( -0x3FFFFFFF, -0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF );
247 745 : if( pOutDev->GetConnectMetaFile() )
248 0 : pOutDev->Push();
249 745 : Point aStartPos( rStartPos );
250 745 : if ( IsVertical() )
251 : {
252 0 : aStartPos.X() += GetPaperSize().Width();
253 0 : aStartPos = Rotate( aStartPos, nOrientation, rStartPos );
254 : }
255 745 : pImpEditEngine->Paint( pOutDev, aBigRect, aStartPos, sal_False, nOrientation );
256 745 : if( pOutDev->GetConnectMetaFile() )
257 0 : pOutDev->Pop();
258 745 : }
259 :
260 0 : void EditEngine::Draw( OutputDevice* pOutDev, const Rectangle& rOutRect, const Point& rStartDocPos )
261 : {
262 0 : Draw( pOutDev, rOutRect, rStartDocPos, sal_True );
263 0 : }
264 :
265 60 : void EditEngine::Draw( OutputDevice* pOutDev, const Rectangle& rOutRect, const Point& rStartDocPos, sal_Bool bClip )
266 : {
267 : DBG_CHKTHIS( EditEngine, 0 );
268 :
269 : #if defined( DBG_UTIL ) || (OSL_DEBUG_LEVEL > 1)
270 : if ( bDebugPaint )
271 : EditDbg::ShowEditEngineData( this, sal_False );
272 : #endif
273 :
274 : // Align to the pixel boundary, so that it becomes exactly the same
275 : // as Paint ().
276 60 : Rectangle aOutRect( pOutDev->LogicToPixel( rOutRect ) );
277 60 : aOutRect = pOutDev->PixelToLogic( aOutRect );
278 :
279 60 : Point aStartPos;
280 60 : if ( !IsVertical() )
281 : {
282 60 : aStartPos.X() = aOutRect.Left() - rStartDocPos.X();
283 60 : aStartPos.Y() = aOutRect.Top() - rStartDocPos.Y();
284 : }
285 : else
286 : {
287 0 : aStartPos.X() = aOutRect.Right() + rStartDocPos.Y();
288 0 : aStartPos.Y() = aOutRect.Top() - rStartDocPos.X();
289 : }
290 :
291 60 : sal_Bool bClipRegion = pOutDev->IsClipRegion();
292 60 : sal_Bool bMetafile = pOutDev->GetConnectMetaFile() ? sal_True : sal_False;
293 60 : Region aOldRegion = pOutDev->GetClipRegion();
294 :
295 : // If one existed => intersection!
296 : // Use Push/pop for creating the Meta file
297 60 : if ( bMetafile )
298 0 : pOutDev->Push();
299 :
300 : // Always use the Intersect method, it is a must for Metafile!
301 60 : if ( bClip )
302 : {
303 : // Clip only if neccesary...
304 228 : if ( !rStartDocPos.X() && !rStartDocPos.Y() &&
305 171 : ( rOutRect.GetHeight() >= (long)GetTextHeight() ) &&
306 57 : ( rOutRect.GetWidth() >= (long)CalcTextWidth() ) )
307 : {
308 57 : bClip = sal_False;
309 : }
310 : else
311 : {
312 : // Some printer drivers cause problems if characters graze the
313 : // ClipRegion, therefore rather add a pixel more ...
314 0 : Rectangle aClipRect( aOutRect );
315 0 : if ( pOutDev->GetOutDevType() == OUTDEV_PRINTER )
316 : {
317 0 : Size aPixSz( 1, 0 );
318 0 : aPixSz = pOutDev->PixelToLogic( aPixSz );
319 0 : aClipRect.Right() += aPixSz.Width();
320 0 : aClipRect.Bottom() += aPixSz.Width();
321 : }
322 0 : pOutDev->IntersectClipRegion( aClipRect );
323 : }
324 : }
325 :
326 60 : pImpEditEngine->Paint( pOutDev, aOutRect, aStartPos );
327 :
328 60 : if ( bMetafile )
329 0 : pOutDev->Pop();
330 60 : else if ( bClipRegion )
331 60 : pOutDev->SetClipRegion( aOldRegion );
332 : else
333 0 : pOutDev->SetClipRegion();
334 60 : }
335 :
336 257 : void EditEngine::InsertView(EditView* pEditView, size_t nIndex)
337 : {
338 : DBG_CHKTHIS( EditEngine, 0 );
339 : DBG_CHKOBJ( pEditView, EditView, 0 );
340 :
341 257 : if ( nIndex > pImpEditEngine->GetEditViews().size() )
342 257 : nIndex = pImpEditEngine->GetEditViews().size();
343 :
344 257 : ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
345 257 : rViews.insert(rViews.begin()+nIndex, pEditView);
346 :
347 257 : EditSelection aStartSel;
348 257 : aStartSel = pImpEditEngine->GetEditDoc().GetStartPaM();
349 257 : pEditView->pImpEditView->SetEditSelection( aStartSel );
350 257 : if ( !pImpEditEngine->GetActiveView() )
351 253 : pImpEditEngine->SetActiveView( pEditView );
352 :
353 257 : pEditView->pImpEditView->AddDragAndDropListeners();
354 257 : }
355 :
356 45 : EditView* EditEngine::RemoveView( EditView* pView )
357 : {
358 : DBG_CHKTHIS( EditEngine, 0 );
359 : DBG_CHKOBJ( pView, EditView, 0 );
360 :
361 45 : pView->HideCursor();
362 45 : EditView* pRemoved = NULL;
363 45 : ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
364 45 : ImpEditEngine::ViewsType::iterator it = std::find(rViews.begin(), rViews.end(), pView);
365 :
366 : DBG_ASSERT( it != rViews.end(), "RemoveView with invalid index" );
367 45 : if (it != rViews.end())
368 : {
369 45 : pRemoved = *it;
370 45 : rViews.erase(it);
371 45 : if ( pImpEditEngine->GetActiveView() == pView )
372 : {
373 41 : pImpEditEngine->SetActiveView( 0 );
374 41 : pImpEditEngine->GetSelEngine().SetCurView( 0 );
375 : }
376 45 : pView->pImpEditView->RemoveDragAndDropListeners();
377 :
378 : }
379 45 : return pRemoved;
380 : }
381 :
382 0 : EditView* EditEngine::RemoveView(size_t nIndex)
383 : {
384 : DBG_CHKTHIS( EditEngine, 0 );
385 0 : ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
386 0 : if (nIndex >= rViews.size())
387 0 : return NULL;
388 :
389 0 : EditView* pView = rViews[nIndex];
390 0 : if ( pView )
391 0 : return RemoveView( pView );
392 0 : return NULL;
393 : }
394 :
395 116 : EditView* EditEngine::GetView(size_t nIndex) const
396 : {
397 : DBG_CHKTHIS( EditEngine, 0 );
398 116 : return pImpEditEngine->GetEditViews()[nIndex];
399 : }
400 :
401 294 : size_t EditEngine::GetViewCount() const
402 : {
403 : DBG_CHKTHIS( EditEngine, 0 );
404 294 : return pImpEditEngine->GetEditViews().size();
405 : }
406 :
407 901 : sal_Bool EditEngine::HasView( EditView* pView ) const
408 : {
409 901 : ImpEditEngine::ViewsType& rViews = pImpEditEngine->GetEditViews();
410 901 : return std::find(rViews.begin(), rViews.end(), pView) != rViews.end();
411 : }
412 :
413 19 : EditView* EditEngine::GetActiveView() const
414 : {
415 : DBG_CHKTHIS( EditEngine, 0 );
416 19 : return pImpEditEngine->GetActiveView();
417 : }
418 :
419 0 : void EditEngine::SetActiveView(EditView* pView)
420 : {
421 0 : pImpEditEngine->SetActiveView(pView);
422 0 : }
423 :
424 16165 : void EditEngine::SetDefTab( sal_uInt16 nDefTab )
425 : {
426 : DBG_CHKTHIS( EditEngine, 0 );
427 16165 : pImpEditEngine->GetEditDoc().SetDefTab( nDefTab );
428 16165 : if ( pImpEditEngine->IsFormatted() )
429 : {
430 16139 : pImpEditEngine->FormatFullDoc();
431 16139 : pImpEditEngine->UpdateViews( (EditView*) 0 );
432 : }
433 16165 : }
434 :
435 542395 : void EditEngine::SetPaperSize( const Size& rNewSize )
436 : {
437 : DBG_CHKTHIS( EditEngine, 0 );
438 :
439 542395 : Size aOldSize( pImpEditEngine->GetPaperSize() );
440 542395 : pImpEditEngine->SetValidPaperSize( rNewSize );
441 542395 : Size aNewSize( pImpEditEngine->GetPaperSize() );
442 :
443 542395 : sal_Bool bAutoPageSize = pImpEditEngine->GetStatus().AutoPageSize();
444 542395 : if ( bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() ) )
445 : {
446 375412 : for (size_t nView = 0; nView < pImpEditEngine->aEditViews.size(); ++nView)
447 : {
448 212 : EditView* pView = pImpEditEngine->aEditViews[nView];
449 : DBG_CHKOBJ( pView, EditView, 0 );
450 212 : if ( bAutoPageSize )
451 0 : pView->pImpEditView->RecalcOutputArea();
452 212 : else if ( pView->pImpEditView->DoAutoSize() )
453 : {
454 : pView->pImpEditView->ResetOutputArea( Rectangle(
455 0 : pView->pImpEditView->GetOutputArea().TopLeft(), aNewSize ) );
456 : }
457 : }
458 :
459 375200 : if ( bAutoPageSize || pImpEditEngine->IsFormatted() )
460 : {
461 : // Changing the width has no effect for AutoPageSize, as this is
462 : // determined by the text width.
463 : // Optimization first after Vobis delivery was enabled ...
464 56553 : pImpEditEngine->FormatFullDoc();
465 :
466 56553 : pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
467 :
468 56553 : if ( pImpEditEngine->GetUpdateMode() && pImpEditEngine->GetActiveView() )
469 212 : pImpEditEngine->pActiveView->ShowCursor( sal_False, sal_False );
470 : }
471 : }
472 542395 : }
473 :
474 8172 : const Size& EditEngine::GetPaperSize() const
475 : {
476 : DBG_CHKTHIS( EditEngine, 0 );
477 8172 : return pImpEditEngine->GetPaperSize();
478 : }
479 :
480 6224 : void EditEngine::SetVertical( bool bVertical )
481 : {
482 : DBG_CHKTHIS( EditEngine, 0 );
483 6224 : pImpEditEngine->SetVertical( bVertical );
484 6224 : }
485 :
486 250967 : bool EditEngine::IsVertical() const
487 : {
488 : DBG_CHKTHIS( EditEngine, 0 );
489 250967 : return pImpEditEngine->IsVertical();
490 : }
491 :
492 51379 : void EditEngine::SetFixedCellHeight( sal_Bool bUseFixedCellHeight )
493 : {
494 : DBG_CHKTHIS( EditEngine, 0 );
495 51379 : pImpEditEngine->SetFixedCellHeight( bUseFixedCellHeight );
496 51379 : }
497 :
498 26109 : void EditEngine::SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir )
499 : {
500 : DBG_CHKTHIS( EditEngine, 0 );
501 26109 : pImpEditEngine->SetDefaultHorizontalTextDirection( eHTextDir );
502 26109 : }
503 :
504 11732 : EEHorizontalTextDirection EditEngine::GetDefaultHorizontalTextDirection() const
505 : {
506 : DBG_CHKTHIS( EditEngine, 0 );
507 11732 : return pImpEditEngine->GetDefaultHorizontalTextDirection();
508 : }
509 :
510 1397 : sal_uInt16 EditEngine::GetScriptType( const ESelection& rSelection ) const
511 : {
512 : DBG_CHKTHIS( EditEngine, 0 );
513 1397 : EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) );
514 1397 : return pImpEditEngine->GetScriptType( aSel );
515 : }
516 :
517 0 : LanguageType EditEngine::GetLanguage(const EditPaM& rPaM) const
518 : {
519 0 : return pImpEditEngine->GetLanguage(rPaM);
520 : }
521 :
522 8 : LanguageType EditEngine::GetLanguage( sal_Int32 nPara, sal_uInt16 nPos ) const
523 : {
524 : DBG_CHKTHIS( EditEngine, 0 );
525 8 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
526 : DBG_ASSERT( pNode, "GetLanguage - nPara is invalid!" );
527 8 : return pNode ? pImpEditEngine->GetLanguage( EditPaM( pNode, nPos ) ) : LANGUAGE_DONTKNOW;
528 : }
529 :
530 :
531 0 : void EditEngine::TransliterateText( const ESelection& rSelection, sal_Int32 nTransliterationMode )
532 : {
533 : DBG_CHKTHIS( EditView, 0 );
534 0 : pImpEditEngine->TransliterateText( pImpEditEngine->CreateSel( rSelection ), nTransliterationMode );
535 0 : }
536 :
537 0 : EditSelection EditEngine::TransliterateText(const EditSelection& rSelection, sal_Int32 nTransliterationMode)
538 : {
539 0 : return pImpEditEngine->TransliterateText(rSelection, nTransliterationMode);
540 : }
541 :
542 25083 : void EditEngine::SetAsianCompressionMode( sal_uInt16 n )
543 : {
544 : DBG_CHKTHIS( EditView, 0 );
545 25083 : pImpEditEngine->SetAsianCompressionMode( n );
546 25083 : }
547 :
548 25083 : void EditEngine::SetKernAsianPunctuation( sal_Bool b )
549 : {
550 : DBG_CHKTHIS( EditView, 0 );
551 25083 : pImpEditEngine->SetKernAsianPunctuation( b );
552 25083 : }
553 :
554 23960 : void EditEngine::SetAddExtLeading( sal_Bool b )
555 : {
556 : DBG_CHKTHIS( EditEngine, 0 );
557 23960 : pImpEditEngine->SetAddExtLeading( b );
558 23960 : }
559 :
560 0 : void EditEngine::SetPolygon( const basegfx::B2DPolyPolygon& rPolyPolygon )
561 : {
562 : DBG_CHKTHIS( EditEngine, 0 );
563 0 : SetPolygon( rPolyPolygon, 0L );
564 0 : }
565 :
566 0 : void EditEngine::SetPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon)
567 : {
568 : DBG_CHKTHIS( EditEngine, 0 );
569 0 : sal_Bool bSimple(sal_False);
570 :
571 0 : if(pLinePolyPolygon && 1L == rPolyPolygon.count())
572 : {
573 0 : if(rPolyPolygon.getB2DPolygon(0L).isClosed())
574 : {
575 : // open polygon
576 0 : bSimple = sal_True;
577 : }
578 : }
579 :
580 0 : TextRanger* pRanger = new TextRanger( rPolyPolygon, pLinePolyPolygon, 30, 2, 2, bSimple, sal_True );
581 0 : pImpEditEngine->SetTextRanger( pRanger );
582 0 : pImpEditEngine->SetPaperSize( pRanger->GetBoundRect().GetSize() );
583 0 : }
584 :
585 327306 : void EditEngine::ClearPolygon()
586 : {
587 : DBG_CHKTHIS( EditEngine, 0 );
588 327306 : pImpEditEngine->SetTextRanger( 0 );
589 327306 : }
590 :
591 0 : const Size& EditEngine::GetMinAutoPaperSize() const
592 : {
593 : DBG_CHKTHIS( EditEngine, 0 );
594 0 : return pImpEditEngine->GetMinAutoPaperSize();
595 : }
596 :
597 335747 : void EditEngine::SetMinAutoPaperSize( const Size& rSz )
598 : {
599 : DBG_CHKTHIS( EditEngine, 0 );
600 335747 : pImpEditEngine->SetMinAutoPaperSize( rSz );
601 335747 : }
602 :
603 0 : const Size& EditEngine::GetMaxAutoPaperSize() const
604 : {
605 : DBG_CHKTHIS( EditEngine, 0 );
606 0 : return pImpEditEngine->GetMaxAutoPaperSize();
607 : }
608 :
609 341593 : void EditEngine::SetMaxAutoPaperSize( const Size& rSz )
610 : {
611 : DBG_CHKTHIS( EditEngine, 0 );
612 341593 : pImpEditEngine->SetMaxAutoPaperSize( rSz );
613 341593 : }
614 :
615 1509 : OUString EditEngine::GetText( LineEnd eEnd ) const
616 : {
617 : DBG_CHKTHIS( EditEngine, 0 );
618 1509 : return pImpEditEngine->GetEditDoc().GetText( eEnd );
619 : }
620 :
621 441 : XubString EditEngine::GetText( const ESelection& rESelection, const LineEnd eEnd ) const
622 : {
623 : DBG_CHKTHIS( EditEngine, 0 );
624 441 : EditSelection aSel( pImpEditEngine->CreateSel( rESelection ) );
625 441 : return pImpEditEngine->GetSelected( aSel, eEnd );
626 : }
627 :
628 14 : sal_uInt32 EditEngine::GetTextLen() const
629 : {
630 : DBG_CHKTHIS( EditEngine, 0 );
631 14 : return pImpEditEngine->GetEditDoc().GetTextLen();
632 : }
633 :
634 88451 : sal_Int32 EditEngine::GetParagraphCount() const
635 : {
636 : DBG_CHKTHIS( EditEngine, 0 );
637 88451 : return pImpEditEngine->aEditDoc.Count();
638 : }
639 :
640 0 : sal_uInt16 EditEngine::GetLineCount( sal_Int32 nParagraph ) const
641 : {
642 : DBG_CHKTHIS( EditEngine, 0 );
643 0 : if ( !pImpEditEngine->IsFormatted() )
644 0 : pImpEditEngine->FormatDoc();
645 0 : return pImpEditEngine->GetLineCount( nParagraph );
646 : }
647 :
648 0 : sal_uInt16 EditEngine::GetLineLen( sal_Int32 nParagraph, sal_uInt16 nLine ) const
649 : {
650 : DBG_CHKTHIS( EditEngine, 0 );
651 0 : if ( !pImpEditEngine->IsFormatted() )
652 0 : pImpEditEngine->FormatDoc();
653 0 : return pImpEditEngine->GetLineLen( nParagraph, nLine );
654 : }
655 :
656 0 : void EditEngine::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_Int32 nParagraph, sal_uInt16 nLine ) const
657 : {
658 : DBG_CHKTHIS( EditEngine, 0 );
659 0 : if ( !pImpEditEngine->IsFormatted() )
660 0 : pImpEditEngine->FormatDoc();
661 0 : return pImpEditEngine->GetLineBoundaries( rStart, rEnd, nParagraph, nLine );
662 : }
663 :
664 0 : sal_uInt16 EditEngine::GetLineNumberAtIndex( sal_Int32 nPara, sal_uInt16 nIndex ) const
665 : {
666 : DBG_CHKTHIS( EditEngine, 0 );
667 0 : if ( !pImpEditEngine->IsFormatted() )
668 0 : pImpEditEngine->FormatDoc();
669 0 : return pImpEditEngine->GetLineNumberAtIndex( nPara, nIndex );
670 : }
671 :
672 0 : sal_uInt32 EditEngine::GetLineHeight( sal_Int32 nParagraph, sal_uInt16 nLine )
673 : {
674 : DBG_CHKTHIS( EditEngine, 0 );
675 : // If someone calls GetLineHeight() with an empty Engine.
676 0 : if ( !pImpEditEngine->IsFormatted() )
677 0 : pImpEditEngine->FormatDoc();
678 0 : return pImpEditEngine->GetLineHeight( nParagraph, nLine );
679 : }
680 :
681 121 : sal_uInt32 EditEngine::GetTextHeight( sal_Int32 nParagraph ) const
682 : {
683 : DBG_CHKTHIS( EditEngine, 0 );
684 :
685 121 : if ( !pImpEditEngine->IsFormatted() )
686 0 : pImpEditEngine->FormatDoc();
687 :
688 121 : sal_uInt32 nHeight = pImpEditEngine->GetParaHeight( nParagraph );
689 121 : return nHeight;
690 : }
691 :
692 0 : XubString EditEngine::GetWord( sal_Int32 nPara, sal_uInt16 nIndex )
693 : {
694 0 : ESelection aESel( nPara, nIndex, nPara, nIndex );
695 0 : EditSelection aSel( pImpEditEngine->CreateSel( aESel ) );
696 0 : aSel = pImpEditEngine->SelectWord( aSel );
697 0 : return pImpEditEngine->GetSelected( aSel );
698 : }
699 :
700 0 : ESelection EditEngine::GetWord( const ESelection& rSelection, sal_uInt16 nWordType ) const
701 : {
702 : // ImpEditEngine-Iteration-Methods should be const!
703 0 : EditEngine* pE = (EditEngine*)this;
704 :
705 0 : EditSelection aSel( pE->pImpEditEngine->CreateSel( rSelection ) );
706 0 : aSel = pE->pImpEditEngine->SelectWord( aSel, nWordType );
707 0 : return pE->pImpEditEngine->CreateESel( aSel );
708 : }
709 :
710 50 : void EditEngine::CursorMoved(ContentNode* pPrevNode)
711 : {
712 50 : pImpEditEngine->CursorMoved(pPrevNode);
713 50 : }
714 :
715 1101 : void EditEngine::CheckIdleFormatter()
716 : {
717 1101 : pImpEditEngine->CheckIdleFormatter();
718 1101 : }
719 :
720 0 : bool EditEngine::IsIdleFormatterActive() const
721 : {
722 0 : return pImpEditEngine->aIdleFormatter.IsActive();
723 : }
724 :
725 102 : ParaPortion* EditEngine::FindParaPortion(ContentNode* pNode)
726 : {
727 102 : return pImpEditEngine->FindParaPortion(pNode);
728 : }
729 :
730 0 : const ParaPortion* EditEngine::FindParaPortion(ContentNode* pNode) const
731 : {
732 0 : return pImpEditEngine->FindParaPortion(pNode);
733 : }
734 :
735 0 : const ParaPortion* EditEngine::GetPrevVisPortion(const ParaPortion* pCurPortion) const
736 : {
737 0 : return pImpEditEngine->GetPrevVisPortion(pCurPortion);
738 : }
739 :
740 0 : sal_uInt16 EditEngine::GetScriptType(const EditSelection& rSel) const
741 : {
742 0 : return pImpEditEngine->GetScriptType(rSel);
743 : }
744 :
745 0 : void EditEngine::RemoveParaPortion(sal_Int32 nNode)
746 : {
747 0 : pImpEditEngine->GetParaPortions().Remove(nNode);
748 0 : }
749 :
750 0 : void EditEngine::SetCallParaInsertedOrDeleted(bool b)
751 : {
752 0 : pImpEditEngine->SetCallParaInsertedOrDeleted(b);
753 0 : }
754 :
755 0 : bool EditEngine::IsCallParaInsertedOrDeleted() const
756 : {
757 0 : return pImpEditEngine->IsCallParaInsertedOrDeleted();
758 : }
759 :
760 0 : void EditEngine::AppendDeletedNodeInfo(DeletedNodeInfo* pInfo)
761 : {
762 0 : pImpEditEngine->aDeletedNodes.push_back(pInfo);
763 0 : }
764 :
765 0 : void EditEngine::UpdateSelections()
766 : {
767 0 : pImpEditEngine->UpdateSelections();
768 0 : }
769 :
770 0 : void EditEngine::InsertContent(ContentNode* pNode, sal_Int32 nPos)
771 : {
772 0 : pImpEditEngine->InsertContent(pNode, nPos);
773 0 : }
774 :
775 0 : EditPaM EditEngine::SplitContent(sal_Int32 nNode, sal_uInt16 nSepPos)
776 : {
777 0 : return pImpEditEngine->SplitContent(nNode, nSepPos);
778 : }
779 :
780 0 : EditPaM EditEngine::ConnectContents(sal_Int32 nLeftNode, bool bBackward)
781 : {
782 0 : return pImpEditEngine->ConnectContents(nLeftNode, bBackward);
783 : }
784 :
785 0 : EditPaM EditEngine::InsertFeature(const EditSelection& rEditSelection, const SfxPoolItem& rItem)
786 : {
787 0 : return pImpEditEngine->ImpInsertFeature(rEditSelection, rItem);
788 : }
789 :
790 0 : EditSelection EditEngine::MoveParagraphs(const Range& rParagraphs, sal_Int32 nNewPos, EditView* pCurView)
791 : {
792 0 : return pImpEditEngine->MoveParagraphs(rParagraphs, nNewPos, pCurView);
793 : }
794 :
795 0 : void EditEngine::RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich, bool bRemoveFeatures)
796 : {
797 0 : pImpEditEngine->RemoveCharAttribs(nPara, nWhich, bRemoveFeatures);
798 0 : }
799 :
800 0 : void EditEngine::RemoveCharAttribs(const EditSelection& rSel, bool bRemoveParaAttribs, sal_uInt16 nWhich)
801 : {
802 0 : pImpEditEngine->RemoveCharAttribs(rSel, bRemoveParaAttribs, nWhich);
803 0 : }
804 :
805 0 : EditEngine::ViewsType& EditEngine::GetEditViews()
806 : {
807 0 : return pImpEditEngine->GetEditViews();
808 : }
809 :
810 0 : const EditEngine::ViewsType& EditEngine::GetEditViews() const
811 : {
812 0 : return pImpEditEngine->GetEditViews();
813 : }
814 :
815 6 : void EditEngine::SetUndoMode(bool b)
816 : {
817 6 : pImpEditEngine->SetUndoMode(b);
818 6 : }
819 :
820 32 : void EditEngine::FormatAndUpdate(EditView* pCurView)
821 : {
822 32 : pImpEditEngine->FormatAndUpdate(pCurView);
823 32 : }
824 :
825 0 : bool EditEngine::Undo(EditView* pView)
826 : {
827 0 : return pImpEditEngine->Undo(pView);
828 : }
829 :
830 0 : bool EditEngine::Redo(EditView* pView)
831 : {
832 0 : return pImpEditEngine->Redo(pView);
833 : }
834 :
835 0 : uno::Reference<datatransfer::XTransferable> EditEngine::CreateTransferable(const EditSelection& rSelection)
836 : {
837 0 : return pImpEditEngine->CreateTransferable(rSelection);
838 : }
839 :
840 0 : void EditEngine::ParaAttribsToCharAttribs(ContentNode* pNode)
841 : {
842 0 : pImpEditEngine->ParaAttribsToCharAttribs(pNode);
843 0 : }
844 :
845 4 : EditPaM EditEngine::CreateEditPaM(const EPaM& rEPaM)
846 : {
847 4 : return pImpEditEngine->CreateEditPaM(rEPaM);
848 : }
849 :
850 0 : EditPaM EditEngine::ConnectParagraphs(
851 : ContentNode* pLeft, ContentNode* pRight, bool bBackward)
852 : {
853 0 : return pImpEditEngine->ImpConnectParagraphs(pLeft, pRight, bBackward);
854 : }
855 :
856 0 : EditPaM EditEngine::InsertField(const EditSelection& rEditSelection, const SvxFieldItem& rFld)
857 : {
858 0 : return pImpEditEngine->InsertField(rEditSelection, rFld);
859 : }
860 :
861 22 : EditPaM EditEngine::InsertText(const EditSelection& aCurEditSelection, const String& rStr)
862 : {
863 22 : return pImpEditEngine->InsertText(aCurEditSelection, rStr);
864 : }
865 :
866 0 : EditSelection EditEngine::InsertText(const EditTextObject& rTextObject, const EditSelection& rSel)
867 : {
868 0 : return pImpEditEngine->InsertText(rTextObject, rSel);
869 : }
870 :
871 0 : EditSelection EditEngine::InsertText(
872 : uno::Reference<datatransfer::XTransferable >& rxDataObj,
873 : const String& rBaseURL, const EditPaM& rPaM, bool bUseSpecial)
874 : {
875 0 : return pImpEditEngine->InsertText(rxDataObj, rBaseURL, rPaM, bUseSpecial);
876 : }
877 :
878 0 : EditPaM EditEngine::EndOfWord(const EditPaM& rPaM, sal_Int16 nWordType)
879 : {
880 0 : return pImpEditEngine->EndOfWord(rPaM, nWordType);
881 : }
882 :
883 0 : EditPaM EditEngine::GetPaM(const Point& aDocPos, bool bSmart)
884 : {
885 0 : return pImpEditEngine->GetPaM(aDocPos, bSmart);
886 : }
887 :
888 0 : EditSelection EditEngine::SelectWord(
889 : const EditSelection& rCurSelection, sal_Int16 nWordType, bool bAcceptStartOfWord)
890 : {
891 0 : return pImpEditEngine->SelectWord(rCurSelection, nWordType, bAcceptStartOfWord);
892 : }
893 :
894 16 : long EditEngine::GetXPos(
895 : const ParaPortion* pParaPortion, const EditLine* pLine, sal_uInt16 nIndex, bool bPreferPortionStart) const
896 : {
897 16 : return pImpEditEngine->GetXPos(pParaPortion, pLine, nIndex, bPreferPortionStart);
898 : }
899 :
900 0 : Range EditEngine::GetLineXPosStartEnd(
901 : const ParaPortion* pParaPortion, const EditLine* pLine) const
902 : {
903 0 : return pImpEditEngine->GetLineXPosStartEnd(pParaPortion, pLine);
904 : }
905 :
906 1050 : bool EditEngine::IsFormatted() const
907 : {
908 1050 : return pImpEditEngine->IsFormatted();
909 : }
910 :
911 0 : EditPaM EditEngine::CursorLeft(const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode)
912 : {
913 0 : return pImpEditEngine->CursorLeft(rPaM, nCharacterIteratorMode);
914 : }
915 :
916 0 : EditPaM EditEngine::CursorRight(const EditPaM& rPaM, sal_uInt16 nCharacterIteratorMode)
917 : {
918 0 : return pImpEditEngine->CursorRight(rPaM, nCharacterIteratorMode);
919 : }
920 :
921 8 : sal_uInt16 EditEngine::GetOnePixelInRef() const
922 : {
923 8 : return pImpEditEngine->nOnePixelInRef;
924 : }
925 :
926 8 : InternalEditStatus& EditEngine::GetInternalEditStatus()
927 : {
928 8 : return pImpEditEngine->GetStatus();
929 : }
930 :
931 1572 : EditDoc& EditEngine::GetEditDoc()
932 : {
933 1572 : return pImpEditEngine->GetEditDoc();
934 : }
935 :
936 0 : const EditDoc& EditEngine::GetEditDoc() const
937 : {
938 0 : return pImpEditEngine->GetEditDoc();
939 : }
940 :
941 910 : ParaPortionList& EditEngine::GetParaPortions()
942 : {
943 910 : return pImpEditEngine->GetParaPortions();
944 : }
945 :
946 0 : const ParaPortionList& EditEngine::GetParaPortions() const
947 : {
948 0 : return pImpEditEngine->GetParaPortions();
949 : }
950 :
951 894 : void EditEngine::SeekCursor(
952 : ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut, sal_uInt16 nIgnoreWhich)
953 : {
954 894 : pImpEditEngine->SeekCursor(pNode, nPos, rFont, pOut, nIgnoreWhich);
955 894 : }
956 :
957 2 : EditPaM EditEngine::DeleteSelection(const EditSelection& rSel)
958 : {
959 2 : return pImpEditEngine->ImpDeleteSelection(rSel);
960 : }
961 :
962 55 : ESelection EditEngine::CreateESelection(const EditSelection& rSel)
963 : {
964 55 : return pImpEditEngine->CreateESel(rSel);
965 : }
966 :
967 0 : EditSelection EditEngine::CreateSelection(const ESelection& rSel)
968 : {
969 0 : return pImpEditEngine->CreateSel(rSel);
970 : }
971 :
972 0 : const SfxItemSet& EditEngine::GetBaseParaAttribs(sal_Int32 nPara) const
973 : {
974 0 : return pImpEditEngine->GetParaAttribs(nPara);
975 : }
976 :
977 1 : void EditEngine::SetParaAttribsOnly(sal_Int32 nPara, const SfxItemSet& rSet)
978 : {
979 1 : pImpEditEngine->SetParaAttribs(nPara, rSet);
980 1 : }
981 :
982 22 : void EditEngine::SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, sal_uInt8 nSpecial)
983 : {
984 22 : pImpEditEngine->SetAttribs(rSel, rSet, nSpecial);
985 22 : }
986 :
987 0 : String EditEngine::GetSelected(const EditSelection& rSel, const LineEnd eParaSep) const
988 : {
989 0 : return pImpEditEngine->GetSelected(rSel, eParaSep);
990 : }
991 :
992 0 : EditPaM EditEngine::DeleteSelected(const EditSelection& rSel)
993 : {
994 0 : return pImpEditEngine->DeleteSelected(rSel);
995 : }
996 :
997 0 : void EditEngine::HandleBeginPasteOrDrop(PasteOrDropInfos& rInfos)
998 : {
999 0 : pImpEditEngine->aBeginPasteOrDropHdl.Call(&rInfos);
1000 0 : }
1001 :
1002 0 : void EditEngine::HandleEndPasteOrDrop(PasteOrDropInfos& rInfos)
1003 : {
1004 0 : pImpEditEngine->aEndPasteOrDropHdl.Call(&rInfos);
1005 0 : }
1006 :
1007 0 : bool EditEngine::HasText() const
1008 : {
1009 0 : return pImpEditEngine->ImplHasText();
1010 : }
1011 :
1012 0 : const EditSelectionEngine& EditEngine::GetSelectionEngine() const
1013 : {
1014 0 : return pImpEditEngine->aSelEngine;
1015 : }
1016 :
1017 0 : void EditEngine::SetInSelectionMode(bool b)
1018 : {
1019 0 : pImpEditEngine->bInSelection = b;
1020 0 : }
1021 :
1022 0 : sal_Bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, EditView* pEditView, Window* pFrameWin )
1023 : {
1024 : DBG_CHKTHIS( EditEngine, 0 );
1025 : DBG_CHKOBJ( pEditView, EditView, 0 );
1026 : DBG_ASSERT( pEditView, "no View - no cookie !" );
1027 :
1028 0 : sal_Bool bDone = sal_True;
1029 :
1030 0 : sal_Bool bModified = sal_False;
1031 0 : sal_Bool bMoved = sal_False;
1032 0 : sal_Bool bAllowIdle = sal_True;
1033 0 : sal_Bool bReadOnly = pEditView->IsReadOnly();
1034 :
1035 0 : sal_uInt16 nNewCursorFlags = 0;
1036 0 : sal_Bool bSetCursorFlags = sal_True;
1037 :
1038 0 : EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() );
1039 : DBG_ASSERT( !aCurSel.IsInvalid(), "Blinde Selection in EditEngine::PostKeyEvent" );
1040 :
1041 0 : String aAutoText( pImpEditEngine->GetAutoCompleteText() );
1042 0 : if ( pImpEditEngine->GetAutoCompleteText().Len() )
1043 0 : pImpEditEngine->SetAutoCompleteText( String(), sal_True );
1044 :
1045 0 : sal_uInt16 nCode = rKeyEvent.GetKeyCode().GetCode();
1046 0 : KeyFuncType eFunc = rKeyEvent.GetKeyCode().GetFunction();
1047 0 : if ( eFunc != KEYFUNC_DONTKNOW )
1048 : {
1049 0 : switch ( eFunc )
1050 : {
1051 : case KEYFUNC_UNDO:
1052 : {
1053 0 : if ( !bReadOnly )
1054 0 : pEditView->Undo();
1055 0 : return sal_True;
1056 : }
1057 : // break;
1058 : case KEYFUNC_REDO:
1059 : {
1060 0 : if ( !bReadOnly )
1061 0 : pEditView->Redo();
1062 0 : return sal_True;
1063 : }
1064 : // break;
1065 :
1066 : default: // is then possible edited below.
1067 0 : eFunc = KEYFUNC_DONTKNOW;
1068 : }
1069 : }
1070 :
1071 0 : pImpEditEngine->EnterBlockNotifications();
1072 :
1073 0 : if ( GetNotifyHdl().IsSet() )
1074 : {
1075 0 : EENotify aNotify( EE_NOTIFY_INPUT_START );
1076 0 : aNotify.pEditEngine = this;
1077 0 : pImpEditEngine->CallNotify( aNotify );
1078 : }
1079 :
1080 0 : if ( eFunc == KEYFUNC_DONTKNOW )
1081 : {
1082 0 : switch ( nCode )
1083 : {
1084 : #if defined( DBG_UTIL ) || (OSL_DEBUG_LEVEL > 1)
1085 : case KEY_F1:
1086 : {
1087 : if ( rKeyEvent.GetKeyCode().IsMod1() && rKeyEvent.GetKeyCode().IsMod2() )
1088 : {
1089 : sal_Int32 nParas = GetParagraphCount();
1090 : Point aPos;
1091 : Point aViewStart( pEditView->GetOutputArea().TopLeft() );
1092 : long n20 = 40 * pImpEditEngine->nOnePixelInRef;
1093 : for ( sal_Int32 n = 0; n < nParas; n++ )
1094 : {
1095 : long nH = GetTextHeight( n );
1096 : Point P1( aViewStart.X() + n20 + n20*(n%2), aViewStart.Y() + aPos.Y() );
1097 : Point P2( P1 );
1098 : P2.X() += n20;
1099 : P2.Y() += nH;
1100 : pEditView->GetWindow()->SetLineColor();
1101 : pEditView->GetWindow()->SetFillColor( Color( (n%2) ? COL_YELLOW : COL_LIGHTGREEN ) );
1102 : pEditView->GetWindow()->DrawRect( Rectangle( P1, P2 ) );
1103 : aPos.Y() += nH;
1104 : }
1105 : }
1106 : bDone = sal_False;
1107 : }
1108 : break;
1109 : case KEY_F11:
1110 : {
1111 : if ( rKeyEvent.GetKeyCode().IsMod1() && rKeyEvent.GetKeyCode().IsMod2() )
1112 : {
1113 : bDebugPaint = !bDebugPaint;
1114 : OStringBuffer aInfo(RTL_CONSTASCII_STRINGPARAM(
1115 : "DebugPaint: "));
1116 : aInfo.append(bDebugPaint ? "On" : "Off");
1117 : InfoBox(NULL, OStringToOUString(aInfo.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US)).Execute();
1118 : }
1119 : bDone = sal_False;
1120 : }
1121 : break;
1122 : case KEY_F12:
1123 : {
1124 : if ( rKeyEvent.GetKeyCode().IsMod1() && rKeyEvent.GetKeyCode().IsMod2() )
1125 : {
1126 : EditDbg::ShowEditEngineData( this );
1127 : }
1128 : bDone = sal_False;
1129 : }
1130 : break;
1131 : #endif
1132 : case KEY_UP:
1133 : case KEY_DOWN:
1134 : case KEY_LEFT:
1135 : case KEY_RIGHT:
1136 : case KEY_HOME:
1137 : case KEY_END:
1138 : case KEY_PAGEUP:
1139 : case KEY_PAGEDOWN:
1140 : case com::sun::star::awt::Key::MOVE_WORD_FORWARD:
1141 : case com::sun::star::awt::Key::SELECT_WORD_FORWARD:
1142 : case com::sun::star::awt::Key::MOVE_WORD_BACKWARD:
1143 : case com::sun::star::awt::Key::SELECT_WORD_BACKWARD:
1144 : case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE:
1145 : case com::sun::star::awt::Key::MOVE_TO_END_OF_LINE:
1146 : case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE:
1147 : case com::sun::star::awt::Key::SELECT_TO_END_OF_LINE:
1148 : case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
1149 : case com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
1150 : case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
1151 : case com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
1152 : case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
1153 : case com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT:
1154 : case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
1155 : case com::sun::star::awt::Key::SELECT_TO_END_OF_DOCUMENT:
1156 : {
1157 0 : if ( !rKeyEvent.GetKeyCode().IsMod2() || ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) )
1158 : {
1159 0 : if ( pImpEditEngine->DoVisualCursorTraveling( aCurSel.Max().GetNode() ) && ( ( nCode == KEY_LEFT ) || ( nCode == KEY_RIGHT ) /* || ( nCode == KEY_HOME ) || ( nCode == KEY_END ) */ ) )
1160 0 : bSetCursorFlags = sal_False; // Will be manipulated within visual cursor move
1161 :
1162 0 : aCurSel = pImpEditEngine->MoveCursor( rKeyEvent, pEditView );
1163 :
1164 0 : if ( aCurSel.HasRange() ) {
1165 0 : Reference<com::sun::star::datatransfer::clipboard::XClipboard> aSelection(pEditView->GetWindow()->GetPrimarySelection());
1166 0 : pEditView->pImpEditView->CutCopy( aSelection, sal_False );
1167 : }
1168 :
1169 0 : bMoved = sal_True;
1170 0 : if ( nCode == KEY_HOME )
1171 0 : nNewCursorFlags |= GETCRSR_STARTOFLINE;
1172 0 : else if ( nCode == KEY_END )
1173 0 : nNewCursorFlags |= GETCRSR_ENDOFLINE;
1174 :
1175 : }
1176 : #if OSL_DEBUG_LEVEL > 1
1177 : GetLanguage( pImpEditEngine->GetEditDoc().GetPos( aCurSel.Max().GetNode() ), aCurSel.Max().GetIndex() );
1178 : #endif
1179 : }
1180 0 : break;
1181 : case KEY_BACKSPACE:
1182 : case KEY_DELETE:
1183 : case com::sun::star::awt::Key::DELETE_WORD_BACKWARD:
1184 : case com::sun::star::awt::Key::DELETE_WORD_FORWARD:
1185 : case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_PARAGRAPH:
1186 : case com::sun::star::awt::Key::DELETE_TO_END_OF_PARAGRAPH:
1187 : {
1188 0 : if ( !bReadOnly && !rKeyEvent.GetKeyCode().IsMod2() )
1189 : {
1190 : // check if we are behind a bullet and using the backspace key
1191 0 : ContentNode *pNode = aCurSel.Min().GetNode();
1192 0 : const SvxNumberFormat *pFmt = pImpEditEngine->GetNumberFormat( pNode );
1193 0 : if (pFmt && nCode == KEY_BACKSPACE &&
1194 0 : !aCurSel.HasRange() && aCurSel.Min().GetIndex() == 0)
1195 : {
1196 : // if the bullet is still visible just do not paint it from
1197 : // now on and that will be all. Otherwise continue as usual.
1198 : // ...
1199 :
1200 0 : sal_Int32 nPara = pImpEditEngine->GetEditDoc().GetPos( pNode );
1201 0 : SfxBoolItem aBulletState( (const SfxBoolItem&) pImpEditEngine->GetParaAttrib( nPara, EE_PARA_BULLETSTATE ) );
1202 0 : bool bBulletIsVisible = aBulletState.GetValue() ? true : false;
1203 :
1204 : // just toggling EE_PARA_BULLETSTATE should be fine for both cases...
1205 0 : aBulletState.SetValue( !bBulletIsVisible );
1206 0 : SfxItemSet aSet( pImpEditEngine->GetParaAttribs( nPara ) );
1207 0 : aSet.Put( aBulletState );
1208 0 : pImpEditEngine->SetParaAttribs( nPara, aSet );
1209 :
1210 : // have this and the following paragraphs formatted and repainted.
1211 : // (not painting a numbering in the list may cause the following
1212 : // numberings to have different numbers than before and thus the
1213 : // length may have changed as well )
1214 0 : pImpEditEngine->FormatAndUpdate( pImpEditEngine->GetActiveView() );
1215 :
1216 0 : if (bBulletIsVisible) // bullet just turned invisible...
1217 0 : break;
1218 : }
1219 :
1220 0 : sal_uInt8 nDel = 0, nMode = 0;
1221 0 : switch( nCode )
1222 : {
1223 : case com::sun::star::awt::Key::DELETE_WORD_BACKWARD:
1224 0 : nMode = DELMODE_RESTOFWORD;
1225 0 : nDel = DEL_LEFT;
1226 0 : break;
1227 : case com::sun::star::awt::Key::DELETE_WORD_FORWARD:
1228 0 : nMode = DELMODE_RESTOFWORD;
1229 0 : nDel = DEL_RIGHT;
1230 0 : break;
1231 : case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_PARAGRAPH:
1232 0 : nMode = DELMODE_RESTOFCONTENT;
1233 0 : nDel = DEL_LEFT;
1234 0 : break;
1235 : case com::sun::star::awt::Key::DELETE_TO_END_OF_PARAGRAPH:
1236 0 : nMode = DELMODE_RESTOFCONTENT;
1237 0 : nDel = DEL_RIGHT;
1238 0 : break;
1239 : default:
1240 0 : nDel = ( nCode == KEY_DELETE ) ? DEL_RIGHT : DEL_LEFT;
1241 0 : nMode = rKeyEvent.GetKeyCode().IsMod1() ? DELMODE_RESTOFWORD : DELMODE_SIMPLE;
1242 0 : if ( ( nMode == DELMODE_RESTOFWORD ) && rKeyEvent.GetKeyCode().IsShift() )
1243 0 : nMode = DELMODE_RESTOFCONTENT;
1244 0 : break;
1245 : }
1246 :
1247 0 : pEditView->pImpEditView->DrawSelection();
1248 0 : pImpEditEngine->UndoActionStart( EDITUNDO_DELETE );
1249 0 : aCurSel = pImpEditEngine->DeleteLeftOrRight( aCurSel, nDel, nMode );
1250 0 : pImpEditEngine->UndoActionEnd( EDITUNDO_DELETE );
1251 0 : bModified = sal_True;
1252 0 : bAllowIdle = sal_False;
1253 : }
1254 : }
1255 0 : break;
1256 : case KEY_TAB:
1257 : {
1258 0 : if ( !bReadOnly && !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
1259 : {
1260 0 : sal_Bool bShift = rKeyEvent.GetKeyCode().IsShift();
1261 0 : if ( pImpEditEngine->GetStatus().DoTabIndenting() &&
1262 0 : ( aCurSel.Min().GetNode() != aCurSel.Max().GetNode() ) )
1263 : {
1264 0 : pImpEditEngine->IndentBlock( pEditView, !bShift );
1265 : }
1266 0 : else if ( !bShift )
1267 : {
1268 0 : sal_Bool bSel = pEditView->HasSelection();
1269 0 : if ( bSel )
1270 0 : pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
1271 0 : if ( pImpEditEngine->GetStatus().DoAutoCorrect() )
1272 0 : aCurSel = pImpEditEngine->AutoCorrect( aCurSel, 0, !pEditView->IsInsertMode(), pFrameWin );
1273 0 : aCurSel = pImpEditEngine->InsertTab( aCurSel );
1274 0 : if ( bSel )
1275 0 : pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
1276 0 : bModified = sal_True;
1277 : }
1278 : }
1279 : else
1280 0 : bDone = sal_False;
1281 : }
1282 0 : break;
1283 : case KEY_RETURN:
1284 : {
1285 0 : if ( !bReadOnly )
1286 : {
1287 0 : pEditView->pImpEditView->DrawSelection();
1288 0 : if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
1289 : {
1290 0 : pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
1291 0 : if ( rKeyEvent.GetKeyCode().IsShift() )
1292 : {
1293 0 : aCurSel = pImpEditEngine->AutoCorrect( aCurSel, 0, !pEditView->IsInsertMode(), pFrameWin );
1294 0 : aCurSel = pImpEditEngine->InsertLineBreak( aCurSel );
1295 : }
1296 : else
1297 : {
1298 0 : if ( !aAutoText.Len() )
1299 : {
1300 0 : if ( pImpEditEngine->GetStatus().DoAutoCorrect() )
1301 0 : aCurSel = pImpEditEngine->AutoCorrect( aCurSel, 0, !pEditView->IsInsertMode(), pFrameWin );
1302 0 : aCurSel = pImpEditEngine->InsertParaBreak( aCurSel );
1303 : }
1304 : else
1305 : {
1306 : DBG_ASSERT( !aCurSel.HasRange(), "Selektion bei Complete?!" );
1307 0 : EditPaM aStart( pImpEditEngine->WordLeft( aCurSel.Max() ) );
1308 0 : aCurSel = pImpEditEngine->InsertText(
1309 0 : EditSelection( aStart, aCurSel.Max() ), aAutoText );
1310 0 : pImpEditEngine->SetAutoCompleteText( String(), sal_True );
1311 : }
1312 : }
1313 0 : pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
1314 0 : bModified = sal_True;
1315 : }
1316 : }
1317 : }
1318 0 : break;
1319 : case KEY_INSERT:
1320 : {
1321 0 : if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
1322 0 : pEditView->SetInsertMode( !pEditView->IsInsertMode() );
1323 : }
1324 0 : break;
1325 : default:
1326 : {
1327 : #if (OSL_DEBUG_LEVEL > 1) && defined(DBG_UTIL)
1328 : if ( ( nCode == KEY_W ) && rKeyEvent.GetKeyCode().IsMod1() && rKeyEvent.GetKeyCode().IsMod2() )
1329 : {
1330 : SfxItemSet aAttribs = pEditView->GetAttribs();
1331 : const SvxFrameDirectionItem& rCurrentWritingMode = (const SvxFrameDirectionItem&)aAttribs.Get( EE_PARA_WRITINGDIR );
1332 : SvxFrameDirectionItem aNewItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR );
1333 : if ( rCurrentWritingMode.GetValue() != FRMDIR_HORI_RIGHT_TOP )
1334 : aNewItem.SetValue( FRMDIR_HORI_RIGHT_TOP );
1335 : aAttribs.Put( aNewItem );
1336 : pEditView->SetAttribs( aAttribs );
1337 : }
1338 : #endif
1339 0 : if ( !bReadOnly && IsSimpleCharInput( rKeyEvent ) )
1340 : {
1341 0 : sal_Unicode nCharCode = rKeyEvent.GetCharCode();
1342 0 : pEditView->pImpEditView->DrawSelection();
1343 : // Autocorrection?
1344 0 : SvxAutoCorrect* pAutoCorrect = SvxAutoCorrCfg::Get().GetAutoCorrect();
1345 0 : if ( ( pImpEditEngine->GetStatus().DoAutoCorrect() ) &&
1346 0 : ( SvxAutoCorrect::IsAutoCorrectChar( nCharCode ) ||
1347 0 : pAutoCorrect->HasRunNext() ) )
1348 : {
1349 0 : aCurSel = pImpEditEngine->AutoCorrect(
1350 0 : aCurSel, nCharCode, !pEditView->IsInsertMode(), pFrameWin );
1351 : }
1352 : else
1353 : {
1354 0 : aCurSel = pImpEditEngine->InsertText( (const EditSelection&)aCurSel, nCharCode, !pEditView->IsInsertMode(), sal_True );
1355 : }
1356 : // AutoComplete ???
1357 0 : if ( pImpEditEngine->GetStatus().DoAutoComplete() && ( nCharCode != ' ' ) )
1358 : {
1359 : // Only at end of word...
1360 0 : sal_uInt16 nIndex = aCurSel.Max().GetIndex();
1361 0 : if ( ( nIndex >= aCurSel.Max().GetNode()->Len() ) ||
1362 0 : ( pImpEditEngine->aWordDelimiters.Search( aCurSel.Max().GetNode()->GetChar( nIndex ) ) != STRING_NOTFOUND ) )
1363 : {
1364 0 : EditPaM aStart( pImpEditEngine->WordLeft( aCurSel.Max() ) );
1365 0 : String aWord = pImpEditEngine->GetSelected( EditSelection( aStart, aCurSel.Max() ) );
1366 0 : if ( aWord.Len() >= 3 )
1367 : {
1368 0 : String aComplete;
1369 :
1370 0 : LanguageType eLang = pImpEditEngine->GetLanguage( EditPaM( aStart.GetNode(), aStart.GetIndex()+1));
1371 0 : LanguageTag aLanguageTag( eLang);
1372 :
1373 0 : if (!pImpEditEngine->xLocaleDataWrapper.isInitialized())
1374 0 : pImpEditEngine->xLocaleDataWrapper.init( SvtSysLocale().GetLocaleData().getComponentContext(), aLanguageTag);
1375 : else
1376 0 : pImpEditEngine->xLocaleDataWrapper.changeLocale( aLanguageTag);
1377 :
1378 0 : if (!pImpEditEngine->xTransliterationWrapper.isInitialized())
1379 0 : pImpEditEngine->xTransliterationWrapper.init( SvtSysLocale().GetLocaleData().getComponentContext(), eLang, i18n::TransliterationModules_IGNORE_CASE);
1380 : else
1381 0 : pImpEditEngine->xTransliterationWrapper.changeLocale( eLang);
1382 :
1383 0 : const ::utl::TransliterationWrapper* pTransliteration = pImpEditEngine->xTransliterationWrapper.get();
1384 0 : Sequence< i18n::CalendarItem2 > xItem = pImpEditEngine->xLocaleDataWrapper->getDefaultCalendarDays();
1385 0 : sal_Int32 nCount = xItem.getLength();
1386 0 : const i18n::CalendarItem2* pArr = xItem.getArray();
1387 0 : for( sal_Int32 n = 0; n <= nCount; ++n )
1388 : {
1389 0 : const OUString& rDay = pArr[n].FullName;
1390 0 : if( pTransliteration->isMatch( aWord, rDay) )
1391 : {
1392 0 : aComplete = rDay;
1393 0 : break;
1394 : }
1395 : }
1396 :
1397 0 : if ( !aComplete.Len() )
1398 : {
1399 0 : xItem = pImpEditEngine->xLocaleDataWrapper->getDefaultCalendarMonths();
1400 0 : sal_Int32 nMonthCount = xItem.getLength();
1401 0 : const i18n::CalendarItem2* pMonthArr = xItem.getArray();
1402 0 : for( sal_Int32 n = 0; n <= nMonthCount; ++n )
1403 : {
1404 0 : const OUString& rMon = pMonthArr[n].FullName;
1405 0 : if( pTransliteration->isMatch( aWord, rMon) )
1406 : {
1407 0 : aComplete = rMon;
1408 0 : break;
1409 : }
1410 : }
1411 : }
1412 :
1413 0 : if( aComplete.Len() && ( ( aWord.Len() + 1 ) < aComplete.Len() ) )
1414 : {
1415 0 : pImpEditEngine->SetAutoCompleteText( aComplete, sal_False );
1416 0 : Point aPos = pImpEditEngine->PaMtoEditCursor( aCurSel.Max() ).TopLeft();
1417 0 : aPos = pEditView->pImpEditView->GetWindowPos( aPos );
1418 0 : aPos = pEditView->pImpEditView->GetWindow()->LogicToPixel( aPos );
1419 0 : aPos = pEditView->GetWindow()->OutputToScreenPixel( aPos );
1420 0 : aPos.Y() -= 3;
1421 0 : Help::ShowQuickHelp( pEditView->GetWindow(), Rectangle( aPos, Size( 1, 1 ) ), aComplete, QUICKHELP_BOTTOM|QUICKHELP_LEFT );
1422 0 : }
1423 0 : }
1424 : }
1425 : }
1426 0 : bModified = sal_True;
1427 : }
1428 : else
1429 0 : bDone = sal_False;
1430 : }
1431 : }
1432 : }
1433 :
1434 0 : pEditView->pImpEditView->SetEditSelection( aCurSel );
1435 0 : pImpEditEngine->UpdateSelections();
1436 :
1437 0 : if ( ( !IsVertical() && ( nCode != KEY_UP ) && ( nCode != KEY_DOWN ) ) ||
1438 0 : ( IsVertical() && ( nCode != KEY_LEFT ) && ( nCode != KEY_RIGHT ) ))
1439 : {
1440 0 : pEditView->pImpEditView->nTravelXPos = TRAVEL_X_DONTKNOW;
1441 : }
1442 :
1443 0 : if ( /* ( nCode != KEY_HOME ) && ( nCode != KEY_END ) && */
1444 0 : ( !IsVertical() && ( nCode != KEY_LEFT ) && ( nCode != KEY_RIGHT ) ) ||
1445 0 : ( IsVertical() && ( nCode != KEY_UP ) && ( nCode != KEY_DOWN ) ))
1446 : {
1447 0 : pEditView->pImpEditView->SetCursorBidiLevel( 0xFFFF );
1448 : }
1449 :
1450 0 : if ( bSetCursorFlags )
1451 0 : pEditView->pImpEditView->nExtraCursorFlags = nNewCursorFlags;
1452 :
1453 0 : if ( bModified )
1454 : {
1455 : DBG_ASSERT( !bReadOnly, "ReadOnly but modified???" );
1456 : // Idle-Formatter only when AnyInput.
1457 0 : if ( bAllowIdle && pImpEditEngine->GetStatus().UseIdleFormatter()
1458 0 : && Application::AnyInput( VCL_INPUT_KEYBOARD) )
1459 0 : pImpEditEngine->IdleFormatAndUpdate( pEditView );
1460 : else
1461 0 : pImpEditEngine->FormatAndUpdate( pEditView );
1462 : }
1463 0 : else if ( bMoved )
1464 : {
1465 0 : sal_Bool bGotoCursor = pEditView->pImpEditView->DoAutoScroll();
1466 0 : pEditView->pImpEditView->ShowCursor( bGotoCursor, sal_True );
1467 0 : pImpEditEngine->CallStatusHdl();
1468 : }
1469 :
1470 0 : if ( GetNotifyHdl().IsSet() )
1471 : {
1472 0 : EENotify aNotify( EE_NOTIFY_INPUT_END );
1473 0 : aNotify.pEditEngine = this;
1474 0 : pImpEditEngine->CallNotify( aNotify );
1475 : }
1476 :
1477 0 : pImpEditEngine->LeaveBlockNotifications();
1478 :
1479 0 : return bDone;
1480 : }
1481 :
1482 209167 : sal_uInt32 EditEngine::GetTextHeight() const
1483 : {
1484 : DBG_CHKTHIS( EditEngine, 0 );
1485 :
1486 209167 : if ( !pImpEditEngine->IsFormatted() )
1487 1 : pImpEditEngine->FormatDoc();
1488 :
1489 209167 : sal_uInt32 nHeight = !IsVertical() ? pImpEditEngine->GetTextHeight() : pImpEditEngine->CalcTextWidth( sal_True );
1490 209167 : return nHeight;
1491 : }
1492 :
1493 34 : sal_uInt32 EditEngine::GetTextHeightNTP() const
1494 : {
1495 : DBG_CHKTHIS( EditEngine, 0 );
1496 :
1497 34 : if ( !pImpEditEngine->IsFormatted() )
1498 0 : pImpEditEngine->FormatDoc();
1499 :
1500 34 : if ( IsVertical() )
1501 0 : return pImpEditEngine->CalcTextWidth( sal_True );
1502 :
1503 34 : return pImpEditEngine->GetTextHeightNTP();
1504 : }
1505 :
1506 31428 : sal_uInt32 EditEngine::CalcTextWidth()
1507 : {
1508 : DBG_CHKTHIS( EditEngine, 0 );
1509 :
1510 31428 : if ( !pImpEditEngine->IsFormatted() )
1511 0 : pImpEditEngine->FormatDoc();
1512 :
1513 31428 : sal_uInt32 nWidth = !IsVertical() ? pImpEditEngine->CalcTextWidth( sal_True ) : pImpEditEngine->GetTextHeight();
1514 31428 : return nWidth;
1515 : }
1516 :
1517 2146288 : void EditEngine::SetUpdateMode( sal_Bool bUpdate )
1518 : {
1519 : DBG_CHKTHIS( EditEngine, 0 );
1520 2146288 : pImpEditEngine->SetUpdateMode( bUpdate );
1521 2146288 : if ( pImpEditEngine->pActiveView )
1522 272 : pImpEditEngine->pActiveView->ShowCursor( sal_False, sal_False );
1523 2146288 : }
1524 :
1525 815490 : sal_Bool EditEngine::GetUpdateMode() const
1526 : {
1527 : DBG_CHKTHIS( EditEngine, 0 );
1528 815490 : return pImpEditEngine->GetUpdateMode();
1529 : }
1530 :
1531 217468 : void EditEngine::Clear()
1532 : {
1533 : DBG_CHKTHIS( EditEngine, 0 );
1534 217468 : pImpEditEngine->Clear();
1535 217468 : }
1536 :
1537 11899 : void EditEngine::SetText( const OUString& rText )
1538 : {
1539 : DBG_CHKTHIS( EditEngine, 0 );
1540 11899 : pImpEditEngine->SetText( rText );
1541 11899 : if ( !rText.isEmpty() )
1542 8115 : pImpEditEngine->FormatAndUpdate();
1543 11899 : }
1544 :
1545 1 : sal_uLong EditEngine::Read( SvStream& rInput, const String& rBaseURL, EETextFormat eFormat, SvKeyValueIterator* pHTTPHeaderAttrs /* = NULL */ )
1546 : {
1547 : DBG_CHKTHIS( EditEngine, 0 );
1548 1 : sal_Bool bUndoEnabled = pImpEditEngine->IsUndoEnabled();
1549 1 : pImpEditEngine->EnableUndo( sal_False );
1550 1 : pImpEditEngine->SetText( XubString() );
1551 1 : EditPaM aPaM( pImpEditEngine->GetEditDoc().GetStartPaM() );
1552 1 : pImpEditEngine->Read( rInput, rBaseURL, eFormat, EditSelection( aPaM, aPaM ), pHTTPHeaderAttrs );
1553 1 : pImpEditEngine->EnableUndo( bUndoEnabled );
1554 1 : return rInput.GetError();
1555 : }
1556 :
1557 0 : sal_uLong EditEngine::Write( SvStream& rOutput, EETextFormat eFormat )
1558 : {
1559 : DBG_CHKTHIS( EditEngine, 0 );
1560 0 : EditPaM aStartPaM( pImpEditEngine->GetEditDoc().GetStartPaM() );
1561 0 : EditPaM aEndPaM( pImpEditEngine->GetEditDoc().GetEndPaM() );
1562 0 : pImpEditEngine->Write( rOutput, eFormat, EditSelection( aStartPaM, aEndPaM ) );
1563 0 : return rOutput.GetError();
1564 : }
1565 :
1566 7014 : EditTextObject* EditEngine::CreateTextObject()
1567 : {
1568 : DBG_CHKTHIS( EditEngine, 0 );
1569 7014 : return pImpEditEngine->CreateTextObject();
1570 : }
1571 :
1572 0 : EditTextObject* EditEngine::CreateTextObject( const ESelection& rESelection )
1573 : {
1574 : DBG_CHKTHIS( EditEngine, 0 );
1575 0 : EditSelection aSel( pImpEditEngine->CreateSel( rESelection ) );
1576 0 : return pImpEditEngine->CreateTextObject( aSel );
1577 : }
1578 :
1579 211356 : void EditEngine::SetText( const EditTextObject& rTextObject )
1580 : {
1581 : DBG_CHKTHIS( EditEngine, 0 );
1582 211356 : pImpEditEngine->EnterBlockNotifications();
1583 211356 : pImpEditEngine->SetText( rTextObject );
1584 211356 : pImpEditEngine->FormatAndUpdate();
1585 211356 : pImpEditEngine->LeaveBlockNotifications();
1586 211356 : }
1587 :
1588 0 : void EditEngine::ShowParagraph( sal_Int32 nParagraph, sal_Bool bShow )
1589 : {
1590 : DBG_CHKTHIS( EditEngine, 0 );
1591 0 : pImpEditEngine->ShowParagraph( nParagraph, bShow );
1592 0 : }
1593 :
1594 4110 : void EditEngine::SetNotifyHdl( const Link& rLink )
1595 : {
1596 : DBG_CHKTHIS( EditEngine, 0 );
1597 4110 : pImpEditEngine->SetNotifyHdl( rLink );
1598 4110 : }
1599 :
1600 1296680 : Link EditEngine::GetNotifyHdl() const
1601 : {
1602 : DBG_CHKTHIS( EditEngine, 0 );
1603 1296680 : return pImpEditEngine->GetNotifyHdl();
1604 : }
1605 :
1606 2175 : void EditEngine::SetStatusEventHdl( const Link& rLink )
1607 : {
1608 : DBG_CHKTHIS( EditEngine, 0 );
1609 2175 : pImpEditEngine->SetStatusEventHdl( rLink );
1610 2175 : }
1611 :
1612 116 : Link EditEngine::GetStatusEventHdl() const
1613 : {
1614 : DBG_CHKTHIS( EditEngine, 0 );
1615 116 : return pImpEditEngine->GetStatusEventHdl();
1616 : }
1617 :
1618 2 : void EditEngine::SetImportHdl( const Link& rLink )
1619 : {
1620 : DBG_CHKTHIS( EditEngine, 0 );
1621 2 : pImpEditEngine->aImportHdl = rLink;
1622 2 : }
1623 :
1624 1 : Link EditEngine::GetImportHdl() const
1625 : {
1626 : DBG_CHKTHIS( EditEngine, 0 );
1627 1 : return pImpEditEngine->aImportHdl;
1628 : }
1629 :
1630 13281 : void EditEngine::SetBeginMovingParagraphsHdl( const Link& rLink )
1631 : {
1632 : DBG_CHKTHIS( EditEngine, 0 );
1633 13281 : pImpEditEngine->aBeginMovingParagraphsHdl = rLink;
1634 13281 : }
1635 :
1636 13281 : void EditEngine::SetEndMovingParagraphsHdl( const Link& rLink )
1637 : {
1638 : DBG_CHKTHIS( EditEngine, 0 );
1639 13281 : pImpEditEngine->aEndMovingParagraphsHdl = rLink;
1640 13281 : }
1641 :
1642 13281 : void EditEngine::SetBeginPasteOrDropHdl( const Link& rLink )
1643 : {
1644 : DBG_CHKTHIS( EditEngine, 0 );
1645 :
1646 13281 : pImpEditEngine->aBeginPasteOrDropHdl = rLink;
1647 13281 : }
1648 :
1649 13281 : void EditEngine::SetEndPasteOrDropHdl( const Link& rLink )
1650 : {
1651 : DBG_CHKTHIS( EditEngine, 0 );
1652 13281 : pImpEditEngine->aEndPasteOrDropHdl = rLink;
1653 13281 : }
1654 :
1655 35355 : EditTextObject* EditEngine::CreateTextObject( sal_Int32 nPara, sal_Int32 nParas )
1656 : {
1657 : DBG_CHKTHIS( EditEngine, 0 );
1658 : DBG_ASSERT( 0 <= nPara && nPara < pImpEditEngine->GetEditDoc().Count(), "CreateTextObject: Startpara out of Range" );
1659 : DBG_ASSERT( nParas <= pImpEditEngine->GetEditDoc().Count() - nPara, "CreateTextObject: Endpara out of Range" );
1660 :
1661 35355 : ContentNode* pStartNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
1662 35355 : ContentNode* pEndNode = pImpEditEngine->GetEditDoc().GetObject( nPara+nParas-1 );
1663 : DBG_ASSERT( pStartNode, "Start-Paragraph does not exist: CreateTextObject" );
1664 : DBG_ASSERT( pEndNode, "End-Paragraph does not exist: CreateTextObject" );
1665 :
1666 35355 : if ( pStartNode && pEndNode )
1667 : {
1668 35355 : EditSelection aTmpSel;
1669 35355 : aTmpSel.Min() = EditPaM( pStartNode, 0 );
1670 35355 : aTmpSel.Max() = EditPaM( pEndNode, pEndNode->Len() );
1671 35355 : return pImpEditEngine->CreateTextObject( aTmpSel );
1672 : }
1673 0 : return 0;
1674 : }
1675 :
1676 0 : void EditEngine::RemoveParagraph( sal_Int32 nPara )
1677 : {
1678 : DBG_CHKTHIS( EditEngine, 0 );
1679 : DBG_ASSERT( pImpEditEngine->GetEditDoc().Count() > 1, "The first paragraph should not be deleted!" );
1680 0 : if( pImpEditEngine->GetEditDoc().Count() <= 1 )
1681 0 : return;
1682 :
1683 0 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
1684 0 : const ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
1685 : DBG_ASSERT( pPortion && pNode, "Paragraph not found: RemoveParagraph" );
1686 0 : if ( pNode && pPortion )
1687 : {
1688 : // No Undo encapsulation needed.
1689 0 : pImpEditEngine->ImpRemoveParagraph( nPara );
1690 0 : pImpEditEngine->InvalidateFromParagraph( nPara );
1691 0 : pImpEditEngine->UpdateSelections();
1692 0 : pImpEditEngine->FormatAndUpdate();
1693 : }
1694 : }
1695 :
1696 314275 : sal_uInt16 EditEngine::GetTextLen( sal_Int32 nPara ) const
1697 : {
1698 : DBG_CHKTHIS( EditEngine, 0 );
1699 314275 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
1700 : DBG_ASSERT( pNode, "Paragraph not found: GetTextLen" );
1701 314275 : if ( pNode )
1702 314275 : return pNode->Len();
1703 0 : return 0;
1704 : }
1705 :
1706 15966 : XubString EditEngine::GetText( sal_Int32 nPara ) const
1707 : {
1708 : DBG_CHKTHIS( EditEngine, 0 );
1709 15966 : XubString aStr;
1710 15966 : if ( 0 <= nPara && nPara < pImpEditEngine->GetEditDoc().Count() )
1711 15966 : aStr = pImpEditEngine->GetEditDoc().GetParaAsString( nPara );
1712 15966 : return aStr;
1713 : }
1714 :
1715 594 : void EditEngine::SetModifyHdl( const Link& rLink )
1716 : {
1717 : DBG_CHKTHIS( EditEngine, 0 );
1718 594 : pImpEditEngine->SetModifyHdl( rLink );
1719 594 : }
1720 :
1721 9 : Link EditEngine::GetModifyHdl() const
1722 : {
1723 : DBG_CHKTHIS( EditEngine, 0 );
1724 9 : return pImpEditEngine->GetModifyHdl();
1725 : }
1726 :
1727 :
1728 43 : void EditEngine::ClearModifyFlag()
1729 : {
1730 : DBG_CHKTHIS( EditEngine, 0 );
1731 43 : pImpEditEngine->SetModifyFlag( sal_False );
1732 43 : }
1733 :
1734 8 : void EditEngine::SetModified()
1735 : {
1736 : DBG_CHKTHIS( EditEngine, 0 );
1737 8 : pImpEditEngine->SetModifyFlag( sal_True );
1738 8 : }
1739 :
1740 22 : sal_Bool EditEngine::IsModified() const
1741 : {
1742 : DBG_CHKTHIS( EditEngine, 0 );
1743 22 : return pImpEditEngine->IsModified();
1744 : }
1745 :
1746 0 : sal_Bool EditEngine::IsInSelectionMode() const
1747 : {
1748 : DBG_CHKTHIS( EditEngine, 0 );
1749 0 : return ( pImpEditEngine->IsInSelectionMode() ||
1750 0 : pImpEditEngine->GetSelEngine().IsInSelection() );
1751 : }
1752 :
1753 0 : void EditEngine::InsertParagraph( sal_Int32 nPara, const EditTextObject& rTxtObj )
1754 : {
1755 : DBG_CHKTHIS( EditEngine, 0 );
1756 0 : if ( nPara > GetParagraphCount() )
1757 : {
1758 : DBG_ASSERTWARNING( nPara == EE_PARA_APPEND, "Paragraph number too large, but not EE_PARA_APPEND!" );
1759 0 : nPara = GetParagraphCount();
1760 : }
1761 :
1762 0 : pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
1763 :
1764 : // No Undo componding needed.
1765 0 : EditPaM aPaM( pImpEditEngine->InsertParagraph( nPara ) );
1766 : // When InsertParagraph from the outside, no hard attributes
1767 : // should be taken over!
1768 0 : pImpEditEngine->RemoveCharAttribs( nPara );
1769 0 : pImpEditEngine->InsertText( rTxtObj, EditSelection( aPaM, aPaM ) );
1770 :
1771 0 : pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
1772 :
1773 0 : pImpEditEngine->FormatAndUpdate();
1774 0 : }
1775 :
1776 476 : void EditEngine::InsertParagraph( sal_Int32 nPara, const XubString& rTxt )
1777 : {
1778 : DBG_CHKTHIS( EditEngine, 0 );
1779 476 : if ( nPara > GetParagraphCount() )
1780 : {
1781 : DBG_ASSERTWARNING( nPara == EE_PARA_APPEND, "Paragraph number too large, but not EE_PARA_APPEND!" );
1782 0 : nPara = GetParagraphCount();
1783 : }
1784 :
1785 476 : pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
1786 476 : EditPaM aPaM( pImpEditEngine->InsertParagraph( nPara ) );
1787 : // When InsertParagraph from the outside, no hard attributes
1788 : // should be taken over!
1789 476 : pImpEditEngine->RemoveCharAttribs( nPara );
1790 476 : pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
1791 476 : pImpEditEngine->ImpInsertText( EditSelection( aPaM, aPaM ), rTxt );
1792 476 : pImpEditEngine->FormatAndUpdate();
1793 476 : }
1794 :
1795 13468 : void EditEngine::SetText( sal_Int32 nPara, const XubString& rTxt )
1796 : {
1797 : DBG_CHKTHIS( EditEngine, 0 );
1798 13468 : EditSelection* pSel = pImpEditEngine->SelectParagraph( nPara );
1799 13468 : if ( pSel )
1800 : {
1801 13468 : pImpEditEngine->UndoActionStart( EDITUNDO_INSERT );
1802 13468 : pImpEditEngine->ImpInsertText( *pSel, rTxt );
1803 13468 : pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT );
1804 13468 : pImpEditEngine->FormatAndUpdate();
1805 13468 : delete pSel;
1806 : }
1807 13468 : }
1808 :
1809 602662 : void EditEngine::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
1810 : {
1811 : DBG_CHKTHIS( EditEngine, 0 );
1812 602662 : pImpEditEngine->SetParaAttribs( nPara, rSet );
1813 602662 : pImpEditEngine->FormatAndUpdate();
1814 602662 : }
1815 :
1816 606609 : const SfxItemSet& EditEngine::GetParaAttribs( sal_Int32 nPara ) const
1817 : {
1818 : DBG_CHKTHIS( EditEngine, 0 );
1819 606609 : return pImpEditEngine->GetParaAttribs( nPara );
1820 : }
1821 :
1822 6749 : sal_Bool EditEngine::HasParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich ) const
1823 : {
1824 : DBG_CHKTHIS( EditEngine, 0 );
1825 6749 : return pImpEditEngine->HasParaAttrib( nPara, nWhich );
1826 : }
1827 :
1828 566186 : const SfxPoolItem& EditEngine::GetParaAttrib( sal_Int32 nPara, sal_uInt16 nWhich )
1829 : {
1830 : DBG_CHKTHIS( EditEngine, 0 );
1831 566186 : return pImpEditEngine->GetParaAttrib( nPara, nWhich );
1832 : }
1833 :
1834 4 : void EditEngine::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const
1835 : {
1836 : DBG_CHKTHIS( EditEngine, 0 );
1837 4 : pImpEditEngine->GetCharAttribs( nPara, rLst );
1838 4 : }
1839 :
1840 1985 : SfxItemSet EditEngine::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib )
1841 : {
1842 : DBG_CHKTHIS( EditEngine, 0 );
1843 : EditSelection aSel( pImpEditEngine->
1844 1985 : ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
1845 1985 : return pImpEditEngine->GetAttribs( aSel, bOnlyHardAttrib );
1846 : }
1847 :
1848 9845 : SfxItemSet EditEngine::GetAttribs( sal_Int32 nPara, sal_uInt16 nStart, sal_uInt16 nEnd, sal_uInt8 nFlags ) const
1849 : {
1850 : DBG_CHKTHIS( EditEngine, 0 );
1851 9845 : return pImpEditEngine->GetAttribs( nPara, nStart, nEnd, nFlags );
1852 : }
1853 :
1854 82 : void EditEngine::RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich )
1855 : {
1856 : DBG_CHKTHIS( EditEngine, 0 );
1857 :
1858 82 : pImpEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS );
1859 82 : EditSelection aSel( pImpEditEngine->ConvertSelection( rSelection.nStartPara, rSelection.nStartPos, rSelection.nEndPara, rSelection.nEndPos ) );
1860 82 : pImpEditEngine->RemoveCharAttribs( aSel, bRemoveParaAttribs, nWhich );
1861 82 : pImpEditEngine->UndoActionEnd( EDITUNDO_RESETATTRIBS );
1862 82 : pImpEditEngine->FormatAndUpdate();
1863 82 : }
1864 :
1865 0 : Font EditEngine::GetStandardFont( sal_Int32 nPara )
1866 : {
1867 : DBG_CHKTHIS( EditEngine, 0 );
1868 0 : return GetStandardSvxFont( nPara );
1869 : }
1870 :
1871 0 : SvxFont EditEngine::GetStandardSvxFont( sal_Int32 nPara )
1872 : {
1873 : DBG_CHKTHIS( EditEngine, 0 );
1874 0 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
1875 0 : return pNode->GetCharAttribs().GetDefFont();
1876 : }
1877 :
1878 7150 : void EditEngine::StripPortions()
1879 : {
1880 : DBG_CHKTHIS( EditEngine, 0 );
1881 7150 : VirtualDevice aTmpDev;
1882 7150 : Rectangle aBigRect( Point( 0, 0 ), Size( 0x7FFFFFFF, 0x7FFFFFFF ) );
1883 7150 : if ( IsVertical() )
1884 : {
1885 0 : aBigRect.Right() = 0;
1886 0 : aBigRect.Left() = -0x7FFFFFFF;
1887 : }
1888 7150 : pImpEditEngine->Paint( &aTmpDev, aBigRect, Point(), sal_True );
1889 7150 : }
1890 :
1891 345 : void EditEngine::GetPortions( sal_Int32 nPara, std::vector<sal_uInt16>& rList )
1892 : {
1893 345 : if ( !pImpEditEngine->IsFormatted() )
1894 6 : pImpEditEngine->FormatFullDoc();
1895 :
1896 345 : const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
1897 345 : if ( pParaPortion )
1898 : {
1899 345 : sal_uInt16 nEnd = 0;
1900 345 : sal_uInt16 nTextPortions = pParaPortion->GetTextPortions().Count();
1901 841 : for ( sal_uInt16 n = 0; n < nTextPortions; n++ )
1902 : {
1903 496 : nEnd = nEnd + pParaPortion->GetTextPortions()[n]->GetLen();
1904 496 : rList.push_back( nEnd );
1905 : }
1906 : }
1907 345 : }
1908 :
1909 0 : void EditEngine::SetFlatMode( sal_Bool bFlat)
1910 : {
1911 : DBG_CHKTHIS( EditEngine, 0 );
1912 0 : pImpEditEngine->SetFlatMode( bFlat );
1913 0 : }
1914 :
1915 2794 : sal_Bool EditEngine::IsFlatMode() const
1916 : {
1917 : DBG_CHKTHIS( EditEngine, 0 );
1918 2794 : return !( pImpEditEngine->aStatus.UseCharAttribs() );
1919 : }
1920 :
1921 898722 : void EditEngine::SetControlWord( sal_uInt32 nWord )
1922 : {
1923 : DBG_CHKTHIS( EditEngine, 0 );
1924 :
1925 898722 : if ( nWord != pImpEditEngine->aStatus.GetControlWord() )
1926 : {
1927 23309 : sal_uInt32 nPrev = pImpEditEngine->aStatus.GetControlWord();
1928 23309 : pImpEditEngine->aStatus.GetControlWord() = nWord;
1929 :
1930 23309 : sal_uInt32 nChanges = nPrev ^ nWord;
1931 23309 : if ( pImpEditEngine->IsFormatted() )
1932 : {
1933 : // possibly reformat:
1934 24760 : if ( ( nChanges & EE_CNTRL_USECHARATTRIBS ) ||
1935 24760 : ( nChanges & EE_CNTRL_USEPARAATTRIBS ) ||
1936 24760 : ( nChanges & EE_CNTRL_ONECHARPERLINE ) ||
1937 24760 : ( nChanges & EE_CNTRL_STRETCHING ) ||
1938 24760 : ( nChanges & EE_CNTRL_OUTLINER ) ||
1939 24760 : ( nChanges & EE_CNTRL_NOCOLORS ) ||
1940 12380 : ( nChanges & EE_CNTRL_OUTLINER2 ) )
1941 : {
1942 2558 : if ( ( nChanges & EE_CNTRL_USECHARATTRIBS ) ||
1943 1279 : ( nChanges & EE_CNTRL_USEPARAATTRIBS ) )
1944 : {
1945 0 : sal_Bool bUseCharAttribs = ( nWord & EE_CNTRL_USECHARATTRIBS ) ? sal_True : sal_False;
1946 0 : pImpEditEngine->GetEditDoc().CreateDefFont( bUseCharAttribs );
1947 : }
1948 :
1949 1279 : pImpEditEngine->FormatFullDoc();
1950 1279 : pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
1951 : }
1952 : }
1953 :
1954 23309 : sal_Bool bSpellingChanged = nChanges & EE_CNTRL_ONLINESPELLING ? sal_True : sal_False;
1955 :
1956 23309 : if ( bSpellingChanged )
1957 : {
1958 2495 : pImpEditEngine->StopOnlineSpellTimer();
1959 2495 : if ( bSpellingChanged && ( nWord & EE_CNTRL_ONLINESPELLING ) )
1960 : {
1961 : // Create WrongList, start timer...
1962 2348 : sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
1963 4696 : for ( sal_Int32 n = 0; n < nNodes; n++ )
1964 : {
1965 2348 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
1966 2348 : pNode->CreateWrongList();
1967 : }
1968 2348 : if (pImpEditEngine->IsFormatted())
1969 1966 : pImpEditEngine->StartOnlineSpellTimer();
1970 : }
1971 : else
1972 : {
1973 147 : long nY = 0;
1974 147 : sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
1975 294 : for ( sal_Int32 n = 0; n < nNodes; n++ )
1976 : {
1977 147 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
1978 147 : const ParaPortion* pPortion = pImpEditEngine->GetParaPortions()[n];
1979 147 : bool bWrongs = ( bSpellingChanged || ( nWord & EE_CNTRL_ONLINESPELLING ) ) ? !pNode->GetWrongList()->empty() : false;
1980 147 : if ( bSpellingChanged )
1981 147 : pNode->DestroyWrongList();
1982 147 : if ( bWrongs )
1983 : {
1984 1 : pImpEditEngine->aInvalidRect.Left() = 0;
1985 1 : pImpEditEngine->aInvalidRect.Right() = pImpEditEngine->GetPaperSize().Width();
1986 1 : pImpEditEngine->aInvalidRect.Top() = nY+1;
1987 1 : pImpEditEngine->aInvalidRect.Bottom() = nY+pPortion->GetHeight()-1;
1988 1 : pImpEditEngine->UpdateViews( pImpEditEngine->pActiveView );
1989 : }
1990 147 : nY += pPortion->GetHeight();
1991 : }
1992 : }
1993 : }
1994 : }
1995 898722 : }
1996 :
1997 1005027 : sal_uInt32 EditEngine::GetControlWord() const
1998 : {
1999 : DBG_CHKTHIS( EditEngine, 0 );
2000 1005027 : return pImpEditEngine->aStatus.GetControlWord();
2001 : }
2002 :
2003 0 : long EditEngine::GetFirstLineStartX( sal_Int32 nParagraph )
2004 : {
2005 : DBG_CHKTHIS( EditEngine, 0 );
2006 :
2007 0 : long nX = 0;
2008 0 : const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nParagraph );
2009 0 : if ( pPPortion )
2010 : {
2011 : DBG_ASSERT( pImpEditEngine->IsFormatted() || !pImpEditEngine->IsFormatting(), "GetFirstLineStartX: Doc not formatted - unable to format!" );
2012 0 : if ( !pImpEditEngine->IsFormatted() )
2013 0 : pImpEditEngine->FormatDoc();
2014 0 : const EditLine* pFirstLine = pPPortion->GetLines()[0];
2015 0 : nX = pFirstLine->GetStartPosX();
2016 : }
2017 0 : return nX;
2018 : }
2019 :
2020 0 : Point EditEngine::GetDocPos( const Point& rPaperPos ) const
2021 : {
2022 0 : Point aDocPos( rPaperPos );
2023 0 : if ( IsVertical() )
2024 : {
2025 0 : aDocPos.X() = rPaperPos.Y();
2026 0 : aDocPos.Y() = GetPaperSize().Width() - rPaperPos.X();
2027 : }
2028 0 : return aDocPos;
2029 : }
2030 :
2031 121 : Point EditEngine::GetDocPosTopLeft( sal_Int32 nParagraph )
2032 : {
2033 : DBG_CHKTHIS( EditEngine, 0 );
2034 121 : const ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nParagraph );
2035 : DBG_ASSERT( pPPortion, "Paragraph not found: GetWindowPosTopLeft" );
2036 121 : Point aPoint;
2037 121 : if ( pPPortion )
2038 : {
2039 :
2040 : // If someone calls GetLineHeight() with an empty Engine.
2041 : DBG_ASSERT( pImpEditEngine->IsFormatted() || !pImpEditEngine->IsFormatting(), "GetDocPosTopLeft: Doc not formatted - unable to format!" );
2042 121 : if ( !pImpEditEngine->IsFormatted() )
2043 4 : pImpEditEngine->FormatAndUpdate();
2044 121 : if ( pPPortion->GetLines().Count() )
2045 : {
2046 : // Correct it if large Bullet.
2047 121 : const EditLine* pFirstLine = pPPortion->GetLines()[0];
2048 121 : aPoint.X() = pFirstLine->GetStartPosX();
2049 : }
2050 : else
2051 : {
2052 0 : const SvxLRSpaceItem& rLRItem = pImpEditEngine->GetLRSpaceItem( pPPortion->GetNode() );
2053 : // TL_NF_LR aPoint.X() = pImpEditEngine->GetXValue( (short)(rLRItem.GetTxtLeft() + rLRItem.GetTxtFirstLineOfst()) );
2054 0 : sal_Int32 nSpaceBefore = 0;
2055 0 : pImpEditEngine->GetSpaceBeforeAndMinLabelWidth( pPPortion->GetNode(), &nSpaceBefore );
2056 0 : short nX = (short)(rLRItem.GetTxtLeft()
2057 0 : + rLRItem.GetTxtFirstLineOfst()
2058 0 : + nSpaceBefore);
2059 0 : aPoint.X() = pImpEditEngine->GetXValue( nX
2060 0 : );
2061 : }
2062 121 : aPoint.Y() = pImpEditEngine->GetParaPortions().GetYOffset( pPPortion );
2063 : }
2064 121 : return aPoint;
2065 : }
2066 :
2067 19113 : const SvxNumberFormat* EditEngine::GetNumberFormat( sal_Int32 nPara ) const
2068 : {
2069 : // derived objects may overload this function to give access to
2070 : // bullet information (see Outliner)
2071 : (void) nPara;
2072 19113 : return 0;
2073 : }
2074 :
2075 1243 : sal_Bool EditEngine::IsRightToLeft( sal_Int32 nPara ) const
2076 : {
2077 : DBG_CHKTHIS( EditEngine, 0 );
2078 1243 : return pImpEditEngine->IsRightToLeft( nPara );
2079 : }
2080 :
2081 0 : sal_Bool EditEngine::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder )
2082 : {
2083 : DBG_CHKTHIS( EditEngine, 0 );
2084 :
2085 0 : if ( !pImpEditEngine->IsFormatted() )
2086 0 : pImpEditEngine->FormatDoc();
2087 :
2088 0 : sal_Bool bTextPos = sal_False;
2089 : // take unrotated positions for calculation here
2090 0 : Point aDocPos = GetDocPos( rPaperPos );
2091 :
2092 0 : if ( ( aDocPos.Y() > 0 ) && ( aDocPos.Y() < (long)pImpEditEngine->GetTextHeight() ) )
2093 : {
2094 0 : EditPaM aPaM = pImpEditEngine->GetPaM( aDocPos, sal_False );
2095 0 : if ( aPaM.GetNode() )
2096 : {
2097 0 : const ParaPortion* pParaPortion = pImpEditEngine->FindParaPortion( aPaM.GetNode() );
2098 : DBG_ASSERT( pParaPortion, "ParaPortion?" );
2099 :
2100 0 : sal_uInt16 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex() );
2101 0 : const EditLine* pLine = pParaPortion->GetLines()[nLine];
2102 0 : Range aLineXPosStartEnd = pImpEditEngine->GetLineXPosStartEnd( pParaPortion, pLine );
2103 0 : if ( ( aDocPos.X() >= aLineXPosStartEnd.Min() - nBorder ) &&
2104 0 : ( aDocPos.X() <= aLineXPosStartEnd.Max() + nBorder ) )
2105 : {
2106 0 : bTextPos = sal_True;
2107 : }
2108 : }
2109 : }
2110 0 : return bTextPos;
2111 : }
2112 :
2113 18150 : void EditEngine::SetEditTextObjectPool( SfxItemPool* pPool )
2114 : {
2115 : DBG_CHKTHIS( EditEngine, 0 );
2116 18150 : pImpEditEngine->SetEditTextObjectPool( pPool );
2117 18150 : }
2118 :
2119 549 : SfxItemPool* EditEngine::GetEditTextObjectPool() const
2120 : {
2121 : DBG_CHKTHIS( EditEngine, 0 );
2122 549 : return pImpEditEngine->GetEditTextObjectPool();
2123 : }
2124 :
2125 3718 : void EditEngine::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
2126 : {
2127 : DBG_CHKTHIS( EditEngine, 0 );
2128 :
2129 : EditSelection aSel( pImpEditEngine->
2130 3718 : ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
2131 :
2132 3718 : pImpEditEngine->SetAttribs( aSel, rSet );
2133 3718 : }
2134 :
2135 0 : void EditEngine::QuickMarkInvalid( const ESelection& rSel )
2136 : {
2137 : DBG_CHKTHIS( EditEngine, 0 );
2138 : DBG_ASSERT( rSel.nStartPara < pImpEditEngine->GetEditDoc().Count(), "MarkInvalid: Start out of Range!" );
2139 : DBG_ASSERT( rSel.nEndPara < pImpEditEngine->GetEditDoc().Count(), "MarkInvalid: End out of Range!" );
2140 0 : for ( sal_Int32 nPara = rSel.nStartPara; nPara <= rSel.nEndPara; nPara++ )
2141 : {
2142 0 : ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
2143 0 : if ( pPortion )
2144 0 : pPortion->MarkSelectionInvalid( 0, pPortion->GetNode()->Len() );
2145 : }
2146 0 : }
2147 :
2148 14593 : void EditEngine::QuickInsertText( const XubString& rText, const ESelection& rSel )
2149 : {
2150 : DBG_CHKTHIS( EditEngine, 0 );
2151 :
2152 : EditSelection aSel( pImpEditEngine->
2153 14593 : ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
2154 :
2155 14593 : pImpEditEngine->ImpInsertText( aSel, rText );
2156 14593 : }
2157 :
2158 210 : void EditEngine::QuickDelete( const ESelection& rSel )
2159 : {
2160 : DBG_CHKTHIS( EditEngine, 0 );
2161 :
2162 : EditSelection aSel( pImpEditEngine->
2163 210 : ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
2164 :
2165 210 : pImpEditEngine->ImpDeleteSelection( aSel );
2166 210 : }
2167 :
2168 0 : void EditEngine::QuickMarkToBeRepainted( sal_Int32 nPara )
2169 : {
2170 : DBG_CHKTHIS( EditEngine, 0 );
2171 0 : ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SafeGetObject( nPara );
2172 0 : if ( pPortion )
2173 0 : pPortion->SetMustRepaint( sal_True );
2174 0 : }
2175 :
2176 11 : void EditEngine::QuickInsertLineBreak( const ESelection& rSel )
2177 : {
2178 : DBG_CHKTHIS( EditEngine, 0 );
2179 :
2180 : EditSelection aSel( pImpEditEngine->
2181 11 : ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
2182 :
2183 11 : pImpEditEngine->InsertLineBreak( aSel );
2184 11 : }
2185 :
2186 3662 : void EditEngine::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
2187 : {
2188 : DBG_CHKTHIS( EditEngine, 0 );
2189 :
2190 : EditSelection aSel( pImpEditEngine->
2191 3662 : ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) );
2192 :
2193 3662 : pImpEditEngine->ImpInsertFeature( aSel, rFld );
2194 3662 : }
2195 :
2196 16 : void EditEngine::QuickFormatDoc( sal_Bool bFull )
2197 : {
2198 : DBG_CHKTHIS( EditEngine, 0 );
2199 16 : if ( bFull )
2200 0 : pImpEditEngine->FormatFullDoc();
2201 : else
2202 16 : pImpEditEngine->FormatDoc();
2203 :
2204 : // Don't pass active view, maybe selection is not updated yet...
2205 16 : pImpEditEngine->UpdateViews( NULL );
2206 16 : }
2207 :
2208 15867 : void EditEngine::QuickRemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich )
2209 : {
2210 : DBG_CHKTHIS( EditEngine, 0 );
2211 15867 : pImpEditEngine->RemoveCharAttribs( nPara, nWhich );
2212 15867 : }
2213 :
2214 0 : void EditEngine::SetStyleSheet(const EditSelection& aSel, SfxStyleSheet* pStyle)
2215 : {
2216 0 : pImpEditEngine->SetStyleSheet(aSel, pStyle);
2217 0 : }
2218 :
2219 6673 : void EditEngine::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle )
2220 : {
2221 : DBG_CHKTHIS( EditEngine, 0 );
2222 6673 : pImpEditEngine->SetStyleSheet( nPara, pStyle );
2223 6673 : }
2224 :
2225 0 : const SfxStyleSheet* EditEngine::GetStyleSheet( sal_Int32 nPara ) const
2226 : {
2227 : DBG_CHKTHIS( EditEngine, 0 );
2228 0 : return pImpEditEngine->GetStyleSheet( nPara );
2229 : }
2230 :
2231 3530 : SfxStyleSheet* EditEngine::GetStyleSheet( sal_Int32 nPara )
2232 : {
2233 : DBG_CHKTHIS( EditEngine, 0 );
2234 3530 : return pImpEditEngine->GetStyleSheet( nPara );
2235 : }
2236 :
2237 14004 : void EditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool )
2238 : {
2239 : DBG_CHKTHIS( EditEngine, 0 );
2240 14004 : pImpEditEngine->SetStyleSheetPool( pSPool );
2241 14004 : }
2242 :
2243 76 : SfxStyleSheetPool* EditEngine::GetStyleSheetPool()
2244 : {
2245 : DBG_CHKTHIS( EditEngine, 0 );
2246 76 : return pImpEditEngine->GetStyleSheetPool();
2247 : }
2248 :
2249 2436 : void EditEngine::SetWordDelimiters( const XubString& rDelimiters )
2250 : {
2251 : DBG_CHKTHIS( EditEngine, 0 );
2252 2436 : pImpEditEngine->aWordDelimiters = rDelimiters;
2253 2436 : if ( pImpEditEngine->aWordDelimiters.Search( CH_FEATURE ) == STRING_NOTFOUND )
2254 2436 : pImpEditEngine->aWordDelimiters.Insert( CH_FEATURE );
2255 2436 : }
2256 :
2257 2411 : XubString EditEngine::GetWordDelimiters() const
2258 : {
2259 : DBG_CHKTHIS( EditEngine, 0 );
2260 2411 : return pImpEditEngine->aWordDelimiters;
2261 : }
2262 :
2263 2563 : void EditEngine::EraseVirtualDevice()
2264 : {
2265 : DBG_CHKTHIS( EditEngine, 0 );
2266 2563 : pImpEditEngine->EraseVirtualDevice();
2267 2563 : }
2268 :
2269 3155 : void EditEngine::SetSpeller( Reference< XSpellChecker1 > &xSpeller )
2270 : {
2271 : DBG_CHKTHIS( EditEngine, 0 );
2272 3155 : pImpEditEngine->SetSpeller( xSpeller );
2273 3155 : }
2274 :
2275 0 : Reference< XSpellChecker1 > EditEngine::GetSpeller()
2276 : {
2277 : DBG_CHKTHIS( EditEngine, 0 );
2278 0 : return pImpEditEngine->GetSpeller();
2279 : }
2280 :
2281 14649 : void EditEngine::SetHyphenator( Reference< XHyphenator > & xHyph )
2282 : {
2283 : DBG_CHKTHIS( EditEngine, 0 );
2284 14649 : pImpEditEngine->SetHyphenator( xHyph );
2285 14649 : }
2286 :
2287 25151 : void EditEngine::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars )
2288 : {
2289 : DBG_CHKTHIS( EditEngine, 0 );
2290 25151 : pImpEditEngine->SetForbiddenCharsTable( xForbiddenChars );
2291 25151 : }
2292 :
2293 11009 : void EditEngine::SetDefaultLanguage( LanguageType eLang )
2294 : {
2295 : DBG_CHKTHIS( EditEngine, 0 );
2296 11009 : pImpEditEngine->SetDefaultLanguage( eLang );
2297 11009 : }
2298 :
2299 0 : LanguageType EditEngine::GetDefaultLanguage() const
2300 : {
2301 : DBG_CHKTHIS( EditEngine, 0 );
2302 0 : return pImpEditEngine->GetDefaultLanguage();
2303 : }
2304 :
2305 0 : sal_Bool EditEngine::SpellNextDocument()
2306 : {
2307 : DBG_CHKTHIS( EditEngine, 0 );
2308 0 : return sal_False;
2309 : }
2310 :
2311 0 : EESpellState EditEngine::HasSpellErrors()
2312 : {
2313 : DBG_CHKTHIS( EditEngine, 0 );
2314 0 : if ( !pImpEditEngine->GetSpeller().is() )
2315 0 : return EE_SPELL_NOSPELLER;
2316 :
2317 0 : return pImpEditEngine->HasSpellErrors();
2318 : }
2319 :
2320 0 : void EditEngine::StartSpelling(EditView& rEditView, sal_Bool bMultipleDoc)
2321 : {
2322 : DBG_CHKTHIS( EditEngine, 0 );
2323 0 : pImpEditEngine->StartSpelling(rEditView, bMultipleDoc);
2324 0 : }
2325 :
2326 0 : bool EditEngine::SpellSentence(EditView& rView, ::svx::SpellPortions& rToFill, bool bIsGrammarChecking )
2327 : {
2328 : DBG_CHKTHIS( EditEngine, 0 );
2329 0 : return pImpEditEngine->SpellSentence( rView, rToFill, bIsGrammarChecking );
2330 : }
2331 :
2332 0 : void EditEngine::PutSpellingToSentenceStart( EditView& rEditView )
2333 : {
2334 : DBG_CHKTHIS( EditEngine, 0 );
2335 0 : pImpEditEngine->PutSpellingToSentenceStart( rEditView );
2336 0 : }
2337 :
2338 0 : void EditEngine::ApplyChangedSentence(EditView& rEditView, const ::svx::SpellPortions& rNewPortions, bool bRecheck )
2339 : {
2340 : DBG_CHKTHIS( EditEngine, 0 );
2341 0 : pImpEditEngine->ApplyChangedSentence( rEditView, rNewPortions, bRecheck );
2342 0 : }
2343 :
2344 0 : sal_Bool EditEngine::HasConvertibleTextPortion( LanguageType nLang )
2345 : {
2346 : DBG_CHKTHIS( EditEngine, 0 );
2347 0 : return pImpEditEngine->HasConvertibleTextPortion( nLang );
2348 : }
2349 :
2350 0 : sal_Bool EditEngine::ConvertNextDocument()
2351 : {
2352 : DBG_CHKTHIS( EditEngine, 0 );
2353 0 : return sal_False;
2354 : }
2355 :
2356 0 : sal_Bool EditEngine::HasText( const SvxSearchItem& rSearchItem )
2357 : {
2358 : DBG_CHKTHIS( EditEngine, 0 );
2359 0 : return pImpEditEngine->HasText( rSearchItem );
2360 : }
2361 :
2362 327323 : void EditEngine::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY )
2363 : {
2364 : DBG_CHKTHIS( EditEngine, 0 );
2365 327323 : pImpEditEngine->SetCharStretching( nX, nY );
2366 327323 : }
2367 :
2368 1662 : void EditEngine::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const
2369 : {
2370 : DBG_CHKTHIS( EditEngine, 0 );
2371 1662 : pImpEditEngine->GetCharStretching( rX, rY );
2372 1662 : }
2373 :
2374 0 : sal_Bool EditEngine::ShouldCreateBigTextObject() const
2375 : {
2376 : DBG_CHKTHIS( EditEngine, 0 );
2377 0 : sal_uInt32 nTextPortions = 0;
2378 0 : sal_Int32 nParas = pImpEditEngine->GetEditDoc().Count();
2379 0 : for ( sal_Int32 nPara = 0; nPara < nParas; nPara++ )
2380 : {
2381 0 : ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara];
2382 0 : nTextPortions = nTextPortions + pParaPortion->GetTextPortions().Count();
2383 : }
2384 0 : return ( nTextPortions >= pImpEditEngine->GetBigTextObjectStart() ) ? sal_True : sal_False;
2385 : }
2386 :
2387 351 : sal_uInt16 EditEngine::GetFieldCount( sal_Int32 nPara ) const
2388 : {
2389 351 : sal_uInt16 nFields = 0;
2390 351 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
2391 351 : if ( pNode )
2392 : {
2393 351 : const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
2394 351 : CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
2395 381 : for (; it != itEnd; ++it)
2396 : {
2397 30 : if (it->Which() == EE_FEATURE_FIELD)
2398 30 : ++nFields;
2399 : }
2400 : }
2401 :
2402 351 : return nFields;
2403 : }
2404 :
2405 30 : EFieldInfo EditEngine::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const
2406 : {
2407 30 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
2408 30 : if ( pNode )
2409 : {
2410 30 : sal_uInt16 nCurrentField = 0;
2411 30 : const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
2412 30 : CharAttribList::AttribsType::const_iterator it = rAttrs.begin(), itEnd = rAttrs.end();
2413 30 : for (; it != itEnd; ++it)
2414 : {
2415 30 : const EditCharAttrib& rAttr = *it;
2416 30 : if (rAttr.Which() == EE_FEATURE_FIELD)
2417 : {
2418 30 : if ( nCurrentField == nField )
2419 : {
2420 30 : const SvxFieldItem* p = static_cast<const SvxFieldItem*>(rAttr.GetItem());
2421 30 : EFieldInfo aInfo(*p, nPara, rAttr.GetStart());
2422 30 : aInfo.aCurrentText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue();
2423 30 : return aInfo;
2424 : }
2425 :
2426 0 : ++nCurrentField;
2427 : }
2428 : }
2429 : }
2430 0 : return EFieldInfo();
2431 : }
2432 :
2433 :
2434 93 : bool EditEngine::UpdateFields()
2435 : {
2436 : DBG_CHKTHIS( EditEngine, 0 );
2437 93 : sal_Bool bChanges = pImpEditEngine->UpdateFields();
2438 93 : if ( bChanges )
2439 0 : pImpEditEngine->FormatAndUpdate();
2440 93 : return bChanges;
2441 : }
2442 :
2443 0 : bool EditEngine::UpdateFieldsOnly()
2444 : {
2445 0 : return pImpEditEngine->UpdateFields();
2446 : }
2447 :
2448 0 : void EditEngine::RemoveFields( sal_Bool bKeepFieldText, TypeId aType )
2449 : {
2450 : DBG_CHKTHIS( EditEngine, 0 );
2451 :
2452 0 : if ( bKeepFieldText )
2453 0 : pImpEditEngine->UpdateFields();
2454 :
2455 0 : sal_Int32 nParas = pImpEditEngine->GetEditDoc().Count();
2456 0 : for ( sal_Int32 nPara = 0; nPara < nParas; nPara++ )
2457 : {
2458 0 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( nPara );
2459 0 : const CharAttribList::AttribsType& rAttrs = pNode->GetCharAttribs().GetAttribs();
2460 0 : for (size_t nAttr = rAttrs.size(); nAttr; )
2461 : {
2462 0 : const EditCharAttrib& rAttr = rAttrs[--nAttr];
2463 0 : if (rAttr.Which() == EE_FEATURE_FIELD)
2464 : {
2465 0 : const SvxFieldData* pFldData = static_cast<const SvxFieldItem*>(rAttr.GetItem())->GetField();
2466 0 : if ( pFldData && ( !aType || ( pFldData->IsA( aType ) ) ) )
2467 : {
2468 : DBG_ASSERT( dynamic_cast<const SvxFieldItem*>(rAttr.GetItem()), "no field item..." );
2469 0 : EditSelection aSel( EditPaM(pNode, rAttr.GetStart()), EditPaM(pNode, rAttr.GetEnd()) );
2470 0 : String aFieldText = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue();
2471 0 : pImpEditEngine->ImpInsertText( aSel, aFieldText );
2472 : }
2473 : }
2474 : }
2475 : }
2476 0 : }
2477 :
2478 658 : sal_Bool EditEngine::HasOnlineSpellErrors() const
2479 : {
2480 : DBG_CHKTHIS( EditEngine, 0 );
2481 658 : sal_Int32 nNodes = pImpEditEngine->GetEditDoc().Count();
2482 1157 : for ( sal_Int32 n = 0; n < nNodes; n++ )
2483 : {
2484 658 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( n );
2485 658 : if ( pNode->GetWrongList() && !pNode->GetWrongList()->empty() )
2486 159 : return sal_True;
2487 : }
2488 499 : return sal_False;
2489 : }
2490 :
2491 3365 : void EditEngine::CompleteOnlineSpelling()
2492 : {
2493 : DBG_CHKTHIS( EditEngine, 0 );
2494 3365 : if ( pImpEditEngine->GetStatus().DoOnlineSpelling() )
2495 : {
2496 2866 : if( !pImpEditEngine->IsFormatted() )
2497 0 : pImpEditEngine->FormatAndUpdate();
2498 :
2499 2866 : pImpEditEngine->StopOnlineSpellTimer();
2500 2866 : pImpEditEngine->DoOnlineSpelling( 0, sal_True, sal_False );
2501 : }
2502 3365 : }
2503 :
2504 0 : sal_Int32 EditEngine::FindParagraph( long nDocPosY )
2505 : {
2506 0 : return pImpEditEngine->GetParaPortions().FindParagraph( nDocPosY );
2507 : }
2508 :
2509 11 : EPosition EditEngine::FindDocPosition( const Point& rDocPos ) const
2510 : {
2511 11 : EPosition aPos;
2512 : // From the point of the API, this is const....
2513 11 : EditPaM aPaM = ((EditEngine*)this)->pImpEditEngine->GetPaM( rDocPos, sal_False );
2514 11 : if ( aPaM.GetNode() )
2515 : {
2516 11 : aPos.nPara = pImpEditEngine->aEditDoc.GetPos( aPaM.GetNode() );
2517 11 : aPos.nIndex = aPaM.GetIndex();
2518 : }
2519 11 : return aPos;
2520 : }
2521 :
2522 21 : Rectangle EditEngine::GetCharacterBounds( const EPosition& rPos ) const
2523 : {
2524 21 : Rectangle aBounds;
2525 21 : ContentNode* pNode = pImpEditEngine->GetEditDoc().GetObject( rPos.nPara );
2526 :
2527 : // Check against index, not paragraph
2528 21 : if ( pNode && ( rPos.nIndex < pNode->Len() ) )
2529 : {
2530 21 : aBounds = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex ), GETCRSR_TXTONLY );
2531 21 : Rectangle aR2 = pImpEditEngine->PaMtoEditCursor( EditPaM( pNode, rPos.nIndex+1 ), GETCRSR_TXTONLY|GETCRSR_ENDOFLINE );
2532 21 : if ( aR2.Right() > aBounds.Right() )
2533 21 : aBounds.Right() = aR2.Right();
2534 : }
2535 21 : return aBounds;
2536 : }
2537 :
2538 89619 : ParagraphInfos EditEngine::GetParagraphInfos( sal_Int32 nPara )
2539 : {
2540 : DBG_CHKTHIS( EditEngine, 0 );
2541 :
2542 : // This only works if not already in the format ...
2543 89619 : if ( !pImpEditEngine->IsFormatted() )
2544 89157 : pImpEditEngine->FormatDoc();
2545 :
2546 89619 : ParagraphInfos aInfos;
2547 89619 : aInfos.bValid = pImpEditEngine->IsFormatted();
2548 89619 : if ( pImpEditEngine->IsFormatted() )
2549 : {
2550 462 : const ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara];
2551 462 : const EditLine* pLine = (pParaPortion && pParaPortion->GetLines().Count()) ?
2552 924 : pParaPortion->GetLines()[0] : NULL;
2553 : DBG_ASSERT( pParaPortion && pLine, "GetParagraphInfos - Paragraph out of range" );
2554 462 : if ( pParaPortion && pLine )
2555 : {
2556 462 : aInfos.nParaHeight = (sal_uInt16)pParaPortion->GetHeight();
2557 462 : aInfos.nLines = pParaPortion->GetLines().Count();
2558 462 : aInfos.nFirstLineStartX = pLine->GetStartPosX();
2559 462 : aInfos.nFirstLineOffset = pParaPortion->GetFirstLineOffset();
2560 462 : aInfos.nFirstLineHeight = pLine->GetHeight();
2561 462 : aInfos.nFirstLineTextHeight = pLine->GetTxtHeight();
2562 462 : aInfos.nFirstLineMaxAscent = pLine->GetMaxAscent();
2563 : }
2564 : }
2565 89619 : return aInfos;
2566 : }
2567 :
2568 : ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >
2569 0 : EditEngine::CreateTransferable( const ESelection& rSelection ) const
2570 : {
2571 : DBG_CHKTHIS( EditEngine, 0 );
2572 0 : EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) );
2573 0 : return pImpEditEngine->CreateTransferable( aSel );
2574 : }
2575 :
2576 : // =====================================================================
2577 : // ====================== Virtual Methods ========================
2578 : // =====================================================================
2579 0 : void EditEngine::DrawingText( const Point&, const XubString&, sal_uInt16, sal_uInt16,
2580 : const sal_Int32*, const SvxFont&, sal_Int32, sal_uInt16, sal_uInt8,
2581 : const EEngineData::WrongSpellVector*, const SvxFieldData*, bool, bool, bool,
2582 : const ::com::sun::star::lang::Locale*, const Color&, const Color&)
2583 :
2584 : {
2585 : DBG_CHKTHIS( EditEngine, 0 );
2586 0 : }
2587 :
2588 0 : void EditEngine::DrawingTab( const Point& /*rStartPos*/, long /*nWidth*/,
2589 : const String& /*rChar*/, const SvxFont& /*rFont*/,
2590 : sal_Int32 /*nPara*/, xub_StrLen /*nIndex*/,
2591 : sal_uInt8 /*nRightToLeft*/, bool /*bEndOfLine*/,
2592 : bool /*bEndOfParagraph*/, const Color& /*rOverlineColor*/,
2593 : const Color& /*rTextLineColor*/)
2594 : {
2595 : DBG_CHKTHIS( EditEngine, 0 );
2596 0 : }
2597 :
2598 1580 : void EditEngine::PaintingFirstLine( sal_Int32, const Point&, long, const Point&, short, OutputDevice* )
2599 : {
2600 : DBG_CHKTHIS( EditEngine, 0 );
2601 1580 : }
2602 :
2603 446810 : void EditEngine::ParagraphInserted( sal_Int32 nPara )
2604 : {
2605 : DBG_CHKTHIS( EditEngine, 0 );
2606 :
2607 446810 : if ( GetNotifyHdl().IsSet() )
2608 : {
2609 107 : EENotify aNotify( EE_NOTIFY_PARAGRAPHINSERTED );
2610 107 : aNotify.pEditEngine = this;
2611 107 : aNotify.nParagraph = nPara;
2612 107 : pImpEditEngine->CallNotify( aNotify );
2613 : }
2614 446810 : }
2615 :
2616 441273 : void EditEngine::ParagraphDeleted( sal_Int32 nPara )
2617 : {
2618 : DBG_CHKTHIS( EditEngine, 0 );
2619 :
2620 441273 : if ( GetNotifyHdl().IsSet() )
2621 : {
2622 107 : EENotify aNotify( EE_NOTIFY_PARAGRAPHREMOVED );
2623 107 : aNotify.pEditEngine = this;
2624 107 : aNotify.nParagraph = nPara;
2625 107 : pImpEditEngine->CallNotify( aNotify );
2626 : }
2627 441273 : }
2628 387 : void EditEngine::ParagraphConnected( sal_Int32 /*nLeftParagraph*/, sal_Int32 /*nRightParagraph*/ )
2629 : {
2630 : DBG_CHKTHIS( EditEngine, 0 );
2631 387 : }
2632 :
2633 450459 : sal_Bool EditEngine::FormattingParagraph( sal_Int32 )
2634 : {
2635 : // return sal_True, if the Attribute was changed ...
2636 : DBG_CHKTHIS( EditEngine, 0 );
2637 450459 : return sal_False;
2638 : }
2639 :
2640 20897 : void EditEngine::ParaAttribsChanged( sal_Int32 /* nParagraph */ )
2641 : {
2642 : DBG_CHKTHIS( EditEngine, 0 );
2643 20897 : }
2644 :
2645 0 : void EditEngine::StyleSheetChanged( SfxStyleSheet* /* pStyle */ )
2646 : {
2647 : DBG_CHKTHIS( EditEngine, 0 );
2648 0 : }
2649 :
2650 408597 : void EditEngine::ParagraphHeightChanged( sal_Int32 nPara )
2651 : {
2652 : DBG_CHKTHIS( EditEngine, 0 );
2653 :
2654 408597 : if ( GetNotifyHdl().IsSet() )
2655 : {
2656 111 : EENotify aNotify( EE_NOTIFY_TEXTHEIGHTCHANGED );
2657 111 : aNotify.pEditEngine = this;
2658 111 : aNotify.nParagraph = nPara;
2659 111 : pImpEditEngine->CallNotify( aNotify );
2660 : }
2661 408597 : }
2662 :
2663 77777 : XubString EditEngine::GetUndoComment( sal_uInt16 nId ) const
2664 : {
2665 : DBG_CHKTHIS( EditEngine, 0 );
2666 77777 : XubString aComment;
2667 77777 : switch ( nId )
2668 : {
2669 : case EDITUNDO_REMOVECHARS:
2670 : case EDITUNDO_CONNECTPARAS:
2671 : case EDITUNDO_REMOVEFEATURE:
2672 : case EDITUNDO_DELCONTENT:
2673 : case EDITUNDO_DELETE:
2674 : case EDITUNDO_CUT:
2675 156 : aComment = EE_RESSTR(RID_EDITUNDO_DEL);
2676 156 : break;
2677 : case EDITUNDO_MOVEPARAGRAPHS:
2678 : case EDITUNDO_MOVEPARAS:
2679 : case EDITUNDO_DRAGANDDROP:
2680 0 : aComment = EE_RESSTR(RID_EDITUNDO_MOVE);
2681 0 : break;
2682 : case EDITUNDO_INSERTFEATURE:
2683 : case EDITUNDO_SPLITPARA:
2684 : case EDITUNDO_INSERTCHARS:
2685 : case EDITUNDO_PASTE:
2686 : case EDITUNDO_INSERT:
2687 : case EDITUNDO_READ:
2688 54949 : aComment = EE_RESSTR(RID_EDITUNDO_INSERT);
2689 54949 : break;
2690 : case EDITUNDO_SRCHANDREPL:
2691 : case EDITUNDO_REPLACEALL:
2692 0 : aComment = EE_RESSTR(RID_EDITUNDO_REPLACE);
2693 0 : break;
2694 : case EDITUNDO_ATTRIBS:
2695 : case EDITUNDO_PARAATTRIBS:
2696 : case EDITUNDO_STRETCH:
2697 20952 : aComment = EE_RESSTR(RID_EDITUNDO_SETATTRIBS);
2698 20952 : break;
2699 : case EDITUNDO_RESETATTRIBS:
2700 82 : aComment = EE_RESSTR(RID_EDITUNDO_RESETATTRIBS);
2701 82 : break;
2702 : case EDITUNDO_STYLESHEET:
2703 1638 : aComment = EE_RESSTR(RID_EDITUNDO_SETSTYLE);
2704 1638 : break;
2705 : case EDITUNDO_TRANSLITERATE:
2706 0 : aComment = EE_RESSTR(RID_EDITUNDO_TRANSLITERATE);
2707 0 : break;
2708 : case EDITUNDO_INDENTBLOCK:
2709 : case EDITUNDO_UNINDENTBLOCK:
2710 0 : aComment = EE_RESSTR(RID_EDITUNDO_INDENT);
2711 0 : break;
2712 : }
2713 77777 : return aComment;
2714 : }
2715 :
2716 17734 : Rectangle EditEngine::GetBulletArea( sal_Int32 )
2717 : {
2718 17734 : return Rectangle( Point(), Point() );
2719 : }
2720 :
2721 447 : OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_uInt16, Color*&, Color*& )
2722 : {
2723 : DBG_CHKTHIS( EditEngine, 0 );
2724 447 : return OUString(' ');
2725 : }
2726 :
2727 0 : void EditEngine::FieldClicked( const SvxFieldItem&, sal_Int32, sal_uInt16 )
2728 : {
2729 : DBG_CHKTHIS( EditEngine, 0 );
2730 0 : }
2731 :
2732 0 : void EditEngine::FieldSelected( const SvxFieldItem&, sal_Int32, sal_uInt16 )
2733 : {
2734 : DBG_CHKTHIS( EditEngine, 0 );
2735 0 : }
2736 :
2737 : // =====================================================================
2738 : // ====================== Static Methods =======================
2739 : // =====================================================================
2740 24575 : SfxItemPool* EditEngine::CreatePool( sal_Bool bPersistentRefCounts )
2741 : {
2742 24575 : SfxItemPool* pPool = new EditEngineItemPool( bPersistentRefCounts );
2743 24575 : return pPool;
2744 : }
2745 :
2746 42 : SfxItemPool& EditEngine::GetGlobalItemPool()
2747 : {
2748 42 : if ( !pGlobalPool )
2749 33 : pGlobalPool = CreatePool();
2750 42 : return *pGlobalPool;
2751 : }
2752 :
2753 203 : void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const Font& rFont )
2754 : {
2755 203 : SvxFont aSvxFont( rFont );
2756 203 : SetFontInfoInItemSet( rSet, aSvxFont );
2757 :
2758 203 : }
2759 :
2760 203 : void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const SvxFont& rFont )
2761 : {
2762 203 : rSet.Put( SvxLanguageItem( rFont.GetLanguage(), EE_CHAR_LANGUAGE ) );
2763 203 : rSet.Put( SvxFontItem( rFont.GetFamily(), rFont.GetName(), XubString(), rFont.GetPitch(), rFont.GetCharSet(), EE_CHAR_FONTINFO ) );
2764 203 : rSet.Put( SvxFontHeightItem( rFont.GetSize().Height(), 100, EE_CHAR_FONTHEIGHT ) );
2765 203 : rSet.Put( SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH ) );
2766 203 : rSet.Put( SvxShadowedItem( rFont.IsShadow(), EE_CHAR_SHADOW ) );
2767 203 : rSet.Put( SvxEscapementItem( rFont.GetEscapement(), rFont.GetPropr(), EE_CHAR_ESCAPEMENT ) );
2768 203 : rSet.Put( SvxWeightItem( rFont.GetWeight(), EE_CHAR_WEIGHT ) );
2769 203 : rSet.Put( SvxColorItem( rFont.GetColor(), EE_CHAR_COLOR ) );
2770 203 : rSet.Put( SvxUnderlineItem( rFont.GetUnderline(), EE_CHAR_UNDERLINE ) );
2771 203 : rSet.Put( SvxOverlineItem( rFont.GetOverline(), EE_CHAR_OVERLINE ) );
2772 203 : rSet.Put( SvxCrossedOutItem( rFont.GetStrikeout(), EE_CHAR_STRIKEOUT ) );
2773 203 : rSet.Put( SvxPostureItem( rFont.GetItalic(), EE_CHAR_ITALIC ) );
2774 203 : rSet.Put( SvxContourItem( rFont.IsOutline(), EE_CHAR_OUTLINE ) );
2775 203 : rSet.Put( SvxAutoKernItem( rFont.IsKerning(), EE_CHAR_PAIRKERNING ) );
2776 203 : rSet.Put( SvxKerningItem( rFont.GetFixKerning(), EE_CHAR_KERNING ) );
2777 203 : rSet.Put( SvxWordLineModeItem( rFont.IsWordLineMode(), EE_CHAR_WLM ) );
2778 203 : rSet.Put( SvxEmphasisMarkItem( rFont.GetEmphasisMark(), EE_CHAR_EMPHASISMARK ) );
2779 203 : rSet.Put( SvxCharReliefItem( rFont.GetRelief(), EE_CHAR_RELIEF ) );
2780 203 : }
2781 :
2782 1397 : Font EditEngine::CreateFontFromItemSet( const SfxItemSet& rItemSet, sal_uInt16 nScriptType )
2783 : {
2784 1397 : SvxFont aFont;
2785 1397 : CreateFont( aFont, rItemSet, true, nScriptType );
2786 1397 : return aFont;
2787 : }
2788 :
2789 0 : SvxFont EditEngine::CreateSvxFontFromItemSet( const SfxItemSet& rItemSet )
2790 : {
2791 0 : SvxFont aFont;
2792 0 : CreateFont( aFont, rItemSet );
2793 0 : return aFont;
2794 : }
2795 :
2796 0 : sal_Bool EditEngine::DoesKeyMoveCursor( const KeyEvent& rKeyEvent )
2797 : {
2798 0 : sal_Bool bDoesMove = sal_False;
2799 :
2800 0 : switch ( rKeyEvent.GetKeyCode().GetCode() )
2801 : {
2802 : case KEY_UP:
2803 : case KEY_DOWN:
2804 : case KEY_LEFT:
2805 : case KEY_RIGHT:
2806 : case KEY_HOME:
2807 : case KEY_END:
2808 : case KEY_PAGEUP:
2809 : case KEY_PAGEDOWN:
2810 : {
2811 0 : if ( !rKeyEvent.GetKeyCode().IsMod2() )
2812 0 : bDoesMove = sal_True;
2813 : }
2814 0 : break;
2815 : }
2816 0 : return bDoesMove;
2817 : }
2818 :
2819 0 : sal_Bool EditEngine::DoesKeyChangeText( const KeyEvent& rKeyEvent )
2820 : {
2821 0 : sal_Bool bDoesChange = sal_False;
2822 :
2823 0 : KeyFuncType eFunc = rKeyEvent.GetKeyCode().GetFunction();
2824 0 : if ( eFunc != KEYFUNC_DONTKNOW )
2825 : {
2826 0 : switch ( eFunc )
2827 : {
2828 : case KEYFUNC_UNDO:
2829 : case KEYFUNC_REDO:
2830 : case KEYFUNC_CUT:
2831 0 : case KEYFUNC_PASTE: bDoesChange = sal_True;
2832 0 : break;
2833 : default: // is then possibly edited below.
2834 0 : eFunc = KEYFUNC_DONTKNOW;
2835 : }
2836 : }
2837 0 : if ( eFunc == KEYFUNC_DONTKNOW )
2838 : {
2839 0 : switch ( rKeyEvent.GetKeyCode().GetCode() )
2840 : {
2841 : case KEY_DELETE:
2842 0 : case KEY_BACKSPACE: bDoesChange = sal_True;
2843 0 : break;
2844 : case KEY_RETURN:
2845 : case KEY_TAB:
2846 : {
2847 0 : if ( !rKeyEvent.GetKeyCode().IsMod1() && !rKeyEvent.GetKeyCode().IsMod2() )
2848 0 : bDoesChange = sal_True;
2849 : }
2850 0 : break;
2851 : default:
2852 : {
2853 0 : bDoesChange = IsSimpleCharInput( rKeyEvent );
2854 : }
2855 : }
2856 : }
2857 0 : return bDoesChange;
2858 : }
2859 :
2860 0 : sal_Bool EditEngine::IsSimpleCharInput( const KeyEvent& rKeyEvent )
2861 : {
2862 0 : if( EditEngine::IsPrintable( rKeyEvent.GetCharCode() ) &&
2863 0 : ( KEY_MOD2 != (rKeyEvent.GetKeyCode().GetModifier() & ~KEY_SHIFT ) ) &&
2864 0 : ( KEY_MOD1 != (rKeyEvent.GetKeyCode().GetModifier() & ~KEY_SHIFT ) ) )
2865 : {
2866 0 : return sal_True;
2867 : }
2868 0 : return sal_False;
2869 : }
2870 :
2871 0 : sal_Bool EditEngine::HasValidData( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rTransferable )
2872 : {
2873 0 : sal_Bool bValidData = sal_False;
2874 :
2875 0 : if ( rTransferable.is() )
2876 : {
2877 : // Every application that copies rtf or any other text format also copies plain text into the clipboard....
2878 0 : datatransfer::DataFlavor aFlavor;
2879 0 : SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
2880 0 : bValidData = rTransferable->isDataFlavorSupported( aFlavor );
2881 : }
2882 :
2883 0 : return bValidData;
2884 : }
2885 :
2886 : /** sets a link that is called at the beginning of a drag operation at an edit view */
2887 0 : void EditEngine::SetBeginDropHdl( const Link& rLink )
2888 : {
2889 0 : pImpEditEngine->SetBeginDropHdl( rLink );
2890 0 : }
2891 :
2892 0 : Link EditEngine::GetBeginDropHdl() const
2893 : {
2894 0 : return pImpEditEngine->GetBeginDropHdl();
2895 : }
2896 :
2897 : /** sets a link that is called at the end of a drag operation at an edit view */
2898 0 : void EditEngine::SetEndDropHdl( const Link& rLink )
2899 : {
2900 0 : pImpEditEngine->SetEndDropHdl( rLink );
2901 0 : }
2902 :
2903 0 : Link EditEngine::GetEndDropHdl() const
2904 : {
2905 0 : return pImpEditEngine->GetEndDropHdl();
2906 : }
2907 :
2908 0 : void EditEngine::SetFirstWordCapitalization( sal_Bool bCapitalize )
2909 : {
2910 0 : pImpEditEngine->SetFirstWordCapitalization( bCapitalize );
2911 0 : }
2912 :
2913 55 : bool EditEngine::IsImportHandlerSet() const
2914 : {
2915 55 : return pImpEditEngine->aImportHdl.IsSet();
2916 : }
2917 :
2918 0 : bool EditEngine::IsImportRTFStyleSheetsSet() const
2919 : {
2920 0 : return pImpEditEngine->GetStatus().DoImportRTFStyleSheets();
2921 : }
2922 :
2923 55 : void EditEngine::CallImportHandler(ImportInfo& rInfo)
2924 : {
2925 55 : pImpEditEngine->aImportHdl.Call(&rInfo);
2926 55 : }
2927 :
2928 6 : EditPaM EditEngine::InsertParaBreak(
2929 : const EditSelection& rEditSelection, bool bKeepEndingAttribs)
2930 : {
2931 6 : return pImpEditEngine->ImpInsertParaBreak(rEditSelection, bKeepEndingAttribs);
2932 : }
2933 :
2934 0 : EditPaM EditEngine::InsertLineBreak(const EditSelection& rEditSelection)
2935 : {
2936 0 : return pImpEditEngine->InsertLineBreak(rEditSelection);
2937 : }
2938 :
2939 0 : EFieldInfo::EFieldInfo()
2940 : {
2941 0 : pFieldItem = NULL;
2942 0 : }
2943 :
2944 :
2945 30 : EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_uInt16 nPos ) : aPosition( nPara, nPos )
2946 : {
2947 30 : pFieldItem = new SvxFieldItem( rFieldItem );
2948 30 : }
2949 :
2950 120 : EFieldInfo::~EFieldInfo()
2951 : {
2952 60 : delete pFieldItem;
2953 60 : }
2954 :
2955 30 : EFieldInfo::EFieldInfo( const EFieldInfo& rFldInfo )
2956 : {
2957 30 : *this = rFldInfo;
2958 30 : }
2959 :
2960 30 : EFieldInfo& EFieldInfo::operator= ( const EFieldInfo& rFldInfo )
2961 : {
2962 30 : if( this == &rFldInfo )
2963 0 : return *this;
2964 :
2965 30 : pFieldItem = rFldInfo.pFieldItem ? new SvxFieldItem( *rFldInfo.pFieldItem ) : 0;
2966 30 : aCurrentText = rFldInfo.aCurrentText;
2967 30 : aPosition = rFldInfo.aPosition;
2968 :
2969 30 : return *this;
2970 267 : }
2971 :
2972 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|