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 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_xmloff.hxx" 24 25 #include <tools/debug.hxx> 26 #include <rtl/ustrbuf.hxx> 27 #include <tools/fontenum.hxx> 28 #include <com/sun/star/uno/Any.hxx> 29 #include <com/sun/star/style/DropCapFormat.hpp> 30 #include <com/sun/star/text/FontRelief.hpp> 31 #include <com/sun/star/text/WrapTextMode.hpp> 32 #include <com/sun/star/text/XTextColumns.hpp> 33 #include <com/sun/star/text/TextColumn.hpp> 34 #include <com/sun/star/text/RelOrientation.hpp> 35 #include <com/sun/star/text/HoriOrientation.hpp> 36 #include <com/sun/star/text/VertOrientation.hpp> 37 #include <com/sun/star/text/RubyAdjust.hpp> 38 #include <com/sun/star/text/FontEmphasis.hpp> 39 #include <com/sun/star/text/ParagraphVertAlign.hpp> 40 #include <xmloff/xmltypes.hxx> 41 #include <xmloff/xmluconv.hxx> 42 #include <xmloff/xmltoken.hxx> 43 #include "XMLAnchorTypePropHdl.hxx" 44 #include <xmloff/XMLConstantsPropertyHandler.hxx> 45 #include "XMLClipPropertyHandler.hxx" 46 #include "XMLTextColumnsPropertyHandler.hxx" 47 #include <xmloff/NamedBoolPropertyHdl.hxx> 48 #include "txtprhdl.hxx" 49 #include <com/sun/star/text/WrapInfluenceOnPosition.hpp> 50 51 //UUUU 52 #include <xmloff/EnumPropertyHdl.hxx> 53 #include <com/sun/star/drawing/FillStyle.hpp> 54 #include "XMLFillBitmapSizePropertyHandler.hxx" 55 #include "XMLBitmapLogicalSizePropertyHandler.hxx" 56 #include <com/sun/star/drawing/RectanglePoint.hpp> 57 #include <com/sun/star/drawing/BitmapMode.hpp> 58 #include "XMLBitmapRepeatOffsetPropertyHandler.hxx" 59 60 using ::rtl::OUString; 61 using ::rtl::OUStringBuffer; 62 63 using namespace ::com::sun::star::uno; 64 using namespace ::com::sun::star::style; 65 using namespace ::com::sun::star::text; 66 using namespace ::xmloff::token; 67 68 //UUUU 69 using namespace ::com::sun::star::drawing; 70 71 //UUUU 72 extern SvXMLEnumMapEntry aXML_FillStyle_EnumMap[]; 73 extern SvXMLEnumMapEntry aXML_RefPoint_EnumMap[]; 74 extern SvXMLEnumMapEntry aXML_BitmapMode_EnumMap[]; 75 76 #define CONSTASCII_USTRINGPARAM_CMP(s) s, sizeof(s)-1 77 78 // --------------------------------------------------------------------------- 79 80 SvXMLEnumMapEntry __READONLY_DATA pXML_HoriPos_Enum[] = 81 { 82 { XML_FROM_LEFT, HoriOrientation::NONE }, 83 { XML_FROM_INSIDE, HoriOrientation::NONE }, // import only 84 { XML_LEFT, HoriOrientation::LEFT }, 85 { XML_INSIDE, HoriOrientation::LEFT }, // import only 86 { XML_CENTER, HoriOrientation::CENTER }, 87 { XML_RIGHT, HoriOrientation::RIGHT }, 88 { XML_OUTSIDE, HoriOrientation::RIGHT }, // import only 89 { XML_TOKEN_INVALID, 0 } 90 }; 91 92 SvXMLEnumMapEntry __READONLY_DATA pXML_HoriPosMirrored_Enum[] = 93 { 94 { XML_FROM_INSIDE, HoriOrientation::NONE }, 95 { XML_INSIDE, HoriOrientation::LEFT }, 96 { XML_CENTER, HoriOrientation::CENTER }, 97 { XML_OUTSIDE, HoriOrientation::RIGHT }, 98 { XML_TOKEN_INVALID, 0 } 99 }; 100 101 SvXMLEnumMapEntry __READONLY_DATA pXML_HoriRel_Enum[] = 102 { 103 { XML_PARAGRAPH, RelOrientation::FRAME }, 104 { XML_PARAGRAPH_CONTENT, RelOrientation::PRINT_AREA }, 105 { XML_PAGE, RelOrientation::PAGE_FRAME }, 106 { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA }, 107 { XML_PARAGRAPH_START_MARGIN, RelOrientation::FRAME_LEFT }, 108 { XML_PARAGRAPH_END_MARGIN, RelOrientation::FRAME_RIGHT }, 109 { XML_PAGE_START_MARGIN, RelOrientation::PAGE_LEFT }, 110 { XML_PAGE_END_MARGIN, RelOrientation::PAGE_RIGHT }, 111 { XML_CHAR, RelOrientation::CHAR }, 112 { XML_FRAME, RelOrientation::FRAME }, // import only 113 { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, // import only 114 { XML_FRAME_START_MARGIN, RelOrientation::FRAME_LEFT }, // import only 115 { XML_FRAME_END_MARGIN, RelOrientation::FRAME_RIGHT }, // import only 116 { XML_TOKEN_INVALID, 0 } 117 }; 118 119 SvXMLEnumMapEntry __READONLY_DATA pXML_HoriRelFrame_Enum[] = 120 { 121 { XML_FRAME, RelOrientation::FRAME }, 122 { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, 123 { XML_PAGE, RelOrientation::PAGE_FRAME }, 124 { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA }, 125 { XML_FRAME_START_MARGIN, RelOrientation::FRAME_LEFT }, 126 { XML_FRAME_END_MARGIN, RelOrientation::FRAME_RIGHT }, 127 { XML_PAGE_START_MARGIN, RelOrientation::PAGE_LEFT }, 128 { XML_PAGE_END_MARGIN, RelOrientation::PAGE_RIGHT }, 129 { XML_CHAR, RelOrientation::CHAR }, 130 { XML_TOKEN_INVALID, 0 } 131 }; 132 133 SvXMLEnumMapEntry __READONLY_DATA pXML_HoriMirror_Enum[] = 134 { 135 { XML_FROM_LEFT, sal_False }, 136 { XML_FROM_INSIDE, sal_True }, 137 { XML_LEFT, sal_False }, 138 { XML_INSIDE, sal_True }, 139 { XML_CENTER, sal_False }, 140 { XML_RIGHT, sal_False }, 141 { XML_OUTSIDE, sal_True }, 142 { XML_TOKEN_INVALID, 0 } 143 }; 144 145 SvXMLEnumMapEntry __READONLY_DATA pXML_VertPos_Enum[] = 146 { 147 { XML_FROM_TOP, VertOrientation::NONE }, 148 { XML_TOP, VertOrientation::TOP }, 149 { XML_TOP, VertOrientation::CHAR_TOP }, // export only 150 { XML_TOP, VertOrientation::LINE_TOP }, // export only 151 { XML_MIDDLE, VertOrientation::CENTER }, 152 { XML_MIDDLE, VertOrientation::CHAR_CENTER }, // export only 153 { XML_MIDDLE, VertOrientation::LINE_CENTER }, // export only 154 { XML_BOTTOM, VertOrientation::BOTTOM }, 155 { XML_BOTTOM, VertOrientation::CHAR_BOTTOM }, // export only 156 { XML_BOTTOM, VertOrientation::LINE_BOTTOM }, // export only 157 { XML_BELOW, VertOrientation::CHAR_BOTTOM }, // import only 158 { XML_TOKEN_INVALID, 0 } 159 }; 160 161 SvXMLEnumMapEntry __READONLY_DATA pXML_VertPosAtChar_Enum[] = 162 { 163 { XML_FROM_TOP, VertOrientation::NONE }, 164 { XML_TOP, VertOrientation::TOP }, 165 { XML_TOP, VertOrientation::CHAR_TOP }, // export only 166 { XML_TOP, VertOrientation::LINE_TOP }, // export only 167 { XML_MIDDLE, VertOrientation::CENTER }, 168 { XML_MIDDLE, VertOrientation::CHAR_CENTER }, // export only 169 { XML_MIDDLE, VertOrientation::LINE_CENTER }, // export only 170 { XML_BOTTOM, VertOrientation::BOTTOM }, 171 { XML_BELOW, VertOrientation::CHAR_BOTTOM }, // export only 172 { XML_BOTTOM, VertOrientation::LINE_BOTTOM }, // export only 173 { XML_TOKEN_INVALID, 0 } 174 }; 175 176 SvXMLEnumMapEntry __READONLY_DATA pXML_VertRel_Enum[] = 177 { 178 { XML_PARAGRAPH, RelOrientation::FRAME }, 179 { XML_PARAGRAPH_CONTENT, RelOrientation::PRINT_AREA }, 180 { XML_CHAR, RelOrientation::CHAR }, 181 // DVO, OD 17.09.2003 #i18732# - allow vertical alignment at page 182 { XML_PAGE, RelOrientation::PAGE_FRAME }, 183 { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA }, 184 { XML_FRAME, RelOrientation::FRAME }, // import only 185 { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, // import only 186 // OD 13.11.2003 #i22341# - new vertical alignment at top of line 187 { XML_LINE, RelOrientation::TEXT_LINE }, 188 { XML_TOKEN_INVALID, 0 } 189 }; 190 191 SvXMLEnumMapEntry __READONLY_DATA pXML_VertRelPage_Enum[] = 192 { 193 { XML_PAGE, RelOrientation::FRAME }, 194 { XML_PAGE_CONTENT, RelOrientation::PRINT_AREA }, 195 { XML_PAGE, RelOrientation::PAGE_FRAME }, 196 { XML_PAGE_CONTENT, RelOrientation::PAGE_PRINT_AREA }, 197 { XML_TOKEN_INVALID, 0 } 198 }; 199 200 SvXMLEnumMapEntry __READONLY_DATA pXML_VertRelFrame_Enum[] = 201 { 202 { XML_FRAME, RelOrientation::FRAME }, 203 { XML_FRAME_CONTENT, RelOrientation::PRINT_AREA }, 204 { XML_TOKEN_INVALID, 0 } 205 }; 206 207 SvXMLEnumMapEntry __READONLY_DATA pXML_VertRelAsChar_Enum[] = 208 { 209 { XML_BASELINE, VertOrientation::TOP }, 210 { XML_BASELINE, VertOrientation::CENTER }, // export only 211 { XML_BASELINE, VertOrientation::BOTTOM }, // export only 212 { XML_TEXT, VertOrientation::CHAR_TOP }, 213 { XML_TEXT, VertOrientation::CHAR_CENTER }, // export only 214 { XML_TEXT, VertOrientation::CHAR_BOTTOM }, // export only 215 { XML_LINE, VertOrientation::LINE_TOP }, 216 { XML_LINE, VertOrientation::LINE_CENTER }, // export only 217 { XML_LINE, VertOrientation::LINE_BOTTOM }, // export only 218 { XML_TOKEN_INVALID, 0 } 219 }; 220 221 SvXMLEnumMapEntry __READONLY_DATA pXML_RubyAdjust_Enum[] = 222 { 223 { XML_LEFT, RubyAdjust_LEFT }, 224 { XML_CENTER, RubyAdjust_CENTER }, 225 { XML_RIGHT, RubyAdjust_RIGHT }, 226 { XML_DISTRIBUTE_LETTER, RubyAdjust_BLOCK }, 227 { XML_DISTRIBUTE_SPACE, RubyAdjust_INDENT_BLOCK }, 228 { XML_TOKEN_INVALID, 0 } 229 }; 230 231 SvXMLEnumMapEntry __READONLY_DATA pXML_FontRelief_Enum[] = 232 { 233 { XML_NONE, FontRelief::NONE }, 234 { XML_ENGRAVED, FontRelief::ENGRAVED }, 235 { XML_EMBOSSED, FontRelief::EMBOSSED }, 236 { XML_TOKEN_INVALID, 0 } 237 }; 238 239 SvXMLEnumMapEntry __READONLY_DATA pXML_VerticalAlign_Enum[] = 240 { 241 { XML_TOP, ParagraphVertAlign::TOP }, 242 { XML_MIDDLE, ParagraphVertAlign::CENTER }, 243 { XML_BOTTOM, ParagraphVertAlign::BOTTOM }, 244 { XML_BASELINE, ParagraphVertAlign::BASELINE }, 245 { XML_AUTO, ParagraphVertAlign::AUTOMATIC }, 246 { XML_TOKEN_INVALID, 0 } 247 }; 248 249 // OD 2004-05-05 #i28701# 250 SvXMLEnumMapEntry __READONLY_DATA pXML_WrapInfluenceOnPosition_Enum[] = 251 { 252 // --> OD 2004-10-18 #i35017# - tokens have been renamed and 253 // <XML_ITERATIVE> has been added 254 { XML_ONCE_SUCCESSIVE, WrapInfluenceOnPosition::ONCE_SUCCESSIVE }, 255 { XML_ONCE_CONCURRENT, WrapInfluenceOnPosition::ONCE_CONCURRENT }, 256 { XML_ITERATIVE, WrapInfluenceOnPosition::ITERATIVE }, 257 // <-- 258 { XML_TOKEN_INVALID, 0 } 259 }; 260 261 // --------------------------------------------------------------------------- 262 263 class XMLDropCapPropHdl_Impl : public XMLPropertyHandler 264 { 265 public: 266 virtual ~XMLDropCapPropHdl_Impl (); 267 268 virtual bool equals( 269 const ::com::sun::star::uno::Any& r1, 270 const ::com::sun::star::uno::Any& r2 ) const; 271 272 /// TabStops will be imported/exported as XML-Elements. So the Import/Export-work must be done at another place. 273 virtual sal_Bool importXML( 274 const ::rtl::OUString& rStrImpValue, 275 ::com::sun::star::uno::Any& rValue, 276 const SvXMLUnitConverter& ) const; 277 virtual sal_Bool exportXML( 278 ::rtl::OUString& rStrExpValue, 279 const ::com::sun::star::uno::Any& rValue, 280 const SvXMLUnitConverter& ) const; 281 }; 282 283 XMLDropCapPropHdl_Impl::~XMLDropCapPropHdl_Impl () 284 { 285 } 286 287 bool XMLDropCapPropHdl_Impl::equals( 288 const Any& r1, 289 const Any& r2 ) const 290 { 291 DropCapFormat aFormat1, aFormat2; 292 r1 >>= aFormat1; 293 r2 >>= aFormat2; 294 295 return (aFormat1.Lines <=1 && aFormat2.Lines <=1) || 296 (aFormat1.Lines == aFormat2.Lines && 297 aFormat1.Count == aFormat2.Count && 298 aFormat1.Distance == aFormat2.Distance); 299 } 300 301 sal_Bool XMLDropCapPropHdl_Impl::importXML( 302 const OUString&, 303 Any&, 304 const SvXMLUnitConverter& ) const 305 { 306 DBG_ASSERT( sal_False, "drop caps are an element import property" ); 307 return sal_False; 308 } 309 310 sal_Bool XMLDropCapPropHdl_Impl::exportXML( 311 OUString&, 312 const Any&, 313 const SvXMLUnitConverter& ) const 314 { 315 DBG_ASSERT( sal_False, "drop caps are an element export property" ); 316 return sal_False; 317 } 318 319 // --------------------------------------------------------------------------- 320 321 class XMLOpaquePropHdl_Impl : public XMLPropertyHandler 322 { 323 public: 324 virtual ~XMLOpaquePropHdl_Impl (); 325 326 virtual sal_Bool importXML( 327 const ::rtl::OUString& rStrImpValue, 328 ::com::sun::star::uno::Any& rValue, 329 const SvXMLUnitConverter& ) const; 330 virtual sal_Bool exportXML( 331 ::rtl::OUString& rStrExpValue, 332 const ::com::sun::star::uno::Any& rValue, 333 const SvXMLUnitConverter& ) const; 334 }; 335 336 sal_Bool XMLOpaquePropHdl_Impl::importXML( 337 const OUString& rStrImpValue, 338 Any& rValue, 339 const SvXMLUnitConverter& ) const 340 { 341 sal_Bool bRet = sal_True; 342 sal_Bool bVal = sal_False; 343 if( IsXMLToken( rStrImpValue, XML_FOREGROUND ) ) 344 bVal = sal_True; 345 else if( !IsXMLToken( rStrImpValue, XML_BACKGROUND ) ) 346 bRet = sal_False; 347 348 if( bRet ) 349 rValue.setValue( &bVal, ::getBooleanCppuType() ); 350 351 return bRet; 352 } 353 354 sal_Bool XMLOpaquePropHdl_Impl::exportXML( 355 OUString& rStrExpValue, 356 const Any& rValue, 357 const SvXMLUnitConverter& ) const 358 { 359 if( *(sal_Bool *)rValue.getValue() ) 360 rStrExpValue = GetXMLToken( XML_FOREGROUND ); 361 else 362 rStrExpValue = GetXMLToken( XML_BACKGROUND ); 363 364 return sal_True; 365 } 366 367 XMLOpaquePropHdl_Impl::~XMLOpaquePropHdl_Impl () 368 { 369 } 370 371 // --------------------------------------------------------------------------- 372 373 class XMLContourModePropHdl_Impl : public XMLPropertyHandler 374 { 375 public: 376 virtual ~XMLContourModePropHdl_Impl (); 377 378 virtual sal_Bool importXML( 379 const ::rtl::OUString& rStrImpValue, 380 ::com::sun::star::uno::Any& rValue, 381 const SvXMLUnitConverter& ) const; 382 virtual sal_Bool exportXML( 383 ::rtl::OUString& rStrExpValue, 384 const ::com::sun::star::uno::Any& rValue, 385 const SvXMLUnitConverter& ) const; 386 }; 387 388 sal_Bool XMLContourModePropHdl_Impl::importXML( 389 const OUString& rStrImpValue, 390 Any& rValue, 391 const SvXMLUnitConverter& ) const 392 { 393 sal_Bool bRet = sal_True; 394 sal_Bool bVal = sal_False; 395 if( IsXMLToken( rStrImpValue, XML_OUTSIDE ) ) 396 bVal = sal_True; 397 else if( ! IsXMLToken( rStrImpValue, XML_FULL ) ) 398 bRet = sal_False; 399 400 if( bRet ) 401 rValue.setValue( &bVal, ::getBooleanCppuType() ); 402 403 return bRet; 404 } 405 406 sal_Bool XMLContourModePropHdl_Impl::exportXML( 407 OUString& rStrExpValue, 408 const Any& rValue, 409 const SvXMLUnitConverter& ) const 410 { 411 if( *(sal_Bool *)rValue.getValue() ) 412 rStrExpValue = GetXMLToken( XML_OUTSIDE ); 413 else 414 rStrExpValue = GetXMLToken( XML_FULL ); 415 416 return sal_True; 417 } 418 419 XMLContourModePropHdl_Impl::~XMLContourModePropHdl_Impl() 420 { 421 } 422 423 // --------------------------------------------------------------------------- 424 425 class XMLParagraphOnlyPropHdl_Impl : public XMLPropertyHandler 426 { 427 public: 428 virtual ~XMLParagraphOnlyPropHdl_Impl (); 429 430 virtual sal_Bool importXML( 431 const ::rtl::OUString& rStrImpValue, 432 ::com::sun::star::uno::Any& rValue, 433 const SvXMLUnitConverter& ) const; 434 virtual sal_Bool exportXML( 435 ::rtl::OUString& rStrExpValue, 436 const ::com::sun::star::uno::Any& rValue, 437 const SvXMLUnitConverter& ) const; 438 }; 439 440 sal_Bool XMLParagraphOnlyPropHdl_Impl::importXML( 441 const OUString& rStrImpValue, 442 Any& rValue, 443 const SvXMLUnitConverter& ) const 444 { 445 sal_Bool bRet = sal_True; 446 sal_Bool bVal = sal_False; 447 448 if( ! IsXMLToken( rStrImpValue, XML_NO_LIMIT ) ) 449 { 450 sal_Int32 nValue = 0; 451 bRet = SvXMLUnitConverter::convertNumber( nValue, rStrImpValue ); 452 bVal = 1 == nValue; 453 } 454 455 if( bRet ) 456 rValue.setValue( &bVal, ::getBooleanCppuType() ); 457 458 return bRet; 459 } 460 461 sal_Bool XMLParagraphOnlyPropHdl_Impl::exportXML( 462 OUString& rStrExpValue, 463 const Any& rValue, 464 const SvXMLUnitConverter& ) const 465 { 466 if( *(sal_Bool *)rValue.getValue() ) 467 rStrExpValue = GetXMLToken( XML_1 ); 468 else 469 rStrExpValue = GetXMLToken( XML_NO_LIMIT ); 470 471 return sal_True; 472 } 473 474 XMLParagraphOnlyPropHdl_Impl::~XMLParagraphOnlyPropHdl_Impl() 475 { 476 } 477 478 // --------------------------------------------------------------------------- 479 480 SvXMLEnumMapEntry __READONLY_DATA pXML_Wrap_Enum[] = 481 { 482 { XML_NONE, WrapTextMode_NONE }, 483 { XML_RUN_THROUGH, WrapTextMode_THROUGHT }, 484 { XML_PARALLEL, WrapTextMode_PARALLEL }, 485 { XML_DYNAMIC, WrapTextMode_DYNAMIC }, 486 { XML_LEFT, WrapTextMode_LEFT }, 487 { XML_RIGHT, WrapTextMode_RIGHT }, 488 { XML_TOKEN_INVALID, 0 } 489 }; 490 491 class XMLWrapPropHdl_Impl : public XMLPropertyHandler 492 { 493 public: 494 virtual ~XMLWrapPropHdl_Impl (); 495 496 virtual sal_Bool importXML( 497 const ::rtl::OUString& rStrImpValue, 498 ::com::sun::star::uno::Any& rValue, 499 const SvXMLUnitConverter& ) const; 500 virtual sal_Bool exportXML( 501 ::rtl::OUString& rStrExpValue, 502 const ::com::sun::star::uno::Any& rValue, 503 const SvXMLUnitConverter& ) const; 504 }; 505 506 sal_Bool XMLWrapPropHdl_Impl::importXML( 507 const OUString& rStrImpValue, 508 Any& rValue, 509 const SvXMLUnitConverter& ) const 510 { 511 sal_uInt16 nWrap; 512 sal_Bool bRet = SvXMLUnitConverter::convertEnum( nWrap, rStrImpValue, 513 pXML_Wrap_Enum ); 514 515 if( bRet ) 516 rValue <<= (WrapTextMode)nWrap; 517 518 return bRet; 519 } 520 521 sal_Bool XMLWrapPropHdl_Impl::exportXML( 522 OUString& rStrExpValue, 523 const Any& rValue, 524 const SvXMLUnitConverter& ) const 525 { 526 OUStringBuffer aOut; 527 WrapTextMode eVal; 528 529 rValue >>= eVal; 530 531 sal_Bool bRet = SvXMLUnitConverter::convertEnum( aOut, eVal, pXML_Wrap_Enum, XML_NONE ); 532 533 rStrExpValue = aOut.makeStringAndClear(); 534 535 return bRet; 536 } 537 538 XMLWrapPropHdl_Impl::~XMLWrapPropHdl_Impl () 539 { 540 } 541 542 // --------------------------------------------------------------------------- 543 544 class XMLFrameProtectPropHdl_Impl : public XMLPropertyHandler 545 { 546 const OUString sVal; 547 public: 548 XMLFrameProtectPropHdl_Impl( enum XMLTokenEnum eVal ) : 549 sVal( GetXMLToken(eVal) ) {} 550 virtual ~XMLFrameProtectPropHdl_Impl (); 551 552 virtual sal_Bool importXML( 553 const ::rtl::OUString& rStrImpValue, 554 ::com::sun::star::uno::Any& rValue, 555 const SvXMLUnitConverter& ) const; 556 virtual sal_Bool exportXML( 557 ::rtl::OUString& rStrExpValue, 558 const ::com::sun::star::uno::Any& rValue, 559 const SvXMLUnitConverter& ) const; 560 }; 561 562 sal_Bool XMLFrameProtectPropHdl_Impl::importXML( 563 const OUString& rStrImpValue, 564 Any& rValue, 565 const SvXMLUnitConverter& ) const 566 { 567 sal_Bool bRet = sal_True; 568 sal_Bool bVal = sal_False; 569 if( ! IsXMLToken( rStrImpValue, XML_NONE ) ) 570 { 571 bRet = sal_False; 572 SvXMLTokenEnumerator aTokenEnum( rStrImpValue ); 573 OUString aToken; 574 while( aTokenEnum.getNextToken( aToken ) ) 575 { 576 bRet = sal_True; 577 if( aToken == sVal ) 578 { 579 bVal = sal_True; 580 break; 581 } 582 } 583 } 584 585 if( bRet ) 586 rValue.setValue( &bVal, ::getBooleanCppuType() ); 587 588 return bRet; 589 } 590 591 sal_Bool XMLFrameProtectPropHdl_Impl::exportXML( 592 OUString& rStrExpValue, 593 const Any& rValue, 594 const SvXMLUnitConverter& ) const 595 { 596 if( *(sal_Bool *)rValue.getValue() ) 597 { 598 if( !rStrExpValue.getLength() || 599 IsXMLToken( rStrExpValue, XML_NONE ) ) 600 { 601 rStrExpValue = sVal; 602 } 603 else 604 { 605 OUStringBuffer aOut( rStrExpValue.getLength() + 1 + 606 sVal.getLength() ); 607 aOut.append( rStrExpValue ); 608 aOut.append( (sal_Unicode)' ' ); 609 aOut.append( sVal ); 610 rStrExpValue = aOut.makeStringAndClear(); 611 } 612 } 613 else if( !rStrExpValue.getLength() ) 614 { 615 rStrExpValue = GetXMLToken( XML_NONE ); 616 } 617 618 return sal_True; 619 } 620 621 XMLFrameProtectPropHdl_Impl::~XMLFrameProtectPropHdl_Impl() 622 { 623 } 624 625 // --------------------------------------------------------------------------- 626 627 SvXMLEnumMapEntry __READONLY_DATA pXML_Anchor_Enum[] = 628 { 629 { XML_CHAR, TextContentAnchorType_AT_CHARACTER }, 630 { XML_PAGE, TextContentAnchorType_AT_PAGE }, 631 { XML_FRAME, TextContentAnchorType_AT_FRAME }, 632 { XML_PARAGRAPH, TextContentAnchorType_AT_PARAGRAPH }, 633 { XML_AS_CHAR, TextContentAnchorType_AS_CHARACTER }, 634 { XML_TOKEN_INVALID, 0 } 635 }; 636 637 638 sal_Bool XMLAnchorTypePropHdl::importXML( 639 const OUString& rStrImpValue, 640 Any& rValue, 641 const SvXMLUnitConverter& ) const 642 { 643 sal_uInt16 nAnchor; 644 sal_Bool bRet = SvXMLUnitConverter::convertEnum( nAnchor, rStrImpValue, 645 pXML_Anchor_Enum ); 646 647 if( bRet ) 648 rValue <<= (TextContentAnchorType)nAnchor; 649 650 return bRet; 651 } 652 653 sal_Bool XMLAnchorTypePropHdl::exportXML( 654 OUString& rStrExpValue, 655 const Any& rValue, 656 const SvXMLUnitConverter& ) const 657 { 658 OUStringBuffer aOut; 659 TextContentAnchorType eVal; 660 661 rValue >>= eVal; 662 663 sal_Bool bRet = SvXMLUnitConverter::convertEnum( aOut, eVal, pXML_Anchor_Enum, XML_PARAGRAPH ); 664 665 rStrExpValue = aOut.makeStringAndClear(); 666 667 return bRet; 668 } 669 670 XMLAnchorTypePropHdl::~XMLAnchorTypePropHdl() 671 { 672 } 673 674 sal_Bool XMLAnchorTypePropHdl::convert( const OUString& rStrImpValue, 675 TextContentAnchorType& rType ) 676 { 677 sal_uInt16 nAnchor; 678 sal_Bool bRet = SvXMLUnitConverter::convertEnum( nAnchor, rStrImpValue, 679 pXML_Anchor_Enum ); 680 if( bRet ) 681 rType = (TextContentAnchorType)nAnchor; 682 return bRet; 683 } 684 685 // --------------------------------------------------------------------------- 686 687 688 XMLTextColumnsPropertyHandler::~XMLTextColumnsPropertyHandler () 689 { 690 } 691 692 bool XMLTextColumnsPropertyHandler::equals( 693 const Any& r1, 694 const Any& r2 ) const 695 { 696 Reference < XTextColumns > xColumns1; 697 r1 >>= xColumns1; 698 699 Reference < XTextColumns > xColumns2; 700 r2 >>= xColumns2; 701 702 if( xColumns1->getColumnCount() != xColumns2->getColumnCount() || 703 xColumns1->getReferenceValue() != xColumns2->getReferenceValue() ) 704 return sal_False; 705 706 Sequence < TextColumn > aColumns1 = xColumns1->getColumns(); 707 Sequence < TextColumn > aColumns2 = xColumns2->getColumns(); 708 sal_Int32 nCount = aColumns1.getLength(); 709 if( aColumns2.getLength() != nCount ) 710 return sal_False; 711 712 const TextColumn *pColumns1 = aColumns1.getArray(); 713 const TextColumn *pColumns2 = aColumns2.getArray(); 714 715 while( nCount-- ) 716 { 717 if( pColumns1->Width != pColumns2->Width || 718 pColumns1->LeftMargin != pColumns2->LeftMargin || 719 pColumns1->RightMargin != pColumns2->RightMargin ) 720 return sal_False; 721 722 pColumns1++; 723 pColumns2++; 724 } 725 726 return sal_True; 727 } 728 729 sal_Bool XMLTextColumnsPropertyHandler::importXML( 730 const OUString&, 731 Any&, 732 const SvXMLUnitConverter& ) const 733 { 734 DBG_ASSERT( sal_False, "columns are an element import property" ); 735 return sal_False; 736 } 737 738 sal_Bool XMLTextColumnsPropertyHandler::exportXML( 739 OUString&, 740 const Any&, 741 const SvXMLUnitConverter& ) const 742 { 743 DBG_ASSERT( sal_False, "columns are an element export property" ); 744 return sal_False; 745 } 746 747 // --------------------------------------------------------------------------- 748 749 class XMLHoriMirrorPropHdl_Impl : public XMLPropertyHandler 750 { 751 public: 752 virtual ~XMLHoriMirrorPropHdl_Impl (); 753 754 virtual sal_Bool importXML( 755 const ::rtl::OUString& rStrImpValue, 756 ::com::sun::star::uno::Any& rValue, 757 const SvXMLUnitConverter& ) const; 758 virtual sal_Bool exportXML( 759 ::rtl::OUString& rStrExpValue, 760 const ::com::sun::star::uno::Any& rValue, 761 const SvXMLUnitConverter& ) const; 762 }; 763 764 sal_Bool XMLHoriMirrorPropHdl_Impl::importXML( 765 const OUString& rStrImpValue, 766 Any& rValue, 767 const SvXMLUnitConverter& ) const 768 { 769 sal_uInt16 nHoriMirror; 770 sal_Bool bRet = SvXMLUnitConverter::convertEnum( nHoriMirror, rStrImpValue, 771 pXML_HoriMirror_Enum ); 772 773 if( bRet ) 774 { 775 sal_Bool bTmp = nHoriMirror != 0; 776 rValue.setValue( &bTmp, ::getBooleanCppuType() ); 777 } 778 779 return bRet; 780 } 781 782 sal_Bool XMLHoriMirrorPropHdl_Impl::exportXML( 783 OUString&, 784 const Any&, 785 const SvXMLUnitConverter& ) const 786 { 787 DBG_ASSERT( sal_False, "HorMirror property shouldn't be exported" ); 788 789 return sal_False; 790 } 791 792 XMLHoriMirrorPropHdl_Impl::~XMLHoriMirrorPropHdl_Impl () 793 { 794 } 795 796 // --------------------------------------------------------------------------- 797 798 class XMLGrfMirrorPropHdl_Impl : public XMLPropertyHandler 799 { 800 const OUString sVal; 801 sal_Bool bHori; 802 803 public: 804 XMLGrfMirrorPropHdl_Impl( enum XMLTokenEnum eVal, sal_Bool bH ) : 805 sVal( GetXMLToken( eVal ) ), 806 bHori( bH ) {} 807 virtual ~XMLGrfMirrorPropHdl_Impl (); 808 809 virtual sal_Bool importXML( 810 const ::rtl::OUString& rStrImpValue, 811 ::com::sun::star::uno::Any& rValue, 812 const SvXMLUnitConverter& ) const; 813 virtual sal_Bool exportXML( 814 ::rtl::OUString& rStrExpValue, 815 const ::com::sun::star::uno::Any& rValue, 816 const SvXMLUnitConverter& ) const; 817 }; 818 819 sal_Bool XMLGrfMirrorPropHdl_Impl::importXML( 820 const OUString& rStrImpValue, 821 Any& rValue, 822 const SvXMLUnitConverter& ) const 823 { 824 sal_Bool bRet = sal_True; 825 sal_Bool bVal = sal_False; 826 if( ! IsXMLToken( rStrImpValue, XML_NONE ) ) 827 { 828 bRet = sal_False; 829 SvXMLTokenEnumerator aTokenEnum( rStrImpValue ); 830 OUString aToken; 831 while( aTokenEnum.getNextToken( aToken ) ) 832 { 833 bRet = sal_True; 834 if( aToken == sVal || 835 (bHori && IsXMLToken( aToken, XML_HORIZONTAL ) ) ) 836 { 837 bVal = sal_True; 838 break; 839 } 840 } 841 } 842 843 if( bRet ) 844 rValue.setValue( &bVal, ::getBooleanCppuType() ); 845 846 return bRet; 847 } 848 849 sal_Bool XMLGrfMirrorPropHdl_Impl::exportXML( 850 OUString& rStrExpValue, 851 const Any& rValue, 852 const SvXMLUnitConverter& ) const 853 { 854 if( *(sal_Bool *)rValue.getValue() ) 855 { 856 if( !rStrExpValue.getLength() || 857 IsXMLToken( rStrExpValue, XML_NONE ) ) 858 { 859 rStrExpValue = sVal; 860 } 861 else if( bHori && 862 // --> OD 2005-05-12 #i49139# 863 // XML_HORIZONTAL_ON_LEFT_PAGES and XML_HORIZONTAL_ON_RIGHT_PAGES 864 // are replaced by XML_HORIZONTAL_ON_EVEN and XML_HORIZONTAL_ON_ODD. 865 ( IsXMLToken( rStrExpValue, XML_HORIZONTAL_ON_EVEN ) || 866 IsXMLToken( rStrExpValue, XML_HORIZONTAL_ON_ODD ) )) 867 // <-- 868 { 869 rStrExpValue = GetXMLToken( XML_HORIZONTAL ); 870 } 871 else 872 { 873 OUStringBuffer aOut( rStrExpValue.getLength() + 1 + 874 sVal.getLength() ); 875 aOut.append( rStrExpValue ); 876 aOut.append( (sal_Unicode)' ' ); 877 aOut.append( sVal ); 878 rStrExpValue = aOut.makeStringAndClear(); 879 } 880 } 881 else if( !rStrExpValue.getLength() ) 882 { 883 rStrExpValue = GetXMLToken( XML_NONE ); 884 } 885 886 return sal_True; 887 } 888 889 XMLGrfMirrorPropHdl_Impl::~XMLGrfMirrorPropHdl_Impl() 890 { 891 } 892 893 // --------------------------------------------------------------------------- 894 895 SvXMLEnumMapEntry __READONLY_DATA pXML_Emphasize_Enum[] = 896 { 897 { XML_NONE, FontEmphasis::NONE }, 898 { XML_DOT, FontEmphasis::DOT_ABOVE }, 899 { XML_CIRCLE, FontEmphasis::CIRCLE_ABOVE }, 900 { XML_DISC, FontEmphasis::DISK_ABOVE }, 901 { XML_ACCENT, FontEmphasis::ACCENT_ABOVE }, 902 { XML_TOKEN_INVALID, 0 } 903 }; 904 class XMLTextEmphasizePropHdl_Impl : public XMLPropertyHandler 905 { 906 public: 907 XMLTextEmphasizePropHdl_Impl() {} 908 virtual ~XMLTextEmphasizePropHdl_Impl(); 909 910 virtual sal_Bool importXML( 911 const ::rtl::OUString& rStrImpValue, 912 ::com::sun::star::uno::Any& rValue, 913 const SvXMLUnitConverter& ) const; 914 virtual sal_Bool exportXML( 915 ::rtl::OUString& rStrExpValue, 916 const ::com::sun::star::uno::Any& rValue, 917 const SvXMLUnitConverter& ) const; 918 }; 919 920 sal_Bool XMLTextEmphasizePropHdl_Impl::importXML( 921 const OUString& rStrImpValue, 922 Any& rValue, 923 const SvXMLUnitConverter& ) const 924 { 925 sal_Bool bRet = sal_True; 926 sal_uInt16 nVal = FontEmphasis::NONE; 927 sal_Bool bBelow = sal_False; 928 sal_Bool bHasPos = sal_False, bHasType = sal_False; 929 OUString aToken; 930 931 SvXMLTokenEnumerator aTokenEnum( rStrImpValue ); 932 while( aTokenEnum.getNextToken( aToken ) ) 933 { 934 if( !bHasPos && IsXMLToken( aToken, XML_ABOVE ) ) 935 { 936 bBelow = sal_False; 937 bHasPos = sal_True; 938 } 939 else if( !bHasPos && IsXMLToken( aToken, XML_BELOW ) ) 940 { 941 bBelow = sal_True; 942 bHasPos = sal_True; 943 } 944 else if( !bHasType && 945 SvXMLUnitConverter::convertEnum( nVal, aToken, 946 pXML_Emphasize_Enum )) 947 { 948 bHasType = sal_True; 949 } 950 else 951 { 952 bRet = sal_False; 953 break; 954 } 955 } 956 957 if( bRet ) 958 { 959 if( FontEmphasis::NONE != nVal && bBelow ) 960 nVal += 10; 961 rValue <<= (sal_Int16)nVal; 962 } 963 964 return bRet; 965 } 966 967 sal_Bool XMLTextEmphasizePropHdl_Impl::exportXML( 968 OUString& rStrExpValue, 969 const Any& rValue, 970 const SvXMLUnitConverter& ) const 971 { 972 OUStringBuffer aOut( 15 ); 973 sal_Bool bRet = sal_True; 974 sal_Int16 nType = sal_Int16(); 975 if( rValue >>= nType ) 976 { 977 sal_Bool bBelow = sal_False; 978 if( nType > 10 ) 979 { 980 bBelow = sal_True; 981 nType -= 10; 982 } 983 bRet = SvXMLUnitConverter::convertEnum( aOut, nType, 984 pXML_Emphasize_Enum, 985 XML_DOT ); 986 if( bRet ) 987 { 988 if( nType != 0 ) 989 { 990 enum XMLTokenEnum ePos = bBelow ? XML_BELOW : XML_ABOVE; 991 aOut.append( (sal_Unicode)' ' ); 992 aOut.append( GetXMLToken(ePos) ); 993 } 994 rStrExpValue = aOut.makeStringAndClear(); 995 } 996 } 997 998 return bRet; 999 } 1000 1001 XMLTextEmphasizePropHdl_Impl::~XMLTextEmphasizePropHdl_Impl() 1002 { 1003 } 1004 1005 1006 // --------------------------------------------------------------------------- 1007 1008 class XMLTextCombineCharPropHdl_Impl : public XMLPropertyHandler 1009 { 1010 public: 1011 XMLTextCombineCharPropHdl_Impl() {} 1012 virtual ~XMLTextCombineCharPropHdl_Impl(); 1013 1014 virtual sal_Bool importXML( 1015 const ::rtl::OUString& rStrImpValue, 1016 ::com::sun::star::uno::Any& rValue, 1017 const SvXMLUnitConverter& ) const; 1018 virtual sal_Bool exportXML( 1019 ::rtl::OUString& rStrExpValue, 1020 const ::com::sun::star::uno::Any& rValue, 1021 const SvXMLUnitConverter& ) const; 1022 }; 1023 1024 sal_Bool XMLTextCombineCharPropHdl_Impl::importXML( 1025 const OUString& rStrImpValue, 1026 Any& rValue, 1027 const SvXMLUnitConverter& ) const 1028 { 1029 if( rStrImpValue.getLength() ) 1030 rValue <<= rStrImpValue.copy( 0, 1 ); 1031 else 1032 rValue <<= rStrImpValue; 1033 1034 return sal_True; 1035 } 1036 1037 sal_Bool XMLTextCombineCharPropHdl_Impl::exportXML( 1038 OUString& rStrExpValue, 1039 const Any& rValue, 1040 const SvXMLUnitConverter& ) const 1041 { 1042 rValue >>= rStrExpValue; 1043 1044 // #i114107# attribute of type "character": export only if length is 1 1045 return (1 == rStrExpValue.getLength()) ? sal_True : sal_False; 1046 } 1047 1048 XMLTextCombineCharPropHdl_Impl::~XMLTextCombineCharPropHdl_Impl() 1049 { 1050 } 1051 1052 // --------------------------------------------------------------------------- 1053 1054 class XMLTextRelWidthHeightPropHdl_Impl : public XMLPropertyHandler 1055 { 1056 public: 1057 XMLTextRelWidthHeightPropHdl_Impl() {} 1058 virtual ~XMLTextRelWidthHeightPropHdl_Impl(); 1059 1060 virtual sal_Bool importXML( 1061 const ::rtl::OUString& rStrImpValue, 1062 ::com::sun::star::uno::Any& rValue, 1063 const SvXMLUnitConverter& ) const; 1064 virtual sal_Bool exportXML( 1065 ::rtl::OUString& rStrExpValue, 1066 const ::com::sun::star::uno::Any& rValue, 1067 const SvXMLUnitConverter& ) const; 1068 }; 1069 1070 sal_Bool XMLTextRelWidthHeightPropHdl_Impl::importXML( 1071 const OUString& rStrImpValue, 1072 Any& rValue, 1073 const SvXMLUnitConverter& ) const 1074 { 1075 sal_Bool bRet; 1076 sal_Int32 nValue; 1077 bRet = SvXMLUnitConverter::convertPercent( nValue, rStrImpValue ); 1078 if( bRet ) 1079 rValue <<= (sal_Int16)nValue; 1080 1081 return bRet; 1082 } 1083 1084 sal_Bool XMLTextRelWidthHeightPropHdl_Impl::exportXML( 1085 OUString& rStrExpValue, 1086 const Any& rValue, 1087 const SvXMLUnitConverter& ) const 1088 { 1089 sal_Bool bRet = sal_False; 1090 sal_Int16 nValue = sal_Int16(); 1091 if( (rValue >>= nValue) && nValue > 0 ) 1092 { 1093 OUStringBuffer aOut; 1094 SvXMLUnitConverter::convertPercent( aOut, nValue ); 1095 rStrExpValue = aOut.makeStringAndClear(); 1096 1097 bRet = sal_True; 1098 } 1099 1100 return bRet; 1101 } 1102 1103 XMLTextRelWidthHeightPropHdl_Impl::~XMLTextRelWidthHeightPropHdl_Impl() 1104 { 1105 } 1106 1107 // --------------------------------------------------------------------------- 1108 1109 class XMLTextSyncWidthHeightPropHdl_Impl : public XMLPropertyHandler 1110 { 1111 const OUString sValue; 1112 1113 public: 1114 XMLTextSyncWidthHeightPropHdl_Impl( enum XMLTokenEnum eValue ) : 1115 sValue( GetXMLToken(eValue) ) {} 1116 virtual ~XMLTextSyncWidthHeightPropHdl_Impl(); 1117 1118 virtual sal_Bool importXML( 1119 const ::rtl::OUString& rStrImpValue, 1120 ::com::sun::star::uno::Any& rValue, 1121 const SvXMLUnitConverter& ) const; 1122 virtual sal_Bool exportXML( 1123 ::rtl::OUString& rStrExpValue, 1124 const ::com::sun::star::uno::Any& rValue, 1125 const SvXMLUnitConverter& ) const; 1126 }; 1127 1128 sal_Bool XMLTextSyncWidthHeightPropHdl_Impl::importXML( 1129 const OUString& rStrImpValue, 1130 Any& rValue, 1131 const SvXMLUnitConverter& ) const 1132 { 1133 sal_Bool bValue = (rStrImpValue == sValue ); 1134 rValue.setValue( &bValue, ::getBooleanCppuType() ); 1135 1136 return sal_True; 1137 } 1138 1139 sal_Bool XMLTextSyncWidthHeightPropHdl_Impl::exportXML( 1140 OUString& rStrExpValue, 1141 const Any& rValue, 1142 const SvXMLUnitConverter& ) const 1143 { 1144 sal_Bool bRet = sal_False; 1145 if( *(sal_Bool *)rValue.getValue() ) 1146 { 1147 rStrExpValue = sValue; 1148 bRet = sal_True; 1149 } 1150 1151 return bRet; 1152 } 1153 1154 XMLTextSyncWidthHeightPropHdl_Impl::~XMLTextSyncWidthHeightPropHdl_Impl() 1155 { 1156 } 1157 1158 // --------------------------------------------------------------------------- 1159 1160 class XMLTextRotationAnglePropHdl_Impl : public XMLPropertyHandler 1161 { 1162 1163 public: 1164 XMLTextRotationAnglePropHdl_Impl() {} 1165 virtual ~XMLTextRotationAnglePropHdl_Impl(); 1166 1167 virtual sal_Bool importXML( 1168 const ::rtl::OUString& rStrImpValue, 1169 ::com::sun::star::uno::Any& rValue, 1170 const SvXMLUnitConverter& ) const; 1171 virtual sal_Bool exportXML( 1172 ::rtl::OUString& rStrExpValue, 1173 const ::com::sun::star::uno::Any& rValue, 1174 const SvXMLUnitConverter& ) const; 1175 }; 1176 1177 sal_Bool XMLTextRotationAnglePropHdl_Impl::importXML( 1178 const OUString& rStrImpValue, 1179 Any& rValue, 1180 const SvXMLUnitConverter& ) const 1181 { 1182 sal_Int32 nValue; 1183 sal_Bool bRet = SvXMLUnitConverter::convertNumber( nValue, rStrImpValue ); 1184 if( bRet ) 1185 { 1186 nValue = (nValue % 360 ); 1187 if( nValue < 0 ) 1188 nValue = 360 + nValue; 1189 sal_Int16 nAngle; 1190 if( nValue < 45 || nValue > 315 ) 1191 nAngle = 0; 1192 else if( nValue < 180 ) 1193 nAngle = 900; 1194 else /* if nValalue <= 315 ) */ 1195 nAngle = 2700; 1196 rValue <<= nAngle; 1197 } 1198 1199 return bRet; 1200 } 1201 1202 sal_Bool XMLTextRotationAnglePropHdl_Impl::exportXML( 1203 OUString& rStrExpValue, 1204 const Any& rValue, 1205 const SvXMLUnitConverter& ) const 1206 { 1207 sal_Int16 nAngle = sal_Int16(); 1208 sal_Bool bRet = ( rValue >>= nAngle ); 1209 if( bRet ) 1210 { 1211 OUStringBuffer aOut; 1212 SvXMLUnitConverter::convertNumber( aOut, nAngle / 10 ); 1213 rStrExpValue = aOut.makeStringAndClear(); 1214 } 1215 OSL_ENSURE( bRet, "illegal rotation angle" ); 1216 1217 return bRet; 1218 } 1219 1220 XMLTextRotationAnglePropHdl_Impl::~XMLTextRotationAnglePropHdl_Impl() 1221 { 1222 } 1223 // --------------------------------------------------------------------------- 1224 class XMLNumber8OneBasedHdl : public XMLPropertyHandler 1225 { 1226 1227 public: 1228 XMLNumber8OneBasedHdl() {} 1229 virtual ~XMLNumber8OneBasedHdl() {}; 1230 1231 virtual sal_Bool importXML( 1232 const ::rtl::OUString& rStrImpValue, 1233 ::com::sun::star::uno::Any& rValue, 1234 const SvXMLUnitConverter& ) const; 1235 virtual sal_Bool exportXML( 1236 ::rtl::OUString& rStrExpValue, 1237 const ::com::sun::star::uno::Any& rValue, 1238 const SvXMLUnitConverter& ) const; 1239 }; 1240 1241 sal_Bool XMLNumber8OneBasedHdl::importXML( 1242 const OUString& rStrImpValue, 1243 Any& rValue, 1244 const SvXMLUnitConverter& ) const 1245 { 1246 sal_Int32 nValue = 0; 1247 sal_Bool bRet = SvXMLUnitConverter::convertNumber( nValue, rStrImpValue ); 1248 if( bRet ) 1249 rValue <<= static_cast<sal_Int8>( nValue - 1 ); 1250 return bRet; 1251 } 1252 1253 sal_Bool XMLNumber8OneBasedHdl::exportXML( 1254 OUString& rStrExpValue, 1255 const Any& rValue, 1256 const SvXMLUnitConverter& ) const 1257 { 1258 sal_Int8 nValue = sal_Int8(); 1259 sal_Bool bRet = ( rValue >>= nValue ); 1260 if( bRet ) 1261 { 1262 OUStringBuffer aOut; 1263 SvXMLUnitConverter::convertNumber( aOut, nValue + 1 ); 1264 rStrExpValue = aOut.makeStringAndClear(); 1265 } 1266 return bRet; 1267 } 1268 // --------------------------------------------------------------------------- 1269 class XMLTextPropertyHandlerFactory_Impl 1270 { 1271 public: 1272 const XMLPropertyHandler *GetPropertyHandler( sal_Int32 nType ) const; 1273 1274 XMLTextPropertyHandlerFactory_Impl(); 1275 ~XMLTextPropertyHandlerFactory_Impl(); 1276 }; 1277 1278 const XMLPropertyHandler *XMLTextPropertyHandlerFactory_Impl::GetPropertyHandler 1279 ( sal_Int32 nType ) const 1280 { 1281 const XMLPropertyHandler* pHdl = 0; 1282 switch( nType ) 1283 { 1284 case XML_TYPE_TEXT_DROPCAP: 1285 pHdl = new XMLDropCapPropHdl_Impl; 1286 break; 1287 case XML_TYPE_TEXT_WRAP: 1288 pHdl = new XMLWrapPropHdl_Impl; 1289 break; 1290 case XML_TYPE_TEXT_PARAGRAPH_ONLY: 1291 pHdl = new XMLParagraphOnlyPropHdl_Impl; 1292 break; 1293 case XML_TYPE_TEXT_WRAP_OUTSIDE: 1294 pHdl = new XMLContourModePropHdl_Impl; 1295 break; 1296 case XML_TYPE_TEXT_OPAQUE: 1297 pHdl = new XMLOpaquePropHdl_Impl; 1298 break; 1299 case XML_TYPE_TEXT_PROTECT_CONTENT: 1300 pHdl = new XMLFrameProtectPropHdl_Impl( XML_CONTENT ); 1301 break; 1302 case XML_TYPE_TEXT_PROTECT_SIZE: 1303 pHdl = new XMLFrameProtectPropHdl_Impl( XML_SIZE ); 1304 break; 1305 case XML_TYPE_TEXT_PROTECT_POSITION: 1306 pHdl = new XMLFrameProtectPropHdl_Impl( XML_POSITION ); 1307 break; 1308 case XML_TYPE_TEXT_ANCHOR_TYPE: 1309 pHdl = new XMLAnchorTypePropHdl; 1310 break; 1311 case XML_TYPE_TEXT_COLUMNS: 1312 pHdl = new XMLTextColumnsPropertyHandler; 1313 break; 1314 case XML_TYPE_TEXT_HORIZONTAL_POS: 1315 pHdl = new XMLConstantsPropertyHandler( pXML_HoriPos_Enum, XML_TOKEN_INVALID ); 1316 break; 1317 case XML_TYPE_TEXT_HORIZONTAL_POS_MIRRORED: 1318 pHdl = new XMLConstantsPropertyHandler( pXML_HoriPosMirrored_Enum, XML_TOKEN_INVALID ); 1319 break; 1320 case XML_TYPE_TEXT_HORIZONTAL_REL: 1321 pHdl = new XMLConstantsPropertyHandler( pXML_HoriRel_Enum, XML_TOKEN_INVALID ); 1322 break; 1323 case XML_TYPE_TEXT_HORIZONTAL_REL_FRAME: 1324 pHdl = new XMLConstantsPropertyHandler( pXML_HoriRelFrame_Enum, XML_TOKEN_INVALID ); 1325 break; 1326 case XML_TYPE_TEXT_HORIZONTAL_MIRROR: 1327 pHdl = new XMLHoriMirrorPropHdl_Impl; 1328 break; 1329 case XML_TYPE_TEXT_VERTICAL_POS: 1330 pHdl = new XMLConstantsPropertyHandler( pXML_VertPos_Enum, XML_TOKEN_INVALID ); 1331 break; 1332 case XML_TYPE_TEXT_VERTICAL_POS_AT_CHAR: 1333 pHdl = new XMLConstantsPropertyHandler( pXML_VertPosAtChar_Enum, XML_TOKEN_INVALID ); 1334 break; 1335 case XML_TYPE_TEXT_VERTICAL_REL: 1336 pHdl = new XMLConstantsPropertyHandler( pXML_VertRel_Enum, XML_TOKEN_INVALID ); 1337 break; 1338 case XML_TYPE_TEXT_VERTICAL_REL_PAGE: 1339 pHdl = new XMLConstantsPropertyHandler( pXML_VertRelPage_Enum, XML_TOKEN_INVALID ); 1340 break; 1341 case XML_TYPE_TEXT_VERTICAL_REL_FRAME: 1342 pHdl = new XMLConstantsPropertyHandler( pXML_VertRelFrame_Enum, XML_TOKEN_INVALID ); 1343 break; 1344 case XML_TYPE_TEXT_VERTICAL_REL_AS_CHAR: 1345 pHdl = new XMLConstantsPropertyHandler( pXML_VertRelAsChar_Enum, XML_TOKEN_INVALID ); 1346 break; 1347 case XML_TYPE_TEXT_MIRROR_VERTICAL: 1348 pHdl = new XMLGrfMirrorPropHdl_Impl( XML_VERTICAL, sal_False ); 1349 break; 1350 case XML_TYPE_TEXT_MIRROR_HORIZONTAL_LEFT: 1351 // --> OD 2005-05-12 #i49139# 1352 // XML_HORIZONTAL_ON_LEFT_PAGES is replaced by XML_HORIZONTAL_ON_EVEN. 1353 pHdl = new XMLGrfMirrorPropHdl_Impl( XML_HORIZONTAL_ON_EVEN, sal_True ); 1354 // <-- 1355 break; 1356 case XML_TYPE_TEXT_MIRROR_HORIZONTAL_RIGHT: 1357 // --> OD 2005-05-12 #i49139# 1358 // XML_HORIZONTAL_ON_RIGHT_PAGES is replaced by XML_HORIZONTAL_ON_ODD. 1359 pHdl = new XMLGrfMirrorPropHdl_Impl( XML_HORIZONTAL_ON_ODD, sal_True ); 1360 // <-- 1361 break; 1362 case XML_TYPE_TEXT_CLIP: 1363 pHdl = new XMLClipPropertyHandler( sal_False ); 1364 break; 1365 case XML_TYPE_TEXT_CLIP11: 1366 pHdl = new XMLClipPropertyHandler( sal_True ); 1367 break; 1368 case XML_TYPE_TEXT_EMPHASIZE: 1369 pHdl = new XMLTextEmphasizePropHdl_Impl; 1370 break; 1371 case XML_TYPE_TEXT_COMBINE: 1372 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_LINES ), 1373 GetXMLToken( XML_NONE ) ); 1374 break; 1375 case XML_TYPE_TEXT_COMBINE_CHARACTERS: 1376 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_LETTERS ), 1377 GetXMLToken( XML_NONE ) ); 1378 break; 1379 case XML_TYPE_TEXT_COMBINECHAR: 1380 pHdl = new XMLTextCombineCharPropHdl_Impl; 1381 break; 1382 case XML_TYPE_TEXT_AUTOSPACE: 1383 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_IDEOGRAPH_ALPHA ), 1384 GetXMLToken( XML_NONE ) ); 1385 break; 1386 case XML_TYPE_TEXT_PUNCTUATION_WRAP: 1387 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_HANGING ), 1388 GetXMLToken( XML_SIMPLE ) ); 1389 break; 1390 case XML_TYPE_TEXT_LINE_BREAK: 1391 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_STRICT ), 1392 GetXMLToken( XML_NORMAL ) ); 1393 break; 1394 case XML_TYPE_TEXT_REL_WIDTH_HEIGHT: 1395 pHdl = new XMLTextRelWidthHeightPropHdl_Impl; 1396 break; 1397 case XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT: 1398 pHdl = new XMLTextSyncWidthHeightPropHdl_Impl( XML_SCALE ); 1399 break; 1400 case XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT_MIN: 1401 pHdl = new XMLTextSyncWidthHeightPropHdl_Impl( XML_SCALE_MIN ); 1402 break; 1403 case XML_TYPE_TEXT_RUBY_ADJUST: 1404 pHdl = new XMLConstantsPropertyHandler( pXML_RubyAdjust_Enum, XML_TOKEN_INVALID ); 1405 break; 1406 case XML_TYPE_TEXT_FONT_RELIEF: 1407 pHdl = new XMLConstantsPropertyHandler( pXML_FontRelief_Enum, XML_TOKEN_INVALID ); 1408 break; 1409 case XML_TYPE_TEXT_ROTATION_ANGLE: 1410 pHdl = new XMLTextRotationAnglePropHdl_Impl; 1411 break; 1412 case XML_TYPE_TEXT_ROTATION_SCALE: 1413 pHdl = new XMLNamedBoolPropertyHdl( GetXMLToken( XML_FIXED ), 1414 GetXMLToken( XML_LINE_HEIGHT ) ); 1415 break; 1416 case XML_TYPE_TEXT_VERTICAL_ALIGN: 1417 pHdl = new XMLConstantsPropertyHandler( pXML_VerticalAlign_Enum, XML_TOKEN_INVALID ); 1418 break; 1419 case XML_TYPE_TEXT_RUBY_POSITION: 1420 pHdl = new XMLNamedBoolPropertyHdl( ::xmloff::token::XML_ABOVE, 1421 ::xmloff::token::XML_BELOW ); 1422 break; 1423 // OD 2004-05-05 #i28701# 1424 case XML_TYPE_WRAP_INFLUENCE_ON_POSITION: 1425 pHdl = new XMLConstantsPropertyHandler( pXML_WrapInfluenceOnPosition_Enum, 1426 XML_TOKEN_INVALID ); 1427 break; 1428 case XML_TYPE_BORDER_MODEL: 1429 pHdl = new XMLNamedBoolPropertyHdl( xmloff::token::XML_COLLAPSING, 1430 xmloff::token::XML_SEPARATING ); 1431 break; 1432 case XML_TYPE_TEXT_LINE_MODE: 1433 pHdl = new XMLNamedBoolPropertyHdl( 1434 ::xmloff::token::XML_SKIP_WHITE_SPACE, 1435 ::xmloff::token::XML_CONTINUOUS); 1436 break; 1437 case XML_TYPE_TEXT_KEEP: 1438 pHdl = new XMLNamedBoolPropertyHdl( 1439 ::xmloff::token::XML_ALWAYS, 1440 ::xmloff::token::XML_AUTO); 1441 break; 1442 case XML_TYPE_TEXT_NKEEP: 1443 pHdl = new XMLNamedBoolPropertyHdl( 1444 ::xmloff::token::XML_AUTO, 1445 ::xmloff::token::XML_ALWAYS); 1446 break; 1447 case XML_TYPE_TEXT_NUMBER8_ONE_BASED: 1448 pHdl = new XMLNumber8OneBasedHdl(); 1449 break; 1450 1451 //UUUU 1452 case XML_SW_TYPE_FILLSTYLE: 1453 pHdl = new XMLEnumPropertyHdl( aXML_FillStyle_EnumMap, ::getCppuType((const FillStyle*)0) ); 1454 break; 1455 case XML_SW_TYPE_FILLBITMAPSIZE: 1456 pHdl = new XMLFillBitmapSizePropertyHandler(); 1457 break; 1458 case XML_SW_TYPE_LOGICAL_SIZE: 1459 pHdl = new XMLBitmapLogicalSizePropertyHandler(); 1460 break; 1461 case XML_SW_TYPE_BITMAP_REFPOINT: 1462 pHdl = new XMLEnumPropertyHdl( aXML_RefPoint_EnumMap, getCppuType((const RectanglePoint*)0) ); 1463 break; 1464 case XML_SW_TYPE_BITMAP_MODE: 1465 pHdl = new XMLEnumPropertyHdl( aXML_BitmapMode_EnumMap, getCppuType((const BitmapMode*)0) ); 1466 break; 1467 case XML_SW_TYPE_BITMAPREPOFFSETX: 1468 case XML_SW_TYPE_BITMAPREPOFFSETY: 1469 pHdl = new XMLBitmapRepeatOffsetPropertyHandler(XML_SW_TYPE_BITMAPREPOFFSETX == nType); 1470 break; 1471 1472 //UUUU 1473 default: 1474 { 1475 OSL_ENSURE(false, "XMLPropertyHandler missing (!)"); 1476 break; 1477 } 1478 } 1479 1480 return pHdl; 1481 } 1482 1483 XMLTextPropertyHandlerFactory_Impl::XMLTextPropertyHandlerFactory_Impl() 1484 { 1485 } 1486 1487 XMLTextPropertyHandlerFactory_Impl::~XMLTextPropertyHandlerFactory_Impl() 1488 { 1489 } 1490 1491 // ---------------------------------------------------------------------------- 1492 1493 XMLTextPropertyHandlerFactory::XMLTextPropertyHandlerFactory() : 1494 XMLPropertyHandlerFactory(), 1495 pImpl( new XMLTextPropertyHandlerFactory_Impl ) 1496 { 1497 } 1498 1499 XMLTextPropertyHandlerFactory::~XMLTextPropertyHandlerFactory() 1500 { 1501 delete pImpl; 1502 } 1503 1504 const XMLPropertyHandler *XMLTextPropertyHandlerFactory::GetPropertyHandler( 1505 sal_Int32 nType ) const 1506 { 1507 const XMLPropertyHandler *pHdl = 1508 XMLPropertyHandlerFactory::GetPropertyHandler( nType ); 1509 1510 if( !pHdl ) 1511 { 1512 const XMLPropertyHandler *pNewHdl = pImpl->GetPropertyHandler( nType ); 1513 1514 if( pNewHdl ) 1515 PutHdlCache( nType, pNewHdl ); 1516 1517 pHdl = pNewHdl; 1518 } 1519 1520 return pHdl; 1521 } 1522 1523 1524