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