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 27 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 28 #include <com/sun/star/style/NumberingType.hpp> 29 #include <com/sun/star/style/XStyle.hpp> 30 #include <com/sun/star/container/XNameContainer.hpp> 31 #include <com/sun/star/container/XIndexReplace.hpp> 32 #include <com/sun/star/awt/XBitmap.hpp> 33 #include <com/sun/star/awt/FontDescriptor.hpp> 34 #include <com/sun/star/text/HoriOrientation.hpp> 35 #include <com/sun/star/text/VertOrientation.hpp> 36 #include <com/sun/star/text/XChapterNumberingSupplier.hpp> 37 // --> OD 2008-01-16 #newlistlevelattrs# 38 #include <com/sun/star/text/PositionAndSpaceMode.hpp> 39 #include <com/sun/star/text/LabelFollow.hpp> 40 // <-- 41 #include <com/sun/star/beans/PropertyValue.hpp> 42 #include <com/sun/star/beans/XPropertySet.hpp> 43 44 #include <rtl/ustrbuf.hxx> 45 46 #include <tools/debug.hxx> 47 48 #include <xmloff/nmspmap.hxx> 49 #include "xmloff/xmlnmspe.hxx" 50 #include <xmloff/xmltoken.hxx> 51 #include <xmloff/xmluconv.hxx> 52 #include "fonthdl.hxx" 53 #include "xmloff/XMLTextListAutoStylePool.hxx" 54 #include <xmloff/xmlnume.hxx> 55 #include <xmloff/xmlexp.hxx> 56 #include <tools/fontenum.hxx> 57 58 59 using ::rtl::OUString; 60 using ::rtl::OUStringBuffer; 61 62 using namespace ::com::sun::star; 63 using namespace ::com::sun::star::uno; 64 using namespace ::com::sun::star::style; 65 using namespace ::com::sun::star::text; 66 using namespace ::com::sun::star::container; 67 using namespace ::com::sun::star::beans; 68 using namespace ::xmloff::token; 69 70 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE[] = "SymbolTextDistance"; 71 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_PARENT_NUMBERING[] = "ParentNumbering"; 72 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_CHAR_STYLE_NAME[] = "CharStyleName"; 73 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_CHAR[] = "BulletChar"; 74 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_RELSIZE[] = "BulletRelSize"; 75 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_COLOR[] = "BulletColor"; 76 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_GRAPHIC_BITMAP[] = "GraphicBitmap"; 77 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_GRAPHIC_SIZE[] = "GraphicSize"; 78 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_VERT_ORIENT[] = "VertOrient"; 79 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_NUMBERINGTYPE[] = "NumberingType"; 80 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_HEADING_STYLE_NAME[] = "HeadingStyleName"; 81 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_PREFIX[] = "Prefix"; 82 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_SUFFIX[] = "Suffix"; 83 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_ADJUST[] = "Adjust"; 84 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LEFT_MARGIN[] = "LeftMargin"; 85 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET[] = "FirstLineOffset"; 86 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_BULLET_FONT[] = "BulletFont"; 87 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_GRAPHICURL[] = "GraphicURL"; 88 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_START_WITH[] = "StartWith"; 89 // --> OD 2008-01-15 #newlistlevelattrs# 90 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE[] = "PositionAndSpaceMode"; 91 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY[] = "LabelFollowedBy"; 92 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION[] = "ListtabStopPosition"; 93 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_FIRST_LINE_INDENT[] = "FirstLineIndent"; 94 static sal_Char __READONLY_DATA XML_UNO_NAME_NRULE_INDENT_AT[] = "IndentAt"; 95 // <-- 96 97 void SvxXMLNumRuleExport::exportLevelStyles( const uno::Reference< ::com::sun::star::container::XIndexReplace > & xNumRule, 98 sal_Bool bOutline ) 99 { 100 sal_Int32 nCount = xNumRule ->getCount(); 101 for( sal_Int32 i=0; i<nCount; i++ ) 102 { 103 uno::Any aEntry( xNumRule->getByIndex( i ) ); 104 uno::Sequence<beans::PropertyValue> aSeq; 105 if( aEntry >>= aSeq ) 106 { 107 exportLevelStyle( i, aSeq, bOutline ); 108 } 109 } 110 } 111 112 void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel, 113 const uno::Sequence<beans::PropertyValue>& rProps, 114 sal_Bool bOutline ) 115 { 116 sal_Int16 eType = NumberingType::CHAR_SPECIAL; 117 118 sal_Int16 eAdjust = HoriOrientation::LEFT; 119 OUString sPrefix, sSuffix; 120 OUString sTextStyleName; 121 sal_Bool bHasColor = sal_False; 122 sal_Int32 nColor = 0; 123 sal_Int32 nSpaceBefore = 0, nMinLabelWidth = 0, nMinLabelDist = 0; 124 125 sal_Int16 nStartValue = 1, nDisplayLevels = 1, nBullRelSize = 0; 126 127 sal_Unicode cBullet = 0xf095; 128 OUString sBulletFontName, sBulletFontStyleName ; 129 sal_Int16 eBulletFontFamily = FAMILY_DONTKNOW; 130 sal_Int16 eBulletFontPitch = PITCH_DONTKNOW; 131 rtl_TextEncoding eBulletFontEncoding = RTL_TEXTENCODING_DONTKNOW; 132 133 OUString sImageURL; 134 uno::Reference< ::com::sun::star::awt::XBitmap > xBitmap; 135 sal_Int32 nImageWidth = 0, nImageHeight = 0; 136 sal_Int16 eImageVertOrient = VertOrientation::LINE_CENTER; 137 138 // --> OD 2008-01-15 #newlistlevelattrs# 139 sal_Int16 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION; 140 sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB; 141 sal_Int32 nListtabStopPosition( 0 ); 142 sal_Int32 nFirstLineIndent( 0 ); 143 sal_Int32 nIndentAt( 0 ); 144 // <-- 145 146 const sal_Int32 nCount = rProps.getLength(); 147 const beans::PropertyValue* pPropArray = rProps.getConstArray(); 148 for( sal_Int32 i=0; i<nCount; i++ ) 149 { 150 const beans::PropertyValue& rProp = pPropArray[i]; 151 152 if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_NUMBERINGTYPE, sizeof(XML_UNO_NAME_NRULE_NUMBERINGTYPE)-1 ) ) 153 { 154 rProp.Value >>= eType; 155 } 156 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_PREFIX, sizeof(XML_UNO_NAME_NRULE_PREFIX)-1 ) ) 157 { 158 rProp.Value >>= sPrefix; 159 } 160 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_SUFFIX, sizeof(XML_UNO_NAME_NRULE_SUFFIX)-1 ) ) 161 { 162 rProp.Value >>= sSuffix; 163 } 164 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_BULLET_CHAR, sizeof(XML_UNO_NAME_NRULE_BULLET_CHAR)-1 ) ) 165 { 166 OUString sValue; 167 rProp.Value >>= sValue; 168 if( sValue.getLength() > 0 ) 169 { 170 cBullet = (sal_Unicode)sValue[0]; 171 } 172 } 173 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_BULLET_RELSIZE, sizeof(XML_UNO_NAME_NRULE_BULLET_RELSIZE)-1 ) ) 174 { 175 rProp.Value >>= nBullRelSize; 176 } 177 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_ADJUST, sizeof(XML_UNO_NAME_NRULE_ADJUST)-1 ) ) 178 { 179 sal_Int16 nValue = 0; 180 rProp.Value >>= nValue; 181 eAdjust = nValue; 182 } 183 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_BULLET_FONT, sizeof(XML_UNO_NAME_NRULE_BULLET_FONT)-1 ) ) 184 { 185 awt::FontDescriptor rFDesc; 186 if( rProp.Value >>= rFDesc ) 187 { 188 sBulletFontName = rFDesc.Name; 189 sBulletFontStyleName = rFDesc.StyleName; 190 eBulletFontFamily = (sal_Int16)rFDesc.Family; 191 eBulletFontPitch = (sal_Int16)rFDesc.Pitch; 192 eBulletFontEncoding = (rtl_TextEncoding)rFDesc.CharSet; 193 } 194 } 195 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_GRAPHICURL, sizeof(XML_UNO_NAME_NRULE_GRAPHICURL)-1 ) ) 196 { 197 rProp.Value >>= sImageURL; 198 } 199 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_GRAPHIC_BITMAP, sizeof(XML_UNO_NAME_NRULE_GRAPHIC_BITMAP)-1 ) ) 200 { 201 rProp.Value >>= xBitmap; 202 } 203 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_BULLET_COLOR, sizeof(XML_UNO_NAME_NRULE_BULLET_COLOR)-1 ) ) 204 { 205 rProp.Value >>= nColor; 206 bHasColor = sal_True; 207 } 208 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_START_WITH, sizeof(XML_UNO_NAME_NRULE_START_WITH)-1 ) ) 209 { 210 rProp.Value >>= nStartValue; 211 } 212 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_LEFT_MARGIN, sizeof(XML_UNO_NAME_NRULE_LEFT_MARGIN)-1 ) ) 213 { 214 rProp.Value >>= nSpaceBefore; 215 } 216 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET, sizeof(XML_UNO_NAME_NRULE_FIRST_LINE_OFFSET)-1 ) ) 217 { 218 rProp.Value >>= nMinLabelWidth; 219 } 220 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE, sizeof(XML_UNO_NAME_NRULE_SYMBOL_TEXT_DISTANCE)-1 ) ) 221 { 222 rProp.Value >>= nMinLabelDist; 223 } 224 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_PARENT_NUMBERING, sizeof(XML_UNO_NAME_NRULE_PARENT_NUMBERING)-1 ) ) 225 { 226 rProp.Value >>= nDisplayLevels; 227 if( nDisplayLevels > nLevel+1 ) 228 nDisplayLevels = static_cast<sal_Int16>( nLevel )+1; 229 } 230 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_CHAR_STYLE_NAME, sizeof(XML_UNO_NAME_NRULE_CHAR_STYLE_NAME)-1 ) ) 231 { 232 rProp.Value >>= sTextStyleName; 233 } 234 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_GRAPHIC_SIZE, sizeof(XML_UNO_NAME_NRULE_GRAPHIC_SIZE)-1 ) ) 235 { 236 awt::Size aSize; 237 if( rProp.Value >>= aSize ) 238 { 239 nImageWidth = aSize.Width; 240 nImageHeight = aSize.Height; 241 } 242 } 243 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_VERT_ORIENT, sizeof(XML_UNO_NAME_NRULE_VERT_ORIENT)-1 ) ) 244 { 245 sal_Int16 nValue = 0; 246 rProp.Value >>= nValue; 247 eImageVertOrient = nValue; 248 } 249 // --> OD 2008-01-16 #newlistlevelattrs# 250 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE, 251 sizeof(XML_UNO_NAME_NRULE_POSITION_AND_SPACE_MODE)-1 ) ) 252 { 253 sal_Int16 nValue = 0; 254 rProp.Value >>= nValue; 255 ePosAndSpaceMode = nValue; 256 } 257 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY, 258 sizeof(XML_UNO_NAME_NRULE_LABEL_FOLLOWED_BY)-1 ) ) 259 { 260 sal_Int16 nValue = 0; 261 rProp.Value >>= nValue; 262 eLabelFollowedBy = nValue; 263 } 264 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION, 265 sizeof(XML_UNO_NAME_NRULE_LISTTAB_STOP_POSITION)-1 ) ) 266 { 267 rProp.Value >>= nListtabStopPosition; 268 } 269 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_FIRST_LINE_INDENT, 270 sizeof(XML_UNO_NAME_NRULE_FIRST_LINE_INDENT)-1 ) ) 271 { 272 rProp.Value >>= nFirstLineIndent; 273 } 274 else if( rProp.Name.equalsAsciiL( XML_UNO_NAME_NRULE_INDENT_AT, 275 sizeof(XML_UNO_NAME_NRULE_INDENT_AT)-1 ) ) 276 { 277 rProp.Value >>= nIndentAt; 278 } 279 // <-- 280 } 281 282 if( bOutline && (NumberingType::CHAR_SPECIAL == eType || 283 NumberingType::BITMAP == eType) ) 284 { 285 DBG_ASSERT( !bOutline, 286 "SvxXMLNumRuleExport::exportLevelStyle: invalid style for outline" ); 287 return; 288 } 289 290 GetExport().CheckAttrList(); 291 292 // text:level 293 OUStringBuffer sTmp; 294 sTmp.append( nLevel + 1 ); 295 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL, sTmp.makeStringAndClear() ); 296 // #i110694#: no style-name on list-level-style-image 297 // #i116149#: neither prefix/suffix 298 if (NumberingType::BITMAP != eType) 299 { 300 if (sTextStyleName.getLength() > 0) 301 { 302 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, 303 GetExport().EncodeStyleName( sTextStyleName ) ); 304 } 305 if (sPrefix.getLength() > 0) 306 { 307 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NUM_PREFIX, 308 sPrefix ); 309 } 310 if (sSuffix.getLength() > 0) 311 { 312 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NUM_SUFFIX, 313 sSuffix ); 314 } 315 } 316 317 enum XMLTokenEnum eElem = XML_LIST_LEVEL_STYLE_NUMBER; 318 if( NumberingType::CHAR_SPECIAL == eType ) 319 { 320 // <text:list-level-style-bullet> 321 eElem = XML_LIST_LEVEL_STYLE_BULLET; 322 323 if( cBullet ) 324 { 325 if( cBullet < ' ' ) 326 { 327 cBullet = 0xF000 + 149; 328 } 329 // text:bullet-char="..." 330 sTmp.append( cBullet ); 331 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_BULLET_CHAR, 332 sTmp.makeStringAndClear() ); 333 } 334 335 } 336 else if( NumberingType::BITMAP == eType ) 337 { 338 // <text:list-level-style-image> 339 340 eElem = XML_LIST_LEVEL_STYLE_IMAGE; 341 342 343 if( sImageURL.getLength() ) 344 { 345 OUString sURL( GetExport().AddEmbeddedGraphicObject( sImageURL ) ); 346 if( sURL.getLength() ) 347 { 348 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL ); 349 350 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); 351 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED ); 352 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD ); 353 } 354 } 355 else 356 { 357 DBG_ASSERT( !xBitmap.is(), 358 "embedded images are not supported by now" ); 359 } 360 } 361 else 362 { 363 // <text:list-level-style-number> or <text:outline-level-style> 364 if( bOutline ) 365 eElem = XML_OUTLINE_LEVEL_STYLE; 366 else 367 eElem = XML_LIST_LEVEL_STYLE_NUMBER; 368 369 GetExport().GetMM100UnitConverter().convertNumFormat( sTmp, eType ); 370 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NUM_FORMAT, 371 sTmp.makeStringAndClear() ); 372 GetExport().GetMM100UnitConverter().convertNumLetterSync( sTmp, eType ); 373 if( sTmp.getLength() ) 374 GetExport().AddAttribute( XML_NAMESPACE_STYLE, 375 XML_NUM_LETTER_SYNC, 376 sTmp.makeStringAndClear() ); 377 378 if( nStartValue != 1 ) 379 { 380 sTmp.append( (sal_Int32)nStartValue ); 381 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE, 382 sTmp.makeStringAndClear() ); 383 } 384 if( nDisplayLevels > 1 && NumberingType::NUMBER_NONE != eType ) 385 { 386 sTmp.append( (sal_Int32)nDisplayLevels ); 387 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_DISPLAY_LEVELS, 388 sTmp.makeStringAndClear() ); 389 } 390 } 391 392 { 393 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, eElem, 394 sal_True, sal_True ); 395 396 // --> OD 2008-01-16 #newlistlevelattrs# 397 OUStringBuffer sBuffer; 398 if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION ) 399 { 400 // --> OD 2008-06-05 #i89178# 401 // optimization of XML stream size: 402 // suppress export of property list-level-position-and-space-mode, 403 // if its value is "label-width-and-position" - its the default value 404 // GetExport().AddAttribute( XML_NAMESPACE_TEXT, 405 // XML_LIST_LEVEL_POSITION_AND_SPACE_MODE, 406 // XML_LABEL_WIDTH_AND_POSITION ); 407 // <-- 408 409 nSpaceBefore += nMinLabelWidth; 410 nMinLabelWidth = -nMinLabelWidth; 411 if( nSpaceBefore != 0 ) 412 { 413 GetExport().GetMM100UnitConverter().convertMeasure( sBuffer, nSpaceBefore ); 414 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_SPACE_BEFORE, 415 sBuffer.makeStringAndClear() ); 416 } 417 if( nMinLabelWidth != 0 ) 418 { 419 GetExport().GetMM100UnitConverter().convertMeasure( sBuffer, nMinLabelWidth ); 420 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_WIDTH, 421 sBuffer.makeStringAndClear() ); 422 } 423 if( nMinLabelDist > 0 ) 424 { 425 GetExport().GetMM100UnitConverter().convertMeasure( sBuffer, nMinLabelDist ); 426 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_MIN_LABEL_DISTANCE, 427 sBuffer.makeStringAndClear() ); 428 } 429 } 430 // --> OD 2008-06-06 #i89178# 431 // check, if properties for position-and-space-mode LABEL_ALIGNMENT 432 // are allowed to be exported. 433 else if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT && 434 mbExportPositionAndSpaceModeLabelAlignment ) 435 // <-- 436 { 437 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 438 XML_LIST_LEVEL_POSITION_AND_SPACE_MODE, 439 XML_LABEL_ALIGNMENT ); 440 } 441 // <-- 442 if( HoriOrientation::LEFT != eAdjust ) 443 { 444 enum XMLTokenEnum eValue = XML_TOKEN_INVALID; 445 switch( eAdjust ) 446 { 447 case HoriOrientation::RIGHT: eValue = XML_END; break; 448 case HoriOrientation::CENTER: eValue = XML_CENTER; break; 449 } 450 if( eValue != XML_TOKEN_INVALID ) 451 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_TEXT_ALIGN, eValue ); 452 } 453 454 if( NumberingType::BITMAP == eType ) 455 { 456 enum XMLTokenEnum eValue = XML_TOKEN_INVALID; 457 switch( eImageVertOrient ) 458 { 459 case VertOrientation::BOTTOM: // yes, its OK: BOTTOM means that the baseline 460 // hits the frame at its topmost position 461 case VertOrientation::LINE_TOP: 462 case VertOrientation::CHAR_TOP: 463 eValue = XML_TOP; 464 break; 465 case VertOrientation::CENTER: 466 case VertOrientation::LINE_CENTER: 467 case VertOrientation::CHAR_CENTER: 468 eValue = XML_MIDDLE; 469 break; 470 case VertOrientation::TOP: // yes, its OK: TOP means that the baseline 471 // hits the frame at its bottommost position 472 case VertOrientation::LINE_BOTTOM: 473 case VertOrientation::CHAR_BOTTOM: 474 eValue = XML_BOTTOM; 475 break; 476 } 477 if( eValue != XML_TOKEN_INVALID ) 478 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_VERTICAL_POS, eValue ); 479 480 eValue = XML_TOKEN_INVALID; 481 switch( eImageVertOrient ) 482 { 483 case VertOrientation::TOP: 484 case VertOrientation::CENTER: 485 case VertOrientation::BOTTOM: 486 eValue = XML_BASELINE; 487 break; 488 case VertOrientation::LINE_TOP: 489 case VertOrientation::LINE_CENTER: 490 case VertOrientation::LINE_BOTTOM: 491 eValue = XML_LINE; 492 break; 493 case VertOrientation::CHAR_TOP: 494 case VertOrientation::CHAR_CENTER: 495 case VertOrientation::CHAR_BOTTOM: 496 eValue = XML_CHAR; 497 break; 498 } 499 if( eValue != XML_TOKEN_INVALID ) 500 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_VERTICAL_REL, eValue ); 501 502 if( nImageWidth > 0 ) 503 { 504 GetExport().GetMM100UnitConverter().convertMeasure( sBuffer, nImageWidth ); 505 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_WIDTH, 506 sBuffer.makeStringAndClear() ); 507 } 508 509 if( nImageHeight > 0 ) 510 { 511 GetExport().GetMM100UnitConverter().convertMeasure( sBuffer, nImageHeight ); 512 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_HEIGHT, 513 sBuffer.makeStringAndClear() ); 514 } 515 } 516 517 // --> OD 2008-01-16 #newlistlevelattrs# 518 // if( GetExport().GetAttrList().getLength() > 0 ) 519 { 520 SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_STYLE, 521 XML_LIST_LEVEL_PROPERTIES, sal_True, sal_True ); 522 523 // --> OD 2008-06-06 #i89178# 524 // check, if properties for position-and-space-mode LABEL_ALIGNMENT 525 // are allowed to be exported. 526 if ( ePosAndSpaceMode == PositionAndSpaceMode::LABEL_ALIGNMENT && 527 mbExportPositionAndSpaceModeLabelAlignment ) 528 // <-- 529 { 530 enum XMLTokenEnum eValue = XML_LISTTAB; 531 if ( eLabelFollowedBy == LabelFollow::SPACE ) 532 { 533 eValue = XML_SPACE; 534 } 535 else if ( eLabelFollowedBy == LabelFollow::NOTHING ) 536 { 537 eValue = XML_NOTHING; 538 } 539 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 540 XML_LABEL_FOLLOWED_BY, eValue ); 541 542 if ( eLabelFollowedBy == LabelFollow::LISTTAB && 543 nListtabStopPosition > 0 ) 544 { 545 GetExport().GetMM100UnitConverter().convertMeasure( sBuffer, nListtabStopPosition ); 546 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 547 XML_LIST_TAB_STOP_POSITION, 548 sBuffer.makeStringAndClear() ); 549 } 550 551 if ( nFirstLineIndent != 0 ) 552 { 553 GetExport().GetMM100UnitConverter().convertMeasure( sBuffer, nFirstLineIndent ); 554 GetExport().AddAttribute( XML_NAMESPACE_FO, 555 XML_TEXT_INDENT, 556 sBuffer.makeStringAndClear() ); 557 } 558 559 if ( nIndentAt != 0 ) 560 { 561 GetExport().GetMM100UnitConverter().convertMeasure( sBuffer, nIndentAt ); 562 GetExport().AddAttribute( XML_NAMESPACE_FO, 563 XML_MARGIN_LEFT, 564 sBuffer.makeStringAndClear() ); 565 } 566 567 SvXMLElementExport aLabelAlignmentElement( GetExport(), XML_NAMESPACE_STYLE, 568 XML_LIST_LEVEL_LABEL_ALIGNMENT, 569 sal_True, sal_True ); 570 } 571 } 572 // <-- 573 574 if( NumberingType::CHAR_SPECIAL == eType ) 575 { 576 if( sBulletFontName.getLength() ) 577 { 578 OUString sStyleName = 579 GetExport().GetFontAutoStylePool()->Find( 580 sBulletFontName, sBulletFontStyleName, 581 eBulletFontFamily, eBulletFontPitch, 582 eBulletFontEncoding ); 583 584 if( sStyleName.getLength() ) 585 { 586 GetExport().AddAttribute( XML_NAMESPACE_STYLE, 587 XML_FONT_NAME, 588 sStyleName ); 589 } 590 else 591 { 592 Any aAny; 593 OUString sTemp; 594 595 const SvXMLUnitConverter& rUnitConv = 596 GetExport().GetMM100UnitConverter(); 597 XMLFontFamilyNamePropHdl aFamilyNameHdl; 598 aAny <<= sBulletFontName; 599 if( aFamilyNameHdl.exportXML( sTemp, aAny, rUnitConv ) ) 600 GetExport().AddAttribute( XML_NAMESPACE_FO, 601 XML_FONT_FAMILY, sTemp ); 602 603 if( sBulletFontStyleName.getLength() ) 604 GetExport().AddAttribute( XML_NAMESPACE_STYLE, 605 XML_FONT_STYLE_NAME, 606 sBulletFontStyleName ); 607 608 XMLFontFamilyPropHdl aFamilyHdl; 609 aAny <<= (sal_Int16)eBulletFontFamily; 610 if( aFamilyHdl.exportXML( sTemp, aAny, rUnitConv ) ) 611 GetExport().AddAttribute( XML_NAMESPACE_STYLE, 612 XML_FONT_FAMILY_GENERIC, 613 sTemp ); 614 615 XMLFontPitchPropHdl aPitchHdl; 616 aAny <<= (sal_Int16)eBulletFontPitch; 617 if( aPitchHdl.exportXML( sTemp, aAny, rUnitConv ) ) 618 GetExport().AddAttribute( XML_NAMESPACE_STYLE, 619 XML_FONT_PITCH, sTemp ); 620 621 XMLFontEncodingPropHdl aEncHdl; 622 aAny <<= (sal_Int16)eBulletFontEncoding; 623 if( aEncHdl.exportXML( sTemp, aAny, rUnitConv ) ) 624 GetExport().AddAttribute( XML_NAMESPACE_STYLE, 625 XML_FONT_CHARSET, sTemp ); 626 } 627 } 628 } 629 if( NumberingType::BITMAP != eType ) 630 { 631 // fo:color = "#..." 632 if( bHasColor ) 633 { 634 const Color aColor( nColor ); 635 if( aColor.GetColor() == 0xffffffff ) 636 { 637 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_USE_WINDOW_FONT_COLOR, XML_TRUE ); 638 } 639 else 640 { 641 SvXMLUnitConverter::convertColor( sBuffer, aColor ); 642 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_COLOR, 643 sBuffer.makeStringAndClear() ); 644 } 645 } 646 // fo:height="...%" 647 if( nBullRelSize ) 648 { 649 GetExport().GetMM100UnitConverter().convertPercent( sTmp, nBullRelSize ); 650 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_FONT_SIZE, 651 sTmp.makeStringAndClear() ); 652 } 653 } 654 if( GetExport().GetAttrList().getLength() > 0 ) 655 { 656 SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_STYLE, 657 XML_TEXT_PROPERTIES, sal_True, sal_True ); 658 } 659 if( NumberingType::BITMAP == eType && sImageURL.getLength() ) 660 { 661 // optional office:binary-data 662 GetExport().AddEmbeddedGraphicObjectAsBase64( sImageURL ); 663 } 664 } 665 } 666 667 668 uno::Reference< ::com::sun::star::container::XIndexReplace > SvxXMLNumRuleExport::GetUNONumRule() const 669 { 670 return uno::Reference< ::com::sun::star::container::XIndexReplace > (); 671 } 672 673 void SvxXMLNumRuleExport::AddListStyleAttributes() 674 { 675 } 676 677 678 SvxXMLNumRuleExport::SvxXMLNumRuleExport( SvXMLExport& rExp ) : 679 rExport( rExp ), 680 sNumberingRules( RTL_CONSTASCII_USTRINGPARAM( "NumberingRules" ) ), 681 sIsPhysical( RTL_CONSTASCII_USTRINGPARAM( "IsPhysical" ) ), 682 sIsContinuousNumbering( RTL_CONSTASCII_USTRINGPARAM( "IsContinuousNumbering" ) ), 683 // --> OD 2008-06-06 #i89178# 684 mbExportPositionAndSpaceModeLabelAlignment( true ) 685 // <-- 686 { 687 switch ( GetExport().getDefaultVersion() ) 688 { 689 case SvtSaveOptions::ODFVER_010: 690 case SvtSaveOptions::ODFVER_011: 691 { 692 mbExportPositionAndSpaceModeLabelAlignment = false; 693 } 694 break; 695 default: // ODFVER_UNKNOWN or ODFVER_012 696 { 697 mbExportPositionAndSpaceModeLabelAlignment = true; 698 } 699 } 700 } 701 702 SvxXMLNumRuleExport::~SvxXMLNumRuleExport() 703 { 704 } 705 706 // --> OD 2008-06-17 #i90780# 707 // refactoring: removing unused methods 708 //void SvxXMLNumRuleExport::Export( const OUString& rName, 709 // sal_Bool bContNumbering ) 710 //{ 711 // GetExport().CheckAttrList(); 712 713 // // style:name="..." 714 // if( rName.getLength() ) 715 // { 716 // sal_Bool bEncoded = sal_False; 717 // GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, 718 // GetExport().EncodeStyleName( rName, &bEncoded ) ); 719 // if( bEncoded ) 720 // GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, 721 // rName); 722 // } 723 724 // // text:consecutive-numbering="..." 725 // if( bContNumbering ) 726 // GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_CONSECUTIVE_NUMBERING, 727 // XML_TRUE ); 728 729 // // other application specific attributes 730 // AddListStyleAttributes(); 731 732 // OUString sElem = GetExport().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TEXT, 733 // GetXMLToken(XML_LIST_STYLE) ); 734 // GetExport().IgnorableWhitespace(); 735 // GetExport().StartElement( XML_NAMESPACE_TEXT, XML_LIST_STYLE, sal_False ); 736 737 // uno::Reference< ::com::sun::star::container::XIndexReplace > xNumRule = GetUNONumRule(); 738 // if( xNumRule.is() ) 739 // exportLevelStyles( xNumRule ); 740 741 // GetExport().EndElement( XML_NAMESPACE_TEXT, XML_LIST_STYLE, sal_True ); 742 //} 743 744 //void SvxXMLNumRuleExport::ExportOutline() 745 //{ 746 // GetExport().IgnorableWhitespace( ); 747 // GetExport().StartElement( XML_NAMESPACE_TEXT, XML_OUTLINE_STYLE, sal_False ); 748 749 // uno::Reference< ::com::sun::star::container::XIndexReplace > xNumRule = GetUNONumRule(); 750 // if( xNumRule.is() ) 751 // exportLevelStyles( xNumRule, sal_True ); 752 753 // GetExport().EndElement( XML_NAMESPACE_TEXT, XML_OUTLINE_STYLE, sal_True ); 754 //} 755 // <-- 756 757 void SvxXMLNumRuleExport::exportNumberingRule( 758 const OUString& rName, 759 const Reference< XIndexReplace >& rNumRule ) 760 { 761 Reference< XPropertySet > xPropSet( rNumRule, UNO_QUERY ); 762 Reference< XPropertySetInfo > xPropSetInfo; 763 if( xPropSet.is() ) 764 xPropSetInfo = xPropSet->getPropertySetInfo(); 765 766 GetExport().CheckAttrList(); 767 768 // style:name="..." 769 if( rName.getLength() ) 770 { 771 sal_Bool bEncoded = sal_False; 772 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, 773 GetExport().EncodeStyleName( rName, &bEncoded ) ); 774 if( bEncoded ) 775 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, 776 rName); 777 } 778 779 // text:consecutive-numbering="..." 780 sal_Bool bContNumbering = sal_False; 781 if( xPropSetInfo.is() && 782 xPropSetInfo->hasPropertyByName( sIsContinuousNumbering ) ) 783 { 784 Any aAny( xPropSet->getPropertyValue( sIsContinuousNumbering ) ); 785 bContNumbering = *(sal_Bool *)aAny.getValue(); 786 } 787 if( bContNumbering ) 788 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 789 XML_CONSECUTIVE_NUMBERING, XML_TRUE ); 790 791 // other application specific attributes 792 AddListStyleAttributes(); 793 794 { 795 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_LIST_STYLE , 796 sal_True, sal_True ); 797 exportLevelStyles( rNumRule ); 798 } 799 } 800 801 sal_Bool SvxXMLNumRuleExport::exportStyle( const Reference< XStyle >& rStyle ) 802 { 803 Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY ); 804 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); 805 806 Any aAny; 807 808 // Don't export styles that aren't existing really. This may be the 809 // case for StarOffice Writer's pool styles. 810 if( xPropSetInfo->hasPropertyByName( sIsPhysical ) ) 811 { 812 aAny = xPropSet->getPropertyValue( sIsPhysical ); 813 if( !*(sal_Bool *)aAny.getValue() ) 814 return sal_False; 815 } 816 817 aAny = xPropSet->getPropertyValue( sNumberingRules ); 818 Reference<XIndexReplace> xNumRule; 819 aAny >>= xNumRule; 820 821 OUString sName = rStyle->getName(); 822 823 exportNumberingRule( sName, xNumRule ); 824 825 return sal_True; 826 } 827 828 void SvxXMLNumRuleExport::exportOutline() 829 { 830 Reference< XChapterNumberingSupplier > xCNSupplier( GetExport().GetModel(), 831 UNO_QUERY ); 832 DBG_ASSERT( xCNSupplier.is(), "no chapter numbering supplier" ); 833 834 if( xCNSupplier.is() ) 835 { 836 Reference< XIndexReplace > xNumRule( xCNSupplier->getChapterNumberingRules() ); 837 DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" ); 838 839 if( xNumRule.is() ) 840 { 841 // --> OD 2008-06-17 #i90780# 842 // Outline style has property style:name since ODF 1.2 843 // Thus, export this property and adjust fix for issue #i69627# 844 OUString sOutlineStyleName; 845 { 846 Reference<XPropertySet> xNumRulePropSet( 847 xCNSupplier->getChapterNumberingRules(), UNO_QUERY ); 848 if (xNumRulePropSet.is()) 849 { 850 const OUString sName( RTL_CONSTASCII_USTRINGPARAM("Name") ); 851 xNumRulePropSet->getPropertyValue( sName ) >>= sOutlineStyleName; 852 } 853 } 854 const SvtSaveOptions::ODFDefaultVersion nODFVersion = 855 GetExport().getDefaultVersion(); 856 if ( ( nODFVersion == SvtSaveOptions::ODFVER_010 || 857 nODFVersion == SvtSaveOptions::ODFVER_011 ) && 858 GetExport().writeOutlineStyleAsNormalListStyle() ) 859 { 860 exportNumberingRule( sOutlineStyleName, xNumRule ); 861 } 862 else 863 { 864 if ( nODFVersion != SvtSaveOptions::ODFVER_010 && 865 nODFVersion != SvtSaveOptions::ODFVER_011 ) 866 { 867 // style:name="..." 868 GetExport().CheckAttrList(); 869 if ( sOutlineStyleName.getLength() > 0 ) 870 { 871 sal_Bool bEncoded = sal_False; 872 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, 873 GetExport().EncodeStyleName( sOutlineStyleName, 874 &bEncoded ) ); 875 if( bEncoded ) 876 GetExport().AddAttribute( XML_NAMESPACE_STYLE, 877 XML_DISPLAY_NAME, 878 sOutlineStyleName ); 879 } 880 } 881 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, 882 XML_OUTLINE_STYLE, sal_True, sal_True ); 883 exportLevelStyles( xNumRule, sal_True ); 884 } 885 } 886 } 887 } 888 889 void SvxXMLNumRuleExport::exportStyles( sal_Bool bUsed, 890 XMLTextListAutoStylePool *pPool, 891 sal_Bool bExportChapterNumbering ) 892 { 893 if( bExportChapterNumbering ) 894 exportOutline(); 895 896 Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetExport().GetModel(), UNO_QUERY ); 897 DBG_ASSERT( xFamiliesSupp.is(), "No XStyleFamiliesSupplier from XModel for export!" ); 898 if( xFamiliesSupp.is() ) 899 { 900 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() ); 901 DBG_ASSERT( xFamiliesSupp.is(), "getStyleFamilies() from XModel failed for export!" ); 902 903 if( xFamilies.is() ) 904 { 905 const OUString aNumberStyleName( RTL_CONSTASCII_USTRINGPARAM( "NumberingStyles" )); 906 907 Reference< XIndexAccess > xStyles; 908 if( xFamilies->hasByName( aNumberStyleName ) ) 909 { 910 xFamilies->getByName( aNumberStyleName ) >>= xStyles; 911 912 DBG_ASSERT( xStyles.is(), "Style not found for export!" ); 913 914 if( xStyles.is() ) 915 { 916 const sal_Int32 nStyles = xStyles->getCount(); 917 918 for( sal_Int32 i=0; i < nStyles; i++ ) 919 { 920 Reference< XStyle > xStyle; 921 xStyles->getByIndex( i ) >>= xStyle; 922 923 if( !bUsed || xStyle->isInUse() ) 924 { 925 exportStyle( xStyle ); 926 if( pPool ) 927 pPool->RegisterName( xStyle->getName() ); 928 } 929 } 930 } 931 } 932 } 933 } 934 } 935 936 sal_Bool SvxXMLNumRuleExport::GetOutlineStyles( XMLStringVector& rStyleNames, 937 const ::com::sun::star::uno::Reference< 938 ::com::sun::star::frame::XModel > & rModel ) 939 { 940 Reference< XChapterNumberingSupplier > xCNSupplier( rModel, 941 UNO_QUERY ); 942 sal_Int32 nLevels = 0; 943 Reference< XIndexReplace > xNumRule; 944 if( xCNSupplier.is() ) 945 { 946 xNumRule = xCNSupplier->getChapterNumberingRules(); 947 if( xNumRule.is() ) 948 nLevels = xNumRule->getCount(); 949 } 950 951 rStyleNames.resize( nLevels ); 952 for( sal_Int32 i=0; i<nLevels; i++ ) 953 { 954 uno::Any aEntry( xNumRule->getByIndex( i ) ); 955 uno::Sequence<beans::PropertyValue> aSeq; 956 if( aEntry >>= aSeq ) 957 { 958 const sal_Int32 nCount = aSeq.getLength(); 959 const beans::PropertyValue* pPropArray = aSeq.getConstArray(); 960 for( sal_Int32 j=0; j<nCount; j++ ) 961 { 962 const beans::PropertyValue& rProp = pPropArray[j]; 963 964 if( rProp.Name.equalsAsciiL( 965 XML_UNO_NAME_NRULE_HEADING_STYLE_NAME, 966 sizeof(XML_UNO_NAME_NRULE_HEADING_STYLE_NAME)-1 ) ) 967 { 968 rProp.Value >>= rStyleNames[i]; 969 break; 970 } 971 } 972 } 973 } 974 975 return nLevels != 0; 976 } 977