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 #include "unointerfacetouniqueidentifiermapper.hxx" 25 #include <tools/debug.hxx> 26 #ifndef _SVSTDARR_LONGS_DECL 27 #define _SVSTDARR_LONGS 28 #include <svl/svstdarr.hxx> 29 #endif 30 #include <svl/svarray.hxx> 31 #include <rtl/ustrbuf.hxx> 32 #include <sal/types.h> 33 #include <vector> 34 #include <list> 35 #include <hash_map> 36 #include <com/sun/star/lang/XServiceInfo.hpp> 37 #include <com/sun/star/container/XEnumerationAccess.hpp> 38 #include <com/sun/star/container/XEnumeration.hpp> 39 #include <com/sun/star/container/XIndexReplace.hpp> 40 #include <com/sun/star/beans/XPropertySet.hpp> 41 #include <com/sun/star/beans/XMultiPropertySet.hpp> 42 #include <com/sun/star/beans/XPropertyState.hpp> 43 #include <com/sun/star/text/XTextDocument.hpp> 44 #include <com/sun/star/text/XTextSectionsSupplier.hpp> 45 #include <com/sun/star/text/XTextTablesSupplier.hpp> 46 #include <com/sun/star/text/XNumberingRulesSupplier.hpp> 47 #include <com/sun/star/text/XChapterNumberingSupplier.hpp>//#outline level,add by zhaojianwei 48 #include <com/sun/star/text/XTextTable.hpp> 49 #include <com/sun/star/text/XText.hpp> 50 #include <com/sun/star/text/XTextContent.hpp> 51 #include <com/sun/star/text/XTextRange.hpp> 52 #include <com/sun/star/text/XTextField.hpp> 53 #include <com/sun/star/text/XFootnote.hpp> 54 #include <com/sun/star/container/XNamed.hpp> 55 #include <com/sun/star/container/XContentEnumerationAccess.hpp> 56 #include <com/sun/star/text/XTextFrame.hpp> 57 #include <com/sun/star/container/XNameAccess.hpp> 58 #include <com/sun/star/text/SizeType.hpp> 59 #include <com/sun/star/text/HoriOrientation.hpp> 60 #include <com/sun/star/text/VertOrientation.hpp> 61 #include <com/sun/star/text/TextContentAnchorType.hpp> 62 #include <com/sun/star/text/XTextFramesSupplier.hpp> 63 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> 64 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> 65 #include <com/sun/star/drawing/XDrawPageSupplier.hpp> 66 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> 67 #include <com/sun/star/document/XEventsSupplier.hpp> 68 #include <com/sun/star/document/XRedlinesSupplier.hpp> 69 #include <com/sun/star/text/XBookmarksSupplier.hpp> 70 #include <com/sun/star/text/XFormField.hpp> 71 #include <com/sun/star/text/XTextSection.hpp> 72 #include <com/sun/star/text/SectionFileLink.hpp> 73 #include <com/sun/star/drawing/XShape.hpp> 74 #include <com/sun/star/text/XTextShapesSupplier.hpp> 75 #include <com/sun/star/style/XAutoStylesSupplier.hpp> 76 #include <com/sun/star/style/XAutoStyleFamily.hpp> 77 #include <com/sun/star/text/XTextFieldsSupplier.hpp> 78 #include <com/sun/star/text/XFootnotesSupplier.hpp> 79 #include <com/sun/star/text/XEndnotesSupplier.hpp> 80 #include <com/sun/star/drawing/XControlShape.hpp> 81 #include <com/sun/star/util/DateTime.hpp> 82 #include "xmloff/xmlnmspe.hxx" 83 #include <xmloff/xmlaustp.hxx> 84 #include <xmloff/families.hxx> 85 #include "txtexppr.hxx" 86 #include <xmloff/xmlnumfe.hxx> 87 #include <xmloff/xmlnume.hxx> 88 #include <xmloff/xmluconv.hxx> 89 #include "XMLAnchorTypePropHdl.hxx" 90 #include "xexptran.hxx" 91 #include <xmloff/ProgressBarHelper.hxx> 92 #include <xmloff/nmspmap.hxx> 93 #include <xmloff/xmlexp.hxx> 94 #include "txtflde.hxx" 95 #include <xmloff/txtprmap.hxx> 96 #include "XMLImageMapExport.hxx" 97 #include "XMLTextNumRuleInfo.hxx" 98 #include "xmloff/XMLTextListAutoStylePool.hxx" 99 #include <xmloff/txtparae.hxx> 100 #include "XMLSectionExport.hxx" 101 #include "XMLIndexMarkExport.hxx" 102 #include <xmloff/XMLEventExport.hxx> 103 #include "XMLRedlineExport.hxx" 104 #include "MultiPropertySetHelper.hxx" 105 #include <xmloff/formlayerexport.hxx> 106 #include "XMLTextCharStyleNamesElementExport.hxx" 107 #include <comphelper/stlunosequence.hxx> 108 #include <txtlists.hxx> 109 #include <com/sun/star/rdf/XMetadatable.hpp> 110 #include <basegfx/polygon/b2dpolypolygon.hxx> 111 #include <basegfx/polygon/b2dpolypolygontools.hxx> 112 #include <basegfx/polygon/b2dpolygontools.hxx> 113 #include <xmloff/odffields.hxx> 114 115 using ::rtl::OUString; 116 using ::rtl::OUStringBuffer; 117 118 using namespace ::std; 119 using namespace ::com::sun::star; 120 using namespace ::com::sun::star::uno; 121 using namespace ::com::sun::star::lang; 122 using namespace ::com::sun::star::beans; 123 using namespace ::com::sun::star::container; 124 using namespace ::com::sun::star::text; 125 using namespace ::com::sun::star::style; 126 using namespace ::com::sun::star::util; 127 using namespace ::com::sun::star::drawing; 128 using namespace ::com::sun::star::document; 129 using namespace ::com::sun::star::frame; 130 using namespace ::xmloff; 131 using namespace ::xmloff::token; 132 133 namespace 134 { 135 class TextContentSet 136 { 137 public: 138 typedef Reference<XTextContent> text_content_ref_t; 139 typedef list<text_content_ref_t> contents_t; 140 typedef back_insert_iterator<contents_t> inserter_t; 141 typedef contents_t::const_iterator const_iterator_t; 142 143 inserter_t getInserter() 144 { return back_insert_iterator<contents_t>(m_vTextContents); }; 145 const_iterator_t getBegin() const 146 { return m_vTextContents.begin(); }; 147 const_iterator_t getEnd() const 148 { return m_vTextContents.end(); }; 149 150 private: 151 contents_t m_vTextContents; 152 }; 153 154 struct FrameRefHash 155 : public unary_function<Reference<XTextFrame>, size_t> 156 { 157 size_t operator()(const Reference<XTextFrame> xFrame) const 158 { return sal::static_int_cast<size_t>(reinterpret_cast<sal_uIntPtr>(xFrame.get())); } 159 }; 160 161 static bool lcl_TextContentsUnfiltered(const Reference<XTextContent>&) 162 { return true; }; 163 164 static bool lcl_ShapeFilter(const Reference<XTextContent>& xTxtContent) 165 { 166 static const OUString sTextFrameService = OUString::createFromAscii("com.sun.star.text.TextFrame"); 167 static const OUString sTextGraphicService = OUString::createFromAscii("com.sun.star.text.TextGraphicObject"); 168 static const OUString sTextEmbeddedService = OUString::createFromAscii("com.sun.star.text.TextEmbeddedObject"); 169 Reference<XShape> xShape(xTxtContent, UNO_QUERY); 170 if(!xShape.is()) 171 return false; 172 Reference<XServiceInfo> xServiceInfo(xTxtContent, UNO_QUERY); 173 if(xServiceInfo->supportsService(sTextFrameService) || 174 xServiceInfo->supportsService(sTextGraphicService) || 175 xServiceInfo->supportsService(sTextEmbeddedService) ) 176 return false; 177 return true; 178 }; 179 180 class BoundFrames 181 { 182 public: 183 typedef bool (*filter_t)(const Reference<XTextContent>&); 184 BoundFrames( 185 const Reference<XEnumerationAccess> xEnumAccess, 186 const filter_t& rFilter) 187 : m_xEnumAccess(xEnumAccess) 188 { 189 Fill(rFilter); 190 }; 191 BoundFrames() 192 {}; 193 const TextContentSet* GetPageBoundContents() const 194 { return &m_vPageBounds; }; 195 const TextContentSet* GetFrameBoundContents(const Reference<XTextFrame>& rParentFrame) const 196 { 197 framebound_map_t::const_iterator it = m_vFrameBoundsOf.find(rParentFrame); 198 if(it == m_vFrameBoundsOf.end()) 199 return NULL; 200 return &(it->second); 201 }; 202 Reference<XEnumeration> createEnumeration() const 203 { 204 if(!m_xEnumAccess.is()) 205 return Reference<XEnumeration>(); 206 return m_xEnumAccess->createEnumeration(); 207 }; 208 209 private: 210 typedef hash_map< 211 Reference<XTextFrame>, 212 TextContentSet, 213 FrameRefHash> framebound_map_t; 214 TextContentSet m_vPageBounds; 215 framebound_map_t m_vFrameBoundsOf; 216 const Reference<XEnumerationAccess> m_xEnumAccess; 217 void Fill(const filter_t& rFilter); 218 static const OUString our_sAnchorType; 219 static const OUString our_sAnchorFrame; 220 }; 221 const OUString BoundFrames::our_sAnchorType = OUString::createFromAscii("AnchorType"); 222 const OUString BoundFrames::our_sAnchorFrame = OUString::createFromAscii("AnchorFrame"); 223 224 class FieldParamExporter 225 { 226 public: 227 FieldParamExporter(SvXMLExport* const pExport, Reference<XNameContainer> xFieldParams) 228 : m_pExport(pExport) 229 , m_xFieldParams(xFieldParams) 230 { }; 231 void Export(); 232 233 private: 234 SvXMLExport* const m_pExport; 235 const Reference<XNameContainer> m_xFieldParams; 236 237 void ExportParameter(const OUString& sKey, const OUString& sValue); 238 }; 239 } 240 241 namespace xmloff 242 { 243 class BoundFrameSets 244 { 245 public: 246 BoundFrameSets(const Reference<XInterface> xModel); 247 const BoundFrames* GetTexts() const 248 { return m_pTexts.get(); }; 249 const BoundFrames* GetGraphics() const 250 { return m_pGraphics.get(); }; 251 const BoundFrames* GetEmbeddeds() const 252 { return m_pEmbeddeds.get(); }; 253 const BoundFrames* GetShapes() const 254 { return m_pShapes.get(); }; 255 private: 256 auto_ptr<BoundFrames> m_pTexts; 257 auto_ptr<BoundFrames> m_pGraphics; 258 auto_ptr<BoundFrames> m_pEmbeddeds; 259 auto_ptr<BoundFrames> m_pShapes; 260 }; 261 } 262 263 typedef OUString *OUStringPtr; 264 SV_DECL_PTRARR_DEL( OUStrings_Impl, OUStringPtr, 20, 10 ) 265 SV_IMPL_PTRARR( OUStrings_Impl, OUStringPtr ) 266 267 SV_DECL_PTRARR_SORT_DEL( OUStringsSort_Impl, OUStringPtr, 20, 10 ) 268 SV_IMPL_OP_PTRARR_SORT( OUStringsSort_Impl, OUStringPtr ) 269 270 #ifdef DBG_UTIL 271 static int txtparae_bContainsIllegalCharacters = sal_False; 272 #endif 273 274 // The following map shows which property values are required: 275 // 276 // property auto style pass export 277 // -------------------------------------------------------- 278 // ParaStyleName if style exists always 279 // ParaConditionalStyleName if style exists always 280 // NumberingRules if style exists always 281 // TextSection always always 282 // ParaChapterNumberingLevel never always 283 // NumberingIsNumber never always 284 285 // The conclusion is that for auto styles the first three properties 286 // should be queried using a multi property set if, and only if, an 287 // auto style needs to be exported. TextSection should be queried by 288 // an individual call to getPropertyvalue, because this seems to be 289 // less expensive than querying the first three properties if they aren't 290 // required. 291 292 // For the export pass all properties can be queried using a multi property 293 // set. 294 295 static const sal_Char* aParagraphPropertyNamesAuto[] = 296 { 297 "NumberingRules", 298 "ParaConditionalStyleName", 299 "ParaStyleName", 300 NULL 301 }; 302 303 enum eParagraphPropertyNamesEnumAuto 304 { 305 NUMBERING_RULES_AUTO = 0, 306 PARA_CONDITIONAL_STYLE_NAME_AUTO = 1, 307 PARA_STYLE_NAME_AUTO = 2 308 }; 309 310 static const sal_Char* aParagraphPropertyNames[] = 311 { 312 "NumberingIsNumber", 313 "NumberingStyleName", //#outline level,add by zhaojianwei 314 315 //"ParaChapterNumberingLevel", //#outline level,remove by zhaojianwei 316 "OutlineLevel", //<-end,add by zhaojianwei 317 "ParaConditionalStyleName", 318 "ParaStyleName", 319 "TextSection", 320 NULL 321 }; 322 323 enum eParagraphPropertyNamesEnum 324 { 325 NUMBERING_IS_NUMBER = 0, 326 PARA_NUMBERING_STYLENAME = 1, //#outline level,add by zhaojianwei 327 //PARA_CHAPTER_NUMERBING_LEVEL = 1, //#outline level,remove by zhaojianwei 328 PARA_OUTLINE_LEVEL=2, //<-end.add by zhaojianwei 329 PARA_CONDITIONAL_STYLE_NAME = 3, 330 PARA_STYLE_NAME = 4, 331 TEXT_SECTION = 5 332 }; 333 334 void BoundFrames::Fill(const filter_t& rFilter) 335 { 336 if(!m_xEnumAccess.is()) 337 return; 338 const Reference< XEnumeration > xEnum = m_xEnumAccess->createEnumeration(); 339 if(!xEnum.is()) 340 return; 341 while(xEnum->hasMoreElements()) 342 { 343 Reference<XPropertySet> xPropSet(xEnum->nextElement(), UNO_QUERY); 344 Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY); 345 if(!xPropSet.is() || !xTextContent.is()) 346 continue; 347 TextContentAnchorType eAnchor; 348 xPropSet->getPropertyValue(our_sAnchorType) >>= eAnchor; 349 if(TextContentAnchorType_AT_PAGE != eAnchor && TextContentAnchorType_AT_FRAME != eAnchor) 350 continue; 351 if(!rFilter(xTextContent)) 352 continue; 353 354 TextContentSet::inserter_t pInserter = m_vPageBounds.getInserter(); 355 if(TextContentAnchorType_AT_FRAME == eAnchor) 356 { 357 Reference<XTextFrame> xAnchorTxtFrame( 358 xPropSet->getPropertyValue(our_sAnchorFrame), 359 uno::UNO_QUERY); 360 pInserter = m_vFrameBoundsOf[xAnchorTxtFrame].getInserter(); 361 } 362 *pInserter++ = xTextContent; 363 } 364 } 365 366 BoundFrameSets::BoundFrameSets(const Reference<XInterface> xModel) 367 : m_pTexts(new BoundFrames()) 368 , m_pGraphics(new BoundFrames()) 369 , m_pEmbeddeds(new BoundFrames()) 370 , m_pShapes(new BoundFrames()) 371 { 372 const Reference<XTextFramesSupplier> xTFS(xModel, UNO_QUERY); 373 const Reference<XTextGraphicObjectsSupplier> xGOS(xModel, UNO_QUERY); 374 const Reference<XTextEmbeddedObjectsSupplier> xEOS(xModel, UNO_QUERY); 375 const Reference<XDrawPageSupplier> xDPS(xModel, UNO_QUERY); 376 if(xTFS.is()) 377 m_pTexts = auto_ptr<BoundFrames>(new BoundFrames( 378 Reference<XEnumerationAccess>(xTFS->getTextFrames(), UNO_QUERY), 379 &lcl_TextContentsUnfiltered)); 380 if(xGOS.is()) 381 m_pGraphics = auto_ptr<BoundFrames>(new BoundFrames( 382 Reference<XEnumerationAccess>(xGOS->getGraphicObjects(), UNO_QUERY), 383 &lcl_TextContentsUnfiltered)); 384 if(xEOS.is()) 385 m_pEmbeddeds = auto_ptr<BoundFrames>(new BoundFrames( 386 Reference<XEnumerationAccess>(xEOS->getEmbeddedObjects(), UNO_QUERY), 387 &lcl_TextContentsUnfiltered)); 388 if(xDPS.is()) 389 m_pShapes = auto_ptr<BoundFrames>(new BoundFrames( 390 Reference<XEnumerationAccess>(xDPS->getDrawPage(), UNO_QUERY), 391 &lcl_ShapeFilter)); 392 }; 393 394 void FieldParamExporter::Export() 395 { 396 static const Type aStringType = ::getCppuType((OUString*)0); 397 static const Type aBoolType = ::getCppuType((sal_Bool*)0); 398 static const Type aSeqType = ::getCppuType((Sequence<OUString>*)0); 399 static const Type aIntType = ::getCppuType((sal_Int32*)0); 400 Sequence<OUString> vParameters(m_xFieldParams->getElementNames()); 401 for(const OUString* pCurrent=::comphelper::stl_begin(vParameters); pCurrent!=::comphelper::stl_end(vParameters); ++pCurrent) 402 { 403 const Any aValue = m_xFieldParams->getByName(*pCurrent); 404 const Type aValueType = aValue.getValueType(); 405 if(aValueType == aStringType) 406 { 407 OUString sValue; 408 aValue >>= sValue; 409 ExportParameter(*pCurrent,sValue); 410 } 411 else if(aValueType == aBoolType) 412 { 413 sal_Bool bValue = false; 414 aValue >>= bValue; 415 ExportParameter(*pCurrent,OUString::createFromAscii(bValue ? "true" : "false")); 416 } 417 else if(aValueType == aSeqType) 418 { 419 Sequence<OUString> vValue; 420 aValue >>= vValue; 421 for(OUString* pSeqCurrent = ::comphelper::stl_begin(vValue); pSeqCurrent != ::comphelper::stl_end(vValue); ++pSeqCurrent) 422 { 423 ExportParameter(*pCurrent, *pSeqCurrent); 424 } 425 } 426 else if(aValueType == aIntType) 427 { 428 sal_Int32 nValue = 0; 429 aValue >>= nValue; 430 ExportParameter(*pCurrent, OUStringBuffer().append(nValue).makeStringAndClear()); 431 } 432 } 433 } 434 435 void FieldParamExporter::ExportParameter(const OUString& sKey, const OUString& sValue) 436 { 437 m_pExport->AddAttribute(XML_NAMESPACE_FIELD, XML_NAME, sKey); 438 m_pExport->AddAttribute(XML_NAMESPACE_FIELD, XML_VALUE, sValue); 439 m_pExport->StartElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False); 440 m_pExport->EndElement(XML_NAMESPACE_FIELD, XML_PARAM, sal_False); 441 } 442 443 void XMLTextParagraphExport::Add( sal_uInt16 nFamily, 444 const Reference < XPropertySet > & rPropSet, 445 const XMLPropertyState** ppAddStates, bool bDontSeek ) 446 { 447 UniReference < SvXMLExportPropertyMapper > xPropMapper; 448 switch( nFamily ) 449 { 450 case XML_STYLE_FAMILY_TEXT_PARAGRAPH: 451 xPropMapper = GetParaPropMapper(); 452 break; 453 case XML_STYLE_FAMILY_TEXT_TEXT: 454 xPropMapper = GetTextPropMapper(); 455 break; 456 case XML_STYLE_FAMILY_TEXT_FRAME: 457 xPropMapper = GetAutoFramePropMapper(); 458 break; 459 case XML_STYLE_FAMILY_TEXT_SECTION: 460 xPropMapper = GetSectionPropMapper(); 461 break; 462 case XML_STYLE_FAMILY_TEXT_RUBY: 463 xPropMapper = GetRubyPropMapper(); 464 break; 465 } 466 DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" ); 467 468 vector< XMLPropertyState > xPropStates = 469 xPropMapper->Filter( rPropSet ); 470 471 if( ppAddStates ) 472 { 473 while( *ppAddStates ) 474 { 475 xPropStates.push_back( **ppAddStates ); 476 ppAddStates++; 477 } 478 } 479 480 if( !xPropStates.empty() ) 481 { 482 Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo()); 483 OUString sParent, sCondParent; 484 sal_uInt16 nIgnoreProps = 0; 485 switch( nFamily ) 486 { 487 case XML_STYLE_FAMILY_TEXT_PARAGRAPH: 488 if( xPropSetInfo->hasPropertyByName( sParaStyleName ) ) 489 { 490 rPropSet->getPropertyValue( sParaStyleName ) >>= sParent; 491 } 492 if( xPropSetInfo->hasPropertyByName( sParaConditionalStyleName ) ) 493 { 494 rPropSet->getPropertyValue( sParaConditionalStyleName ) >>= sCondParent; 495 } 496 if( xPropSetInfo->hasPropertyByName( sNumberingRules ) ) 497 { 498 Reference < XIndexReplace > xNumRule(rPropSet->getPropertyValue( sNumberingRules ), uno::UNO_QUERY); 499 if( xNumRule.is() && xNumRule->getCount() ) 500 { 501 Reference < XNamed > xNamed( xNumRule, UNO_QUERY ); 502 OUString sName; 503 if( xNamed.is() ) 504 sName = xNamed->getName(); 505 sal_Bool bAdd = !sName.getLength(); 506 if( !bAdd ) 507 { 508 Reference < XPropertySet > xNumPropSet( xNumRule, 509 UNO_QUERY ); 510 const OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) ); 511 if( xNumPropSet.is() && 512 xNumPropSet->getPropertySetInfo() 513 ->hasPropertyByName( sIsAutomatic ) ) 514 { 515 bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue(); 516 // --> OD 2007-01-12 #i73361# - check on outline style 517 const OUString sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) ); 518 if ( bAdd && 519 xNumPropSet->getPropertySetInfo() 520 ->hasPropertyByName( sNumberingIsOutline ) ) 521 { 522 bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue()); 523 } 524 // <-- 525 } 526 else 527 { 528 bAdd = sal_True; 529 } 530 } 531 if( bAdd ) 532 pListAutoPool->Add( xNumRule ); 533 } 534 } 535 break; 536 case XML_STYLE_FAMILY_TEXT_TEXT: 537 { 538 // Get parent and remove hyperlinks (they aren't of interest) 539 UniReference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper()); 540 for( ::std::vector< XMLPropertyState >::iterator i(xPropStates.begin()); 541 nIgnoreProps < 2 && i != xPropStates.end(); ) 542 { 543 if( i->mnIndex == -1 ) 544 { 545 ++i; 546 continue; 547 } 548 549 switch( xPM->GetEntryContextId(i->mnIndex) ) 550 { 551 case CTF_CHAR_STYLE_NAME: 552 case CTF_HYPERLINK_URL: 553 i->mnIndex = -1; 554 nIgnoreProps++; 555 i = xPropStates.erase( i ); 556 break; 557 default: 558 ++i; 559 break; 560 } 561 } 562 } 563 break; 564 case XML_STYLE_FAMILY_TEXT_FRAME: 565 if( xPropSetInfo->hasPropertyByName( sFrameStyleName ) ) 566 { 567 rPropSet->getPropertyValue( sFrameStyleName ) >>= sParent; 568 } 569 break; 570 case XML_STYLE_FAMILY_TEXT_SECTION: 571 case XML_STYLE_FAMILY_TEXT_RUBY: 572 ; // section styles have no parents 573 break; 574 } 575 if( (xPropStates.size() - nIgnoreProps) > 0 ) 576 { 577 GetAutoStylePool().Add( nFamily, sParent, xPropStates, bDontSeek ); 578 if( sCondParent.getLength() && sParent != sCondParent ) 579 GetAutoStylePool().Add( nFamily, sCondParent, xPropStates ); 580 } 581 } 582 } 583 584 bool lcl_validPropState( const XMLPropertyState& rState ) 585 { 586 return rState.mnIndex != -1; 587 } 588 589 void XMLTextParagraphExport::Add( sal_uInt16 nFamily, 590 MultiPropertySetHelper& rPropSetHelper, 591 const Reference < XPropertySet > & rPropSet, 592 const XMLPropertyState** ppAddStates) 593 { 594 UniReference < SvXMLExportPropertyMapper > xPropMapper; 595 switch( nFamily ) 596 { 597 case XML_STYLE_FAMILY_TEXT_PARAGRAPH: 598 xPropMapper = GetParaPropMapper(); 599 break; 600 } 601 DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" ); 602 603 vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet )); 604 if( ppAddStates ) 605 { 606 while( *ppAddStates ) 607 { 608 xPropStates.push_back( **ppAddStates ); 609 ++ppAddStates; 610 } 611 } 612 613 if( rPropSetHelper.hasProperty( NUMBERING_RULES_AUTO ) ) 614 { 615 Reference < XIndexReplace > xNumRule(rPropSetHelper.getValue( NUMBERING_RULES_AUTO, 616 rPropSet, sal_True ), uno::UNO_QUERY); 617 if( xNumRule.is() && xNumRule->getCount() ) 618 { 619 Reference < XNamed > xNamed( xNumRule, UNO_QUERY ); 620 OUString sName; 621 if( xNamed.is() ) 622 sName = xNamed->getName(); 623 sal_Bool bAdd = !sName.getLength(); 624 if( !bAdd ) 625 { 626 Reference < XPropertySet > xNumPropSet( xNumRule, 627 UNO_QUERY ); 628 const OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) ); 629 if( xNumPropSet.is() && 630 xNumPropSet->getPropertySetInfo() 631 ->hasPropertyByName( sIsAutomatic ) ) 632 { 633 bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue(); 634 // --> OD 2007-01-12 #i73361# - check on outline style 635 const OUString sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) ); 636 if ( bAdd && 637 xNumPropSet->getPropertySetInfo() 638 ->hasPropertyByName( sNumberingIsOutline ) ) 639 { 640 bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue()); 641 } 642 // <-- 643 } 644 else 645 { 646 bAdd = sal_True; 647 } 648 } 649 if( bAdd ) 650 pListAutoPool->Add( xNumRule ); 651 } 652 } 653 654 if( !xPropStates.empty() ) 655 { 656 OUString sParent, sCondParent; 657 switch( nFamily ) 658 { 659 case XML_STYLE_FAMILY_TEXT_PARAGRAPH: 660 if( rPropSetHelper.hasProperty( PARA_STYLE_NAME_AUTO ) ) 661 { 662 rPropSetHelper.getValue( PARA_STYLE_NAME_AUTO, rPropSet, 663 sal_True ) >>= sParent; 664 } 665 if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO ) ) 666 { 667 rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO, 668 rPropSet, sal_True ) >>= sCondParent; 669 } 670 671 break; 672 } 673 674 if( find_if( xPropStates.begin(), xPropStates.end(), lcl_validPropState ) != xPropStates.end() ) 675 { 676 GetAutoStylePool().Add( nFamily, sParent, xPropStates ); 677 if( sCondParent.getLength() && sParent != sCondParent ) 678 GetAutoStylePool().Add( nFamily, sCondParent, xPropStates ); 679 } 680 } 681 } 682 683 OUString XMLTextParagraphExport::Find( 684 sal_uInt16 nFamily, 685 const Reference < XPropertySet > & rPropSet, 686 const OUString& rParent, 687 const XMLPropertyState** ppAddStates) const 688 { 689 OUString sName( rParent ); 690 UniReference < SvXMLExportPropertyMapper > xPropMapper; 691 switch( nFamily ) 692 { 693 case XML_STYLE_FAMILY_TEXT_PARAGRAPH: 694 xPropMapper = GetParaPropMapper(); 695 break; 696 case XML_STYLE_FAMILY_TEXT_FRAME: 697 xPropMapper = GetAutoFramePropMapper(); 698 break; 699 case XML_STYLE_FAMILY_TEXT_SECTION: 700 xPropMapper = GetSectionPropMapper(); 701 break; 702 case XML_STYLE_FAMILY_TEXT_RUBY: 703 xPropMapper = GetRubyPropMapper(); 704 break; 705 } 706 DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" ); 707 if( !xPropMapper.is() ) 708 return sName; 709 vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet )); 710 if( ppAddStates ) 711 { 712 while( *ppAddStates ) 713 { 714 xPropStates.push_back( **ppAddStates ); 715 ++ppAddStates; 716 } 717 } 718 if( find_if( xPropStates.begin(), xPropStates.end(), lcl_validPropState ) != xPropStates.end() ) 719 sName = GetAutoStylePool().Find( nFamily, sName, xPropStates ); 720 721 return sName; 722 } 723 724 OUString XMLTextParagraphExport::FindTextStyleAndHyperlink( 725 const Reference < XPropertySet > & rPropSet, 726 sal_Bool& rbHyperlink, 727 sal_Bool& rbHasCharStyle, 728 sal_Bool& rbHasAutoStyle, 729 const XMLPropertyState** ppAddStates ) const 730 { 731 UniReference < SvXMLExportPropertyMapper > xPropMapper(GetTextPropMapper()); 732 vector< XMLPropertyState > xPropStates(xPropMapper->Filter( rPropSet )); 733 734 // Get parent and remove hyperlinks (they aren't of interest) 735 OUString sName; 736 rbHyperlink = rbHasCharStyle = rbHasAutoStyle = sal_False; 737 sal_uInt16 nIgnoreProps = 0; 738 UniReference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper()); 739 ::std::vector< XMLPropertyState >::iterator aFirstDel = xPropStates.end(); 740 ::std::vector< XMLPropertyState >::iterator aSecondDel = xPropStates.end(); 741 742 for( ::std::vector< XMLPropertyState >::iterator 743 i = xPropStates.begin(); 744 nIgnoreProps < 2 && i != xPropStates.end(); 745 i++ ) 746 { 747 if( i->mnIndex == -1 ) 748 continue; 749 750 switch( xPM->GetEntryContextId(i->mnIndex) ) 751 { 752 case CTF_CHAR_STYLE_NAME: 753 i->maValue >>= sName; 754 i->mnIndex = -1; 755 rbHasCharStyle = sName.getLength() > 0; 756 if( nIgnoreProps ) 757 aSecondDel = i; 758 else 759 aFirstDel = i; 760 nIgnoreProps++; 761 break; 762 case CTF_HYPERLINK_URL: 763 rbHyperlink = sal_True; 764 i->mnIndex = -1; 765 if( nIgnoreProps ) 766 aSecondDel = i; 767 else 768 aFirstDel = i; 769 nIgnoreProps++; 770 break; 771 } 772 } 773 if( ppAddStates ) 774 { 775 while( *ppAddStates ) 776 { 777 xPropStates.push_back( **ppAddStates ); 778 ppAddStates++; 779 } 780 } 781 if( (xPropStates.size() - nIgnoreProps) > 0L ) 782 { 783 // erase the character style, otherwise the autostyle cannot be found! 784 // erase the hyperlink, otherwise the autostyle cannot be found! 785 if ( nIgnoreProps ) 786 { 787 // If two elements of a vector have to be deleted, 788 // we should delete the second one first. 789 if( --nIgnoreProps ) 790 xPropStates.erase( aSecondDel ); 791 xPropStates.erase( aFirstDel ); 792 } 793 OUString sParent; // AutoStyles should not have parents! 794 sName = GetAutoStylePool().Find( XML_STYLE_FAMILY_TEXT_TEXT, sParent, xPropStates ); 795 DBG_ASSERT( sName.getLength(), "AutoStyle could not be found" ); 796 rbHasAutoStyle = sal_True; 797 } 798 799 return sName; 800 } 801 802 OUString XMLTextParagraphExport::FindTextStyle( 803 const Reference < XPropertySet > & rPropSet, 804 sal_Bool& rHasCharStyle ) const 805 { 806 sal_Bool bDummy; 807 sal_Bool bDummy2; 808 return FindTextStyleAndHyperlink( rPropSet, bDummy, rHasCharStyle, bDummy2 ); 809 } 810 811 812 // --> OD 2008-04-25 #refactorlists# 813 // adjustments to support lists independent from list style 814 void XMLTextParagraphExport::exportListChange( 815 const XMLTextNumRuleInfo& rPrevInfo, 816 const XMLTextNumRuleInfo& rNextInfo ) 817 { 818 // end a list 819 if ( rPrevInfo.GetLevel() > 0 ) 820 { 821 bool bRootListToBeClosed = false; 822 sal_Int16 nListLevelsToBeClosed = 0; 823 if ( !rNextInfo.BelongsToSameList( rPrevInfo ) || 824 rNextInfo.GetLevel() <= 0 ) 825 { 826 // close complete previous list 827 bRootListToBeClosed = true; 828 nListLevelsToBeClosed = rPrevInfo.GetLevel(); 829 } 830 else if ( rPrevInfo.GetLevel() > rNextInfo.GetLevel() ) 831 { 832 // close corresponding sub lists 833 DBG_ASSERT( rNextInfo.GetLevel() > 0, 834 "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." ); 835 nListLevelsToBeClosed = rPrevInfo.GetLevel() - rNextInfo.GetLevel(); 836 } 837 838 if ( nListLevelsToBeClosed > 0 && 839 pListElements && 840 pListElements->Count() >= ( 2 * nListLevelsToBeClosed ) ) 841 { 842 do { 843 for( sal_uInt16 j = 0; j < 2; ++j ) 844 { 845 OUString *pElem = (*pListElements)[pListElements->Count()-1]; 846 pListElements->Remove( pListElements->Count()-1 ); 847 848 GetExport().EndElement( *pElem, sal_True ); 849 850 delete pElem; 851 } 852 853 // remove closed list from list stack 854 mpTextListsHelper->PopListFromStack(); 855 856 --nListLevelsToBeClosed; 857 } while ( nListLevelsToBeClosed > 0 ); 858 } 859 } 860 861 const bool bExportODF = 862 ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0; 863 const SvtSaveOptions::ODFDefaultVersion eODFDefaultVersion = 864 GetExport().getDefaultVersion(); 865 866 // start a new list 867 if ( rNextInfo.GetLevel() > 0 ) 868 { 869 bool bRootListToBeStarted = false; 870 sal_Int16 nListLevelsToBeOpened = 0; 871 if ( !rPrevInfo.BelongsToSameList( rNextInfo ) || 872 rPrevInfo.GetLevel() <= 0 ) 873 { 874 // new root list 875 bRootListToBeStarted = true; 876 nListLevelsToBeOpened = rNextInfo.GetLevel(); 877 } 878 else if ( rNextInfo.GetLevel() > rPrevInfo.GetLevel() ) 879 { 880 // open corresponding sub lists 881 DBG_ASSERT( rPrevInfo.GetLevel() > 0, 882 "<rPrevInfo.GetLevel() > 0> not hold. Serious defect -> please inform OD." ); 883 nListLevelsToBeOpened = rNextInfo.GetLevel() - rPrevInfo.GetLevel(); 884 } 885 886 if ( nListLevelsToBeOpened > 0 ) 887 { 888 const ::rtl::OUString sListStyleName( rNextInfo.GetNumRulesName() ); 889 // Currently only the text documents support <ListId>. 890 // Thus, for other document types <sListId> is empty. 891 const ::rtl::OUString sListId( rNextInfo.GetListId() ); 892 bool bExportListStyle( true ); 893 bool bRestartNumberingAtContinuedRootList( false ); 894 sal_Int16 nRestartValueForContinuedRootList( -1 ); 895 // --> OD 2008-11-26 #158694# 896 bool bContinueingPreviousSubList = !bRootListToBeStarted && 897 rNextInfo.IsContinueingPreviousSubTree(); 898 // <-- 899 do { 900 GetExport().CheckAttrList(); 901 902 if ( bRootListToBeStarted ) 903 { 904 if ( !mpTextListsHelper->IsListProcessed( sListId ) ) 905 { 906 if ( bExportODF && 907 eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 && 908 sListId.getLength() > 0 ) 909 { 910 // --> OD 2008-07-31 #i92221# 911 GetExport().AddAttribute( XML_NAMESPACE_XML, 912 XML_ID, 913 sListId ); 914 // <-- 915 } 916 mpTextListsHelper->KeepListAsProcessed( sListId, 917 sListStyleName, 918 ::rtl::OUString() ); 919 } 920 else 921 { 922 const ::rtl::OUString sNewListId( 923 mpTextListsHelper->GenerateNewListId() ); 924 if ( bExportODF && 925 eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 && 926 sListId.getLength() > 0 ) 927 { 928 // --> OD 2008-07-31 #i92221# 929 GetExport().AddAttribute( XML_NAMESPACE_XML, 930 XML_ID, 931 sNewListId ); 932 // <-- 933 } 934 935 const ::rtl::OUString sContinueListId = 936 mpTextListsHelper->GetLastContinuingListId( sListId ); 937 // store that list with list id <sNewListId> is last list, 938 // which has continued list with list id <sListId> 939 mpTextListsHelper->StoreLastContinuingList( sListId, 940 sNewListId ); 941 if ( sListStyleName == 942 mpTextListsHelper->GetListStyleOfLastProcessedList() && 943 // --> OD 2008-08-15 #i92811# 944 sContinueListId == 945 mpTextListsHelper->GetLastProcessedListId() && 946 // <-- 947 !rNextInfo.IsRestart() ) 948 { 949 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 950 XML_CONTINUE_NUMBERING, 951 XML_TRUE ); 952 } 953 else 954 { 955 if ( bExportODF && 956 eODFDefaultVersion >= SvtSaveOptions::ODFVER_012 && 957 sListId.getLength() > 0 ) 958 { 959 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 960 XML_CONTINUE_LIST, 961 sContinueListId ); 962 } 963 964 if ( rNextInfo.IsRestart() && 965 ( nListLevelsToBeOpened != 1 || 966 !rNextInfo.HasStartValue() ) ) 967 { 968 bRestartNumberingAtContinuedRootList = true; 969 nRestartValueForContinuedRootList = 970 rNextInfo.GetListLevelStartValue(); 971 } 972 } 973 974 mpTextListsHelper->KeepListAsProcessed( sNewListId, 975 sListStyleName, 976 sContinueListId ); 977 } 978 979 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, 980 GetExport().EncodeStyleName( sListStyleName ) ); 981 bExportListStyle = false; 982 983 bRootListToBeStarted = false; 984 } 985 else if ( bExportListStyle && 986 !mpTextListsHelper->EqualsToTopListStyleOnStack( sListStyleName ) ) 987 { 988 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, 989 GetExport().EncodeStyleName( sListStyleName ) ); 990 bExportListStyle = false; 991 } 992 993 // --> OD 2008-11-26 #158694# 994 if ( bContinueingPreviousSubList ) 995 { 996 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 997 XML_CONTINUE_NUMBERING, XML_TRUE ); 998 bContinueingPreviousSubList = false; 999 } 1000 // <-- 1001 1002 enum XMLTokenEnum eLName = XML_LIST; 1003 1004 OUString *pElem = new OUString( 1005 GetExport().GetNamespaceMap().GetQNameByKey( 1006 XML_NAMESPACE_TEXT, 1007 GetXMLToken(eLName) ) ); 1008 GetExport().IgnorableWhitespace(); 1009 GetExport().StartElement( *pElem, sal_False ); 1010 1011 if( !pListElements ) 1012 pListElements = new OUStrings_Impl; 1013 pListElements->Insert( pElem, pListElements->Count() ); 1014 1015 mpTextListsHelper->PushListOnStack( sListId, 1016 sListStyleName ); 1017 1018 // <text:list-header> or <text:list-item> 1019 GetExport().CheckAttrList(); 1020 1021 // --> OD 2009-06-24 #i97309# 1022 // export start value in case of <bRestartNumberingAtContinuedRootList> 1023 // at correct list item 1024 if ( nListLevelsToBeOpened == 1 ) 1025 { 1026 if ( rNextInfo.HasStartValue() ) 1027 { 1028 OUStringBuffer aBuffer; 1029 aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() ); 1030 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE, 1031 aBuffer.makeStringAndClear() ); 1032 } 1033 else if ( bRestartNumberingAtContinuedRootList ) 1034 { 1035 OUStringBuffer aBuffer; 1036 aBuffer.append( (sal_Int32)nRestartValueForContinuedRootList ); 1037 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 1038 XML_START_VALUE, 1039 aBuffer.makeStringAndClear() ); 1040 bRestartNumberingAtContinuedRootList = false; 1041 } 1042 } 1043 // <-- 1044 1045 eLName = ( rNextInfo.IsNumbered() || nListLevelsToBeOpened > 1 ) 1046 ? XML_LIST_ITEM 1047 : XML_LIST_HEADER; 1048 pElem = new OUString( GetExport().GetNamespaceMap().GetQNameByKey( 1049 XML_NAMESPACE_TEXT, 1050 GetXMLToken(eLName) ) ); 1051 GetExport().IgnorableWhitespace(); 1052 GetExport().StartElement( *pElem, sal_False ); 1053 1054 pListElements->Insert( pElem, pListElements->Count() ); 1055 1056 // --> OD 2008-11-26 #158694# 1057 // export of <text:number> element for last opened <text:list-item>, if requested 1058 if ( GetExport().exportTextNumberElement() && 1059 eLName == XML_LIST_ITEM && nListLevelsToBeOpened == 1 && // last iteration --> last opened <text:list-item> 1060 rNextInfo.ListLabelString().getLength() > 0 ) 1061 { 1062 const ::rtl::OUString aTextNumberElem = 1063 OUString( GetExport().GetNamespaceMap().GetQNameByKey( 1064 XML_NAMESPACE_TEXT, 1065 GetXMLToken(XML_NUMBER) ) ); 1066 GetExport().IgnorableWhitespace(); 1067 GetExport().StartElement( aTextNumberElem, sal_False ); 1068 GetExport().Characters( rNextInfo.ListLabelString() ); 1069 GetExport().EndElement( aTextNumberElem, sal_True ); 1070 } 1071 // <-- 1072 1073 --nListLevelsToBeOpened; 1074 } while ( nListLevelsToBeOpened > 0 ); 1075 } 1076 } 1077 1078 if ( rNextInfo.GetLevel() > 0 && 1079 rNextInfo.IsNumbered() && 1080 rPrevInfo.BelongsToSameList( rNextInfo ) && 1081 rPrevInfo.GetLevel() >= rNextInfo.GetLevel() ) 1082 { 1083 // close previous list-item 1084 DBG_ASSERT( pListElements && pListElements->Count() >= 2, 1085 "SwXMLExport::ExportListChange: list elements missing" ); 1086 1087 OUString *pElem = (*pListElements)[pListElements->Count()-1]; 1088 GetExport().EndElement( *pElem, sal_True ); 1089 1090 pListElements->Remove( pListElements->Count()-1 ); 1091 delete pElem; 1092 1093 // --> OD 2009-11-12 #i103745# - only for sub lists 1094 if ( rNextInfo.IsRestart() && !rNextInfo.HasStartValue() && 1095 rNextInfo.GetLevel() != 1 ) 1096 // <-- 1097 { 1098 // start new sub list respectively list on same list level 1099 pElem = (*pListElements)[pListElements->Count()-1]; 1100 GetExport().EndElement( *pElem, sal_True ); 1101 GetExport().IgnorableWhitespace(); 1102 GetExport().StartElement( *pElem, sal_False ); 1103 } 1104 1105 // open new list-item 1106 GetExport().CheckAttrList(); 1107 if( rNextInfo.HasStartValue() ) 1108 { 1109 OUStringBuffer aBuffer; 1110 aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() ); 1111 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE, 1112 aBuffer.makeStringAndClear() ); 1113 } 1114 // --> OD 2009-11-12 #i103745# - handle restart without start value on list level 1 1115 else if ( rNextInfo.IsRestart() && /*!rNextInfo.HasStartValue() &&*/ 1116 rNextInfo.GetLevel() == 1 ) 1117 { 1118 OUStringBuffer aBuffer; 1119 aBuffer.append( (sal_Int32)rNextInfo.GetListLevelStartValue() ); 1120 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE, 1121 aBuffer.makeStringAndClear() ); 1122 } 1123 // <-- 1124 if ( ( GetExport().getExportFlags() & EXPORT_OASIS ) != 0 && 1125 GetExport().getDefaultVersion() >= SvtSaveOptions::ODFVER_012 ) 1126 { 1127 const ::rtl::OUString sListStyleName( rNextInfo.GetNumRulesName() ); 1128 if ( !mpTextListsHelper->EqualsToTopListStyleOnStack( sListStyleName ) ) 1129 { 1130 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 1131 XML_STYLE_OVERRIDE, 1132 GetExport().EncodeStyleName( sListStyleName ) ); 1133 } 1134 } 1135 pElem = new OUString( GetExport().GetNamespaceMap().GetQNameByKey( 1136 XML_NAMESPACE_TEXT, 1137 GetXMLToken(XML_LIST_ITEM) ) ); 1138 GetExport().IgnorableWhitespace(); 1139 GetExport().StartElement( *pElem, sal_False ); 1140 1141 pListElements->Insert( pElem, pListElements->Count() ); 1142 1143 // --> OD 2008-11-26 #158694# 1144 // export of <text:number> element for <text:list-item>, if requested 1145 if ( GetExport().exportTextNumberElement() && 1146 rNextInfo.ListLabelString().getLength() > 0 ) 1147 { 1148 const ::rtl::OUString aTextNumberElem = 1149 OUString( GetExport().GetNamespaceMap().GetQNameByKey( 1150 XML_NAMESPACE_TEXT, 1151 GetXMLToken(XML_NUMBER) ) ); 1152 GetExport().IgnorableWhitespace(); 1153 GetExport().StartElement( aTextNumberElem, sal_False ); 1154 GetExport().Characters( rNextInfo.ListLabelString() ); 1155 GetExport().EndElement( aTextNumberElem, sal_True ); 1156 } 1157 // <-- 1158 } 1159 } 1160 // <-- 1161 1162 XMLTextParagraphExport::XMLTextParagraphExport( 1163 SvXMLExport& rExp, 1164 SvXMLAutoStylePoolP & rASP 1165 ) : 1166 XMLStyleExport( rExp, OUString(), &rASP ), 1167 rAutoStylePool( rASP ), 1168 pBoundFrameSets(new BoundFrameSets(GetExport().GetModel())), 1169 pFieldExport( 0 ), 1170 pListElements( 0 ), 1171 // --> OD 2008-05-07 #refactorlists# - no longer needed 1172 // pExportedLists( 0 ), 1173 // <-- 1174 pListAutoPool( new XMLTextListAutoStylePool( this->GetExport() ) ), 1175 pSectionExport( NULL ), 1176 pIndexMarkExport( NULL ), 1177 1178 pRedlineExport( NULL ), 1179 pHeadingStyles( NULL ), 1180 1181 bProgress( sal_False ), 1182 bBlock( sal_False ), 1183 1184 bOpenRuby( sal_False ), 1185 // --> OD 2008-04-25 #refactorlists# 1186 mpTextListsHelper( 0 ), 1187 maTextListsHelperStack(), 1188 // <-- 1189 1190 sActualSize(RTL_CONSTASCII_USTRINGPARAM("ActualSize")), 1191 // --> OD 2009-07-22 #i73249# 1192 // sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")), 1193 sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")), 1194 sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")), 1195 // <-- 1196 sAnchorCharStyleName(RTL_CONSTASCII_USTRINGPARAM("AnchorCharStyleName")), 1197 sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")), 1198 sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")), 1199 sBeginNotice(RTL_CONSTASCII_USTRINGPARAM("BeginNotice")), 1200 sBookmark(RTL_CONSTASCII_USTRINGPARAM("Bookmark")), 1201 sCategory(RTL_CONSTASCII_USTRINGPARAM("Category")), 1202 sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")), 1203 sCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName")), 1204 sCharStyleNames(RTL_CONSTASCII_USTRINGPARAM("CharStyleNames")), 1205 sContourPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon")), 1206 sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex")), 1207 sDocumentIndexMark(RTL_CONSTASCII_USTRINGPARAM("DocumentIndexMark")), 1208 sEndNotice(RTL_CONSTASCII_USTRINGPARAM("EndNotice")), 1209 sFootnote(RTL_CONSTASCII_USTRINGPARAM("Footnote")), 1210 sFootnoteCounting(RTL_CONSTASCII_USTRINGPARAM("FootnoteCounting")), 1211 sFrame(RTL_CONSTASCII_USTRINGPARAM("Frame")), 1212 sFrameHeightAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameHeightAbsolute")), 1213 sFrameHeightPercent(RTL_CONSTASCII_USTRINGPARAM("FrameHeightPercent")), 1214 sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")), 1215 sFrameWidthAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameWidthAbsolute")), 1216 sFrameWidthPercent(RTL_CONSTASCII_USTRINGPARAM("FrameWidthPercent")), 1217 sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")), 1218 sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")), 1219 sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")), 1220 sReplacementGraphicURL(RTL_CONSTASCII_USTRINGPARAM("ReplacementGraphicURL")), 1221 sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")), 1222 sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), 1223 sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), 1224 sHyperLinkName(RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")), 1225 sHyperLinkTarget(RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")), 1226 sHyperLinkURL(RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")), 1227 sIsAutomaticContour(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour")), 1228 sIsCollapsed(RTL_CONSTASCII_USTRINGPARAM("IsCollapsed")), 1229 sIsPixelContour(RTL_CONSTASCII_USTRINGPARAM("IsPixelContour")), 1230 sIsStart(RTL_CONSTASCII_USTRINGPARAM("IsStart")), 1231 sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")), 1232 sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")), 1233 sNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules")), 1234 sNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType")), 1235 sPageDescName(RTL_CONSTASCII_USTRINGPARAM("PageDescName")), 1236 sPageStyleName(RTL_CONSTASCII_USTRINGPARAM("PageStyleName")), 1237 sParaChapterNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("ParaChapterNumberingLevel")), 1238 sParaConditionalStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaConditionalStyleName")), 1239 sParagraphService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Paragraph")), 1240 sParaStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName")), 1241 sPositionEndOfDoc(RTL_CONSTASCII_USTRINGPARAM("PositionEndOfDoc")), 1242 sPrefix(RTL_CONSTASCII_USTRINGPARAM("Prefix")), 1243 sRedline(RTL_CONSTASCII_USTRINGPARAM("Redline")), 1244 sReferenceId(RTL_CONSTASCII_USTRINGPARAM("ReferenceId")), 1245 sReferenceMark(RTL_CONSTASCII_USTRINGPARAM("ReferenceMark")), 1246 sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")), 1247 sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")), 1248 sRuby(RTL_CONSTASCII_USTRINGPARAM("Ruby")), 1249 sRubyAdjust(RTL_CONSTASCII_USTRINGPARAM("RubyAdjust")), 1250 sRubyCharStyleName(RTL_CONSTASCII_USTRINGPARAM("RubyCharStyleName")), 1251 sRubyText(RTL_CONSTASCII_USTRINGPARAM("RubyText")), 1252 sServerMap(RTL_CONSTASCII_USTRINGPARAM("ServerMap")), 1253 sShapeService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape")), 1254 sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")), 1255 sSoftPageBreak( RTL_CONSTASCII_USTRINGPARAM( "SoftPageBreak" ) ), 1256 sStartAt(RTL_CONSTASCII_USTRINGPARAM("StartAt")), 1257 sSuffix(RTL_CONSTASCII_USTRINGPARAM("Suffix")), 1258 sTableService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable")), 1259 sText(RTL_CONSTASCII_USTRINGPARAM("Text")), 1260 sTextContentService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextContent")), 1261 sTextEmbeddedService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextEmbeddedObject")), 1262 sTextEndnoteService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote")), 1263 sTextField(RTL_CONSTASCII_USTRINGPARAM("TextField")), 1264 sTextFieldService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField")), 1265 sTextFrameService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")), 1266 sTextGraphicService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextGraphicObject")), 1267 sTextPortionType(RTL_CONSTASCII_USTRINGPARAM("TextPortionType")), 1268 sTextSection(RTL_CONSTASCII_USTRINGPARAM("TextSection")), 1269 sUnvisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("UnvisitedCharStyleName")), 1270 sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), 1271 sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), 1272 sVisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("VisitedCharStyleName")), 1273 sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")), 1274 sWidthType( RTL_CONSTASCII_USTRINGPARAM( "WidthType" ) ), 1275 sTextFieldStart( RTL_CONSTASCII_USTRINGPARAM( "TextFieldStart" ) ), 1276 sTextFieldEnd( RTL_CONSTASCII_USTRINGPARAM( "TextFieldEnd" ) ), 1277 sTextFieldStartEnd( RTL_CONSTASCII_USTRINGPARAM( "TextFieldStartEnd" ) ), 1278 aCharStyleNamesPropInfoCache( sCharStyleNames ) 1279 { 1280 UniReference < XMLPropertySetMapper > xPropMapper(new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA )); 1281 xParaPropMapper = new XMLTextExportPropertySetMapper( xPropMapper, 1282 GetExport() ); 1283 1284 OUString sFamily( GetXMLToken(XML_PARAGRAPH) ); 1285 OUString aPrefix( String( 'P' ) ); 1286 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH, sFamily, 1287 xParaPropMapper, aPrefix ); 1288 1289 xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT ); 1290 xTextPropMapper = new XMLTextExportPropertySetMapper( xPropMapper, 1291 GetExport() ); 1292 sFamily = OUString( GetXMLToken(XML_TEXT) ); 1293 aPrefix = OUString( String( 'T' ) ); 1294 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_TEXT, sFamily, 1295 xTextPropMapper, aPrefix ); 1296 1297 xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_AUTO_FRAME ); 1298 xAutoFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper, 1299 GetExport() ); 1300 sFamily = OUString( RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME) ); 1301 aPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "fr" ) ); 1302 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_FRAME, sFamily, 1303 xAutoFramePropMapper, aPrefix ); 1304 1305 xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION ); 1306 xSectionPropMapper = new XMLTextExportPropertySetMapper( xPropMapper, 1307 GetExport() ); 1308 sFamily = OUString( GetXMLToken( XML_SECTION ) ); 1309 aPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "Sect" ) ); 1310 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_SECTION, sFamily, 1311 xSectionPropMapper, aPrefix ); 1312 1313 xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY ); 1314 xRubyPropMapper = new SvXMLExportPropertyMapper( xPropMapper ); 1315 sFamily = OUString( GetXMLToken( XML_RUBY ) ); 1316 aPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "Ru" ) ); 1317 rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_RUBY, sFamily, 1318 xRubyPropMapper, aPrefix ); 1319 1320 xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME ); 1321 xFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper, 1322 GetExport() ); 1323 1324 pSectionExport = new XMLSectionExport( rExp, *this ); 1325 pIndexMarkExport = new XMLIndexMarkExport( rExp, *this ); 1326 1327 if( ! IsBlockMode() && 1328 Reference<XRedlinesSupplier>( GetExport().GetModel(), UNO_QUERY ).is()) 1329 pRedlineExport = new XMLRedlineExport( rExp ); 1330 1331 // The text field helper needs a pre-constructed XMLPropertyState 1332 // to export the combined characters field. We construct that 1333 // here, because we need the text property mapper to do it. 1334 1335 // construct Any value, then find index 1336 sal_Int32 nIndex = xTextPropMapper->getPropertySetMapper()->FindEntryIndex( 1337 "", XML_NAMESPACE_STYLE, 1338 GetXMLToken(XML_TEXT_COMBINE)); 1339 pFieldExport = new XMLTextFieldExport( rExp, new XMLPropertyState( nIndex, uno::makeAny(sal_True) ) ); 1340 1341 // --> OD 2008-05-08 #refactorlists# 1342 PushNewTextListsHelper(); 1343 // <-- 1344 } 1345 1346 XMLTextParagraphExport::~XMLTextParagraphExport() 1347 { 1348 delete pHeadingStyles; 1349 delete pRedlineExport; 1350 delete pIndexMarkExport; 1351 delete pSectionExport; 1352 delete pFieldExport; 1353 delete pListElements; 1354 // --> OD 2008-05-07 #refactorlists# - no longer needed 1355 // delete pExportedLists; 1356 // <-- 1357 delete pListAutoPool; 1358 #ifdef DBG_UTIL 1359 txtparae_bContainsIllegalCharacters = sal_False; 1360 #endif 1361 // --> OD 2008-04-25 #refactorlists# 1362 // also deletes <mpTextListsHelper> 1363 PopTextListsHelper(); 1364 DBG_ASSERT( maTextListsHelperStack.size() == 0, 1365 "misusage of text lists helper stack - it is not empty. Serious defect - please inform OD" ); 1366 // <-- 1367 } 1368 1369 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateShapeExtPropMapper( 1370 SvXMLExport& rExport ) 1371 { 1372 UniReference < XMLPropertySetMapper > xPropMapper = 1373 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE ); 1374 return new XMLTextExportPropertySetMapper( xPropMapper, rExport ); 1375 } 1376 1377 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateCharExtPropMapper( 1378 SvXMLExport& rExport) 1379 { 1380 XMLPropertySetMapper *pPropMapper = 1381 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT ); 1382 return new XMLTextExportPropertySetMapper( pPropMapper, rExport ); 1383 } 1384 1385 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaExtPropMapper( 1386 SvXMLExport& rExport) 1387 { 1388 XMLPropertySetMapper *pPropMapper = 1389 new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA ); 1390 return new XMLTextExportPropertySetMapper( pPropMapper, rExport ); 1391 } 1392 1393 SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaDefaultExtPropMapper( 1394 SvXMLExport& rExport) 1395 { 1396 XMLPropertySetMapper *pPropMapper = 1397 new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT_ADDITIONAL_DEFAULTS ); 1398 return new XMLTextExportPropertySetMapper( pPropMapper, rExport ); 1399 } 1400 1401 void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles, 1402 sal_Bool bIsProgress ) 1403 { 1404 const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetPageBoundContents(); 1405 const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetPageBoundContents(); 1406 const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetPageBoundContents(); 1407 const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetPageBoundContents(); 1408 for(TextContentSet::const_iterator_t it = pTexts->getBegin(); 1409 it != pTexts->getEnd(); 1410 ++it) 1411 exportTextFrame(*it, bAutoStyles, bIsProgress, sal_True); 1412 for(TextContentSet::const_iterator_t it = pGraphics->getBegin(); 1413 it != pGraphics->getEnd(); 1414 ++it) 1415 exportTextGraphic(*it, bAutoStyles); 1416 for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin(); 1417 it != pEmbeddeds->getEnd(); 1418 ++it) 1419 exportTextEmbedded(*it, bAutoStyles); 1420 for(TextContentSet::const_iterator_t it = pShapes->getBegin(); 1421 it != pShapes->getEnd(); 1422 ++it) 1423 exportShape(*it, bAutoStyles); 1424 } 1425 1426 void XMLTextParagraphExport::exportFrameFrames( 1427 sal_Bool bAutoStyles, 1428 sal_Bool bIsProgress, 1429 const Reference < XTextFrame > *pParentTxtFrame ) 1430 { 1431 const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetFrameBoundContents(*pParentTxtFrame); 1432 if(pTexts) 1433 for(TextContentSet::const_iterator_t it = pTexts->getBegin(); 1434 it != pTexts->getEnd(); 1435 ++it) 1436 exportTextFrame(*it, bAutoStyles, bIsProgress, sal_True); 1437 const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetFrameBoundContents(*pParentTxtFrame); 1438 if(pGraphics) 1439 for(TextContentSet::const_iterator_t it = pGraphics->getBegin(); 1440 it != pGraphics->getEnd(); 1441 ++it) 1442 exportTextGraphic(*it, bAutoStyles); 1443 const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetFrameBoundContents(*pParentTxtFrame); 1444 if(pEmbeddeds) 1445 for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin(); 1446 it != pEmbeddeds->getEnd(); 1447 ++it) 1448 exportTextEmbedded(*it, bAutoStyles); 1449 const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetFrameBoundContents(*pParentTxtFrame); 1450 if(pShapes) 1451 for(TextContentSet::const_iterator_t it = pShapes->getBegin(); 1452 it != pShapes->getEnd(); 1453 ++it) 1454 exportShape(*it, bAutoStyles); 1455 } 1456 1457 // bookmarks, reference marks (and TOC marks) are the same except for the 1458 // element names. We use the same method for export and it an array with 1459 // the proper element names 1460 static const enum XMLTokenEnum lcl_XmlReferenceElements[] = { 1461 XML_REFERENCE_MARK, XML_REFERENCE_MARK_START, XML_REFERENCE_MARK_END }; 1462 static const enum XMLTokenEnum lcl_XmlBookmarkElements[] = { 1463 XML_BOOKMARK, XML_BOOKMARK_START, XML_BOOKMARK_END }; 1464 1465 // This function replaces the text portion iteration during auto style 1466 // collection. 1467 bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgress ) 1468 { 1469 GetExport().GetShapeExport(); // make sure the graphics styles family is added 1470 1471 const sal_Bool bAutoStyles = sal_True; 1472 const sal_Bool bExportContent = sal_False; 1473 1474 // Export AutoStyles: 1475 Reference< XAutoStylesSupplier > xAutoStylesSupp( GetExport().GetModel(), UNO_QUERY ); 1476 if ( xAutoStylesSupp.is() ) 1477 { 1478 Reference< XAutoStyles > xAutoStyleFamilies = xAutoStylesSupp->getAutoStyles(); 1479 OUString sName; 1480 sal_uInt16 nFamily; 1481 1482 for ( int i = 0; i < 3; ++i ) 1483 { 1484 if ( 0 == i ) 1485 { 1486 sName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharacterStyles" ) ); 1487 nFamily = XML_STYLE_FAMILY_TEXT_TEXT; 1488 } 1489 else if ( 1 == i ) 1490 { 1491 sName = OUString( RTL_CONSTASCII_USTRINGPARAM( "RubyStyles" ) ); 1492 nFamily = XML_STYLE_FAMILY_TEXT_RUBY; 1493 } 1494 else 1495 { 1496 sName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) ); 1497 nFamily = XML_STYLE_FAMILY_TEXT_PARAGRAPH; 1498 } 1499 1500 Any aAny = xAutoStyleFamilies->getByName( sName ); 1501 Reference< XAutoStyleFamily > xAutoStyles = *(Reference<XAutoStyleFamily>*)aAny.getValue(); 1502 Reference < XEnumeration > xAutoStylesEnum( xAutoStyles->createEnumeration() ); 1503 1504 while ( xAutoStylesEnum->hasMoreElements() ) 1505 { 1506 aAny = xAutoStylesEnum->nextElement(); 1507 Reference< XAutoStyle > xAutoStyle = *(Reference<XAutoStyle>*)aAny.getValue(); 1508 Reference < XPropertySet > xPSet( xAutoStyle, uno::UNO_QUERY ); 1509 Add( nFamily, xPSet, 0, true ); 1510 } 1511 } 1512 } 1513 1514 // Export Field AutoStyles: 1515 Reference< XTextFieldsSupplier > xTextFieldsSupp( GetExport().GetModel(), UNO_QUERY ); 1516 if ( xTextFieldsSupp.is() ) 1517 { 1518 Reference< XEnumerationAccess > xTextFields = xTextFieldsSupp->getTextFields(); 1519 Reference < XEnumeration > xTextFieldsEnum( xTextFields->createEnumeration() ); 1520 1521 while ( xTextFieldsEnum->hasMoreElements() ) 1522 { 1523 Any aAny = xTextFieldsEnum->nextElement(); 1524 Reference< XTextField > xTextField = *(Reference<XTextField>*)aAny.getValue(); 1525 exportTextField( xTextField, bAutoStyles, bIsProgress, 1526 !xAutoStylesSupp.is() ); 1527 try 1528 { 1529 Reference < XPropertySet > xSet( xTextField, UNO_QUERY ); 1530 Reference < XText > xText; 1531 Any a = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("TextRange") ); 1532 a >>= xText; 1533 if ( xText.is() ) 1534 { 1535 exportText( xText, sal_True, bIsProgress, bExportContent ); 1536 GetExport().GetTextParagraphExport() 1537 ->collectTextAutoStyles( xText ); 1538 } 1539 } 1540 catch (Exception&) 1541 { 1542 } 1543 } 1544 } 1545 1546 // Export text frames: 1547 Reference<XEnumeration> xTextFramesEnum = pBoundFrameSets->GetTexts()->createEnumeration(); 1548 if(xTextFramesEnum.is()) 1549 while(xTextFramesEnum->hasMoreElements()) 1550 { 1551 Reference<XTextContent> xTxtCntnt(xTextFramesEnum->nextElement(), UNO_QUERY); 1552 if(xTxtCntnt.is()) 1553 exportTextFrame(xTxtCntnt, bAutoStyles, bIsProgress, bExportContent, 0); 1554 } 1555 1556 // Export graphic objects: 1557 Reference<XEnumeration> xGraphicsEnum = pBoundFrameSets->GetGraphics()->createEnumeration(); 1558 if(xGraphicsEnum.is()) 1559 while(xGraphicsEnum->hasMoreElements()) 1560 { 1561 Reference<XTextContent> xTxtCntnt(xGraphicsEnum->nextElement(), UNO_QUERY); 1562 if(xTxtCntnt.is()) 1563 exportTextGraphic(xTxtCntnt, true, 0); 1564 } 1565 1566 // Export embedded objects: 1567 Reference<XEnumeration> xEmbeddedsEnum = pBoundFrameSets->GetEmbeddeds()->createEnumeration(); 1568 if(xEmbeddedsEnum.is()) 1569 while(xEmbeddedsEnum->hasMoreElements()) 1570 { 1571 Reference<XTextContent> xTxtCntnt(xEmbeddedsEnum->nextElement(), UNO_QUERY); 1572 if(xTxtCntnt.is()) 1573 exportTextEmbedded(xTxtCntnt, true, 0); 1574 } 1575 1576 // Export shapes: 1577 Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration(); 1578 if(xShapesEnum.is()) 1579 while(xShapesEnum->hasMoreElements()) 1580 { 1581 Reference<XTextContent> xTxtCntnt(xShapesEnum->nextElement(), UNO_QUERY); 1582 if(xTxtCntnt.is()) 1583 { 1584 Reference<XServiceInfo> xServiceInfo(xTxtCntnt, UNO_QUERY); 1585 if( xServiceInfo->supportsService(sShapeService)) 1586 exportShape(xTxtCntnt, true, 0); 1587 } 1588 } 1589 1590 sal_Int32 nCount; 1591 // AutoStyles for sections 1592 Reference< XTextSectionsSupplier > xSectionsSupp( GetExport().GetModel(), UNO_QUERY ); 1593 if ( xSectionsSupp.is() ) 1594 { 1595 Reference< XIndexAccess > xSections( xSectionsSupp->getTextSections(), UNO_QUERY ); 1596 if ( xSections.is() ) 1597 { 1598 nCount = xSections->getCount(); 1599 for( sal_Int32 i = 0; i < nCount; ++i ) 1600 { 1601 Any aAny = xSections->getByIndex( i ); 1602 Reference< XTextSection > xSection = *(Reference<XTextSection>*)aAny.getValue(); 1603 Reference < XPropertySet > xPSet( xSection, uno::UNO_QUERY ); 1604 Add( XML_STYLE_FAMILY_TEXT_SECTION, xPSet ); 1605 } 1606 } 1607 } 1608 1609 // AutoStyles for tables (Note: suppress autostyle collection for paragraphs in exportTable) 1610 Reference< XTextTablesSupplier > xTablesSupp( GetExport().GetModel(), UNO_QUERY ); 1611 if ( xTablesSupp.is() ) 1612 { 1613 Reference< XIndexAccess > xTables( xTablesSupp->getTextTables(), UNO_QUERY ); 1614 if ( xTables.is() ) 1615 { 1616 nCount = xTables->getCount(); 1617 for( sal_Int32 i = 0; i < nCount; ++i ) 1618 { 1619 Any aAny = xTables->getByIndex( i ); 1620 Reference< XTextTable > xTable = *(Reference<XTextTable>*)aAny.getValue(); 1621 Reference < XTextContent > xTextContent( xTable, uno::UNO_QUERY ); 1622 exportTable( xTextContent, sal_True, sal_True ); 1623 } 1624 } 1625 } 1626 1627 Reference< XNumberingRulesSupplier > xNumberingRulesSupp( GetExport().GetModel(), UNO_QUERY ); 1628 if ( xNumberingRulesSupp.is() ) 1629 { 1630 Reference< XIndexAccess > xNumberingRules = xNumberingRulesSupp->getNumberingRules(); 1631 nCount = xNumberingRules->getCount(); 1632 // --> OD 2007-01-12 #i73361# 1633 const OUString sNumberingIsOutline( RTL_CONSTASCII_USTRINGPARAM( "NumberingIsOutline" ) ); 1634 // <-- 1635 for( sal_Int32 i = 0; i < nCount; ++i ) 1636 { 1637 Reference< XIndexReplace > xNumRule( xNumberingRules->getByIndex( i ), UNO_QUERY ); 1638 if( xNumRule.is() && xNumRule->getCount() ) 1639 { 1640 Reference < XNamed > xNamed( xNumRule, UNO_QUERY ); 1641 OUString sName; 1642 if( xNamed.is() ) 1643 sName = xNamed->getName(); 1644 sal_Bool bAdd = !sName.getLength(); 1645 if( !bAdd ) 1646 { 1647 Reference < XPropertySet > xNumPropSet( xNumRule, 1648 UNO_QUERY ); 1649 const OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) ); 1650 if( xNumPropSet.is() && 1651 xNumPropSet->getPropertySetInfo() 1652 ->hasPropertyByName( sIsAutomatic ) ) 1653 { 1654 bAdd = *(sal_Bool *)xNumPropSet->getPropertyValue( sIsAutomatic ).getValue(); 1655 // --> OD 2007-01-12 #i73361# - check on outline style 1656 if ( bAdd && 1657 xNumPropSet->getPropertySetInfo() 1658 ->hasPropertyByName( sNumberingIsOutline ) ) 1659 { 1660 bAdd = !(*(sal_Bool *)xNumPropSet->getPropertyValue( sNumberingIsOutline ).getValue()); 1661 } 1662 // <-- 1663 } 1664 else 1665 { 1666 bAdd = sal_True; 1667 } 1668 } 1669 if( bAdd ) 1670 pListAutoPool->Add( xNumRule ); 1671 } 1672 } 1673 } 1674 1675 return true; 1676 } 1677 1678 void XMLTextParagraphExport::exportText( 1679 const Reference < XText > & rText, 1680 sal_Bool bAutoStyles, 1681 sal_Bool bIsProgress, 1682 sal_Bool bExportParagraph ) 1683 { 1684 if( bAutoStyles ) 1685 GetExport().GetShapeExport(); // make sure the graphics styles family 1686 // is added 1687 Reference < XEnumerationAccess > xEA( rText, UNO_QUERY ); 1688 Reference < XEnumeration > xParaEnum(xEA->createEnumeration()); 1689 Reference < XPropertySet > xPropertySet( rText, UNO_QUERY ); 1690 Reference < XTextSection > xBaseSection; 1691 1692 // #97718# footnotes don't supply paragraph enumerations in some cases 1693 // This is always a bug, but at least we don't want to crash. 1694 DBG_ASSERT( xParaEnum.is(), "We need a paragraph enumeration" ); 1695 if( ! xParaEnum.is() ) 1696 return; 1697 1698 sal_Bool bExportLevels = sal_True; 1699 1700 if (xPropertySet.is()) 1701 { 1702 Reference < XPropertySetInfo > xInfo ( xPropertySet->getPropertySetInfo() ); 1703 1704 if( xInfo.is() ) 1705 { 1706 if (xInfo->hasPropertyByName( sTextSection )) 1707 { 1708 xPropertySet->getPropertyValue(sTextSection) >>= xBaseSection ; 1709 } 1710 1711 /* #i35937# 1712 // for applications that use the outliner we need to check if 1713 // the current text object needs the level information exported 1714 if( !bAutoStyles ) 1715 { 1716 // fixme: move string to class member, couldn't do now because 1717 // of no incompatible build 1718 OUString sHasLevels( RTL_CONSTASCII_USTRINGPARAM("HasLevels") ); 1719 if (xInfo->hasPropertyByName( sHasLevels ) ) 1720 { 1721 xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels; 1722 } 1723 } 1724 */ 1725 } 1726 } 1727 1728 // #96530# Export redlines at start & end of XText before & after 1729 // exporting the text content enumeration 1730 if( !bAutoStyles && (pRedlineExport != NULL) ) 1731 pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True ); 1732 exportTextContentEnumeration( xParaEnum, bAutoStyles, xBaseSection, 1733 bIsProgress, bExportParagraph, 0, bExportLevels ); 1734 if( !bAutoStyles && (pRedlineExport != NULL) ) 1735 pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False ); 1736 } 1737 1738 void XMLTextParagraphExport::exportText( 1739 const Reference < XText > & rText, 1740 const Reference < XTextSection > & rBaseSection, 1741 sal_Bool bAutoStyles, 1742 sal_Bool bIsProgress, 1743 sal_Bool bExportParagraph ) 1744 { 1745 if( bAutoStyles ) 1746 GetExport().GetShapeExport(); // make sure the graphics styles family 1747 // is added 1748 Reference < XEnumerationAccess > xEA( rText, UNO_QUERY ); 1749 Reference < XEnumeration > xParaEnum(xEA->createEnumeration()); 1750 1751 // #98165# don't continue without a paragraph enumeration 1752 if( ! xParaEnum.is() ) 1753 return; 1754 1755 // #96530# Export redlines at start & end of XText before & after 1756 // exporting the text content enumeration 1757 Reference<XPropertySet> xPropertySet; 1758 if( !bAutoStyles && (pRedlineExport != NULL) ) 1759 { 1760 xPropertySet.set(rText, uno::UNO_QUERY ); 1761 pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True ); 1762 } 1763 exportTextContentEnumeration( xParaEnum, bAutoStyles, rBaseSection, 1764 bIsProgress, bExportParagraph ); 1765 if( !bAutoStyles && (pRedlineExport != NULL) ) 1766 pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False ); 1767 } 1768 1769 sal_Bool XMLTextParagraphExport::exportTextContentEnumeration( 1770 const Reference < XEnumeration > & rContEnum, 1771 sal_Bool bAutoStyles, 1772 const Reference < XTextSection > & rBaseSection, 1773 sal_Bool bIsProgress, 1774 sal_Bool bExportParagraph, 1775 const Reference < XPropertySet > *pRangePropSet, 1776 sal_Bool bExportLevels ) 1777 { 1778 DBG_ASSERT( rContEnum.is(), "No enumeration to export!" ); 1779 sal_Bool bHasMoreElements = rContEnum->hasMoreElements(); 1780 if( !bHasMoreElements ) 1781 return sal_False; 1782 1783 XMLTextNumRuleInfo aPrevNumInfo; 1784 XMLTextNumRuleInfo aNextNumInfo; 1785 1786 sal_Bool bHasContent = sal_False; 1787 Reference<XTextSection> xCurrentTextSection(rBaseSection); 1788 1789 MultiPropertySetHelper aPropSetHelper( 1790 bAutoStyles ? aParagraphPropertyNamesAuto : 1791 aParagraphPropertyNames ); 1792 1793 sal_Bool bHoldElement = sal_False; 1794 Reference < XTextContent > xTxtCntnt; 1795 while( bHoldElement || bHasMoreElements ) 1796 { 1797 if (bHoldElement) 1798 { 1799 bHoldElement = sal_False; 1800 } 1801 else 1802 { 1803 xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY); 1804 1805 aPropSetHelper.resetValues(); 1806 1807 } 1808 1809 Reference<XServiceInfo> xServiceInfo( xTxtCntnt, UNO_QUERY ); 1810 if( xServiceInfo->supportsService( sParagraphService ) ) 1811 { 1812 if( bExportLevels ) 1813 { 1814 if( bAutoStyles ) 1815 { 1816 exportListAndSectionChange( xCurrentTextSection, xTxtCntnt, 1817 aPrevNumInfo, aNextNumInfo, 1818 bAutoStyles ); 1819 } 1820 else 1821 { 1822 // --> OD 2006-09-27 #i69627# 1823 // --> OD 2008-04-24 #refactorlists# 1824 // pass list auto style pool to <XMLTextNumRuleInfo> instance 1825 // --> OD 2008-11-26 #158694# 1826 // pass info about request to export <text:number> element 1827 // to <XMLTextNumRuleInfo> instance 1828 aNextNumInfo.Set( xTxtCntnt, 1829 GetExport().writeOutlineStyleAsNormalListStyle(), 1830 GetListAutoStylePool(), 1831 GetExport().exportTextNumberElement() ); 1832 // <-- 1833 1834 exportListAndSectionChange( xCurrentTextSection, aPropSetHelper, 1835 TEXT_SECTION, xTxtCntnt, 1836 aPrevNumInfo, aNextNumInfo, 1837 bAutoStyles ); 1838 } 1839 } 1840 1841 // if we found a mute section: skip all section content 1842 if (pSectionExport->IsMuteSection(xCurrentTextSection)) 1843 { 1844 // Make sure headings are exported anyway. 1845 if( !bAutoStyles ) 1846 pSectionExport->ExportMasterDocHeadingDummies(); 1847 1848 while (rContEnum->hasMoreElements() && 1849 pSectionExport->IsInSection( xCurrentTextSection, 1850 xTxtCntnt, sal_True )) 1851 { 1852 xTxtCntnt.set(rContEnum->nextElement(), uno::UNO_QUERY); 1853 aPropSetHelper.resetValues(); 1854 aNextNumInfo.Reset(); 1855 } 1856 // the first non-mute element still needs to be processed 1857 bHoldElement = 1858 ! pSectionExport->IsInSection( xCurrentTextSection, 1859 xTxtCntnt, sal_False ); 1860 } 1861 else 1862 exportParagraph( xTxtCntnt, bAutoStyles, bIsProgress, 1863 bExportParagraph, aPropSetHelper ); 1864 bHasContent = sal_True; 1865 } 1866 else if( xServiceInfo->supportsService( sTableService ) ) 1867 { 1868 if( !bAutoStyles ) 1869 { 1870 aNextNumInfo.Reset(); 1871 } 1872 1873 exportListAndSectionChange( xCurrentTextSection, xTxtCntnt, 1874 aPrevNumInfo, aNextNumInfo, 1875 bAutoStyles ); 1876 1877 if (! pSectionExport->IsMuteSection(xCurrentTextSection)) 1878 { 1879 // export start + end redlines (for wholly redlined tables) 1880 if ((! bAutoStyles) && (NULL != pRedlineExport)) 1881 pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_True); 1882 1883 exportTable( xTxtCntnt, bAutoStyles, bIsProgress ); 1884 1885 if ((! bAutoStyles) && (NULL != pRedlineExport)) 1886 pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_False); 1887 } 1888 else if( !bAutoStyles ) 1889 { 1890 // Make sure headings are exported anyway. 1891 pSectionExport->ExportMasterDocHeadingDummies(); 1892 } 1893 1894 bHasContent = sal_True; 1895 } 1896 else if( xServiceInfo->supportsService( sTextFrameService ) ) 1897 { 1898 exportTextFrame( xTxtCntnt, bAutoStyles, bIsProgress, sal_True, pRangePropSet ); 1899 } 1900 else if( xServiceInfo->supportsService( sTextGraphicService ) ) 1901 { 1902 exportTextGraphic( xTxtCntnt, bAutoStyles, pRangePropSet ); 1903 } 1904 else if( xServiceInfo->supportsService( sTextEmbeddedService ) ) 1905 { 1906 exportTextEmbedded( xTxtCntnt, bAutoStyles, pRangePropSet ); 1907 } 1908 else if( xServiceInfo->supportsService( sShapeService ) ) 1909 { 1910 exportShape( xTxtCntnt, bAutoStyles, pRangePropSet ); 1911 } 1912 else 1913 { 1914 DBG_ASSERT( !xTxtCntnt.is(), "unknown text content" ); 1915 } 1916 1917 if( !bAutoStyles ) 1918 { 1919 aPrevNumInfo = aNextNumInfo; 1920 } 1921 1922 bHasMoreElements = rContEnum->hasMoreElements(); 1923 } 1924 1925 if( bExportLevels && bHasContent && !bAutoStyles ) 1926 { 1927 aNextNumInfo.Reset(); 1928 1929 // close open lists and sections; no new styles 1930 exportListAndSectionChange( xCurrentTextSection, rBaseSection, 1931 aPrevNumInfo, aNextNumInfo, 1932 bAutoStyles ); 1933 } 1934 1935 return sal_True; 1936 } 1937 1938 void XMLTextParagraphExport::exportParagraph( 1939 const Reference < XTextContent > & rTextContent, 1940 sal_Bool bAutoStyles, sal_Bool bIsProgress, sal_Bool bExportParagraph, 1941 MultiPropertySetHelper& rPropSetHelper) 1942 { 1943 sal_Int16 nOutlineLevel = -1; 1944 1945 if( bIsProgress ) 1946 { 1947 ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper(); 1948 pProgress->SetValue( pProgress->GetValue()+1 ); 1949 } 1950 1951 // get property set or multi property set and initialize helper 1952 Reference<XMultiPropertySet> xMultiPropSet( rTextContent, UNO_QUERY ); 1953 Reference<XPropertySet> xPropSet( rTextContent, UNO_QUERY ); 1954 1955 // check for supported properties 1956 if( !rPropSetHelper.checkedProperties() ) 1957 rPropSetHelper.hasProperties( xPropSet->getPropertySetInfo() ); 1958 1959 // if( xMultiPropSet.is() ) 1960 // rPropSetHelper.getValues( xMultiPropSet ); 1961 // else 1962 // rPropSetHelper.getValues( xPropSet ); 1963 1964 if( bExportParagraph ) 1965 { 1966 if( bAutoStyles ) 1967 { 1968 Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, rPropSetHelper, xPropSet ); 1969 } 1970 else 1971 { 1972 // xml:id for RDF metadata 1973 GetExport().AddAttributeXmlId(rTextContent); 1974 GetExport().AddAttributesRDFa(rTextContent); 1975 1976 OUString sStyle; 1977 if( rPropSetHelper.hasProperty( PARA_STYLE_NAME ) ) 1978 { 1979 if( xMultiPropSet.is() ) 1980 rPropSetHelper.getValue( PARA_STYLE_NAME, 1981 xMultiPropSet ) >>= sStyle; 1982 else 1983 rPropSetHelper.getValue( PARA_STYLE_NAME, 1984 xPropSet ) >>= sStyle; 1985 } 1986 1987 Reference< XInterface > xRef( rTextContent, UNO_QUERY ); 1988 if( xRef.is() ) 1989 { 1990 const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( xRef ); 1991 if( rIdentifier.getLength() ) 1992 { 1993 // FIXME: this is just temporary until EditEngine 1994 // paragraphs implement XMetadatable. 1995 // then that must be used and not the mapper, because 1996 // when both can be used we get two xml:id! 1997 uno::Reference<rdf::XMetadatable> const xMeta(xRef, 1998 uno::UNO_QUERY); 1999 OSL_ENSURE(!xMeta.is(), "paragraph that implements " 2000 "XMetadatable used in interfaceToIdentifierMapper?"); 2001 GetExport().AddAttributeIdLegacy(XML_NAMESPACE_TEXT, 2002 rIdentifier); 2003 } 2004 } 2005 2006 OUString sAutoStyle( sStyle ); 2007 sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle ); 2008 if( sAutoStyle.getLength() ) 2009 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, 2010 GetExport().EncodeStyleName( sAutoStyle ) ); 2011 2012 if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME ) ) 2013 { 2014 OUString sCondStyle; 2015 if( xMultiPropSet.is() ) 2016 rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME, 2017 xMultiPropSet ) >>= sCondStyle; 2018 else 2019 rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME, 2020 xPropSet ) >>= sCondStyle; 2021 if( sCondStyle != sStyle ) 2022 { 2023 sCondStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, 2024 sCondStyle ); 2025 if( sCondStyle.getLength() ) 2026 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 2027 XML_COND_STYLE_NAME, 2028 GetExport().EncodeStyleName( sCondStyle ) ); 2029 } 2030 } 2031 2032 //if( rPropSetHelper.hasProperty( PARA_CHAPTER_NUMERBING_LEVEL ) ) //#outline level,zhaojianwei 2033 if( rPropSetHelper.hasProperty( PARA_OUTLINE_LEVEL ) ) //<-end 2034 { 2035 if( xMultiPropSet.is() ) 2036 //rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL, //#outline level,zhaojianwei 2037 rPropSetHelper.getValue( PARA_OUTLINE_LEVEL, //<-end 2038 xMultiPropSet ) >>= nOutlineLevel; 2039 else 2040 //rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL, //#outline level,zhaojianwei 2041 rPropSetHelper.getValue( PARA_OUTLINE_LEVEL, //<-end 2042 xPropSet ) >>= nOutlineLevel; 2043 2044 //if( -1 != nOutlineLevel ) //#outline level,zhaojianwei 2045 if( 0 < nOutlineLevel ) //<-end,zhaojianwei 2046 { 2047 OUStringBuffer sTmp; 2048 //sTmp.append( sal_Int32( nOutlineLevel + 1 ) ); //#outline level,zhaojianwei 2049 sTmp.append( sal_Int32( nOutlineLevel) ); //<-end,zhaojianwei 2050 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 2051 XML_OUTLINE_LEVEL, 2052 sTmp.makeStringAndClear() ); 2053 2054 if( rPropSetHelper.hasProperty( NUMBERING_IS_NUMBER ) ) 2055 { 2056 bool bIsNumber = false; 2057 if( xMultiPropSet.is() ) 2058 rPropSetHelper.getValue( 2059 NUMBERING_IS_NUMBER, xMultiPropSet ) >>= bIsNumber; 2060 else 2061 rPropSetHelper.getValue( 2062 NUMBERING_IS_NUMBER, xPropSet ) >>= bIsNumber; 2063 2064 OUString sListStyleName; 2065 if( xMultiPropSet.is() ) 2066 rPropSetHelper.getValue( 2067 PARA_NUMBERING_STYLENAME, xMultiPropSet ) >>= sListStyleName; 2068 else 2069 rPropSetHelper.getValue( 2070 PARA_NUMBERING_STYLENAME, xPropSet ) >>= sListStyleName; 2071 2072 2073 2074 bool bAssignedtoOutlineStyle = false;//#outline level,add by zhaojianwei 2075 { 2076 Reference< XChapterNumberingSupplier > xCNSupplier( GetExport().GetModel(), UNO_QUERY ); 2077 2078 OUString sOutlineName; 2079 if (xCNSupplier.is()) 2080 { 2081 Reference< XIndexReplace > xNumRule ( xCNSupplier->getChapterNumberingRules() ); 2082 DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" ); 2083 2084 if (xNumRule.is()) 2085 { 2086 Reference< XPropertySet > xNumRulePropSet( xNumRule, UNO_QUERY ); 2087 xNumRulePropSet->getPropertyValue( 2088 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) ) >>= sOutlineName; 2089 bAssignedtoOutlineStyle = ( sListStyleName == sOutlineName ); 2090 } 2091 } 2092 2093 } //<end,zhaojianwei 2094 2095 //if( ! bIsNumber ) //#outline level,removed by zhaojianwei 2096 if( ! bIsNumber && bAssignedtoOutlineStyle ) //#outline level,add by zhaojianwei 2097 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 2098 XML_IS_LIST_HEADER, 2099 XML_TRUE ); 2100 } 2101 2102 { 2103 String sParaIsNumberingRestart 2104 (RTL_CONSTASCII_USTRINGPARAM 2105 ("ParaIsNumberingRestart")); 2106 bool bIsRestartNumbering = false; 2107 2108 Reference< XPropertySetInfo > 2109 xPropSetInfo(xMultiPropSet.is() ? 2110 xMultiPropSet->getPropertySetInfo(): 2111 xPropSet->getPropertySetInfo()); 2112 2113 if (xPropSetInfo-> 2114 hasPropertyByName(sParaIsNumberingRestart)) 2115 { 2116 xPropSet->getPropertyValue(sParaIsNumberingRestart) 2117 >>= bIsRestartNumbering; 2118 } 2119 2120 if (bIsRestartNumbering) 2121 { 2122 GetExport().AddAttribute(XML_NAMESPACE_TEXT, 2123 XML_RESTART_NUMBERING, 2124 XML_TRUE); 2125 2126 String sNumberingStartValue 2127 (RTL_CONSTASCII_USTRINGPARAM 2128 ("NumberingStartValue")); 2129 2130 2131 sal_Int32 nStartValue = 0; 2132 2133 if (xPropSetInfo-> 2134 hasPropertyByName(sNumberingStartValue)) 2135 { 2136 xPropSet->getPropertyValue(sNumberingStartValue) 2137 >>= nStartValue; 2138 2139 OUStringBuffer sTmpStartValue; 2140 2141 sTmpStartValue.append(nStartValue); 2142 2143 GetExport(). 2144 AddAttribute(XML_NAMESPACE_TEXT, 2145 XML_START_VALUE, 2146 sTmpStartValue. 2147 makeStringAndClear()); 2148 } 2149 } 2150 } 2151 } 2152 } 2153 } 2154 } 2155 2156 Reference < XEnumerationAccess > xEA( rTextContent, UNO_QUERY ); 2157 Reference < XEnumeration > xTextEnum; 2158 xTextEnum = xEA->createEnumeration(); 2159 const sal_Bool bHasPortions = xTextEnum.is(); 2160 2161 Reference < XEnumeration> xContentEnum; 2162 Reference < XContentEnumerationAccess > xCEA( rTextContent, UNO_QUERY ); 2163 if( xCEA.is() ) 2164 xContentEnum.set(xCEA->createContentEnumeration( sTextContentService )); 2165 const sal_Bool bHasContentEnum = xContentEnum.is() && 2166 xContentEnum->hasMoreElements(); 2167 2168 Reference < XTextSection > xSection; 2169 if( bHasContentEnum ) 2170 { 2171 // For the auto styles, the multi property set helper is only used 2172 // if hard attributes are existing. Therfor, it seems to be a better 2173 // strategy to have the TextSection property seperate, because otherwise 2174 // we always retrieve the style names even if they are not required. 2175 if( bAutoStyles ) 2176 { 2177 if( xPropSet->getPropertySetInfo()->hasPropertyByName( sTextSection ) ) 2178 { 2179 xSection.set(xPropSet->getPropertyValue( sTextSection ), uno::UNO_QUERY); 2180 } 2181 } 2182 else 2183 { 2184 if( rPropSetHelper.hasProperty( TEXT_SECTION ) ) 2185 { 2186 xSection.set(rPropSetHelper.getValue( TEXT_SECTION ), uno::UNO_QUERY); 2187 } 2188 } 2189 } 2190 2191 if( bAutoStyles ) 2192 { 2193 sal_Bool bPrevCharIsSpace = sal_True; 2194 if( bHasContentEnum ) 2195 bPrevCharIsSpace = !exportTextContentEnumeration( 2196 xContentEnum, bAutoStyles, xSection, 2197 bIsProgress, sal_True, 0, sal_True ); 2198 if ( bHasPortions ) 2199 exportTextRangeEnumeration( xTextEnum, bAutoStyles, bIsProgress ); 2200 } 2201 else 2202 { 2203 sal_Bool bPrevCharIsSpace = sal_True; 2204 enum XMLTokenEnum eElem = 2205 //-1 == nOutlineLevel ? XML_P : XML_H; //#outline level,zhaojianwei 2206 0 < nOutlineLevel ? XML_H : XML_P; //<-end,zhaojianwei 2207 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, eElem, 2208 sal_True, sal_False ); 2209 if( bHasContentEnum ) 2210 bPrevCharIsSpace = !exportTextContentEnumeration( 2211 xContentEnum, bAutoStyles, xSection, 2212 bIsProgress ); 2213 exportTextRangeEnumeration( xTextEnum, bAutoStyles, bIsProgress, 2214 bPrevCharIsSpace ); 2215 } 2216 } 2217 2218 void XMLTextParagraphExport::exportTextRangeEnumeration( 2219 const Reference < XEnumeration > & rTextEnum, 2220 sal_Bool bAutoStyles, 2221 sal_Bool bIsProgress, 2222 sal_Bool bPrvChrIsSpc ) 2223 { 2224 static OUString sMeta(RTL_CONSTASCII_USTRINGPARAM("InContentMetadata")); 2225 sal_Bool bPrevCharIsSpace = bPrvChrIsSpc; 2226 bool bAnnotationStarted = false; 2227 2228 while( rTextEnum->hasMoreElements() ) 2229 { 2230 Reference<XPropertySet> xPropSet(rTextEnum->nextElement(), UNO_QUERY); 2231 Reference < XTextRange > xTxtRange(xPropSet, uno::UNO_QUERY); 2232 Reference<XPropertySetInfo> xPropInfo(xPropSet->getPropertySetInfo()); 2233 2234 if (xPropInfo->hasPropertyByName(sTextPortionType)) 2235 { 2236 rtl::OUString sType; 2237 xPropSet->getPropertyValue(sTextPortionType) >>= sType; 2238 2239 if( sType.equals(sText)) 2240 { 2241 exportTextRange( xTxtRange, bAutoStyles, bPrevCharIsSpace ); 2242 } 2243 else if( sType.equals(sTextField)) 2244 { 2245 if ( bAnnotationStarted ) 2246 { 2247 bAnnotationStarted = false; 2248 } 2249 else 2250 { 2251 exportTextField( xTxtRange, bAutoStyles, bIsProgress ); 2252 bPrevCharIsSpace = false; 2253 } 2254 } 2255 else if( sType.equals( sFrame ) ) 2256 { 2257 Reference < XEnumeration> xContentEnum; 2258 Reference < XContentEnumerationAccess > xCEA( xTxtRange, UNO_QUERY ); 2259 if( xCEA.is() ) 2260 xContentEnum.set(xCEA->createContentEnumeration( sTextContentService )); 2261 // frames are never in sections 2262 Reference<XTextSection> xSection; 2263 if( xContentEnum.is() ) 2264 exportTextContentEnumeration( 2265 xContentEnum, 2266 bAutoStyles, 2267 xSection, 2268 bIsProgress, 2269 sal_True, 2270 &xPropSet ); 2271 2272 bPrevCharIsSpace = sal_False; 2273 } 2274 else if (sType.equals(sFootnote)) 2275 { 2276 exportTextFootnote( xPropSet, xTxtRange->getString(), bAutoStyles, bIsProgress ); 2277 bPrevCharIsSpace = sal_False; 2278 } 2279 else if (sType.equals(sBookmark)) 2280 { 2281 exportTextMark( xPropSet, sBookmark, lcl_XmlBookmarkElements, bAutoStyles ); 2282 } 2283 else if (sType.equals(sReferenceMark)) 2284 { 2285 exportTextMark( xPropSet, sReferenceMark, lcl_XmlReferenceElements, bAutoStyles); 2286 } 2287 else if (sType.equals(sDocumentIndexMark)) 2288 { 2289 pIndexMarkExport->ExportIndexMark( xPropSet, bAutoStyles); 2290 } 2291 else if (sType.equals(sRedline)) 2292 { 2293 if (NULL != pRedlineExport) 2294 pRedlineExport->ExportChange( xPropSet, bAutoStyles ); 2295 } 2296 else if (sType.equals(sRuby)) 2297 { 2298 exportRuby( xPropSet, bAutoStyles ); 2299 } 2300 else if (sType.equals(sMeta)) 2301 { 2302 exportMeta( xPropSet, bAutoStyles, bIsProgress ); 2303 } 2304 else if (sType.equals(sTextFieldStart)) 2305 { 2306 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); 2307 if ( xFormField.is() 2308 && xFormField->getFieldType().equalsAscii( ODF_COMMENTRANGE ) ) 2309 { 2310 exportTextField( xTxtRange, bAutoStyles, bIsProgress ); 2311 bPrevCharIsSpace = false; 2312 bAnnotationStarted = true; 2313 } 2314 else 2315 { 2316 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); 2317 if (xBookmark.is()) 2318 { 2319 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName()); 2320 } 2321 2322 if (xFormField.is()) 2323 { 2324 GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType()); 2325 } 2326 2327 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False); 2328 if (xFormField.is()) 2329 { 2330 FieldParamExporter(&GetExport(), xFormField->getParameters()).Export(); 2331 } 2332 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_START, sal_False); 2333 } 2334 } 2335 else if (sType.equals(sTextFieldEnd)) 2336 { 2337 if (bAnnotationStarted) 2338 { 2339 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); 2340 const OUString& rName = xBookmark->getName(); 2341 if ( rName.getLength() > 0 ) 2342 { 2343 GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, rName); 2344 } 2345 SvXMLElementExport aElem( GetExport(), !bAutoStyles, XML_NAMESPACE_OFFICE, XML_ANNOTATION_END, sal_False, sal_False ); 2346 } 2347 else 2348 { 2349 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_END, sal_False); 2350 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK_END, sal_False); 2351 } 2352 } 2353 else if (sType.equals(sTextFieldStartEnd)) 2354 { 2355 Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); 2356 if (xBookmark.is()) 2357 { 2358 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, xBookmark->getName()); 2359 } 2360 Reference< ::com::sun::star::text::XFormField > xFormField(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); 2361 if (xFormField.is()) 2362 { 2363 GetExport().AddAttribute(XML_NAMESPACE_FIELD, XML_TYPE, xFormField->getFieldType()); 2364 } 2365 GetExport().StartElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False); 2366 if (xFormField.is()) 2367 { 2368 FieldParamExporter(&GetExport(), xFormField->getParameters()).Export(); 2369 } 2370 GetExport().EndElement(XML_NAMESPACE_FIELD, XML_FIELDMARK, sal_False); 2371 } 2372 else if (sType.equals(sSoftPageBreak)) 2373 { 2374 exportSoftPageBreak(xPropSet, bAutoStyles); 2375 } 2376 else { 2377 DBG_ERROR("unknown text portion type"); 2378 } 2379 } 2380 else 2381 { 2382 Reference<XServiceInfo> xServiceInfo( xTxtRange, UNO_QUERY ); 2383 if( xServiceInfo->supportsService( sTextFieldService ) ) 2384 { 2385 exportTextField( xTxtRange, bAutoStyles, bIsProgress ); 2386 bPrevCharIsSpace = sal_False; 2387 } 2388 else 2389 { 2390 // no TextPortionType property -> non-Writer app -> text 2391 exportTextRange( xTxtRange, bAutoStyles, bPrevCharIsSpace ); 2392 } 2393 } 2394 } 2395 2396 // now that there are nested enumerations for meta(-field), this may be valid! 2397 // DBG_ASSERT( !bOpenRuby, "Red Alert: Ruby still open!" ); 2398 } 2399 2400 void XMLTextParagraphExport::exportTable( 2401 const Reference < XTextContent > &, 2402 sal_Bool /*bAutoStyles*/, sal_Bool /*bIsProgress*/ ) 2403 { 2404 } 2405 2406 void XMLTextParagraphExport::exportTextField( 2407 const Reference < XTextRange > & rTextRange, 2408 sal_Bool bAutoStyles, sal_Bool bIsProgress ) 2409 { 2410 Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY ); 2411 // non-Writer apps need not support Property TextField, so test first 2412 if (xPropSet->getPropertySetInfo()->hasPropertyByName( sTextField )) 2413 { 2414 Reference < XTextField > xTxtFld(xPropSet->getPropertyValue( sTextField ), uno::UNO_QUERY); 2415 DBG_ASSERT( xTxtFld.is(), "text field missing" ); 2416 if( xTxtFld.is() ) 2417 { 2418 exportTextField(xTxtFld, bAutoStyles, bIsProgress, sal_True); 2419 } 2420 else 2421 { 2422 // write only characters 2423 GetExport().Characters(rTextRange->getString()); 2424 } 2425 } 2426 } 2427 2428 void XMLTextParagraphExport::exportTextField( 2429 const Reference < XTextField > & xTextField, 2430 const sal_Bool bAutoStyles, const sal_Bool bIsProgress, 2431 const sal_Bool bRecursive ) 2432 { 2433 if ( bAutoStyles ) 2434 { 2435 pFieldExport->ExportFieldAutoStyle( xTextField, bIsProgress, 2436 bRecursive ); 2437 } 2438 else 2439 { 2440 pFieldExport->ExportField( xTextField, bIsProgress ); 2441 } 2442 } 2443 2444 void XMLTextParagraphExport::exportSoftPageBreak( 2445 const Reference<XPropertySet> & , 2446 sal_Bool ) 2447 { 2448 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, 2449 XML_SOFT_PAGE_BREAK, sal_False, 2450 sal_False ); 2451 } 2452 2453 void XMLTextParagraphExport::exportTextMark( 2454 const Reference<XPropertySet> & rPropSet, 2455 const OUString sProperty, 2456 const enum XMLTokenEnum pElements[], 2457 sal_Bool bAutoStyles) 2458 { 2459 // mib said: "Hau wech!" 2460 // 2461 // (Originally, I'd export a span element in case the (book|reference)mark 2462 // was formatted. This actually makes a difference in case some pervert 2463 // sets a point reference mark in the document and, say, formats it bold. 2464 // This basically meaningless formatting will now been thrown away 2465 // (aka cleaned up), since mib said: ... dvo 2466 2467 if (!bAutoStyles) 2468 { 2469 // name element 2470 Reference<XNamed> xName(rPropSet->getPropertyValue(sProperty), UNO_QUERY); 2471 GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, 2472 xName->getName()); 2473 2474 // start, end, or point-reference? 2475 sal_Int8 nElement; 2476 if( *(sal_Bool *)rPropSet->getPropertyValue(sIsCollapsed).getValue() ) 2477 { 2478 nElement = 0; 2479 } 2480 else 2481 { 2482 nElement = *(sal_Bool *)rPropSet->getPropertyValue(sIsStart).getValue() ? 1 : 2; 2483 } 2484 2485 // bookmark, bookmark-start: xml:id and RDFa for RDF metadata 2486 if( nElement < 2 ) { 2487 GetExport().AddAttributeXmlId(xName); 2488 const uno::Reference<text::XTextContent> xTextContent( 2489 xName, uno::UNO_QUERY_THROW); 2490 GetExport().AddAttributesRDFa(xTextContent); 2491 } 2492 2493 // export element 2494 DBG_ASSERT(pElements != NULL, "illegal element array"); 2495 DBG_ASSERT(nElement >= 0, "illegal element number"); 2496 DBG_ASSERT(nElement <= 2, "illegal element number"); 2497 SvXMLElementExport aElem(GetExport(), 2498 XML_NAMESPACE_TEXT, pElements[nElement], 2499 sal_False, sal_False); 2500 } 2501 // else: no styles. (see above) 2502 } 2503 2504 sal_Bool lcl_txtpara_isBoundAsChar( 2505 const Reference < XPropertySet > & rPropSet, 2506 const Reference < XPropertySetInfo > & rPropSetInfo ) 2507 { 2508 sal_Bool bIsBoundAsChar = sal_False; 2509 OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) ); 2510 if( rPropSetInfo->hasPropertyByName( sAnchorType ) ) 2511 { 2512 TextContentAnchorType eAnchor; 2513 rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor; 2514 bIsBoundAsChar = TextContentAnchorType_AS_CHARACTER == eAnchor; 2515 } 2516 2517 return bIsBoundAsChar; 2518 } 2519 2520 sal_Int32 XMLTextParagraphExport::addTextFrameAttributes( 2521 const Reference < XPropertySet >& rPropSet, 2522 sal_Bool bShape, 2523 OUString *pMinHeightValue ) 2524 { 2525 sal_Int32 nShapeFeatures = SEF_DEFAULT; 2526 2527 // draw:name (#97662#: not for shapes, since those names will be 2528 // treated in the shape export) 2529 if( !bShape ) 2530 { 2531 Reference < XNamed > xNamed( rPropSet, UNO_QUERY ); 2532 if( xNamed.is() ) 2533 { 2534 OUString sName( xNamed->getName() ); 2535 if( sName.getLength() ) 2536 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, 2537 xNamed->getName() ); 2538 } 2539 } 2540 2541 OUStringBuffer sValue; 2542 2543 // text:anchor-type 2544 TextContentAnchorType eAnchor = TextContentAnchorType_AT_PARAGRAPH; 2545 rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor; 2546 { 2547 XMLAnchorTypePropHdl aAnchorTypeHdl; 2548 OUString sTmp; 2549 aAnchorTypeHdl.exportXML( sTmp, uno::makeAny(eAnchor), 2550 GetExport().GetMM100UnitConverter() ); 2551 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_TYPE, sTmp ); 2552 } 2553 2554 // text:anchor-page-number 2555 if( TextContentAnchorType_AT_PAGE == eAnchor ) 2556 { 2557 sal_Int16 nPage = 0; 2558 rPropSet->getPropertyValue( sAnchorPageNo ) >>= nPage; 2559 GetExport().GetMM100UnitConverter().convertNumber( sValue, 2560 (sal_Int32)nPage ); 2561 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ANCHOR_PAGE_NUMBER, 2562 sValue.makeStringAndClear() ); 2563 } 2564 else 2565 { 2566 // #92210# 2567 nShapeFeatures |= SEF_EXPORT_NO_WS; 2568 } 2569 2570 // OD 2004-06-01 #i27691# - correction: no export of svg:x, if object 2571 // is anchored as-character. 2572 if ( !bShape && 2573 eAnchor != TextContentAnchorType_AS_CHARACTER ) 2574 { 2575 // svg:x 2576 sal_Int16 nHoriOrient = HoriOrientation::NONE; 2577 rPropSet->getPropertyValue( sHoriOrient ) >>= nHoriOrient; 2578 if( HoriOrientation::NONE == nHoriOrient ) 2579 { 2580 sal_Int32 nPos = 0; 2581 rPropSet->getPropertyValue( sHoriOrientPosition ) >>= nPos; 2582 GetExport().GetMM100UnitConverter().convertMeasure( sValue, nPos ); 2583 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_X, 2584 sValue.makeStringAndClear() ); 2585 } 2586 } 2587 else if( TextContentAnchorType_AS_CHARACTER == eAnchor ) 2588 nShapeFeatures = (nShapeFeatures & ~SEF_EXPORT_X); 2589 2590 if( !bShape || TextContentAnchorType_AS_CHARACTER == eAnchor ) 2591 { 2592 // svg:y 2593 sal_Int16 nVertOrient = VertOrientation::NONE; 2594 rPropSet->getPropertyValue( sVertOrient ) >>= nVertOrient; 2595 if( VertOrientation::NONE == nVertOrient ) 2596 { 2597 sal_Int32 nPos = 0; 2598 rPropSet->getPropertyValue( sVertOrientPosition ) >>= nPos; 2599 GetExport().GetMM100UnitConverter().convertMeasure( sValue, nPos ); 2600 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_Y, 2601 sValue.makeStringAndClear() ); 2602 } 2603 if( bShape ) 2604 nShapeFeatures = (nShapeFeatures & ~SEF_EXPORT_Y); 2605 } 2606 2607 2608 Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo()); 2609 2610 // svg:width 2611 sal_Int16 nWidthType = SizeType::FIX; 2612 if( xPropSetInfo->hasPropertyByName( sWidthType ) ) 2613 { 2614 rPropSet->getPropertyValue( sWidthType ) >>= nWidthType; 2615 } 2616 if( xPropSetInfo->hasPropertyByName( sWidth ) ) 2617 { 2618 sal_Int32 nWidth = 0; 2619 // VAR size will be written as zero min-size 2620 if( SizeType::VARIABLE != nWidthType ) 2621 { 2622 rPropSet->getPropertyValue( sWidth ) >>= nWidth; 2623 } 2624 GetExport().GetMM100UnitConverter().convertMeasure( sValue, nWidth ); 2625 if( SizeType::FIX != nWidthType ) 2626 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_WIDTH, 2627 sValue.makeStringAndClear() ); 2628 else 2629 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, 2630 sValue.makeStringAndClear() ); 2631 } 2632 sal_Bool bSyncWidth = sal_False; 2633 if( xPropSetInfo->hasPropertyByName( sIsSyncWidthToHeight ) ) 2634 { 2635 bSyncWidth = *(sal_Bool *)rPropSet->getPropertyValue( sIsSyncWidthToHeight ).getValue(); 2636 if( bSyncWidth ) 2637 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH, 2638 XML_SCALE ); 2639 } 2640 if( !bSyncWidth && xPropSetInfo->hasPropertyByName( sRelativeWidth ) ) 2641 { 2642 sal_Int16 nRelWidth = 0; 2643 rPropSet->getPropertyValue( sRelativeWidth ) >>= nRelWidth; 2644 DBG_ASSERT( nRelWidth >= 0 && nRelWidth <= 254, 2645 "Got illegal relative width from API" ); 2646 if( nRelWidth > 0 ) 2647 { 2648 GetExport().GetMM100UnitConverter().convertPercent( sValue, 2649 nRelWidth ); 2650 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH, 2651 sValue.makeStringAndClear() ); 2652 } 2653 } 2654 2655 // svg:height, fo:min-height or style:rel-height 2656 sal_Int16 nSizeType = SizeType::FIX; 2657 if( xPropSetInfo->hasPropertyByName( sSizeType ) ) 2658 { 2659 rPropSet->getPropertyValue( sSizeType ) >>= nSizeType; 2660 } 2661 sal_Bool bSyncHeight = sal_False; 2662 if( xPropSetInfo->hasPropertyByName( sIsSyncHeightToWidth ) ) 2663 { 2664 bSyncHeight = *(sal_Bool *)rPropSet->getPropertyValue( sIsSyncHeightToWidth ).getValue(); 2665 } 2666 sal_Int16 nRelHeight = 0; 2667 if( !bSyncHeight && xPropSetInfo->hasPropertyByName( sRelativeHeight ) ) 2668 { 2669 rPropSet->getPropertyValue( sRelativeHeight ) >>= nRelHeight; 2670 } 2671 if( xPropSetInfo->hasPropertyByName( sHeight ) ) 2672 { 2673 sal_Int32 nHeight = 0; 2674 if( SizeType::VARIABLE != nSizeType ) 2675 { 2676 rPropSet->getPropertyValue( sHeight ) >>= nHeight; 2677 } 2678 GetExport().GetMM100UnitConverter().convertMeasure( sValue, 2679 nHeight ); 2680 if( SizeType::FIX != nSizeType && 0==nRelHeight && !bSyncHeight && 2681 pMinHeightValue ) 2682 *pMinHeightValue = sValue.makeStringAndClear(); 2683 else 2684 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, 2685 sValue.makeStringAndClear() ); 2686 } 2687 if( bSyncHeight ) 2688 { 2689 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_HEIGHT, 2690 SizeType::MIN == nSizeType ? XML_SCALE_MIN : XML_SCALE ); 2691 2692 } 2693 else if( nRelHeight > 0 ) 2694 { 2695 GetExport().GetMM100UnitConverter().convertPercent( sValue, 2696 nRelHeight ); 2697 if( SizeType::MIN == nSizeType ) 2698 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_HEIGHT, 2699 sValue.makeStringAndClear() ); 2700 else 2701 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_HEIGHT, 2702 sValue.makeStringAndClear() ); 2703 } 2704 2705 OUString sZOrder( RTL_CONSTASCII_USTRINGPARAM( "ZOrder" ) ); 2706 if( xPropSetInfo->hasPropertyByName( sZOrder ) ) 2707 { 2708 sal_Int32 nZIndex = 0; 2709 rPropSet->getPropertyValue( sZOrder ) >>= nZIndex; 2710 if( -1 != nZIndex ) 2711 { 2712 GetExport().GetMM100UnitConverter().convertNumber( sValue, 2713 nZIndex ); 2714 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_ZINDEX, 2715 sValue.makeStringAndClear() ); 2716 } 2717 } 2718 2719 return nShapeFeatures; 2720 } 2721 2722 void XMLTextParagraphExport::exportAnyTextFrame( 2723 const Reference < XTextContent > & rTxtCntnt, 2724 FrameType eType, 2725 sal_Bool bAutoStyles, 2726 sal_Bool bIsProgress, 2727 sal_Bool bExportContent, 2728 const Reference < XPropertySet > *pRangePropSet) 2729 { 2730 Reference < XPropertySet > xPropSet( rTxtCntnt, UNO_QUERY ); 2731 2732 if( bAutoStyles ) 2733 { 2734 if( FT_EMBEDDED == eType ) 2735 _collectTextEmbeddedAutoStyles( xPropSet ); 2736 // --> OD 2004-08-09 #i28745# - no text frame style for shapes 2737 else if ( FT_SHAPE != eType ) 2738 Add( XML_STYLE_FAMILY_TEXT_FRAME, xPropSet ); 2739 // <-- 2740 2741 if( pRangePropSet && lcl_txtpara_isBoundAsChar( xPropSet, 2742 xPropSet->getPropertySetInfo() ) ) 2743 Add( XML_STYLE_FAMILY_TEXT_TEXT, *pRangePropSet ); 2744 2745 switch( eType ) 2746 { 2747 case FT_TEXT: 2748 { 2749 // frame bound frames 2750 if ( bExportContent ) 2751 { 2752 Reference < XTextFrame > xTxtFrame( rTxtCntnt, UNO_QUERY ); 2753 Reference < XText > xTxt(xTxtFrame->getText()); 2754 exportFrameFrames( sal_True, bIsProgress, &xTxtFrame ); 2755 exportText( xTxt, bAutoStyles, bIsProgress, sal_True ); 2756 } 2757 } 2758 break; 2759 case FT_SHAPE: 2760 { 2761 Reference < XShape > xShape( rTxtCntnt, UNO_QUERY ); 2762 GetExport().GetShapeExport()->collectShapeAutoStyles( xShape ); 2763 } 2764 break; 2765 default: 2766 break; 2767 } 2768 } 2769 else 2770 { 2771 Reference< XPropertySetInfo > xPropSetInfo(xPropSet->getPropertySetInfo()); 2772 Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY ); 2773 { 2774 sal_Bool bAddCharStyles = pRangePropSet && 2775 lcl_txtpara_isBoundAsChar( xPropSet, xPropSetInfo ); 2776 2777 sal_Bool bIsUICharStyle; 2778 sal_Bool bHasAutoStyle = sal_False; 2779 sal_Bool bDummy; 2780 2781 OUString sStyle; 2782 2783 if( bAddCharStyles ) 2784 sStyle = FindTextStyleAndHyperlink( *pRangePropSet, bDummy, bIsUICharStyle, bHasAutoStyle ); 2785 else 2786 bIsUICharStyle = sal_False; 2787 2788 XMLTextCharStyleNamesElementExport aCharStylesExport( 2789 GetExport(), bIsUICharStyle && 2790 aCharStyleNamesPropInfoCache.hasProperty( 2791 *pRangePropSet ), bHasAutoStyle, 2792 *pRangePropSet, sCharStyleNames ); 2793 2794 if( sStyle.getLength() ) 2795 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, 2796 GetExport().EncodeStyleName( sStyle ) ); 2797 { 2798 SvXMLElementExport aElem( GetExport(), sStyle.getLength() > 0, 2799 XML_NAMESPACE_TEXT, XML_SPAN, sal_False, sal_False ); 2800 { 2801 SvXMLElementExport aElement( GetExport(), 2802 FT_SHAPE != eType && 2803 addHyperlinkAttributes( xPropSet, 2804 xPropState,xPropSetInfo ), 2805 XML_NAMESPACE_DRAW, XML_A, sal_False, sal_False ); 2806 switch( eType ) 2807 { 2808 case FT_TEXT: 2809 _exportTextFrame( xPropSet, xPropSetInfo, bIsProgress ); 2810 break; 2811 case FT_GRAPHIC: 2812 _exportTextGraphic( xPropSet, xPropSetInfo ); 2813 break; 2814 case FT_EMBEDDED: 2815 _exportTextEmbedded( xPropSet, xPropSetInfo ); 2816 break; 2817 case FT_SHAPE: 2818 { 2819 Reference < XShape > xShape( rTxtCntnt, UNO_QUERY ); 2820 sal_Int32 nFeatures = 2821 addTextFrameAttributes( xPropSet, sal_True ); 2822 GetExport().GetShapeExport() 2823 ->exportShape( xShape, nFeatures ); 2824 } 2825 break; 2826 } 2827 } 2828 } 2829 } 2830 } 2831 } 2832 2833 void XMLTextParagraphExport::_exportTextFrame( 2834 const Reference < XPropertySet > & rPropSet, 2835 const Reference < XPropertySetInfo > & rPropSetInfo, 2836 sal_Bool bIsProgress ) 2837 { 2838 Reference < XTextFrame > xTxtFrame( rPropSet, UNO_QUERY ); 2839 Reference < XText > xTxt(xTxtFrame->getText()); 2840 2841 OUString sStyle; 2842 if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) ) 2843 { 2844 rPropSet->getPropertyValue( sFrameStyleName ) >>= sStyle; 2845 } 2846 2847 OUString sAutoStyle( sStyle ); 2848 OUString aMinHeightValue; 2849 sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle ); 2850 if( sAutoStyle.getLength() ) 2851 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME, 2852 GetExport().EncodeStyleName( sAutoStyle ) ); 2853 addTextFrameAttributes( rPropSet, sal_False, &aMinHeightValue ); 2854 2855 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, 2856 XML_FRAME, sal_False, sal_True ); 2857 2858 if( aMinHeightValue.getLength() ) 2859 GetExport().AddAttribute( XML_NAMESPACE_FO, XML_MIN_HEIGHT, 2860 aMinHeightValue ); 2861 2862 // draw:chain-next-name 2863 if( rPropSetInfo->hasPropertyByName( sChainNextName ) ) 2864 { 2865 OUString sNext; 2866 if( (rPropSet->getPropertyValue( sChainNextName ) >>= sNext) && sNext.getLength() > 0 ) 2867 GetExport().AddAttribute( XML_NAMESPACE_DRAW, 2868 XML_CHAIN_NEXT_NAME, 2869 sNext ); 2870 } 2871 2872 { 2873 SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_DRAW, 2874 XML_TEXT_BOX, sal_True, sal_True ); 2875 2876 // frame bound frames 2877 exportFramesBoundToFrame( xTxtFrame, bIsProgress ); 2878 2879 exportText( xTxt, sal_False, bIsProgress, sal_True ); 2880 } 2881 2882 // script:events 2883 Reference<XEventsSupplier> xEventsSupp( xTxtFrame, UNO_QUERY ); 2884 GetExport().GetEventExport().Export(xEventsSupp); 2885 2886 // image map 2887 GetExport().GetImageMapExport().Export( rPropSet ); 2888 2889 // --> OD 2009-07-22 #i73249# 2890 // svg:title and svg:desc 2891 exportTitleAndDescription( rPropSet, rPropSetInfo ); 2892 // <-- 2893 } 2894 2895 void XMLTextParagraphExport::exportContour( 2896 const Reference < XPropertySet > & rPropSet, 2897 const Reference < XPropertySetInfo > & rPropSetInfo ) 2898 { 2899 if( !rPropSetInfo->hasPropertyByName( sContourPolyPolygon ) ) 2900 { 2901 return; 2902 } 2903 2904 PointSequenceSequence aSourcePolyPolygon; 2905 rPropSet->getPropertyValue( sContourPolyPolygon ) >>= aSourcePolyPolygon; 2906 const basegfx::B2DPolyPolygon aPolyPolygon( 2907 basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon( 2908 aSourcePolyPolygon)); 2909 const sal_uInt32 nPolygonCount(aPolyPolygon.count()); 2910 2911 if(!nPolygonCount) 2912 { 2913 return; 2914 } 2915 2916 const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange()); 2917 bool bPixel(false); 2918 2919 if( rPropSetInfo->hasPropertyByName( sIsPixelContour ) ) 2920 { 2921 bPixel = *(sal_Bool *)rPropSet->getPropertyValue( sIsPixelContour ).getValue(); 2922 } 2923 2924 // svg: width 2925 OUStringBuffer aStringBuffer( 10 ); 2926 2927 if(bPixel) 2928 { 2929 GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer, basegfx::fround(aPolyPolygonRange.getWidth())); 2930 } 2931 else 2932 { 2933 GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer, basegfx::fround(aPolyPolygonRange.getWidth())); 2934 } 2935 2936 GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStringBuffer.makeStringAndClear()); 2937 2938 // svg: height 2939 if(bPixel) 2940 { 2941 GetExport().GetMM100UnitConverter().convertMeasurePx(aStringBuffer, basegfx::fround(aPolyPolygonRange.getHeight())); 2942 } 2943 else 2944 { 2945 GetExport().GetMM100UnitConverter().convertMeasure(aStringBuffer, basegfx::fround(aPolyPolygonRange.getHeight())); 2946 } 2947 2948 GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStringBuffer.makeStringAndClear()); 2949 2950 // svg:viewbox 2951 SdXMLImExViewBox aViewBox(0.0, 0.0, aPolyPolygonRange.getWidth(), aPolyPolygonRange.getHeight()); 2952 GetExport().AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString()); 2953 enum XMLTokenEnum eElem = XML_TOKEN_INVALID; 2954 2955 if(1 == nPolygonCount ) 2956 { 2957 // simple polygon shape, can be written as svg:points sequence 2958 const ::rtl::OUString aPointString( 2959 basegfx::tools::exportToSvgPoints( 2960 aPolyPolygon.getB2DPolygon(0))); 2961 2962 // write point array 2963 GetExport().AddAttribute(XML_NAMESPACE_DRAW, XML_POINTS, aPointString); 2964 eElem = XML_CONTOUR_POLYGON; 2965 } 2966 else 2967 { 2968 // polypolygon, needs to be written as a svg:path sequence 2969 const ::rtl::OUString aPolygonString( 2970 basegfx::tools::exportToSvgD( 2971 aPolyPolygon, 2972 true, // bUseRelativeCoordinates 2973 false, // bDetectQuadraticBeziers: not used in old, but maybe activated now 2974 true)); // bHandleRelativeNextPointCompatible 2975 2976 // write point array 2977 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_D, aPolygonString); 2978 eElem = XML_CONTOUR_PATH; 2979 } 2980 2981 if( rPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) 2982 { 2983 sal_Bool bTmp = *(sal_Bool *)rPropSet->getPropertyValue( 2984 sIsAutomaticContour ).getValue(); 2985 GetExport().AddAttribute( XML_NAMESPACE_DRAW, 2986 XML_RECREATE_ON_EDIT, bTmp ? XML_TRUE : XML_FALSE ); 2987 } 2988 2989 // write object now 2990 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW, eElem, 2991 sal_True, sal_True ); 2992 } 2993 2994 void XMLTextParagraphExport::_exportTextGraphic( 2995 const Reference < XPropertySet > & rPropSet, 2996 const Reference < XPropertySetInfo > & rPropSetInfo ) 2997 { 2998 OUString sStyle; 2999 if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) ) 3000 { 3001 rPropSet->getPropertyValue( sFrameStyleName ) >>= sStyle; 3002 } 3003 3004 OUString sAutoStyle( sStyle ); 3005 sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle ); 3006 if( sAutoStyle.getLength() ) 3007 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME, 3008 GetExport().EncodeStyleName( sAutoStyle ) ); 3009 addTextFrameAttributes( rPropSet, sal_False ); 3010 3011 // svg:transform 3012 sal_Int16 nVal = 0; 3013 rPropSet->getPropertyValue( sGraphicRotation ) >>= nVal; 3014 if( nVal != 0 ) 3015 { 3016 OUStringBuffer sRet( GetXMLToken(XML_ROTATE).getLength()+4 ); 3017 sRet.append( GetXMLToken(XML_ROTATE)); 3018 sRet.append( (sal_Unicode)'(' ); 3019 GetExport().GetMM100UnitConverter().convertNumber( sRet, (sal_Int32)nVal ); 3020 sRet.append( (sal_Unicode)')' ); 3021 GetExport().AddAttribute( XML_NAMESPACE_SVG, XML_TRANSFORM, 3022 sRet.makeStringAndClear() ); 3023 } 3024 3025 // original content 3026 SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_DRAW, XML_FRAME, sal_False, sal_True); 3027 3028 // replacement graphic for backwards compatibility, but 3029 // only for SVG currently 3030 OUString sReplacementOrigURL; 3031 rPropSet->getPropertyValue( sReplacementGraphicURL ) >>= sReplacementOrigURL; 3032 3033 if(sReplacementOrigURL.getLength()) 3034 { 3035 const OUString sReplacementURL(GetExport().AddEmbeddedGraphicObject( sReplacementOrigURL )); 3036 3037 // If there is no url, then then graphic is empty 3038 if(sReplacementURL.getLength()) 3039 { 3040 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sReplacementURL); 3041 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE); 3042 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED); 3043 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD); 3044 3045 // xlink:href for replacement, only written for Svg content 3046 SvXMLElementExport aElement(GetExport(), XML_NAMESPACE_DRAW, XML_IMAGE, sal_False, sal_True); 3047 3048 // optional office:binary-data 3049 GetExport().AddEmbeddedGraphicObjectAsBase64(sReplacementURL); 3050 } 3051 } 3052 3053 // xlink:href 3054 OUString sOrigURL; 3055 rPropSet->getPropertyValue( sGraphicURL ) >>= sOrigURL; 3056 OUString sURL(GetExport().AddEmbeddedGraphicObject( sOrigURL )); 3057 setTextEmbeddedGraphicURL( rPropSet, sURL ); 3058 3059 // If there still is no url, then then graphic is empty 3060 if( sURL.getLength() ) 3061 { 3062 GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sURL ); 3063 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); 3064 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED ); 3065 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, 3066 XML_ONLOAD ); 3067 } 3068 3069 // draw:filter-name 3070 OUString sGrfFilter; 3071 rPropSet->getPropertyValue( sGraphicFilter ) >>= sGrfFilter; 3072 if( sGrfFilter.getLength() ) 3073 GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_FILTER_NAME, 3074 sGrfFilter ); 3075 3076 { 3077 SvXMLElementExport aElement( GetExport(), XML_NAMESPACE_DRAW, 3078 XML_IMAGE, sal_False, sal_True ); 3079 3080 // optional office:binary-data 3081 GetExport().AddEmbeddedGraphicObjectAsBase64( sOrigURL ); 3082 } 3083 3084 // script:events 3085 Reference<XEventsSupplier> xEventsSupp( rPropSet, UNO_QUERY ); 3086 GetExport().GetEventExport().Export(xEventsSupp); 3087 3088 // image map 3089 GetExport().GetImageMapExport().Export( rPropSet ); 3090 3091 // --> OD 2009-07-22 #i73249# 3092 // svg:title and svg:desc 3093 exportTitleAndDescription( rPropSet, rPropSetInfo ); 3094 // <-- 3095 3096 // draw:contour 3097 exportContour( rPropSet, rPropSetInfo ); 3098 } 3099 3100 void XMLTextParagraphExport::_collectTextEmbeddedAutoStyles(const Reference < XPropertySet > & ) 3101 { 3102 DBG_ASSERT( !this, "no API implementation avialable" ); 3103 } 3104 3105 void XMLTextParagraphExport::_exportTextEmbedded( 3106 const Reference < XPropertySet > &, 3107 const Reference < XPropertySetInfo > & ) 3108 { 3109 DBG_ASSERT( !this, "no API implementation avialable" ); 3110 } 3111 3112 void XMLTextParagraphExport::exportEvents( const Reference < XPropertySet > & rPropSet ) 3113 { 3114 // script:events 3115 Reference<XEventsSupplier> xEventsSupp( rPropSet, UNO_QUERY ); 3116 GetExport().GetEventExport().Export(xEventsSupp); 3117 3118 // image map 3119 OUString sImageMap(RTL_CONSTASCII_USTRINGPARAM("ImageMap")); 3120 if (rPropSet->getPropertySetInfo()->hasPropertyByName(sImageMap)) 3121 GetExport().GetImageMapExport().Export( rPropSet ); 3122 } 3123 3124 // --> OD 2009-07-22 #i73249# 3125 void XMLTextParagraphExport::exportTitleAndDescription( 3126 const Reference < XPropertySet > & rPropSet, 3127 const Reference < XPropertySetInfo > & rPropSetInfo ) 3128 { 3129 // svg:title 3130 if( rPropSetInfo->hasPropertyByName( sTitle ) ) 3131 { 3132 OUString sObjTitle; 3133 rPropSet->getPropertyValue( sTitle ) >>= sObjTitle; 3134 if( sObjTitle.getLength() ) 3135 { 3136 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG, 3137 XML_TITLE, sal_True, sal_False ); 3138 GetExport().Characters( sObjTitle ); 3139 } 3140 } 3141 3142 // svg:description 3143 if( rPropSetInfo->hasPropertyByName( sDescription ) ) 3144 { 3145 OUString sObjDesc; 3146 rPropSet->getPropertyValue( sDescription ) >>= sObjDesc; 3147 if( sObjDesc.getLength() ) 3148 { 3149 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG, 3150 XML_DESC, sal_True, sal_False ); 3151 GetExport().Characters( sObjDesc ); 3152 } 3153 } 3154 } 3155 // <-- 3156 3157 void XMLTextParagraphExport::setTextEmbeddedGraphicURL( 3158 const Reference < XPropertySet >&, 3159 OUString& /*rStreamName*/ ) const 3160 { 3161 } 3162 3163 sal_Bool XMLTextParagraphExport::addHyperlinkAttributes( 3164 const Reference < XPropertySet > & rPropSet, 3165 const Reference < XPropertyState > & rPropState, 3166 const Reference < XPropertySetInfo > & rPropSetInfo ) 3167 { 3168 sal_Bool bExport = sal_False; 3169 OUString sHRef, sName, sTargetFrame, sUStyleName, sVStyleName; 3170 sal_Bool bServerMap = sal_False; 3171 3172 /* bool bHyperLinkURL = false; 3173 bool bHyperLinkName = false; 3174 bool bHyperLinkTarget = false; 3175 bool bServer = false; 3176 bool bUnvisitedCharStyleName = false; 3177 bool bVisitedCharStyleName = false; 3178 3179 const Reference< XMultiPropertySet > xMultiPropertySet( rPropSet, UNO_QUERY ); 3180 if ( xMultiPropertySet.is() ) 3181 { 3182 sal_uInt32 nCount = 0; 3183 Sequence< OUString > aPropertyNames( 6 ); 3184 OUString* pArray = aPropertyNames.getArray(); 3185 3186 if ( rPropSetInfo->hasPropertyByName( sServerMap ) ) 3187 { 3188 bServer = true; 3189 pArray[ nCount++ ] = sServerMap; 3190 } 3191 if ( rPropSetInfo->hasPropertyByName( sHyperLinkName ) ) 3192 { 3193 bHyperLinkName = true; 3194 pArray[ nCount++ ] = sHyperLinkName; 3195 } 3196 if ( rPropSetInfo->hasPropertyByName( sHyperLinkTarget ) ) 3197 { 3198 bHyperLinkTarget = true; 3199 pArray[ nCount++ ] = sHyperLinkTarget; 3200 } 3201 if ( rPropSetInfo->hasPropertyByName( sHyperLinkURL ) ) 3202 { 3203 bHyperLinkURL = true; 3204 pArray[ nCount++ ] = sHyperLinkURL; 3205 } 3206 if ( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) ) 3207 { 3208 bUnvisitedCharStyleName = true; 3209 pArray[ nCount++ ] = sUnvisitedCharStyleName; 3210 } 3211 if ( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) ) 3212 { 3213 bVisitedCharStyleName = true; 3214 pArray[ nCount++ ] = sVisitedCharStyleName; 3215 } 3216 3217 aPropertyNames.realloc( nCount ); 3218 3219 if ( nCount ) 3220 { 3221 Sequence< PropertyState > aPropertyStates( nCount ); 3222 PropertyState* pStateArray = aPropertyStates.getArray(); 3223 3224 if ( rPropState.is() ) 3225 aPropertyStates = rPropState->getPropertyStates( aPropertyNames ); 3226 3227 Sequence< Any > aPropertyValues ( xMultiPropertySet->getPropertyValues( aPropertyNames ) ); 3228 Any* pValueArray = aPropertyValues.getArray(); 3229 3230 sal_uInt32 nIdx = 0; 3231 3232 if ( bServer ) 3233 { 3234 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] ) 3235 { 3236 bServerMap = *(sal_Bool *)pValueArray[ nIdx ].getValue(); 3237 if( bServerMap ) 3238 bExport = sal_True; 3239 } 3240 ++nIdx; 3241 } 3242 if ( bHyperLinkName ) 3243 { 3244 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] ) 3245 { 3246 pValueArray[ nIdx ] >>= sName; 3247 if( sName.getLength() > 0 ) 3248 bExport = sal_True; 3249 } 3250 ++nIdx; 3251 } 3252 if ( bHyperLinkTarget ) 3253 { 3254 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] ) 3255 { 3256 pValueArray[ nIdx ] >>= sTargetFrame; 3257 if( sTargetFrame.getLength() ) 3258 bExport = sal_True; 3259 } 3260 ++nIdx; 3261 } 3262 if ( bHyperLinkURL ) 3263 { 3264 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] ) 3265 { 3266 pValueArray[ nIdx ] >>= sHRef; 3267 if( sHRef.getLength() > 0 ) 3268 bExport = sal_True; 3269 } 3270 ++nIdx; 3271 } 3272 if ( bUnvisitedCharStyleName ) 3273 { 3274 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] ) 3275 { 3276 pValueArray[ nIdx ] >>= sUStyleName; 3277 if( sUStyleName.getLength() ) 3278 bExport = sal_True; 3279 } 3280 ++nIdx; 3281 } 3282 if ( bVisitedCharStyleName ) 3283 { 3284 if ( !rPropState.is() || PropertyState_DIRECT_VALUE == pStateArray[ nIdx ] ) 3285 { 3286 pValueArray[ nIdx ] >>= sVStyleName; 3287 if( sVStyleName.getLength() ) 3288 bExport = sal_True; 3289 } 3290 ++nIdx; 3291 } 3292 } 3293 } 3294 else 3295 {*/ 3296 if( rPropSetInfo->hasPropertyByName( sHyperLinkURL ) && 3297 ( !rPropState.is() || PropertyState_DIRECT_VALUE == 3298 rPropState->getPropertyState( sHyperLinkURL ) ) ) 3299 { 3300 rPropSet->getPropertyValue( sHyperLinkURL ) >>= sHRef; 3301 3302 if( sHRef.getLength() > 0 ) 3303 bExport = sal_True; 3304 } 3305 3306 if( rPropSetInfo->hasPropertyByName( sHyperLinkName ) && 3307 ( !rPropState.is() || PropertyState_DIRECT_VALUE == 3308 rPropState->getPropertyState( sHyperLinkName ) ) ) 3309 { 3310 rPropSet->getPropertyValue( sHyperLinkName ) >>= sName; 3311 if( sName.getLength() > 0 ) 3312 bExport = sal_True; 3313 } 3314 3315 if( rPropSetInfo->hasPropertyByName( sHyperLinkTarget ) && 3316 ( !rPropState.is() || PropertyState_DIRECT_VALUE == 3317 rPropState->getPropertyState( sHyperLinkTarget ) ) ) 3318 { 3319 rPropSet->getPropertyValue( sHyperLinkTarget ) >>= sTargetFrame; 3320 if( sTargetFrame.getLength() ) 3321 bExport = sal_True; 3322 } 3323 3324 if( rPropSetInfo->hasPropertyByName( sServerMap ) && 3325 ( !rPropState.is() || PropertyState_DIRECT_VALUE == 3326 rPropState->getPropertyState( sServerMap ) ) ) 3327 { 3328 bServerMap = *(sal_Bool *)rPropSet->getPropertyValue( sServerMap ).getValue(); 3329 if( bServerMap ) 3330 bExport = sal_True; 3331 } 3332 3333 if( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) && 3334 ( !rPropState.is() || PropertyState_DIRECT_VALUE == 3335 rPropState->getPropertyState( sUnvisitedCharStyleName ) ) ) 3336 { 3337 rPropSet->getPropertyValue( sUnvisitedCharStyleName ) >>= sUStyleName; 3338 if( sUStyleName.getLength() ) 3339 bExport = sal_True; 3340 } 3341 3342 if( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) && 3343 ( !rPropState.is() || PropertyState_DIRECT_VALUE == 3344 rPropState->getPropertyState( sVisitedCharStyleName ) ) ) 3345 { 3346 rPropSet->getPropertyValue( sVisitedCharStyleName ) >>= sVStyleName; 3347 if( sVStyleName.getLength() ) 3348 bExport = sal_True; 3349 } 3350 3351 if( bExport ) 3352 { 3353 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); 3354 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( sHRef ) ); 3355 3356 if( sName.getLength() > 0 ) 3357 GetExport().AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME, sName ); 3358 3359 if( sTargetFrame.getLength() ) 3360 { 3361 GetExport().AddAttribute( XML_NAMESPACE_OFFICE, 3362 XML_TARGET_FRAME_NAME, sTargetFrame ); 3363 enum XMLTokenEnum eTok = 3364 sTargetFrame.equalsAsciiL( "_blank", sizeof("_blank")-1 ) 3365 ? XML_NEW : XML_REPLACE; 3366 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, eTok ); 3367 } 3368 3369 if( bServerMap ) 3370 GetExport().AddAttribute( XML_NAMESPACE_OFFICE, 3371 XML_SERVER_MAP, XML_TRUE ); 3372 3373 if( sUStyleName.getLength() ) 3374 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 3375 XML_STYLE_NAME, GetExport().EncodeStyleName( sUStyleName ) ); 3376 3377 if( sVStyleName.getLength() ) 3378 GetExport().AddAttribute( XML_NAMESPACE_TEXT, 3379 XML_VISITED_STYLE_NAME, GetExport().EncodeStyleName( sVStyleName ) ); 3380 } 3381 3382 return bExport; 3383 } 3384 3385 void XMLTextParagraphExport::exportTextRange( 3386 const Reference < XTextRange > & rTextRange, 3387 sal_Bool bAutoStyles, 3388 sal_Bool& rPrevCharIsSpace ) 3389 { 3390 Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY ); 3391 if( bAutoStyles ) 3392 { 3393 Add( XML_STYLE_FAMILY_TEXT_TEXT, xPropSet ); 3394 } 3395 else 3396 { 3397 sal_Bool bHyperlink = sal_False; 3398 sal_Bool bIsUICharStyle = sal_False; 3399 sal_Bool bHasAutoStyle = sal_False; 3400 3401 OUString sStyle(FindTextStyleAndHyperlink( xPropSet, bHyperlink, 3402 bIsUICharStyle, bHasAutoStyle )); 3403 3404 Reference < XPropertySetInfo > xPropSetInfo; 3405 if( bHyperlink ) 3406 { 3407 Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY ); 3408 xPropSetInfo.set(xPropSet->getPropertySetInfo()); 3409 bHyperlink = addHyperlinkAttributes( xPropSet, xPropState, xPropSetInfo ); 3410 } 3411 SvXMLElementExport aElem( GetExport(), bHyperlink, XML_NAMESPACE_TEXT, 3412 XML_A, sal_False, sal_False ); 3413 if( bHyperlink ) 3414 { 3415 // export events (if supported) 3416 OUString sHyperLinkEvents(RTL_CONSTASCII_USTRINGPARAM( 3417 "HyperLinkEvents")); 3418 if (xPropSetInfo->hasPropertyByName(sHyperLinkEvents)) 3419 { 3420 Reference<XNameReplace> xName(xPropSet->getPropertyValue(sHyperLinkEvents), uno::UNO_QUERY); 3421 GetExport().GetEventExport().Export(xName, sal_False); 3422 } 3423 } 3424 3425 { 3426 XMLTextCharStyleNamesElementExport aCharStylesExport( 3427 GetExport(), bIsUICharStyle && 3428 aCharStyleNamesPropInfoCache.hasProperty( 3429 xPropSet, xPropSetInfo ), bHasAutoStyle, 3430 xPropSet, sCharStyleNames ); 3431 3432 OUString aText(rTextRange->getString()); 3433 if( sStyle.getLength() ) 3434 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, 3435 GetExport().EncodeStyleName( sStyle ) ); 3436 { 3437 // in a block to make sure it is destroyed before the text:a element 3438 SvXMLElementExport aElement( GetExport(), sStyle.getLength() > 0, 3439 XML_NAMESPACE_TEXT, XML_SPAN, sal_False, 3440 sal_False ); 3441 exportText( aText, rPrevCharIsSpace ); 3442 } 3443 } 3444 } 3445 } 3446 3447 void XMLTextParagraphExport::exportText( const OUString& rText, 3448 sal_Bool& rPrevCharIsSpace ) 3449 { 3450 sal_Int32 nExpStartPos = 0; 3451 sal_Int32 nEndPos = rText.getLength(); 3452 sal_Int32 nSpaceChars = 0; 3453 for( sal_Int32 nPos = 0; nPos < nEndPos; nPos++ ) 3454 { 3455 sal_Unicode cChar = rText[nPos]; 3456 sal_Bool bExpCharAsText = sal_True; 3457 sal_Bool bExpCharAsElement = sal_False; 3458 sal_Bool bCurrCharIsSpace = sal_False; 3459 switch( cChar ) 3460 { 3461 case 0x0009: // Tab 3462 case 0x000A: // LF 3463 // These characters are exported as text. 3464 bExpCharAsElement = sal_True; 3465 bExpCharAsText = sal_False; 3466 break; 3467 case 0x000D: 3468 break; // legal character 3469 case 0x0020: // Blank 3470 if( rPrevCharIsSpace ) 3471 { 3472 // If the previous character is a space character, 3473 // too, export a special space element. 3474 bExpCharAsText = sal_False; 3475 } 3476 bCurrCharIsSpace = sal_True; 3477 break; 3478 default: 3479 if( cChar < 0x0020 ) 3480 { 3481 #ifdef DBG_UTIL 3482 OSL_ENSURE( txtparae_bContainsIllegalCharacters || 3483 cChar >= 0x0020, 3484 "illegal character in text content" ); 3485 txtparae_bContainsIllegalCharacters = sal_True; 3486 #endif 3487 bExpCharAsText = sal_False; 3488 } 3489 break; 3490 } 3491 3492 // If the current character is not exported as text 3493 // the text that has not been exported by now has to be exported now. 3494 if( nPos > nExpStartPos && !bExpCharAsText ) 3495 { 3496 DBG_ASSERT( 0==nSpaceChars, "pending spaces" ); 3497 OUString sExp( rText.copy( nExpStartPos, nPos - nExpStartPos ) ); 3498 GetExport().Characters( sExp ); 3499 nExpStartPos = nPos; 3500 } 3501 3502 // If there are spaces left that have not been exported and the 3503 // current chracter is not a space , the pending spaces have to be 3504 // exported now. 3505 if( nSpaceChars > 0 && !bCurrCharIsSpace ) 3506 { 3507 DBG_ASSERT( nExpStartPos == nPos, " pending characters" ); 3508 3509 if( nSpaceChars > 1 ) 3510 { 3511 OUStringBuffer sTmp; 3512 sTmp.append( (sal_Int32)nSpaceChars ); 3513 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C, 3514 sTmp.makeStringAndClear() ); 3515 } 3516 3517 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, 3518 XML_S, sal_False, sal_False ); 3519 3520 nSpaceChars = 0; 3521 } 3522 3523 // If the current character has to be exported as a special 3524 // element, the elemnt will be exported now. 3525 if( bExpCharAsElement ) 3526 { 3527 switch( cChar ) 3528 { 3529 case 0x0009: // Tab 3530 { 3531 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, 3532 XML_TAB, sal_False, 3533 sal_False ); 3534 } 3535 break; 3536 case 0x000A: // LF 3537 { 3538 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, 3539 XML_LINE_BREAK, sal_False, 3540 sal_False ); 3541 } 3542 break; 3543 } 3544 } 3545 3546 // If the current character is a space, and the previous one 3547 // is a space, too, the number of pending spaces is incremented 3548 // only. 3549 if( bCurrCharIsSpace && rPrevCharIsSpace ) 3550 nSpaceChars++; 3551 rPrevCharIsSpace = bCurrCharIsSpace; 3552 3553 // If the currect character is not exported as text, the start 3554 // position for text is the position behind the current position. 3555 if( !bExpCharAsText ) 3556 { 3557 DBG_ASSERT( nExpStartPos == nPos, "wrong export start pos" ); 3558 nExpStartPos = nPos+1; 3559 } 3560 } 3561 3562 if( nExpStartPos < nEndPos ) 3563 { 3564 DBG_ASSERT( 0==nSpaceChars, " pending spaces " ); 3565 OUString sExp( rText.copy( nExpStartPos, nEndPos - nExpStartPos ) ); 3566 GetExport().Characters( sExp ); 3567 } 3568 3569 // If there are some spaces left, they have to be exported now. 3570 if( nSpaceChars > 0 ) 3571 { 3572 if( nSpaceChars > 1 ) 3573 { 3574 OUStringBuffer sTmp; 3575 sTmp.append( (sal_Int32)nSpaceChars ); 3576 GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C, 3577 sTmp.makeStringAndClear() ); 3578 } 3579 3580 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_S, 3581 sal_False, sal_False ); 3582 } 3583 } 3584 3585 void XMLTextParagraphExport::exportTextDeclarations() 3586 { 3587 pFieldExport->ExportFieldDeclarations(); 3588 3589 // get XPropertySet from the document and ask for AutoMarkFileURL. 3590 // If it exists, export the auto-mark-file element. 3591 Reference<XPropertySet> xPropertySet( GetExport().GetModel(), UNO_QUERY ); 3592 if (xPropertySet.is()) 3593 { 3594 OUString sUrl; 3595 OUString sIndexAutoMarkFileURL( 3596 RTL_CONSTASCII_USTRINGPARAM("IndexAutoMarkFileURL")); 3597 if (xPropertySet->getPropertySetInfo()->hasPropertyByName( 3598 sIndexAutoMarkFileURL)) 3599 { 3600 xPropertySet->getPropertyValue(sIndexAutoMarkFileURL) >>= sUrl; 3601 if (sUrl.getLength() > 0) 3602 { 3603 GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, 3604 GetExport().GetRelativeReference(sUrl) ); 3605 SvXMLElementExport aAutoMarkElement( 3606 GetExport(), XML_NAMESPACE_TEXT, 3607 XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE, 3608 sal_True, sal_True ); 3609 } 3610 } 3611 } 3612 } 3613 3614 void XMLTextParagraphExport::exportTextDeclarations( 3615 const Reference<XText> & rText ) 3616 { 3617 pFieldExport->ExportFieldDeclarations(rText); 3618 } 3619 3620 void XMLTextParagraphExport::exportUsedDeclarations( sal_Bool bOnlyUsed ) 3621 { 3622 pFieldExport->SetExportOnlyUsedFieldDeclarations( bOnlyUsed ); 3623 } 3624 3625 3626 void XMLTextParagraphExport::exportTrackedChanges(sal_Bool bAutoStyles) 3627 { 3628 if (NULL != pRedlineExport) 3629 pRedlineExport->ExportChangesList( bAutoStyles ); 3630 } 3631 3632 void XMLTextParagraphExport::exportTrackedChanges( 3633 const Reference<XText> & rText, 3634 sal_Bool bAutoStyle) 3635 { 3636 if (NULL != pRedlineExport) 3637 pRedlineExport->ExportChangesList(rText, bAutoStyle); 3638 } 3639 3640 void XMLTextParagraphExport::recordTrackedChangesForXText( 3641 const Reference<XText> & rText ) 3642 { 3643 if (NULL != pRedlineExport) 3644 pRedlineExport->SetCurrentXText(rText); 3645 } 3646 3647 void XMLTextParagraphExport::recordTrackedChangesNoXText() 3648 { 3649 if (NULL != pRedlineExport) 3650 pRedlineExport->SetCurrentXText(); 3651 } 3652 3653 3654 void XMLTextParagraphExport::exportTextAutoStyles() 3655 { 3656 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_PARAGRAPH, 3657 GetExport().GetDocHandler(), 3658 GetExport().GetMM100UnitConverter(), 3659 GetExport().GetNamespaceMap() ); 3660 3661 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_TEXT, 3662 GetExport().GetDocHandler(), 3663 GetExport().GetMM100UnitConverter(), 3664 GetExport().GetNamespaceMap() ); 3665 3666 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_FRAME, 3667 GetExport().GetDocHandler(), 3668 GetExport().GetMM100UnitConverter(), 3669 GetExport().GetNamespaceMap() ); 3670 3671 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_SECTION, 3672 GetExport().GetDocHandler(), 3673 GetExport().GetMM100UnitConverter(), 3674 GetExport().GetNamespaceMap() ); 3675 3676 GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_RUBY, 3677 GetExport().GetDocHandler(), 3678 GetExport().GetMM100UnitConverter(), 3679 GetExport().GetNamespaceMap() ); 3680 3681 pListAutoPool->exportXML(); 3682 } 3683 3684 void XMLTextParagraphExport::exportRuby( 3685 const Reference<XPropertySet> & rPropSet, 3686 sal_Bool bAutoStyles ) 3687 { 3688 // early out: a collapsed ruby makes no sense 3689 if (*(sal_Bool*)rPropSet->getPropertyValue(sIsCollapsed).getValue()) 3690 return; 3691 3692 // start value ? 3693 sal_Bool bStart = (*(sal_Bool*)rPropSet->getPropertyValue(sIsStart).getValue()); 3694 3695 if (bAutoStyles) 3696 { 3697 // ruby auto styles 3698 if (bStart) 3699 Add( XML_STYLE_FAMILY_TEXT_RUBY, rPropSet ); 3700 } 3701 else 3702 { 3703 // prepare element names 3704 OUString aRuby(GetXMLToken(XML_RUBY)); 3705 OUString sTextRuby(GetExport().GetNamespaceMap(). 3706 GetQNameByKey(XML_NAMESPACE_TEXT, aRuby)); 3707 OUString sRubyBase(GetXMLToken(XML_RUBY_BASE)); 3708 OUString sTextRubyBase(GetExport().GetNamespaceMap(). 3709 GetQNameByKey(XML_NAMESPACE_TEXT, sRubyBase)); 3710 3711 if (bStart) 3712 { 3713 // ruby start 3714 3715 // we can only start a ruby if none is open 3716 DBG_ASSERT(! bOpenRuby, "Can't open a ruby inside of ruby!"); 3717 if( bOpenRuby ) 3718 return; 3719 3720 // save ruby text + ruby char style 3721 rPropSet->getPropertyValue(sRubyText) >>= sOpenRubyText; 3722 rPropSet->getPropertyValue(sRubyCharStyleName) >>= sOpenRubyCharStyle; 3723 3724 // ruby style 3725 GetExport().CheckAttrList(); 3726 OUString sEmpty; 3727 OUString sStyleName(Find( XML_STYLE_FAMILY_TEXT_RUBY, rPropSet, 3728 sEmpty )); 3729 DBG_ASSERT(sStyleName.getLength() > 0, "I can't find the style!"); 3730 GetExport().AddAttribute(XML_NAMESPACE_TEXT, 3731 XML_STYLE_NAME, sStyleName); 3732 3733 // export <text:ruby> and <text:ruby-base> start elements 3734 GetExport().StartElement( XML_NAMESPACE_TEXT, XML_RUBY, sal_False); 3735 GetExport().ClearAttrList(); 3736 GetExport().StartElement( XML_NAMESPACE_TEXT, XML_RUBY_BASE, 3737 sal_False ); 3738 bOpenRuby = sal_True; 3739 } 3740 else 3741 { 3742 // ruby end 3743 3744 // check for an open ruby 3745 DBG_ASSERT(bOpenRuby, "Can't close a ruby if none is open!"); 3746 if( !bOpenRuby ) 3747 return; 3748 3749 // close <text:ruby-base> 3750 GetExport().EndElement(XML_NAMESPACE_TEXT, XML_RUBY_BASE, 3751 sal_False); 3752 3753 // write the ruby text (with char style) 3754 { 3755 if (sOpenRubyCharStyle.getLength() > 0) 3756 GetExport().AddAttribute( 3757 XML_NAMESPACE_TEXT, XML_STYLE_NAME, 3758 GetExport().EncodeStyleName( sOpenRubyCharStyle) ); 3759 3760 SvXMLElementExport aRubyElement( 3761 GetExport(), XML_NAMESPACE_TEXT, XML_RUBY_TEXT, 3762 sal_False, sal_False); 3763 3764 GetExport().Characters(sOpenRubyText); 3765 } 3766 3767 // and finally, close the ruby 3768 GetExport().EndElement(XML_NAMESPACE_TEXT, XML_RUBY, sal_False); 3769 bOpenRuby = sal_False; 3770 } 3771 } 3772 } 3773 3774 void XMLTextParagraphExport::exportMeta( 3775 const Reference<XPropertySet> & i_xPortion, 3776 sal_Bool i_bAutoStyles, sal_Bool i_isProgress) 3777 { 3778 static OUString sMeta(RTL_CONSTASCII_USTRINGPARAM("InContentMetadata")); 3779 3780 bool doExport(!i_bAutoStyles); // do not export element if autostyles 3781 // check version >= 1.2 3782 switch (GetExport().getDefaultVersion()) { 3783 case SvtSaveOptions::ODFVER_011: // fall thru 3784 case SvtSaveOptions::ODFVER_010: doExport = false; break; 3785 default: break; 3786 } 3787 3788 const Reference< XTextContent > xTextContent( 3789 i_xPortion->getPropertyValue(sMeta), UNO_QUERY_THROW); 3790 const Reference< XEnumerationAccess > xEA( xTextContent, UNO_QUERY_THROW ); 3791 const Reference< XEnumeration > xTextEnum( xEA->createEnumeration() ); 3792 3793 if (doExport) 3794 { 3795 const Reference<rdf::XMetadatable> xMeta(xTextContent, UNO_QUERY_THROW); 3796 3797 // text:meta with neither xml:id nor RDFa is invalid 3798 xMeta->ensureMetadataReference(); 3799 3800 // xml:id and RDFa for RDF metadata 3801 GetExport().AddAttributeXmlId(xMeta); 3802 GetExport().AddAttributesRDFa(xTextContent); 3803 } 3804 3805 SvXMLElementExport aElem( GetExport(), doExport, 3806 XML_NAMESPACE_TEXT, XML_META, sal_False, sal_False ); 3807 3808 // recurse to export content 3809 exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_isProgress ); 3810 } 3811 3812 3813 void XMLTextParagraphExport::PreventExportOfControlsInMuteSections( 3814 const Reference<XIndexAccess> & rShapes, 3815 UniReference<xmloff::OFormLayerXMLExport> xFormExport ) 3816 { 3817 // check parameters ad pre-conditions 3818 if( ( ! rShapes.is() ) || ( ! xFormExport.is() ) ) 3819 { 3820 // if we don't have shapes or a form export, there's nothing to do 3821 return; 3822 } 3823 DBG_ASSERT( pSectionExport != NULL, "We need the section export." ); 3824 3825 Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration(); 3826 if(!xShapesEnum.is()) 3827 return; 3828 while( xShapesEnum->hasMoreElements() ) 3829 { 3830 // now we need to check 3831 // 1) if this is a control shape, and 3832 // 2) if it's in a mute section 3833 // if both answers are 'yes', notify the form layer export 3834 3835 // we join accessing the shape and testing for control 3836 Reference<XControlShape> xControlShape(xShapesEnum->nextElement(), UNO_QUERY); 3837 if( xControlShape.is() ) 3838 { 3839 // Reference<XPropertySet> xPropSet( xControlShape, UNO_QUERY ); 3840 // Reference<XTextContent> xTextContent; 3841 // xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) ) ) >>= xTextContent; 3842 3843 Reference<XTextContent> xTextContent( xControlShape, UNO_QUERY ); 3844 if( xTextContent.is() ) 3845 { 3846 if( pSectionExport->IsMuteSection( xTextContent, sal_False ) ) 3847 { 3848 // Ah, we've found a shape that 3849 // 1) is a control shape 3850 // 2) is anchored in a mute section 3851 // so: don't export it! 3852 xFormExport->excludeFromExport( 3853 xControlShape->getControl() ); 3854 } 3855 // else: not in mute section -> should be exported -> nothing 3856 // to do 3857 } 3858 // else: no anchor -> ignore 3859 } 3860 // else: no control shape -> nothing to do 3861 } 3862 } 3863 sal_Int32 XMLTextParagraphExport::GetHeadingLevel( const OUString& rStyleName ) 3864 { 3865 if( !pHeadingStyles ) 3866 { 3867 pHeadingStyles = new XMLStringVector; 3868 SvxXMLNumRuleExport::GetOutlineStyles( *pHeadingStyles, 3869 GetExport().GetModel() ); 3870 } 3871 for( XMLStringVector::size_type i=0; i < pHeadingStyles->size(); ++i ) 3872 { 3873 if( (*pHeadingStyles)[i] == rStyleName ) 3874 return static_cast < sal_Int32 >( i ); 3875 } 3876 3877 return -1; 3878 } 3879 3880 // --> OD 2008-05-08 #refactorlists# 3881 void XMLTextParagraphExport::PushNewTextListsHelper() 3882 { 3883 mpTextListsHelper = new XMLTextListsHelper(); 3884 maTextListsHelperStack.push_back( mpTextListsHelper ); 3885 } 3886 3887 void XMLTextParagraphExport::PopTextListsHelper() 3888 { 3889 delete mpTextListsHelper; 3890 mpTextListsHelper = 0; 3891 maTextListsHelperStack.pop_back(); 3892 if ( !maTextListsHelperStack.empty() ) 3893 { 3894 mpTextListsHelper = maTextListsHelperStack.back(); 3895 } 3896 } 3897 // <-- 3898