xref: /trunk/main/xmloff/source/text/txtimppr.cxx (revision 63bba73c)
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_xmloff.hxx"
26 #include <tools/debug.hxx>
27 #include <com/sun/star/awt/FontFamily.hpp>
28 #include <com/sun/star/awt/FontPitch.hpp>
29 #include <com/sun/star/table/BorderLine.hpp>
30 #include <com/sun/star/text/VertOrientation.hpp>
31 #include <com/sun/star/text/SizeType.hpp>
32 #include <tools/string.hxx>
33 #include <xmloff/XMLFontStylesContext.hxx>
34 #include <xmloff/txtprmap.hxx>
35 #include <xmloff/xmlimp.hxx>
36 #include "xmloff/txtimppr.hxx"
37 
38 #define XML_LINE_LEFT 0
39 #define XML_LINE_RIGHT 1
40 #define XML_LINE_TOP 2
41 #define XML_LINE_BOTTOM 3
42 #define MIN_BORDER_DIST 49
43 
44 using ::rtl::OUString;
45 
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::table;
49 using namespace ::com::sun::star::text;
50 
51 sal_Bool XMLTextImportPropertyMapper::handleSpecialItem(
52 			XMLPropertyState& rProperty,
53 			::std::vector< XMLPropertyState >& rProperties,
54 			const ::rtl::OUString& rValue,
55 			const SvXMLUnitConverter& rUnitConverter,
56 			const SvXMLNamespaceMap& rNamespaceMap ) const
57 {
58 	sal_Bool bRet = sal_False;
59 	sal_Int32 nIndex = rProperty.mnIndex;
60 	switch( getPropertySetMapper()->GetEntryContextId( nIndex  ) )
61 	{
62 	case CTF_FONTNAME:
63 	case CTF_FONTNAME_CJK:
64 	case CTF_FONTNAME_CTL:
65 		if( xFontDecls.Is() )
66 		{
67 			DBG_ASSERT(
68 				( CTF_FONTFAMILYNAME ==
69 					getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
70 				  CTF_FONTSTYLENAME ==
71 					getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
72 				  CTF_FONTFAMILY ==
73 					getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
74 				  CTF_FONTPITCH ==
75 					getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
76 				  CTF_FONTCHARSET ==
77 					getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
78 				( CTF_FONTFAMILYNAME_CJK ==
79 					getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
80 				  CTF_FONTSTYLENAME_CJK ==
81 					getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
82 				  CTF_FONTFAMILY_CJK ==
83 					getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
84 				  CTF_FONTPITCH_CJK ==
85 					getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
86 				  CTF_FONTCHARSET_CJK ==
87 					getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
88 				( CTF_FONTFAMILYNAME_CTL ==
89 					getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
90 				  CTF_FONTSTYLENAME_CTL ==
91 					getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
92 				  CTF_FONTFAMILY_CTL ==
93 					getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
94 				  CTF_FONTPITCH_CTL ==
95 					getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
96 				  CTF_FONTCHARSET_CTL ==
97 					getPropertySetMapper()->GetEntryContextId(nIndex+5) ),
98 				"illegal property map" );
99 
100 			((XMLFontStylesContext *)&xFontDecls)->FillProperties(
101 							rValue, rProperties,
102 							rProperty.mnIndex+1, rProperty.mnIndex+2,
103 							rProperty.mnIndex+3, rProperty.mnIndex+4,
104 							rProperty.mnIndex+5 );
105 			bRet = sal_False; // the property hasn't been filled
106 		}
107 		break;
108 
109     // If we want to do StarMath/StarSymbol font conversion, then we'll
110     // want these special items to be treated just like regular ones...
111     // For the Writer, we'll catch and convert them in _FillPropertySet;
112     // the other apps probably don't care. For the other apps, we just
113 	// imitate the default non-special-item mechanism.
114 	case CTF_FONTFAMILYNAME:
115 	case CTF_FONTFAMILYNAME_CJK:
116 	case CTF_FONTFAMILYNAME_CTL:
117 		bRet = getPropertySetMapper()->importXML( rValue, rProperty,
118 												  rUnitConverter );
119         break;
120 
121     case CTF_TEXT_DISPLAY:
122 		bRet = getPropertySetMapper()->importXML( rValue, rProperty,
123 												  rUnitConverter );
124         if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() )
125         {
126             sal_Bool bHidden;
127             rProperty.maValue >>= bHidden;
128             bHidden = !bHidden;
129             rProperty.maValue <<= bHidden;
130         }
131     break;
132 	default:
133 		bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty,
134 					rProperties, rValue, rUnitConverter, rNamespaceMap );
135 		break;
136 	}
137 
138 	return bRet;
139 }
140 
141 XMLTextImportPropertyMapper::XMLTextImportPropertyMapper(
142 			const UniReference< XMLPropertySetMapper >& rMapper,
143             SvXMLImport& rImp,
144 			XMLFontStylesContext *pFontDecls ) :
145 	SvXMLImportPropertyMapper( rMapper, rImp ),
146 	nSizeTypeIndex( -2 ),
147 	nWidthTypeIndex( -2 ),
148 	xFontDecls( pFontDecls )
149 {
150 }
151 
152 XMLTextImportPropertyMapper::~XMLTextImportPropertyMapper()
153 {
154 }
155 
156 void XMLTextImportPropertyMapper::SetFontDecls(
157 		XMLFontStylesContext *pFontDecls )
158 {
159 	xFontDecls = pFontDecls;
160 }
161 
162 void XMLTextImportPropertyMapper::FontFinished(
163 	XMLPropertyState *pFontFamilyNameState,
164 	XMLPropertyState *pFontStyleNameState,
165 	XMLPropertyState *pFontFamilyState,
166 	XMLPropertyState *pFontPitchState,
167 	XMLPropertyState *pFontCharsetState ) const
168 {
169 	if( pFontFamilyNameState && pFontFamilyNameState->mnIndex != -1 )
170 	{
171 		OUString sName;
172 		pFontFamilyNameState->maValue >>= sName;
173 		if( !sName.getLength() )
174 			pFontFamilyNameState->mnIndex = -1;
175 	}
176 	if( !pFontFamilyNameState || pFontFamilyNameState->mnIndex == -1 )
177 	{
178 		if( pFontStyleNameState )
179 			pFontStyleNameState->mnIndex = -1;
180 		if( pFontFamilyState )
181 			pFontFamilyState->mnIndex = -1;
182 		if( pFontPitchState )
183 			pFontPitchState->mnIndex = -1;
184 		if( pFontCharsetState )
185 			pFontCharsetState->mnIndex = -1;
186 	}
187 }
188 
189 /** since the properties "CharFontFamilyName", "CharFontStyleName", "CharFontFamily",
190 	"CharFontPitch" and "CharFontSet" and theire CJK and CTL counterparts are only
191 	usable as a union, we add defaults to all values that are not set as long as we
192 	have an "CharFontFamilyName"
193 
194 	#99928# CL */
195 void XMLTextImportPropertyMapper::FontDefaultsCheck(
196 										XMLPropertyState* pFontFamilyName,
197 										XMLPropertyState* pFontStyleName,
198 										XMLPropertyState* pFontFamily,
199 										XMLPropertyState* pFontPitch,
200 										XMLPropertyState* pFontCharSet,
201 										XMLPropertyState** ppNewFontStyleName,
202 										XMLPropertyState** ppNewFontFamily,
203 										XMLPropertyState** ppNewFontPitch,
204 										XMLPropertyState** ppNewFontCharSet ) const
205 {
206 	if( pFontFamilyName )
207 	{
208 		OUString sEmpty;
209 		Any aAny;
210 
211 		if( !pFontStyleName )
212 		{
213 			aAny <<= sEmpty;
214 	#ifdef DBG_UTIL
215 				sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
216 												pFontFamilyName->mnIndex + 1 );
217 				DBG_ASSERT( nTmp == CTF_FONTSTYLENAME || nTmp == CTF_FONTSTYLENAME_CJK || nTmp == CTF_FONTSTYLENAME_CTL,
218 							"wrong property context id" );
219 	#endif
220 				*ppNewFontStyleName = new XMLPropertyState( pFontFamilyName->mnIndex + 1,
221 													   aAny );
222 		}
223 
224 		if( !pFontFamily )
225 		{
226 			aAny <<= (sal_Int16)com::sun::star::awt::FontFamily::DONTKNOW;
227 
228 	#ifdef DBG_UTIL
229 				sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
230 												pFontFamilyName->mnIndex + 2 );
231 				DBG_ASSERT( nTmp == CTF_FONTFAMILY || nTmp == CTF_FONTFAMILY_CJK || nTmp == CTF_FONTFAMILY_CTL,
232 							"wrong property context id" );
233 	#endif
234 				*ppNewFontFamily = new XMLPropertyState( pFontFamilyName->mnIndex + 2,
235 													   aAny );
236 		}
237 
238 		if( !pFontPitch )
239 		{
240 			aAny <<= (sal_Int16)com::sun::star::awt::FontPitch::DONTKNOW;
241 	#ifdef DBG_UTIL
242 				sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
243 												pFontFamilyName->mnIndex + 3 );
244 				DBG_ASSERT( nTmp == CTF_FONTPITCH || nTmp == CTF_FONTPITCH_CJK || nTmp == CTF_FONTPITCH_CTL,
245 							"wrong property context id" );
246 	#endif
247 				*ppNewFontPitch = new XMLPropertyState( pFontFamilyName->mnIndex + 3,
248 													   aAny );
249 		}
250 
251 		if( !pFontCharSet )
252 		{
253 			aAny <<= (sal_Int16)gsl_getSystemTextEncoding();
254 	#ifdef DBG_UTIL
255 				sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
256 												pFontFamilyName->mnIndex + 4 );
257 				DBG_ASSERT( nTmp == CTF_FONTCHARSET || nTmp == CTF_FONTCHARSET_CJK || nTmp == CTF_FONTCHARSET_CTL,
258 							"wrong property context id" );
259 	#endif
260 				*ppNewFontCharSet = new XMLPropertyState( pFontFamilyName->mnIndex + 4,
261 													   aAny );
262 		}
263 	}
264 }
265 
266 void XMLTextImportPropertyMapper::finished(
267 			::std::vector< XMLPropertyState >& rProperties,
268 			sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
269 {
270 	sal_Bool bHasAnyHeight = sal_False;
271 	sal_Bool bHasAnyMinHeight = sal_False;
272 	sal_Bool bHasAnyWidth = sal_False;
273 	sal_Bool bHasAnyMinWidth = sal_False;
274 
275 	XMLPropertyState* pFontFamilyName = 0;
276 	XMLPropertyState* pFontStyleName = 0;
277 	XMLPropertyState* pFontFamily = 0;
278 	XMLPropertyState* pFontPitch = 0;
279 	XMLPropertyState* pFontCharSet = 0;
280 	XMLPropertyState* pNewFontStyleName = 0;
281 	XMLPropertyState* pNewFontFamily = 0;
282 	XMLPropertyState* pNewFontPitch = 0;
283 	XMLPropertyState* pNewFontCharSet = 0;
284 	XMLPropertyState* pFontFamilyNameCJK = 0;
285 	XMLPropertyState* pFontStyleNameCJK = 0;
286 	XMLPropertyState* pFontFamilyCJK = 0;
287 	XMLPropertyState* pFontPitchCJK = 0;
288 	XMLPropertyState* pFontCharSetCJK = 0;
289 	XMLPropertyState* pNewFontStyleNameCJK = 0;
290 	XMLPropertyState* pNewFontFamilyCJK = 0;
291 	XMLPropertyState* pNewFontPitchCJK = 0;
292 	XMLPropertyState* pNewFontCharSetCJK = 0;
293 	XMLPropertyState* pFontFamilyNameCTL = 0;
294 	XMLPropertyState* pFontStyleNameCTL = 0;
295 	XMLPropertyState* pFontFamilyCTL = 0;
296 	XMLPropertyState* pFontPitchCTL = 0;
297 	XMLPropertyState* pFontCharSetCTL = 0;
298 	XMLPropertyState* pNewFontStyleNameCTL = 0;
299 	XMLPropertyState* pNewFontFamilyCTL = 0;
300 	XMLPropertyState* pNewFontPitchCTL = 0;
301 	XMLPropertyState* pNewFontCharSetCTL = 0;
302 	XMLPropertyState* pAllBorderDistance = 0;
303 	XMLPropertyState* pBorderDistances[4] = { 0, 0, 0, 0 };
304 	XMLPropertyState* pNewBorderDistances[4] = { 0, 0, 0, 0 };
305 	XMLPropertyState* pAllBorder = 0;
306 	XMLPropertyState* pBorders[4] = { 0, 0, 0, 0 };
307 	XMLPropertyState* pNewBorders[4] = { 0, 0, 0, 0 };
308 	XMLPropertyState* pAllBorderWidth = 0;
309 	XMLPropertyState* pBorderWidths[4] = { 0, 0, 0, 0 };
310 	XMLPropertyState* pAnchorType = 0;
311 	XMLPropertyState* pVertOrient = 0;
312 	XMLPropertyState* pVertOrientRelAsChar = 0;
313 	XMLPropertyState* pBackTransparency = NULL; // transparency in %
314 	XMLPropertyState* pBackTransparent = NULL;  // transparency as boolean
315     XMLPropertyState* pAllParaMargin = 0;
316     XMLPropertyState* pParaMargins[4] = { 0, 0, 0, 0 };
317     ::std::auto_ptr<XMLPropertyState> pNewParaMargins[4];
318     XMLPropertyState* pAllMargin = 0;
319     XMLPropertyState* pMargins[4] = { 0, 0, 0, 0 };
320     ::std::auto_ptr<XMLPropertyState> pNewMargins[4];
321 
322 	for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
323 		 aIter != rProperties.end();
324 		 ++aIter )
325 	{
326         XMLPropertyState* property = &(*aIter);
327 		if( -1 == property->mnIndex )
328 			continue;
329 
330 		switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
331 		{
332 		case CTF_FONTFAMILYNAME:	pFontFamilyName = property;	break;
333 		case CTF_FONTSTYLENAME:	pFontStyleName = property;	break;
334 		case CTF_FONTFAMILY:	pFontFamily = property;	break;
335 		case CTF_FONTPITCH:	pFontPitch = property;	break;
336 		case CTF_FONTCHARSET:	pFontCharSet = property;	break;
337 
338 		case CTF_FONTFAMILYNAME_CJK:	pFontFamilyNameCJK = property;	break;
339 		case CTF_FONTSTYLENAME_CJK:	pFontStyleNameCJK = property;	break;
340 		case CTF_FONTFAMILY_CJK:	pFontFamilyCJK = property;	break;
341 		case CTF_FONTPITCH_CJK:	pFontPitchCJK = property;	break;
342 		case CTF_FONTCHARSET_CJK:	pFontCharSetCJK = property;	break;
343 
344 		case CTF_FONTFAMILYNAME_CTL:	pFontFamilyNameCTL = property;	break;
345 		case CTF_FONTSTYLENAME_CTL:	pFontStyleNameCTL = property;	break;
346 		case CTF_FONTFAMILY_CTL:	pFontFamilyCTL = property;	break;
347 		case CTF_FONTPITCH_CTL:	pFontPitchCTL = property;	break;
348 		case CTF_FONTCHARSET_CTL:	pFontCharSetCTL = property;	break;
349 
350 		case CTF_ALLBORDERDISTANCE:		pAllBorderDistance = property; break;
351 		case CTF_LEFTBORDERDISTANCE:	pBorderDistances[XML_LINE_LEFT] = property; break;
352 		case CTF_RIGHTBORDERDISTANCE:	pBorderDistances[XML_LINE_RIGHT] = property; break;
353 		case CTF_TOPBORDERDISTANCE:		pBorderDistances[XML_LINE_TOP] = property; break;
354 		case CTF_BOTTOMBORDERDISTANCE:	pBorderDistances[XML_LINE_BOTTOM] = property; break;
355 		case CTF_ALLBORDER:				pAllBorder = property; break;
356 		case CTF_LEFTBORDER:			pBorders[XML_LINE_LEFT] = property; break;
357 		case CTF_RIGHTBORDER:			pBorders[XML_LINE_RIGHT] = property; break;
358 		case CTF_TOPBORDER:				pBorders[XML_LINE_TOP] = property; break;
359 		case CTF_BOTTOMBORDER:			pBorders[XML_LINE_BOTTOM] = property; break;
360 
361 		case CTF_ALLBORDERWIDTH:		pAllBorderWidth = property; break;
362 		case CTF_LEFTBORDERWIDTH:		pBorderWidths[XML_LINE_LEFT] = property; break;
363 		case CTF_RIGHTBORDERWIDTH:		pBorderWidths[XML_LINE_RIGHT] = property; break;
364 		case CTF_TOPBORDERWIDTH:		pBorderWidths[XML_LINE_TOP] = property; break;
365 		case CTF_BOTTOMBORDERWIDTH:		pBorderWidths[XML_LINE_BOTTOM] = property; break;
366 		case CTF_ANCHORTYPE:			pAnchorType = property; break;
367 		case CTF_VERTICALPOS:  			pVertOrient = property; break;
368 		case CTF_VERTICALREL_ASCHAR: 	pVertOrientRelAsChar = property; break;
369 
370 		case CTF_FRAMEHEIGHT_MIN_ABS:
371 		case CTF_FRAMEHEIGHT_MIN_REL:
372 //		case CTF_SYNCHEIGHT_MIN:
373 										bHasAnyMinHeight = sal_True;
374 										// no break here!
375 		case CTF_FRAMEHEIGHT_ABS:
376 		case CTF_FRAMEHEIGHT_REL:
377 //		case CTF_SYNCHEIGHT:
378 										bHasAnyHeight = sal_True; break;
379 		case CTF_FRAMEWIDTH_MIN_ABS:
380 		case CTF_FRAMEWIDTH_MIN_REL:
381 										bHasAnyMinWidth = sal_True;
382 										// no break here!
383 		case CTF_FRAMEWIDTH_ABS:
384 		case CTF_FRAMEWIDTH_REL:
385 										bHasAnyWidth = sal_True; break;
386         case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break;
387         case CTF_BACKGROUND_TRANSPARENT:  pBackTransparent = property; break;
388         case CTF_PARAMARGINALL:
389         case CTF_PARAMARGINALL_REL:
390                 pAllParaMargin = property; break;
391         case CTF_PARALEFTMARGIN:
392         case CTF_PARALEFTMARGIN_REL:
393                 pParaMargins[XML_LINE_LEFT] = property; break;
394         case CTF_PARARIGHTMARGIN:
395         case CTF_PARARIGHTMARGIN_REL:
396                 pParaMargins[XML_LINE_RIGHT] = property; break;
397         case CTF_PARATOPMARGIN:
398         case CTF_PARATOPMARGIN_REL:
399                 pParaMargins[XML_LINE_TOP] = property; break;
400         case CTF_PARABOTTOMMARGIN:
401         case CTF_PARABOTTOMMARGIN_REL:
402                 pParaMargins[XML_LINE_BOTTOM] = property; break;
403         case CTF_MARGINALL:
404                 pAllMargin = property; break;
405         case CTF_MARGINLEFT:
406                 pMargins[XML_LINE_LEFT] = property; break;
407         case CTF_MARGINRIGHT:
408                 pMargins[XML_LINE_RIGHT] = property; break;
409         case CTF_MARGINTOP:
410                 pMargins[XML_LINE_TOP] = property; break;
411         case CTF_MARGINBOTTOM:
412                 pMargins[XML_LINE_BOTTOM] = property; break;
413 		}
414 	}
415 
416 	if( pFontFamilyName || pFontStyleName || pFontFamily ||
417 		pFontPitch || pFontCharSet )
418 		FontFinished( pFontFamilyName, pFontStyleName, pFontFamily,
419 					  pFontPitch, pFontCharSet );
420 	if( pFontFamilyNameCJK || pFontStyleNameCJK || pFontFamilyCJK ||
421 		pFontPitchCJK || pFontCharSetCJK )
422 		FontFinished( pFontFamilyNameCJK, pFontStyleNameCJK, pFontFamilyCJK,
423 					  pFontPitchCJK, pFontCharSetCJK );
424 	if( pFontFamilyNameCTL || pFontStyleNameCTL || pFontFamilyCTL ||
425 		pFontPitchCTL || pFontCharSetCTL )
426 		FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL,
427 					  pFontPitchCTL, pFontCharSetCTL );
428 
429     for (sal_uInt16 i = 0; i < 4; i++)
430     {
431         if (pAllParaMargin && !pParaMargins[i])
432         {
433 #ifdef DBG_UTIL
434             sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
435                                         pAllParaMargin->mnIndex + (2*i) + 2 );
436             OSL_ENSURE( nTmp >= CTF_PARALEFTMARGIN &&
437                         nTmp <= CTF_PARABOTTOMMARGIN_REL,
438                         "wrong property context id" );
439 #endif
440             pNewParaMargins[i].reset(new XMLPropertyState(
441                 pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue));
442         }
443         if (pAllMargin && !pMargins[i])
444         {
445 #ifdef DBG_UTIL
446             sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
447                                         pAllMargin->mnIndex + i + 1 );
448             OSL_ENSURE( nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM,
449                         "wrong property context id" );
450 #endif
451             pNewMargins[i].reset(new XMLPropertyState(
452                 pAllMargin->mnIndex + i + 1, pAllMargin->maValue));
453         }
454 		if( pAllBorderDistance && !pBorderDistances[i] )
455 		{
456 #ifdef DBG_UTIL
457 			sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
458 										pAllBorderDistance->mnIndex + i + 1 );
459 			DBG_ASSERT( nTmp >= CTF_LEFTBORDERDISTANCE &&
460 						nTmp <= CTF_BOTTOMBORDERDISTANCE,
461 						"wrong property context id" );
462 #endif
463 			pNewBorderDistances[i] =
464 				new XMLPropertyState( pAllBorderDistance->mnIndex + i + 1,
465 									  pAllBorderDistance->maValue );
466 			pBorderDistances[i] = pNewBorderDistances[i];
467 		}
468 		if( pAllBorder && !pBorders[i] )
469 		{
470 #ifdef DBG_UTIL
471 			sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
472 											pAllBorder->mnIndex + i + 1 );
473 			DBG_ASSERT( nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER,
474 						"wrong property context id" );
475 #endif
476 			pNewBorders[i] = new XMLPropertyState( pAllBorder->mnIndex + i + 1,
477 												   pAllBorder->maValue );
478 			pBorders[i] = pNewBorders[i];
479 		}
480 		if( !pBorderWidths[i] )
481 			pBorderWidths[i] = pAllBorderWidth;
482 		else
483 			pBorderWidths[i]->mnIndex = -1;
484 
485 #ifdef XML_CHECK_UI_CONSTRAINS
486 		sal_Bool bHasBorder = sal_False;
487 		if( pBorders[i] )
488 		{
489 			table::BorderLine aBorderLine;
490 			pBorders[i]->maValue >>= aBorderLine;
491 
492  			if( pBorderWidths[i] )
493 			{
494 				table::BorderLine aBorderLineWidth;
495 				pBorderWidths[i]->maValue >>= aBorderLineWidth;
496 				aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
497 				aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
498 				aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
499 
500 				pBorders[i]->maValue <<= aBorderLine;
501 			}
502 			bHasBorder = (aBorderLine.OuterLineWidth +
503 						  aBorderLine.InnerLineWidth) > 0;
504 		}
505 		if( bHasBorder )
506 		{
507 			if( !pBorderDistances[i] )
508 			{
509 #ifdef DBG_UTIL
510 				sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
511 										pBorders[i]->mnIndex + 5 );
512 				DBG_ASSERT( nTmp >= CTF_LEFTBORDERDISTANCE &&
513 							nTmp <= CTF_BOTTOMBORDERDISTANCE,
514 							"wrong property context id" );
515 #endif
516 
517 				pNewBorderDistances[i] =
518 					new XMLPropertyState( pBorders[i]->mnIndex + 5 );
519 				pNewBorderDistances[i]->maValue <<= (sal_Int32)MIN_BORDER_DIST;
520 				pBorderDistances[i] = pNewBorderDistances[i];
521 			}
522 			else
523 			{
524 				sal_Int32 nDist;
525 				pBorderDistances[i]->maValue >>= nDist;
526 				if( nDist < MIN_BORDER_DIST )
527 					pBorderDistances[i]->maValue <<= (sal_Int32)MIN_BORDER_DIST;
528 			}
529 		}
530 		else
531 		{
532 			if( pBorderDistances[i] )
533 			{
534 				sal_Int32 nDist;
535 				pBorderDistances[i]->maValue >>= nDist;
536 				if( nDist > 0 )
537 					pBorderDistances[i]->maValue <<= (sal_Int32)0;
538 			}
539 		}
540 #else
541 		if( pBorders[i] && pBorderWidths[i] )
542 		{
543 			table::BorderLine aBorderLine;
544 			pBorders[i]->maValue >>= aBorderLine;
545 
546 			table::BorderLine aBorderLineWidth;
547 			pBorderWidths[i]->maValue >>= aBorderLineWidth;
548 
549 			aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
550 			aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
551 			aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
552 
553 			pBorders[i]->maValue <<= aBorderLine;
554 		}
555 #endif
556 	}
557 
558     if (pAllParaMargin)
559     {
560         pAllParaMargin->mnIndex = -1;
561     }
562     if (pAllMargin)
563     {
564         pAllMargin->mnIndex = -1;
565     }
566 
567 	if( pAllBorderDistance )
568 		pAllBorderDistance->mnIndex = -1;
569 
570 	if( pAllBorder )
571 		pAllBorder->mnIndex = -1;
572 
573 	if( pAllBorderWidth )
574 		pAllBorderWidth->mnIndex = -1;
575 
576 	if( pVertOrient && pVertOrientRelAsChar )
577 	{
578 		sal_Int16 nVertOrient;
579 		pVertOrient->maValue >>= nVertOrient;
580 		sal_Int16 nVertOrientRel = 0;
581 		pVertOrientRelAsChar->maValue >>= nVertOrientRel;
582 		switch( nVertOrient )
583 		{
584 		case VertOrientation::TOP:
585 			nVertOrient = nVertOrientRel;
586 			break;
587 		case VertOrientation::CENTER:
588 			switch( nVertOrientRel )
589 			{
590 			case VertOrientation::CHAR_TOP:
591 				nVertOrient = VertOrientation::CHAR_CENTER;
592 				break;
593 			case VertOrientation::LINE_TOP:
594 				nVertOrient = VertOrientation::LINE_CENTER;
595 				break;
596 			}
597 			break;
598 		case VertOrientation::BOTTOM:
599 			switch( nVertOrientRel )
600 			{
601 			case VertOrientation::CHAR_TOP:
602 				nVertOrient = VertOrientation::CHAR_BOTTOM;
603 				break;
604 			case VertOrientation::LINE_TOP:
605 				nVertOrient = VertOrientation::LINE_BOTTOM;
606 				break;
607 			}
608 			break;
609 		}
610 		pVertOrient->maValue <<= nVertOrient;
611 		pVertOrientRelAsChar->mnIndex = -1;
612 	}
613 
614 	FontDefaultsCheck( pFontFamilyName,
615 					   pFontStyleName, pFontFamily, pFontPitch, pFontCharSet,
616 					   &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet );
617 
618 	FontDefaultsCheck( pFontFamilyNameCJK,
619 					   pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK,
620 					   &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK );
621 
622 	FontDefaultsCheck( pFontFamilyNameCTL,
623 					   pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
624 					   &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
625 
626     // #i5775# don't overwrite %transparency with binary transparency
627     if( ( pBackTransparency != NULL ) && ( pBackTransparent != NULL ) )
628     {
629         if( ! *(sal_Bool*)(pBackTransparent->maValue.getValue()) )
630             pBackTransparent->mnIndex = -1;
631     }
632 
633 
634 	// insert newly created properties. This inavlidates all iterators!
635     // Most of the pXXX variables in this method are iterators and will be
636     // invalidated!!!
637 
638 	if( pNewFontStyleName )
639 	{
640 		rProperties.push_back( *pNewFontStyleName );
641 		delete pNewFontStyleName;
642 	}
643 
644 	if( pNewFontFamily )
645 	{
646 		rProperties.push_back( *pNewFontFamily );
647 		delete pNewFontFamily;
648 	}
649 
650 	if( pNewFontPitch )
651 	{
652 		rProperties.push_back( *pNewFontPitch );
653 		delete pNewFontPitch;
654 	}
655 
656 	if( pNewFontCharSet )
657 	{
658 		rProperties.push_back( *pNewFontCharSet );
659 		delete pNewFontCharSet;
660 	}
661 
662 	if( pNewFontStyleNameCJK )
663 	{
664 		rProperties.push_back( *pNewFontStyleNameCJK );
665 		delete pNewFontStyleNameCJK;
666 	}
667 
668 	if( pNewFontFamilyCJK )
669 	{
670 		rProperties.push_back( *pNewFontFamilyCJK );
671 		delete pNewFontFamilyCJK;
672 	}
673 
674 	if( pNewFontPitchCJK )
675 	{
676 		rProperties.push_back( *pNewFontPitchCJK );
677 		delete pNewFontPitchCJK;
678 	}
679 
680 	if( pNewFontCharSetCJK )
681 	{
682 		rProperties.push_back( *pNewFontCharSetCJK );
683 		delete pNewFontCharSetCJK;
684 	}
685 
686 	if( pNewFontStyleNameCTL)
687 	{
688 		rProperties.push_back( *pNewFontStyleNameCTL );
689 		delete pNewFontStyleNameCTL;
690 	}
691 
692 	if( pNewFontFamilyCTL )
693 	{
694 		rProperties.push_back( *pNewFontFamilyCTL );
695 		delete pNewFontFamilyCTL;
696 	}
697 
698 	if( pNewFontPitchCTL )
699 	{
700 		rProperties.push_back( *pNewFontPitchCTL );
701 		delete pNewFontPitchCTL;
702 	}
703 
704 	if( pNewFontCharSetCTL )
705 	{
706 		rProperties.push_back( *pNewFontCharSetCTL );
707 		delete pNewFontCharSetCTL;
708 	}
709 
710     for (sal_uInt16 i=0; i<4; i++)
711     {
712         if (pNewParaMargins[i].get())
713         {
714             rProperties.push_back(*pNewParaMargins[i]);
715         }
716         if (pNewMargins[i].get())
717         {
718             rProperties.push_back(*pNewMargins[i]);
719         }
720 		if( pNewBorderDistances[i] )
721 		{
722 			rProperties.push_back( *pNewBorderDistances[i] );
723 			delete pNewBorderDistances[i];
724 		}
725 		if( pNewBorders[i] )
726 		{
727 			rProperties.push_back( *pNewBorders[i] );
728 			delete pNewBorders[i];
729 		}
730 	}
731 
732 	if( bHasAnyHeight )
733 	{
734 		if( nSizeTypeIndex == -2 )
735 		{
736 			const_cast < XMLTextImportPropertyMapper * > ( this )
737 				->nSizeTypeIndex  = -1;
738 			sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount();
739 			for( sal_Int32 j=0; j < nPropCount; j++ )
740 			{
741 				if( CTF_SIZETYPE == getPropertySetMapper()
742 						->GetEntryContextId( j ) )
743 				{
744 					const_cast < XMLTextImportPropertyMapper * > ( this )
745 						->nSizeTypeIndex = j;
746 					break;
747 				}
748 			}
749 		}
750 		if( nSizeTypeIndex != -1 )
751 		{
752 			XMLPropertyState aSizeTypeState( nSizeTypeIndex );
753 			aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinHeight
754 														? SizeType::MIN
755 														: SizeType::FIX);
756 			rProperties.push_back( aSizeTypeState );
757 		}
758 	}
759 
760 	if( bHasAnyWidth )
761 	{
762 		if( nWidthTypeIndex == -2 )
763 		{
764 			const_cast < XMLTextImportPropertyMapper * > ( this )
765 				->nWidthTypeIndex  = -1;
766 			sal_Int32 nCount = getPropertySetMapper()->GetEntryCount();
767 			for( sal_Int32 j=0; j < nCount; j++ )
768 			{
769 				if( CTF_FRAMEWIDTH_TYPE	 == getPropertySetMapper()
770 						->GetEntryContextId( j ) )
771 				{
772 					const_cast < XMLTextImportPropertyMapper * > ( this )
773 						->nWidthTypeIndex = j;
774 					break;
775 				}
776 			}
777 		}
778 		if( nWidthTypeIndex != -1 )
779 		{
780 			XMLPropertyState aSizeTypeState( nWidthTypeIndex );
781 			aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinWidth
782 														? SizeType::MIN
783 														: SizeType::FIX);
784 			rProperties.push_back( aSizeTypeState );
785 		}
786 	}
787 
788     // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER
789     // THIS LINE.  All iterators into the rProperties-vector, especially all
790     // pXXX-type variables set in the first switch statement of this method,
791     // may have been invalidated by the above push_back() calls!
792 }
793 
794 
795