xref: /trunk/main/editeng/source/editeng/editdbg.cxx (revision 8dc46c98)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_editeng.hxx"
26 
27 #include <vcl/wrkwin.hxx>
28 #include <vcl/dialog.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <vcl/svapp.hxx>
31 
32 #include <editeng/lspcitem.hxx>
33 #include <editeng/lrspitem.hxx>
34 #include <editeng/ulspitem.hxx>
35 #include <editeng/cntritem.hxx>
36 #include <editeng/colritem.hxx>
37 #include <editeng/fhgtitem.hxx>
38 #include <editeng/fontitem.hxx>
39 #include <editeng/adjitem.hxx>
40 #include <editeng/wghtitem.hxx>
41 #include <editeng/postitem.hxx>
42 #include <editeng/udlnitem.hxx>
43 #include <editeng/crsditem.hxx>
44 #include <editeng/shdditem.hxx>
45 #include <editeng/escpitem.hxx>
46 #include <editeng/kernitem.hxx>
47 #include <editeng/wrlmitem.hxx>
48 #include <editeng/akrnitem.hxx>
49 #include <editeng/langitem.hxx>
50 #include <editeng/emphitem.hxx>
51 #include <editeng/numitem.hxx>
52 #include <editeng/tstpitem.hxx>
53 #include <editeng/charscaleitem.hxx>
54 #include <editeng/charreliefitem.hxx>
55 #include <editeng/frmdiritem.hxx>
56 
57 #include <impedit.hxx>
58 #include <editeng/editeng.hxx>
59 #include <editeng/editview.hxx>
60 #include <editdoc.hxx>
61 #include <editdbg.hxx>
62 
63 #if defined( DBG_UTIL ) || ( OSL_DEBUG_LEVEL > 1 )
64 
DbgOutItem(const SfxItemPool & rPool,const SfxPoolItem & rItem)65 ByteString DbgOutItem( const SfxItemPool& rPool, const SfxPoolItem& rItem )
66 {
67 	ByteString aDebStr;
68 	switch ( rItem.Which() )
69 	{
70         case EE_PARA_WRITINGDIR:
71 			aDebStr += "WritingDir=";
72 			aDebStr += ByteString::CreateFromInt32( ((SvxFrameDirectionItem&)rItem).GetValue() );
73         break;
74 		case EE_PARA_OUTLLRSPACE:
75 		case EE_PARA_LRSPACE:
76 			aDebStr += "FI=";
77 			aDebStr += ByteString::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetTxtFirstLineOfst() );
78 			aDebStr += ", LI=";
79 			aDebStr += ByteString::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetTxtLeft() );
80 			aDebStr += ", RI=";
81 			aDebStr += ByteString::CreateFromInt32( ((SvxLRSpaceItem&)rItem).GetRight() );
82 		break;
83 		case EE_PARA_NUMBULLET:
84 			{
85 			aDebStr += "NumItem ";
86 			for ( sal_uInt16 nLevel = 0; nLevel < 3; nLevel++ )
87 			{
88 				aDebStr += "Level";
89 				aDebStr += ByteString::CreateFromInt32( nLevel );
90 				aDebStr += "=";
91 				const SvxNumberFormat* pFmt = ((const SvxNumBulletItem&)rItem).GetNumRule()->Get( nLevel );
92 				if ( pFmt )
93 				{
94 					aDebStr += "(";
95 					aDebStr += ByteString::CreateFromInt32( pFmt->GetFirstLineOffset() );
96 					aDebStr += ",";
97 					aDebStr += ByteString::CreateFromInt32( pFmt->GetAbsLSpace() );
98 					aDebStr += ",";
99 					if ( pFmt->GetNumberingType() == SVX_NUM_BITMAP )
100 					{
101 						aDebStr += "Bitmap";
102 					}
103 					else if( pFmt->GetNumberingType() != SVX_NUM_CHAR_SPECIAL )
104 					{
105 						aDebStr += "Number";
106 					}
107 					else
108 					{
109 						aDebStr += "Char=[";
110 						aDebStr += ByteString::CreateFromInt32( pFmt->GetBulletChar() );
111 						aDebStr += "]";
112 					}
113 					aDebStr += ") ";
114 				}
115 			}
116 			}
117 		break;
118 		case EE_PARA_BULLETSTATE:
119 			aDebStr += "ShowBullet=";
120 			aDebStr += ByteString::CreateFromInt32( ((SfxBoolItem&)rItem).GetValue() );
121 		break;
122 		case EE_PARA_HYPHENATE:
123 			aDebStr += "Hyphenate=";
124 			aDebStr += ByteString::CreateFromInt32( ((SfxBoolItem&)rItem).GetValue() );
125 		break;
126 		case EE_PARA_OUTLLEVEL:
127 			aDebStr += "Level=";
128 			aDebStr += ByteString::CreateFromInt32( ((SfxInt16Item&)rItem).GetValue() );
129 		break;
130 		case EE_PARA_ULSPACE:
131 			aDebStr += "SB=";
132 			aDebStr += ByteString::CreateFromInt32( ((SvxULSpaceItem&)rItem).GetUpper() );
133 			aDebStr += ", SA=";
134 			aDebStr += ByteString::CreateFromInt32( ((SvxULSpaceItem&)rItem).GetLower() );
135 		break;
136 		case EE_PARA_SBL:
137 			aDebStr += "SBL=";
138 			if ( ((SvxLineSpacingItem&)rItem).GetLineSpaceRule() == SVX_LINE_SPACE_MIN )
139 			{
140 				aDebStr += "Min: ";
141 				aDebStr += ByteString::CreateFromInt32( ((SvxLineSpacingItem&)rItem).GetInterLineSpace() );
142 			}
143 			else if ( ((SvxLineSpacingItem&)rItem).GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP )
144 			{
145 				aDebStr += "Prop: ";
146 				aDebStr += ByteString::CreateFromInt32( (sal_uLong)((SvxLineSpacingItem&)rItem).GetPropLineSpace() );
147 			}
148 			else
149 				aDebStr += "Unsupported Type!";
150 		break;
151 		case EE_PARA_JUST:
152 			aDebStr += "SvxAdust=";
153 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxAdjustItem&)rItem).GetAdjust() );
154 		break;
155 		case EE_PARA_TABS:
156         {
157 			aDebStr += "Tabs: ";
158 	        const SvxTabStopItem& rTabs = (const SvxTabStopItem&) rItem;
159             aDebStr += ByteString::CreateFromInt32( rTabs.Count() );
160             if ( rTabs.Count() )
161             {
162 			    aDebStr += "( ";
163 	            for ( sal_uInt16 i = 0; i < rTabs.Count(); i++ )
164 	            {
165 		            const SvxTabStop& rTab = rTabs[i];
166                     aDebStr += ByteString::CreateFromInt32( rTab.GetTabPos() );
167 			        aDebStr += " ";
168 	            }
169 			    aDebStr += ")";
170             }
171         }
172 		break;
173 		case EE_CHAR_LANGUAGE:
174 		case EE_CHAR_LANGUAGE_CJK:
175 		case EE_CHAR_LANGUAGE_CTL:
176 			aDebStr += "Language=";
177 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxLanguageItem&)rItem).GetLanguage() );
178 		break;
179 		case EE_CHAR_COLOR:
180 		{
181 			aDebStr += "Color= ";
182 			Color aColor( ((SvxColorItem&)rItem).GetValue() );
183 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)aColor.GetRed() );
184 			aDebStr += ", ";
185 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)aColor.GetGreen() );
186 			aDebStr += ", ";
187 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)aColor.GetBlue() );
188 		}
189 		break;
190 		case EE_CHAR_FONTINFO:
191 		case EE_CHAR_FONTINFO_CJK:
192 		case EE_CHAR_FONTINFO_CTL:
193 		{
194 			aDebStr += "Font=";
195 			aDebStr += ByteString( ((SvxFontItem&)rItem).GetFamilyName(), RTL_TEXTENCODING_ASCII_US );
196 			aDebStr += " (CharSet: ";
197 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxFontItem&)rItem).GetCharSet() );
198 			aDebStr += ')';
199 		}
200 		break;
201 		case EE_CHAR_FONTHEIGHT:
202 		case EE_CHAR_FONTHEIGHT_CJK:
203 		case EE_CHAR_FONTHEIGHT_CTL:
204 		{
205 			aDebStr += "Groesse=";
206 			aDebStr += ByteString::CreateFromInt32( ((SvxFontHeightItem&)rItem).GetHeight() );
207 			Size aSz( 0, ((SvxFontHeightItem&)rItem).GetHeight() );
208 			SfxMapUnit eUnit = rPool.GetMetric( rItem.Which() );
209 			MapMode aItemMapMode( (MapUnit) eUnit );
210 			MapMode aPntMap( MAP_POINT );
211 			aSz = OutputDevice::LogicToLogic( aSz, aItemMapMode, aPntMap );
212 			aDebStr += " Points=";
213 			aDebStr += ByteString::CreateFromInt32( aSz.Height() );
214 		}
215 		break;
216 		case EE_CHAR_FONTWIDTH:
217 		{
218 			aDebStr += "Breite=";
219 			aDebStr += ByteString::CreateFromInt32( ((SvxCharScaleWidthItem&)rItem).GetValue() );
220 			aDebStr += "%";
221 		}
222 		break;
223 		case EE_CHAR_WEIGHT:
224 		case EE_CHAR_WEIGHT_CJK:
225 		case EE_CHAR_WEIGHT_CTL:
226 			aDebStr += "FontWeight=";
227 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxWeightItem&)rItem).GetWeight() );
228 		break;
229 		case EE_CHAR_UNDERLINE:
230 			aDebStr += "FontUnderline=";
231 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxUnderlineItem&)rItem).GetLineStyle() );
232 		break;
233 		case EE_CHAR_OVERLINE:
234 			aDebStr += "FontOverline=";
235 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxOverlineItem&)rItem).GetLineStyle() );
236 		break;
237 		case EE_CHAR_EMPHASISMARK:
238 			aDebStr += "FontUnderline=";
239 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxEmphasisMarkItem&)rItem).GetEmphasisMark() );
240 		break;
241 		case EE_CHAR_RELIEF:
242 			aDebStr += "FontRelief=";
243 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxCharReliefItem&)rItem).GetValue() );
244 		break;
245 		case EE_CHAR_STRIKEOUT:
246 			aDebStr += "FontStrikeout=";
247 			aDebStr +=ByteString::CreateFromInt32(  (sal_uInt16)((SvxCrossedOutItem&)rItem).GetStrikeout() );
248 		break;
249 		case EE_CHAR_ITALIC:
250 		case EE_CHAR_ITALIC_CJK:
251 		case EE_CHAR_ITALIC_CTL:
252 			aDebStr += "FontPosture=";
253 			aDebStr +=ByteString::CreateFromInt32(  (sal_uInt16)((SvxPostureItem&)rItem).GetPosture() );
254 		break;
255 		case EE_CHAR_OUTLINE:
256 			aDebStr += "FontOutline=";
257 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxContourItem&)rItem).GetValue() );
258 		break;
259 		case EE_CHAR_SHADOW:
260 			aDebStr += "FontShadowed=";
261 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxShadowedItem&)rItem).GetValue() );
262 		break;
263 		case EE_CHAR_ESCAPEMENT:
264 			aDebStr += "Escape=";
265 			aDebStr += ByteString::CreateFromInt32( (short)((SvxEscapementItem&)rItem).GetEsc() );
266 			aDebStr += ", ";
267 			aDebStr += ByteString::CreateFromInt32( (short)((SvxEscapementItem&)rItem).GetProp() );
268 		break;
269 		case EE_CHAR_PAIRKERNING:
270 			aDebStr += "PairKerning=";
271 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxAutoKernItem&)rItem).GetValue() );
272 		break;
273 		case EE_CHAR_KERNING:
274 		{
275 			aDebStr += "Kerning=";
276 			aDebStr += ByteString::CreateFromInt32( (short)((SvxKerningItem&)rItem).GetValue() );
277 			Size aSz( 0, (short)((SvxKerningItem&)rItem).GetValue() );
278 			SfxMapUnit eUnit = rPool.GetMetric( rItem.Which() );
279 			MapMode aItemMapMode( (MapUnit) eUnit );
280 			MapMode aPntMap( MAP_POINT );
281 			aSz = OutputDevice::LogicToLogic( aSz, aItemMapMode, aPntMap );
282 			aDebStr += " Points=";
283 			aDebStr += ByteString::CreateFromInt32( aSz.Height() );
284 		}
285 		break;
286 		case EE_CHAR_WLM:
287 			aDebStr += "WordLineMode=";
288 			aDebStr += ByteString::CreateFromInt32( (sal_uInt16)((SvxWordLineModeItem&)rItem).GetValue() );
289 		break;
290 		case EE_CHAR_XMLATTRIBS:
291 			aDebStr += "XMLAttribs=...";
292 		break;
293 	}
294 	return aDebStr;
295 }
296 
DbgOutItemSet(FILE * fp,const SfxItemSet & rSet,sal_Bool bSearchInParent,sal_Bool bShowALL)297 void DbgOutItemSet( FILE* fp, const SfxItemSet& rSet, sal_Bool bSearchInParent, sal_Bool bShowALL )
298 {
299 	for ( sal_uInt16 nWhich = EE_PARA_START; nWhich <= EE_CHAR_END; nWhich++ )
300 	{
301 		fprintf( fp, "\nWhich: %i\t", nWhich );
302 		if ( rSet.GetItemState( nWhich, bSearchInParent ) == SFX_ITEM_OFF )
303 			fprintf( fp, "ITEM_OFF   " );
304 		else if ( rSet.GetItemState( nWhich, bSearchInParent ) == SFX_ITEM_DONTCARE )
305 			fprintf( fp, "ITEM_DC    " );
306 		else if ( rSet.GetItemState( nWhich, bSearchInParent ) == SFX_ITEM_ON )
307 			fprintf( fp, "ITEM_ON   *" );
308 
309 		if ( !bShowALL && ( rSet.GetItemState( nWhich, bSearchInParent ) != SFX_ITEM_ON ) )
310 			continue;
311 
312 		const SfxPoolItem& rItem = rSet.Get( nWhich, bSearchInParent );
313 		ByteString aDebStr = DbgOutItem( *rSet.GetPool(), rItem );
314 		fprintf( fp, "%s", aDebStr.GetBuffer() );
315 	}
316 }
317 
ShowEditEngineData(EditEngine * pEE,sal_Bool bInfoBox)318 void EditDbg::ShowEditEngineData( EditEngine* pEE, sal_Bool bInfoBox )
319 {
320 #if defined UNX
321 	FILE* fp = fopen( "/tmp/debug.log", "w" );
322 #else
323 	FILE* fp = fopen( "d:\\debug.log", "w" );
324 #endif
325 	if ( fp == 0 )
326 	{
327 		DBG_ERROR( "Log-File konnte nicht angelegt werden!" );
328 		return;
329 	}
330 
331 	const SfxItemPool& rPool = *pEE->GetEmptyItemSet().GetPool();
332 
333 	fprintf( fp, "================================================================================" );
334 	fprintf( fp, "\n==================   Dokument   ================================================" );
335 	fprintf( fp, "\n================================================================================" );
336 	for ( sal_uInt32 nPortion = 0; nPortion < pEE->pImpEditEngine->GetParaPortions(). Count(); nPortion++)
337 	{
338 
339 		ParaPortion* pPPortion = pEE->pImpEditEngine->GetParaPortions().GetObject(nPortion );
340 		fprintf( fp, "\nAbsatz %i: Laenge = %i, Invalid = %i\nText = '%s'", nPortion, pPPortion->GetNode()->Len(), pPPortion->IsInvalid(), ByteString( *pPPortion->GetNode(), RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
341 		fprintf( fp, "\nVorlage:" );
342 		SfxStyleSheet* pStyle = pPPortion->GetNode()->GetStyleSheet();
343 		if ( pStyle )
344 			fprintf( fp, " %s", ByteString( pStyle->GetName(), RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
345 		fprintf( fp, "\nAbsatzattribute:" );
346 		DbgOutItemSet( fp, pPPortion->GetNode()->GetContentAttribs().GetItems(), sal_False, sal_False );
347 
348 		fprintf( fp, "\nZeichenattribute:" );
349 		sal_Bool bZeroAttr = sal_False;
350 		sal_uInt16 z;
351 		for ( z = 0; z < pPPortion->GetNode()->GetCharAttribs().Count(); z++ )
352 		{
353 			EditCharAttrib* pAttr = pPPortion->GetNode()->GetCharAttribs().GetAttribs().GetObject( z );
354 			ByteString aCharAttribs;
355 			aCharAttribs += "\nA";
356 			aCharAttribs += ByteString::CreateFromInt32( nPortion );
357 			aCharAttribs += ":  ";
358 			aCharAttribs += ByteString::CreateFromInt32( pAttr->GetItem()->Which() );
359 			aCharAttribs += '\t';
360 			aCharAttribs += ByteString::CreateFromInt32( pAttr->GetStart() );
361 			aCharAttribs += '\t';
362 			aCharAttribs += ByteString::CreateFromInt32( pAttr->GetEnd() );
363 			if ( pAttr->IsEmpty() )
364 				bZeroAttr = sal_True;
365 			fprintf( fp, "%s => ", aCharAttribs.GetBuffer() );
366 
367 			ByteString aDebStr = DbgOutItem( rPool, *pAttr->GetItem() );
368 			fprintf( fp, "%s", aDebStr.GetBuffer() );
369 		}
370 		if ( bZeroAttr )
371 			fprintf( fp, "\nNULL-Attribute!" );
372 
373 		sal_uInt16 nTextPortions = pPPortion->GetTextPortions().Count();
374 		ByteString aPortionStr("\nTextportions: #");
375 		aPortionStr += ByteString::CreateFromInt32( nTextPortions );
376 		aPortionStr += " \nA";
377 		aPortionStr += ByteString::CreateFromInt32( nPortion );
378 		aPortionStr += ": Absatzlaenge = ";
379 		aPortionStr += ByteString::CreateFromInt32( pPPortion->GetNode()->Len() );
380 		aPortionStr += "\nA";
381 		aPortionStr += ByteString::CreateFromInt32( nPortion );
382 		aPortionStr += ": ";
383 		sal_uLong n = 0;
384 		for ( z = 0; z < nTextPortions; z++ )
385 		{
386 			TextPortion* pPortion = pPPortion->GetTextPortions().GetObject( z );
387 			aPortionStr += " ";
388 			aPortionStr += ByteString::CreateFromInt32( pPortion->GetLen() );
389 			aPortionStr += "(";
390 			aPortionStr += ByteString::CreateFromInt32( pPortion->GetSize().Width() );
391 			aPortionStr += ")";
392 			aPortionStr += "[";
393 			aPortionStr += ByteString::CreateFromInt32( (sal_uInt16)pPortion->GetKind() );
394 			aPortionStr += "]";
395 			aPortionStr += ";";
396 			n += pPortion->GetLen();
397 		}
398 		aPortionStr += "\nA";
399 		aPortionStr += ByteString::CreateFromInt32( nPortion );
400 		aPortionStr += ": Gesamtlaenge: ";
401 		aPortionStr += ByteString::CreateFromInt32( n );
402 		if ( pPPortion->GetNode()->Len() != n )
403 			aPortionStr += " => Fehler !!!";
404 		fprintf( fp, "%s", aPortionStr.GetBuffer() );
405 
406 
407 		fprintf( fp, "\n\nZeilen:" );
408 		// Erstmal die Inhalte...
409 		sal_uInt16 nLine;
410 		for ( nLine = 0; nLine < pPPortion->GetLines().Count(); nLine++ )
411 		{
412 			EditLine* pLine = pPPortion->GetLines().GetObject( nLine );
413 
414 			ByteString aLine( *(pPPortion->GetNode()), pLine->GetStart(), pLine->GetEnd() - pLine->GetStart(), RTL_TEXTENCODING_ASCII_US );
415 			fprintf( fp, "\nZeile %i\t>%s<", nLine, aLine.GetBuffer() );
416 		}
417 		// dann die internen Daten...
418 		for ( nLine = 0; nLine < pPPortion->GetLines().Count(); nLine++ )
419 		{
420 			EditLine* pLine = pPPortion->GetLines().GetObject( nLine );
421 			fprintf( fp, "\nZeile %i:\tStart: %i,\tEnd: %i", nLine, pLine->GetStart(), pLine->GetEnd() );
422 			fprintf( fp, "\t\tPortions: %i - %i.\tHoehe: %i, Ascent=%i", pLine->GetStartPortion(), pLine->GetEndPortion(), pLine->GetHeight(), pLine->GetMaxAscent() );
423 		}
424 
425 		fprintf( fp, "\n-----------------------------------------------------------------------------" );
426 	}
427 
428 	if ( pEE->pImpEditEngine->GetStyleSheetPool() )
429 	{
430 		sal_uLong nStyles = pEE->pImpEditEngine->GetStyleSheetPool() ? pEE->pImpEditEngine->GetStyleSheetPool()->Count() : 0;
431 		fprintf( fp, "\n\n================================================================================" );
432 		fprintf( fp, "\n==================   Stylesheets   =============================================" );
433 		fprintf( fp, "\n================================================================================" );
434 		fprintf( fp, "\n#Vorlagen:   %lu\n", nStyles );
435 		SfxStyleSheetIterator aIter( pEE->pImpEditEngine->GetStyleSheetPool(), SFX_STYLE_FAMILY_ALL );
436 		SfxStyleSheetBase* pStyle = aIter.First();
437 		while ( pStyle )
438 		{
439 			fprintf( fp, "\nVorlage:   %s", ByteString( pStyle->GetName(), RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
440 			fprintf( fp, "\nParent:    %s", ByteString( pStyle->GetParent(), RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
441 			fprintf( fp, "\nFollow:    %s", ByteString( pStyle->GetFollow(), RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
442 			DbgOutItemSet( fp, pStyle->GetItemSet(), sal_False, sal_False );
443 			fprintf( fp, "\n----------------------------------" );
444 
445 			pStyle = aIter.Next();
446 		}
447 	}
448 
449 	fprintf( fp, "\n\n================================================================================" );
450 	fprintf( fp, "\n==================   Defaults   ================================================" );
451 	fprintf( fp, "\n================================================================================" );
452 	DbgOutItemSet( fp, pEE->pImpEditEngine->GetEmptyItemSet(), sal_True, sal_True );
453 
454 	fprintf( fp, "\n\n================================================================================" );
455 	fprintf( fp, "\n==================   EditEngine & Views   ======================================" );
456 	fprintf( fp, "\n================================================================================" );
457 	fprintf( fp, "\nControl: %" SAL_PRIxUINT32, pEE->GetControlWord() );
458 	fprintf( fp, "\nRefMapMode: %i", pEE->pImpEditEngine->pRefDev->GetMapMode().GetMapUnit() );
459 	fprintf( fp, "\nPaperSize: %li x %li", pEE->GetPaperSize().Width(), pEE->GetPaperSize().Height() );
460 	fprintf( fp, "\nMaxAutoPaperSize: %li x %li", pEE->GetMaxAutoPaperSize().Width(), pEE->GetMaxAutoPaperSize().Height() );
461 	fprintf( fp, "\nMinAutoPaperSize: %li x %li", pEE->GetMinAutoPaperSize().Width(), pEE->GetMinAutoPaperSize().Height() );
462 	fprintf( fp, "\nUpdate: %i", pEE->GetUpdateMode() );
463 	fprintf( fp, "\nAnzahl der Views: %i", pEE->GetViewCount() );
464 	for	( sal_uInt16 nView = 0; nView < pEE->GetViewCount(); nView++ )
465 	{
466 		EditView* pV = pEE->GetView( nView );
467 		DBG_ASSERT( pV, "View nicht gefunden!" );
468 		fprintf( fp, "\nView %i: Focus=%i", nView, pV->GetWindow()->HasFocus() );
469 		Rectangle aR( pV->GetOutputArea() );
470 		fprintf( fp, "\n  OutputArea: nX=%li, nY=%li, dX=%li, dY=%li, MapMode = %i", aR.TopLeft().X(), aR.TopLeft().Y(), aR.GetSize().Width(), aR.GetSize().Height() , pV->GetWindow()->GetMapMode().GetMapUnit() );
471 		aR = pV->GetVisArea();
472 		fprintf( fp, "\n  VisArea: nX=%li, nY=%li, dX=%li, dY=%li", aR.TopLeft().X(), aR.TopLeft().Y(), aR.GetSize().Width(), aR.GetSize().Height() );
473 		ESelection aSel = pV->GetSelection();
474 		fprintf( fp, "\n  Selektion: Start=%u,%u, End=%u,%u", aSel.nStartPara, aSel.nStartPos, aSel.nEndPara, aSel.nEndPos );
475 	}
476 	if ( pEE->GetActiveView() )
477 	{
478 		fprintf( fp, "\n\n================================================================================" );
479 		fprintf( fp, "\n==================   Aktuelle View   ===========================================" );
480 		fprintf( fp, "\n================================================================================" );
481 		DbgOutItemSet( fp, pEE->GetActiveView()->GetAttribs(), sal_True, sal_False );
482 	}
483 	fclose( fp );
484 	if ( bInfoBox )
485 		InfoBox(0, String( RTL_CONSTASCII_USTRINGPARAM( "D:\\DEBUG.LOG !" ) ) ).Execute();
486 }
487 
GetPortionInfo(ParaPortion * pPPortion)488 ByteString EditDbg::GetPortionInfo( ParaPortion* pPPortion )
489 {
490 	sal_uInt16 z;
491 
492 	ByteString aDebStr( "Absatzlaenge = " );
493 	aDebStr += ByteString::CreateFromInt32( pPPortion->GetNode()->Len() );
494 
495 	aDebStr += "\nZeichenattribute:";
496 	for ( z = 0; z < pPPortion->GetNode()->GetCharAttribs().Count(); z++ )
497 	{
498 		EditCharAttrib* pAttr = pPPortion->GetNode()->GetCharAttribs().GetAttribs().GetObject( z );
499 		aDebStr += "\n  ";
500 		aDebStr += ByteString::CreateFromInt32( pAttr->GetItem()->Which() );
501 		aDebStr += '\t';
502 		aDebStr += ByteString::CreateFromInt32( pAttr->GetStart() );
503 		aDebStr += '\t';
504 		aDebStr += ByteString::CreateFromInt32( pAttr->GetEnd() );
505 	}
506 
507 	aDebStr += "\nTextportions:";
508 	sal_uInt16 n = 0;
509 	for ( z = 0; z < pPPortion->GetTextPortions().Count(); z++ )
510 	{
511 		TextPortion* pPortion = pPPortion->GetTextPortions().GetObject( z );
512 		aDebStr += " ";
513 		aDebStr += ByteString::CreateFromInt32( pPortion->GetLen() );
514 		aDebStr += "(";
515 		aDebStr += ByteString::CreateFromInt32( pPortion->GetSize().Width() );
516 		aDebStr += ")";
517 		aDebStr += ";";
518 		n = n + pPortion->GetLen();
519 	}
520 	aDebStr += "\nGesamtlaenge: ";
521 	aDebStr += ByteString::CreateFromInt32( n );
522 	aDebStr += "\nSortiert nach Start:";
523 	for ( sal_uInt16 x = 0; x < pPPortion->GetNode()->GetCharAttribs().Count(); x++ )
524 	{
525 		EditCharAttrib* pCurAttrib = pPPortion->GetNode()->GetCharAttribs().GetAttribs().GetObject( x );
526 		aDebStr += "\nStart: ";
527 		aDebStr += ByteString::CreateFromInt32( pCurAttrib->GetStart() );
528 		aDebStr += "\tEnde: ";
529 		aDebStr += ByteString::CreateFromInt32( pCurAttrib->GetEnd() );
530 	}
531 	return aDebStr;
532 }
533 
GetTextPortionInfo(TextPortionList & rPortions)534 ByteString EditDbg::GetTextPortionInfo( TextPortionList& rPortions )
535 {
536 	ByteString aDebStr;
537 	for ( sal_uInt16 z = 0; z < rPortions.Count(); z++ )
538 	{
539 		TextPortion* pPortion = rPortions.GetObject( z );
540 		aDebStr += " ";
541 		aDebStr += ByteString::CreateFromInt32( pPortion->GetLen() );
542 		aDebStr += "(";
543 		aDebStr += ByteString::CreateFromInt32( pPortion->GetSize().Width() );
544 		aDebStr += ")";
545 		aDebStr += ";";
546 	}
547 	return aDebStr;
548 }
549 
ShowPortionData(ParaPortion * pPortion)550 void EditDbg::ShowPortionData( ParaPortion* pPortion )
551 {
552 	ByteString aDebStr( GetPortionInfo( pPortion ) );
553 	InfoBox( 0, String( aDebStr, RTL_TEXTENCODING_ASCII_US )  ).Execute();
554 }
555 
556 
DbgCheckTextPortions()557 sal_Bool ParaPortion::DbgCheckTextPortions()
558 {
559 	// pruefen, ob Portionlaenge ok:
560 	sal_uInt16 nXLen = 0;
561 	for ( sal_uInt16 nPortion = 0; nPortion < aTextPortionList.Count(); nPortion++  )
562 		nXLen = nXLen + aTextPortionList[nPortion]->GetLen();
563 	return nXLen == pNode->Len() ? sal_True : sal_False;
564 }
565 
CheckOrderedList(CharAttribArray & rAttribs,sal_Bool bStart)566 sal_Bool CheckOrderedList( CharAttribArray& rAttribs, sal_Bool bStart )
567 {
568 	sal_uInt16 nPrev = 0;
569 	for ( sal_uInt16 nAttr = 0; nAttr < rAttribs.Count(); nAttr++ )
570 	{
571 		EditCharAttrib* pAttr = rAttribs[nAttr];
572 		sal_uInt16 nCur = bStart ? pAttr->GetStart() : pAttr->GetEnd();
573 		if ( nCur < nPrev )
574 			return sal_False;
575 
576 		nPrev = nCur;
577 	}
578 	return sal_True;
579 }
580 
581 #endif
582 
583