Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <hintids.hxx>
31 : : #include <vcl/cmdevt.hxx>
32 : : #include <unotools/charclass.hxx>
33 : : #include <comphelper/processfactory.hxx>
34 : : #include <comphelper/string.hxx>
35 : : #include <unotools/transliterationwrapper.hxx>
36 : : #include <swwait.hxx>
37 : : #include <fmtsrnd.hxx>
38 : : #include <fmtinfmt.hxx>
39 : : #include <txtinet.hxx>
40 : : #include <frmfmt.hxx>
41 : : #include <charfmt.hxx>
42 : : #include <doc.hxx>
43 : : #include <IDocumentUndoRedo.hxx>
44 : : #include <docary.hxx>
45 : : #include <editsh.hxx>
46 : : #include <frame.hxx>
47 : : #include <cntfrm.hxx>
48 : : #include <pam.hxx>
49 : : #include <ndtxt.hxx> // fuer SwTxtNode
50 : : #include <grfatr.hxx>
51 : : #include <flyfrm.hxx>
52 : : #include <swtable.hxx>
53 : : #include <swundo.hxx> // UNDO_START, UNDO_END
54 : : #include <calc.hxx>
55 : : #include <edimp.hxx>
56 : : #include <ndgrf.hxx>
57 : : #include <ndole.hxx>
58 : : #include <txtfrm.hxx>
59 : : #include <rootfrm.hxx>
60 : : #include <extinput.hxx>
61 : : #include <crsskip.hxx>
62 : : #include <scriptinfo.hxx>
63 : : #include <unocrsrhelper.hxx>
64 : : #include <section.hxx>
65 : : #include <unochart.hxx>
66 : : #include <numrule.hxx>
67 : : #include <SwNodeNum.hxx>
68 : : #include <unocrsr.hxx>
69 : : #include <switerator.hxx>
70 : :
71 : : using namespace com::sun::star;
72 : :
73 : :
74 : : /******************************************************************************
75 : : * void SwEditShell::Insert(char c)
76 : : ******************************************************************************/
77 : :
78 : :
79 : 0 : void SwEditShell::Insert( sal_Unicode c, sal_Bool bOnlyCurrCrsr )
80 : : {
81 : 0 : StartAllAction();
82 [ # # ]: 0 : FOREACHPAM_START(this)
83 : :
84 [ # # ][ # # ]: 0 : const bool bSuccess = GetDoc()->InsertString(*PCURCRSR, rtl::OUString(c));
[ # # ]
85 : : OSL_ENSURE( bSuccess, "Doc->Insert() failed." );
86 : : (void) bSuccess;
87 : :
88 : 0 : SaveTblBoxCntnt( PCURCRSR->GetPoint() );
89 [ # # ]: 0 : if( bOnlyCurrCrsr )
90 : 0 : break;
91 : :
92 : 0 : FOREACHPAM_END()
93 : :
94 : 0 : EndAllAction();
95 : 0 : }
96 : :
97 : :
98 : : /******************************************************************************
99 : : * void SwEditShell::Insert(const String &rStr)
100 : : ******************************************************************************/
101 : :
102 : :
103 : 10 : void SwEditShell::Insert2(const String &rStr, const bool bForceExpandHints )
104 : : {
105 : 10 : StartAllAction();
106 : : {
107 : : const enum IDocumentContentOperations::InsertFlags nInsertFlags =
108 : : (bForceExpandHints)
109 : : ? static_cast<IDocumentContentOperations::InsertFlags>(
110 : : IDocumentContentOperations::INS_FORCEHINTEXPAND |
111 : : IDocumentContentOperations::INS_EMPTYEXPAND)
112 [ - + ]: 10 : : IDocumentContentOperations::INS_EMPTYEXPAND;
113 : :
114 [ + - ]: 10 : SwPaM *_pStartCrsr = getShellCrsr( true ), *__pStartCrsr = _pStartCrsr;
115 [ - + ]: 10 : do {
116 : : //OPT: GetSystemCharSet
117 : : const bool bSuccess =
118 : 10 : GetDoc()->InsertString(*_pStartCrsr, rStr, nInsertFlags);
119 : : OSL_ENSURE( bSuccess, "Doc->Insert() failed." );
120 : : (void) bSuccess;
121 : :
122 : 10 : GetDoc()->UpdateRsid( *_pStartCrsr, rStr.Len() );
123 : :
124 : : // Set paragraph rsid if beginning of paragraph
125 : 10 : SwTxtNode *pTxtNode = _pStartCrsr->GetPoint()->nNode.GetNode().GetTxtNode();
126 [ - + ][ - + ]: 10 : if( pTxtNode && pTxtNode->Len() == 1)
[ + - ]
127 : 0 : GetDoc()->UpdateParRsid( pTxtNode );
128 : :
129 : 10 : SaveTblBoxCntnt( _pStartCrsr->GetPoint() );
130 : :
131 : 10 : } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr );
132 : : }
133 : :
134 : : // calculate cursor bidi level
135 [ + - ]: 10 : SwCursor* pTmpCrsr = _GetCrsr();
136 : : const sal_Bool bDoNotSetBidiLevel = ! pTmpCrsr ||
137 [ + - ][ + - ]: 10 : ( 0 != dynamic_cast<SwUnoCrsr*>(pTmpCrsr) );
[ - + ]
138 : :
139 [ + - ]: 10 : if ( ! bDoNotSetBidiLevel )
140 : : {
141 : 10 : SwNode& rNode = pTmpCrsr->GetPoint()->nNode.GetNode();
142 [ + - ]: 10 : if ( rNode.IsTxtNode() )
143 : : {
144 : 10 : SwIndex& rIdx = pTmpCrsr->GetPoint()->nContent;
145 : 10 : xub_StrLen nPos = rIdx.GetIndex();
146 : 10 : xub_StrLen nPrevPos = nPos;
147 [ + - ]: 10 : if ( nPrevPos )
148 : 10 : --nPrevPos;
149 : :
150 : : SwScriptInfo* pSI = SwScriptInfo::GetScriptInfo( ((SwTxtNode&)rNode),
151 : 10 : sal_True );
152 : :
153 : 10 : sal_uInt8 nLevel = 0;
154 [ + + ]: 10 : if ( ! pSI )
155 : : {
156 : : // seems to be an empty paragraph.
157 : 4 : Point aPt;
158 : : SwCntntFrm* pFrm =
159 [ + - ]: 4 : ((SwTxtNode&)rNode).getLayoutFrm( GetLayout(), &aPt, pTmpCrsr->GetPoint(),
160 [ + - ]: 4 : sal_False );
161 : :
162 [ + - ]: 4 : SwScriptInfo aScriptInfo;
163 [ + - ][ + - ]: 4 : aScriptInfo.InitScriptInfo( (SwTxtNode&)rNode, pFrm->IsRightToLeft() );
164 [ + - ][ + - ]: 4 : nLevel = aScriptInfo.DirType( nPrevPos );
165 : : }
166 : : else
167 : : {
168 [ + - ]: 6 : if ( STRING_LEN != pSI->GetInvalidity() )
169 : 6 : pSI->InitScriptInfo( (SwTxtNode&)rNode );
170 : 6 : nLevel = pSI->DirType( nPrevPos );
171 : : }
172 : :
173 : 10 : pTmpCrsr->SetCrsrBidiLevel( nLevel );
174 : : }
175 : : }
176 : :
177 : 10 : SetInFrontOfLabel( sal_False ); // #i27615#
178 : :
179 : 10 : EndAllAction();
180 : 10 : }
181 : :
182 : :
183 : : /******************************************************************************
184 : : * void SwEditShell::Overwrite(const String &rStr)
185 : : ******************************************************************************/
186 : :
187 : :
188 : 0 : void SwEditShell::Overwrite(const String &rStr)
189 : : {
190 : 0 : StartAllAction();
191 [ # # ]: 0 : FOREACHPAM_START(this)
192 : 0 : if( !GetDoc()->Overwrite(*PCURCRSR, rStr ) )
193 : : {
194 : : OSL_FAIL( "Doc->Overwrite(Str) failed." );
195 : : }
196 : 0 : SaveTblBoxCntnt( PCURCRSR->GetPoint() );
197 : 0 : FOREACHPAM_END()
198 : 0 : EndAllAction();
199 : 0 : }
200 : :
201 : :
202 : : /******************************************************************************
203 : : * long SwEditShell::SplitNode()
204 : : ******************************************************************************/
205 : :
206 : 0 : long SwEditShell::SplitNode( sal_Bool bAutoFormat, sal_Bool bCheckTableStart )
207 : : {
208 : 0 : StartAllAction();
209 : 0 : GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
210 : :
211 [ # # ]: 0 : FOREACHPAM_START(this)
212 : : // eine Tabellen Zelle wird jetzt zu einer normalen Textzelle!
213 : 0 : GetDoc()->ClearBoxNumAttrs( PCURCRSR->GetPoint()->nNode );
214 : 0 : GetDoc()->SplitNode( *PCURCRSR->GetPoint(), bCheckTableStart );
215 : 0 : FOREACHPAM_END()
216 : :
217 : 0 : GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
218 : :
219 [ # # ]: 0 : if( bAutoFormat )
220 : 0 : AutoFmtBySplitNode();
221 : :
222 : 0 : ClearTblBoxCntnt();
223 : :
224 : 0 : EndAllAction();
225 : 0 : return(1L);
226 : : }
227 : :
228 : 0 : sal_Bool SwEditShell::AppendTxtNode()
229 : : {
230 : 0 : sal_Bool bRet = sal_False;
231 : 0 : StartAllAction();
232 : 0 : GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
233 : :
234 [ # # ]: 0 : FOREACHPAM_START(this)
235 : 0 : GetDoc()->ClearBoxNumAttrs( PCURCRSR->GetPoint()->nNode );
236 [ # # ][ # # ]: 0 : bRet = GetDoc()->AppendTxtNode( *PCURCRSR->GetPoint()) || bRet;
237 : 0 : FOREACHPAM_END()
238 : :
239 : 0 : GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
240 : :
241 : 0 : ClearTblBoxCntnt();
242 : :
243 : 0 : EndAllAction();
244 : 0 : return bRet;
245 : : }
246 : :
247 : : /******************************************************************************
248 : : * liefert einen Pointer auf einen SwGrfNode; dieser wird von
249 : : * GetGraphic() und GetGraphicSize() verwendet.
250 : : ******************************************************************************/
251 : :
252 : :
253 : 0 : SwGrfNode * SwEditShell::_GetGrfNode() const
254 : : {
255 : 0 : SwGrfNode *pGrfNode = 0;
256 : 0 : SwPaM* pCrsr = GetCrsr();
257 [ # # ]: 0 : if( !pCrsr->HasMark() ||
[ # # # # ]
258 : 0 : pCrsr->GetPoint()->nNode == pCrsr->GetMark()->nNode )
259 : 0 : pGrfNode = pCrsr->GetPoint()->nNode.GetNode().GetGrfNode();
260 : :
261 : 0 : return pGrfNode;
262 : : }
263 : : /******************************************************************************
264 : : * liefert Pointer auf eine Graphic, wenn CurCrsr->GetPoint() auf
265 : : * einen SwGrfNode zeigt (und GetMark nicht gesetzt ist
266 : : * oder auf die gleiche Graphic zeigt)
267 : : ******************************************************************************/
268 : :
269 : 0 : const Graphic* SwEditShell::GetGraphic( sal_Bool bWait ) const
270 : : {
271 : 0 : SwGrfNode* pGrfNode = _GetGrfNode();
272 : 0 : const Graphic* pGrf( 0L );
273 [ # # ]: 0 : if ( pGrfNode )
274 : : {
275 : 0 : pGrf = &(pGrfNode->GetGrf());
276 : : // --> #i73788#
277 : : // no load of linked graphic, if its not needed now (bWait = sal_False).
278 [ # # ]: 0 : if ( bWait )
279 : : {
280 [ # # # # : 0 : if( pGrf->IsSwapOut() ||
# # ][ # # ]
281 : 0 : ( pGrfNode->IsLinkedFile() && GRAPHIC_DEFAULT == pGrf->GetType() ) )
282 : : {
283 : 0 : bool const bResult = pGrfNode->SwapIn(bWait);
284 : : OSL_ENSURE(bResult || !bWait, "Graphic could not be loaded" );
285 : : (void) bResult; // unused in non-debug
286 : : }
287 : : }
288 : : else
289 : : {
290 [ # # ][ # # ]: 0 : if ( pGrf->IsSwapOut() && !pGrfNode->IsLinkedFile() )
[ # # ]
291 : : {
292 : 0 : bool const bResult = pGrfNode->SwapIn(bWait);
293 : : OSL_ENSURE(bResult || !bWait, "Graphic could not be loaded" );
294 : : (void) bResult; // unused in non-debug
295 : : }
296 : : }
297 : : }
298 : 0 : return pGrf;
299 : : }
300 : :
301 : 0 : sal_Bool SwEditShell::IsGrfSwapOut( sal_Bool bOnlyLinked ) const
302 : : {
303 : 0 : SwGrfNode *pGrfNode = _GetGrfNode();
304 : : return pGrfNode &&
305 : 0 : (bOnlyLinked ? ( pGrfNode->IsLinkedFile() &&
306 : 0 : ( GRAPHIC_DEFAULT == pGrfNode->GetGrfObj().GetType()||
307 : 0 : pGrfNode->GetGrfObj().IsSwappedOut()))
308 [ # # # # : 0 : : pGrfNode->GetGrfObj().IsSwappedOut());
# # # # ]
[ # # ][ # # ]
309 : : }
310 : :
311 : 0 : const GraphicObject* SwEditShell::GetGraphicObj() const
312 : : {
313 : 0 : SwGrfNode* pGrfNode = _GetGrfNode();
314 [ # # ]: 0 : return pGrfNode ? &(pGrfNode->GetGrfObj()) : 0L;
315 : : }
316 : :
317 : 0 : sal_uInt16 SwEditShell::GetGraphicType() const
318 : : {
319 : 0 : SwGrfNode *pGrfNode = _GetGrfNode();
320 [ # # ]: 0 : return static_cast<sal_uInt16>(pGrfNode ? pGrfNode->GetGrfObj().GetType() : GRAPHIC_NONE);
321 : : }
322 : :
323 : : /******************************************************************************
324 : : * liefert die Groesse der Graphic, wenn CurCrsr->GetPoint() auf
325 : : * einen SwGrfNode zeigt (und GetMark nicht gesetzt ist
326 : : * oder auf die gleiche Graphic zeigt)
327 : : ******************************************************************************/
328 : :
329 : 0 : sal_Bool SwEditShell::GetGrfSize(Size& rSz) const
330 : : {
331 : : SwNoTxtNode* pNoTxtNd;
332 : 0 : SwPaM* pCurrentCrsr = GetCrsr();
333 [ # # ][ # # : 0 : if( ( !pCurrentCrsr->HasMark()
# # # # ]
334 : 0 : || pCurrentCrsr->GetPoint()->nNode == pCurrentCrsr->GetMark()->nNode )
335 : 0 : && 0 != ( pNoTxtNd = pCurrentCrsr->GetNode()->GetNoTxtNode() ) )
336 : : {
337 : 0 : rSz = pNoTxtNd->GetTwipSize();
338 : 0 : return sal_True;
339 : : }
340 : 0 : return sal_False;
341 : :
342 : : }
343 : : /******************************************************************************
344 : : * erneutes Einlesen, falls Graphic nicht Ok ist. Die
345 : : * aktuelle wird durch die neue ersetzt.
346 : : ******************************************************************************/
347 : :
348 : 0 : void SwEditShell::ReRead( const String& rGrfName, const String& rFltName,
349 : : const Graphic* pGraphic, const GraphicObject* pGrfObj )
350 : : {
351 : 0 : StartAllAction();
352 : 0 : pDoc->ReRead( *GetCrsr(), rGrfName, rFltName, pGraphic, pGrfObj );
353 : 0 : EndAllAction();
354 : 0 : }
355 : :
356 : :
357 : : /******************************************************************************
358 : : * liefert den Namen und den FilterNamen einer Graphic, wenn der Cursor
359 : : * auf einer Graphic steht
360 : : * Ist ein String-Ptr != 0 dann returne den entsp. Namen
361 : : ******************************************************************************/
362 : :
363 : :
364 : 0 : void SwEditShell::GetGrfNms( String* pGrfName, String* pFltName,
365 : : const SwFlyFrmFmt* pFmt ) const
366 : : {
367 : : OSL_ENSURE( pGrfName || pFltName, "was wird denn nun erfragt?" );
368 [ # # ]: 0 : if( pFmt )
369 : 0 : GetDoc()->GetGrfNms( *pFmt, pGrfName, pFltName );
370 : : else
371 : : {
372 : 0 : SwGrfNode *pGrfNode = _GetGrfNode();
373 [ # # ][ # # ]: 0 : if( pGrfNode && pGrfNode->IsLinkedFile() )
[ # # ]
374 : 0 : pGrfNode->GetFileFilterNms( pGrfName, pFltName );
375 : : }
376 : 0 : }
377 : :
378 : :
379 : 0 : const PolyPolygon *SwEditShell::GetGraphicPolygon() const
380 : : {
381 : 0 : SwNoTxtNode *pNd = GetCrsr()->GetNode()->GetNoTxtNode();
382 : 0 : return pNd->HasContour();
383 : : }
384 : :
385 : :
386 : 0 : void SwEditShell::SetGraphicPolygon( const PolyPolygon *pPoly )
387 : : {
388 : 0 : SwNoTxtNode *pNd = GetCrsr()->GetNode()->GetNoTxtNode();
389 : 0 : StartAllAction();
390 : 0 : pNd->SetContour( pPoly );
391 : 0 : SwFlyFrm *pFly = (SwFlyFrm*)pNd->getLayoutFrm(GetLayout())->GetUpper();
392 : 0 : const SwFmtSurround &rSur = pFly->GetFmt()->GetSurround();
393 : 0 : pFly->GetFmt()->NotifyClients( (SwFmtSurround*)&rSur, (SwFmtSurround*)&rSur );
394 : 0 : GetDoc()->SetModified();
395 : 0 : EndAllAction();
396 : 0 : }
397 : :
398 : 0 : void SwEditShell::ClearAutomaticContour()
399 : : {
400 : 0 : SwNoTxtNode *pNd = GetCrsr()->GetNode()->GetNoTxtNode();
401 : : OSL_ENSURE( pNd, "is no NoTxtNode!" );
402 [ # # ]: 0 : if( pNd->HasAutomaticContour() )
403 : : {
404 : 0 : StartAllAction();
405 : 0 : pNd->SetContour( NULL, sal_False );
406 : 0 : SwFlyFrm *pFly = (SwFlyFrm*)pNd->getLayoutFrm(GetLayout())->GetUpper();
407 : 0 : const SwFmtSurround &rSur = pFly->GetFmt()->GetSurround();
408 : 0 : pFly->GetFmt()->NotifyClients( (SwFmtSurround*)&rSur, (SwFmtSurround*)&rSur );
409 : 0 : GetDoc()->SetModified();
410 : 0 : EndAllAction();
411 : : }
412 : 0 : }
413 : :
414 : : /******************************************************************************
415 : : * liefert Pointer auf ein SvInPlaceObjectRef, wenn CurCrsr->GetPoint() auf
416 : : * einen SwOLENode zeigt (und GetMark nicht gesetzt ist
417 : : * oder auf das gleiche SvInPlaceObjectRef zeigt)
418 : : * besorgt den Pointer vom Doc wenn das Objekt per Namen gesucht werden
419 : : * soll
420 : : ******************************************************************************/
421 : :
422 : 0 : svt::EmbeddedObjectRef& SwEditShell::GetOLEObject() const
423 : : {
424 : : OSL_ENSURE( CNT_OLE == GetCntType(), "GetOLEObj: kein OLENode." );
425 : : OSL_ENSURE( !GetCrsr()->HasMark() ||
426 : : (GetCrsr()->HasMark() &&
427 : : GetCrsr()->GetPoint()->nNode == GetCrsr()->GetMark()->nNode),
428 : : "GetOLEObj: kein OLENode." );
429 : :
430 : 0 : SwOLENode *pOLENode = GetCrsr()->GetNode()->GetOLENode();
431 : : OSL_ENSURE( pOLENode, "GetOLEObj: kein OLENode." );
432 : 0 : SwOLEObj& rOObj = pOLENode->GetOLEObj();
433 : 0 : return rOObj.GetObject();
434 : : }
435 : :
436 : :
437 : 0 : sal_Bool SwEditShell::HasOLEObj( const String &rName ) const
438 : : {
439 : : SwStartNode *pStNd;
440 [ # # ][ # # ]: 0 : SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
441 [ # # ]: 0 : while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) )
442 : : {
443 [ # # ]: 0 : aIdx++;
444 : 0 : SwNode& rNd = aIdx.GetNode();
445 [ # # ][ # # ]: 0 : if( rNd.IsOLENode() &&
[ # # ][ # # ]
446 [ # # ]: 0 : rName == ((SwOLENode&)rNd).GetChartTblName() &&
447 [ # # ][ # # ]: 0 : ((SwOLENode&)rNd).getLayoutFrm( GetLayout() ) )
448 : 0 : return sal_True;
449 : :
450 [ # # ]: 0 : aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
451 : : }
452 [ # # ]: 0 : return sal_False;
453 : : }
454 : :
455 : :
456 : 0 : void SwEditShell::SetChartName( const String &rName )
457 : : {
458 : 0 : SwOLENode *pONd = GetCrsr()->GetNode()->GetOLENode();
459 : : OSL_ENSURE( pONd, "ChartNode not found" );
460 : 0 : pONd->SetChartTblName( rName );
461 : 0 : }
462 : :
463 : 0 : void SwEditShell::UpdateCharts( const String &rName )
464 : : {
465 : 0 : GetDoc()->UpdateCharts( rName );
466 : 0 : }
467 : :
468 : :
469 : : /******************************************************************************
470 : : * Aenderung des Tabellennamens
471 : : ******************************************************************************/
472 : :
473 : 0 : void SwEditShell::SetTableName( SwFrmFmt& rTblFmt, const String &rNewName )
474 : : {
475 : 0 : GetDoc()->SetTableName( rTblFmt, rNewName );
476 : 0 : }
477 : :
478 : : // erfragen des akt. Wortes
479 : :
480 : 0 : String SwEditShell::GetCurWord()
481 : : {
482 : 0 : const SwPaM& rPaM = *GetCrsr();
483 : 0 : const SwTxtNode* pNd = rPaM.GetNode()->GetTxtNode();
484 : : String aString = pNd ?
485 : 0 : pNd->GetCurWord(rPaM.GetPoint()->nContent.GetIndex()) :
486 [ # # ]: 0 : aEmptyStr;
487 : 0 : return aString;
488 : : }
489 : :
490 : : /****************************************************************************
491 : : * void SwEditShell::UpdateDocStat()
492 : : ****************************************************************************/
493 : :
494 : :
495 : 0 : void SwEditShell::UpdateDocStat( )
496 : : {
497 : 0 : StartAllAction();
498 : 0 : GetDoc()->UpdateDocStat( );
499 : 0 : EndAllAction();
500 : 0 : }
501 : :
502 : 0 : const SwDocStat& SwEditShell::GetUpdatedDocStat()
503 : : {
504 : 0 : StartAllAction();
505 : 0 : const SwDocStat &rRet = GetDoc()->GetUpdatedDocStat();
506 : 0 : EndAllAction();
507 : 0 : return rRet;
508 : : }
509 : :
510 : : // OPT: eddocinl.cxx
511 : :
512 : :
513 : : // returne zum Namen die im Doc gesetzte Referenz
514 : 0 : const SwFmtRefMark* SwEditShell::GetRefMark( const String& rName ) const
515 : : {
516 : 0 : return GetDoc()->GetRefMark( rName );
517 : : }
518 : :
519 : : // returne die Namen aller im Doc gesetzten Referenzen
520 : 0 : sal_uInt16 SwEditShell::GetRefMarks( std::vector<rtl::OUString>* pStrings ) const
521 : : {
522 : 0 : return GetDoc()->GetRefMarks( pStrings );
523 : : }
524 : :
525 : : /******************************************************************************
526 : : * DropCap-SS
527 : : ******************************************************************************/
528 : :
529 : :
530 : 0 : String SwEditShell::GetDropTxt( const sal_uInt16 nChars ) const
531 : : {
532 : : /**
533 : : * pb: made changes for #i74939#
534 : : *
535 : : * always return a string even though there is a selection
536 : : */
537 : :
538 : 0 : String aTxt;
539 [ # # ]: 0 : SwPaM* pCrsr = GetCrsr();
540 [ # # ]: 0 : if ( IsMultiSelection() )
541 : : {
542 : : // if a multi selection exists, search for the first line
543 : : // -> it is the cursor with the lowest index
544 : 0 : sal_uLong nIndex = pCrsr->GetMark()->nNode.GetIndex();
545 : 0 : bool bPrev = true;
546 : 0 : SwPaM* pLast = pCrsr;
547 : 0 : SwPaM* pTemp = pCrsr;
548 [ # # ]: 0 : while ( bPrev )
549 : : {
550 [ # # ]: 0 : SwPaM* pPrev2 = dynamic_cast< SwPaM* >( pTemp->GetPrev() );
551 [ # # ][ # # ]: 0 : bPrev = ( pPrev2 && pPrev2 != pLast );
552 [ # # ]: 0 : if ( bPrev )
553 : : {
554 : 0 : pTemp = pPrev2;
555 : 0 : sal_uLong nTemp = pPrev2->GetMark()->nNode.GetIndex();
556 [ # # ]: 0 : if ( nTemp < nIndex )
557 : : {
558 : 0 : nIndex = nTemp;
559 : 0 : pCrsr = pPrev2;
560 : : }
561 : : }
562 : : }
563 : : }
564 : :
565 : 0 : SwTxtNode* pTxtNd = pCrsr->GetNode( !pCrsr->HasMark() )->GetTxtNode();
566 [ # # ]: 0 : if( pTxtNd )
567 : : {
568 [ # # ]: 0 : xub_StrLen nDropLen = pTxtNd->GetDropLen( nChars );
569 [ # # ]: 0 : if( nDropLen )
570 [ # # ][ # # ]: 0 : aTxt = pTxtNd->GetTxt().Copy( 0, nDropLen );
[ # # ]
571 : : }
572 : :
573 : 0 : return aTxt;
574 : : }
575 : :
576 : 0 : void SwEditShell::ReplaceDropTxt( const String &rStr, SwPaM* pPaM )
577 : : {
578 [ # # ]: 0 : SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
579 [ # # # # ]: 0 : if( pCrsr->GetPoint()->nNode == pCrsr->GetMark()->nNode &&
[ # # ]
580 : 0 : pCrsr->GetNode()->GetTxtNode()->IsTxtNode() )
581 : : {
582 [ # # ]: 0 : StartAllAction();
583 : :
584 : 0 : const SwNodeIndex& rNd = pCrsr->GetPoint()->nNode;
585 [ # # ]: 0 : SwPaM aPam( rNd, rStr.Len(), rNd, 0 );
586 [ # # ]: 0 : if( !GetDoc()->Overwrite( aPam, rStr ) )
587 : : {
588 : : OSL_FAIL( "Doc->Overwrite(Str) failed." );
589 : : }
590 : :
591 [ # # ][ # # ]: 0 : EndAllAction();
592 : : }
593 : 0 : }
594 : :
595 : :
596 : 0 : String SwEditShell::Calculate()
597 : : {
598 [ # # ]: 0 : String aFormel; // die entgueltige Formel
599 [ # # ]: 0 : SwPaM *pPaMLast = (SwPaM*)GetCrsr()->GetNext(),
600 : 0 : *pPaM = pPaMLast; // die Pointer auf Cursor
601 [ # # ]: 0 : SwCalc aCalc( *GetDoc() );
602 [ # # ]: 0 : const CharClass& rCC = GetAppCharClass();
603 : :
604 [ # # ]: 0 : do {
605 : 0 : SwTxtNode* pTxtNd = pPaM->GetNode()->GetTxtNode();
606 [ # # ]: 0 : if(pTxtNd)
607 : : {
608 [ # # ][ # # ]: 0 : const SwPosition *pStart = pPaM->Start(), *pEnd = pPaM->End();
609 : 0 : xub_StrLen nStt = pStart->nContent.GetIndex();
610 : : String aStr = pTxtNd->GetExpandTxt( nStt, pEnd->nContent.
611 [ # # ]: 0 : GetIndex() - nStt );
612 : :
613 [ # # ][ # # ]: 0 : aStr = rCC.lowercase( aStr );
[ # # ]
614 : :
615 : : sal_Unicode ch;
616 : 0 : sal_Bool bValidFlds = sal_False;
617 : 0 : xub_StrLen nPos = 0;
618 : :
619 [ # # ]: 0 : while( nPos < aStr.Len() )
620 : : {
621 : 0 : ch = aStr.GetChar( nPos++ );
622 [ # # ][ # # ]: 0 : if( rCC.isLetter( aStr, nPos-1 ) || ch == '_' )
[ # # ][ # # ]
623 : : {
624 : 0 : xub_StrLen nTmpStt = nPos-1;
625 [ # # ][ # # ]: 0 : while( nPos < aStr.Len() &&
[ # # ][ # # ]
[ # # ][ # # ]
626 : 0 : 0 != ( ch = aStr.GetChar( nPos++ )) &&
627 [ # # ]: 0 : (rCC.isLetterNumeric( aStr, nPos - 1 ) ||
628 : : ch == '_'|| ch == '.' ))
629 : : ;
630 : :
631 [ # # ]: 0 : if( nPos < aStr.Len() )
632 : 0 : --nPos;
633 : :
634 [ # # ]: 0 : String sVar( aStr.Copy( nTmpStt, nPos - nTmpStt ));
635 [ # # ][ # # ]: 0 : if( !::FindOperator( sVar ) &&
[ # # ][ # # ]
[ # # ]
636 [ # # ]: 0 : (::Find( sVar, aCalc.GetVarTable(),TBLSZ) ||
637 [ # # ]: 0 : aCalc.VarLook( sVar )) )
638 : : {
639 [ # # ]: 0 : if( !bValidFlds )
640 : : {
641 : 0 : GetDoc()->FldsToCalc( aCalc,
642 : : pStart->nNode.GetIndex(),
643 [ # # ]: 0 : pStart->nContent.GetIndex() );
644 : 0 : bValidFlds = sal_True;
645 : : }
646 [ # # ]: 0 : (( aFormel += '(' ) +=
647 [ # # ]: 0 : aCalc.GetStrResult( aCalc.VarLook( sVar )
648 [ # # ][ # # ]: 0 : ->nValue )) += ')';
[ # # ][ # # ]
649 : : }
650 : : else
651 [ # # ][ # # ]: 0 : aFormel += sVar;
652 : : }
653 : : else
654 [ # # ]: 0 : aFormel += ch;
655 [ # # ]: 0 : }
656 : : }
657 : 0 : } while( pPaMLast != (pPaM = (SwPaM*)pPaM->GetNext()) );
658 : :
659 [ # # ][ # # ]: 0 : return aCalc.GetStrResult( aCalc.Calculate(aFormel) );
[ # # ][ # # ]
[ # # ]
660 : : }
661 : :
662 : :
663 : 14 : sfx2::LinkManager& SwEditShell::GetLinkManager()
664 : : {
665 : 14 : return pDoc->GetLinkManager();
666 : : }
667 : :
668 : :
669 : 0 : void *SwEditShell::GetIMapInventor() const
670 : : {
671 : : //Als eindeutige Identifikation sollte der Node, auf dem der Crsr steht
672 : : //genuegen.
673 : 0 : return (void*)GetCrsr()->GetNode();
674 : : }
675 : :
676 : : // #i73788#
677 : : // remove default parameter, because method is always called this default value
678 : 0 : Graphic SwEditShell::GetIMapGraphic() const
679 : : {
680 : : //Liefert immer eine Graphic, wenn der Crsr in einem Fly steht.
681 [ # # ]: 0 : SET_CURR_SHELL( (ViewShell*)this );
682 [ # # ]: 0 : Graphic aRet;
683 [ # # ]: 0 : SwPaM* pCrsr = GetCrsr();
684 [ # # ]: 0 : if ( !pCrsr->HasMark() )
685 : : {
686 : 0 : SwNode *pNd =pCrsr->GetNode();
687 [ # # ]: 0 : if( pNd->IsGrfNode() )
688 : : {
689 [ # # ]: 0 : SwGrfNode & rGrfNode(*static_cast<SwGrfNode*>(pNd));
690 [ # # ]: 0 : const Graphic& rGrf = rGrfNode.GetGrf();
691 [ # # ][ # # ]: 0 : if( rGrf.IsSwapOut() || ( rGrfNode.IsLinkedFile() &&
[ # # ][ # # ]
[ # # ]
692 [ # # ]: 0 : GRAPHIC_DEFAULT == rGrf.GetType() ) )
693 : : {
694 [ # # ]: 0 : bool const bResult = rGrfNode.SwapIn(true);
695 : : OSL_ENSURE(bResult, "Graphic could not be loaded" );
696 : : (void) bResult; // unused in non-debug
697 : : }
698 [ # # ]: 0 : aRet = rGrf;
699 : : }
700 [ # # ]: 0 : else if ( pNd->IsOLENode() )
701 : : {
702 [ # # ][ # # ]: 0 : aRet = *((SwOLENode*)pNd)->GetGraphic();
[ # # ]
703 : : }
704 : : else
705 : : {
706 [ # # ][ # # ]: 0 : SwFlyFrm* pFlyFrm = pNd->GetCntntNode()->getLayoutFrm( GetLayout() )->FindFlyFrm();
[ # # ]
707 [ # # ]: 0 : if(pFlyFrm)
708 [ # # ][ # # ]: 0 : aRet = pFlyFrm->GetFmt()->MakeGraphic();
[ # # ][ # # ]
709 : : }
710 : : }
711 [ # # ]: 0 : return aRet;
712 : : }
713 : :
714 : :
715 : 0 : sal_Bool SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, const String& rStr, sal_Bool bKeepSelection )
716 : : {
717 : : // URL und Hinweistext (direkt oder via Selektion) notwendig
718 [ # # ][ # # ]: 0 : if( !rFmt.GetValue().Len() || ( !rStr.Len() && !HasSelection() ) )
[ # # ][ # # ]
719 : 0 : return sal_False;
720 : 0 : StartAllAction();
721 : 0 : GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_UI_INSERT_URLTXT, NULL);
722 : 0 : sal_Bool bInsTxt = sal_True;
723 : :
724 [ # # ]: 0 : if( rStr.Len() )
725 : : {
726 : 0 : SwPaM* pCrsr = GetCrsr();
727 [ # # ][ # # ]: 0 : if( pCrsr->HasMark() && *pCrsr->GetPoint() != *pCrsr->GetMark() )
[ # # ]
728 : : {
729 : : // Selection vorhanden, MehrfachSelektion?
730 : 0 : sal_Bool bDelTxt = sal_True;
731 [ # # ]: 0 : if( pCrsr->GetNext() == pCrsr )
732 : : {
733 : : // einfach Selection -> Text ueberpruefen
734 [ # # ][ # # ]: 0 : String sTxt(comphelper::string::stripEnd(GetSelTxt(), ' '));
[ # # ][ # # ]
[ # # ]
735 [ # # ][ # # ]: 0 : if( sTxt == rStr )
736 [ # # ]: 0 : bDelTxt = bInsTxt = sal_False;
737 : : }
738 [ # # ]: 0 : else if( rFmt.GetValue() == rStr ) // Name und URL gleich?
739 : 0 : bDelTxt = bInsTxt = sal_False;
740 : :
741 [ # # ]: 0 : if( bDelTxt )
742 : 0 : Delete();
743 : : }
744 [ # # ][ # # ]: 0 : else if( pCrsr->GetNext() != pCrsr && rFmt.GetValue() == rStr )
[ # # ]
745 : 0 : bInsTxt = sal_False;
746 : :
747 [ # # ]: 0 : if( bInsTxt )
748 : : {
749 : 0 : Insert2( rStr );
750 : 0 : SetMark();
751 : 0 : ExtendSelection( sal_False, rStr.Len() );
752 : : }
753 : : }
754 : : else
755 : 0 : bInsTxt = sal_False;
756 : :
757 : 0 : SetAttr( rFmt );
758 [ # # ][ # # ]: 0 : if (bInsTxt && !IsCrsrPtAtEnd())
[ # # ]
759 : 0 : SwapPam();
760 [ # # ]: 0 : if(!bKeepSelection)
761 : 0 : ClearMark();
762 [ # # ]: 0 : if( bInsTxt )
763 : 0 : DontExpandFmt();
764 : 0 : GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_UI_INSERT_URLTXT, NULL );
765 : 0 : EndAllAction();
766 : 0 : return sal_True;
767 : : }
768 : :
769 : :
770 : 0 : sal_uInt16 SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr )
771 : : {
772 : 0 : rArr.clear();
773 : :
774 : : const SwTxtNode* pTxtNd;
775 : 0 : const SwCharFmts* pFmts = GetDoc()->GetCharFmts();
776 [ # # ]: 0 : for( sal_uInt16 n = pFmts->size(); 1 < n; )
777 : : {
778 [ # # ][ # # ]: 0 : SwIterator<SwTxtINetFmt,SwCharFmt> aIter(*(*pFmts)[--n]);
779 [ # # ][ # # ]: 0 : for( SwTxtINetFmt* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() )
[ # # ]
780 : : {
781 [ # # ][ # # ]: 0 : if( 0 != ( pTxtNd = pFnd->GetpTxtNode()) &&
[ # # ]
782 [ # # ]: 0 : pTxtNd->GetNodes().IsDocNodes() )
783 : : {
784 : 0 : SwTxtINetFmt& rAttr = *pFnd;
785 : 0 : String sTxt( pTxtNd->GetExpandTxt( *rAttr.GetStart(),
786 [ # # ][ # # ]: 0 : *rAttr.GetEnd() - *rAttr.GetStart() ) );
787 : :
788 [ # # ][ # # ]: 0 : sTxt = comphelper::string::remove(sTxt, 0x0a);
789 [ # # ][ # # ]: 0 : sTxt = comphelper::string::strip(sTxt, ' ');
[ # # ]
790 : :
791 [ # # ]: 0 : if( sTxt.Len() )
792 : : {
793 [ # # ][ # # ]: 0 : SwGetINetAttr* pNew = new SwGetINetAttr( sTxt, rAttr );
794 [ # # ]: 0 : rArr.push_back( pNew );
795 [ # # ]: 0 : }
796 : : }
797 : : }
798 [ # # ]: 0 : }
799 : 0 : return rArr.size();
800 : : }
801 : :
802 : :
803 : : // ist der Cursor in eine INetAttribut, dann wird das komplett
804 : : // geloescht; inclusive des Hinweistextes (wird beim Drag&Drop gebraucht)
805 : 0 : sal_Bool SwEditShell::DelINetAttrWithText()
806 : : {
807 : 0 : sal_Bool bRet = SelectTxtAttr( RES_TXTATR_INETFMT, sal_False );
808 [ # # ]: 0 : if( bRet )
809 : 0 : DeleteSel( *GetCrsr() );
810 : 0 : return bRet;
811 : : }
812 : :
813 : :
814 : : // setzen an den Textzeichenattributen das DontExpand-Flag
815 : 0 : sal_Bool SwEditShell::DontExpandFmt()
816 : : {
817 : 0 : sal_Bool bRet = sal_False;
818 [ # # ][ # # ]: 0 : if( !IsTableMode() && GetDoc()->DontExpandFmt( *GetCrsr()->GetPoint() ))
[ # # ]
819 : : {
820 : 0 : bRet = sal_True;
821 : 0 : CallChgLnk();
822 : : }
823 : 0 : return bRet;
824 : : }
825 : :
826 : 0 : SvNumberFormatter* SwEditShell::GetNumberFormatter()
827 : : {
828 : 0 : return GetDoc()->GetNumberFormatter();
829 : : }
830 : :
831 : 0 : sal_Bool SwEditShell::RemoveInvisibleContent()
832 : : {
833 : 0 : StartAllAction();
834 : 0 : sal_Bool bRet = GetDoc()->RemoveInvisibleContent();
835 : 0 : EndAllAction();
836 : 0 : return bRet;
837 : : }
838 : 0 : sal_Bool SwEditShell::ConvertFieldsToText()
839 : : {
840 : 0 : StartAllAction();
841 : 0 : sal_Bool bRet = GetDoc()->ConvertFieldsToText();
842 : 0 : EndAllAction();
843 : 0 : return bRet;
844 : : }
845 : 0 : void SwEditShell::SetNumberingRestart()
846 : : {
847 : 0 : StartAllAction();
848 : 0 : Push();
849 : : //iterate over all text contents - body, frames, header, footer, footnote text
850 : 0 : SwPaM* pCrsr = GetCrsr();
851 [ # # ]: 0 : for(sal_uInt16 i = 0; i < 2; i++)
852 : : {
853 [ # # ]: 0 : if(!i)
854 : 0 : MakeFindRange(DOCPOS_START, DOCPOS_END, pCrsr); //body content
855 : : else
856 : 0 : MakeFindRange(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, pCrsr); //extra content
857 : 0 : SwPosition* pSttPos = pCrsr->Start(), *pEndPos = pCrsr->End();
858 : 0 : sal_uLong nCurrNd = pSttPos->nNode.GetIndex();
859 : 0 : sal_uLong nEndNd = pEndPos->nNode.GetIndex();
860 [ # # ]: 0 : if( nCurrNd <= nEndNd )
861 : : {
862 : : SwCntntFrm* pCntFrm;
863 : 0 : sal_Bool bGoOn = sal_True;
864 : : //iterate over all paragraphs
865 [ # # ]: 0 : while( bGoOn )
866 : : {
867 : 0 : SwNode* pNd = GetDoc()->GetNodes()[ nCurrNd ];
868 [ # # # # ]: 0 : switch( pNd->GetNodeType() )
869 : : {
870 : : case ND_TEXTNODE:
871 [ # # ][ # # ]: 0 : if( 0 != ( pCntFrm = ((SwTxtNode*)pNd)->getLayoutFrm( GetLayout() )) )
872 : : {
873 : : //jump over hidden frames - ignore protection!
874 [ # # ]: 0 : if( !((SwTxtFrm*)pCntFrm)->IsHiddenNow() )
875 : : {
876 : : //if the node is numbered and the starting value of the numbering equals the
877 : : //start value of the numbering rule then set this value as hard starting value
878 : :
879 : : //get the node num
880 : : // OD 2005-11-09
881 [ # # ]: 0 : SwTxtNode* pTxtNd( static_cast<SwTxtNode*>(pNd) );
882 : 0 : SwNumRule* pNumRule( pTxtNd->GetNumRule() );
883 : :
884 [ # # # # : 0 : if ( pNumRule && pTxtNd->GetNum() &&
# # # # #
# # # ]
[ # # ][ # # ]
885 : 0 : ( pTxtNd->HasNumber() || pTxtNd->HasBullet() ) &&
886 : 0 : pTxtNd->IsCountedInList() &&
887 : 0 : !pTxtNd->IsListRestart() &&
888 : 0 : pTxtNd->GetNum()->GetNumber() ==
889 : 0 : pNumRule->Get( static_cast<sal_uInt16>(pTxtNd->GetActualListLevel()) ).GetStart() )
890 : : {
891 : : //now set a the start value as attribute
892 [ # # ]: 0 : SwPosition aCurrentNode(*pNd);
893 [ # # ][ # # ]: 0 : GetDoc()->SetNumRuleStart( aCurrentNode, sal_True );
894 : : }
895 : : }
896 : : }
897 : 0 : break;
898 : : case ND_SECTIONNODE:
899 : : // jump over hidden sections - ignore protection!
900 [ # # ]: 0 : if(((SwSectionNode*)pNd)->GetSection().IsHidden() )
901 : 0 : nCurrNd = pNd->EndOfSectionIndex();
902 : 0 : break;
903 : : case ND_ENDNODE:
904 : : {
905 : 0 : break;
906 : : }
907 : : }
908 : :
909 : 0 : bGoOn = nCurrNd < nEndNd;
910 : 0 : ++nCurrNd;
911 : : }
912 : : }
913 : : }
914 : :
915 : :
916 : 0 : Pop(sal_False);
917 : 0 : EndAllAction();
918 : 0 : }
919 : :
920 : 0 : sal_uInt16 SwEditShell::GetLineCount( sal_Bool bActPos )
921 : : {
922 : 0 : sal_uInt16 nRet = 0;
923 [ # # ]: 0 : CalcLayout();
924 [ # # ]: 0 : SwPaM* pPam = GetCrsr();
925 : 0 : SwNodeIndex& rPtIdx = pPam->GetPoint()->nNode;
926 [ # # ]: 0 : SwNodeIndex aStart( rPtIdx );
927 : : SwCntntNode* pCNd;
928 : 0 : SwCntntFrm *pCntFrm = 0;
929 : : sal_uLong nTmpPos;
930 : :
931 [ # # ]: 0 : if( !bActPos )
932 [ # # ]: 0 : aStart = 0;
933 [ # # ][ # # ]: 0 : else if( rPtIdx > ( nTmpPos = GetDoc()->GetNodes().GetEndOfExtras().GetIndex()) )
934 : : // BodyBereich => Start ist EndOfIcons + 1
935 [ # # ]: 0 : aStart = nTmpPos + 1;
936 : : else
937 : : {
938 [ # # ][ # # ]: 0 : if( 0 != ( pCNd = pPam->GetCntntNode() ) &&
[ # # ][ # # ]
939 [ # # ]: 0 : 0 != ( pCntFrm = pCNd->getLayoutFrm( GetLayout() ) ) )
940 : : {
941 : : const SwStartNode *pTmp;
942 [ # # ][ # # ]: 0 : if( pCntFrm->IsInFly() ) // Fly
943 [ # # ]: 0 : pTmp = pCNd->FindFlyStartNode();
944 [ # # ][ # # ]: 0 : else if( pCntFrm->IsInFtn() ) // Footnote
945 [ # # ]: 0 : pTmp = pCNd->FindFootnoteStartNode();
946 : : else
947 : : { // Footer/Header
948 : 0 : const sal_uInt16 nTyp = FRM_HEADER | FRM_FOOTER;
949 : 0 : SwFrm* pFrm = pCntFrm;
950 [ # # ][ # # ]: 0 : while( pFrm && !(pFrm->GetType() & nTyp) )
[ # # ]
951 : 0 : pFrm = pFrm->GetUpper();
952 : : OSL_ENSURE( pFrm, "Wo bin ich?" );
953 [ # # ][ # # ]: 0 : if( pFrm && ( pFrm->GetType() & FRM_FOOTER ) )
[ # # ]
954 [ # # ]: 0 : pTmp = pCNd->FindFooterStartNode();
955 : : else
956 [ # # ]: 0 : pTmp = pCNd->FindHeaderStartNode();
957 : : }
958 : : OSL_ENSURE( pTmp, "Missing StartNode" );
959 [ # # ]: 0 : aStart = *pTmp;
960 : : }
961 : : OSL_ENSURE( pCNd && pCntFrm, "Missing Layout-Information" );
962 : : }
963 : :
964 [ # # ][ # # ]: 0 : while( 0 != ( pCNd = GetDoc()->GetNodes().GoNextSection(
[ # # ]
[ # # # # ]
[ # # ]
965 : 0 : &aStart, sal_True, sal_False )) && ( !bActPos || aStart <= rPtIdx ) )
966 : : {
967 [ # # ][ # # ]: 0 : if( 0 != ( pCntFrm = pCNd->getLayoutFrm( GetLayout() ) ) && pCntFrm->IsTxtFrm() )
[ # # ][ # # ]
[ # # ]
968 : : {
969 : 0 : xub_StrLen nActPos = bActPos && aStart == rPtIdx ?
970 [ # # # # ]: 0 : pPam->GetPoint()->nContent.GetIndex() : USHRT_MAX;
971 [ # # ]: 0 : nRet = nRet + ((SwTxtFrm*)pCntFrm)->GetLineCount( nActPos );
972 : : }
973 : : }
974 [ # # ]: 0 : return nRet;
975 : : }
976 : :
977 : 0 : long SwEditShell::CompareDoc( const SwDoc& rDoc )
978 : : {
979 : 0 : StartAllAction();
980 : 0 : long nRet = GetDoc()->CompareDoc( rDoc );
981 : 0 : EndAllAction();
982 : 0 : return nRet;
983 : : }
984 : :
985 : 0 : long SwEditShell::MergeDoc( const SwDoc& rDoc )
986 : : {
987 : 0 : StartAllAction();
988 : 0 : long nRet = GetDoc()->MergeDoc( rDoc );
989 : 0 : EndAllAction();
990 : 0 : return nRet;
991 : : }
992 : :
993 : :
994 : 0 : const SwFtnInfo& SwEditShell::GetFtnInfo() const
995 : : {
996 : 0 : return GetDoc()->GetFtnInfo();
997 : : }
998 : :
999 : 0 : void SwEditShell::SetFtnInfo(const SwFtnInfo& rInfo)
1000 : : {
1001 [ # # ]: 0 : StartAllAction();
1002 [ # # ]: 0 : SET_CURR_SHELL( this );
1003 [ # # ]: 0 : GetDoc()->SetFtnInfo(rInfo);
1004 [ # # ]: 0 : CallChgLnk();
1005 [ # # ][ # # ]: 0 : EndAllAction();
1006 : 0 : }
1007 : :
1008 : 0 : const SwEndNoteInfo& SwEditShell::GetEndNoteInfo() const
1009 : : {
1010 : 0 : return GetDoc()->GetEndNoteInfo();
1011 : : }
1012 : :
1013 : 0 : void SwEditShell::SetEndNoteInfo(const SwEndNoteInfo& rInfo)
1014 : : {
1015 [ # # ]: 0 : StartAllAction();
1016 [ # # ]: 0 : SET_CURR_SHELL( this );
1017 [ # # ]: 0 : GetDoc()->SetEndNoteInfo(rInfo);
1018 [ # # ][ # # ]: 0 : EndAllAction();
1019 : 0 : }
1020 : :
1021 : 0 : const SwLineNumberInfo& SwEditShell::GetLineNumberInfo() const
1022 : : {
1023 : 0 : return GetDoc()->GetLineNumberInfo();
1024 : : }
1025 : :
1026 : 0 : void SwEditShell::SetLineNumberInfo(const SwLineNumberInfo& rInfo)
1027 : : {
1028 [ # # ]: 0 : StartAllAction();
1029 [ # # ]: 0 : SET_CURR_SHELL( this );
1030 [ # # ]: 0 : GetDoc()->SetLineNumberInfo(rInfo);
1031 [ # # ][ # # ]: 0 : AddPaintRect( GetLayout()->Frm() );
1032 [ # # ][ # # ]: 0 : EndAllAction();
1033 : 0 : }
1034 : :
1035 : 0 : sal_uInt16 SwEditShell::GetLinkUpdMode(sal_Bool bDocSettings) const
1036 : : {
1037 : 0 : return getIDocumentSettingAccess()->getLinkUpdateMode( !bDocSettings );
1038 : : }
1039 : :
1040 : 0 : void SwEditShell::SetLinkUpdMode( sal_uInt16 nMode )
1041 : : {
1042 : 0 : getIDocumentSettingAccess()->setLinkUpdateMode( nMode );
1043 : 0 : }
1044 : :
1045 : :
1046 : : // Schnittstelle fuer die TextInputDaten - ( fuer die Texteingabe
1047 : : // von japanischen/chinesischen Zeichen)
1048 : 0 : SwExtTextInput* SwEditShell::CreateExtTextInput(LanguageType eInputLanguage)
1049 : : {
1050 : 0 : SwExtTextInput* pRet = GetDoc()->CreateExtTextInput( *GetCrsr() );
1051 : 0 : pRet->SetLanguage(eInputLanguage);
1052 : 0 : pRet->SetOverwriteCursor( SwCrsrShell::IsOverwriteCrsr() );
1053 : 0 : return pRet;
1054 : : }
1055 : :
1056 : 0 : String SwEditShell::DeleteExtTextInput( SwExtTextInput* pDel, sal_Bool bInsText )
1057 : : {
1058 [ # # ]: 0 : if( !pDel )
1059 : : {
1060 : 0 : const SwPosition& rPos = *GetCrsr()->GetPoint();
1061 : 0 : pDel = GetDoc()->GetExtTextInput( rPos.nNode.GetNode(),
1062 : 0 : rPos.nContent.GetIndex() );
1063 [ # # ]: 0 : if( !pDel )
1064 : : {
1065 : : //JP 25.10.2001: under UNIX the cursor is moved before the Input-
1066 : : // Engine event comes in. So take any - normally there
1067 : : // exist only one at the time. -- Task 92016
1068 : 0 : pDel = GetDoc()->GetExtTextInput();
1069 : : }
1070 : : }
1071 : 0 : String sRet;
1072 [ # # ]: 0 : if( pDel )
1073 : : {
1074 : 0 : rtl::OUString sTmp;
1075 [ # # ]: 0 : SwUnoCursorHelper::GetTextFromPam(*pDel, sTmp);
1076 [ # # ]: 0 : sRet = sTmp;
1077 [ # # ]: 0 : SET_CURR_SHELL( this );
1078 [ # # ]: 0 : StartAllAction();
1079 : 0 : pDel->SetInsText( bInsText );
1080 : 0 : SetOverwriteCrsr( pDel->IsOverwriteCursor() );
1081 [ # # ]: 0 : const SwPosition aPos( *pDel->GetPoint() );
1082 [ # # ]: 0 : GetDoc()->DeleteExtTextInput( pDel );
1083 : :
1084 : : // In this case, the "replace" function did not set the cursor
1085 : : // to the original position. Therefore we have to do this manually.
1086 [ # # ][ # # ]: 0 : if ( ! bInsText && IsOverwriteCrsr() )
[ # # ]
1087 [ # # ][ # # ]: 0 : *GetCrsr()->GetPoint() = aPos;
1088 : :
1089 [ # # ][ # # ]: 0 : EndAllAction();
[ # # ]
1090 : : }
1091 : 0 : return sRet;
1092 : : }
1093 : :
1094 : 0 : void SwEditShell::SetExtTextInputData( const CommandExtTextInputData& rData )
1095 : : {
1096 : 0 : const SwPosition& rPos = *GetCrsr()->GetPoint();
1097 : 0 : SwExtTextInput* pInput = GetDoc()->GetExtTextInput( rPos.nNode.GetNode()
1098 : 0 : /*, rPos.nContent.GetIndex()*/ );
1099 [ # # ]: 0 : if( pInput )
1100 : : {
1101 [ # # ]: 0 : StartAllAction();
1102 [ # # ]: 0 : SET_CURR_SHELL( this );
1103 : :
1104 [ # # ]: 0 : if( !rData.IsOnlyCursorChanged() )
1105 [ # # ]: 0 : pInput->SetInputData( rData );
1106 : : // Cursor positionieren:
1107 [ # # ]: 0 : const SwPosition& rStt = *pInput->Start();
1108 : 0 : xub_StrLen nNewCrsrPos = rStt.nContent.GetIndex() + rData.GetCursorPos();
1109 : :
1110 : : // zwar unschoen aber was hilfts
1111 [ # # ]: 0 : ShowCrsr();
1112 : 0 : long nDiff = nNewCrsrPos - rPos.nContent.GetIndex();
1113 [ # # ]: 0 : if( 0 > nDiff )
1114 [ # # ]: 0 : Left( (xub_StrLen)-nDiff, CRSR_SKIP_CHARS );
1115 [ # # ]: 0 : else if( 0 < nDiff )
1116 [ # # ]: 0 : Right( (xub_StrLen)nDiff, CRSR_SKIP_CHARS );
1117 : :
1118 : 0 : SetOverwriteCrsr( rData.IsCursorOverwrite() );
1119 : :
1120 [ # # ]: 0 : EndAllAction();
1121 : :
1122 [ # # ]: 0 : if( !rData.IsCursorVisible() ) // must be called after the EndAction
1123 [ # # ][ # # ]: 0 : HideCrsr();
1124 : : }
1125 : 0 : }
1126 : :
1127 : 0 : void SwEditShell::TransliterateText( sal_uInt32 nType )
1128 : : {
1129 [ # # ][ # # ]: 0 : utl::TransliterationWrapper aTrans( ::comphelper::getProcessServiceFactory(), nType );
1130 [ # # ]: 0 : StartAllAction();
1131 [ # # ]: 0 : SET_CURR_SHELL( this );
1132 : :
1133 [ # # ]: 0 : SwPaM* pCrsr = GetCrsr();
1134 [ # # ]: 0 : if( pCrsr->GetNext() != pCrsr )
1135 : : {
1136 [ # # ][ # # ]: 0 : GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
1137 [ # # ][ # # ]: 0 : FOREACHPAM_START( this )
1138 : :
1139 [ # # ]: 0 : if( PCURCRSR->HasMark() )
1140 [ # # ]: 0 : GetDoc()->TransliterateText( *PCURCRSR, aTrans );
1141 : :
1142 : 0 : FOREACHPAM_END()
1143 [ # # ][ # # ]: 0 : GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
1144 : : }
1145 : : else
1146 [ # # ]: 0 : GetDoc()->TransliterateText( *pCrsr, aTrans );
1147 : :
1148 [ # # ][ # # ]: 0 : EndAllAction();
[ # # ]
1149 : 0 : }
1150 : :
1151 : 1360 : void SwEditShell::CountWords( SwDocStat& rStat ) const
1152 : : {
1153 [ + + ]: 2732 : FOREACHPAM_START( this )
1154 : :
1155 [ + + ]: 1372 : if( PCURCRSR->HasMark() )
1156 : 16 : GetDoc()->CountWords( *PCURCRSR, rStat );
1157 : :
1158 : 1372 : FOREACHPAM_END()
1159 : 1360 : }
1160 : :
1161 : 222 : void SwEditShell::ApplyViewOptions( const SwViewOption &rOpt )
1162 : : {
1163 : 222 : SwCrsrShell::StartAction();
1164 : 222 : ViewShell::ApplyViewOptions( rOpt );
1165 : 222 : SwEditShell::EndAction();
1166 : 222 : }
1167 : :
1168 : :
1169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|