diff options
author | Kurt Zenker <kz@openoffice.org> | 2009-06-03 11:26:39 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2009-06-03 11:26:39 +0000 |
commit | a8da772c4a21e7c9883823e3ae4dbee03c8c77fa (patch) | |
tree | d78ff4dbe4ab2916be487f8f921333877ae331a4 /xmloff | |
parent | a55914808cc66c14c4fb139f229ee84c8284bb74 (diff) |
CWS-TOOLING: integrate CWS os128
2009-04-22 12:58:26 +0200 b_michaelsen r271093 : #i101084# using the frames enumeration for other SwXFrames-queries; also added a complex test to ensure the behavior to be the same
2009-04-20 14:53:03 +0200 mav r270987 : #i101219# adjust the testcases to test memory cache and temporary file cache
2009-04-20 14:52:09 +0200 mav r270986 : #i101219#,#i99077# use memory to cache data; no precopying on commit
2009-04-20 14:39:21 +0200 mav r270984 : #i101219# use memory to cache data
2009-04-20 14:39:08 +0200 mav r270983 : #i101219# use memory to cache data
2009-04-20 14:38:45 +0200 mav r270982 : #i101219# use memory to cache data
2009-04-17 07:37:52 +0200 os r270912 : CWS-TOOLING: rebase CWS os128 to trunk@270723 (milestone: DEV300:m46)
2009-04-15 14:54:18 +0200 b_michaelsen r270845 : #i101084# using frame enumerations for paragraph export for better performance
2009-04-15 14:52:54 +0200 b_michaelsen r270843 : #i101084# implemented XEnumerationAccess interface on framesets
2009-04-03 17:08:10 +0200 mav r270504 : #i100722# do not compress streams of known compressed types per default
2009-04-03 13:49:50 +0200 os r270484 : resync error fixed
2009-04-03 12:55:32 +0200 mav r270470 : #i100722# do not compress streams of known compressed types per default
2009-04-03 10:00:58 +0200 os r270463 : resync error fixed
2009-04-03 09:52:53 +0200 os r270462 : resync error fixed
2009-04-03 09:10:14 +0200 os r270449 : #i99568# string compare operator of hash_map changed
2009-04-03 09:03:49 +0200 os r270446 : #i100683# normalize file URLs
2009-04-02 11:09:27 +0200 os r270381 : #i100683# making URLs relative without file access
2009-04-02 09:04:42 +0200 os r270366 : CWS-TOOLING: rebase CWS os128 to trunk@270033 (milestone: DEV300:m45)
2009-03-31 08:08:37 +0200 os r270258 : #i100683# reducing calls to URIHelper::simpleNormalizeMakeRelative()
2009-03-19 17:06:22 +0100 os r269756 : #i99568# XTolerantMultiPropertySet activated
2009-03-16 11:46:14 +0100 os r269517 : wrong commit to #i97471# removed
2009-03-16 11:36:50 +0100 os r269514 : #i97471# SwDrawTextShell::Init(): mouse double click and key input in group objects at the same time: prevent crash
2009-03-13 11:08:54 +0100 os r269464 : #i99568# static SfxItemPropertySet
2009-03-13 11:03:22 +0100 os r269463 : #i99568# static SfxItemPropertySet
2009-03-11 12:59:27 +0100 os r269320 : #i99568# WhichId of properties handled from ScDocOptionsObj added
2009-03-06 09:09:58 +0100 os r268972 : #i99568# SfxItemPropertySet improvements
2009-03-05 20:54:43 +0100 os r268942 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 20:19:52 +0100 os r268941 : #i99568# SfxItemPropertySet improvements
2009-03-05 20:05:03 +0100 os r268940 : #i99568# SfxItemPropertySet improvements
2009-03-05 18:54:47 +0100 os r268936 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 17:51:38 +0100 os r268931 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 17:33:03 +0100 os r268930 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:53:00 +0100 os r268920 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:52:50 +0100 os r268919 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:50:41 +0100 os r268918 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:41:04 +0100 os r268916 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 15:40:40 +0100 os r268915 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 10:16:20 +0100 os r268881 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-05 10:15:55 +0100 os r268880 : #i99568# Sfx/SvxItemPropertySet improvements
2009-03-03 08:40:09 +0100 os r268704 : ScTableSheetObj::GetItemPropertyMap fixed
2009-03-03 07:50:00 +0100 os r268703 : SfxItemProperty set as pointer
2009-03-03 07:49:46 +0100 os r268702 : SfxItemProperty set as pointer
2009-03-02 08:15:37 +0100 os r268631 : minor fix
2009-03-02 07:58:38 +0100 os r268630 : minor fix
2009-02-27 13:03:25 +0100 os r268584 : exports
2009-02-27 11:17:04 +0100 os r268567 : debug code removed
2009-02-27 11:04:07 +0100 os r268565 : duplicate return removed
2009-02-27 10:17:37 +0100 os r268558 : syntax fixed
2009-02-27 09:56:14 +0100 os r268554 : #i99568# type mix fixed
2009-02-27 09:40:56 +0100 os r268553 : #i99568# exports changes reverted
2009-02-25 12:50:54 +0100 os r268433 : #i99568# SfxItemPropertySet rework
2009-02-25 12:13:39 +0100 os r268432 : #i99568# SfxItemPropertySet rework
2009-02-25 12:12:47 +0100 os r268431 : #i99568# SfxItemPropertySet rework
2009-02-25 12:10:27 +0100 os r268430 : #i99568# SfxItemPropertySet rework
2009-02-25 12:09:36 +0100 os r268429 : #i99568# SfxItemPropertySet rework
2009-02-25 12:07:39 +0100 os r268428 : #i99568# SfxItemPropertySet rework
2009-02-25 11:59:35 +0100 os r268427 : #i99568# SfxItemPropertySet rework
2009-02-25 11:52:52 +0100 os r268425 : #i99568# SfxItemPropertySet rework
2009-02-25 11:49:17 +0100 os r268424 : #i99568# SfxItemPropertySet rework
2009-02-25 11:45:17 +0100 os r268423 : #i99568# SfxItemPropertySet rework
2009-02-11 11:39:04 +0100 os r267587 : #i57008# use registration of index marks at SwUnoCallback
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/xmloff/txtparae.hxx | 61 | ||||
-rw-r--r-- | xmloff/source/core/xmlexp.cxx | 27 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 605 |
3 files changed, 291 insertions, 402 deletions
diff --git a/xmloff/inc/xmloff/txtparae.hxx b/xmloff/inc/xmloff/txtparae.hxx index 36026c9d16..2794f26991 100644 --- a/xmloff/inc/xmloff/txtparae.hxx +++ b/xmloff/inc/xmloff/txtparae.hxx @@ -68,12 +68,17 @@ namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; class XPropertyState; class XPropertySetInfo; } - namespace container { class XEnumeration; class XIndexAccess; } + namespace container { class XEnumerationAccess; class XEnumeration; class XIndexAccess; } namespace text { class XTextContent; class XTextRange; class XText; class XFootnote; class XTextFrame; class XTextSection; class XDocumentIndex; class XTextShapesSupplier; } } } } -namespace xmloff { class OFormLayerXMLExport; } + +namespace xmloff +{ + class OFormLayerXMLExport; + class BoundFrameSets; +} class XMLOFF_DLLPUBLIC XMLTextParagraphExport : public XMLStyleExport { @@ -86,23 +91,8 @@ class XMLOFF_DLLPUBLIC XMLTextParagraphExport : public XMLStyleExport UniReference < SvXMLExportPropertyMapper > xAutoFramePropMapper; UniReference < SvXMLExportPropertyMapper > xSectionPropMapper; UniReference < SvXMLExportPropertyMapper > xRubyPropMapper; - ::com::sun::star::uno::Reference < - ::com::sun::star::container::XIndexAccess > xTextFrames; - ::com::sun::star::uno::Reference < - ::com::sun::star::container::XIndexAccess > xGraphics; - ::com::sun::star::uno::Reference < - ::com::sun::star::container::XIndexAccess > xEmbeddeds; - ::com::sun::star::uno::Reference < - ::com::sun::star::container::XIndexAccess > xShapes; - - SvLongs *pPageTextFrameIdxs; - SvLongs *pPageGraphicIdxs; - SvLongs *pPageEmbeddedIdxs; - SvLongs *pPageShapeIdxs; - SvLongs *pFrameTextFrameIdxs; - SvLongs *pFrameGraphicIdxs; - SvLongs *pFrameEmbeddedIdxs; - SvLongs *pFrameShapeIdxs; + + const ::std::auto_ptr< ::xmloff::BoundFrameSets > pBoundFrameSets; XMLTextFieldExport *pFieldExport; OUStrings_Impl *pListElements; // --> OD 2008-05-07 #refactorlists# - no longer needed @@ -286,8 +276,6 @@ protected: const ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > & rStyle ); - void collectFrames(); - void collectFrames( sal_Bool bBoundToFrameOnly ); void exportPageFrames( sal_Bool bAutoStyles, sal_Bool bProgress ); void exportFrameFrames( sal_Bool bAutoStyles, sal_Bool bProgress, const ::com::sun::star::uno::Reference < @@ -608,35 +596,6 @@ public: bool collectTextAutoStylesOptimized( sal_Bool bIsProgress = sal_False ); - // This method collects all automatic styles that are bound to a page - void collectFrameBoundToPageAutoStyles( sal_Bool bIsProgress = sal_False ) - { - collectFrames(); - exportPageFrames( sal_True, bIsProgress ); - exportFrameFrames( sal_True, bIsProgress ); - } - // This method prepares the collection of auto styles for frames - // that are bound to a frame. - void collectFramesBoundToFrameAutoStyles() - { - collectFrames( sal_True ); - } - // This method prepares the collection of auto styles for frames - // that are bound to a frame and it collects auto styles - // for frames bound to a page. - void collectFramesBoundToPageOrFrameAutoStyles( sal_Bool bIsProgress = sal_False ) - { - collectFrames( sal_False ); - exportPageFrames( sal_True, bIsProgress ); - } - void collectFramesBoundToFrameAutoStyles( - const ::com::sun::star::uno::Reference < - ::com::sun::star::text::XTextFrame >& rParentTxtFrame, - sal_Bool bIsProgress = sal_False ) - { - exportFrameFrames( sal_True, bIsProgress, &rParentTxtFrame ); - } - // This method exports all automatic styles that have been collected. virtual void exportTextAutoStyles(); @@ -712,6 +671,8 @@ public: void PushNewTextListsHelper(); void PopTextListsHelper(); // <-- + private: + XMLTextParagraphExport(XMLTextParagraphExport &); // private copy-ctor because of explicit copy-ctor of auto_ptr }; inline const XMLTextListAutoStylePool& diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index dde9393c5a..83a9984140 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -208,6 +208,7 @@ public: ::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper; uno::Reference< uri::XUriReferenceFactory > mxUriReferenceFactory; rtl::OUString msPackageURI; + rtl::OUString msPackageURIScheme; // --> OD 2006-09-27 #i69627# sal_Bool mbOutlineStyleAsNormalListStyle; // <-- @@ -226,6 +227,13 @@ public: sal_Bool mbExportTextNumberElement; // <-- sal_Bool mbNullDateInitialized; + + void SetSchemeOf( const ::rtl::OUString& rOrigFileName ) + { + sal_Int32 nSep = rOrigFileName.indexOf(':'); + if( nSep != -1 ) + msPackageURIScheme = rOrigFileName.copy( 0, nSep ); + } }; SvXMLExport_Impl::SvXMLExport_Impl() @@ -425,6 +433,7 @@ SvXMLExport::SvXMLExport( msWS( GetXMLToken(XML_WS) ), mbSaveLinkedSections(sal_True) { + mpImpl->SetSchemeOf( msOrigFileName ); DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); _InitCtor(); @@ -464,6 +473,7 @@ SvXMLExport::SvXMLExport( msWS( GetXMLToken(XML_WS) ), mbSaveLinkedSections(sal_True) { + mpImpl->SetSchemeOf( msOrigFileName ); DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); _InitCtor(); @@ -504,6 +514,7 @@ SvXMLExport::SvXMLExport( msWS( GetXMLToken(XML_WS) ), mbSaveLinkedSections(sal_True) { + mpImpl->SetSchemeOf( msOrigFileName ); DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); _InitCtor(); @@ -727,6 +738,7 @@ void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArgumen uno::Any aAny = mxExportInfo->getPropertyValue(sPropName); aAny >>= msOrigFileName; mpImpl->msPackageURI = msOrigFileName; + mpImpl->SetSchemeOf( msOrigFileName ); } OUString sRelPath; sPropName = OUString( RTL_CONSTASCII_USTRINGPARAM("StreamRelPath" ) ); @@ -2112,11 +2124,12 @@ OUString SvXMLExport::GetRelativeReference(const OUString& rValue) OUString sValue( rValue ); // #i65474# handling of fragment URLs ("#....") is undefined // they are stored 'as is' + uno::Reference< uri::XUriReference > xUriRef; if(sValue.getLength() && sValue.getStr()[0] != '#') { try { - uno::Reference< uri::XUriReference > xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue ); + xUriRef = mpImpl->mxUriReferenceFactory->parse( rValue ); if( xUriRef.is() && !xUriRef->isAbsolute() ) { //#i61943# relative URLs need special handling @@ -2129,7 +2142,17 @@ OUString SvXMLExport::GetRelativeReference(const OUString& rValue) { } } - return URIHelper::simpleNormalizedMakeRelative(msOrigFileName, sValue); + OUString sRet = sValue; + if( xUriRef.is() )//no conversion for empty values or for fragments + { + //conversion for matching schemes only + if( xUriRef->getScheme() == mpImpl->msPackageURIScheme ) + { + sValue = INetURLObject::GetRelURL( msOrigFileName, sValue, + INetURLObject::WAS_ENCODED, INetURLObject::DECODE_TO_IURI, RTL_TEXTENCODING_UTF8, INetURLObject::FSYS_DETECT); + } + } + return sValue; } void SvXMLExport::StartElement(sal_uInt16 nPrefix, diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 3bd72cfef6..559a578d2d 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -40,7 +40,8 @@ #include <rtl/ustrbuf.hxx> #include <vector> - +#include <list> +#include <hash_map> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> @@ -147,8 +148,123 @@ using namespace ::com::sun::star::util; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::document; using namespace ::com::sun::star::frame; +using namespace ::xmloff; using namespace ::xmloff::token; +namespace +{ + class TextContentSet + { + public: + typedef Reference<XTextContent> text_content_ref_t; + typedef list<text_content_ref_t> contents_t; + typedef back_insert_iterator<contents_t> inserter_t; + typedef contents_t::const_iterator const_iterator_t; + + inserter_t getInserter() + { return back_insert_iterator<contents_t>(m_vTextContents); }; + const_iterator_t getBegin() const + { return m_vTextContents.begin(); }; + const_iterator_t getEnd() const + { return m_vTextContents.end(); }; + + private: + contents_t m_vTextContents; + }; + + struct FrameRefHash + : public unary_function<Reference<XTextFrame>, size_t> + { + size_t operator()(const Reference<XTextFrame> xFrame) const + { return reinterpret_cast<sal_Int32>(xFrame.get()) & 0xffffffff; } + }; + + static bool lcl_TextContentsUnfiltered(const Reference<XTextContent>&) + { return true; }; + + static bool lcl_ShapeFilter(const Reference<XTextContent>& xTxtContent) + { + static const OUString sTextFrameService = OUString::createFromAscii("com.sun.star.text.TextFrame"); + static const OUString sTextGraphicService = OUString::createFromAscii("com.sun.star.text.TextGraphicObject"); + static const OUString sTextEmbeddedService = OUString::createFromAscii("com.sun.star.text.TextEmbeddedObject"); + Reference<XShape> xShape(xTxtContent, UNO_QUERY); + if(!xShape.is()) + return false; + Reference<XServiceInfo> xServiceInfo(xTxtContent, UNO_QUERY); + if(xServiceInfo->supportsService(sTextFrameService) || + xServiceInfo->supportsService(sTextGraphicService) || + xServiceInfo->supportsService(sTextEmbeddedService) ) + return false; + return true; + }; + + class BoundFrames + { + public: + typedef bool (*filter_t)(const Reference<XTextContent>&); + BoundFrames( + const Reference<XEnumerationAccess> xEnumAccess, + const filter_t& rFilter) + : m_xEnumAccess(xEnumAccess) + { + Fill(rFilter); + }; + BoundFrames() + {}; + const TextContentSet* GetPageBoundContents() const + { return &m_vPageBounds; }; + const TextContentSet* GetFrameBoundContents(const Reference<XTextFrame>& rParentFrame) const + { + framebound_map_t::const_iterator it = m_vFrameBoundsOf.find(rParentFrame); + if(it == m_vFrameBoundsOf.end()) + return NULL; + return &(it->second); + }; + Reference<XEnumeration> createEnumeration() const + { + if(!m_xEnumAccess.is()) + return Reference<XEnumeration>(); + return m_xEnumAccess->createEnumeration(); + }; + + private: + typedef hash_map< + Reference<XTextFrame>, + TextContentSet, + FrameRefHash> framebound_map_t; + TextContentSet m_vPageBounds; + framebound_map_t m_vFrameBoundsOf; + const Reference<XEnumerationAccess> m_xEnumAccess; + void Fill(const filter_t& rFilter); + static const OUString our_sAnchorType; + static const OUString our_sAnchorFrame; + }; + const OUString BoundFrames::our_sAnchorType = OUString::createFromAscii("AnchorType"); + const OUString BoundFrames::our_sAnchorFrame = OUString::createFromAscii("AnchorFrame"); + +} + +namespace xmloff +{ + class BoundFrameSets + { + public: + BoundFrameSets(const Reference<XInterface> xModel); + const BoundFrames* GetTexts() const + { return m_pTexts.get(); }; + const BoundFrames* GetGraphics() const + { return m_pGraphics.get(); }; + const BoundFrames* GetEmbeddeds() const + { return m_pEmbeddeds.get(); }; + const BoundFrames* GetShapes() const + { return m_pShapes.get(); }; + private: + auto_ptr<BoundFrames> m_pTexts; + auto_ptr<BoundFrames> m_pGraphics; + auto_ptr<BoundFrames> m_pEmbeddeds; + auto_ptr<BoundFrames> m_pShapes; + }; +} typedef OUString *OUStringPtr; SV_DECL_PTRARR_DEL( OUStrings_Impl, OUStringPtr, 20, 10 ) @@ -221,6 +337,66 @@ enum eParagraphPropertyNamesEnum TEXT_SECTION = 5 }; +void BoundFrames::Fill(const filter_t& rFilter) +{ + if(!m_xEnumAccess.is()) + return; + const Reference< XEnumeration > xEnum = m_xEnumAccess->createEnumeration(); + if(!xEnum.is()) + return; + while(xEnum->hasMoreElements()) + { + Reference<XPropertySet> xPropSet(xEnum->nextElement(), UNO_QUERY); + Reference<XTextContent> xTextContent(xPropSet, UNO_QUERY); + if(!xPropSet.is() || !xTextContent.is()) + continue; + TextContentAnchorType eAnchor; + xPropSet->getPropertyValue(our_sAnchorType) >>= eAnchor; + if(TextContentAnchorType_AT_PAGE != eAnchor && TextContentAnchorType_AT_FRAME != eAnchor) + continue; + if(!rFilter(xTextContent)) + continue; + + TextContentSet::inserter_t pInserter = m_vPageBounds.getInserter(); + if(TextContentAnchorType_AT_FRAME == eAnchor) + { + Reference<XTextFrame> xAnchorTxtFrame( + xPropSet->getPropertyValue(our_sAnchorFrame), + uno::UNO_QUERY); + pInserter = m_vFrameBoundsOf[xAnchorTxtFrame].getInserter(); + } + *pInserter++ = xTextContent; + } +} + +BoundFrameSets::BoundFrameSets(const Reference<XInterface> xModel) + : m_pTexts(new BoundFrames()) + , m_pGraphics(new BoundFrames()) + , m_pEmbeddeds(new BoundFrames()) + , m_pShapes(new BoundFrames()) +{ + const Reference<XTextFramesSupplier> xTFS(xModel, UNO_QUERY); + const Reference<XTextGraphicObjectsSupplier> xGOS(xModel, UNO_QUERY); + const Reference<XTextEmbeddedObjectsSupplier> xEOS(xModel, UNO_QUERY); + const Reference<XDrawPageSupplier> xDPS(xModel, UNO_QUERY); + if(xTFS.is()) + m_pTexts = auto_ptr<BoundFrames>(new BoundFrames( + Reference<XEnumerationAccess>(xTFS->getTextFrames(), UNO_QUERY), + &lcl_TextContentsUnfiltered)); + if(xGOS.is()) + m_pGraphics = auto_ptr<BoundFrames>(new BoundFrames( + Reference<XEnumerationAccess>(xGOS->getGraphicObjects(), UNO_QUERY), + &lcl_TextContentsUnfiltered)); + if(xEOS.is()) + m_pEmbeddeds = auto_ptr<BoundFrames>(new BoundFrames( + Reference<XEnumerationAccess>(xEOS->getEmbeddedObjects(), UNO_QUERY), + &lcl_TextContentsUnfiltered)); + if(xDPS.is()) + m_pShapes = auto_ptr<BoundFrames>(new BoundFrames( + Reference<XEnumerationAccess>(xDPS->getDrawPage(), UNO_QUERY), + &lcl_ShapeFilter)); +}; + void XMLTextParagraphExport::Add( sal_uInt16 nFamily, const Reference < XPropertySet > & rPropSet, const XMLPropertyState** ppAddStates, bool bDontSeek ) @@ -931,15 +1107,7 @@ XMLTextParagraphExport::XMLTextParagraphExport( ) : XMLStyleExport( rExp, OUString(), &rASP ), rAutoStylePool( rASP ), - - pPageTextFrameIdxs( 0 ), - pPageGraphicIdxs( 0 ), - pPageEmbeddedIdxs( 0 ), - pPageShapeIdxs( 0 ), - pFrameTextFrameIdxs( 0 ), - pFrameGraphicIdxs( 0 ), - pFrameEmbeddedIdxs( 0 ), - pFrameShapeIdxs( 0 ), + pBoundFrameSets(new BoundFrameSets(GetExport().GetModel())), pFieldExport( 0 ), pListElements( 0 ), // --> OD 2008-05-07 #refactorlists# - no longer needed @@ -1124,14 +1292,6 @@ XMLTextParagraphExport::~XMLTextParagraphExport() // delete pExportedLists; // <-- delete pListAutoPool; - delete pPageTextFrameIdxs; - delete pPageGraphicIdxs; - delete pPageEmbeddedIdxs; - delete pPageShapeIdxs; - delete pFrameTextFrameIdxs; - delete pFrameGraphicIdxs; - delete pFrameEmbeddedIdxs; - delete pFrameShapeIdxs; #ifndef PRODUCT txtparae_bContainsIllegalCharacters = sal_False; #endif @@ -1175,207 +1335,29 @@ SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaDefaultExtPropMappe return new XMLTextExportPropertySetMapper( pPropMapper, rExport ); } -void XMLTextParagraphExport::collectFrames() -{ - collectFrames( sal_False ); -} - -void XMLTextParagraphExport::collectFrames( sal_Bool bBoundToFrameOnly ) -{ - Reference < XTextFramesSupplier > xTFS( GetExport().GetModel(), UNO_QUERY ); - if( xTFS.is() ) - { - xTextFrames.set( xTFS->getTextFrames(), uno::UNO_QUERY); - sal_Int32 nCount = xTextFrames->getCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - Reference < XPropertySet > xPropSet( xTextFrames->getByIndex( i ), UNO_QUERY ); - - TextContentAnchorType eAnchor; - xPropSet->getPropertyValue( sAnchorType ) >>= eAnchor; - - switch( eAnchor ) - { - case TextContentAnchorType_AT_PAGE: - if( !bBoundToFrameOnly ) - { - if( !pPageTextFrameIdxs ) - pPageTextFrameIdxs = new SvLongs; - pPageTextFrameIdxs->Insert( i, pPageTextFrameIdxs->Count() ); - } - break; - case TextContentAnchorType_AT_FRAME: - if( !pFrameTextFrameIdxs ) - pFrameTextFrameIdxs = new SvLongs; - pFrameTextFrameIdxs->Insert( i, pFrameTextFrameIdxs->Count() ); - break; - default: - break; - } - } - } - - Reference < XTextGraphicObjectsSupplier > xTGOS( GetExport().GetModel(), - UNO_QUERY ); - if( xTGOS.is() ) - { - xGraphics.set( xTGOS->getGraphicObjects(), - UNO_QUERY ); - sal_Int32 nCount = xGraphics->getCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - Reference < XPropertySet > xPropSet( xGraphics->getByIndex( i ), UNO_QUERY ); - - TextContentAnchorType eAnchor; - xPropSet->getPropertyValue( sAnchorType ) >>= eAnchor; - - switch( eAnchor ) - { - case TextContentAnchorType_AT_PAGE: - if( !bBoundToFrameOnly ) - { - if( !pPageGraphicIdxs ) - pPageGraphicIdxs = new SvLongs; - pPageGraphicIdxs->Insert( i, pPageGraphicIdxs->Count() ); - } - break; - case TextContentAnchorType_AT_FRAME: - if( !pFrameGraphicIdxs ) - pFrameGraphicIdxs = new SvLongs; - pFrameGraphicIdxs->Insert( i, pFrameGraphicIdxs->Count() ); - break; - default: - break; - } - } - } - - Reference < XTextEmbeddedObjectsSupplier > xTEOS( GetExport().GetModel(), - UNO_QUERY ); - if( xTEOS.is() ) - { - xEmbeddeds = Reference < XIndexAccess >( xTEOS->getEmbeddedObjects(), - UNO_QUERY ); - sal_Int32 nCount = xEmbeddeds->getCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - Reference < XPropertySet > xPropSet( xEmbeddeds->getByIndex( i ), UNO_QUERY ); - - TextContentAnchorType eAnchor; - xPropSet->getPropertyValue( sAnchorType ) >>= eAnchor; - - switch( eAnchor ) - { - case TextContentAnchorType_AT_PAGE: - if( !bBoundToFrameOnly ) - { - if( !pPageEmbeddedIdxs ) - pPageEmbeddedIdxs = new SvLongs; - pPageEmbeddedIdxs->Insert( i, pPageEmbeddedIdxs->Count() ); - } - break; - case TextContentAnchorType_AT_FRAME: - if( !pFrameEmbeddedIdxs ) - pFrameEmbeddedIdxs = new SvLongs; - pFrameEmbeddedIdxs->Insert( i, pFrameEmbeddedIdxs->Count() ); - break; - default: - break; - } - } - } - - Reference < XDrawPageSupplier > xDPS( GetExport().GetModel(), - UNO_QUERY ); - if( xDPS.is() ) - { - xShapes = Reference < XIndexAccess >( xDPS->getDrawPage(), - UNO_QUERY ); - sal_Int32 nCount = xShapes->getCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - Reference < XShape > xShape(xShapes->getByIndex( i ), uno::UNO_QUERY); - if( !xShape.is() ) - continue; - - Reference < XPropertySet > xPropSet( xShape, UNO_QUERY ); - - TextContentAnchorType eAnchor; - xPropSet->getPropertyValue( sAnchorType ) >>= eAnchor; - - if( (TextContentAnchorType_AT_PAGE != eAnchor && - TextContentAnchorType_AT_FRAME != eAnchor) || - (TextContentAnchorType_AT_PAGE == eAnchor && - bBoundToFrameOnly ) ) - continue; - - Reference<XServiceInfo> xServiceInfo( xShape, - UNO_QUERY ); - if( xServiceInfo->supportsService( sTextFrameService ) || - xServiceInfo->supportsService( sTextGraphicService ) || - xServiceInfo->supportsService( sTextEmbeddedService ) ) - continue; - - if( TextContentAnchorType_AT_PAGE == eAnchor ) - { - if( !pPageShapeIdxs ) - pPageShapeIdxs = new SvLongs; - pPageShapeIdxs->Insert( i, pPageShapeIdxs->Count() ); - } - else - { - if( !pFrameShapeIdxs ) - pFrameShapeIdxs = new SvLongs; - pFrameShapeIdxs->Insert( i, pFrameShapeIdxs->Count() ); - } - } - } -} - void XMLTextParagraphExport::exportPageFrames( sal_Bool bAutoStyles, sal_Bool bIsProgress ) { - if( pPageTextFrameIdxs ) - { - for( sal_uInt16 i = 0; i < pPageTextFrameIdxs->Count(); i++ ) - { - Reference < XTextContent > xTxtCntnt( xTextFrames->getByIndex( (*pPageTextFrameIdxs)[i] ), UNO_QUERY ); - exportTextFrame( xTxtCntnt, bAutoStyles, bIsProgress, sal_True ); - } - } - if( pPageGraphicIdxs ) - { - for( sal_uInt16 i = 0; i < pPageGraphicIdxs->Count(); i++ ) - { - Reference < XTextContent > xTxtCntnt(xGraphics->getByIndex( (*pPageGraphicIdxs)[i] ), uno::UNO_QUERY); - exportTextGraphic( xTxtCntnt, bAutoStyles ); - } - } - if( pPageEmbeddedIdxs ) - { - for( sal_uInt16 i = 0; i < pPageEmbeddedIdxs->Count(); i++ ) - { - Reference < XTextContent > xTxtCntnt(xEmbeddeds->getByIndex( (*pPageEmbeddedIdxs)[i] ), uno::UNO_QUERY); - exportTextEmbedded( xTxtCntnt, bAutoStyles ); - } - } - if( pPageShapeIdxs ) - { - for( sal_uInt16 i = 0; i < pPageShapeIdxs->Count(); i++ ) - { - Reference < XTextContent > xTxtCntnt( xShapes->getByIndex( (*pPageShapeIdxs)[i] ), UNO_QUERY ); - exportShape( xTxtCntnt, bAutoStyles ); - } - } -} - -sal_Bool lcl_txtpara_isFrameAnchor( - const Reference < XPropertySet > rPropSet, - const Reference < XTextFrame >& rParentTxtFrame ) -{ - Reference < XTextFrame > xAnchorTxtFrame(rPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorFrame") ) ), uno::UNO_QUERY); - - return xAnchorTxtFrame == rParentTxtFrame; + const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetPageBoundContents(); + const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetPageBoundContents(); + const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetPageBoundContents(); + const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetPageBoundContents(); + for(TextContentSet::const_iterator_t it = pTexts->getBegin(); + it != pTexts->getEnd(); + ++it) + exportTextFrame(*it, bAutoStyles, bIsProgress, sal_True); + for(TextContentSet::const_iterator_t it = pGraphics->getBegin(); + it != pGraphics->getEnd(); + ++it) + exportTextGraphic(*it, bAutoStyles); + for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin(); + it != pEmbeddeds->getEnd(); + ++it) + exportTextEmbedded(*it, bAutoStyles); + for(TextContentSet::const_iterator_t it = pShapes->getBegin(); + it != pShapes->getEnd(); + ++it) + exportShape(*it, bAutoStyles); } void XMLTextParagraphExport::exportFrameFrames( @@ -1383,97 +1365,30 @@ void XMLTextParagraphExport::exportFrameFrames( sal_Bool bIsProgress, const Reference < XTextFrame > *pParentTxtFrame ) { - if( pFrameTextFrameIdxs && pFrameTextFrameIdxs->Count() ) - { - sal_uInt16 i = 0; - while( i < pFrameTextFrameIdxs->Count() ) - { - Reference < XPropertySet > xPropSet( xTextFrames->getByIndex( (*pFrameTextFrameIdxs)[i] ), UNO_QUERY ); - if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) ) - { - if( !bAutoStyles ) - pFrameTextFrameIdxs->Remove( i ); - sal_uInt16 nOldCount = pFrameTextFrameIdxs->Count(); - Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY ); - exportTextFrame( xTxtCntnt, bAutoStyles, bIsProgress, sal_True ); - if( bAutoStyles ) - i++; - else if( pFrameTextFrameIdxs->Count() != nOldCount ) - i = 0; - } - else - i++; - } - } - if( pFrameGraphicIdxs && pFrameGraphicIdxs->Count() ) - { - Any aAny; - sal_uInt16 i = 0; - while( i < pFrameGraphicIdxs->Count() ) - { - Reference < XPropertySet > xPropSet( xGraphics->getByIndex( (*pFrameGraphicIdxs)[i] ), UNO_QUERY ); - if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) ) - { - if( !bAutoStyles ) - pFrameGraphicIdxs->Remove( i ); - sal_uInt16 nOldCount = pFrameGraphicIdxs->Count(); - Reference < XTextContent > xTxtCntnt(xPropSet, uno::UNO_QUERY); - exportTextGraphic( xTxtCntnt, bAutoStyles ); - if( bAutoStyles ) - i++; - else if( pFrameGraphicIdxs->Count() != nOldCount ) - i = 0; - } - else - i++; - } - } - if( pFrameEmbeddedIdxs && pFrameEmbeddedIdxs->Count() ) - { - Any aAny; - sal_uInt16 i = 0; - while( i < pFrameEmbeddedIdxs->Count() ) - { - Reference < XPropertySet > xPropSet( xEmbeddeds->getByIndex( (*pFrameEmbeddedIdxs)[i] ), UNO_QUERY ); - if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) ) - { - if( !bAutoStyles ) - pFrameEmbeddedIdxs->Remove( i ); - sal_uInt16 nOldCount = pFrameEmbeddedIdxs->Count(); - Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY ); - exportTextEmbedded( xTxtCntnt, bAutoStyles ); - if( bAutoStyles ) - i++; - else if( pFrameEmbeddedIdxs->Count() != nOldCount ) - i = 0; - } - else - i++; - } - } - if( pFrameShapeIdxs && pFrameShapeIdxs->Count() ) - { - Any aAny; - sal_uInt16 i = 0; - while( i < pFrameShapeIdxs->Count() ) - { - Reference < XPropertySet > xPropSet( xShapes->getByIndex( (*pFrameShapeIdxs)[i] ), UNO_QUERY ); - if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) ) - { - if( !bAutoStyles ) - pFrameShapeIdxs->Remove( i ); - sal_uInt16 nOldCount = pFrameShapeIdxs->Count(); - Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY ); - exportShape( xTxtCntnt, bAutoStyles ); - if( bAutoStyles ) - i++; - else if( pFrameShapeIdxs->Count() != nOldCount ) - i = 0; - } - else - i++; - } - } + const TextContentSet* const pTexts = pBoundFrameSets->GetTexts()->GetFrameBoundContents(*pParentTxtFrame); + if(pTexts) + for(TextContentSet::const_iterator_t it = pTexts->getBegin(); + it != pTexts->getEnd(); + ++it) + exportTextFrame(*it, bAutoStyles, bIsProgress, sal_True); + const TextContentSet* const pGraphics = pBoundFrameSets->GetGraphics()->GetFrameBoundContents(*pParentTxtFrame); + if(pGraphics) + for(TextContentSet::const_iterator_t it = pGraphics->getBegin(); + it != pGraphics->getEnd(); + ++it) + exportTextGraphic(*it, bAutoStyles); + const TextContentSet* const pEmbeddeds = pBoundFrameSets->GetEmbeddeds()->GetFrameBoundContents(*pParentTxtFrame); + if(pEmbeddeds) + for(TextContentSet::const_iterator_t it = pEmbeddeds->getBegin(); + it != pEmbeddeds->getEnd(); + ++it) + exportTextEmbedded(*it, bAutoStyles); + const TextContentSet* const pShapes = pBoundFrameSets->GetShapes()->GetFrameBoundContents(*pParentTxtFrame); + if(pShapes) + for(TextContentSet::const_iterator_t it = pShapes->getBegin(); + it != pShapes->getEnd(); + ++it) + exportShape(*it, bAutoStyles); } // bookmarks, reference marks (and TOC marks) are the same except for the @@ -1562,62 +1477,50 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgres } // Export text frames: - sal_Int32 nCount = 0; - if ( xTextFrames.is() ) - { - nCount = xTextFrames->getCount(); - for( sal_Int32 i = 0; i < nCount; ++i ) + Reference<XEnumeration> xTextFramesEnum = pBoundFrameSets->GetTexts()->createEnumeration(); + if(xTextFramesEnum.is()) + while(xTextFramesEnum->hasMoreElements()) { - Any aAny = xTextFrames->getByIndex( i ); - Reference < XTextContent > xTxtCntnt( aAny, UNO_QUERY ); - if ( xTxtCntnt.is() ) - exportTextFrame( xTxtCntnt, bAutoStyles, bIsProgress, bExportContent, 0 ); + Reference<XTextContent> xTxtCntnt(xTextFramesEnum->nextElement(), UNO_QUERY); + if(xTxtCntnt.is()) + exportTextFrame(xTxtCntnt, bAutoStyles, bIsProgress, bExportContent, 0); } - } // Export graphic objects: - if ( xGraphics.is() ) - { - nCount = xGraphics->getCount(); - for( sal_Int32 i = 0; i < nCount; ++i ) + Reference<XEnumeration> xGraphicsEnum = pBoundFrameSets->GetGraphics()->createEnumeration(); + if(xGraphicsEnum.is()) + while(xGraphicsEnum->hasMoreElements()) { - Any aAny = xGraphics->getByIndex( i ); - Reference < XTextContent > xTxtCntnt( aAny, UNO_QUERY ); - if ( xTxtCntnt.is() ) - exportTextGraphic( xTxtCntnt, sal_True, 0 ); + Reference<XTextContent> xTxtCntnt(xGraphicsEnum->nextElement(), UNO_QUERY); + if(xTxtCntnt.is()) + exportTextGraphic(xTxtCntnt, true, 0); } - } // Export embedded objects: - if ( xEmbeddeds.is() ) - { - nCount = xEmbeddeds->getCount(); - for( sal_Int32 i = 0; i < nCount; ++i ) + Reference<XEnumeration> xEmbeddedsEnum = pBoundFrameSets->GetEmbeddeds()->createEnumeration(); + if(xEmbeddedsEnum.is()) + while(xEmbeddedsEnum->hasMoreElements()) { - Any aAny = xEmbeddeds->getByIndex( i ); - Reference < XTextContent > xTxtCntnt( aAny, UNO_QUERY ); - if ( xTxtCntnt.is() ) - exportTextEmbedded( xTxtCntnt, sal_True, 0 ); + Reference<XTextContent> xTxtCntnt(xEmbeddedsEnum->nextElement(), UNO_QUERY); + if(xTxtCntnt.is()) + exportTextEmbedded(xTxtCntnt, true, 0); } - } // Export shapes: - if ( xShapes.is() ) - { - nCount = xShapes->getCount(); - for( sal_Int32 i = 0; i < nCount; ++i ) + Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration(); + if(xShapesEnum.is()) + while(xShapesEnum->hasMoreElements()) { - Any aAny( xShapes->getByIndex( i ) ); - Reference < XTextContent > xTxtCntnt( aAny, UNO_QUERY ); - if ( xTxtCntnt.is() ) + Reference<XTextContent> xTxtCntnt(xShapesEnum->nextElement(), UNO_QUERY); + if(xTxtCntnt.is()) { - Reference<XServiceInfo> xServiceInfo( xTxtCntnt, UNO_QUERY ); - if( xServiceInfo->supportsService( sShapeService ) ) - exportShape( xTxtCntnt, sal_True, 0 ); + Reference<XServiceInfo> xServiceInfo(xTxtCntnt, UNO_QUERY); + if( xServiceInfo->supportsService(sShapeService)) + exportShape(xTxtCntnt, true, 0); } } - } + sal_Int32 nCount; // AutoStyles for sections Reference< XTextSectionsSupplier > xSectionsSupp( GetExport().GetModel(), UNO_QUERY ); if ( xSectionsSupp.is() ) @@ -2739,7 +2642,7 @@ void XMLTextParagraphExport::exportAnyTextFrame( { Reference < XTextFrame > xTxtFrame( rTxtCntnt, UNO_QUERY ); Reference < XText > xTxt(xTxtFrame->getText()); - collectFramesBoundToFrameAutoStyles( xTxtFrame, bIsProgress ); + exportFrameFrames( sal_True, bIsProgress, &xTxtFrame ); exportText( xTxt, bAutoStyles, bIsProgress, sal_True ); } } @@ -3745,8 +3648,10 @@ void XMLTextParagraphExport::PreventExportOfControlsInMuteSections( } DBG_ASSERT( pSectionExport != NULL, "We need the section export." ); - sal_Int32 nShapes = xShapes->getCount(); - for( sal_Int32 i = 0; i < nShapes; i++ ) + Reference<XEnumeration> xShapesEnum = pBoundFrameSets->GetShapes()->createEnumeration(); + if(!xShapesEnum.is()) + return; + while( xShapesEnum->hasMoreElements() ) { // now we need to check // 1) if this is a control shape, and @@ -3754,7 +3659,7 @@ void XMLTextParagraphExport::PreventExportOfControlsInMuteSections( // if both answers are 'yes', notify the form layer export // we join accessing the shape and testing for control - Reference<XControlShape> xControlShape(xShapes->getByIndex( i ), uno::UNO_QUERY); + Reference<XControlShape> xControlShape(xShapesEnum->nextElement(), UNO_QUERY); if( xControlShape.is() ) { // Reference<XPropertySet> xPropSet( xControlShape, UNO_QUERY ); |