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 316 XMLPropertyState* pAllParaMargin = 0; 317 XMLPropertyState* pParaMargins[4] = { 0, 0, 0, 0 }; 318 ::std::auto_ptr<XMLPropertyState> pNewParaMargins[4]; 319 320 XMLPropertyState* pAllMargin = 0; 321 XMLPropertyState* pMargins[4] = { 0, 0, 0, 0 }; 322 ::std::auto_ptr<XMLPropertyState> pNewMargins[4]; 323 324 for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin(); 325 aIter != rProperties.end(); 326 ++aIter ) 327 { 328 XMLPropertyState* property = &(*aIter); 329 if( -1 == property->mnIndex ) 330 continue; 331 332 switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) ) 333 { 334 case CTF_FONTFAMILYNAME: pFontFamilyName = property; break; 335 case CTF_FONTSTYLENAME: pFontStyleName = property; break; 336 case CTF_FONTFAMILY: pFontFamily = property; break; 337 case CTF_FONTPITCH: pFontPitch = property; break; 338 case CTF_FONTCHARSET: pFontCharSet = property; break; 339 340 case CTF_FONTFAMILYNAME_CJK: pFontFamilyNameCJK = property; break; 341 case CTF_FONTSTYLENAME_CJK: pFontStyleNameCJK = property; break; 342 case CTF_FONTFAMILY_CJK: pFontFamilyCJK = property; break; 343 case CTF_FONTPITCH_CJK: pFontPitchCJK = property; break; 344 case CTF_FONTCHARSET_CJK: pFontCharSetCJK = property; break; 345 346 case CTF_FONTFAMILYNAME_CTL: pFontFamilyNameCTL = property; break; 347 case CTF_FONTSTYLENAME_CTL: pFontStyleNameCTL = property; break; 348 case CTF_FONTFAMILY_CTL: pFontFamilyCTL = property; break; 349 case CTF_FONTPITCH_CTL: pFontPitchCTL = property; break; 350 case CTF_FONTCHARSET_CTL: pFontCharSetCTL = property; break; 351 352 case CTF_ALLBORDERDISTANCE: pAllBorderDistance = property; break; 353 case CTF_LEFTBORDERDISTANCE: pBorderDistances[XML_LINE_LEFT] = property; break; 354 case CTF_RIGHTBORDERDISTANCE: pBorderDistances[XML_LINE_RIGHT] = property; break; 355 case CTF_TOPBORDERDISTANCE: pBorderDistances[XML_LINE_TOP] = property; break; 356 case CTF_BOTTOMBORDERDISTANCE: pBorderDistances[XML_LINE_BOTTOM] = property; break; 357 case CTF_ALLBORDER: pAllBorder = property; break; 358 case CTF_LEFTBORDER: pBorders[XML_LINE_LEFT] = property; break; 359 case CTF_RIGHTBORDER: pBorders[XML_LINE_RIGHT] = property; break; 360 case CTF_TOPBORDER: pBorders[XML_LINE_TOP] = property; break; 361 case CTF_BOTTOMBORDER: pBorders[XML_LINE_BOTTOM] = property; break; 362 363 case CTF_ALLBORDERWIDTH: pAllBorderWidth = property; break; 364 case CTF_LEFTBORDERWIDTH: pBorderWidths[XML_LINE_LEFT] = property; break; 365 case CTF_RIGHTBORDERWIDTH: pBorderWidths[XML_LINE_RIGHT] = property; break; 366 case CTF_TOPBORDERWIDTH: pBorderWidths[XML_LINE_TOP] = property; break; 367 case CTF_BOTTOMBORDERWIDTH: pBorderWidths[XML_LINE_BOTTOM] = property; break; 368 case CTF_ANCHORTYPE: pAnchorType = property; break; 369 case CTF_VERTICALPOS: pVertOrient = property; break; 370 case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break; 371 372 case CTF_FRAMEHEIGHT_MIN_ABS: 373 case CTF_FRAMEHEIGHT_MIN_REL: 374 // case CTF_SYNCHEIGHT_MIN: 375 bHasAnyMinHeight = sal_True; 376 // no break here! 377 case CTF_FRAMEHEIGHT_ABS: 378 case CTF_FRAMEHEIGHT_REL: 379 // case CTF_SYNCHEIGHT: 380 bHasAnyHeight = sal_True; break; 381 case CTF_FRAMEWIDTH_MIN_ABS: 382 case CTF_FRAMEWIDTH_MIN_REL: 383 bHasAnyMinWidth = sal_True; 384 // no break here! 385 case CTF_FRAMEWIDTH_ABS: 386 case CTF_FRAMEWIDTH_REL: 387 bHasAnyWidth = sal_True; break; 388 case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break; 389 case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break; 390 391 case CTF_PARAMARGINALL: 392 pAllParaMargin = property; 393 break; 394 case CTF_PARAMARGINALL_REL: 395 { 396 sal_uInt32 nValue; 397 property->maValue >>= nValue; 398 // treat fo:margin="100%" as it is not exisiting as the 399 // corresponding core attribute classes - <SvxULSpaceItem> and 400 // <SvxLRSpaceItem> - are not able to treat such a value correctly. 401 // The result will be the same as the values will be inherited 402 // from parent, when the no margin attribute is given. 403 if ( nValue != 100 ) 404 { 405 pAllParaMargin = property; 406 } 407 } 408 break; 409 410 case CTF_PARALEFTMARGIN: 411 case CTF_PARALEFTMARGIN_REL: 412 pParaMargins[XML_LINE_LEFT] = property; break; 413 414 case CTF_PARARIGHTMARGIN: 415 case CTF_PARARIGHTMARGIN_REL: 416 pParaMargins[XML_LINE_RIGHT] = property; break; 417 418 case CTF_PARATOPMARGIN: 419 case CTF_PARATOPMARGIN_REL: 420 pParaMargins[XML_LINE_TOP] = property; break; 421 422 case CTF_PARABOTTOMMARGIN: 423 case CTF_PARABOTTOMMARGIN_REL: 424 pParaMargins[XML_LINE_BOTTOM] = property; break; 425 426 case CTF_MARGINALL: 427 pAllMargin = property; break; 428 case CTF_MARGINLEFT: 429 pMargins[XML_LINE_LEFT] = property; break; 430 case CTF_MARGINRIGHT: 431 pMargins[XML_LINE_RIGHT] = property; break; 432 case CTF_MARGINTOP: 433 pMargins[XML_LINE_TOP] = property; break; 434 case CTF_MARGINBOTTOM: 435 pMargins[XML_LINE_BOTTOM] = property; break; 436 } 437 } 438 439 if( pFontFamilyName || pFontStyleName || pFontFamily || 440 pFontPitch || pFontCharSet ) 441 FontFinished( pFontFamilyName, pFontStyleName, pFontFamily, 442 pFontPitch, pFontCharSet ); 443 if( pFontFamilyNameCJK || pFontStyleNameCJK || pFontFamilyCJK || 444 pFontPitchCJK || pFontCharSetCJK ) 445 FontFinished( pFontFamilyNameCJK, pFontStyleNameCJK, pFontFamilyCJK, 446 pFontPitchCJK, pFontCharSetCJK ); 447 if( pFontFamilyNameCTL || pFontStyleNameCTL || pFontFamilyCTL || 448 pFontPitchCTL || pFontCharSetCTL ) 449 FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL, 450 pFontPitchCTL, pFontCharSetCTL ); 451 452 for (sal_uInt16 i = 0; i < 4; i++) 453 { 454 if ( pAllParaMargin != NULL 455 && pParaMargins[i] == NULL ) 456 { 457 #ifdef DBG_UTIL 458 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId( 459 pAllParaMargin->mnIndex + (2*i) + 2 ); 460 OSL_ENSURE( nTmp >= CTF_PARALEFTMARGIN && 461 nTmp <= CTF_PARABOTTOMMARGIN_REL, 462 "wrong property context id" ); 463 #endif 464 // IMPORTANT NOTE: the index calculation depends on the right order in the property map 465 pNewParaMargins[i].reset( 466 new XMLPropertyState( pAllParaMargin->mnIndex + (2*i) + 2, 467 pAllParaMargin->maValue ) ); 468 } 469 470 if (pAllMargin && !pMargins[i]) 471 { 472 #ifdef DBG_UTIL 473 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId( 474 pAllMargin->mnIndex + i + 1 ); 475 OSL_ENSURE( nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM, 476 "wrong property context id" ); 477 #endif 478 // IMPORTANT NOTE: the index calculation depends on the right order in the property map 479 pNewMargins[i].reset( 480 new XMLPropertyState( pAllMargin->mnIndex + i + 1, 481 pAllMargin->maValue ) ); 482 } 483 if( pAllBorderDistance && !pBorderDistances[i] ) 484 { 485 #ifdef DBG_UTIL 486 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId( 487 pAllBorderDistance->mnIndex + i + 1 ); 488 DBG_ASSERT( nTmp >= CTF_LEFTBORDERDISTANCE && 489 nTmp <= CTF_BOTTOMBORDERDISTANCE, 490 "wrong property context id" ); 491 #endif 492 pNewBorderDistances[i] = 493 new XMLPropertyState( pAllBorderDistance->mnIndex + i + 1, 494 pAllBorderDistance->maValue ); 495 pBorderDistances[i] = pNewBorderDistances[i]; 496 } 497 if( pAllBorder && !pBorders[i] ) 498 { 499 #ifdef DBG_UTIL 500 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId( 501 pAllBorder->mnIndex + i + 1 ); 502 DBG_ASSERT( nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER, 503 "wrong property context id" ); 504 #endif 505 pNewBorders[i] = new XMLPropertyState( pAllBorder->mnIndex + i + 1, 506 pAllBorder->maValue ); 507 pBorders[i] = pNewBorders[i]; 508 } 509 if( !pBorderWidths[i] ) 510 pBorderWidths[i] = pAllBorderWidth; 511 else 512 pBorderWidths[i]->mnIndex = -1; 513 514 #ifdef XML_CHECK_UI_CONSTRAINS 515 sal_Bool bHasBorder = sal_False; 516 if( pBorders[i] ) 517 { 518 table::BorderLine aBorderLine; 519 pBorders[i]->maValue >>= aBorderLine; 520 521 if( pBorderWidths[i] ) 522 { 523 table::BorderLine aBorderLineWidth; 524 pBorderWidths[i]->maValue >>= aBorderLineWidth; 525 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; 526 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; 527 aBorderLine.LineDistance = aBorderLineWidth.LineDistance; 528 529 pBorders[i]->maValue <<= aBorderLine; 530 } 531 bHasBorder = (aBorderLine.OuterLineWidth + 532 aBorderLine.InnerLineWidth) > 0; 533 } 534 if( bHasBorder ) 535 { 536 if( !pBorderDistances[i] ) 537 { 538 #ifdef DBG_UTIL 539 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId( 540 pBorders[i]->mnIndex + 5 ); 541 DBG_ASSERT( nTmp >= CTF_LEFTBORDERDISTANCE && 542 nTmp <= CTF_BOTTOMBORDERDISTANCE, 543 "wrong property context id" ); 544 #endif 545 546 pNewBorderDistances[i] = 547 new XMLPropertyState( pBorders[i]->mnIndex + 5 ); 548 pNewBorderDistances[i]->maValue <<= (sal_Int32)MIN_BORDER_DIST; 549 pBorderDistances[i] = pNewBorderDistances[i]; 550 } 551 else 552 { 553 sal_Int32 nDist; 554 pBorderDistances[i]->maValue >>= nDist; 555 if( nDist < MIN_BORDER_DIST ) 556 pBorderDistances[i]->maValue <<= (sal_Int32)MIN_BORDER_DIST; 557 } 558 } 559 else 560 { 561 if( pBorderDistances[i] ) 562 { 563 sal_Int32 nDist; 564 pBorderDistances[i]->maValue >>= nDist; 565 if( nDist > 0 ) 566 pBorderDistances[i]->maValue <<= (sal_Int32)0; 567 } 568 } 569 #else 570 if( pBorders[i] && pBorderWidths[i] ) 571 { 572 table::BorderLine aBorderLine; 573 pBorders[i]->maValue >>= aBorderLine; 574 575 table::BorderLine aBorderLineWidth; 576 pBorderWidths[i]->maValue >>= aBorderLineWidth; 577 578 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; 579 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; 580 aBorderLine.LineDistance = aBorderLineWidth.LineDistance; 581 582 pBorders[i]->maValue <<= aBorderLine; 583 } 584 #endif 585 } 586 587 if (pAllParaMargin) 588 { 589 pAllParaMargin->mnIndex = -1; 590 } 591 if (pAllMargin) 592 { 593 pAllMargin->mnIndex = -1; 594 } 595 596 if( pAllBorderDistance ) 597 pAllBorderDistance->mnIndex = -1; 598 599 if( pAllBorder ) 600 pAllBorder->mnIndex = -1; 601 602 if( pAllBorderWidth ) 603 pAllBorderWidth->mnIndex = -1; 604 605 if( pVertOrient && pVertOrientRelAsChar ) 606 { 607 sal_Int16 nVertOrient; 608 pVertOrient->maValue >>= nVertOrient; 609 sal_Int16 nVertOrientRel = 0; 610 pVertOrientRelAsChar->maValue >>= nVertOrientRel; 611 switch( nVertOrient ) 612 { 613 case VertOrientation::TOP: 614 nVertOrient = nVertOrientRel; 615 break; 616 case VertOrientation::CENTER: 617 switch( nVertOrientRel ) 618 { 619 case VertOrientation::CHAR_TOP: 620 nVertOrient = VertOrientation::CHAR_CENTER; 621 break; 622 case VertOrientation::LINE_TOP: 623 nVertOrient = VertOrientation::LINE_CENTER; 624 break; 625 } 626 break; 627 case VertOrientation::BOTTOM: 628 switch( nVertOrientRel ) 629 { 630 case VertOrientation::CHAR_TOP: 631 nVertOrient = VertOrientation::CHAR_BOTTOM; 632 break; 633 case VertOrientation::LINE_TOP: 634 nVertOrient = VertOrientation::LINE_BOTTOM; 635 break; 636 } 637 break; 638 } 639 pVertOrient->maValue <<= nVertOrient; 640 pVertOrientRelAsChar->mnIndex = -1; 641 } 642 643 FontDefaultsCheck( pFontFamilyName, 644 pFontStyleName, pFontFamily, pFontPitch, pFontCharSet, 645 &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet ); 646 647 FontDefaultsCheck( pFontFamilyNameCJK, 648 pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK, 649 &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK ); 650 651 FontDefaultsCheck( pFontFamilyNameCTL, 652 pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL, 653 &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL ); 654 655 // #i5775# don't overwrite %transparency with binary transparency 656 if( ( pBackTransparency != NULL ) && ( pBackTransparent != NULL ) ) 657 { 658 if( ! *(sal_Bool*)(pBackTransparent->maValue.getValue()) ) 659 pBackTransparent->mnIndex = -1; 660 } 661 662 663 // insert newly created properties. This inavlidates all iterators! 664 // Most of the pXXX variables in this method are iterators and will be 665 // invalidated!!! 666 667 if( pNewFontStyleName ) 668 { 669 rProperties.push_back( *pNewFontStyleName ); 670 delete pNewFontStyleName; 671 } 672 673 if( pNewFontFamily ) 674 { 675 rProperties.push_back( *pNewFontFamily ); 676 delete pNewFontFamily; 677 } 678 679 if( pNewFontPitch ) 680 { 681 rProperties.push_back( *pNewFontPitch ); 682 delete pNewFontPitch; 683 } 684 685 if( pNewFontCharSet ) 686 { 687 rProperties.push_back( *pNewFontCharSet ); 688 delete pNewFontCharSet; 689 } 690 691 if( pNewFontStyleNameCJK ) 692 { 693 rProperties.push_back( *pNewFontStyleNameCJK ); 694 delete pNewFontStyleNameCJK; 695 } 696 697 if( pNewFontFamilyCJK ) 698 { 699 rProperties.push_back( *pNewFontFamilyCJK ); 700 delete pNewFontFamilyCJK; 701 } 702 703 if( pNewFontPitchCJK ) 704 { 705 rProperties.push_back( *pNewFontPitchCJK ); 706 delete pNewFontPitchCJK; 707 } 708 709 if( pNewFontCharSetCJK ) 710 { 711 rProperties.push_back( *pNewFontCharSetCJK ); 712 delete pNewFontCharSetCJK; 713 } 714 715 if( pNewFontStyleNameCTL) 716 { 717 rProperties.push_back( *pNewFontStyleNameCTL ); 718 delete pNewFontStyleNameCTL; 719 } 720 721 if( pNewFontFamilyCTL ) 722 { 723 rProperties.push_back( *pNewFontFamilyCTL ); 724 delete pNewFontFamilyCTL; 725 } 726 727 if( pNewFontPitchCTL ) 728 { 729 rProperties.push_back( *pNewFontPitchCTL ); 730 delete pNewFontPitchCTL; 731 } 732 733 if( pNewFontCharSetCTL ) 734 { 735 rProperties.push_back( *pNewFontCharSetCTL ); 736 delete pNewFontCharSetCTL; 737 } 738 739 for (sal_uInt16 i=0; i<4; i++) 740 { 741 if (pNewParaMargins[i].get()) 742 { 743 rProperties.push_back(*pNewParaMargins[i]); 744 } 745 if (pNewMargins[i].get()) 746 { 747 rProperties.push_back(*pNewMargins[i]); 748 } 749 if( pNewBorderDistances[i] ) 750 { 751 rProperties.push_back( *pNewBorderDistances[i] ); 752 delete pNewBorderDistances[i]; 753 } 754 if( pNewBorders[i] ) 755 { 756 rProperties.push_back( *pNewBorders[i] ); 757 delete pNewBorders[i]; 758 } 759 } 760 761 if( bHasAnyHeight ) 762 { 763 if( nSizeTypeIndex == -2 ) 764 { 765 const_cast < XMLTextImportPropertyMapper * > ( this ) 766 ->nSizeTypeIndex = -1; 767 sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount(); 768 for( sal_Int32 j=0; j < nPropCount; j++ ) 769 { 770 if( CTF_SIZETYPE == getPropertySetMapper() 771 ->GetEntryContextId( j ) ) 772 { 773 const_cast < XMLTextImportPropertyMapper * > ( this ) 774 ->nSizeTypeIndex = j; 775 break; 776 } 777 } 778 } 779 if( nSizeTypeIndex != -1 ) 780 { 781 XMLPropertyState aSizeTypeState( nSizeTypeIndex ); 782 aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinHeight 783 ? SizeType::MIN 784 : SizeType::FIX); 785 rProperties.push_back( aSizeTypeState ); 786 } 787 } 788 789 if( bHasAnyWidth ) 790 { 791 if( nWidthTypeIndex == -2 ) 792 { 793 const_cast < XMLTextImportPropertyMapper * > ( this ) 794 ->nWidthTypeIndex = -1; 795 sal_Int32 nCount = getPropertySetMapper()->GetEntryCount(); 796 for( sal_Int32 j=0; j < nCount; j++ ) 797 { 798 if( CTF_FRAMEWIDTH_TYPE == getPropertySetMapper() 799 ->GetEntryContextId( j ) ) 800 { 801 const_cast < XMLTextImportPropertyMapper * > ( this ) 802 ->nWidthTypeIndex = j; 803 break; 804 } 805 } 806 } 807 if( nWidthTypeIndex != -1 ) 808 { 809 XMLPropertyState aSizeTypeState( nWidthTypeIndex ); 810 aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinWidth 811 ? SizeType::MIN 812 : SizeType::FIX); 813 rProperties.push_back( aSizeTypeState ); 814 } 815 } 816 817 // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER 818 // THIS LINE. All iterators into the rProperties-vector, especially all 819 // pXXX-type variables set in the first switch statement of this method, 820 // may have been invalidated by the above push_back() calls! 821 } 822 823 824