/binfilter/bf_xmloff/source/text/xmloff_txtparae.cxx
C++ | 3054 lines | 2554 code | 291 blank | 209 comment | 393 complexity | 9eaf98ef9bd2f1643d84b74de1493e2f MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, AGPL-1.0, BSD-3-Clause-No-Nuclear-License-2014, GPL-3.0, GPL-2.0, BSD-3-Clause, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- /*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
- #ifndef _SVSTDARR_LONGS_DECL
- #define _SVSTDARR_LONGS
- #include <bf_svtools/svstdarr.hxx>
- #endif
- #include <vector>
- #ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
- #include <com/sun/star/container/XEnumerationAccess.hpp>
- #endif
- #ifndef _COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HPP_
- #include <com/sun/star/beans/XMultiPropertySet.hpp>
- #endif
- #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
- #include <com/sun/star/beans/XPropertyState.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_XTEXTFIELD_HPP_
- #include <com/sun/star/text/XTextField.hpp>
- #endif
- #ifndef _COM_SUN_STAR_CONTAINER_XCONTENTENUMERATIONACCESS_HPP_
- #include <com/sun/star/container/XContentEnumerationAccess.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_XTEXTFRAME_HPP_
- #include <com/sun/star/text/XTextFrame.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_SIZETYPE_HPP_
- #include <com/sun/star/text/SizeType.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_HORIORIENTATION_HPP_
- #include <com/sun/star/text/HoriOrientation.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_VERTORIENTATION_HPP_
- #include <com/sun/star/text/VertOrientation.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_XTEXTFRAMESSUPPLIER_HPP_
- #include <com/sun/star/text/XTextFramesSupplier.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_XTEXTGRAPHICOBJECTSSUPPLIER_HPP_
- #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_XTEXTEMBEDDEDOBJECTSSUPPLIER_HPP_
- #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
- #endif
- #ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESUPPLIER_HPP_
- #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
- #endif
- #ifndef _COM_SUN_STAR_DOCUMENT_XEMBEDDEDOBJECTSUPPLIER_HPP_
- #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
- #endif
- #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_
- #include <com/sun/star/document/XEventsSupplier.hpp>
- #endif
- #ifndef _COM_SUN_STAR_TEXT_XTEXTSECTION_HPP_
- #include <com/sun/star/text/XTextSection.hpp>
- #endif
- #ifndef _COM_SUN_STAR_DRAWING_XCONTROLSHAPE_HPP_
- #include <com/sun/star/drawing/XControlShape.hpp>
- #endif
- #ifndef _XMLOFF_TXTEXPPR_HXX
- #include "txtexppr.hxx"
- #endif
- #ifndef _XMLOFF_XMLUCONV_HXX
- #include "xmluconv.hxx"
- #endif
- #ifndef _XMLOFF_XMLANCHORTYPEPROPHDL_HXX
- #include "XMLAnchorTypePropHdl.hxx"
- #endif
- #ifndef _XEXPTRANSFORM_HXX
- #include "xexptran.hxx"
- #endif
- #ifndef _XMLOFF_NMSPMAP_HXX
- #include "nmspmap.hxx"
- #endif
- #ifndef _XMLOFF_XMLEXP_HXX
- #include "xmlexp.hxx"
- #endif
- #ifndef _XMLOFF_TXTFLDE_HXX
- #include "txtflde.hxx"
- #endif
- #ifndef _XMLOFF_TXTPRMAP_HXX
- #include "txtprmap.hxx"
- #endif
- #ifndef _XMLOFF_XMLIMAGEMAPEXPORT_HXX_
- #include "XMLImageMapExport.hxx"
- #endif
- #ifndef _XMLOFF_XMLTEXTNUMRULEINFO_HXX
- #include "XMLTextNumRuleInfo.hxx"
- #endif
- #ifndef _XMLOFF_XMLTEXTLISTAUTOSTYLEPOOL_HXX
- #include "XMLTextListAutoStylePool.hxx"
- #endif
- #ifndef _XMLOFF_XMLSECTIONEXPORT_HXX_
- #include "XMLSectionExport.hxx"
- #endif
- #ifndef _XMLOFF_XMLINDEXMARKEXPORT_HXX_
- #include "XMLIndexMarkExport.hxx"
- #endif
- #ifndef _XMLOFF_XMLEVENTEXPORT_HXX
- #include "XMLEventExport.hxx"
- #endif
- #ifndef _XMLOFF_XMLREDLINEEXPORT_HXX
- #include "XMLRedlineExport.hxx"
- #endif
- #ifndef _XMLOFF_MULTIPROPERTYSETHELPER_HXX
- #include "MultiPropertySetHelper.hxx"
- #endif
- #ifndef _XMLOFF_XMLTEXTCHARSTYLENAMESELEMENTEXPORT_HXX
- #include "XMLTextCharStyleNamesElementExport.hxx"
- #endif
- namespace binfilter {
- using namespace ::rtl;
- using namespace ::std;
- using namespace ::com::sun::star;
- using namespace ::com::sun::star::uno;
- using namespace ::com::sun::star::lang;
- using namespace ::com::sun::star::beans;
- using namespace ::com::sun::star::container;
- using namespace ::com::sun::star::text;
- 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 ::binfilter::xmloff::token;
- typedef OUString *OUStringPtr;
- SV_DECL_PTRARR_DEL( OUStrings_Impl, OUStringPtr, 20, 10 )
- SV_IMPL_PTRARR( OUStrings_Impl, OUStringPtr )
- SV_DECL_PTRARR_SORT_DEL( OUStringsSort_Impl, OUStringPtr, 20, 10 )
- SV_IMPL_OP_PTRARR_SORT( OUStringsSort_Impl, OUStringPtr )
- #ifdef DBG_UTIL
- static int txtparae_bContainsIllegalCharacters = sal_False;
- #endif
- // The following map shows which property values are required:
- //
- // property auto style pass export
- // --------------------------------------------------------
- // ParaStyleName if style exists always
- // ParaConditionalStyleName if style exists always
- // NumberingRules if style exists always
- // TextSection always always
- // ParaChapterNumberingLevel never always
- // The conclusion is that for auto styles the first three properties
- // should be queried using a multi property set if, and only if, an
- // auto style needs to be exported. TextSection should be queried by
- // an individual call to getPropertyvalue, because this seems to be
- // less expensive than querying the first three properties if they aren't
- // required.
- // For the export pass all properties can be queried using a multi property
- // set.
- static const sal_Char* aParagraphPropertyNamesAuto[] =
- {
- "NumberingRules",
- "ParaConditionalStyleName",
- "ParaStyleName",
- NULL
- };
- enum eParagraphPropertyNamesEnumAuto
- {
- NUMBERING_RULES_AUTO = 0,
- PARA_CONDITIONAL_STYLE_NAME_AUTO = 1,
- PARA_STYLE_NAME_AUTO = 2
- };
- static const sal_Char* aParagraphPropertyNames[] =
- {
- "ParaChapterNumberingLevel",
- "ParaConditionalStyleName",
- "ParaStyleName",
- "TextSection",
- NULL
- };
- enum eParagraphPropertyNamesEnum
- {
- PARA_CHAPTER_NUMERBING_LEVEL = 0,
- PARA_CONDITIONAL_STYLE_NAME = 1,
- PARA_STYLE_NAME = 2,
- TEXT_SECTION = 3
- };
- void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
- const Reference < XPropertySet > & rPropSet,
- const XMLPropertyState** ppAddStates)
- {
- UniReference < SvXMLExportPropertyMapper > xPropMapper;
- switch( nFamily )
- {
- case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
- xPropMapper = GetParaPropMapper();
- break;
- case XML_STYLE_FAMILY_TEXT_TEXT:
- xPropMapper = GetTextPropMapper();
- break;
- case XML_STYLE_FAMILY_TEXT_FRAME:
- xPropMapper = GetAutoFramePropMapper();
- break;
- case XML_STYLE_FAMILY_TEXT_SECTION:
- xPropMapper = GetSectionPropMapper();
- break;
- case XML_STYLE_FAMILY_TEXT_RUBY:
- xPropMapper = GetRubyPropMapper();
- break;
- }
- DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
- vector< XMLPropertyState > xPropStates =
- xPropMapper->Filter( rPropSet );
- if( ppAddStates )
- {
- while( *ppAddStates )
- {
- xPropStates.push_back( **ppAddStates );
- ppAddStates++;
- }
- }
- if( xPropStates.size() > 0L )
- {
- Reference< XPropertySetInfo > xPropSetInfo =
- rPropSet->getPropertySetInfo();
- OUString sParent, sCondParent;
- Any aAny;
- sal_uInt16 nIgnoreProps = 0;
- switch( nFamily )
- {
- case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
- if( xPropSetInfo->hasPropertyByName( sParaStyleName ) )
- {
- aAny = rPropSet->getPropertyValue( sParaStyleName );
- aAny >>= sParent;
- }
- if( xPropSetInfo->hasPropertyByName( sParaConditionalStyleName ) )
- {
- aAny = rPropSet->getPropertyValue( sParaConditionalStyleName );
- aAny >>= sCondParent;
- }
- if( xPropSetInfo->hasPropertyByName( sNumberingRules ) )
- {
- aAny = rPropSet->getPropertyValue( sNumberingRules );
- Reference < XIndexReplace > xNumRule;
- aAny >>= xNumRule;
- if( xNumRule.is() && xNumRule->getCount() )
- {
- Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
- OUString sName;
- if( xNamed.is() )
- sName = xNamed->getName();
- sal_Bool bAdd = !sName.getLength();
- if( !bAdd )
- {
- Reference < XPropertySet > xNumPropSet( xNumRule,
- UNO_QUERY );
- OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
- if( xNumPropSet.is() &&
- xNumPropSet->getPropertySetInfo()
- ->hasPropertyByName( sIsAutomatic ) )
- {
- aAny = xNumPropSet->getPropertyValue( sIsAutomatic );
- bAdd = *(sal_Bool *)aAny.getValue();
- }
- else
- {
- bAdd = sal_True;
- }
- }
- if( bAdd )
- pListAutoPool->Add( xNumRule );
- }
- }
- break;
- case XML_STYLE_FAMILY_TEXT_TEXT:
- {
- // Get parent and remove hyperlinks (they aren't of interest)
- UniReference< XMLPropertySetMapper > xPM =
- xPropMapper->getPropertySetMapper();
- for( ::std::vector< XMLPropertyState >::iterator i
- = xPropStates.begin();
- nIgnoreProps < 2 && i != xPropStates.end();
- i++ )
- {
- switch( xPM->GetEntryContextId(i->mnIndex) )
- {
- case CTF_CHAR_STYLE_NAME:
- i->maValue >>= sParent;
- i->mnIndex = -1;
- nIgnoreProps++;
- break;
- case CTF_HYPERLINK_URL:
- i->mnIndex = -1;
- nIgnoreProps++;
- break;
- }
- }
- }
- break;
- case XML_STYLE_FAMILY_TEXT_FRAME:
- if( xPropSetInfo->hasPropertyByName( sFrameStyleName ) )
- {
- aAny = rPropSet->getPropertyValue( sFrameStyleName );
- aAny >>= sParent;
- }
- break;
- case XML_STYLE_FAMILY_TEXT_SECTION:
- case XML_STYLE_FAMILY_TEXT_RUBY:
- ; // section styles have no parents
- break;
- }
- if( (xPropStates.size() - nIgnoreProps) > 0 )
- {
- GetAutoStylePool().Add( nFamily, sParent, xPropStates );
- if( sCondParent.getLength() && sParent != sCondParent )
- GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
- }
- }
- }
- void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
- MultiPropertySetHelper& rPropSetHelper,
- const Reference < XPropertySet > & rPropSet,
- const XMLPropertyState** ppAddStates)
- {
- UniReference < SvXMLExportPropertyMapper > xPropMapper;
- switch( nFamily )
- {
- case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
- xPropMapper = GetParaPropMapper();
- break;
- }
- DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
- vector< XMLPropertyState > xPropStates =
- xPropMapper->Filter( rPropSet );
- if( ppAddStates )
- {
- while( *ppAddStates )
- {
- xPropStates.push_back( **ppAddStates );
- ppAddStates++;
- }
- }
- if( xPropStates.size() > 0L )
- {
- OUString sParent, sCondParent;
- Any aAny;
- switch( nFamily )
- {
- case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
- if( rPropSetHelper.hasProperty( PARA_STYLE_NAME_AUTO ) )
- {
- aAny = rPropSetHelper.getValue( PARA_STYLE_NAME_AUTO, rPropSet,
- sal_True );
- aAny >>= sParent;
- }
- if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO ) )
- {
- aAny = rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO,
- rPropSet, sal_True );
- aAny >>= sCondParent;
- }
- if( rPropSetHelper.hasProperty( NUMBERING_RULES_AUTO ) )
- {
- aAny = rPropSetHelper.getValue( NUMBERING_RULES_AUTO,
- rPropSet, sal_True );
- Reference < XIndexReplace > xNumRule;
- aAny >>= xNumRule;
- if( xNumRule.is() && xNumRule->getCount() )
- {
- Reference < XNamed > xNamed( xNumRule, UNO_QUERY );
- OUString sName;
- if( xNamed.is() )
- sName = xNamed->getName();
- sal_Bool bAdd = !sName.getLength();
- if( !bAdd )
- {
- Reference < XPropertySet > xNumPropSet( xNumRule,
- UNO_QUERY );
- OUString sIsAutomatic( RTL_CONSTASCII_USTRINGPARAM( "IsAutomatic" ) );
- if( xNumPropSet.is() &&
- xNumPropSet->getPropertySetInfo()
- ->hasPropertyByName( sIsAutomatic ) )
- {
- aAny = xNumPropSet->getPropertyValue( sIsAutomatic );
- bAdd = *(sal_Bool *)aAny.getValue();
- }
- else
- {
- bAdd = sal_True;
- }
- }
- if( bAdd )
- pListAutoPool->Add( xNumRule );
- }
- }
- break;
- }
- if( xPropStates.size() > 0 )
- {
- GetAutoStylePool().Add( nFamily, sParent, xPropStates );
- if( sCondParent.getLength() && sParent != sCondParent )
- GetAutoStylePool().Add( nFamily, sCondParent, xPropStates );
- }
- }
- }
- OUString XMLTextParagraphExport::Find(
- sal_uInt16 nFamily,
- const Reference < XPropertySet > & rPropSet,
- const OUString& rParent,
- const XMLPropertyState** ppAddStates) const
- {
- OUString sName( rParent );
- UniReference < SvXMLExportPropertyMapper > xPropMapper;
- switch( nFamily )
- {
- case XML_STYLE_FAMILY_TEXT_PARAGRAPH:
- xPropMapper = GetParaPropMapper();
- break;
- case XML_STYLE_FAMILY_TEXT_FRAME:
- xPropMapper = GetAutoFramePropMapper();
- break;
- case XML_STYLE_FAMILY_TEXT_SECTION:
- xPropMapper = GetSectionPropMapper();
- break;
- case XML_STYLE_FAMILY_TEXT_RUBY:
- xPropMapper = GetRubyPropMapper();
- break;
- }
- DBG_ASSERT( xPropMapper.is(), "There is the property mapper?" );
- if( !xPropMapper.is() )
- return sName;
- vector< XMLPropertyState > xPropStates =
- xPropMapper->Filter( rPropSet );
- if( ppAddStates )
- {
- while( *ppAddStates )
- {
- xPropStates.push_back( **ppAddStates );
- ppAddStates++;
- }
- }
- if( xPropStates.size() > 0L )
- sName = GetAutoStylePool().Find( nFamily, sName, xPropStates );
- return sName;
- }
- OUString XMLTextParagraphExport::FindTextStyleAndHyperlink(
- const Reference < XPropertySet > & rPropSet,
- sal_Bool& rHyperlink,
- sal_Bool& rHasCharStyle,
- const XMLPropertyState** ppAddStates ) const
- {
- UniReference < SvXMLExportPropertyMapper > xPropMapper
- = GetTextPropMapper();
- vector< XMLPropertyState > xPropStates =
- xPropMapper->Filter( rPropSet );
- // Get parent and remove hyperlinks (they aren't of interest)
- OUString sName;
- rHyperlink = rHasCharStyle = sal_False;
- sal_uInt16 nIgnoreProps = 0;
- UniReference< XMLPropertySetMapper > xPM =
- xPropMapper->getPropertySetMapper();
- for( ::std::vector< XMLPropertyState >::iterator
- i = xPropStates.begin();
- nIgnoreProps < 2 && i != xPropStates.end();
- i++ )
- {
- switch( xPM->GetEntryContextId(i->mnIndex) )
- {
- case CTF_CHAR_STYLE_NAME:
- i->maValue >>= sName;
- i->mnIndex = -1;
- rHasCharStyle = sName.getLength() > 0;
- nIgnoreProps++;
- break;
- case CTF_HYPERLINK_URL:
- rHyperlink = sal_True;
- i->mnIndex = -1;
- nIgnoreProps++;
- break;
- }
- }
- if( ppAddStates )
- {
- while( *ppAddStates )
- {
- xPropStates.push_back( **ppAddStates );
- ppAddStates++;
- }
- }
- if( (xPropStates.size() - nIgnoreProps) > 0L )
- sName = GetAutoStylePool().Find( XML_STYLE_FAMILY_TEXT_TEXT, sName, xPropStates );
- return sName;
- }
- OUString XMLTextParagraphExport::FindTextStyle(
- const Reference < XPropertySet > & rPropSet,
- sal_Bool& rHasCharStyle ) const
- {
- sal_Bool bDummy;
- return FindTextStyleAndHyperlink( rPropSet, bDummy, rHasCharStyle );
- }
- void XMLTextParagraphExport::exportListChange(
- const XMLTextNumRuleInfo& rPrevInfo,
- const XMLTextNumRuleInfo& rNextInfo )
- {
- // end a list
- if( rPrevInfo.GetLevel() > 0 &&
- ( !rNextInfo.HasSameNumRules( rPrevInfo ) ||
- rNextInfo.GetLevel() < rPrevInfo.GetLevel() ||
- rNextInfo.IsRestart() ) )
- {
- sal_Int16 nPrevLevel = rPrevInfo.GetLevel();
- sal_Int16 nNextLevel =
- ( !rNextInfo.HasSameNumRules( rPrevInfo ) ||
- rNextInfo.IsRestart() ) ? 0 : rNextInfo.GetLevel();
- DBG_ASSERT( pListElements &&
- pListElements->Count() >= 2*(nNextLevel-nPrevLevel),
- "SwXMLExport::ExportListChange: list elements missing" );
- for( sal_Int16 i=nPrevLevel; i > nNextLevel; i-- )
- {
- for( sal_uInt16 j=0; j<2; j++ )
- {
- OUString *pElem = (*pListElements)[pListElements->Count()-1];
- pListElements->Remove( pListElements->Count()-1 );
- GetExport().EndElement( *pElem, sal_True );
- delete pElem;
- }
- }
- }
- // start a new list
- if( rNextInfo.GetLevel() > 0 &&
- ( !rPrevInfo.HasSameNumRules( rNextInfo ) ||
- rPrevInfo.GetLevel() < rNextInfo.GetLevel() ||
- rNextInfo.IsRestart() ) )
- {
- sal_Int16 nPrevLevel =
- ( !rNextInfo.HasSameNumRules( rPrevInfo ) ||
- rNextInfo.IsRestart() ) ? 0 : rPrevInfo.GetLevel();
- sal_Int16 nNextLevel = rNextInfo.GetLevel();
- // Find out whether this is the first application of the list or not.
- // For named lists, we use the internal name. For unnamed lists, we
- // use the generated name. This works well, because there are either
- // unnamed or either named lists only.
- sal_Bool bListExported = sal_False;
- OUString sName;
- if( rNextInfo.IsNamed() )
- sName = rNextInfo.GetName();
- else
- sName = pListAutoPool->Find( rNextInfo.GetNumRules() );
- DBG_ASSERT( sName.getLength(), "list without a name" );
- if( sName.getLength() )
- {
- bListExported = pExportedLists &&
- pExportedLists->Seek_Entry( (OUString *)&sName );
- if( !bListExported )
- {
- if( !pExportedLists )
- pExportedLists = new OUStringsSort_Impl;
- pExportedLists->Insert( new OUString(sName) );
- }
- }
- sal_Bool bContinue = !rNextInfo.IsRestart() && bListExported &&
- !rPrevInfo.HasSameNumRules( rNextInfo );
- for( sal_Int16 i=nPrevLevel; i < nNextLevel; i++)
- {
- // <text:ordered-list> or <text:unordered-list>
- GetExport().CheckAttrList();
- if( 0 == i )
- {
- // For named list, the name might be the name of an automatic
- // rule, so we have to take a look into the style pool.
- // For unnamed lists, we have done this already.
- if( rNextInfo.IsNamed() )
- {
- OUString sTmp( pListAutoPool->Find(
- rNextInfo.GetNumRules() ) );
- if( sTmp.getLength() )
- sName = sTmp;
- }
- GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
- sName );
- }
- if( bContinue && rNextInfo.IsOrdered() )
- GetExport().AddAttribute( XML_NAMESPACE_TEXT,
- XML_CONTINUE_NUMBERING, XML_TRUE );
- enum XMLTokenEnum eLName =
- rNextInfo.IsOrdered() ? XML_ORDERED_LIST
- : XML_UNORDERED_LIST;
- OUString *pElem = new OUString(
- GetExport().GetNamespaceMap().GetQNameByKey(
- XML_NAMESPACE_TEXT,
- GetXMLToken(eLName) ) );
- GetExport().IgnorableWhitespace();
- GetExport().StartElement( *pElem, sal_False );
- if( !pListElements )
- pListElements = new OUStrings_Impl;
- pListElements->Insert( pElem, pListElements->Count() );
- // <text:list-header> or <text:list-item>
- GetExport().CheckAttrList();
- if( rNextInfo.HasStartValue() )
- {
- OUStringBuffer aBuffer;
- aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
- GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
- aBuffer.makeStringAndClear() );
- }
- eLName = (rNextInfo.IsNumbered() || i+1 < nNextLevel)
- ? XML_LIST_ITEM
- : XML_LIST_HEADER;
- pElem = new OUString( GetExport().GetNamespaceMap().GetQNameByKey(
- XML_NAMESPACE_TEXT,
- GetXMLToken(eLName) ) );
- GetExport().IgnorableWhitespace();
- GetExport().StartElement( *pElem, sal_False );
- pListElements->Insert( pElem, pListElements->Count() );
- }
- }
- if( rNextInfo.GetLevel() > 0 && rNextInfo.IsNumbered() &&
- rPrevInfo.HasSameNumRules( rNextInfo ) &&
- rPrevInfo.GetLevel() >= rNextInfo.GetLevel() &&
- !rNextInfo.IsRestart() )
- {
- // </text:list-item> or </text:list-header>
- DBG_ASSERT( pListElements && pListElements->Count() >= 2,
- "SwXMLExport::ExportListChange: list elements missing" );
- OUString *pElem = (*pListElements)[pListElements->Count()-1];
- GetExport().EndElement( *pElem, sal_True );
- pListElements->Remove( pListElements->Count()-1 );
- delete pElem;
- // <text:list-item>
- GetExport().CheckAttrList();
- if( rNextInfo.HasStartValue() )
- {
- OUStringBuffer aBuffer;
- aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() );
- GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE,
- aBuffer.makeStringAndClear() );
- }
- pElem = new OUString( GetExport().GetNamespaceMap().GetQNameByKey(
- XML_NAMESPACE_TEXT,
- GetXMLToken(XML_LIST_ITEM) ) );
- GetExport().IgnorableWhitespace();
- GetExport().StartElement( *pElem, sal_False );
- pListElements->Insert( pElem, pListElements->Count() );
- }
- }
- XMLTextParagraphExport::XMLTextParagraphExport(
- SvXMLExport& rExp,
- SvXMLAutoStylePoolP & rASP
- ) :
- XMLStyleExport( rExp, OUString(), &rASP ),
- // rExport( rExp ),
- rAutoStylePool( rASP ),
- pListElements( 0 ),
- pExportedLists( 0 ),
- pListAutoPool( new XMLTextListAutoStylePool( this->GetExport() ) ),
- pFieldExport( 0 ),
- pPageTextFrameIdxs( 0 ),
- pPageGraphicIdxs( 0 ),
- pPageEmbeddedIdxs( 0 ),
- pPageShapeIdxs( 0 ),
- pFrameTextFrameIdxs( 0 ),
- pFrameGraphicIdxs( 0 ),
- pFrameEmbeddedIdxs( 0 ),
- pSectionExport( NULL ),
- pIndexMarkExport( NULL ),
- pRedlineExport( NULL ),
- pFrameShapeIdxs( 0 ),
- bBlock( sal_False ),
- bOpenRuby( sal_False ),
- sParagraphService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Paragraph")),
- sTableService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable")),
- sTextFieldService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField")),
- sTextFrameService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")),
- sTextGraphicService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextGraphicObject")),
- sTextEmbeddedService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextEmbeddedObject")),
- sTextEndnoteService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote")),
- sTextContentService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextContent")),
- sShapeService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape")),
- sParaStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName")),
- sParaConditionalStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaConditionalStyleName")),
- sParaChapterNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("ParaChapterNumberingLevel")),
- sCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName")),
- sCharStyleNames(RTL_CONSTASCII_USTRINGPARAM("CharStyleNames")),
- sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")),
- sTextField(RTL_CONSTASCII_USTRINGPARAM("TextField")),
- sText(RTL_CONSTASCII_USTRINGPARAM("Text")),
- sFrame(RTL_CONSTASCII_USTRINGPARAM("Frame")),
- sCategory(RTL_CONSTASCII_USTRINGPARAM("Category")),
- sNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules")),
- sTextPortionType(RTL_CONSTASCII_USTRINGPARAM("TextPortionType")),
- sFootnote(RTL_CONSTASCII_USTRINGPARAM("Footnote")),
- sBookmark(RTL_CONSTASCII_USTRINGPARAM("Bookmark")),
- sReferenceMark(RTL_CONSTASCII_USTRINGPARAM("ReferenceMark")),
- sIsCollapsed(RTL_CONSTASCII_USTRINGPARAM("IsCollapsed")),
- sIsStart(RTL_CONSTASCII_USTRINGPARAM("IsStart")),
- sReferenceId(RTL_CONSTASCII_USTRINGPARAM("ReferenceId")),
- sNumberingType(RTL_CONSTASCII_USTRINGPARAM("NumberingType")),
- sPageStyleName(RTL_CONSTASCII_USTRINGPARAM("PageStyleName")),
- sPageDescName(RTL_CONSTASCII_USTRINGPARAM("PageDescName")),
- sPrefix(RTL_CONSTASCII_USTRINGPARAM("Prefix")),
- sStartAt(RTL_CONSTASCII_USTRINGPARAM("StartAt")),
- sSuffix(RTL_CONSTASCII_USTRINGPARAM("Suffix")),
- sPositionEndOfDoc(RTL_CONSTASCII_USTRINGPARAM("PositionEndOfDoc")),
- sFootnoteCounting(RTL_CONSTASCII_USTRINGPARAM("FootnoteCounting")),
- sEndNotice(RTL_CONSTASCII_USTRINGPARAM("EndNotice")),
- sBeginNotice(RTL_CONSTASCII_USTRINGPARAM("BeginNotice")),
- sFrameWidthAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameWidthAbsolute")),
- sFrameWidthPercent(RTL_CONSTASCII_USTRINGPARAM("FrameWidthPercent")),
- sFrameHeightAbsolute(RTL_CONSTASCII_USTRINGPARAM("FrameHeightAbsolute")),
- sFrameHeightPercent(RTL_CONSTASCII_USTRINGPARAM("FrameHeightPercent")),
- sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")),
- sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")),
- sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")),
- sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")),
- sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")),
- sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")),
- sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")),
- sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")),
- sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")),
- sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")),
- sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")),
- sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")),
- sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")),
- sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")),
- sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")),
- sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")),
- sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")),
- sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")),
- sHyperLinkURL(RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")),
- sHyperLinkName(RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")),
- sHyperLinkTarget(RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")),
- sUnvisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("UnvisitedCharStyleName")),
- sVisitedCharStyleName(RTL_CONSTASCII_USTRINGPARAM("VisitedCharStyleName")),
- sTextSection(RTL_CONSTASCII_USTRINGPARAM("TextSection")),
- sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex")),
- sDocumentIndexMark(RTL_CONSTASCII_USTRINGPARAM("DocumentIndexMark")),
- sActualSize(RTL_CONSTASCII_USTRINGPARAM("ActualSize")),
- sContourPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon")),
- sIsPixelContour(RTL_CONSTASCII_USTRINGPARAM("IsPixelContour")),
- sIsAutomaticContour(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour")),
- sAnchorCharStyleName(RTL_CONSTASCII_USTRINGPARAM("AnchorCharStyleName")),
- sServerMap(RTL_CONSTASCII_USTRINGPARAM("ServerMap")),
- sRedline(RTL_CONSTASCII_USTRINGPARAM("Redline")),
- sRuby(RTL_CONSTASCII_USTRINGPARAM("Ruby")),
- sRubyText(RTL_CONSTASCII_USTRINGPARAM("RubyText")),
- sRubyAdjust(RTL_CONSTASCII_USTRINGPARAM("RubyAdjust")),
- sRubyCharStyleName(RTL_CONSTASCII_USTRINGPARAM("RubyCharStyleName")),
- bProgress( sal_False ),
- aCharStyleNamesPropInfoCache( sCharStyleNames )
- {
- UniReference < XMLPropertySetMapper > xPropMapper =
- new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA );
- xParaPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
- GetExport() );
- OUString sFamily( GetXMLToken(XML_PARAGRAPH) );
- OUString sPrefix( 'P' );
- rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_PARAGRAPH, sFamily,
- xParaPropMapper, sPrefix );
- xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
- xTextPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
- GetExport() );
- sFamily = OUString( GetXMLToken(XML_TEXT) );
- sPrefix = OUString( 'T' );
- rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_TEXT, sFamily,
- xTextPropMapper, sPrefix );
- xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_AUTO_FRAME );
- xAutoFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
- GetExport() );
- sFamily = OUString( RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME) );
- sPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "fr" ) );
- rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_FRAME, sFamily,
- xAutoFramePropMapper, sPrefix );
- xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION );
- xSectionPropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
- GetExport() );
- sFamily = OUString( GetXMLToken( XML_SECTION ) );
- sPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "Sect" ) );
- rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_SECTION, sFamily,
- xSectionPropMapper, sPrefix );
- xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY );
- xRubyPropMapper = new SvXMLExportPropertyMapper( xPropMapper );
- sFamily = OUString( GetXMLToken( XML_RUBY ) );
- sPrefix = OUString( RTL_CONSTASCII_USTRINGPARAM( "Ru" ) );
- rAutoStylePool.AddFamily( XML_STYLE_FAMILY_TEXT_RUBY, sFamily,
- xRubyPropMapper, sPrefix );
- xPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME );
- xFramePropMapper = new XMLTextExportPropertySetMapper( xPropMapper,
- GetExport() );
- pSectionExport = new XMLSectionExport( rExp, *this );
- pIndexMarkExport = new XMLIndexMarkExport( rExp, *this );
- pRedlineExport = IsBlockMode() ? NULL : new XMLRedlineExport( rExp );
- // The text field helper needs a pre-constructed XMLPropertyState
- // to export the combined characters field. We construct that
- // here, because we need the text property mapper to do it.
- // construct Any value, then find index
- Any aAny;
- sal_Bool bTmp = sal_True;
- aAny.setValue(&bTmp, ::getBooleanCppuType());
- sal_Int32 nIndex = xTextPropMapper->getPropertySetMapper()->FindEntryIndex(
- "", XML_NAMESPACE_STYLE,
- GetXMLToken(XML_TEXT_COMBINE));
- pFieldExport = new XMLTextFieldExport( rExp, new XMLPropertyState( nIndex, aAny ) );
- }
- XMLTextParagraphExport::~XMLTextParagraphExport()
- {
- delete pRedlineExport;
- delete pIndexMarkExport;
- delete pSectionExport;
- delete pFieldExport;
- delete pListElements;
- delete pExportedLists;
- delete pListAutoPool;
- delete pPageTextFrameIdxs;
- delete pPageGraphicIdxs;
- delete pPageEmbeddedIdxs;
- delete pPageShapeIdxs;
- delete pFrameTextFrameIdxs;
- delete pFrameGraphicIdxs;
- delete pFrameEmbeddedIdxs;
- delete pFrameShapeIdxs;
- #ifdef DBG_UTIL
- txtparae_bContainsIllegalCharacters = sal_False;
- #endif
- }
- SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateShapeExtPropMapper(
- SvXMLExport& rExport )
- {
- UniReference < XMLPropertySetMapper > xPropMapper =
- new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE );
- return new XMLTextExportPropertySetMapper( xPropMapper, rExport );
- }
- SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateCharExtPropMapper(
- SvXMLExport& rExport)
- {
- XMLPropertySetMapper *pPropMapper =
- new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT );
- return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
- }
- SvXMLExportPropertyMapper *XMLTextParagraphExport::CreateParaExtPropMapper(
- SvXMLExport& rExport)
- {
- XMLPropertySetMapper *pPropMapper =
- new XMLTextPropertySetMapper( TEXT_PROP_MAP_SHAPE_PARA );
- return new XMLTextExportPropertySetMapper( pPropMapper, rExport );
- }
- void XMLTextParagraphExport::collectFrames( sal_Bool bBoundToFrameOnly )
- {
- Reference < XTextFramesSupplier > xTFS( GetExport().GetModel(), UNO_QUERY );
- if( xTFS.is() )
- {
- xTextFrames = Reference < XIndexAccess >( xTFS->getTextFrames(),
- UNO_QUERY );
- sal_Int32 nCount = xTextFrames->getCount();
- for( sal_Int32 i = 0; i < nCount; i++ )
- {
- Any aAny = xTextFrames->getByIndex( i );
- Reference < XTextFrame > xTxtFrame;
- aAny >>= xTxtFrame;
- Reference < XPropertySet > xPropSet( xTxtFrame, UNO_QUERY );
- aAny = xPropSet->getPropertyValue( sAnchorType );
- TextContentAnchorType eAnchor;
- aAny >>= 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;
- }
- }
- }
- Reference < XTextGraphicObjectsSupplier > xTGOS( GetExport().GetModel(),
- UNO_QUERY );
- if( xTGOS.is() )
- {
- xGraphics = Reference < XIndexAccess >( xTGOS->getGraphicObjects(),
- UNO_QUERY );
- sal_Int32 nCount = xGraphics->getCount();
- for( sal_Int32 i = 0; i < nCount; i++ )
- {
- Any aAny = xGraphics->getByIndex( i );
- Reference < XTextContent > xTxtCntnt;
- aAny >>= xTxtCntnt;
- Reference < XPropertySet > xPropSet( xTxtCntnt, UNO_QUERY );
- aAny = xPropSet->getPropertyValue( sAnchorType );
- TextContentAnchorType eAnchor;
- aAny >>= 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;
- }
- }
- }
- 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++ )
- {
- Any aAny = xEmbeddeds->getByIndex( i );
- Reference < XTextContent > xTxtCntnt;
- aAny >>= xTxtCntnt;
- Reference < XPropertySet > xPropSet( xTxtCntnt, UNO_QUERY );
- aAny = xPropSet->getPropertyValue( sAnchorType );
- TextContentAnchorType eAnchor;
- aAny >>= 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;
- }
- }
- }
- 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++ )
- {
- Any aAny = xShapes->getByIndex( i );
- Reference < XShape > xShape;
- aAny >>= xShape;
- if( !xShape.is() )
- continue;
- Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
- aAny = xPropSet->getPropertyValue( sAnchorType );
- TextContentAnchorType eAnchor;
- aAny >>= 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 bProgress )
- {
- if( pPageTextFrameIdxs )
- {
- for( sal_uInt16 i = 0; i < pPageTextFrameIdxs->Count(); i++ )
- {
- Any aAny = xTextFrames->getByIndex( (*pPageTextFrameIdxs)[i] );
- Reference < XTextFrame > xTxtFrame;
- aAny >>= xTxtFrame;
- Reference < XTextContent > xTxtCntnt( xTxtFrame, UNO_QUERY );
- exportTextFrame( xTxtCntnt, bAutoStyles, bProgress );
- }
- }
- if( pPageGraphicIdxs )
- {
- for( sal_uInt16 i = 0; i < pPageGraphicIdxs->Count(); i++ )
- {
- Any aAny = xGraphics->getByIndex( (*pPageGraphicIdxs)[i] );
- Reference < XTextContent > xTxtCntnt;
- aAny >>= xTxtCntnt;
- exportTextGraphic( xTxtCntnt, bAutoStyles );
- }
- }
- if( pPageEmbeddedIdxs )
- {
- for( sal_uInt16 i = 0; i < pPageEmbeddedIdxs->Count(); i++ )
- {
- Any aAny = xEmbeddeds->getByIndex( (*pPageEmbeddedIdxs)[i] );
- Reference < XTextContent > xTxtCntnt;
- aAny >>= xTxtCntnt;
- exportTextEmbedded( xTxtCntnt, bAutoStyles );
- }
- }
- if( pPageShapeIdxs )
- {
- for( sal_uInt16 i = 0; i < pPageShapeIdxs->Count(); i++ )
- {
- Any aAny = xShapes->getByIndex( (*pPageShapeIdxs)[i] );
- Reference < XShape > xShape;
- aAny >>= xShape;
- Reference < XTextContent > xTxtCntnt( xShape, UNO_QUERY );
- exportShape( xTxtCntnt, bAutoStyles );
- }
- }
- }
- sal_Bool lcl_txtpara_isFrameAnchor(
- const Reference < XPropertySet > rPropSet,
- const Reference < XTextFrame >& rParentTxtFrame )
- {
- Any aAny = rPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorFrame") ) );
- Reference < XTextFrame > xAnchorTxtFrame;
- aAny >>= xAnchorTxtFrame;
- return xAnchorTxtFrame == rParentTxtFrame;
- }
- void XMLTextParagraphExport::exportFrameFrames(
- sal_Bool bAutoStyles,
- sal_Bool bProgress,
- const Reference < XTextFrame > *pParentTxtFrame )
- {
- if( pFrameTextFrameIdxs && pFrameTextFrameIdxs->Count() )
- {
- Any aAny;
- sal_uInt16 i = 0;
- while( i < pFrameTextFrameIdxs->Count() )
- {
- aAny = xTextFrames->getByIndex( (*pFrameTextFrameIdxs)[i] );
- Reference < XTextFrame > xTxtFrame;
- aAny >>= xTxtFrame;
- Reference < XPropertySet > xPropSet( xTxtFrame, UNO_QUERY );
- if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) )
- {
- if( !bAutoStyles )
- pFrameTextFrameIdxs->Remove( i );
- sal_uInt16 nOldCount = pFrameTextFrameIdxs->Count();
- Reference < XTextContent > xTxtCntnt( xTxtFrame, UNO_QUERY );
- exportTextFrame( xTxtCntnt, bAutoStyles, bProgress );
- 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() )
- {
- aAny = xGraphics->getByIndex( (*pFrameGraphicIdxs)[i] );
- Reference < XTextContent > xTxtCntnt;
- aAny >>= xTxtCntnt;
- Reference < XPropertySet > xPropSet( xTxtCntnt, UNO_QUERY );
- if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) )
- {
- if( !bAutoStyles )
- pFrameGraphicIdxs->Remove( i );
- sal_uInt16 nOldCount = pFrameGraphicIdxs->Count();
- 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() )
- {
- aAny = xEmbeddeds->getByIndex( (*pFrameEmbeddedIdxs)[i] );
- Reference < XEmbeddedObjectSupplier > xEOS;
- aAny >>= xEOS;
- Reference < XPropertySet > xPropSet( xEOS, UNO_QUERY );
- if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) )
- {
- if( !bAutoStyles )
- pFrameEmbeddedIdxs->Remove( i );
- sal_uInt16 nOldCount = pFrameEmbeddedIdxs->Count();
- Reference < XTextContent > xTxtCntnt( xEOS, 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() )
- {
- aAny = xShapes->getByIndex( (*pFrameShapeIdxs)[i] );
- Reference < XShape > xShape;
- aAny >>= xShape;
- Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
- if( lcl_txtpara_isFrameAnchor( xPropSet, *pParentTxtFrame ) )
- {
- if( !bAutoStyles )
- pFrameShapeIdxs->Remove( i );
- sal_uInt16 nOldCount = pFrameShapeIdxs->Count();
- Reference < XTextContent > xTxtCntnt( xShape, UNO_QUERY );
- exportShape( xTxtCntnt, bAutoStyles );
- if( bAutoStyles )
- i++;
- else if( pFrameShapeIdxs->Count() != nOldCount )
- i = 0;
- }
- else
- i++;
- }
- }
- }
- void XMLTextParagraphExport::exportText(
- const Reference < XText > & rText,
- sal_Bool bAutoStyles,
- sal_Bool bProgress,
- sal_Bool bExportParagraph )
- {
- if( bAutoStyles )
- GetExport().GetShapeExport(); // make sure the graphics styles family
- // is added
- Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
- Reference < XEnumeration > xParaEnum = xEA->createEnumeration();
- Reference < XPropertySet > xPropertySet( rText, UNO_QUERY );
- Reference < XTextSection > xBaseSection;
- // #97718# footnotes don't supply paragraph enumerations in some cases
- // This is always a bug, but at least we don't want to crash.
- DBG_ASSERT( xParaEnum.is(), "We need a paragraph enumeration" );
- if( ! xParaEnum.is() )
- return;
- sal_Bool bExportLevels = sal_True;
- if (xPropertySet.is())
- {
- Reference < XPropertySetInfo > xInfo ( xPropertySet->getPropertySetInfo() );
- if( xInfo.is() )
- {
- if (xInfo->hasPropertyByName( sTextSection ))
- {
- xPropertySet->getPropertyValue(sTextSection) >>= xBaseSection ;
- }
- // for applications that use the outliner we need to check if
- // the current text object needs the level information exported
- if( !bAutoStyles )
- {
- // fixme: move string to class member, couldn't do now because
- // of no incompatible build
- OUString sHasLevels( RTL_CONSTASCII_USTRINGPARAM("HasLevels") );
- if (xInfo->hasPropertyByName( sHasLevels ) )
- {
- xPropertySet->getPropertyValue(sHasLevels) >>= bExportLevels;
- }
- }
- }
- }
- // #96530# Export redlines at start & end of XText before & after
- // exporting the text content enumeration
- if( !bAutoStyles && (pRedlineExport != NULL) )
- pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True );
- exportTextContentEnumeration( xParaEnum, bAutoStyles, xBaseSection,
- bProgress, bExportParagraph, 0, bExportLevels );
- if( !bAutoStyles && (pRedlineExport != NULL) )
- pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False );
- }
- void XMLTextParagraphExport::exportText(
- const Reference < XText > & rText,
- const Reference < XTextSection > & rBaseSection,
- sal_Bool bAutoStyles,
- sal_Bool bProgress,
- sal_Bool bExportParagraph )
- {
- if( bAutoStyles )
- GetExport().GetShapeExport(); // make sure the graphics styles family
- // is added
- Reference < XEnumerationAccess > xEA( rText, UNO_QUERY );
- Reference < XEnumeration > xParaEnum = xEA->createEnumeration();
- // #98165# don't continue without a paragraph enumeration
- if( ! xParaEnum.is() )
- return;
- // #96530# Export redlines at start & end of XText before & after
- // exporting the text content enumeration
- Reference<XPropertySet> xPropertySet;
- if( !bAutoStyles && (pRedlineExport != NULL) )
- {
- xPropertySet = Reference<XPropertySet>::query( rText );
- pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_True );
- }
- exportTextContentEnumeration( xParaEnum, bAutoStyles, rBaseSection,
- bProgress, bExportParagraph );
- if( !bAutoStyles && (pRedlineExport != NULL) )
- pRedlineExport->ExportStartOrEndRedline( xPropertySet, sal_False );
- }
- sal_Bool XMLTextParagraphExport::exportTextContentEnumeration(
- const Reference < XEnumeration > & rContEnum,
- sal_Bool bAutoStyles,
- const Reference < XTextSection > & rBaseSection,
- sal_Bool bProgress,
- sal_Bool bExportParagraph,
- const Reference < XPropertySet > *pRangePropSet,
- sal_Bool bExportLevels)
- {
- DBG_ASSERT( rContEnum.is(), "No enumeration to export!" );
- sal_Bool bHasMoreElements = rContEnum->hasMoreElements();
- if( !bHasMoreElements )
- return sal_False;
- XMLTextNumRuleInfo aPrevNumInfo;
- XMLTextNumRuleInfo aNextNumInfo;
- sal_Bool bHasContent sal_False;
- Reference<XTextSection> xCurrentTextSection = rBaseSection;
- MultiPropertySetHelper aPropSetHelper(
- bAutoStyles ? aParagraphPropertyNamesAuto :
- aParagraphPropertyNames );
- Any aAny;
- sal_Bool bHoldElement = sal_False;
- Reference < XTextContent > xTxtCntnt;
- while( bHoldElement || bHasMoreElements )
- {
- if (bHoldElement)
- {
- bHoldElement = sal_False;
- }
- else
- {
- aAny = rContEnum->nextElement();
- aAny >>= xTxtCntnt;
- aPropSetHelper.resetValues();
- }
- Reference<XServiceInfo> xServiceInfo( xTxtCntnt, UNO_QUERY );
- if( xServiceInfo->supportsService( sParagraphService ) )
- {
- if( bExportLevels )
- {
- if( bAutoStyles )
- {
- exportListAndSectionChange( xCurrentTextSection, xTxtCntnt,
- aPrevNumInfo, aNextNumInfo,
- bAutoStyles );
- }
- else
- {
- aNextNumInfo.Set( xTxtCntnt );
- exportListAndSectionChange( xCurrentTextSection, aPropSetHelper,
- TEXT_SECTION, xTxtCntnt,
- aPrevNumInfo, aNextNumInfo,
- bAutoStyles );
- }
- }
- // if we found a mute section: skip all section content
- if (pSectionExport->IsMuteSection(xCurrentTextSection))
- {
- // Make sure headings are exported anyway.
- if( !bAutoStyles )
- pSectionExport->ExportMasterDocHeadingDummies();
- while (rContEnum->hasMoreElements() &&
- pSectionExport->IsInSection( xCurrentTextSection,
- xTxtCntnt, sal_True ))
- {
- aAny = rContEnum->nextElement();
- aAny >>= xTxtCntnt;
- aPropSetHelper.resetValues();
- aNextNumInfo.Reset();
- }
- // the first non-mute element still needs to be processed
- bHoldElement =
- ! pSectionExport->IsInSection( xCurrentTextSection,
- xTxtCntnt, sal_False );
- }
- else
- exportParagraph( xTxtCntnt, bAutoStyles, bProgress,
- bExportParagraph, aPropSetHelper );
- bHasContent = sal_True;
- }
- else if( xServiceInfo->supportsService( sTableService ) )
- {
- if( !bAutoStyles )
- {
- aNextNumInfo.Reset();
- }
- exportListAndSectionChange( xCurrentTextSection, xTxtCntnt,
- aPrevNumInfo, aNextNumInfo,
- bAutoStyles );
- if (! pSectionExport->IsMuteSection(xCurrentTextSection))
- {
- // export start + end redlines (for wholly redlined tables)
- if ((! bAutoStyles) && (NULL != pRedlineExport))
- pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_True);
- exportTable( xTxtCntnt, bAutoStyles, bProgress );
- if ((! bAutoStyles) && (NULL != pRedlineExport))
- pRedlineExport->ExportStartOrEndRedline(xTxtCntnt, sal_False);
- }
- else if( !bAutoStyles )
- {
- // Make sure headings are exported anyway.
- pSectionExport->ExportMasterDocHeadingDummies();
- }
- bHasContent = sal_True;
- }
- else if( xServiceInfo->supportsService( sTextFrameService ) )
- {
- exportTextFrame( xTxtCntnt, bAutoStyles, bProgress, pRangePropSet );
- }
- else if( xServiceInfo->supportsService( sTextGraphicService ) )
- {
- exportTextGraphic( xTxtCntnt, bAutoStyles, pRangePropSet );
- }
- else if( xServiceInfo->supportsService( sTextEmbeddedService ) )
- {
- exportTextEmbedded( xTxtCntnt, bAutoStyles, pRangePropSet );
- }
- else if( xServiceInfo->supportsService( sShapeService ) )
- {
- exportShape( xTxtCntnt, bAutoStyles, pRangePropSet );
- }
- else
- {
- DBG_ASSERT( !xTxtCntnt.is(), "unknown text content" );
- }
- if( !bAutoStyles )
- {
- aPrevNumInfo = aNextNumInfo;
- }
- bHasMoreElements = rContEnum->hasMoreElements();
- }
- if( bExportLevels && bHasContent && !bAutoStyles )
- {
- aNextNumInfo.Reset();
- // close open lists and sections; no new styles
- exportListAndSectionChange( xCurrentTextSection, rBaseSection,
- aPrevNumInfo, aNextNumInfo,
- bAutoStyles );
- }
- return sal_True;
- }
- void XMLTextParagraphExport::exportParagraph(
- const Reference < XTextContent > & rTextContent,
- sal_Bool bAutoStyles, sal_Bool bProgress, sal_Bool bExportParagraph,
- MultiPropertySetHelper& rPropSetHelper)
- {
- sal_Int8 nOutlineLevel = -1;
- if( bProgress )
- {
- ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
- pProgress->SetValue( pProgress->GetValue()+1 );
- }
- // get property set or multi property set and initialize helper
- Reference<XMultiPropertySet> xMultiPropSet( rTextContent, UNO_QUERY );
- Reference<XPropertySet> xPropSet( rTextContent, UNO_QUERY );
- // check for supported properties
- if( !rPropSetHelper.checkedProperties() )
- rPropSetHelper.hasProperties( xPropSet->getPropertySetInfo() );
- // if( xMultiPropSet.is() )
- // rPropSetHelper.getValues( xMultiPropSet );
- // else
- // rPropSetHelper.getValues( xPropSet );
- Any aAny;
- if( bExportParagraph )
- {
- if( bAutoStyles )
- {
- Add( XML_STYLE_FAMILY_TEXT_PARAGRAPH, rPropSetHelper, xPropSet );
- }
- else
- {
- OUString sStyle;
- if( rPropSetHelper.hasProperty( PARA_STYLE_NAME ) )
- {
- if( xMultiPropSet.is() )
- aAny = rPropSetHelper.getValue( PARA_STYLE_NAME,
- xMultiPropSet );
- else
- aAny = rPropSetHelper.getValue( PARA_STYLE_NAME,
- xPropSet );
- aAny >>= sStyle;
- }
- OUString sAutoStyle( sStyle );
- sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet, sStyle );
- if( sAutoStyle.getLength() )
- GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
- sAutoStyle );
- if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME ) )
- {
- OUString sCondStyle;
- if( xMultiPropSet.is() )
- aAny = rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME,
- xMultiPropSet );
- else
- aAny = rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME,
- xPropSet );
- aAny >>= sCondStyle;
- if( sCondStyle != sStyle )
- {
- sCondStyle = Find( XML_STYLE_FAMILY_TEXT_PARAGRAPH, xPropSet,
- sCondStyle );
- if( sCondStyle.getLength() )
- GetExport().AddAttribute( XML_NAMESPACE_TEXT,
- XML_COND_STYLE_NAME,
- sCondStyle );
- }
- }
- if( rPropSetHelper.hasProperty( PARA_CHAPTER_NUMERBING_LEVEL ) )
- {
- if( xMultiPropSet.is() )
- aAny = rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL,
- xMultiPropSet );
- else
- aAny = rPropSetHelper.getValue( PARA_CHAPTER_NUMERBING_LEVEL,
- xPropSet );
- aAn…
Large files files are truncated, but you can click here to view the full file