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