PageRenderTime 61ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/libreoffice-3.6.0.2/binfilter/bf_xmloff/source/text/xmloff_txtparae.cxx

#
C++ | 2997 lines | 2494 code | 293 blank | 210 comment | 392 complexity | 504031675134d2727f0e3b91f789c3a7 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, AGPL-1.0, BSD-3-Clause-No-Nuclear-License-2014, GPL-3.0, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /*************************************************************************
  3. *
  4. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5. *
  6. * Copyright 2000, 2010 Oracle and/or its affiliates.
  7. *
  8. * OpenOffice.org - a multi-platform office productivity suite
  9. *
  10. * This file is part of OpenOffice.org.
  11. *
  12. * OpenOffice.org is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Lesser General Public License version 3
  14. * only, as published by the Free Software Foundation.
  15. *
  16. * OpenOffice.org is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Lesser General Public License version 3 for more details
  20. * (a copy is included in the LICENSE file that accompanied this code).
  21. *
  22. * You should have received a copy of the GNU Lesser General Public License
  23. * version 3 along with OpenOffice.org. If not, see
  24. * <http://www.openoffice.org/license.html>
  25. * for a copy of the LGPLv3 License.
  26. *
  27. ************************************************************************/
  28. #ifndef _SVSTDARR_LONGS_DECL
  29. #define _SVSTDARR_LONGS
  30. #include <bf_svtools/svstdarr.hxx>
  31. #endif
  32. #include <vector>
  33. #include <com/sun/star/container/XEnumerationAccess.hpp>
  34. #include <com/sun/star/beans/XMultiPropertySet.hpp>
  35. #include <com/sun/star/beans/XPropertyState.hpp>
  36. #include <com/sun/star/text/XTextField.hpp>
  37. #include <com/sun/star/container/XContentEnumerationAccess.hpp>
  38. #include <com/sun/star/text/XTextFrame.hpp>
  39. #include <com/sun/star/text/SizeType.hpp>
  40. #include <com/sun/star/text/HoriOrientation.hpp>
  41. #include <com/sun/star/text/VertOrientation.hpp>
  42. #include <com/sun/star/text/XTextFramesSupplier.hpp>
  43. #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
  44. #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
  45. #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
  46. #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
  47. #include <com/sun/star/document/XEventsSupplier.hpp>
  48. #include <com/sun/star/text/XTextSection.hpp>
  49. #include <com/sun/star/drawing/XControlShape.hpp>
  50. #include "txtexppr.hxx"
  51. #include "xmluconv.hxx"
  52. #include "XMLAnchorTypePropHdl.hxx"
  53. #include "xexptran.hxx"
  54. #include "nmspmap.hxx"
  55. #include "xmlexp.hxx"
  56. #include "txtflde.hxx"
  57. #include "txtprmap.hxx"
  58. #include "XMLImageMapExport.hxx"
  59. #include "XMLTextNumRuleInfo.hxx"
  60. #include "XMLTextListAutoStylePool.hxx"
  61. #include "XMLSectionExport.hxx"
  62. #include "XMLIndexMarkExport.hxx"
  63. #include "XMLEventExport.hxx"
  64. #include "XMLRedlineExport.hxx"
  65. #include "MultiPropertySetHelper.hxx"
  66. #include "XMLTextCharStyleNamesElementExport.hxx"
  67. namespace binfilter {
  68. using namespace ::std;
  69. using namespace ::com::sun::star;
  70. using namespace ::com::sun::star::uno;
  71. using namespace ::com::sun::star::lang;
  72. using namespace ::com::sun::star::beans;
  73. using namespace ::com::sun::star::container;
  74. using namespace ::com::sun::star::text;
  75. using namespace ::com::sun::star::util;
  76. using namespace ::com::sun::star::drawing;
  77. using namespace ::com::sun::star::document;
  78. using namespace ::com::sun::star::frame;
  79. using namespace ::binfilter::xmloff::token;
  80. using rtl::OUString;
  81. using rtl::OUStringBuffer;
  82. typedef OUString *OUStringPtr;
  83. SV_DECL_PTRARR_DEL( OUStrings_Impl, OUStringPtr, 20, 10 )
  84. SV_IMPL_PTRARR( OUStrings_Impl, OUStringPtr )
  85. SV_DECL_PTRARR_SORT_DEL( OUStringsSort_Impl, OUStringPtr, 20, 10 )
  86. SV_IMPL_OP_PTRARR_SORT( OUStringsSort_Impl, OUStringPtr )
  87. #ifdef DBG_UTIL
  88. static int txtparae_bContainsIllegalCharacters = sal_False;
  89. #endif
  90. // The following map shows which property values are required:
  91. //
  92. // property auto style pass export
  93. // --------------------------------------------------------
  94. // ParaStyleName if style exists always
  95. // ParaConditionalStyleName if style exists always
  96. // NumberingRules if style exists always
  97. // TextSection always always
  98. // ParaChapterNumberingLevel never always
  99. // The conclusion is that for auto styles the first three properties
  100. // should be queried using a multi property set if, and only if, an
  101. // auto style needs to be exported. TextSection should be queried by
  102. // an individual call to getPropertyvalue, because this seems to be
  103. // less expensive than querying the first three properties if they aren't
  104. // required.
  105. // For the export pass all properties can be queried using a multi property
  106. // set.
  107. static const sal_Char* aParagraphPropertyNamesAuto[] =
  108. {
  109. "NumberingRules",
  110. "ParaConditionalStyleName",
  111. "ParaStyleName",
  112. NULL
  113. };
  114. enum eParagraphPropertyNamesEnumAuto
  115. {
  116. NUMBERING_RULES_AUTO = 0,
  117. PARA_CONDITIONAL_STYLE_NAME_AUTO = 1,
  118. PARA_STYLE_NAME_AUTO = 2
  119. };
  120. static const sal_Char* aParagraphPropertyNames[] =
  121. {
  122. "ParaChapterNumberingLevel",
  123. "ParaConditionalStyleName",
  124. "ParaStyleName",
  125. "TextSection",
  126. NULL
  127. };
  128. enum eParagraphPropertyNamesEnum
  129. {
  130. PARA_CHAPTER_NUMERBING_LEVEL = 0,
  131. PARA_CONDITIONAL_STYLE_NAME = 1,
  132. PARA_STYLE_NAME = 2,
  133. TEXT_SECTION = 3
  134. };
  135. void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
  136. const Reference < XPropertySet > & rPropSet,
  137. const XMLPropertyState** ppAddStates)
  138. {
  139. UniReference < SvXMLExportPropertyMapper > xPropMapper;
  140. switch( nFamily )
  141. {
  142. case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
  143. xPropMapper = GetParaPropMapper();
  144. break;
  145. case XML_STYLE_FAMILY_TEXT_TEXT:
  146. xPropMapper = GetTextPropMapper();
  147. break;
  148. case XML_STYLE_FAMILY_TEXT_FRAME:
  149. xPropMapper = GetAutoFramePropMapper();
  150. break;
  151. case XML_STYLE_FAMILY_TEXT_SECTION:
  152. xPropMapper = GetSectionPropMapper();
  153. break;
  154. case XML_STYLE_FAMILY_TEXT_RUBY:
  155. xPropMapper = GetRubyPropMapper();
  156. break;
  157. }
  158. DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
  159. vector< XMLPropertyState > xPropStates =
  160. xPropMapper->Filter( rPropSet );
  161. if( ppAddStates )
  162. {
  163. while( *ppAddStates )
  164. {
  165. xPropStates.push_back( **ppAddStates );
  166. ppAddStates++;
  167. }
  168. }
  169. if( !xPropStates.empty() )
  170. {
  171. Reference< XPropertySetInfo > xPropSetInfo =
  172. rPropSet->getPropertySetInfo();
  173. OUString sParent, sCondParent;
  174. Any aAny;
  175. sal_uInt16 nIgnoreProps = 0;
  176. switch( nFamily )
  177. {
  178. case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
  179. if( xPropSetInfo->hasPropertyByName( sParaStyleName ) )
  180. {
  181. aAny = rPropSet->getPropertyValue( sParaStyleName );
  182. aAny >>= sParent;
  183. }
  184. if( xPropSetInfo->hasPropertyByName( sParaConditionalStyleName ) )
  185. {
  186. aAny = rPropSet->getPropertyValue( sParaConditionalStyleName );
  187. aAny >>= sCondParent;
  188. }
  189. if( xPropSetInfo->hasPropertyByName( sNumberingRules ) )
  190. {
  191. aAny = rPropSet->getPropertyValue( sNumberingRules );
  192. Reference < XIndexReplace > xNumRule;
  193. aAny >>= xNumRule;
  194. if( xNumRule.is() && xNumRule->getCount() )
  195. {
  196. Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
  197. OUString sName;
  198. if( xNamed.is() )
  199. sName = xNamed->getName();
  200. sal_Bool bAdd = !sName.getLength();
  201. if( !bAdd )
  202. {
  203. Reference < XPropertySet > xNumPropSet( xNumRule,
  204. UNO_QUERY );
  205. OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
  206. if( xNumPropSet.is() &&
  207. xNumPropSet->getPropertySetInfo()
  208. ->hasPropertyByName( sIsAutomatic ) )
  209. {
  210. aAny = xNumPropSet->getPropertyValue( sIsAutomatic );
  211. bAdd = *(sal_Bool *)aAny.getValue();
  212. }
  213. else
  214. {
  215. bAdd = sal_True;
  216. }
  217. }
  218. if( bAdd )
  219. pListAutoPool->Add( xNumRule );
  220. }
  221. }
  222. break;
  223. case XML_STYLE_FAMILY_TEXT_TEXT:
  224. {
  225. // Get parent and remove hyperlinks (they aren't of interest)
  226. UniReference< XMLPropertySetMapper > xPM =
  227. xPropMapper->getPropertySetMapper();
  228. for( ::std::vector< XMLPropertyState >::iterator i
  229. = xPropStates.begin();
  230. nIgnoreProps < 2 && i != xPropStates.end();
  231. ++i )
  232. {
  233. switch( xPM->GetEntryContextId(i->mnIndex) )
  234. {
  235. case CTF_CHAR_STYLE_NAME:
  236. i->maValue >>= sParent;
  237. i->mnIndex = -1;
  238. nIgnoreProps++;
  239. break;
  240. case CTF_HYPERLINK_URL:
  241. i->mnIndex = -1;
  242. nIgnoreProps++;
  243. break;
  244. }
  245. }
  246. }
  247. break;
  248. case XML_STYLE_FAMILY_TEXT_FRAME:
  249. if( xPropSetInfo->hasPropertyByName( sFrameStyleName ) )
  250. {
  251. aAny = rPropSet->getPropertyValue( sFrameStyleName );
  252. aAny >>= sParent;
  253. }
  254. break;
  255. case XML_STYLE_FAMILY_TEXT_SECTION:
  256. case XML_STYLE_FAMILY_TEXT_RUBY:
  257. ; // section styles have no parents
  258. break;
  259. }
  260. if( (xPropStates.size() - nIgnoreProps) > 0 )
  261. {
  262. GetAutoStylePool().Add( nFamily, sParent, xPropStates );
  263. if( sCondParent.getLength() && sParent != sCondParent )
  264. GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
  265. }
  266. }
  267. }
  268. void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
  269. MultiPropertySetHelper& rPropSetHelper,
  270. const Reference < XPropertySet > & rPropSet,
  271. const XMLPropertyState** ppAddStates)
  272. {
  273. UniReference < SvXMLExportPropertyMapper > xPropMapper;
  274. switch( nFamily )
  275. {
  276. case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
  277. xPropMapper = GetParaPropMapper();
  278. break;
  279. }
  280. DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
  281. vector< XMLPropertyState > xPropStates =
  282. xPropMapper->Filter( rPropSet );
  283. if( ppAddStates )
  284. {
  285. while( *ppAddStates )
  286. {
  287. xPropStates.push_back( **ppAddStates );
  288. ppAddStates++;
  289. }
  290. }
  291. if( !xPropStates.empty() )
  292. {
  293. OUString sParent, sCondParent;
  294. Any aAny;
  295. switch( nFamily )
  296. {
  297. case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
  298. if( rPropSetHelper.hasProperty( PARA_STYLE_NAME_AUTO ) )
  299. {
  300. aAny = rPropSetHelper.getValue( PARA_STYLE_NAME_AUTO, rPropSet,
  301. sal_True );
  302. aAny >>= sParent;
  303. }
  304. if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO ) )
  305. {
  306. aAny = rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO,
  307. rPropSet, sal_True );
  308. aAny >>= sCondParent;
  309. }
  310. if( rPropSetHelper.hasProperty( NUMBERING_RULES_AUTO ) )
  311. {
  312. aAny = rPropSetHelper.getValue( NUMBERING_RULES_AUTO,
  313. rPropSet, sal_True );
  314. Reference < XIndexReplace > xNumRule;
  315. aAny >>= xNumRule;
  316. if( xNumRule.is() && xNumRule->getCount() )
  317. {
  318. Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
  319. OUString sName;
  320. if( xNamed.is() )
  321. sName = xNamed->getName();
  322. sal_Bool bAdd = !sName.getLength();
  323. if( !bAdd )
  324. {
  325. Reference < XPropertySet > xNumPropSet( xNumRule,
  326. UNO_QUERY );
  327. OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
  328. if( xNumPropSet.is() &&
  329. xNumPropSet->getPropertySetInfo()
  330. ->hasPropertyByName( sIsAutomatic ) )
  331. {
  332. aAny = xNumPropSet->getPropertyValue( sIsAutomatic );
  333. bAdd = *(sal_Bool *)aAny.getValue();
  334. }
  335. else
  336. {
  337. bAdd = sal_True;
  338. }
  339. }
  340. if( bAdd )
  341. pListAutoPool->Add( xNumRule );
  342. }
  343. }
  344. break;
  345. }
  346. if( !xPropStates.empty() )
  347. {
  348. GetAutoStylePool().Add( nFamily, sParent, xPropStates );
  349. if( sCondParent.getLength() && sParent != sCondParent )
  350. GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
  351. }
  352. }
  353. }
  354. OUString XMLTextParagraphExport::Find(
  355. sal_uInt16 nFamily,
  356. const Reference < XPropertySet > & rPropSet,
  357. const OUString& rParent,
  358. const XMLPropertyState** ppAddStates) const
  359. {
  360. OUString sName( rParent );
  361. UniReference < SvXMLExportPropertyMapper > xPropMapper;
  362. switch( nFamily )
  363. {
  364. case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
  365. xPropMapper = GetParaPropMapper();
  366. break;
  367. case XML_STYLE_FAMILY_TEXT_FRAME:
  368. xPropMapper = GetAutoFramePropMapper();
  369. break;
  370. case XML_STYLE_FAMILY_TEXT_SECTION:
  371. xPropMapper = GetSectionPropMapper();
  372. break;
  373. case XML_STYLE_FAMILY_TEXT_RUBY:
  374. xPropMapper = GetRubyPropMapper();
  375. break;
  376. }
  377. DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
  378. if( !xPropMapper.is() )
  379. return sName;
  380. vector< XMLPropertyState > xPropStates =
  381. xPropMapper->Filter( rPropSet );
  382. if( ppAddStates )
  383. {
  384. while( *ppAddStates )
  385. {
  386. xPropStates.push_back( **ppAddStates );
  387. ppAddStates++;
  388. }
  389. }
  390. if( !xPropStates.empty() )
  391. sName = GetAutoStylePool().Find( nFamily, sName, xPropStates );
  392. return sName;
  393. }
  394. OUString XMLTextParagraphExport::FindTextStyleAndHyperlink(
  395. const Reference < XPropertySet > & rPropSet,
  396. sal_Bool& rHyperlink,
  397. sal_Bool& rHasCharStyle,
  398. const XMLPropertyState** ppAddStates ) const
  399. {
  400. UniReference < SvXMLExportPropertyMapper > xPropMapper
  401. = GetTextPropMapper();
  402. vector< XMLPropertyState > xPropStates =
  403. xPropMapper->Filter( rPropSet );
  404. // Get parent and remove hyperlinks (they aren't of interest)
  405. OUString sName;
  406. rHyperlink = rHasCharStyle = sal_False;
  407. sal_uInt16 nIgnoreProps = 0;
  408. UniReference< XMLPropertySetMapper > xPM =
  409. xPropMapper->getPropertySetMapper();
  410. for( ::std::vector< XMLPropertyState >::iterator
  411. i = xPropStates.begin();
  412. nIgnoreProps < 2 && i != xPropStates.end();
  413. ++i )
  414. {
  415. switch( xPM->GetEntryContextId(i->mnIndex) )
  416. {
  417. case CTF_CHAR_STYLE_NAME:
  418. i->maValue >>= sName;
  419. i->mnIndex = -1;
  420. rHasCharStyle = sName.getLength() > 0;
  421. nIgnoreProps++;
  422. break;
  423. case CTF_HYPERLINK_URL:
  424. rHyperlink = sal_True;
  425. i->mnIndex = -1;
  426. nIgnoreProps++;
  427. break;
  428. }
  429. }
  430. if( ppAddStates )
  431. {
  432. while( *ppAddStates )
  433. {
  434. xPropStates.push_back( **ppAddStates );
  435. ppAddStates++;
  436. }
  437. }
  438. if( (xPropStates.size() - nIgnoreProps) > 0L )
  439. sName = GetAutoStylePool().Find( XML_STYLE_FAMILY_TEXT_TEXT, sName, xPropStates );
  440. return sName;
  441. }
  442. OUString XMLTextParagraphExport::FindTextStyle(
  443. const Reference < XPropertySet > & rPropSet,
  444. sal_Bool& rHasCharStyle ) const
  445. {
  446. sal_Bool bDummy;
  447. return FindTextStyleAndHyperlink( rPropSet, bDummy, rHasCharStyle );
  448. }
  449. void XMLTextParagraphExport::exportListChange(
  450. const XMLTextNumRuleInfo& rPrevInfo,
  451. const XMLTextNumRuleInfo& rNextInfo )
  452. {
  453. // end a list
  454. if( rPrevInfo.GetLevel() > 0 &&
  455. ( !rNextInfo.HasSameNumRules( rPrevInfo ) ||
  456. rNextInfo.GetLevel() < rPrevInfo.GetLevel() ||
  457. rNextInfo.IsRestart() ) )
  458. {
  459. sal_Int16 nPrevLevel = rPrevInfo.GetLevel();
  460. sal_Int16 nNextLevel =
  461. ( !rNextInfo.HasSameNumRules( rPrevInfo ) ||
  462. rNextInfo.IsRestart() ) ? 0 : rNextInfo.GetLevel();
  463. DBG_ASSERT( pListElements &&
  464. pListElements->Count() >= 2*(nNextLevel-nPrevLevel),
  465. "SwXMLExport::ExportListChange: list elements missing" );
  466. for( sal_Int16 i=nPrevLevel; i > nNextLevel; i-- )
  467. {
  468. for( sal_uInt16 j=0; j<2; j++ )
  469. {
  470. OUString *pElem = (*pListElements)[pListElements->Count()-1];
  471. pListElements->Remove( pListElements->Count()-1 );
  472. GetExport().EndElement( *pElem, sal_True );
  473. delete pElem;
  474. }
  475. }
  476. }
  477. // start a new list
  478. if( rNextInfo.GetLevel() > 0 &&
  479. ( !rPrevInfo.HasSameNumRules( rNextInfo ) ||
  480. rPrevInfo.GetLevel() < rNextInfo.GetLevel() ||
  481. rNextInfo.IsRestart() ) )
  482. {
  483. sal_Int16 nPrevLevel =
  484. ( !rNextInfo.HasSameNumRules( rPrevInfo ) ||
  485. rNextInfo.IsRestart() ) ? 0 : rPrevInfo.GetLevel();
  486. sal_Int16 nNextLevel = rNextInfo.GetLevel();
  487. // Find out whether this is the first application of the list or not.
  488. // For named lists, we use the internal name. For unnamed lists, we
  489. // use the generated name. This works well, because there are either
  490. // unnamed or either named lists only.
  491. sal_Bool bListExported = sal_False;
  492. OUString sName;
  493. if( rNextInfo.IsNamed() )
  494. sName = rNextInfo.GetName();
  495. else
  496. sName = pListAutoPool->Find( rNextInfo.GetNumRules() );
  497. DBG_ASSERT( sName.getLength(), "list without a name" );
  498. if( sName.getLength() )
  499. {
  500. bListExported = pExportedLists &&
  501. pExportedLists->Seek_Entry( (OUString *)&sName );
  502. if( !bListExported )
  503. {
  504. if( !pExportedLists )
  505. pExportedLists = new OUStringsSort_Impl;
  506. pExportedLists->Insert( new OUString(sName) );
  507. }
  508. }
  509. sal_Bool bContinue = !rNextInfo.IsRestart() && bListExported &&
  510. !rPrevInfo.HasSameNumRules( rNextInfo );
  511. for( sal_Int16 i=nPrevLevel; i < nNextLevel; i++)
  512. {
  513. // <text:ordered-list> or <text:unordered-list>
  514. GetExport().CheckAttrList();
  515. if( 0 == i )
  516. {
  517. // For named list, the name might be the name of an automatic
  518. // rule, so we have to take a look into the style pool.
  519. // For unnamed lists, we have done this already.
  520. if( rNextInfo.IsNamed() )
  521. {
  522. OUString sTmp( pListAutoPool->Find(
  523. rNextInfo.GetNumRules() ) );
  524. if( sTmp.getLength() )
  525. sName = sTmp;
  526. }
  527. GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
  528. sName );
  529. }
  530. if( bContinue && rNextInfo.IsOrdered() )
  531. GetExport().AddAttribute( XML_NAMESPACE_TEXT,
  532. XML_CONTINUE_NUMBERING, XML_TRUE );
  533. enum XMLTokenEnum eLName =
  534. rNextInfo.IsOrdered() ? XML_ORDERED_LIST
  535. : XML_UNORDERED_LIST;
  536. OUString *pElem = new OUString(
  537. GetExport().GetNamespaceMap().GetQNameByKey(
  538. XML_NAMESPACE_TEXT,
  539. GetXMLToken(eLName) ) );
  540. GetExport().IgnorableWhitespace();
  541. GetExport().StartElement( *pElem, sal_False );
  542. if( !pListElements )
  543. pListElements = new OUStrings_Impl;
  544. pListElements->Insert( pElem, pListElements->Count() );
  545. // <text:list-header> or <text:list-item>
  546. GetExport().CheckAttrList();
  547. if( rNextInfo.HasStartValue() )
  548. {
  549. OUStringBuffer aBuffer;
  550. aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
  551. GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
  552. aBuffer.makeStringAndClear() );
  553. }
  554. eLName = (rNextInfo.IsNumbered() || i+1 < nNextLevel)
  555. ? XML_LIST_ITEM
  556. : XML_LIST_HEADER;
  557. pElem = new OUString( GetExport().GetNamespaceMap().GetQNameByKey(
  558. XML_NAMESPACE_TEXT,
  559. GetXMLToken(eLName) ) );
  560. GetExport().IgnorableWhitespace();
  561. GetExport().StartElement( *pElem, sal_False );
  562. pListElements->Insert( pElem, pListElements->Count() );
  563. }
  564. }
  565. if( rNextInfo.GetLevel() > 0 && rNextInfo.IsNumbered() &&
  566. rPrevInfo.HasSameNumRules( rNextInfo ) &&
  567. rPrevInfo.GetLevel() >= rNextInfo.GetLevel() &&
  568. !rNextInfo.IsRestart() )
  569. {
  570. // </text:list-item> or </text:list-header>
  571. DBG_ASSERT( pListElements && pListElements->Count() >= 2,
  572. "SwXMLExport::ExportListChange: list elements missing" );
  573. OUString *pElem = (*pListElements)[pListElements->Count()-1];
  574. GetExport().EndElement( *pElem, sal_True );
  575. pListElements->Remove( pListElements->Count()-1 );
  576. delete pElem;
  577. // <text:list-item>
  578. GetExport().CheckAttrList();
  579. if( rNextInfo.HasStartValue() )
  580. {
  581. OUStringBuffer aBuffer;
  582. aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
  583. GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
  584. aBuffer.makeStringAndClear() );
  585. }
  586. pElem = new OUString( GetExport().GetNamespaceMap().GetQNameByKey(
  587. XML_NAMESPACE_TEXT,
  588. GetXMLToken(XML_LIST_ITEM) ) );
  589. GetExport().IgnorableWhitespace();
  590. GetExport().StartElement( *pElem, sal_False );
  591. pListElements->Insert( pElem, pListElements->Count() );
  592. }
  593. }
  594. XMLTextParagraphExport::XMLTextParagraphExport(
  595. SvXMLExport& rExp,
  596. SvXMLAutoStylePoolP & rASP
  597. ) :
  598. XMLStyleExport( rExp, OUString(), &rASP ),
  599. rAutoStylePool( rASP ),
  600. pPageTextFrameIdxs( 0 ),
  601. pPageGraphicIdxs( 0 ),
  602. pPageEmbeddedIdxs( 0 ),
  603. pPageShapeIdxs( 0 ),
  604. pFrameTextFrameIdxs( 0 ),
  605. pFrameGraphicIdxs( 0 ),
  606. pFrameEmbeddedIdxs( 0 ),
  607. pFrameShapeIdxs( 0 ),
  608. pFieldExport( 0 ),
  609. pListElements( 0 ),
  610. pExportedLists( 0 ),
  611. pListAutoPool( new XMLTextListAutoStylePool( this->GetExport() ) ),
  612. pSectionExport( NULL ),
  613. pIndexMarkExport( NULL ),
  614. pRedlineExport( NULL ),
  615. bProgress( sal_False ),
  616. bBlock( sal_False ),
  617. bOpenRuby( sal_False ),
  618. sParagraphService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Paragraph")),
  619. sTableService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable")),
  620. sTextFieldService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField")),
  621. sTextFrameService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")),
  622. sTextEmbeddedService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextEmbeddedObject")),
  623. sTextGraphicService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextGraphicObject")),
  624. sTextEndnoteService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote")),
  625. sTextContentService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextContent")),
  626. sShapeService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape")),
  627. sParaStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName")),
  628. sParaConditionalStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaConditionalStyleName")),
  629. sParaChapterNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("ParaChapterNumberingLevel")),
  630. sCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName")),
  631. sCharStyleNames(RTL_CONSTASCII_USTRINGPARAM("CharStyleNames")),
  632. sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")),
  633. sText(RTL_CONSTASCII_USTRINGPARAM("Text")),
  634. sTextField(RTL_CONSTASCII_USTRINGPARAM("TextField")),
  635. sFrame(RTL_CONSTASCII_USTRINGPARAM("Frame")),
  636. sCategory(RTL_CONSTASCII_USTRINGPARAM("Category")),
  637. sNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules")),
  638. sTextPortionType(RTL_CONSTASCII_USTRINGPARAM("TextPortionType")),
  639. sFootnote(RTL_CONSTASCII_USTRINGPARAM("Footnote")),
  640. sBookmark(RTL_CONSTASCII_USTRINGPARAM("Bookmark")),
  641. sReferenceMark(RTL_CONSTASCII_USTRINGPARAM("ReferenceMark")),
  642. sIsCollapsed(RTL_CONSTASCII_USTRINGPARAM("IsCollapsed")),
  643. sIsStart(RTL_CONSTASCII_USTRINGPARAM("IsStart")),
  644. sReferenceId(RTL_CONSTASCII_USTRINGPARAM("ReferenceId")),
  645. sNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType")),
  646. sPageStyleName(RTL_CONSTASCII_USTRINGPARAM("PageStyleName")),
  647. sPageDescName(RTL_CONSTASCII_USTRINGPARAM("PageDescName")),
  648. sPrefix(RTL_CONSTASCII_USTRINGPARAM("Prefix")),
  649. sStartAt(RTL_CONSTASCII_USTRINGPARAM("StartAt")),
  650. sSuffix(RTL_CONSTASCII_USTRINGPARAM("Suffix")),
  651. sPositionEndOfDoc(RTL_CONSTASCII_USTRINGPARAM("PositionEndOfDoc")),
  652. sFootnoteCounting(RTL_CONSTASCII_USTRINGPARAM("FootnoteCounting")),
  653. sEndNotice(RTL_CONSTASCII_USTRINGPARAM("EndNotice")),
  654. sBeginNotice(RTL_CONSTASCII_USTRINGPARAM("BeginNotice")),
  655. sFrameWidthAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameWidthAbsolute")),
  656. sFrameWidthPercent(RTL_CONSTASCII_USTRINGPARAM("FrameWidthPercent")),
  657. sFrameHeightAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameHeightAbsolute")),
  658. sFrameHeightPercent(RTL_CONSTASCII_USTRINGPARAM("FrameHeightPercent")),
  659. sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")),
  660. sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")),
  661. sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")),
  662. sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")),
  663. sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")),
  664. sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")),
  665. sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")),
  666. sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")),
  667. sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")),
  668. sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")),
  669. sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")),
  670. sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")),
  671. sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")),
  672. sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")),
  673. sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")),
  674. sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")),
  675. sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")),
  676. sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")),
  677. sHyperLinkURL(RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")),
  678. sHyperLinkName(RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")),
  679. sHyperLinkTarget(RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")),
  680. sUnvisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("UnvisitedCharStyleName")),
  681. sVisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("VisitedCharStyleName")),
  682. sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex")),
  683. sTextSection(RTL_CONSTASCII_USTRINGPARAM("TextSection")),
  684. sDocumentIndexMark(RTL_CONSTASCII_USTRINGPARAM("DocumentIndexMark")),
  685. sActualSize(RTL_CONSTASCII_USTRINGPARAM("ActualSize")),
  686. sContourPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon")),
  687. sIsPixelContour(RTL_CONSTASCII_USTRINGPARAM("IsPixelContour")),
  688. sIsAutomaticContour(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour")),
  689. sAnchorCharStyleName(RTL_CONSTASCII_USTRINGPARAM("AnchorCharStyleName")),
  690. sServerMap(RTL_CONSTASCII_USTRINGPARAM("ServerMap")),
  691. sRedline(RTL_CONSTASCII_USTRINGPARAM("Redline")),
  692. sRuby(RTL_CONSTASCII_USTRINGPARAM("Ruby")),
  693. sRubyText(RTL_CONSTASCII_USTRINGPARAM("RubyText")),
  694. sRubyAdjust(RTL_CONSTASCII_USTRINGPARAM("RubyAdjust")),
  695. sRubyCharStyleName(RTL_CONSTASCII_USTRINGPARAM("RubyCharStyleName")),
  696. aCharStyleNamesPropInfoCache( sCharStyleNames )
  697. {
  698. UniReference < XMLPropertySetMapper > xPropMapper =
  699. new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA );
  700. xParaPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
  701. GetExport() );
  702. OUString sFamily( GetXMLToken(XML_PARAGRAPH) );
  703. OUString sLclPrefix( 'P' );
  704. rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH, sFamily,
  705. xParaPropMapper, sLclPrefix );
  706. xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
  707. xTextPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
  708. GetExport() );
  709. sFamily = OUString( GetXMLToken(XML_TEXT) );
  710. sLclPrefix = OUString( 'T' );
  711. rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_TEXT, sFamily,
  712. xTextPropMapper, sLclPrefix );
  713. xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_AUTO_FRAME );
  714. xAutoFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
  715. GetExport() );
  716. sFamily = OUString( RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME) );
  717. sLclPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "fr" ) );
  718. rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_FRAME, sFamily,
  719. xAutoFramePropMapper, sLclPrefix );
  720. xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION );
  721. xSectionPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
  722. GetExport() );
  723. sFamily = OUString( GetXMLToken( XML_SECTION ) );
  724. sLclPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "Sect" ) );
  725. rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_SECTION, sFamily,
  726. xSectionPropMapper, sLclPrefix );
  727. xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY );
  728. xRubyPropMapper = new SvXMLExportPropertyMapper( xPropMapper );
  729. sFamily = OUString( GetXMLToken( XML_RUBY ) );
  730. sLclPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "Ru" ) );
  731. rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_RUBY, sFamily,
  732. xRubyPropMapper, sLclPrefix );
  733. xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
  734. xFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
  735. GetExport() );
  736. pSectionExport = new XMLSectionExport( rExp, *this );
  737. pIndexMarkExport = new XMLIndexMarkExport( rExp, *this );
  738. pRedlineExport = IsBlockMode() ? NULL : new XMLRedlineExport( rExp );
  739. // The text field helper needs a pre-constructed XMLPropertyState
  740. // to export the combined characters field. We construct that
  741. // here, because we need the text property mapper to do it.
  742. // construct Any value, then find index
  743. Any aAny;
  744. sal_Bool bTmp = sal_True;
  745. aAny.setValue(&bTmp, ::getBooleanCppuType());
  746. sal_Int32 nIndex = xTextPropMapper->getPropertySetMapper()->FindEntryIndex(
  747. "", XML_NAMESPACE_STYLE,
  748. GetXMLToken(XML_TEXT_COMBINE));
  749. pFieldExport = new XMLTextFieldExport( rExp, new XMLPropertyState( nIndex, aAny ) );
  750. }
  751. XMLTextParagraphExport::~XMLTextParagraphExport()
  752. {
  753. delete pRedlineExport;
  754. delete pIndexMarkExport;
  755. delete pSectionExport;
  756. delete pFieldExport;
  757. delete pListElements;
  758. delete pExportedLists;
  759. delete pListAutoPool;
  760. delete pPageTextFrameIdxs;
  761. delete pPageGraphicIdxs;
  762. delete pPageEmbeddedIdxs;
  763. delete pPageShapeIdxs;
  764. delete pFrameTextFrameIdxs;
  765. delete pFrameGraphicIdxs;
  766. delete pFrameEmbeddedIdxs;
  767. delete pFrameShapeIdxs;
  768. #ifdef DBG_UTIL
  769. txtparae_bContainsIllegalCharacters = sal_False;
  770. #endif
  771. }
  772. SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateShapeExtPropMapper(
  773. SvXMLExport& rExport )
  774. {
  775. UniReference < XMLPropertySetMapper > xPropMapper =
  776. new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE );
  777. return new XMLTextExportPropertySetMapper( xPropMapper, rExport );
  778. }
  779. SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateCharExtPropMapper(
  780. SvXMLExport& rExport)
  781. {
  782. XMLPropertySetMapper *pPropMapper =
  783. new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
  784. return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
  785. }
  786. SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaExtPropMapper(
  787. SvXMLExport& rExport)
  788. {
  789. XMLPropertySetMapper *pPropMapper =
  790. new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
  791. return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
  792. }
  793. void XMLTextParagraphExport::collectFrames( sal_Bool bBoundToFrameOnly )
  794. {
  795. Reference < XTextFramesSupplier > xTFS( GetExport().GetModel(), UNO_QUERY );
  796. if( xTFS.is() )
  797. {
  798. xTextFrames = Reference < XIndexAccess >( xTFS->getTextFrames(),
  799. UNO_QUERY );
  800. sal_Int32 nCount = xTextFrames->getCount();
  801. for( sal_Int32 i = 0; i < nCount; i++ )
  802. {
  803. Any aAny = xTextFrames->getByIndex( i );
  804. Reference < XTextFrame > xTxtFrame;
  805. aAny >>= xTxtFrame;
  806. Reference < XPropertySet > xPropSet( xTxtFrame, UNO_QUERY );
  807. aAny = xPropSet->getPropertyValue( sAnchorType );
  808. TextContentAnchorType eAnchor;
  809. aAny >>= eAnchor;
  810. switch( eAnchor )
  811. {
  812. case TextContentAnchorType_AT_PAGE:
  813. if( !bBoundToFrameOnly )
  814. {
  815. if( !pPageTextFrameIdxs )
  816. pPageTextFrameIdxs = new SvLongs;
  817. pPageTextFrameIdxs->Insert( i, pPageTextFrameIdxs->Count() );
  818. }
  819. break;
  820. case TextContentAnchorType_AT_FRAME:
  821. if( !pFrameTextFrameIdxs )
  822. pFrameTextFrameIdxs = new SvLongs;
  823. pFrameTextFrameIdxs->Insert( i, pFrameTextFrameIdxs->Count() );
  824. break;
  825. default:
  826. break;
  827. }
  828. }
  829. }
  830. Reference < XTextGraphicObjectsSupplier > xTGOS( GetExport().GetModel(),
  831. UNO_QUERY );
  832. if( xTGOS.is() )
  833. {
  834. xGraphics = Reference < XIndexAccess >( xTGOS->getGraphicObjects(),
  835. UNO_QUERY );
  836. sal_Int32 nCount = xGraphics->getCount();
  837. for( sal_Int32 i = 0; i < nCount; i++ )
  838. {
  839. Any aAny = xGraphics->getByIndex( i );
  840. Reference < XTextContent > xTxtCntnt;
  841. aAny >>= xTxtCntnt;
  842. Reference < XPropertySet > xPropSet( xTxtCntnt, UNO_QUERY );
  843. aAny = xPropSet->getPropertyValue( sAnchorType );
  844. TextContentAnchorType eAnchor;
  845. aAny >>= eAnchor;
  846. switch( eAnchor )
  847. {
  848. case TextContentAnchorType_AT_PAGE:
  849. if( !bBoundToFrameOnly )
  850. {
  851. if( !pPageGraphicIdxs )
  852. pPageGraphicIdxs = new SvLongs;
  853. pPageGraphicIdxs->Insert( i, pPageGraphicIdxs->Count() );
  854. }
  855. break;
  856. case TextContentAnchorType_AT_FRAME:
  857. if( !pFrameGraphicIdxs )
  858. pFrameGraphicIdxs = new SvLongs;
  859. pFrameGraphicIdxs->Insert( i, pFrameGraphicIdxs->Count() );
  860. break;
  861. default:
  862. break;
  863. }
  864. }
  865. }
  866. Reference < XTextEmbeddedObjectsSupplier > xTEOS( GetExport().GetModel(),
  867. UNO_QUERY );
  868. if( xTEOS.is() )
  869. {
  870. xEmbeddeds = Reference < XIndexAccess >( xTEOS->getEmbeddedObjects(),
  871. UNO_QUERY );
  872. sal_Int32 nCount = xEmbeddeds->getCount();
  873. for( sal_Int32 i = 0; i < nCount; i++ )
  874. {
  875. Any aAny = xEmbeddeds->getByIndex( i );
  876. Reference < XTextContent > xTxtCntnt;
  877. aAny >>= xTxtCntnt;
  878. Reference < XPropertySet > xPropSet( xTxtCntnt, UNO_QUERY );
  879. aAny = xPropSet->getPropertyValue( sAnchorType );
  880. TextContentAnchorType eAnchor;
  881. aAny >>= eAnchor;
  882. switch( eAnchor )
  883. {
  884. case TextContentAnchorType_AT_PAGE:
  885. if( !bBoundToFrameOnly )
  886. {
  887. if( !pPageEmbeddedIdxs )
  888. pPageEmbeddedIdxs = new SvLongs;
  889. pPageEmbeddedIdxs->Insert( i, pPageEmbeddedIdxs->Count() );
  890. }
  891. break;
  892. case TextContentAnchorType_AT_FRAME:
  893. if( !pFrameEmbeddedIdxs )
  894. pFrameEmbeddedIdxs = new SvLongs;
  895. pFrameEmbeddedIdxs->Insert( i, pFrameEmbeddedIdxs->Count() );
  896. break;
  897. default:
  898. break;
  899. }
  900. }
  901. }
  902. Reference < XDrawPageSupplier > xDPS( GetExport().GetModel(),
  903. UNO_QUERY );
  904. if( xDPS.is() )
  905. {
  906. xShapes = Reference < XIndexAccess >( xDPS->getDrawPage(),
  907. UNO_QUERY );
  908. sal_Int32 nCount = xShapes->getCount();
  909. for( sal_Int32 i = 0; i < nCount; i++ )
  910. {
  911. Any aAny = xShapes->getByIndex( i );
  912. Reference < XShape > xShape;
  913. aAny >>= xShape;
  914. if( !xShape.is() )
  915. continue;
  916. Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
  917. aAny = xPropSet->getPropertyValue( sAnchorType );
  918. TextContentAnchorType eAnchor;
  919. aAny >>= eAnchor;
  920. if( (TextContentAnchorType_AT_PAGE != eAnchor &&
  921. TextContentAnchorType_AT_FRAME != eAnchor) ||
  922. (TextContentAnchorType_AT_PAGE == eAnchor &&
  923. bBoundToFrameOnly ) )
  924. continue;
  925. Reference<XServiceInfo> xServiceInfo( xShape,
  926. UNO_QUERY );
  927. if( xServiceInfo->supportsService( sTextFrameService ) ||
  928. xServiceInfo->supportsService( sTextGraphicService ) ||
  929. xServiceInfo->supportsService( sTextEmbeddedService ) )
  930. continue;
  931. if( TextContentAnchorType_AT_PAGE == eAnchor )
  932. {
  933. if( !pPageShapeIdxs )
  934. pPageShapeIdxs = new SvLongs;
  935. pPageShapeIdxs->Insert( i, pPageShapeIdxs->Count() );
  936. }
  937. else
  938. {
  939. if( !pFrameShapeIdxs )
  940. pFrameShapeIdxs = new SvLongs;
  941. pFrameShapeIdxs->Insert( i, pFrameShapeIdxs->Count() );
  942. }
  943. }
  944. }
  945. }
  946. void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles,
  947. sal_Bool bInProgress )
  948. {
  949. if( pPageTextFrameIdxs )
  950. {
  951. for( sal_uInt16 i = 0; i < pPageTextFrameIdxs->Count(); i++ )
  952. {
  953. Any aAny = xTextFrames->getByIndex( (*pPageTextFrameIdxs)[i] );
  954. Reference < XTextFrame > xTxtFrame;
  955. aAny >>= xTxtFrame;
  956. Reference < XTextContent > xTxtCntnt( xTxtFrame, UNO_QUERY );
  957. exportTextFrame( xTxtCntnt, bAutoStyles, bInProgress );
  958. }
  959. }
  960. if( pPageGraphicIdxs )
  961. {
  962. for( sal_uInt16 i = 0; i < pPageGraphicIdxs->Count(); i++ )
  963. {
  964. Any aAny = xGraphics->getByIndex( (*pPageGraphicIdxs)[i] );
  965. Reference < XTextContent > xTxtCntnt;
  966. aAny >>= xTxtCntnt;
  967. exportTextGraphic( xTxtCntnt, bAutoStyles );
  968. }
  969. }
  970. if( pPageEmbeddedIdxs )
  971. {
  972. for( sal_uInt16 i = 0; i < pPageEmbeddedIdxs->Count(); i++ )
  973. {
  974. Any aAny = xEmbeddeds->getByIndex( (*pPageEmbeddedIdxs)[i] );
  975. Reference < XTextContent > xTxtCntnt;
  976. aAny >>= xTxtCntnt;
  977. exportTextEmbedded( xTxtCntnt, bAutoStyles );
  978. }
  979. }
  980. if( pPageShapeIdxs )
  981. {
  982. for( sal_uInt16 i = 0; i < pPageShapeIdxs->Count(); i++ )
  983. {
  984. Any aAny = xShapes->getByIndex( (*pPageShapeIdxs)[i] );
  985. Reference < XShape > xShape;
  986. aAny >>= xShape;
  987. Reference < XTextContent > xTxtCntnt( xShape, UNO_QUERY );
  988. exportShape( xTxtCntnt, bAutoStyles );
  989. }
  990. }
  991. }
  992. sal_Bool lcl_txtpara_isFrameAnchor(
  993. const Reference < XPropertySet > rPropSet,
  994. const Reference < XTextFrame >& rParentTxtFrame )
  995. {
  996. Any aAny = rPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorFrame") ) );
  997. Reference < XTextFrame > xAnchorTxtFrame;
  998. aAny >>= xAnchorTxtFrame;
  999. return xAnchorTxtFrame == rParentTxtFrame;
  1000. }
  1001. void XMLTextParagraphExport::exportFrameFrames(
  1002. sal_Bool bAutoStyles,
  1003. sal_Bool bInProgress,
  1004. const Reference < XTextFrame > *pParentTxtFrame )
  1005. {
  1006. if( pFrameTextFrameIdxs && pFrameTextFrameIdxs->Count() )
  1007. {
  1008. Any aAny;
  1009. sal_uInt16 i = 0;
  1010. while( i < pFrameTextFrameIdxs->Count() )
  1011. {
  1012. aAny = xTextFrames->getByIndex( (*pFrameTextFrameIdxs)[i] );
  1013. Reference < XTextFrame > xTxtFrame;
  1014. aAny >>= xTxtFrame;
  1015. Reference < XPropertySet > xPropSet( xTxtFrame, UNO_QUERY );
  1016. if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) )
  1017. {
  1018. if( !bAutoStyles )
  1019. pFrameTextFrameIdxs->Remove( i );
  1020. sal_uInt16 nOldCount = pFrameTextFrameIdxs->Count();
  1021. Reference < XTextContent > xTxtCntnt( xTxtFrame, UNO_QUERY );
  1022. exportTextFrame( xTxtCntnt, bAutoStyles, bInProgress );
  1023. if( bAutoStyles )
  1024. i++;
  1025. else if( pFrameTextFrameIdxs->Count() != nOldCount )
  1026. i = 0;
  1027. }
  1028. else
  1029. i++;
  1030. }
  1031. }
  1032. if( pFrameGraphicIdxs && pFrameGraphicIdxs->Count() )
  1033. {
  1034. Any aAny;
  1035. sal_uInt16 i = 0;
  1036. while( i < pFrameGraphicIdxs->Count() )
  1037. {
  1038. aAny = xGraphics->getByIndex( (*pFrameGraphicIdxs)[i] );
  1039. Reference < XTextContent > xTxtCntnt;
  1040. aAny >>= xTxtCntnt;
  1041. Reference < XPropertySet > xPropSet( xTxtCntnt, UNO_QUERY );
  1042. if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) )
  1043. {
  1044. if( !bAutoStyles )
  1045. pFrameGraphicIdxs->Remove( i );
  1046. sal_uInt16 nOldCount = pFrameGraphicIdxs->Count();
  1047. exportTextGraphic( xTxtCntnt, bAutoStyles );
  1048. if( bAutoStyles )
  1049. i++;
  1050. else if( pFrameGraphicIdxs->Count() != nOldCount )
  1051. i = 0;
  1052. }
  1053. else
  1054. i++;
  1055. }
  1056. }
  1057. if( pFrameEmbeddedIdxs && pFrameEmbeddedIdxs->Count() )
  1058. {
  1059. Any aAny;
  1060. sal_uInt16 i = 0;
  1061. while( i < pFrameEmbeddedIdxs->Count() )
  1062. {
  1063. aAny = xEmbeddeds->getByIndex( (*pFrameEmbeddedIdxs)[i] );
  1064. Reference < XEmbeddedObjectSupplier > xEOS;
  1065. aAny >>= xEOS;
  1066. Reference < XPropertySet > xPropSet( xEOS, UNO_QUERY );
  1067. if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) )
  1068. {
  1069. if( !bAutoStyles )
  1070. pFrameEmbeddedIdxs->Remove( i );
  1071. sal_uInt16 nOldCount = pFrameEmbeddedIdxs->Count();
  1072. Reference < XTextContent > xTxtCntnt( xEOS, UNO_QUERY );
  1073. exportTextEmbedded( xTxtCntnt, bAutoStyles );
  1074. if( bAutoStyles )
  1075. i++;
  1076. else if( pFrameEmbeddedIdxs->Count() != nOldCount )
  1077. i = 0;
  1078. }
  1079. else
  1080. i++;
  1081. }
  1082. }
  1083. if( pFrameShapeIdxs && pFrameShapeIdxs->Count() )
  1084. {
  1085. Any aAny;
  1086. sal_uInt16 i = 0;
  1087. while( i < pFrameShapeIdxs->Count() )
  1088. {
  1089. aAny = xShapes->getByIndex( (*pFrameShapeIdxs)[i] );
  1090. Reference < XShape > xShape;
  1091. aAny >>= xShape;
  1092. Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
  1093. if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) )
  1094. {
  1095. if( !bAutoStyles )
  1096. pFrameShapeIdxs->Remove( i );
  1097. sal_uInt16 nOldCount = pFrameShapeIdxs->Count();
  1098. Reference < XTextContent > xTxtCntnt( xShape, UNO_QUERY );
  1099. exportShape( xTxtCntnt, bAutoStyles );
  1100. if( bAutoStyles )
  1101. i++;
  1102. else if( pFrameShapeIdxs->Count() != nOldCount )
  1103. i = 0;
  1104. }
  1105. else
  1106. i++;
  1107. }
  1108. }
  1109. }
  1110. void XMLTextParagraphExport::exportText(
  1111. const Reference < XText > & rText,
  1112. sal_Bool bAutoStyles,
  1113. sal_Bool bInProgress,
  1114. sal_Bool bExportParagraph )
  1115. {
  1116. if( bAutoStyles )
  1117. GetExport().GetShapeExport(); // make sure the graphics styles family
  1118. // is added
  1119. Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
  1120. Reference < XEnumeration > xParaEnum = xEA->createEnumeration();
  1121. Reference < XPropertySet > xPropertySet( rText, UNO_QUERY );
  1122. Reference < XTextSection > xBaseSection;
  1123. // #97718# footnotes don't supply paragraph enumerations in some cases
  1124. // This is always a bug, but at least we don't want to crash.
  1125. DBG_ASSERT( xParaEnum.is(), "We need a paragraph enumeration" );
  1126. if( ! xParaEnum.is() )
  1127. return;
  1128. sal_Bool bExportLevels = sal_True;
  1129. if (xPropertySet.is())
  1130. {
  1131. Reference < XPropertySetInfo > xInfo ( xPropertySet->getPropertySetInfo() );
  1132. if( xInfo.is() )
  1133. {
  1134. if (xInfo->hasPropertyByName( sTextSection ))
  1135. {
  1136. xPropertySet->getPropertyValue(sTextSection) >>= xBaseSection ;
  1137. }
  1138. // for applications that use the outliner we need to check if
  1139. // the current text object needs the level information exported
  1140. if( !bAutoStyles )
  1141. {
  1142. // fixme: move string to class member, couldn't do now because
  1143. // of no incompatible build
  1144. OUString sHasLevels( RTL_CONSTASCII_USTRINGPARAM("HasLevels") );
  1145. if (xInfo->hasPropertyByName( sHasLevels ) )
  1146. {
  1147. xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels;
  1148. }
  1149. }
  1150. }
  1151. }
  1152. // #96530# Export redlines at start & end of XText before & after
  1153. // exporting the text content enumeration
  1154. if( !bAutoStyles && (pRedlineExport != NULL) )
  1155. pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True );
  1156. exportTextContentEnumeration( xParaEnum, bAutoStyles, xBaseSection,
  1157. bInProgress, bExportParagraph, 0, bExportLevels );
  1158. if( !bAutoStyles && (pRedlineExport != NULL) )
  1159. pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False );
  1160. }
  1161. void XMLTextParagraphExport::exportText(
  1162. const Reference < XText > & rText,
  1163. const Reference < XTextSection > & rBaseSection,
  1164. sal_Bool bAutoStyles,
  1165. sal_Bool bInProgress,
  1166. sal_Bool bExportParagraph )
  1167. {
  1168. if( bAutoStyles )
  1169. GetExport().GetShapeExport(); // make sure the graphics styles family
  1170. // is added
  1171. Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
  1172. Reference < XEnumeration > xParaEnum = xEA->createEnumeration();
  1173. // #98165# don't continue without a paragraph enumeration
  1174. if( ! xParaEnum.is() )
  1175. return;
  1176. // #96530# Export redlines at start & end of XText before & after
  1177. // exporting the text content enumeration
  1178. Reference<XPropertySet> xPropertySet;
  1179. if( !bAutoStyles && (pRedlineExport != NULL) )
  1180. {
  1181. xPropertySet = Reference<XPropertySet>::query( rText );
  1182. pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True );
  1183. }
  1184. exportTextContentEnume

Large files files are truncated, but you can click here to view the full file