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