xref: /aoo42x/main/sw/source/filter/ww1/w1sprm.cxx (revision efeef26f)
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_sw.hxx"
26 
27 #include <hintids.hxx>
28 #include <tools/solar.h>
29 #include <editeng/paperinf.hxx>
30 #include <editeng/lrspitem.hxx>
31 #include <editeng/adjitem.hxx>
32 #include <editeng/spltitem.hxx>
33 #include <editeng/keepitem.hxx>
34 #include <editeng/boxitem.hxx>
35 #include <editeng/shaditem.hxx>
36 #include <editeng/ulspitem.hxx>
37 #include <editeng/lspcitem.hxx>
38 #include <editeng/tstpitem.hxx>
39 #include <fmtclds.hxx>
40 #include <fmtfsize.hxx>
41 #include <pam.hxx>
42 #include <ndtxt.hxx>
43 #include <charatr.hxx>
44 #include <frmatr.hxx>
45 #include <doc.hxx>
46 #include <errhdl.hxx>
47 #include <fltini.hxx>
48 #include <docufld.hxx>
49 #include <pagedesc.hxx>
50 #include <flddat.hxx>
51 #include <reffld.hxx>
52 #include <expfld.hxx>
53 #include <w1par.hxx>
54 #include <mdiexp.hxx>
55 #include <swerror.h>
56 #include <statstr.hrc>
57 
58 using namespace ::com::sun::star;
59 
60 /////////////////////////////////////////////////////////////// Ww1Sprm
Stop(Ww1Shell & rOut,Ww1Manager & rMan)61 void Ww1Sprm::Stop( Ww1Shell& rOut, Ww1Manager& rMan)
62 {
63 	if(IsUsed())
64 //		for(sal_uInt16 i=0;i<Count();i++)
65 		for(short i=Count()-1;i>=0;i--){	// rueckwaerts
66 			sal_uInt8 nId;
67 			sal_uInt16 nSize;
68 			sal_uInt8* pSprm;
69 			Fill(i, nId, nSize, pSprm);
70 			GetTab(nId).Stop(rOut, nId, pSprm, nSize, rMan);
71 		}
72 }
73 
Start(Ww1Shell & rOut,Ww1Manager & rMan,sal_uInt16 i)74 void Ww1Sprm::Start(
75 	Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 i)
76 {
77 	sal_uInt8 nId;
78 	sal_uInt16 nSize;
79 	sal_uInt8* pSprm;
80 	Fill(i, nId, nSize, pSprm);
81 	GetTab(nId).Start(rOut, nId, pSprm, nSize, rMan);
82 }
83 
Start(Ww1Shell & rOut,Ww1Manager & rMan)84 void Ww1Sprm::Start(
85 	Ww1Shell& rOut, Ww1Manager& rMan)
86 {
87 	if(IsUsed())
88 		for(sal_uInt16 i=0;i<Count();i++)
89 			Start(rOut, rMan, i);
90 }
91 
92 //////////////////////////////////////////////////////////// SingleSprm
Start(Ww1Shell &,sal_uInt8,sal_uInt8 *,sal_uInt16,Ww1Manager &)93 void Ww1SingleSprm::Start(
94 	Ww1Shell&, sal_uInt8 /*nId*/, sal_uInt8*, sal_uInt16, Ww1Manager&)
95 {
96 }
97 
Stop(Ww1Shell &,sal_uInt8,sal_uInt8 *,sal_uInt16,Ww1Manager &)98 void Ww1SingleSprm::Stop(
99 	Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&)
100 {
101 //	ASSERT(sal_False, "Unknown Sprm");
102 }
103 
104 ////////////////////////////////////////////////////////////////// STOP
105 //
106 // folgende defines werden genutzt zur implementierung der
107 // Stop()-Member der SingleSprm-klassen, da diese im normalfalle
108 // lediglich EndItem(s) in die shell stellen.
109 //
110 #define STOP1(Class, Code) \
111 	void Class::Stop( \
112 	 Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) { \
113 		rOut.EndItem(Code); }
114 #define STOP2(Class, Code1, Code2) \
115 	void Class::Stop( \
116 	 Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) { \
117 		rOut.EndItem(Code1).EndItem(Code2); }
118 
119 /////////////////////////////////////////////////////// SingleSprmXxxxx
120 //
121 // hier beginnt die auswertung der eigentlichen sprms. jeder sprmtyp
122 // hat eine eigene klasse, die die virtualen methoden start und stop
123 // implementiert. die klassen stehen in der sprm-tab, die statischer
124 // member von Ww1Sprm ist. taucht ein sprm im dokument auf, werden die
125 // virtualen methoden bei beginn und ende der formatierung gerufen.
126 //
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)127 void Ww1SingleSprmPDxaLeft::Start(
128 	Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
129 {
130 	SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
131 	short nPara = SVBT16ToShort(pSprm);
132 	if(nPara < 0)
133 		nPara = 0;
134 	if(aLR.GetTxtFirstLineOfst() < -nPara)
135 		aLR.SetTxtFirstLineOfst(-nPara); // sonst weigert sich SetTxtLeft()
136 	aLR.SetTxtLeft(nPara);
137 	rOut << aLR;
138 }
139 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)140 void Ww1SingleSprmPDxaRight::Start(
141 	Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
142 {
143 	SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
144 	short nPara = SVBT16ToShort(pSprm);
145 	if(nPara < 0)
146 		nPara = 0;
147 	aLR.SetRight(nPara);
148 	rOut << aLR;
149 }
150 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)151 void Ww1SingleSprmPDxaLeft1::Start(
152 	Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
153 {
154 	SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE));
155 	short nPara = SVBT16ToShort(pSprm);
156 	if(-nPara >(short)aLR.GetTxtLeft())
157 		nPara = -(short)aLR.GetTxtLeft();
158 	aLR.SetTxtFirstLineOfst(nPara);
159 	rOut << aLR;
160 }
161 
STOP1(Ww1SingleSprmPDxa,RES_LR_SPACE)162 STOP1(Ww1SingleSprmPDxa, RES_LR_SPACE)
163 
164 void Ww1SingleSprmPJc::Start(
165 	Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
166 {
167 	static SvxAdjust __READONLY_DATA aAdj[] = {
168 		SVX_ADJUST_LEFT,
169 		SVX_ADJUST_CENTER,
170 		SVX_ADJUST_RIGHT,
171 		SVX_ADJUST_BLOCK };
172 	sal_uInt8 nPara = SVBT8ToByte(pSprm);
173 	nPara %=(sizeof(aAdj)/sizeof(*aAdj));
174     rOut << SvxAdjustItem(aAdj[nPara], RES_PARATR_ADJUST);
175 }
176 
STOP1(Ww1SingleSprmPJc,RES_PARATR_ADJUST)177 STOP1(Ww1SingleSprmPJc, RES_PARATR_ADJUST)
178 
179 void Ww1SingleSprmPFKeep::Start(
180 	Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
181 {
182     rOut << SvxFmtSplitItem((SVBT8ToByte(pSprm) & 1) == 0, RES_PARATR_SPLIT);
183 }
184 
STOP1(Ww1SingleSprmPFKeep,RES_PARATR_SPLIT)185 STOP1(Ww1SingleSprmPFKeep, RES_PARATR_SPLIT)
186 
187 void Ww1SingleSprmPFKeepFollow::Start(
188 	Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
189 {
190     rOut << SvxFmtKeepItem((SVBT8ToByte(pSprm) & 1) != 0, RES_KEEP);
191 }
192 
STOP1(Ww1SingleSprmPFKeepFollow,RES_KEEP)193 STOP1(Ww1SingleSprmPFKeepFollow, RES_KEEP)
194 
195 void Ww1SingleSprmPPageBreakBefore::Start(
196 	Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&)
197 {
198 	rOut << SvxFmtBreakItem(SVBT8ToByte(pSprm) & 1?
199      SVX_BREAK_PAGE_BEFORE:SVX_BREAK_NONE, RES_BREAK );
200 }
201 
STOP1(Ww1SingleSprmPPageBreakBefore,RES_BREAK)202 STOP1(Ww1SingleSprmPPageBreakBefore, RES_BREAK)
203 
204 SvxBorderLine* Ww1SingleSprmPBrc::SetBorder(SvxBorderLine* pLine, W1_BRC10* pBrc)
205 {
206 	sal_uInt16 nCode;
207 	if(pBrc->dxpLine2WidthGet() == 0)
208 	{
209 		switch(pBrc->dxpLine1WidthGet())
210 		{
211 		default: ASSERT(sal_False, "unknown linewidth");
212 		case 0: return 0;							// keine Linie
213 		case 1: nCode = DEF_LINE_WIDTH_0; break;
214 		case 2: nCode = DEF_LINE_WIDTH_1; break;
215 		case 3: nCode = DEF_LINE_WIDTH_2; break;
216 		case 4: nCode = DEF_LINE_WIDTH_3; break;
217 		case 5: nCode = DEF_LINE_WIDTH_4; break;
218 		}
219 		pLine->SetOutWidth(nCode);
220 		pLine->SetInWidth(0);
221 	}
222 	else
223 	{
224 		switch(pBrc->dxpLine1WidthGet())
225 		{
226 		default: ASSERT(sal_False, "unknown linewidth");
227 		case 1: nCode = DEF_DOUBLE_LINE0_IN; break;
228 		}
229 		pLine->SetOutWidth(nCode);
230 		switch(pBrc->dxpLine2WidthGet())
231 		{
232 		default: ASSERT(sal_False, "unknown linewidth");
233 		case 1: nCode = DEF_DOUBLE_LINE0_OUT; break;
234 		}
235 		pLine->SetInWidth(nCode);
236 	}
237 	switch(pBrc->dxpLine1WidthGet())
238 	{
239 	default: ASSERT(sal_False, "unknown space");
240 	case 0: nCode = DEF_DOUBLE_LINE0_DIST; break;
241 	case 1: nCode = DEF_DOUBLE_LINE1_DIST; break;
242 	case 2: nCode = DEF_DOUBLE_LINE2_DIST; break;
243 	case 3: nCode = DEF_DOUBLE_LINE3_DIST; break;
244 	}
245 	pLine->SetDistance(nCode);
246 	return pLine;
247 }
248 
Start(Ww1Shell & rOut,sal_uInt8,W1_BRC10 * pBrc,sal_uInt16 nSize,Ww1Manager &,SvxBoxItem & aBox)249 void Ww1SingleSprmPBrc::Start(
250 	Ww1Shell& rOut, sal_uInt8,
251 	W1_BRC10* pBrc,
252 	sal_uInt16
253 #ifdef DBG_UTIL
254 	nSize
255 #endif
256 	,
257 	Ww1Manager& /*rMan*/,
258 	SvxBoxItem& aBox)
259 {
260 	ASSERT(sizeof(W1_BRC10) == nSize, "sizemissmatch");
261 	if(pBrc->dxpSpaceGet())
262 		aBox.SetDistance(10 + 20 * pBrc->dxpSpaceGet());
263 			//??? Warum 10+... ????
264 
265 	if( rOut.IsInFly() )
266 		rOut.SetFlyFrmAttr( aBox );
267 	else
268 		rOut << aBox;
269 
270 	if(pBrc->fShadowGet())
271 	{
272 		Color aBlack(COL_BLACK); // schwarzer...
273         SvxShadowItem aS(RES_SHADOW,(const Color*)&aBlack, 32,
274 						 SVX_SHADOW_BOTTOMRIGHT); // 1.6 tw breit
275 		if( rOut.IsInFly() )
276 			rOut.SetFlyFrmAttr( aS );
277 		else
278 			rOut << aS;
279 	}
280 }
281 
282 STOP2(Ww1SingleSprmPBrc, RES_BOX, RES_SHADOW)
283 
284 static sal_uInt16 __READONLY_DATA nBrcTrans[BRC_ANZ] =
285 	 { BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
286 
Start(Ww1Shell & rOut,sal_uInt8 nId,sal_uInt8 * pSprm,sal_uInt16 nSize,Ww1Manager & rMan)287 void Ww1SingleSprmPBrc10::Start(
288 	Ww1Shell& rOut, sal_uInt8 nId, sal_uInt8* pSprm, sal_uInt16 nSize, Ww1Manager& rMan)
289 {
290 
291 	W1_BRC10* pBrc =(W1_BRC10*)pSprm;
292 	const SfxPoolItem &rItem = ( ( rOut.IsInFly() ) ?
293 					 rOut.GetFlyFrmAttr(RES_BOX) :rOut.GetAttr(RES_BOX));
294 	const SvxBoxItem &rBoxItem = (const SvxBoxItem&)rItem;
295 	SvxBoxItem aBox( rBoxItem );
296 //	rOut >> aBox;
297 	SvxBorderLine aLine;
298 	aBox.SetLine(SetBorder(&aLine, pBrc), nBrcTrans[nLine] );
299 	Ww1SingleSprmPBrc::Start(rOut, nId, pBrc, nSize, rMan, aBox);
300 }
301 
STOP1(Ww1SingleSprmParaSpace,RES_UL_SPACE)302 STOP1(Ww1SingleSprmParaSpace, RES_UL_SPACE)
303 
304 void Ww1SingleSprmPDyaBefore::Start(
305 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
306 {
307 	short nPara = SVBT16ToShort(pSprm);
308 	if(nPara < 0)
309 		nPara = -nPara;
310 	SvxULSpaceItem aUL((SvxULSpaceItem&)rOut.GetAttr(RES_UL_SPACE));
311 	aUL.SetUpper(nPara);
312 	rOut << aUL;
313 }
314 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)315 void Ww1SingleSprmPDyaAfter::Start(
316 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
317 {
318 	short nPara = SVBT16ToShort(pSprm);
319 	if(nPara < 0)
320 		nPara = -nPara;
321 	SvxULSpaceItem aUL((SvxULSpaceItem&)rOut.GetAttr(RES_UL_SPACE));
322 	aUL.SetLower(nPara);
323 	rOut << aUL;
324 }
325 
STOP1(Ww1SingleSprmPDyaLine,RES_PARATR_LINESPACING)326 STOP1(Ww1SingleSprmPDyaLine, RES_PARATR_LINESPACING)
327 
328 void Ww1SingleSprmPDyaLine::Start(
329 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
330 {
331 	short nSpace = SVBT16ToShort(pSprm);
332 	if(nSpace < 0)
333 		nSpace = -nSpace;
334     SvxLineSpacingItem aLSpc( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING );
335 	if(sal_True)
336 	{// MultilineSpace(proportional)
337 		long n = nSpace * 100 / 240;	// W1: 240 = 100%, SW: 100 = 100%
338 		if(n>200)
339 			n = 200; // SW_UI-Maximum
340 		aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
341 		aLSpc.SetPropLineSpace((sal_uInt8)n);
342 	}
343 	else
344 	{// Fixed / Minimum
345 		aLSpc.SetLineHeight((sal_uInt16)nSpace);
346 		aLSpc.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
347 	}
348 	rOut << aLSpc;
349 }
350 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)351 void Ww1SingleSprmPChgTabsPapx::Start(
352 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
353 {
354 #if OSL_DEBUG_LEVEL > 1
355 //	rOut << 'T';
356 #endif
357 	short nLeftPMgn = 0;	// Koordinaten etwa gleich ??
358 //	( pAktColl ) ? pCollA[nAktColl].nLeftParaMgn
359 //								   : nLeftParaMgn;		// Absatz L-Space
360 
361 	short i;
362 	sal_uInt8 nDel = pSprm[1];
363 	sal_uInt8* pDel = pSprm + 2;						// Del - Array
364 	sal_uInt8 nIns = pSprm[nDel*2+2];
365 	sal_uInt8* pIns = pSprm + 2*nDel + 3;			// Ins - Array
366 	W1_TBD* pTyp = (W1_TBD*)(pSprm + 2*nDel + 2*nIns + 3);// Typ - Array
367 
368 	SvxTabStopItem aAttr( (SvxTabStopItem&)rOut.GetNodeOrStyAttr( RES_PARATR_TABSTOP ));
369 
370 	SvxTabStop aTabStop;
371 
372 	for( i=0; i<nDel; i++ ){
373 		sal_uInt16 nPos = aAttr.GetPos( SVBT16ToShort( pDel + i*2 ) - nLeftPMgn );
374 		if( nPos != SVX_TAB_NOTFOUND )
375 			aAttr.Remove( nPos, 1 );
376 	}
377 
378 	for( i=0; i<nIns; i++ ){
379 		short nPos = SVBT16ToShort( pIns + i*2 ) - nLeftPMgn;
380 		if( nPos < 0 )
381 			continue;
382 		aTabStop.GetTabPos() = nPos;
383 		switch( pTyp[i].jcGet() ){
384 		case 0: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT; break;
385 		case 1:	aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER; break;
386 		case 2: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT; break;
387 		case 3:	aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL; break;
388 		case 4: continue;					// ignoriere Bar
389 		}
390 
391 		switch( pTyp[i].tlcGet() ){
392 		case 0: aTabStop.GetFill() = ' '; break;
393 		case 1: aTabStop.GetFill() = '.'; break;
394 		case 2: aTabStop.GetFill() = '-'; break;
395 		case 3:
396 		case 4: aTabStop.GetFill() = '_'; break;
397 		}
398 
399 		sal_uInt16 nPos2 = aAttr.GetPos( nPos );
400 		if( nPos2 != SVX_TAB_NOTFOUND )
401 			aAttr.Remove( nPos2, 1 );		// sonst weigert sich das Insert()
402 
403 		aAttr.Insert( aTabStop );
404 	}
405 	rOut << aAttr;
406 }
407 
STOP1(Ww1SingleSprmPChgTabsPapx,RES_PARATR_TABSTOP)408 STOP1(Ww1SingleSprmPChgTabsPapx, RES_PARATR_TABSTOP)
409 
410 void Ww1SingleSprmSGprfIhdt::Start(
411 	Ww1Shell& /*rOut*/, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan)
412 {
413 	rMan.GetSep().SetGrpfIhdt(SVBT8ToByte(pSprm));
414 }
415 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)416 void Ww1SingleSprmSColumns::Start(
417 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
418 {
419 	short nColSpace = 708; // default 1,25 cm
420 	short nNettoWidth = -1; //~ mdt: dxaLeft/Right missing...
421 	short nCols = SVBT16ToShort(pSprm);
422 	nCols++;
423 	if (nCols < 2)
424 		return;
425 	SwFmtCol aCol;
426 	aCol.Init(nCols, nColSpace, nNettoWidth);
427     rOut.GetPageDesc().GetMaster().SetFmtAttr(aCol);
428 }
429 
Start(Ww1Shell &,sal_uInt8,sal_uInt8 *,sal_uInt16,Ww1Manager & rMan)430 void Ww1SingleSprmPTtp::Start(
431 	Ww1Shell& /*rOut*/, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager& rMan)
432 {
433 	rMan.SetInTtp( sal_True );		// Besonderheit: wird bei InTable::Stop und
434 								// nicht bei InTtp::Stop zurueckgesetzt,
435 								// da Auswertung in InTable
436 }
437 
Stop(Ww1Shell & rOut,sal_uInt8,sal_uInt8 *,sal_uInt16,Ww1Manager & rMan)438 void Ww1SingleSprmPTtp::Stop(
439 	Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager& rMan)
440 {
441 	if (rOut.IsInTable() && rMan.HasInTable())
442 		rOut.NextTableRow();
443 }
444 
Start(Ww1Shell &,sal_uInt8,sal_uInt8 *,sal_uInt16,Ww1Manager &)445 void Ww1SingleSprmPFInTable::Start(
446 	Ww1Shell& /*rOut*/, sal_uInt8, sal_uInt8*, sal_uInt16,
447 	Ww1Manager& /*rMan*/)
448 {
449 }
450 
Stop(Ww1Shell & rOut,sal_uInt8,sal_uInt8 *,sal_uInt16,Ww1Manager & rMan)451 void Ww1SingleSprmPFInTable::Stop(
452 	Ww1Shell&
453 #ifdef DBG_UTIL
454 	rOut
455 #endif
456 	,
457 	sal_uInt8, sal_uInt8*, sal_uInt16,
458 	Ww1Manager& rMan)
459 {
460 	ASSERT(rOut.IsInTable(), "");
461 	rMan.SetInTtp( sal_False );
462 }
463 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)464 void Ww1SingleSprmTDxaGapHalf::Start(
465 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
466 {
467 	short nSpace = SVBT16ToShort(pSprm);
468 	rOut.SetCellSpace(nSpace);
469 }
470 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16 nSize,Ww1Manager &)471 void Ww1SingleSprmTDefTable10::Start(
472 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 nSize, Ww1Manager& /*rMan*/)
473 {
474     sal_uInt16 i;
475 	sal_uInt8 *p = pSprm + 2;	// LaengenWord ueberlesen
476 	sal_uInt8 nCount = *p;
477 	p++;
478 	nSize -= 3;
479 // Es fehlt noch:
480 // - GapHalf
481 // - eventuelle Ausduennung der Zellenumrandungen
482 
483 	if( nCount < 1 || nCount > 32 || nSize < ( nCount + 1 ) * 2  )
484 		return;
485 
486 // Erstmal die Zellenpositionen einlesen
487 	short nPos = SVBT16ToShort( p );	// signed, kann auch neg. sein !!!
488 
489 //	if( !rOut.IsTableWidthSet() ){		// Muss Tabellenbreite und -Ausrichtung
490 										// noch gesetzt werden ?
491 	{
492 		short nWholeWidth = SVBT16ToShort( p + 2 * nCount ) - nPos;
493 		rOut.SetTableWidth( (sal_uInt16)nWholeWidth );	// Tabellenbreite setzen
494 
495 // Pos der Tabelle setzen
496 		long nMidTab = nPos + nWholeWidth / 2;		// TabellenMitte
497 		const SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster();
498 		const SvxLRSpaceItem& rLR = rFmt.GetLRSpace();
499 		long nRight = rFmt.GetFrmSize().GetWidth()
500 					  - rLR.GetLeft() - rLR.GetRight();
501 
502         sal_Int16 eOri = text::HoriOrientation::LEFT;
503 		if( nPos > MINLAY ){						// per Zuppeln positioniert
504 			if ( nMidTab <= nRight / 3 )			// 1/3 der Seite
505                 eOri = text::HoriOrientation::LEFT;
506 			else if ( nMidTab <= 2 * nRight / 3 )	// 2/3 der Seite
507                 eOri = text::HoriOrientation::CENTER;
508 			else
509                 eOri = text::HoriOrientation::RIGHT;
510 		}
511 		rOut.SetTableOrient( eOri );
512 	}
513 
514 	sal_uInt8* pEndPos = p+2;
515 	sal_uInt8* pTc0 = ( nSize >= nCount * 10 ) ? pEndPos + 2 * nCount : 0;
516 	sal_uInt16 nCellsDeleted = 0;		// fuer gemergte Zellen
517 
518 	for( i = 0; i < nCount; i++ ){
519 // Info sammeln
520 		W1_TC* pTc = (W1_TC*)pTc0;
521 		sal_Bool bMerged = (pTc) ? pTc->fMergedGet() : sal_False;
522 
523 // Zellenbreiten setzen
524 		sal_uInt16 nPos1 = SVBT16ToShort( pEndPos );
525 		if( !bMerged )
526             rOut.SetCellWidth( nPos1 - nPos, i - nCellsDeleted );
527 										// Zellenbreite setzen
528 										// Wechselwirkung mit GapHalf fehlt noch
529 										// ( GapHalf wird noch ignoriert )
530 		pEndPos+=2;
531 		nPos = nPos1;
532 
533 		if( pTc0 ){						// gibts TCs ueberhaupt ?
534 			W1_TC* pTc2 = (W1_TC*)pTc0;
535 			sal_Bool bMerged2 = pTc2->fMergedGet();
536 //			ASSERT( !bMerged2, "Gemergte Tabellenzellen noch nicht vollstaendig implementiert" );
537 			if( !bMerged2 ){
538 // und nun die Umrandungen
539 				SvxBoxItem aBox( (SvxBoxItem&)rOut.GetCellAttr( RES_BOX ));
540 				SvxBorderLine aLine;
541 				W1_BRC10* pBrc = pTc2->rgbrcGet();
542 				for( sal_uInt16 j=0; j<4; j++ ){
543 					aBox.SetLine(Ww1SingleSprmPBrc::SetBorder(&aLine, pBrc),
544 								 nBrcTrans[j]);
545 					pBrc++;
546 				}
547                 rOut.SetCellBorder( aBox, i - nCellsDeleted );
548 			}else{
549 // gemergte Zellen entfernen
550                 rOut.DeleteCell( i - nCellsDeleted );
551 				nCellsDeleted++;
552 			}
553 			pTc0+=sizeof(W1_TC);	// 10
554 		}
555 	}
556 }
557 
558 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)559 void Ww1SingleSprmTDyaRowHeight::Start(
560 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
561 {
562 	short nSpace = SVBT16ToShort(pSprm);
563 	rOut.SetCellHeight(nSpace);
564 }
565 
566 // Fastsave-Attribute brauche ich als Dymmys nicht
567 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager & rMan)568 void Ww1SingleSprmPpc::Start(
569 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan)
570 {
571 	sal_uInt8 nPpc = SVBT8ToByte(pSprm);
572 
573 	if (rOut.IsInTable())						// Flys in Tabellen kann PMW
574 		return;									// nicht
575 
576 	RndStdIds eAnchor;			// Bindung
577     sal_Int16 eHRel;        // Seite oder Seitenrand
578     sal_Int16 eVRel;        // Seite oder Seitenrand
579 
580 	switch ( ( nPpc & 0x30 ) >> 4 ){		// Y - Bindung bestimmt Sw-Bindung
581     case 0: eAnchor = FLY_AT_PARA;          // Vert Margin
582             eVRel = text::RelOrientation::PRINT_AREA;
583 //			if( nYPos < 0 )
584 //				nYPos = 0;					// koennen wir nicht
585 			break;
586 /*	case 1:*/								// Vert. Seite
587     default:eAnchor = FLY_AT_PAGE;          // Vert Page oder unknown
588             eVRel = text::RelOrientation::FRAME;
589 			break;							// 2=Vert. Paragraph, 3=Use Default
590 	}
591 
592 	switch ( ( nPpc & 0xc0 ) >> 6 ){        // X - Bindung -> Koordinatentransformation
593 	case 0: 								// Hor. Spalte
594 	case 1: 								// Hor. Absatz
595             eHRel = text::RelOrientation::PRINT_AREA;
596 //			nXPos += nPgLeft;				// in Seiten-Koordinaten umrechnen
597 			break;
598 /*	case 2:*/								// Hor. Seite
599 	default:
600             eHRel = text::RelOrientation::FRAME;
601 			break;
602 	}
603 
604 	if( !rOut.IsInFly() && rMan.IsInStyle() ){
605 		rOut.BeginFly( eAnchor );			// Starte StyleFly
606 	}else{
607 		rOut.SetFlyAnchor( eAnchor );		// Setze Anker
608 	}
609 }
610 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager & rMan)611 void Ww1SingleSprmPDxaAbs::Start(
612 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan)
613 {
614 	short nXPos = SVBT16ToShort(pSprm);
615 
616 	if( rMan.IsInStyle() && !rOut.IsInFly() ){
617 		rOut.BeginFly();					// Fly ohne PPc-Attribut
618 	}
619 
620     sal_Int16 eHRel = text::RelOrientation::FRAME;
621     sal_Int16 eHAlign = text::HoriOrientation::NONE;
622 
623 	switch( nXPos ){						// besondere X-Positionen ?
624 	case 0:
625     case -12: eHAlign = text::HoriOrientation::NONE; nXPos = 0; break;   // Mogel: innen -> links
626                             // eigentich text::HoriOrientation::LEFT, aber dann verrueckt
627 							// ein Abstand nach aussen den Fly
628     case -4:  eHAlign = text::HoriOrientation::CENTER; nXPos = 0; break; // zentriert
629 	case -8:                             			   // rechts
630     case -16: eHAlign = text::HoriOrientation::RIGHT; nXPos = 0; break;  // Mogel: aussen -> rechts
631 //	default:  nXPos += (short)nIniFlyDx; break;	// Korrekturen per Ini-Datei
632 	}
633 	rOut.SetFlyXPos( nXPos, eHRel, eHAlign );
634 }
635 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)636 void Ww1SingleSprmPDyaAbs::Start(
637 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
638 {
639 	short nYPos = SVBT16ToShort(pSprm);
640     sal_Int16 eVRel = text::RelOrientation::FRAME;
641     sal_Int16 eVAlign = text::VertOrientation::NONE;
642 
643 	switch( nYPos ){							// besondere Y-Positionen ?
644     case -4:  eVAlign = text::VertOrientation::TOP; nYPos = 0; break; // oben
645     case -8:  eVAlign = text::VertOrientation::CENTER; nYPos = 0; break;  // zentriert
646     case -12: eVAlign = text::VertOrientation::BOTTOM; nYPos = 0; break;  // unten
647 //	default:  nYPos += (short)nIniFlyDy; break;	// Korrekturen per Ini-Datei
648 	}
649 	rOut.SetFlyYPos( nYPos, eVRel, eVAlign );
650 }
651 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)652 void Ww1SingleSprmPDxaWidth::Start(
653 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
654 {
655 	short nDxaWidth = SVBT16ToShort(pSprm);
656 	rOut.SetFlyFrmAttr( SwFmtFrmSize( ATT_VAR_SIZE, nDxaWidth, MINFLY ) );
657 }
658 
Start(Ww1Shell & rOut,sal_uInt8,sal_uInt8 * pSprm,sal_uInt16,Ww1Manager &)659 void Ww1SingleSprmPFromText::Start(
660 	Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/)
661 {
662 	if( rOut.IsInFly() ){	// Kommt auch ausserhalb eines Flys vor, hat
663 							// dann aber offensichtlich nichts zu bedeuten.
664 							// Einen impliziten Fly-Anfang bedeutet es
665 							// definitiv nicht
666 		short nFromText = SVBT16ToShort(pSprm);
667 
668         SvxLRSpaceItem aLR( RES_LR_SPACE );
669 		aLR.SetTxtLeft( nFromText );
670 		aLR.SetRight( nFromText );
671 		rOut.SetFlyFrmAttr( aLR );
672 
673         rOut.SetFlyFrmAttr( SvxULSpaceItem( nFromText, nFromText, RES_UL_SPACE ) );
674 	}
675 }
676 
677 #undef STOP1
678 #undef STOP2
679 
680 
681