diff options
author | Mathias Bauer <mba@openoffice.org> | 2009-09-09 11:45:13 +0200 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2009-09-09 11:45:13 +0200 |
commit | e7c6e5d2c248cfb935c91882a3a1e64fea7550b4 (patch) | |
tree | d2f45902cbd12ac6b651e486687130e01272d79f /xmloff/source/text | |
parent | 2484e4f7faa1f052ff48d2192ffb5931a71faa8f (diff) | |
parent | d1886d07b439e7197f731c9d98c0b2ec31c62faa (diff) |
merge commit to DEV300_m57
Diffstat (limited to 'xmloff/source/text')
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.cxx | 141 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.hxx | 3 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.cxx | 60 | ||||
-rw-r--r-- | xmloff/source/text/txtflde.cxx | 76 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 296 | ||||
-rw-r--r-- | xmloff/source/text/txtimppr.cxx | 13 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 144 | ||||
-rw-r--r-- | xmloff/source/text/txtparai.cxx | 372 | ||||
-rw-r--r-- | xmloff/source/text/txtparai.hxx | 7 | ||||
-rw-r--r-- | xmloff/source/text/txtprmap.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/text/txtstyli.cxx | 24 |
11 files changed, 817 insertions, 321 deletions
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index c53885e73187..c3ff9abebd90 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -124,44 +124,45 @@ inline XMLTextFrameContextHyperlink_Impl::XMLTextFrameContextHyperlink_Impl( { } -class XMLTextFrameDescContext_Impl : public SvXMLImportContext +// --> OD 2009-07-22 #i73249# +class XMLTextFrameTitleOrDescContext_Impl : public SvXMLImportContext { - OUString& rDesc; + OUString& mrTitleOrDesc; public: TYPEINFO(); - XMLTextFrameDescContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx, - const ::rtl::OUString& rLName, - const ::com::sun::star::uno::Reference< - ::com::sun::star::xml::sax::XAttributeList > & xAttrList, - OUString& rD ); - virtual ~XMLTextFrameDescContext_Impl(); + XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport, + sal_uInt16 nPrfx, + const ::rtl::OUString& rLName, + OUString& rTitleOrDesc ); + virtual ~XMLTextFrameTitleOrDescContext_Impl(); virtual void Characters( const OUString& rText ); }; -TYPEINIT1( XMLTextFrameDescContext_Impl, SvXMLImportContext ); +TYPEINIT1( XMLTextFrameTitleOrDescContext_Impl, SvXMLImportContext ); -XMLTextFrameDescContext_Impl::XMLTextFrameDescContext_Impl( +XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport, - sal_uInt16 nPrfx, const OUString& rLName, - const Reference< XAttributeList > &, - OUString& rD ) : - SvXMLImportContext( rImport, nPrfx, rLName ), - rDesc( rD ) + sal_uInt16 nPrfx, + const OUString& rLName, + OUString& rTitleOrDesc ) + : SvXMLImportContext( rImport, nPrfx, rLName ) + , mrTitleOrDesc( rTitleOrDesc ) { } -XMLTextFrameDescContext_Impl::~XMLTextFrameDescContext_Impl() +XMLTextFrameTitleOrDescContext_Impl::~XMLTextFrameTitleOrDescContext_Impl() { } -void XMLTextFrameDescContext_Impl::Characters( const OUString& rText ) +void XMLTextFrameTitleOrDescContext_Impl::Characters( const OUString& rText ) { - rDesc += rText; + mrTitleOrDesc += rText; } +// <-- // ------------------------------------------------------------------------ @@ -385,7 +386,11 @@ class XMLTextFrameContext_Impl : public SvXMLImportContext const ::rtl::OUString sAnchorPageNo; const ::rtl::OUString sGraphicURL; const ::rtl::OUString sGraphicFilter; - const ::rtl::OUString sAlternativeText; + // --> OD 2009-07-22 #i73249# +// const ::rtl::OUString sAlternativeText; + const ::rtl::OUString sTitle; + const ::rtl::OUString sDescription; + // <-- const ::rtl::OUString sFrameStyleName; const ::rtl::OUString sGraphicRotation; const ::rtl::OUString sTextBoxServiceName; @@ -461,6 +466,9 @@ public: const ::rtl::OUString& rName, const ::rtl::OUString& rTargetFrameName, sal_Bool bMap ); + // --> OD 2009-07-22 #i73249# + void SetTitle( const ::rtl::OUString& rTitle ); + // <-- void SetDesc( const ::rtl::OUString& rDesc ); ::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; } @@ -829,7 +837,11 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( , sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")) , sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")) , sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")) -, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")) +// --> OD 2009-07-22 #i73249# +//, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")) +, sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")) +, sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")) +// <-- , sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")) , sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")) , sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")) @@ -1135,12 +1147,15 @@ SvXMLImportContext *XMLTextFrameContext_Impl::CreateChildContext( } } } + // --> OD 2009-08-17 #i100480# + // correction of condition which also avoids warnings. if( !pContext && - ( XML_TEXT_FRAME_OBJECT == nType && - (XML_NAMESPACE_OFFICE == nPrefix && - IsXMLToken( rLocalName, XML_DOCUMENT )) || - (XML_NAMESPACE_MATH == nPrefix && - IsXMLToken(rLocalName, XML_MATH) ) ) ) + ( XML_TEXT_FRAME_OBJECT == nType && + ( ( XML_NAMESPACE_OFFICE == nPrefix && + IsXMLToken( rLocalName, XML_DOCUMENT ) ) || + ( XML_NAMESPACE_MATH == nPrefix && + IsXMLToken( rLocalName, XML_MATH ) ) ) ) ) + // <-- { if( !xPropSet.is() && !bCreateFailed ) { @@ -1262,18 +1277,31 @@ void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef, } } +// --> OD 2009-07-22 #i73249# +void XMLTextFrameContext_Impl::SetTitle( const OUString& rTitle ) +{ + if ( xPropSet.is() ) + { + Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); + if( xPropSetInfo->hasPropertyByName( sTitle ) ) + { + xPropSet->setPropertyValue( sTitle, makeAny( rTitle ) ); + } + } +} + void XMLTextFrameContext_Impl::SetDesc( const OUString& rDesc ) { if ( xPropSet.is() ) { - Reference< XPropertySetInfo > xPropSetInfo = - xPropSet->getPropertySetInfo(); - if( xPropSetInfo->hasPropertyByName( sAlternativeText ) ) + Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); + if( xPropSetInfo->hasPropertyByName( sDescription ) ) { - xPropSet->setPropertyValue( sAlternativeText, makeAny( rDesc ) ); + xPropSet->setPropertyValue( sDescription, makeAny( rDesc ) ); } } } +// <-- //----------------------------------------------------------------------------------------------------- @@ -1312,6 +1340,10 @@ XMLTextFrameContext::XMLTextFrameContext( : SvXMLImportContext( rImport, nPrfx, rLName ) , m_xAttrList( new SvXMLAttributeList( xAttrList ) ) , m_pHyperlink( 0 ) +// --> OD 2009-07-22 #i73249# +, m_sTitle() +, m_sDesc() +// <-- , m_eDefaultAnchorType( eATyp ) // --> OD 2006-03-10 #i51726# , m_HasAutomaticStyleWithoutParentStyle( sal_False ) @@ -1374,9 +1406,20 @@ void XMLTextFrameContext::EndElement() { pImpl->CreateIfNotThere(); - // alternative text + // --> OD 2009-07-22 #i73249# +// // alternative text +// if( m_sDesc.getLength() ) +// pImpl->SetDesc( m_sDesc ); + // svg:title + if( m_sTitle.getLength() ) + { + pImpl->SetTitle( m_sTitle ); + } if( m_sDesc.getLength() ) + { pImpl->SetDesc( m_sDesc ); + } + // <-- if( m_pHyperlink ) { @@ -1494,10 +1537,40 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( // the child is a writer frame if( XML_NAMESPACE_SVG == p_nPrefix ) { - bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); - if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) ) - pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName, - xAttrList, m_sDesc ); + // --> OD 2009-07-22 #i73249# +// bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); +// if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) ) +// pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName, +// xAttrList, m_sDesc ); + const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); + if ( bOld ) + { + if ( IsXMLToken( rLocalName, XML_DESC ) ) + { + pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), + p_nPrefix, + rLocalName, + m_sTitle ); + } + } + else + { + if( IsXMLToken( rLocalName, XML_TITLE ) ) + { + pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), + p_nPrefix, + rLocalName, + m_sTitle ); + } + else if ( IsXMLToken( rLocalName, XML_DESC ) ) + { + pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), + p_nPrefix, + rLocalName, + m_sDesc ); + } + } + // <-- } else if( XML_NAMESPACE_DRAW == p_nPrefix ) { diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx index 9b620a993590..51e41d45367c 100644 --- a/xmloff/source/text/XMLTextFrameContext.hxx +++ b/xmloff/source/text/XMLTextFrameContext.hxx @@ -53,6 +53,9 @@ class XMLTextFrameContext : public SvXMLImportContext SvXMLAttributeList *m_pAttrList; XMLTextFrameContextHyperlink_Impl *m_pHyperlink; + // --> OD 2009-07-22 #i73249# + ::rtl::OUString m_sTitle; + // <-- ::rtl::OUString m_sDesc; ::com::sun::star::text::TextContentAnchorType m_eDefaultAnchorType; diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index 04201990b797..1091636c9d3f 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -308,39 +308,57 @@ Reference<XInterface> XMLTextMarkImportContext::CreateAndInsertMark( const OUString& i_rXmlId) { // create mark - Reference<XMultiServiceFactory> xFactory(rImport.GetModel(),UNO_QUERY); - if( xFactory.is() ) + const Reference<XMultiServiceFactory> xFactory(rImport.GetModel(), + UNO_QUERY); + Reference<XInterface> xIfc; + + if (xFactory.is()) { - Reference<XInterface> xIfc = xFactory->createInstance(sServiceName); + xIfc = xFactory->createInstance(sServiceName); - // set name - Reference<XNamed> xNamed(xIfc, UNO_QUERY); + if (!xIfc.is()) + { + OSL_ENSURE(false, "CreateAndInsertMark: cannot create service?"); + return 0; + } + + // set name (unless there is no name (text:meta)) + const Reference<XNamed> xNamed(xIfc, UNO_QUERY); if (xNamed.is()) { xNamed->setName(sMarkName); + } + else + { + if (sMarkName.getLength()) + { + OSL_ENSURE(false, "name given, but XNamed not supported?"); + return 0; + } + } - // xml:id for RDF metadata - rImport.SetXmlId(xIfc, i_rXmlId); + // xml:id for RDF metadata + rImport.SetXmlId(xIfc, i_rXmlId); - // cast to XTextContent and attach to document - Reference<XTextContent> xTextContent(xIfc, UNO_QUERY); - if (xTextContent.is()) + // cast to XTextContent and attach to document + const Reference<XTextContent> xTextContent(xIfc, UNO_QUERY); + if (xTextContent.is()) + { + try { - try - { // if inserting marks, bAbsorb==sal_False will cause // collapsing of the given XTextRange. - rImport.GetTextImport()->GetText()->insertTextContent(rRange, - xTextContent, sal_True); - } - catch (com::sun::star::lang::IllegalArgumentException e) - { - // ignore - } + rImport.GetTextImport()->GetText()->insertTextContent(rRange, + xTextContent, sal_True); + } + catch (com::sun::star::lang::IllegalArgumentException &) + { + OSL_ENSURE(false, "CreateAndInsertMark: cannot insert?"); + return 0; } } - return xIfc; - } else return NULL; + } + return xIfc; } sal_Bool XMLTextMarkImportContext::FindName( diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index e8344e757aed..a2b0146a6cfa 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -44,9 +44,6 @@ #include <xmloff/xmlnume.hxx> #include "numehelp.hxx" -#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX -#include <xmloff/maptypes.hxx> -#endif #include <xmloff/families.hxx> #include <xmloff/XMLEventExport.hxx> #include "XMLTextCharStyleNamesElementExport.hxx" @@ -65,9 +62,7 @@ #include <com/sun/star/text/XDependentTextField.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp> -#ifndef _COM_SUN_STAR_TEXT_SETVARIABLETYPE_HPP #include <com/sun/star/text/SetVariableType.hpp> -#endif #include <com/sun/star/text/PlaceholderType.hpp> #include <com/sun/star/text/FilenameDisplayFormat.hpp> #include <com/sun/star/text/ChapterFormat.hpp> @@ -78,6 +73,7 @@ #include <com/sun/star/util/NumberFormat.hpp> #include <com/sun/star/text/BibliographyDataType.hpp> #include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/rdf/XMetadatable.hpp> #include <rtl/ustrbuf.hxx> #include <tools/debug.hxx> #include <rtl/math.hxx> @@ -152,6 +148,7 @@ static sal_Char __READONLY_DATA FIELD_SERVICE_BIBLIOGRAPHY[] = "Bibliography"; static sal_Char __READONLY_DATA FIELD_SERVICE_SCRIPT[] = "Script"; static sal_Char __READONLY_DATA FIELD_SERVICE_ANNOTATION[] = "Annotation"; static sal_Char __READONLY_DATA FIELD_SERVICE_COMBINED_CHARACTERS[] = "CombinedCharacters"; +static sal_Char __READONLY_DATA FIELD_SERVICE_META[] = "MetaField"; static sal_Char __READONLY_DATA FIELD_SERVICE_MEASURE[] = "Measure"; static sal_Char __READONLY_DATA FIELD_SERVICE_TABLE_FORMULA[] = "TableFormula"; static sal_Char __READONLY_DATA FIELD_SERVICE_DROP_DOWN[] = "DropDown"; @@ -219,6 +216,7 @@ SvXMLEnumStringMapEntry __READONLY_DATA aFieldServiceNameMapping[] = ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_ANNOTATION, FIELD_ID_ANNOTATION ), ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_COMBINED_CHARACTERS, FIELD_ID_COMBINED_CHARACTERS ), + ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_META, FIELD_ID_META ), // non-writer fields ENUM_STRING_MAP_ENTRY( FIELD_SERVICE_SHEET_NAME, FIELD_ID_SHEET_NAME ), @@ -604,6 +602,7 @@ enum FieldIdEnum XMLTextFieldExport::MapFieldName( case FIELD_ID_TEMPLATE_NAME: case FIELD_ID_CHAPTER: case FIELD_ID_FILE_NAME: + case FIELD_ID_META: case FIELD_ID_SHEET_NAME: case FIELD_ID_MEASURE: case FIELD_ID_URL: @@ -646,6 +645,9 @@ sal_Bool XMLTextFieldExport::IsStringField( return !bRet; } + case FIELD_ID_META://FIXME ?????? no idea... + return 0 > GetIntProperty(sPropertyNumberFormat, xPropSet); + case FIELD_ID_DATABASE_DISPLAY: // TODO: depends on... ??? // workaround #no-bug#: no data type @@ -738,7 +740,7 @@ sal_Bool XMLTextFieldExport::IsStringField( /// export the styles needed by the given field. Called on first pass /// through document void XMLTextFieldExport::ExportFieldAutoStyle( - const Reference<XTextField> & rTextField) + const Reference<XTextField> & rTextField, sal_Bool bProgress ) { // get property set Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY); @@ -831,6 +833,10 @@ void XMLTextFieldExport::ExportFieldAutoStyle( } break; + case FIELD_ID_META: + // recurse into content (does not export element, so can be done first) + ExportMetaField(xPropSet, true, bProgress); + // fall-through: for the meta-field itself! case FIELD_ID_DOCINFO_PRINT_TIME: case FIELD_ID_DOCINFO_PRINT_DATE: case FIELD_ID_DOCINFO_CREATION_DATE: @@ -948,7 +954,8 @@ void XMLTextFieldExport::ExportFieldAutoStyle( } /// export the given field to XML. Called on second pass through document -void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField ) +void XMLTextFieldExport::ExportField( + const Reference<XTextField> & rTextField, sal_Bool bProgress ) { // get property set Reference<XPropertySet> xPropSet(rTextField, UNO_QUERY); @@ -1026,7 +1033,8 @@ void XMLTextFieldExport::ExportField(const Reference<XTextField> & rTextField ) sal_False, sal_False); // finally, export the field itself - ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken ); + ExportFieldHelper( rTextField, xPropSet, xRangePropSet, nToken, + bProgress ); } } @@ -1035,7 +1043,8 @@ void XMLTextFieldExport::ExportFieldHelper( const Reference<XTextField> & rTextField, const Reference<XPropertySet> & rPropSet, const Reference<XPropertySet> &, - enum FieldIdEnum nToken) + enum FieldIdEnum nToken, + sal_Bool bProgress ) { // get property set info (because some attributes are not support // in all implementations) @@ -1738,11 +1747,17 @@ void XMLTextFieldExport::ExportFieldHelper( { // The style with the combined characters attribute has // already been handled in the ExportField method. So all that - // is left to do now is to exprot the characters. + // is left to do now is to export the characters. GetExport().Characters(sPresentation); break; } + case FIELD_ID_META: + { + ExportMetaField(rPropSet, false, bProgress); + break; + } + case FIELD_ID_MEASURE: { ProcessString(XML_KIND, MapMeasureKind(GetInt16Property(sPropertyMeasureKind, rPropSet))); @@ -2248,6 +2263,47 @@ void XMLTextFieldExport::ExportMacro( GetExport().Characters(rContent); } +// FIXME: this is untested +void XMLTextFieldExport::ExportMetaField( + const Reference<XPropertySet> & i_xMeta, + bool i_bAutoStyles, sal_Bool i_bProgress ) +{ + bool doExport(!i_bAutoStyles); // do not export element if autostyles + // check version >= 1.2 + switch (GetExport().getDefaultVersion()) { + case SvtSaveOptions::ODFVER_011: // fall thru + case SvtSaveOptions::ODFVER_010: doExport = false; break; + default: break; + } + + const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW ); + const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() ); + + if (doExport) + { + const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW ); + + // style:data-style-name + ProcessValueAndType(sal_False, + GetIntProperty(sPropertyNumberFormat, i_xMeta), + sEmpty, sEmpty, 0.0, sal_False, sal_False, sal_True, + sal_False, sal_False /*, sal_False*/ ); + + // text:meta-field without xml:id is invalid + xMeta->ensureMetadataReference(); + + // xml:id for RDF metadata + GetExport().AddAttributeXmlId(xMeta); + } + + SvXMLElementExport aElem( GetExport(), doExport, + XML_NAMESPACE_TEXT, XML_META_FIELD, sal_False, sal_False ); + + // recurse to export content + GetExport().GetTextParagraphExport()-> + exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_bProgress ); +} + /// export all data-style related attributes void XMLTextFieldExport::ProcessValueAndType( sal_Bool bIsString, /// do we process a string or a number? diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 04ac465daa3f..add97d20efda 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -327,7 +327,11 @@ static __FAR_DATA SvXMLTokenMapEntry aTextPElemTokenMap[] = static __FAR_DATA SvXMLTokenMapEntry aTextPAttrTokenMap[] = { - { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_P_XMLID }, + { XML_NAMESPACE_XML , XML_ID, XML_TOK_TEXT_P_XMLID }, + { XML_NAMESPACE_XHTML, XML_ABOUT, XML_TOK_TEXT_P_ABOUT }, + { XML_NAMESPACE_XHTML, XML_PROPERTY, XML_TOK_TEXT_P_PROPERTY }, + { XML_NAMESPACE_XHTML, XML_CONTENT, XML_TOK_TEXT_P_CONTENT }, + { XML_NAMESPACE_XHTML, XML_DATATYPE, XML_TOK_TEXT_P_DATATYPE }, { XML_NAMESPACE_TEXT, XML_STYLE_NAME, XML_TOK_TEXT_P_STYLE_NAME }, { XML_NAMESPACE_TEXT, XML_COND_STYLE_NAME, XML_TOK_TEXT_P_COND_STYLE_NAME }, @@ -927,6 +931,134 @@ OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars, return bConverted ? sChars.makeStringAndClear() : rChars; } +// --> OD 2006-10-12 #i69629# +// helper method to determine, if a paragraph style has a list style (inclusive +// an empty one) inherits a list style (inclusive an empty one) from one of its parents +// --> OD 2007-01-29 #i73973# +// apply special case, that found list style equals the chapter numbering, also +// to the found list styles of the parent styles. +sal_Bool lcl_HasListStyle( OUString sStyleName, + const Reference < XNameContainer >& xParaStyles, + SvXMLImport& rImport, + const OUString& sNumberingStyleName, + const OUString& sOutlineStyleName ) +{ + sal_Bool bRet( sal_False ); + + if ( !xParaStyles->hasByName( sStyleName ) ) + { + // error case + return sal_True; + } + + Reference< XPropertyState > xPropState( xParaStyles->getByName( sStyleName ), + UNO_QUERY ); + if ( !xPropState.is() ) + { + // error case + return sal_False; + } + + if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE ) + { + // list style found + bRet = sal_True; + // special case: the set list style equals the chapter numbering + Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY ); + if ( xPropSet.is() ) + { + OUString sListStyle; + xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle; + if ( sListStyle.getLength() != 0 && + sListStyle == sOutlineStyleName ) + { + bRet = sal_False; + } + } + } + else + { + // --> OD 2007-12-07 #i77708# + sal_Int32 nUPD( 0 ); + sal_Int32 nBuild( 0 ); + // --> OD 2008-03-19 #i86058# +// rImport.getBuildIds( nUPD, nBuild ); + const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild ); + // <-- + // <-- + // search list style at parent + Reference<XStyle> xStyle( xPropState, UNO_QUERY ); + while ( xStyle.is() ) + { + OUString aParentStyle( xStyle->getParentStyle() ); + if ( aParentStyle.getLength() > 0 ) + { + aParentStyle = + rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH, + aParentStyle ); + } + if ( aParentStyle.getLength() == 0 || + !xParaStyles->hasByName( aParentStyle ) ) + { + // no list style found + break; + } + else + { + xPropState = Reference< XPropertyState >( + xParaStyles->getByName( aParentStyle ), + UNO_QUERY ); + if ( !xPropState.is() ) + { + // error case + return sal_True; + } + if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE ) + { + // list style found + bRet = sal_True; + // --> OD 2007-01-29 #i73973# + // special case: the found list style equals the chapter numbering + Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY ); + if ( xPropSet.is() ) + { + OUString sListStyle; + xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle; + if ( sListStyle.getLength() != 0 && + sListStyle == sOutlineStyleName ) + { + bRet = sal_False; + } + // --> OD 2007-12-07 #i77708# + // special handling for text documents from OOo version prior OOo 2.4 + // --> OD 2008-03-19 #i86058# + // check explicitly on certain versions and on import of + // text documents in OpenOffice.org file format + else if ( sListStyle.getLength() == 0 && + ( rImport.IsTextDocInOOoFileFormat() || + ( bBuildIdFound && + ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0 + ( nUPD == 680 && nBuild <= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1 + { + bRet = sal_False; + } + // <-- + } + // <-- + break; + } + else + { + // search list style at parent + xStyle = Reference<XStyle>( xPropState, UNO_QUERY ); + } + } + } + } + + return bRet; +} +// <-- OUString XMLTextImportHelper::SetStyleAndAttrs( SvXMLImport& rImport, const Reference < XTextCursor >& rCursor, @@ -1237,14 +1369,20 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( // Some minor rework and adjust access to paragraph styles if ( bPara ) { + // --> OD 2009-08-18 #i103817# + sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0; + const bool bHasOutlineLevelProp( xPropSetInfo->hasPropertyByName( sOutlineLevel ) ); + if ( bHasOutlineLevelProp ) + { + xPropSet->getPropertyValue( sOutlineLevel ) >>= nCurrentOutlineLevelInheritedFromParagraphStyle; + } + // <-- //if ( bPara && nOutlineLevel != -1 ) //#outline level,removed by zhaojianwei if ( nOutlineLevel > 0 ) //add by zhaojianwei { //#outline level,removed by zhaojianwei - if ( xPropSetInfo->hasPropertyByName( sOutlineLevel ) ) + if ( bHasOutlineLevelProp ) { - sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0; - xPropSet->getPropertyValue( sOutlineLevel ) >>= nCurrentOutlineLevelInheritedFromParagraphStyle; // In case that the value equals the value of its paragraph style // attribute outline level, the paragraph attribute value is left unset if ( nCurrentOutlineLevelInheritedFromParagraphStyle != nOutlineLevel ) @@ -1323,15 +1461,33 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( { AddOutlineStyleCandidate( nOutlineLevel, sStyleName ); } + // --> OD 2009-08-18 #i103817# + // Assure that heading applies the outline style + if ( ( !pStyle || !pStyle->IsListStyleSet() ) && + !bOutlineStyleCandidate && + xChapterNumbering.is() ) + { + OUString sEmptyStr; + if ( !lcl_HasListStyle( sStyleName, + xParaStyles, GetXMLImport(), + sNumberingStyleName, + sEmptyStr ) ) + { + // heading not in a list --> apply outline style + xPropSet->setPropertyValue( sNumberingRules, + makeAny(xChapterNumbering) ); + xPropSet->setPropertyValue( sNumberingLevel, + makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) ); + } + } + // <-- } // <-- } //-> #outlinelevel added by zhaojianwei //handle for text:p,if the paragraphstyle outlinelevel is set to[1~10] - else if( xPropSetInfo->hasPropertyByName( sOutlineLevel ) ) + else if( bHasOutlineLevelProp ) { - sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0; - xPropSet->getPropertyValue( sOutlineLevel ) >>= nCurrentOutlineLevelInheritedFromParagraphStyle; if ( nCurrentOutlineLevelInheritedFromParagraphStyle != 0 ) { sal_Int16 nZero = 0; @@ -1424,132 +1580,6 @@ void XMLTextImportHelper::AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel // <-- // --> OD 2006-10-12 #i69629# -// helper method to determine, if a paragraph style has a list style (inclusive -// an empty one) inherits a list style (inclusive an empty one) from one of its parents -// --> OD 2007-01-29 #i73973# -// apply special case, that found list style equals the chapter numbering, also -// to the found list styles of the parent styles. -sal_Bool lcl_HasListStyle( OUString sStyleName, - const Reference < XNameContainer >& xParaStyles, - SvXMLImport& rImport, - const OUString& sNumberingStyleName, - const OUString& sOutlineStyleName ) -{ - sal_Bool bRet( sal_False ); - - if ( !xParaStyles->hasByName( sStyleName ) ) - { - // error case - return sal_True; - } - - Reference< XPropertyState > xPropState( xParaStyles->getByName( sStyleName ), - UNO_QUERY ); - if ( !xPropState.is() ) - { - // error case - return sal_False; - } - - if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE ) - { - // list style found - bRet = sal_True; - // special case: the set list style equals the chapter numbering - Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY ); - if ( xPropSet.is() ) - { - OUString sListStyle; - xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle; - if ( sListStyle == sOutlineStyleName ) - { - bRet = sal_False; - } - } - } - else - { - // --> OD 2007-12-07 #i77708# - sal_Int32 nUPD( 0 ); - sal_Int32 nBuild( 0 ); - // --> OD 2008-03-19 #i86058# -// rImport.getBuildIds( nUPD, nBuild ); - const bool bBuildIdFound = rImport.getBuildIds( nUPD, nBuild ); - // <-- - // <-- - // search list style at parent - Reference<XStyle> xStyle( xPropState, UNO_QUERY ); - while ( xStyle.is() ) - { - OUString aParentStyle( xStyle->getParentStyle() ); - if ( aParentStyle.getLength() > 0 ) - { - aParentStyle = - rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_PARAGRAPH, - aParentStyle ); - } - if ( aParentStyle.getLength() == 0 || - !xParaStyles->hasByName( aParentStyle ) ) - { - // no list style found - break; - } - else - { - xPropState = Reference< XPropertyState >( - xParaStyles->getByName( aParentStyle ), - UNO_QUERY ); - if ( !xPropState.is() ) - { - // error case - return sal_True; - } - if ( xPropState->getPropertyState( sNumberingStyleName ) == PropertyState_DIRECT_VALUE ) - { - // list style found - bRet = sal_True; - // --> OD 2007-01-29 #i73973# - // special case: the found list style equals the chapter numbering - Reference< XPropertySet > xPropSet( xPropState, UNO_QUERY ); - if ( xPropSet.is() ) - { - OUString sListStyle; - xPropSet->getPropertyValue( sNumberingStyleName ) >>= sListStyle; - if ( sListStyle == sOutlineStyleName ) - { - bRet = sal_False; - } - // --> OD 2007-12-07 #i77708# - // special handling for text documents from OOo version prior OOo 2.4 - // --> OD 2008-03-19 #i86058# - // check explicitly on certain versions and on import of - // text documents in OpenOffice.org file format - else if ( sListStyle.getLength() == 0 && - ( rImport.IsTextDocInOOoFileFormat() || - ( bBuildIdFound && - ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0 - ( nUPD == 680 && nBuild <= 9238 ) ) ) ) ) // OOo 2.0 - OOo 2.3.1 - { - bRet = sal_False; - } - // <-- - } - // <-- - break; - } - else - { - // search list style at parent - xStyle = Reference<XStyle>( xPropState, UNO_QUERY ); - } - } - } - } - - return bRet; -} -// <-- -// --> OD 2006-10-12 #i69629# void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels ) { if ( ( mpOutlineStylesCandidates != NULL || bSetEmptyLevels ) && diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx index 5ccf3652eebe..4dca73940dba 100644 --- a/xmloff/source/text/txtimppr.cxx +++ b/xmloff/source/text/txtimppr.cxx @@ -39,6 +39,7 @@ #include <tools/string.hxx> #include <xmloff/XMLFontStylesContext.hxx> #include <xmloff/txtprmap.hxx> +#include <xmloff/xmlimp.hxx> #include "txtimppr.hxx" #define XML_LINE_LEFT 0 @@ -120,11 +121,21 @@ sal_Bool XMLTextImportPropertyMapper::handleSpecialItem( case CTF_FONTFAMILYNAME: case CTF_FONTFAMILYNAME_CJK: case CTF_FONTFAMILYNAME_CTL: - case CTF_TEXT_DISPLAY: bRet = getPropertySetMapper()->importXML( rValue, rProperty, rUnitConverter ); break; + case CTF_TEXT_DISPLAY: + bRet = getPropertySetMapper()->importXML( rValue, rProperty, + rUnitConverter ); + if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() ) + { + sal_Bool bHidden; + rProperty.maValue >>= bHidden; + bHidden = !bHidden; + rProperty.maValue <<= bHidden; + } + break; default: bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty, rProperties, rValue, rUnitConverter, rNamespaceMap ); diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 3f243e52cbdc..d9b66ffa3653 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -65,15 +65,11 @@ #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/text/XTextFrame.hpp> -#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_ #include <com/sun/star/container/XNameAccess.hpp> -#endif #include <com/sun/star/text/SizeType.hpp> #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/VertOrientation.hpp> -#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP #include <com/sun/star/text/TextContentAnchorType.hpp> -#endif #include <com/sun/star/text/XTextFramesSupplier.hpp> #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> @@ -111,28 +107,23 @@ #include <xmloff/nmspmap.hxx> #include <xmloff/xmlexp.hxx> #include "txtflde.hxx" -#ifndef _XMLOFF_TXTPRMAP_HXX #include <xmloff/txtprmap.hxx> -#endif #include "XMLImageMapExport.hxx" #include "XMLTextNumRuleInfo.hxx" #include "XMLTextListAutoStylePool.hxx" -#ifndef _XMLOFF_TXTPARAE_HXX #include <xmloff/txtparae.hxx> -#endif #include "XMLSectionExport.hxx" #include "XMLIndexMarkExport.hxx" #include <xmloff/XMLEventExport.hxx> #include "XMLRedlineExport.hxx" -#ifndef _XMLOFF_MULTIPROPERTYSETHELPER_HXX #include "MultiPropertySetHelper.hxx" -#endif #include <xmloff/formlayerexport.hxx> #include "XMLTextCharStyleNamesElementExport.hxx" // --> OD 2008-04-25 #refactorlists# #include <txtlists.hxx> // <-- +#include <com/sun/star/rdf/XMetadatable.hpp> using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -975,23 +966,29 @@ void XMLTextParagraphExport::exportListChange( // <text:list-header> or <text:list-item> GetExport().CheckAttrList(); - if ( nListLevelsToBeOpened == 1 && - rNextInfo.HasStartValue() ) + // --> OD 2009-06-24 #i97309# + // export start value in case of <bRestartNumberingAtContinuedRootList> + // at correct list item + if ( nListLevelsToBeOpened == 1 ) { - OUStringBuffer aBuffer; - aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() ); - GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE, - aBuffer.makeStringAndClear() ); - } - else if ( bRestartNumberingAtContinuedRootList ) - { - OUStringBuffer aBuffer; - aBuffer.append( (sal_Int32)nRestartValueForContinuedRootList ); - GetExport().AddAttribute( XML_NAMESPACE_TEXT, - XML_START_VALUE, - aBuffer.makeStringAndClear() ); - bRestartNumberingAtContinuedRootList = false; + if ( rNextInfo.HasStartValue() ) + { + OUStringBuffer aBuffer; + aBuffer.append( (sal_Int32)rNextInfo.GetStartValue() ); + GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE, + aBuffer.makeStringAndClear() ); + } + else if ( bRestartNumberingAtContinuedRootList ) + { + OUStringBuffer aBuffer; + aBuffer.append( (sal_Int32)nRestartValueForContinuedRootList ); + GetExport().AddAttribute( XML_NAMESPACE_TEXT, + XML_START_VALUE, + aBuffer.makeStringAndClear() ); + bRestartNumberingAtContinuedRootList = false; + } } + // <-- eLName = ( rNextInfo.IsNumbered() || nListLevelsToBeOpened > 1 ) ? XML_LIST_ITEM @@ -1131,7 +1128,11 @@ XMLTextParagraphExport::XMLTextParagraphExport( // <-- sActualSize(RTL_CONSTASCII_USTRINGPARAM("ActualSize")), - sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")), + // --> OD 2009-07-22 #i73249# +// sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")), + sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")), + sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")), + // <-- sAnchorCharStyleName(RTL_CONSTASCII_USTRINGPARAM("AnchorCharStyleName")), sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")), sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")), @@ -1460,7 +1461,8 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( sal_Bool bIsProgres { Any aAny = xTextFieldsEnum->nextElement(); Reference< XTextField > xTextField = *(Reference<XTextField>*)aAny.getValue(); - exportTextField( xTextField->getAnchor(), bAutoStyles ); + exportTextField( xTextField->getAnchor(), bAutoStyles, + bIsProgress ); try { Reference < XPropertySet > xSet( xTextField, UNO_QUERY ); @@ -1905,6 +1907,7 @@ void XMLTextParagraphExport::exportParagraph( { // xml:id for RDF metadata GetExport().AddAttributeXmlId(rTextContent); + GetExport().AddAttributesRDFa(rTextContent); OUString sStyle; if( rPropSetHelper.hasProperty( PARA_STYLE_NAME ) ) @@ -2142,6 +2145,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( sal_Bool bAutoStyles, sal_Bool bIsProgress, sal_Bool bPrvChrIsSpc ) { + static OUString sMeta(RTL_CONSTASCII_USTRINGPARAM("Meta")); // FIXME sal_Bool bPrevCharIsSpace = bPrvChrIsSpc; while( rTextEnum->hasMoreElements() ) @@ -2162,7 +2166,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( } else if( sType.equals(sTextField)) { - exportTextField( xTxtRange, bAutoStyles ); + exportTextField( xTxtRange, bAutoStyles, bIsProgress ); bPrevCharIsSpace = sal_False; } else if( sType.equals( sFrame ) ) @@ -2217,6 +2221,10 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( { exportRuby(xPropSet, bAutoStyles); } + else if (sType.equals(sMeta)) + { + exportMeta(xPropSet, bAutoStyles, bIsProgress); + } else if (sType.equals(sTextFieldStart)) { Reference<XNamed> xBookmark(xPropSet->getPropertyValue(sBookmark), UNO_QUERY); @@ -2286,7 +2294,7 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( Reference<XServiceInfo> xServiceInfo( xTxtRange, UNO_QUERY ); if( xServiceInfo->supportsService( sTextFieldService ) ) { - exportTextField( xTxtRange, bAutoStyles ); + exportTextField( xTxtRange, bAutoStyles, bIsProgress ); bPrevCharIsSpace = sal_False; } else @@ -2308,7 +2316,7 @@ void XMLTextParagraphExport::exportTable( void XMLTextParagraphExport::exportTextField( const Reference < XTextRange > & rTextRange, - sal_Bool bAutoStyles ) + sal_Bool bAutoStyles, sal_Bool bIsProgress ) { Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY ); // non-Writer apps need not support Property TextField, so test first @@ -2320,11 +2328,11 @@ void XMLTextParagraphExport::exportTextField( { if( bAutoStyles ) { - pFieldExport->ExportFieldAutoStyle( xTxtFld ); + pFieldExport->ExportFieldAutoStyle( xTxtFld, bIsProgress ); } else { - pFieldExport->ExportField( xTxtFld ); + pFieldExport->ExportField( xTxtFld, bIsProgress ); } } else @@ -2778,6 +2786,10 @@ void XMLTextParagraphExport::_exportTextFrame( // image map GetExport().GetImageMapExport().Export( rPropSet ); + // --> OD 2009-07-22 #i73249# + // svg:title and svg:desc + exportTitleAndDescription( rPropSet, rPropSetInfo ); + // <-- } void XMLTextParagraphExport::exportContour( @@ -2969,8 +2981,10 @@ void XMLTextParagraphExport::_exportTextGraphic( // image map GetExport().GetImageMapExport().Export( rPropSet ); - // svg:desc - exportAlternativeText( rPropSet, rPropSetInfo ); + // --> OD 2009-07-22 #i73249# + // svg:title and svg:desc + exportTitleAndDescription( rPropSet, rPropSetInfo ); + // <-- // draw:contour exportContour( rPropSet, rPropSetInfo ); @@ -2999,23 +3013,39 @@ void XMLTextParagraphExport::exportEvents( const Reference < XPropertySet > & rP if (rPropSet->getPropertySetInfo()->hasPropertyByName(sImageMap)) GetExport().GetImageMapExport().Export( rPropSet ); } -void XMLTextParagraphExport::exportAlternativeText( + +// --> OD 2009-07-22 #i73249# +void XMLTextParagraphExport::exportTitleAndDescription( const Reference < XPropertySet > & rPropSet, const Reference < XPropertySetInfo > & rPropSetInfo ) { // svg:title - if( rPropSetInfo->hasPropertyByName( sAlternativeText ) ) + if( rPropSetInfo->hasPropertyByName( sTitle ) ) { - OUString sAltText; - rPropSet->getPropertyValue( sAlternativeText ) >>= sAltText; - if( sAltText.getLength() ) + OUString sObjTitle; + rPropSet->getPropertyValue( sTitle ) >>= sObjTitle; + if( sObjTitle.getLength() ) { SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG, XML_TITLE, sal_True, sal_False ); - GetExport().Characters( sAltText ); + GetExport().Characters( sObjTitle ); + } + } + + // svg:description + if( rPropSetInfo->hasPropertyByName( sDescription ) ) + { + OUString sObjDesc; + rPropSet->getPropertyValue( sDescription ) >>= sObjDesc; + if( sObjDesc.getLength() ) + { + SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_SVG, + XML_DESC, sal_True, sal_False ); + GetExport().Characters( sObjDesc ); } } } +// <-- void XMLTextParagraphExport::setTextEmbeddedGraphicURL( const Reference < XPropertySet >&, @@ -3634,7 +3664,41 @@ void XMLTextParagraphExport::exportRuby( } } +// FIXME: this is untested +void XMLTextParagraphExport::exportMeta( + const Reference<XPropertySet> & i_xMeta, + sal_Bool i_bAutoStyles, sal_Bool i_isProgress) +{ + bool doExport(!i_bAutoStyles); // do not export element if autostyles + // check version >= 1.2 + switch (GetExport().getDefaultVersion()) { + case SvtSaveOptions::ODFVER_011: // fall thru + case SvtSaveOptions::ODFVER_010: doExport = false; break; + default: break; + } + + const Reference < XEnumerationAccess > xEA( i_xMeta, UNO_QUERY_THROW ); + const Reference < XEnumeration > xTextEnum( xEA->createEnumeration() ); + + if (doExport) + { + const Reference<rdf::XMetadatable> xMeta( i_xMeta, UNO_QUERY_THROW ); + const Reference<XTextContent> xTextContent( i_xMeta, UNO_QUERY_THROW ); + + // text:meta with neither xml:id nor RDFa is invalid + xMeta->ensureMetadataReference(); + // xml:id and RDFa for RDF metadata + GetExport().AddAttributeXmlId(xMeta); + GetExport().AddAttributesRDFa(xTextContent); + } + + SvXMLElementExport aElem( GetExport(), doExport, + XML_NAMESPACE_TEXT, XML_META, sal_False, sal_False ); + + // recurse to export content + exportTextRangeEnumeration( xTextEnum, i_bAutoStyles, i_isProgress ); +} void XMLTextParagraphExport::PreventExportOfControlsInMuteSections( diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 31d2891f9f79..6fb213f43642 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -671,34 +671,33 @@ SvXMLImportContext *XMLImpRubyContext_Impl::CreateChildContext( // --------------------------------------------------------------------- -/** text:meta and text:meta-field -//FIXME neither finished nor tested +/** for text:meta and text:meta-field +//FIXME not tested */ -class XMLMetaImportContext : public SvXMLImportContext +class XMLMetaImportContextBase : public SvXMLImportContext { - XMLHints_Impl& mrHints; -// XMLStyleHint_Impl *pHint; + XMLHints_Impl& m_rHints; - sal_Bool& mrIgnoreLeadingSpace; + sal_Bool& m_rIgnoreLeadingSpace; /// start position - Reference<XTextRange> mxStart; + Reference<XTextRange> m_xStart; - OUString mXmlId; +protected: + OUString m_XmlId; public: TYPEINFO(); - XMLMetaImportContext( + XMLMetaImportContextBase( SvXMLImport& i_rImport, sal_uInt16 i_nPrefix, const OUString& i_rLocalName, const Reference< xml::sax::XAttributeList > & i_xAttrList, -// enum XMLTextPElemTokens nTok, XMLHints_Impl& i_rHints, sal_Bool & i_rIgnoreLeadingSpace ); - virtual ~XMLMetaImportContext(); + virtual ~XMLMetaImportContextBase(); virtual void EndElement(); @@ -707,25 +706,30 @@ public: const Reference< xml::sax::XAttributeList > & i_xAttrList ); virtual void Characters( const OUString& i_rChars ); + + virtual void ProcessAttribute(sal_uInt16 const i_nPrefix, + OUString const & i_rLocalName, OUString const & i_rValue); + + virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange) + = 0; }; -TYPEINIT1( XMLMetaImportContext , SvXMLImportContext ); +TYPEINIT1( XMLMetaImportContextBase, SvXMLImportContext ); -XMLMetaImportContext::XMLMetaImportContext( +XMLMetaImportContextBase::XMLMetaImportContextBase( SvXMLImport& i_rImport, sal_uInt16 i_nPrefix, const OUString& i_rLocalName, const Reference< xml::sax::XAttributeList > & i_xAttrList, XMLHints_Impl& i_rHints, sal_Bool & i_rIgnoreLeadingSpace ) - : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ), - mrHints( i_rHints ), - mrIgnoreLeadingSpace( i_rIgnoreLeadingSpace ), - mxStart() + : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ) + , m_rHints( i_rHints ) + , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace ) + , m_xStart() { -//FIXME: RDFa (text:meta) const sal_Int16 nAttrCount(i_xAttrList.is() ? i_xAttrList->getLength() : 0); - for( sal_Int16 i=0; i < nAttrCount; i++ ) + for ( sal_Int16 i=0; i < nAttrCount; i++ ) { const OUString& rAttrName( i_xAttrList->getNameByIndex( i ) ); const OUString& rValue( i_xAttrList->getValueByIndex( i ) ); @@ -734,49 +738,61 @@ XMLMetaImportContext::XMLMetaImportContext( sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &sLocalName ); -// FIXME: only meta-field - if( XML_NAMESPACE_TEXT == nPrefix && - IsXMLToken( sLocalName, XML_DATA_STYLE_NAME ) ) - { -// pHint->SetStyleName( rValue ); - break; - } - else if ( (XML_NAMESPACE_XML == nPrefix) && - IsXMLToken(sLocalName, XML_ID) ) - { - mXmlId = rValue; - } + ProcessAttribute(nPrefix, sLocalName, rValue); } - //FIXME meta-field xml:id mandatory - mxStart = GetImport().GetTextImport()->GetCursorAsRange()->getStart(); + m_xStart = GetImport().GetTextImport()->GetCursorAsRange()->getStart(); } -XMLMetaImportContext::~XMLMetaImportContext() +XMLMetaImportContextBase::~XMLMetaImportContextBase() { } -void XMLMetaImportContext::EndElement() +void XMLMetaImportContextBase::EndElement() { - OSL_ENSURE(mxStart.is(), "no mxStart?"); + OSL_ENSURE(m_xStart.is(), "no mxStart?"); + if (!m_xStart.is()) return; - Reference<XTextRange> xEndRange( + const Reference<XTextRange> xEndRange( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ); // create range for insertion - Reference<XTextCursor> xInsertionCursor( + const Reference<XTextCursor> xInsertionCursor( GetImport().GetTextImport()->GetText()->createTextCursorByRange( xEndRange) ); - xInsertionCursor->gotoRange(mxStart, sal_True); + xInsertionCursor->gotoRange(m_xStart, sal_True); - Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY); + const Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY); - OUString sName; + InsertMeta(xInsertionRange); //FIXME - // insert bookmark -// XMLTextMarkImportContext::CreateAndInsertMark +#if 0 + Reference<XMultiServiceFactory> xFactory(rImport.GetModel(), UNO_QUERY); + if ( xFactory.is() ) + { + Reference<XInterface> xIfc = xFactory->createInstance(sServiceName); + + // xml:id for RDF metadata + rImport.SetXmlId(xIfc, i_rXmlId); + + // cast to XTextContent and attach to document + Reference<XTextContent> xTextContent(xIfc, UNO_QUERY); + if (xTextContent.is()) + { + try + { + rImport.GetTextImport()->GetText()->insertTextContent( + xInsertionRange, xTextContent, sal_True); + } + catch (com::sun::star::lang::IllegalArgumentException &) + { + OSL_ENSURE(false, "XMLMetaImportContext::EndElement: iae"); + } + } + } +#endif } -SvXMLImportContext * XMLMetaImportContext::CreateChildContext( +SvXMLImportContext * XMLMetaImportContextBase::CreateChildContext( sal_uInt16 i_nPrefix, const OUString& i_rLocalName, const Reference< xml::sax::XAttributeList > & i_xAttrList ) { @@ -785,15 +801,236 @@ SvXMLImportContext * XMLMetaImportContext::CreateChildContext( sal_uInt16 nToken = rTokenMap.Get( i_nPrefix, i_rLocalName ); return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), i_nPrefix, - i_rLocalName, i_xAttrList, nToken, mrHints, mrIgnoreLeadingSpace ); + i_rLocalName, i_xAttrList, nToken, m_rHints, m_rIgnoreLeadingSpace ); } -void XMLMetaImportContext::Characters( const OUString& i_rChars ) +void XMLMetaImportContextBase::Characters( const OUString& i_rChars ) { - //FIXME do we need to call ConvertStarFonts? - GetImport().GetTextImport()->InsertString( i_rChars, mrIgnoreLeadingSpace ); + GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace); } +void XMLMetaImportContextBase::ProcessAttribute(sal_uInt16 const i_nPrefix, + OUString const & i_rLocalName, OUString const & i_rValue) +{ + if ( (XML_NAMESPACE_XML == i_nPrefix) && + IsXMLToken(i_rLocalName, XML_ID) ) + { + m_XmlId = i_rValue; + } +} + + +// --------------------------------------------------------------------- + +/** text:meta +//FIXME not tested + */ +class XMLMetaImportContext : public XMLMetaImportContextBase +{ + // RDFa + bool m_bHaveAbout; + ::rtl::OUString m_sAbout; + ::rtl::OUString m_sProperty; + ::rtl::OUString m_sContent; + ::rtl::OUString m_sDatatype; + +public: + TYPEINFO(); + + XMLMetaImportContext( + SvXMLImport& i_rImport, + sal_uInt16 i_nPrefix, + const OUString& i_rLocalName, + const Reference< xml::sax::XAttributeList > & i_xAttrList, + XMLHints_Impl& i_rHints, + sal_Bool & i_rIgnoreLeadingSpace ); + + virtual void ProcessAttribute(sal_uInt16 const i_nPrefix, + OUString const & i_rLocalName, OUString const & i_rValue); + + virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange); +}; + +TYPEINIT1( XMLMetaImportContext, XMLMetaImportContextBase ); + +XMLMetaImportContext::XMLMetaImportContext( + SvXMLImport& i_rImport, + sal_uInt16 i_nPrefix, + const OUString& i_rLocalName, + const Reference< xml::sax::XAttributeList > & i_xAttrList, + XMLHints_Impl& i_rHints, + sal_Bool & i_rIgnoreLeadingSpace ) + : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName, + i_xAttrList, i_rHints, i_rIgnoreLeadingSpace ) + , m_bHaveAbout(false) +{ +} + +void XMLMetaImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix, + OUString const & i_rLocalName, OUString const & i_rValue) +{ + if ( XML_NAMESPACE_XHTML == i_nPrefix ) + { + // RDFa + if ( IsXMLToken( i_rLocalName, XML_ABOUT) ) + { + m_sAbout = i_rValue; + m_bHaveAbout = true; + } + else if ( IsXMLToken( i_rLocalName, XML_PROPERTY) ) + { + m_sProperty = i_rValue; + } + else if ( IsXMLToken( i_rLocalName, XML_CONTENT) ) + { + m_sContent = i_rValue; + } + else if ( IsXMLToken( i_rLocalName, XML_DATATYPE) ) + { + m_sDatatype = i_rValue; + } + } + else + { + XMLMetaImportContextBase::ProcessAttribute( + i_nPrefix, i_rLocalName, i_rValue); + } +} + +void XMLMetaImportContext::InsertMeta( + const Reference<XTextRange> & i_xInsertionRange) +{ + OSL_ENSURE(!m_bHaveAbout == !m_sProperty.getLength(), + "XMLMetaImportContext::InsertMeta: invalid RDFa?"); + if (m_XmlId.getLength() || (m_bHaveAbout && m_sProperty.getLength())) + { + // insert mark + const uno::Reference<rdf::XMetadatable> xMeta( + XMLTextMarkImportContext::CreateAndInsertMark( + GetImport(), + OUString::createFromAscii( + "com.sun.star.text.InContentMetadata"), + OUString(), + i_xInsertionRange, m_XmlId), + uno::UNO_QUERY); + OSL_ENSURE(xMeta.is(), "cannot insert Meta?"); + + if (xMeta.is() && m_bHaveAbout) + { + GetImport().AddRDFa(xMeta, + m_sAbout, m_sProperty, m_sContent, m_sDatatype); + } + } + else + { + OSL_TRACE("invalid <text:meta>: no xml:id, no valid RDFa"); + } +} + +// --------------------------------------------------------------------- + +/** text:meta-field +//FIXME not tested + */ +class XMLMetaFieldImportContext : public XMLMetaImportContextBase +{ + OUString m_DataStyleName; + +public: + TYPEINFO(); + + XMLMetaFieldImportContext( + SvXMLImport& i_rImport, + sal_uInt16 i_nPrefix, + const OUString& i_rLocalName, + const Reference< xml::sax::XAttributeList > & i_xAttrList, + XMLHints_Impl& i_rHints, + sal_Bool & i_rIgnoreLeadingSpace ); + + virtual void ProcessAttribute(sal_uInt16 const i_nPrefix, + OUString const & i_rLocalName, OUString const & i_rValue); + + virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange); +}; + +TYPEINIT1( XMLMetaFieldImportContext, XMLMetaImportContextBase ); + +XMLMetaFieldImportContext::XMLMetaFieldImportContext( + SvXMLImport& i_rImport, + sal_uInt16 i_nPrefix, + const OUString& i_rLocalName, + const Reference< xml::sax::XAttributeList > & i_xAttrList, + XMLHints_Impl& i_rHints, + sal_Bool & i_rIgnoreLeadingSpace ) + : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName, + i_xAttrList, i_rHints, i_rIgnoreLeadingSpace ) +{ +} + +void XMLMetaFieldImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix, + OUString const & i_rLocalName, OUString const & i_rValue) +{ + if( XML_NAMESPACE_STYLE == i_nPrefix && + IsXMLToken( i_rLocalName, XML_DATA_STYLE_NAME ) ) + { + m_DataStyleName = i_rValue; + } + else + { + XMLMetaImportContextBase::ProcessAttribute( + i_nPrefix, i_rLocalName, i_rValue); + } +} + +void XMLMetaFieldImportContext::InsertMeta( + const Reference<XTextRange> & i_xInsertionRange) +{ + if (m_XmlId.getLength()) // valid? + { + // insert mark + const Reference<XPropertySet> xPropertySet( + XMLTextMarkImportContext::CreateAndInsertMark( + GetImport(), + OUString::createFromAscii( + "com.sun.star.text.textfield.MetadataField"), + OUString(), + i_xInsertionRange, m_XmlId), + UNO_QUERY); + OSL_ENSURE(xPropertySet.is(), "cannot insert MetaField?"); + if (!xPropertySet.is()) return; + + if (m_DataStyleName.getLength()) + { + sal_Bool isDefaultLanguage(sal_True); + + const sal_Int32 nKey( GetImport().GetTextImport()->GetDataStyleKey( + m_DataStyleName, & isDefaultLanguage) ); + + if (-1 != nKey) + { + static ::rtl::OUString sPropertyIsFixedLanguage( + ::rtl::OUString::createFromAscii("IsFixedLanguage") ); + Any any; + any <<= nKey; + xPropertySet->setPropertyValue( + OUString::createFromAscii("NumberFormat"), any); + if ( xPropertySet->getPropertySetInfo()-> + hasPropertyByName( sPropertyIsFixedLanguage ) ) + { + any <<= static_cast<bool>(!isDefaultLanguage); + xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, + any ); + } + } + } + } + else + { + OSL_TRACE("invalid <text:meta-field>: no xml:id"); + } +} + + // --------------------------------------------------------------------- @@ -1574,13 +1811,17 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( sal_False); break; - case XML_TOK_TEXT_META: - case XML_TOK_TEXT_META_FIELD: // FIXME: should test before enabling... #if 0 + case XML_TOK_TEXT_META: pContext = new XMLMetaImportContext(rImport, nPrefix, rLocalName, xAttrList, rHints, rIgnoreLeadingSpace ); break; + + case XML_TOK_TEXT_META_FIELD: + pContext = new XMLMetaFieldImportContext(rImport, nPrefix, rLocalName, + xAttrList, rHints, rIgnoreLeadingSpace ); + break; #endif default: @@ -1657,6 +1898,7 @@ XMLParaContext::XMLParaContext( sal_Bool bHead ) : SvXMLImportContext( rImport, nPrfx, rLName ), xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ), + m_bHaveAbout(false), nOutlineLevel( IsXMLToken( rLName, XML_H ) ? 1 : -1 ), pHints( 0 ), // --> OD 2007-07-25 #i73509# @@ -1686,9 +1928,21 @@ XMLParaContext::XMLParaContext( &aLocalName ); switch( rTokenMap.Get( nPrefix, aLocalName ) ) { -//FIXME: RDFa case XML_TOK_TEXT_P_XMLID: - sXmlId = rValue; + m_sXmlId = rValue; + break; + case XML_TOK_TEXT_P_ABOUT: + m_sAbout = rValue; + m_bHaveAbout = true; + break; + case XML_TOK_TEXT_P_PROPERTY: + m_sProperty = rValue; + break; + case XML_TOK_TEXT_P_CONTENT: + m_sContent = rValue; + break; + case XML_TOK_TEXT_P_DATATYPE: + m_sDatatype = rValue; break; case XML_TOK_TEXT_P_STYLE_NAME: sStyleName = rValue; @@ -1785,7 +2039,8 @@ XMLParaContext::~XMLParaContext() xAttrCursor->gotoRange( xEnd, sal_True ); // xml:id for RDF metadata - if (sXmlId.getLength() > 0) { + if (m_sXmlId.getLength() || m_bHaveAbout || m_sProperty.getLength()) + { try { const uno::Reference<container::XEnumerationAccess> xEA (xAttrCursor, uno::UNO_QUERY_THROW); @@ -1795,12 +2050,17 @@ XMLParaContext::~XMLParaContext() if (xEnum->hasMoreElements()) { uno::Reference<rdf::XMetadatable> xMeta; xEnum->nextElement() >>= xMeta; -//FIXME not yet -// OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable"); - GetImport().SetXmlId(xMeta, sXmlId); + OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable"); + GetImport().SetXmlId(xMeta, m_sXmlId); + if (m_bHaveAbout) + { + GetImport().AddRDFa(xMeta, + m_sAbout, m_sProperty, m_sContent, m_sDatatype); + } OSL_ENSURE(!xEnum->hasMoreElements(), "xml:id: > 1 paragraph?"); } } catch (uno::Exception &) { + OSL_TRACE("XMLParaContext::~XMLParaContext: exception"); } } diff --git a/xmloff/source/text/txtparai.hxx b/xmloff/source/text/txtparai.hxx index 781055d2f297..6eaeeee1ee46 100644 --- a/xmloff/source/text/txtparai.hxx +++ b/xmloff/source/text/txtparai.hxx @@ -50,7 +50,12 @@ class XMLParaContext : public SvXMLImportContext ::com::sun::star::text::XTextRange > xStart; // xub_StrLen nStart; ::rtl::OUString sStyleName; ::rtl::OUString sId; - ::rtl::OUString sXmlId; + ::rtl::OUString m_sXmlId; + ::rtl::OUString m_sAbout; + ::rtl::OUString m_sProperty; + ::rtl::OUString m_sContent; + ::rtl::OUString m_sDatatype; + bool m_bHaveAbout; sal_Int8 nOutlineLevel; XMLHints_Impl *pHints; // --> OD 2007-07-25 #i73509# diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx index 18946de8c3a6..c82e4d09e271 100644 --- a/xmloff/source/text/txtprmap.cxx +++ b/xmloff/source/text/txtprmap.cxx @@ -372,7 +372,7 @@ XMLPropertyMapEntry aXMLParaPropMap[] = // RES_PARATR_SNAPTOGRID MP_E( "SnapToGrid", STYLE, SNAP_TO_LAYOUT_GRID, XML_TYPE_BOOL, 0 ), - MP_ED( "WritingMode", STYLE, WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT, 0 ), + MP_ED( "WritingMode", STYLE, WRITING_MODE, XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT, CTF_TEXTWRITINGMODE ), MP_E( "ParaIsConnectBorder", STYLE, JOIN_BORDER, XML_TYPE_BOOL, 0 ), diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx index b5eb0a7bdfcb..c41d54bb00ed 100644 --- a/xmloff/source/text/txtstyli.cxx +++ b/xmloff/source/text/txtstyli.cxx @@ -547,30 +547,6 @@ void XMLTextStyleContext::FillPropertySet( struct XMLPropertyState& rState = GetProperties()[nIndex]; Any rAny = rState.maValue; sal_Int32 nMapperIndex = rState.mnIndex; - if( i == 3 ) - { - if( SvXMLImport::OOo_2x != GetImport().getGeneratorVersion() ) - continue; - sal_Bool bHidden; - rAny >>= bHidden; - bHidden = !bHidden; - Any aAny( rAny ); - aAny <<= bHidden; - // get property set mapper - UniReference<XMLPropertySetMapper> rPropMapper = - xImpPrMap->getPropertySetMapper(); - - // set property - OUString rPropertyName( - rPropMapper->GetEntryAPIName(nMapperIndex) ); - if( !xInfo.is() ) - xInfo = rPropSet->getPropertySetInfo(); - if ( xInfo->hasPropertyByName( rPropertyName ) ) - { - rPropSet->setPropertyValue( rPropertyName, aAny ); - } - continue; - } // Now check for font name in rState and set corrected value, // if necessary. |