diff options
author | os <os@openoffice.org> | 2010-06-04 16:00:27 +0200 |
---|---|---|
committer | os <os@openoffice.org> | 2010-06-04 16:00:27 +0200 |
commit | 75ea078b86a58ccdddd4cc4c4e21487e8128ae96 (patch) | |
tree | 6c4aca0eb04f50c78df4fabea03e3bb272b9a3a7 /xmloff/source | |
parent | 1c4ec00e55e5dbfef9de6ff4fb17fa1cd4216ec2 (diff) | |
parent | f8e7afbac976ca862a801b9648fd95b2107757b2 (diff) |
rebase to m80
Diffstat (limited to 'xmloff/source')
75 files changed, 1672 insertions, 1133 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 9940f99d9f7a..ccc400305044 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -41,9 +41,7 @@ #include <tools/globname.hxx> #include <sot/clsids.hxx> -#ifndef _SVTOOLS_NMSPMAP_HXX #include <xmloff/nmspmap.hxx> -#endif #include "xmlnmspe.hxx" #include <xmloff/xmltoken.hxx> #include <xmloff/families.hxx> @@ -649,7 +647,12 @@ lcl_TableData lcl_getDataForLocalTable( SchXMLExportHelper::tDataSequenceCont::const_iterator aIt( aBegin ); size_t nMaxSequenceLength( lcl_getMaxSequenceLength( aSequencesToExport )); - nMaxSequenceLength = std::max( nMaxSequenceLength, size_t( aSimpleCategories.getLength() ) ); + size_t nCategoriesLength( aSimpleCategories.getLength() ); + if( nCategoriesLength > nMaxSequenceLength ) + { + aSimpleCategories.realloc(nMaxSequenceLength);//#i110617# + nCategoriesLength = nMaxSequenceLength; + } size_t nNumColumns( bSeriesFromColumns ? nNumSequences : nMaxSequenceLength ); size_t nNumRows( bSeriesFromColumns ? nMaxSequenceLength : nNumSequences ); @@ -1084,6 +1087,7 @@ void SchXMLExportHelper::parseDocument( Reference< chart::XChartDocument >& rCha aDataProviderURL = OUString( RTL_CONSTASCII_USTRINGPARAM( "." ) ); } mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aDataProviderURL ); + mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); } OUString sChartType( xDiagram->getDiagramType() ); @@ -1520,8 +1524,11 @@ void SchXMLExportHelper::exportTable() // to allow a correct re-association when copying via clipboard if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd ) { - if( (*aColumnDescriptions_RangeIter).getLength()) - mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aColumnDescriptions_RangeIter ); + if ((*aColumnDescriptions_RangeIter).getLength()) + { + mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, + *aColumnDescriptions_RangeIter); + } ++aColumnDescriptions_RangeIter; } exportText( *aIt ); @@ -1553,7 +1560,10 @@ void SchXMLExportHelper::exportTable() // write the original range name as id into the local table // to allow a correct re-association when copying via clipboard if( !bHasOwnData && aRowDescriptions_RangeIter != aRowDescriptions_RangeEnd ) - mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aRowDescriptions_RangeIter++ ); + { + mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, + *aRowDescriptions_RangeIter++); + } exportText( *aRowDescriptionsIter ); ++aRowDescriptionsIter; if( nC < nComplexCount ) @@ -1575,8 +1585,11 @@ void SchXMLExportHelper::exportTable() if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) && ( mbRowSourceColumns || (aColIt == aRowIt->begin())) ) { - if( (*aDataRangeIter).getLength()) - mrExport.AddAttribute( XML_NAMESPACE_TEXT, XML_ID, *aDataRangeIter ); + if ((*aDataRangeIter).getLength()) + { + mrExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, + *aDataRangeIter); + } ++aDataRangeIter; } exportText( msString, false ); // do not convert tabs and lfs diff --git a/xmloff/source/chart/SchXMLParagraphContext.cxx b/xmloff/source/chart/SchXMLParagraphContext.cxx index 646d82e4ab79..972bc9016d4f 100644 --- a/xmloff/source/chart/SchXMLParagraphContext.cxx +++ b/xmloff/source/chart/SchXMLParagraphContext.cxx @@ -60,6 +60,7 @@ void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttr { sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0; rtl::OUString aValue; + bool bHaveXmlId( false ); for( sal_Int16 i = 0; i < nAttrCount; i++ ) { @@ -67,11 +68,20 @@ void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttr rtl::OUString aLocalName; USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); - if( nPrefix == XML_NAMESPACE_TEXT && - IsXMLToken( aLocalName, XML_ID ) ) + if (IsXMLToken(aLocalName, XML_ID)) { - (*mpId) = xAttrList->getValueByIndex( i ); - break; // we only need this attribute + if (nPrefix == XML_NAMESPACE_XML) + { + (*mpId) = xAttrList->getValueByIndex( i ); + bHaveXmlId = true; + } + if (nPrefix == XML_NAMESPACE_TEXT) + { // text:id shall be ignored if xml:id exists + if (!bHaveXmlId) + { + (*mpId) = xAttrList->getValueByIndex( i ); + } + } } } } diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx index 53a32b9193e5..ec5c4b2130c1 100644 --- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx +++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx @@ -1271,6 +1271,10 @@ void SchXMLAxisContext::CreateAxis() // set properties if( xProp.is()) { + // #i109879# the line color is black as default, in the model it is a light gray + xProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineColor" )), + uno::makeAny( COL_BLACK )); + xProp->setPropertyValue( rtl::OUString::createFromAscii( "DisplayLabels" ), aFalseBool ); // #88077# AutoOrigin 'on' is default diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index 91c2bc1b9b4a..86e9693ee225 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -39,7 +39,6 @@ #include <com/sun/star/chart2/XRegressionCurve.hpp> #include <com/sun/star/chart2/data/XDataSink.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> -#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> #include <com/sun/star/chart/ChartAxisAssign.hpp> #include <com/sun/star/chart/ChartSymbolType.hpp> @@ -78,15 +77,6 @@ using ::rtl::OUStringBuffer; namespace { -OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::data::XDataProvider >& xDataProvider ) -{ - OUString aResult = rRange; - Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY ); - if( xConversion.is()) - aResult = xConversion->convertRangeFromXML( rRange ); - return aResult; -} - class SchXMLDomain2Context : public SvXMLImportContext { private: @@ -232,7 +222,7 @@ void lcl_insertErrorBarLSequencesToMap( Reference< chart2::data::XLabeledDataSequence > lcl_createAndAddSequenceToSeries( const rtl::OUString& rRole , const rtl::OUString& rRange - , const Reference< chart2::data::XDataProvider >& xDataProvider + , const Reference< chart2::XChartDocument >& xChartDoc , const Reference< chart2::XDataSeries >& xSeries ) { Reference< chart2::data::XLabeledDataSequence > xLabeledSeq; @@ -240,27 +230,14 @@ Reference< chart2::data::XLabeledDataSequence > lcl_createAndAddSequenceToSeries Reference< chart2::data::XDataSource > xSeriesSource( xSeries,uno::UNO_QUERY ); Reference< chart2::data::XDataSink > xSeriesSink( xSeries, uno::UNO_QUERY ); - if( !(rRange.getLength() && xDataProvider.is() && xSeriesSource.is() && xSeriesSink.is()) ) + if( !(rRange.getLength() && xChartDoc.is() && xSeriesSource.is() && xSeriesSink.is()) ) return xLabeledSeq; // create a new sequence xLabeledSeq = SchXMLTools::GetNewLabeledDataSequence(); // set values at the new sequence - Reference< chart2::data::XDataSequence > xSeq; - try - { - xSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( rRange, xDataProvider ))); - SchXMLTools::setXMLRangePropertyAtDataSequence( xSeq, rRange ); - } - catch( const lang::IllegalArgumentException & ex ) - { - (void)ex; // avoid warning for pro build - OSL_ENSURE( false, ::rtl::OUStringToOString( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) + - ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); - } - + Reference< chart2::data::XDataSequence > xSeq = SchXMLTools::CreateDataSequence( rRange, xChartDoc ); Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY ); if( xSeqProp.is()) xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( rRole)); @@ -336,10 +313,6 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib bool bHasRange = false; bool bHasLabelRange = false; - Reference< chart2::data::XRangeXMLConversion > xRangeConversion; - if( mxNewDoc.is()) - xRangeConversion.set( mxNewDoc->getDataProvider(), uno::UNO_QUERY ); - for( sal_Int16 i = 0; i < nAttrCount; i++ ) { rtl::OUString sAttrName = xAttrList->getNameByIndex( i ); @@ -401,123 +374,93 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib try { OSL_ASSERT( mxNewDoc.is()); - if( mxNewDoc.is()) - { - if( m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && ! bHasRange ) - m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable = sal_False; + if( m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable && ! bHasRange ) + m_rGlobalSeriesImportInfo.rbAllRangeAddressesAvailable = sal_False; - Reference< chart2::data::XDataProvider > xDataProvider( mxNewDoc->getDataProvider() ); - if( xDataProvider.is()) + bool bIsCandleStick = maGlobalChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType")); + if( maSeriesChartTypeName.getLength() ) + { + bIsCandleStick = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType")); + } + else + { + if( bIsCandleStick + && m_bStockHasVolume + && mnSeriesIndex == 0 ) { - bool bIsCandleStick = maGlobalChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType")); - if( maSeriesChartTypeName.getLength() ) - { - bIsCandleStick = maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType")); - } - else - { - if( bIsCandleStick - && m_bStockHasVolume - && mnSeriesIndex == 0 ) - { - maSeriesChartTypeName = OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" ); - bIsCandleStick = false; - } - else - { - maSeriesChartTypeName = maGlobalChartTypeName; - } - } - if( ! mrGlobalChartTypeUsedBySeries ) - mrGlobalChartTypeUsedBySeries = (maSeriesChartTypeName.equals( maGlobalChartTypeName )); - sal_Int32 nCoordinateSystemIndex = 0;//so far we can only import one coordinate system - m_xSeries.set( - mrImportHelper.GetNewDataSeries( mxNewDoc, nCoordinateSystemIndex, maSeriesChartTypeName, ! mrGlobalChartTypeUsedBySeries )); - Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( - SchXMLTools::GetNewLabeledDataSequence()); - - if( bIsCandleStick ) - { - // set default color for range-line to black (before applying styles) - Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY ); - if( xSeriesProp.is()) - xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Color")), - uno::makeAny( sal_Int32( 0x000000 ))); // black - } - else if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.PieChartType"))) - { - //@todo: this property should be saved - Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY ); - if( xSeriesProp.is()) - xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VaryColorsByPoint")), - uno::makeAny( true )); - } + maSeriesChartTypeName = OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" ); + bIsCandleStick = false; + } + else + { + maSeriesChartTypeName = maGlobalChartTypeName; + } + } + if( ! mrGlobalChartTypeUsedBySeries ) + mrGlobalChartTypeUsedBySeries = (maSeriesChartTypeName.equals( maGlobalChartTypeName )); + sal_Int32 nCoordinateSystemIndex = 0;//so far we can only import one coordinate system + m_xSeries.set( + mrImportHelper.GetNewDataSeries( mxNewDoc, nCoordinateSystemIndex, maSeriesChartTypeName, ! mrGlobalChartTypeUsedBySeries )); + Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( + SchXMLTools::GetNewLabeledDataSequence()); + + if( bIsCandleStick ) + { + // set default color for range-line to black (before applying styles) + Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY ); + if( xSeriesProp.is()) + xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Color")), + uno::makeAny( sal_Int32( 0x000000 ))); // black + } + else if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.PieChartType"))) + { + //@todo: this property should be saved + Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY ); + if( xSeriesProp.is()) + xSeriesProp->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VaryColorsByPoint")), + uno::makeAny( true )); + } - // values - Reference< chart2::data::XDataSequence > xSeq; - if( bHasRange ) - try - { - xSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( m_aSeriesRange, xDataProvider ))); - SchXMLTools::setXMLRangePropertyAtDataSequence( xSeq, m_aSeriesRange ); - } - catch( const lang::IllegalArgumentException & ex ) - { - (void)ex; // avoid warning for pro build - OSL_ENSURE( false, ::rtl::OUStringToOString( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) + - ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); - } + // values + Reference< chart2::data::XDataSequence > xSeq; + if( bHasRange ) + xSeq = SchXMLTools::CreateDataSequence( m_aSeriesRange, mxNewDoc ); - Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY ); - if( xSeqProp.is()) - { - OUString aMainRole( OUString::createFromAscii("values-y") ); - if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType") ) ) - aMainRole = OUString::createFromAscii("values-size"); - xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( aMainRole )); - } - xLabeledSeq->setValues( xSeq ); + Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY ); + if( xSeqProp.is()) + { + OUString aMainRole( OUString::createFromAscii("values-y") ); + if( maSeriesChartTypeName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType") ) ) + aMainRole = OUString::createFromAscii("values-size"); + xSeqProp->setPropertyValue(OUString::createFromAscii("Role"), uno::makeAny( aMainRole )); + } + xLabeledSeq->setValues( xSeq ); - // register for setting local data if external data provider is not present - maPostponedSequences.insert( - tSchXMLLSequencesPerIndex::value_type( - tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq )); + // register for setting local data if external data provider is not present + maPostponedSequences.insert( + tSchXMLLSequencesPerIndex::value_type( + tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq )); - // label - if( bHasLabelRange ) - { - try - { - Reference< chart2::data::XDataSequence > xLabelSequence( - xDataProvider->createDataSequenceByRangeRepresentation( - lcl_ConvertRange( m_aSeriesLabelRange, xDataProvider ))); - xLabeledSeq->setLabel( xLabelSequence ); - SchXMLTools::setXMLRangePropertyAtDataSequence( xLabelSequence, m_aSeriesLabelRange ); - } - catch( const lang::IllegalArgumentException & ex ) - { - (void)ex; // avoid warning for pro build - OSL_ENSURE( false, ::rtl::OUStringToOString( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IllegalArgumentException caught, Message: " )) + - ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); - } - } + // label + if( bHasLabelRange ) + { + Reference< chart2::data::XDataSequence > xLabelSequence = + SchXMLTools::CreateDataSequence( m_aSeriesLabelRange, mxNewDoc ); + xLabeledSeq->setLabel( xLabelSequence ); + } - // Note: Even if we have no label, we have to register the label - // for creation, because internal data always has labels. If - // they don't exist in the original, auto-generated labels are - // used for the internal data. - maPostponedSequences.insert( - tSchXMLLSequencesPerIndex::value_type( - tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_LABEL ), xLabeledSeq )); + // Note: Even if we have no label, we have to register the label + // for creation, because internal data always has labels. If + // they don't exist in the original, auto-generated labels are + // used for the internal data. + maPostponedSequences.insert( + tSchXMLLSequencesPerIndex::value_type( + tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_LABEL ), xLabeledSeq )); - Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( &xLabeledSeq, 1 ); - Reference< chart2::data::XDataSink > xSink( m_xSeries, uno::UNO_QUERY_THROW ); - xSink->setData( aSeq ); - } - } + Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( &xLabeledSeq, 1 ); + Reference< chart2::data::XDataSink > xSink( m_xSeries, uno::UNO_QUERY_THROW ); + xSink->setData( aSeq ); } catch( uno::Exception & ex ) { @@ -662,15 +605,11 @@ void SchXMLSeries2Context::EndElement() } } - Reference< chart2::data::XDataProvider > xDataProvider; - if ( mxNewDoc.is() ) { - xDataProvider = mxNewDoc->getDataProvider(); - } for( std::vector< DomainInfo >::reverse_iterator aIt( aDomainInfos.rbegin() ); aIt!= aDomainInfos.rend(); ++aIt ) { DomainInfo aDomainInfo( *aIt ); Reference< chart2::data::XLabeledDataSequence > xLabeledSeq = - lcl_createAndAddSequenceToSeries( aDomainInfo.aRole, aDomainInfo.aRange, xDataProvider, m_xSeries ); + lcl_createAndAddSequenceToSeries( aDomainInfo.aRole, aDomainInfo.aRange, mxNewDoc, m_xSeries ); if( xLabeledSeq.is() ) { // register for setting local data if external data provider is not present diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx index 6ba9a49e4502..d82970858ebe 100644 --- a/xmloff/source/chart/SchXMLTableContext.cxx +++ b/xmloff/source/chart/SchXMLTableContext.cxx @@ -161,6 +161,11 @@ struct lcl_ApplyCellToData : public ::std::unary_function< SchXMLCell, void > ++m_nIndex; } + sal_Int32 getCurrentIndex() const + { + return m_nIndex; + } + private: Sequence< double > & m_rData; sal_Int32 m_nIndex; @@ -865,7 +870,12 @@ void SchXMLTableHelper::applyTableToInternalDataProvider( lcl_ApplyCellToComplexLabel( rRow.front(), aComplexRowDescriptions[nRow] ); // values - ::std::for_each( rRow.begin() + nColOffset, rRow.end(), lcl_ApplyCellToData( aDataInRows[nRow] )); + Sequence< double >& rTargetRow = aDataInRows[nRow]; + lcl_ApplyCellToData aApplyCellToData = ::std::for_each( rRow.begin() + nColOffset, rRow.end(), lcl_ApplyCellToData( rTargetRow ) ); + double fNaN = 0.0; + ::rtl::math::setNan( &fNaN ); + for( sal_Int32 nCurrentIndex = aApplyCellToData.getCurrentIndex(); nCurrentIndex<nNumColumns; nCurrentIndex++ ) + rTargetRow[nCurrentIndex] = fNaN;//#i110615# } } } diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx index f5059f979b63..32fe36197a32 100644 --- a/xmloff/source/chart/SchXMLTools.cxx +++ b/xmloff/source/chart/SchXMLTools.cxx @@ -133,20 +133,25 @@ sal_Int32 lcl_getBuildIDFromGenerator( const ::rtl::OUString& rGenerator ) return nBuildId; } +OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::data::XDataProvider >& xDataProvider ) +{ + OUString aResult = rRange; + Reference< chart2::data::XRangeXMLConversion > xRangeConversion( xDataProvider, uno::UNO_QUERY ); + if( xRangeConversion.is()) + aResult = xRangeConversion->convertRangeFromXML( rRange ); + return aResult; +} + Reference< chart2::data::XDataSequence > lcl_createNewSequenceFromCachedXMLRange( const Reference< chart2::data::XDataSequence >& xSeq, const Reference< chart2::data::XDataProvider >& xDataProvider ) { Reference< chart2::data::XDataSequence > xRet; OUString aRange; - Reference< chart2::data::XRangeXMLConversion > xRangeConversion( xDataProvider, uno::UNO_QUERY ); - if( xRangeConversion.is() ) + if( xSeq.is() && SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) ) { - if( xSeq.is() && SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) ) - { - xRet.set( xDataProvider->createDataSequenceByRangeRepresentation( - xRangeConversion->convertRangeFromXML( aRange )) ); - SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ), - Reference< beans::XPropertySet >( xRet, uno::UNO_QUERY )); - } + xRet.set( xDataProvider->createDataSequenceByRangeRepresentation( + lcl_ConvertRange( aRange, xDataProvider )) ); + SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ), + Reference< beans::XPropertySet >( xRet, uno::UNO_QUERY )); } return xRet; } @@ -385,6 +390,53 @@ Reference< chart2::data::XLabeledDataSequence > GetNewLabeledDataSequence() return xResult; } +Reference< chart2::data::XDataSequence > CreateDataSequence( + const OUString & rRange, + const Reference< chart2::XChartDocument >& xChartDoc ) +{ + Reference< chart2::data::XDataSequence > xRet; + + if( !xChartDoc.is() ) + { + DBG_ERROR( "need a chart document" ); + return xRet; + } + + Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() ); + if( !xDataProvider.is() ) + { + DBG_ERROR( "need a data provider" ); + return xRet; + } + + try + { + xRet.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( rRange, xDataProvider ))); + SchXMLTools::setXMLRangePropertyAtDataSequence( xRet, rRange ); + } + catch( const lang::IllegalArgumentException & ) + { + DBG_ERROR( "could not create data sequence" ); + } + + if( !xRet.is() && !xChartDoc->hasInternalDataProvider() ) + { + //#i103911# switch to internal data in case the parent cannot provide the requested data + xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ ); + xDataProvider = xChartDoc->getDataProvider(); + try + { + xRet.set( xDataProvider->createDataSequenceByRangeRepresentation( lcl_ConvertRange( rRange, xDataProvider ))); + SchXMLTools::setXMLRangePropertyAtDataSequence( xRet, rRange ); + } + catch( const lang::IllegalArgumentException & ) + { + DBG_ERROR( "could not create data sequence" ); + } + } + return xRet; +} + void CreateCategories( const uno::Reference< chart2::data::XDataProvider > & xDataProvider, const uno::Reference< chart2::XChartDocument > & xNewDoc, diff --git a/xmloff/source/chart/SchXMLTools.hxx b/xmloff/source/chart/SchXMLTools.hxx index 35ac3ff72f1b..0b77d8e6d38a 100644 --- a/xmloff/source/chart/SchXMLTools.hxx +++ b/xmloff/source/chart/SchXMLTools.hxx @@ -87,6 +87,11 @@ namespace SchXMLTools ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > GetNewLabeledDataSequence(); + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > CreateDataSequence( + const ::rtl::OUString& rRange, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument >& xChartDoc ); + void CreateCategories( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > & xDataProvider, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xNewDoc, diff --git a/xmloff/source/core/RDFaExportHelper.cxx b/xmloff/source/core/RDFaExportHelper.cxx index 6e3129f48d71..593e2d1f29e6 100644 --- a/xmloff/source/core/RDFaExportHelper.cxx +++ b/xmloff/source/core/RDFaExportHelper.cxx @@ -95,11 +95,6 @@ RDFaExportHelper::RDFaExportHelper(SvXMLExport & i_rExport) OSL_ENSURE(xRS.is(), "AddRDFa: model is no rdf::XRepositorySupplier"); if (!xRS.is()) throw uno::RuntimeException(); m_xRepository.set(xRS->getRDFRepository(), uno::UNO_QUERY_THROW); - - const uno::Reference<rdf::XURI> xLabel( - rdf::URI::createKnown(m_rExport.GetComponentContext(), - rdf::URIs::RDFS_LABEL)); - m_RDFsLabel = xLabel->getStringValue(); } ::rtl::OUString @@ -128,19 +123,21 @@ RDFaExportHelper::AddRDFa( { try { - uno::Sequence<rdf::Statement> stmts( - m_xRepository->getStatementRDFa(i_xMetadatable) ); + beans::Pair< uno::Sequence<rdf::Statement>, sal_Bool > const + RDFaResult( m_xRepository->getStatementRDFa(i_xMetadatable) ); + + uno::Sequence<rdf::Statement> const & rStatements( RDFaResult.First ); - if (0 == stmts.getLength()) + if (0 == rStatements.getLength()) { return; // no RDFa } // all stmts have the same subject, so we only handle first one - const uno::Reference<rdf::XURI> xSubjectURI(stmts[0].Subject, - uno::UNO_QUERY); - const uno::Reference<rdf::XBlankNode> xSubjectBNode(stmts[0].Subject, + const uno::Reference<rdf::XURI> xSubjectURI(rStatements[0].Subject, uno::UNO_QUERY); + const uno::Reference<rdf::XBlankNode> xSubjectBNode( + rStatements[0].Subject, uno::UNO_QUERY); if (!xSubjectURI.is() && !xSubjectBNode.is()) { throw uno::RuntimeException(); @@ -154,47 +151,31 @@ RDFaExportHelper::AddRDFa( .makeStringAndClear() ); - rdf::Statement* const iter - ( ::std::partition( ::comphelper::stl_begin(stmts), - ::comphelper::stl_end(stmts), - ::boost::bind(&::rtl::OUString::equals, m_RDFsLabel, - ::boost::bind(&rdf::XNode::getStringValue, - ::boost::bind(&rdf::Statement::Predicate, _1))) ) ); - - if (iter != ::comphelper::stl_end(stmts)) + const uno::Reference<rdf::XLiteral> xContent( + rStatements[0].Object, uno::UNO_QUERY_THROW ); + const uno::Reference<rdf::XURI> xDatatype(xContent->getDatatype()); + if (xDatatype.is()) { - // from iter to end, all stmts should have same object - const uno::Reference<rdf::XLiteral> xContent( - (*iter).Object, uno::UNO_QUERY_THROW ); - const uno::Reference<rdf::XURI> xDatatype(xContent->getDatatype()); - if (xDatatype.is()) - { - const ::rtl::OUString datatype( - makeCURIE(&m_rExport, xDatatype) ); - m_rExport.AddAttribute(XML_NAMESPACE_XHTML, - token::XML_DATATYPE, datatype); - } - if (iter != ::comphelper::stl_begin(stmts)) // there is rdfs:label - { - m_rExport.AddAttribute(XML_NAMESPACE_XHTML, token::XML_CONTENT, - xContent->getValue()); - } + const ::rtl::OUString datatype( + makeCURIE(&m_rExport, xDatatype) ); + m_rExport.AddAttribute(XML_NAMESPACE_XHTML, + token::XML_DATATYPE, datatype); } - else + if (RDFaResult.Second) // there is xhtml:content { - OSL_ENSURE(false,"invalid RDFa: every property is rdfs:label"); - return; + m_rExport.AddAttribute(XML_NAMESPACE_XHTML, token::XML_CONTENT, + xContent->getValue()); } ::rtl::OUStringBuffer property; ::comphelper::intersperse( ::boost::make_transform_iterator( - iter, // omit RDFsLabel predicates! + ::comphelper::stl_begin(rStatements), ::boost::bind(&makeCURIE, &m_rExport, ::boost::bind(&rdf::Statement::Predicate, _1))), // argh, this must be the same type :( ::boost::make_transform_iterator( - ::comphelper::stl_end(stmts), + ::comphelper::stl_end(rStatements), ::boost::bind(&makeCURIE, &m_rExport, ::boost::bind(&rdf::Statement::Predicate, _1))), ::comphelper::OUStringBufferAppender(property), diff --git a/xmloff/source/core/RDFaImportHelper.cxx b/xmloff/source/core/RDFaImportHelper.cxx index 4dbf840fd343..611889497812 100644 --- a/xmloff/source/core/RDFaImportHelper.cxx +++ b/xmloff/source/core/RDFaImportHelper.cxx @@ -126,28 +126,39 @@ public: void InsertRDFaEntry(struct RDFaEntry const & i_rEntry); }; -/** store metadatable object and its RDFa attributes */ -struct SAL_DLLPRIVATE RDFaEntry +/** store parsed RDFa attributes */ +struct SAL_DLLPRIVATE ParsedRDFaAttributes { - uno::Reference<rdf::XMetadatable> m_xObject; ::rtl::OUString m_About; ::std::vector< ::rtl::OUString > m_Properties; ::rtl::OUString m_Content; ::rtl::OUString m_Datatype; - RDFaEntry(uno::Reference<rdf::XMetadatable> i_xObject, + ParsedRDFaAttributes( ::rtl::OUString const & i_rAbout, ::std::vector< ::rtl::OUString > const & i_rProperties, ::rtl::OUString const & i_rContent, ::rtl::OUString const & i_rDatatype) - : m_xObject(i_xObject) - , m_About(i_rAbout) + : m_About(i_rAbout) , m_Properties(i_rProperties) , m_Content(i_rContent) , m_Datatype(i_rDatatype) { } }; +/** store metadatable object and its RDFa attributes */ +struct SAL_DLLPRIVATE RDFaEntry +{ + uno::Reference<rdf::XMetadatable> m_xObject; + ::boost::shared_ptr<ParsedRDFaAttributes> m_pRDFaAttributes; + + RDFaEntry(uno::Reference<rdf::XMetadatable> const & i_xObject, + ::boost::shared_ptr<ParsedRDFaAttributes> const& i_pRDFaAttributes) + : m_xObject(i_xObject) + , m_pRDFaAttributes(i_pRDFaAttributes) + { } +}; + //////////////////////////////////////////////////////////////////////////// @@ -344,7 +355,7 @@ void RDFaInserter::InsertRDFaEntry( if (!i_rEntry.m_xObject.is()) return; const uno::Reference< rdf::XResource > xSubject( - MakeResource( i_rEntry.m_About ) ); + MakeResource( i_rEntry.m_pRDFaAttributes->m_About ) ); if (!xSubject.is()) { return; // invalid @@ -352,13 +363,15 @@ void RDFaInserter::InsertRDFaEntry( ::comphelper::SequenceAsVector< uno::Reference< rdf::XURI > > predicates; - predicates.reserve(i_rEntry.m_Properties.size()); + predicates.reserve(i_rEntry.m_pRDFaAttributes->m_Properties.size()); ::std::remove_copy_if( - ::boost::make_transform_iterator(i_rEntry.m_Properties.begin(), + ::boost::make_transform_iterator( + i_rEntry.m_pRDFaAttributes->m_Properties.begin(), ::boost::bind(&RDFaInserter::MakeURI, this, _1)), // argh, this must be the same type :( - ::boost::make_transform_iterator(i_rEntry.m_Properties.end(), + ::boost::make_transform_iterator( + i_rEntry.m_pRDFaAttributes->m_Properties.end(), ::boost::bind(&RDFaInserter::MakeURI, this, _1)), ::std::back_inserter(predicates), ref_is_null() ); @@ -375,9 +388,9 @@ void RDFaInserter::InsertRDFaEntry( } uno::Reference<rdf::XURI> xDatatype; - if (i_rEntry.m_Datatype.getLength()) + if (i_rEntry.m_pRDFaAttributes->m_Datatype.getLength()) { - xDatatype = MakeURI( i_rEntry.m_Datatype ); + xDatatype = MakeURI( i_rEntry.m_pRDFaAttributes->m_Datatype ); } try @@ -386,7 +399,8 @@ void RDFaInserter::InsertRDFaEntry( // this must be done _after_ importing the whole XML file, // to prevent collision between generated ids and ids in the file m_xRepository->setStatementRDFa(xSubject, predicates.getAsConstList(), - i_rEntry.m_xObject, i_rEntry.m_Content, xDatatype); + i_rEntry.m_xObject, + i_rEntry.m_pRDFaAttributes->m_Content, xDatatype); } catch (uno::Exception &) { @@ -405,9 +419,8 @@ RDFaImportHelper::~RDFaImportHelper() { } -void -RDFaImportHelper::AddRDFa( - uno::Reference<rdf::XMetadatable> i_xObject, +::boost::shared_ptr<ParsedRDFaAttributes> +RDFaImportHelper::ParseRDFa( ::rtl::OUString const & i_rAbout, ::rtl::OUString const & i_rProperty, ::rtl::OUString const & i_rContent, @@ -416,25 +429,58 @@ RDFaImportHelper::AddRDFa( if (!i_rProperty.getLength()) { OSL_TRACE("AddRDFa: invalid input: xhtml:property empty"); - return; - } - if (!i_xObject.is()) - { - OSL_ENSURE(false, "AddRDFa: invalid arg: null textcontent"); - return; + return ::boost::shared_ptr<ParsedRDFaAttributes>(); } // must parse CURIEs here: need namespace declaration context RDFaReader reader(GetImport()); const ::rtl::OUString about( reader.ReadURIOrSafeCURIE(i_rAbout) ); - if (!about.getLength()) return; + if (!about.getLength()) { + return ::boost::shared_ptr<ParsedRDFaAttributes>(); + } const ::std::vector< ::rtl::OUString > properties( reader.ReadCURIEs(i_rProperty) ); - if (!properties.size()) return; + if (!properties.size()) { + return ::boost::shared_ptr<ParsedRDFaAttributes>(); + } const ::rtl::OUString datatype( i_rDatatype.getLength() ? reader.ReadCURIE(i_rDatatype) : ::rtl::OUString() ); - m_RDFaEntries.push_back(RDFaEntry(i_xObject, - about, properties, i_rContent, datatype)); + return ::boost::shared_ptr<ParsedRDFaAttributes>( + new ParsedRDFaAttributes(about, properties, i_rContent, datatype)); +} + +void +RDFaImportHelper::AddRDFa( + uno::Reference<rdf::XMetadatable> const & i_xObject, + ::boost::shared_ptr<ParsedRDFaAttributes> & i_pRDFaAttributes) +{ + if (!i_xObject.is()) + { + OSL_ENSURE(false, "AddRDFa: invalid arg: null textcontent"); + return; + } + if (!i_pRDFaAttributes.get()) + { + OSL_ENSURE(false, "AddRDFa: invalid arg: null RDFa attributes"); + return; + } + m_RDFaEntries.push_back(RDFaEntry(i_xObject, i_pRDFaAttributes)); +} + +void +RDFaImportHelper::ParseAndAddRDFa( + uno::Reference<rdf::XMetadatable> const & i_xObject, + ::rtl::OUString const & i_rAbout, + ::rtl::OUString const & i_rProperty, + ::rtl::OUString const & i_rContent, + ::rtl::OUString const & i_rDatatype) +{ + ::boost::shared_ptr<ParsedRDFaAttributes> pAttributes( + ParseRDFa(i_rAbout, i_rProperty, i_rContent, i_rDatatype) ); + if (pAttributes.get()) + { + AddRDFa(i_xObject, pAttributes); + } } void RDFaImportHelper::InsertRDFa( diff --git a/xmloff/source/core/makefile.mk b/xmloff/source/core/makefile.mk index b881f9610fbc..4d663d3218d8 100644 --- a/xmloff/source/core/makefile.mk +++ b/xmloff/source/core/makefile.mk @@ -38,12 +38,6 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk .INCLUDE: $(PRJ)$/util$/makefile.pmk -# --- to build xmlkywd.obj in obj, too ----------------------------- - -OBJFILES = $(OBJ)$/xmlkywd.obj -LIB2TARGET =$(LB)$/xmlkywd.lib -LIB2OBJFILES =$(OBJFILES) - # --- Files -------------------------------------------------------- SLOFILES = \ @@ -59,7 +53,6 @@ SLOFILES = \ $(SLO)$/xmlexp.obj \ $(SLO)$/xmlictxt.obj \ $(SLO)$/xmlimp.obj \ - $(SLO)$/xmlkywd.obj \ $(SLO)$/xmltkmap.obj \ $(SLO)$/xmltoken.obj \ $(SLO)$/xmluconv.obj \ diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index f310150e9ade..c10ac0a23c03 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -1314,6 +1314,23 @@ void SvXMLExport::SetBodyAttributes() { } +static void +lcl_AddGrddl(SvXMLExport & rExport, const sal_Int32 nExportMode) +{ + // check version >= 1.2 + switch (rExport.getDefaultVersion()) { + case SvtSaveOptions::ODFVER_011: // fall thru + case SvtSaveOptions::ODFVER_010: return; + default: break; + } + + if (EXPORT_SETTINGS != nExportMode) // meta, content, styles + { + rExport.AddAttribute( XML_NAMESPACE_GRDDL, XML_TRANSFORMATION, + OUString::createFromAscii(s_grddl_xsl) ); + } +} + sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) { bool bOwnGraphicResolver = false; @@ -1449,11 +1466,7 @@ sal_uInt32 SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) enum XMLTokenEnum eRootService = XML_TOKEN_INVALID; const sal_Int32 nExportMode = mnExportFlags & (EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS); - if ( EXPORT_SETTINGS != nExportMode ) // meta, content, styles - { - AddAttribute( XML_NAMESPACE_GRDDL, XML_TRANSFORMATION, - OUString::createFromAscii(s_grddl_xsl) ); - } + lcl_AddGrddl(*this, nExportMode); if( EXPORT_META == nExportMode ) { @@ -2522,6 +2535,22 @@ SvtSaveOptions::ODFDefaultVersion SvXMLExport::getDefaultVersion() const } void +SvXMLExport::AddAttributeIdLegacy( + sal_uInt16 const nLegacyPrefix, ::rtl::OUString const& rValue) +{ + switch (getDefaultVersion()) { + case SvtSaveOptions::ODFVER_011: // fall thru + case SvtSaveOptions::ODFVER_010: break; + default: // ODF 1.2: xml:id + AddAttribute(XML_NAMESPACE_XML, XML_ID, rValue); + } + // in ODF 1.1 this was form:id, anim:id, draw:id, or text:id + // backward compatibility: in ODF 1.2 write _both_ id attrs + AddAttribute(nLegacyPrefix, XML_ID, rValue); + // FIXME: this function simply assumes that rValue is unique +} + +void SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc) { // check version >= 1.2 diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 6a7dcf496722..597a1d50b0f9 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -38,7 +38,6 @@ #include <xmloff/nmspmap.hxx> #include <xmloff/xmluconv.hxx> #include "xmlnmspe.hxx" -#include "xmlkywd.hxx" #include <xmloff/xmltoken.hxx> #include <xmloff/XMLFontStylesContext.hxx> #include <xmloff/xmlictxt.hxx> @@ -110,6 +109,7 @@ sal_Char __READONLY_DATA sXML_np__number[] = "_number"; sal_Char __READONLY_DATA sXML_np__svg[] = "_svg"; sal_Char __READONLY_DATA sXML_np__chart[] = "_chart"; sal_Char __READONLY_DATA sXML_np__math[] = "_math"; +sal_Char __READONLY_DATA sXML_np__form[] = "_form"; sal_Char __READONLY_DATA sXML_np__script[] = "_script"; sal_Char __READONLY_DATA sXML_np__config[] = "_config"; sal_Char __READONLY_DATA sXML_np__db[] = "_db"; @@ -293,7 +293,7 @@ void SvXMLImport::_InitCtor() mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__math) ), GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH ); - mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_namespace_form) ), + mpNamespaceMap->Add(OUString(RTL_CONSTASCII_USTRINGPARAM( sXML_np__form )), GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM ); mpNamespaceMap->Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__script) ), @@ -675,7 +675,7 @@ void SAL_CALL SvXMLImport::startElement( const OUString& rName, } } else if( ( rAttrName.getLength() >= 5 ) && - ( rAttrName.compareToAscii( sXML_xmlns, 5 ) == 0 ) && + ( rAttrName.compareTo( GetXMLToken(XML_XMLNS), 5 ) == 0 ) && ( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) ) { if( !pRewindMap ) @@ -1985,6 +1985,16 @@ void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc, } } +SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & +SvXMLImport::GetRDFaImportHelper() +{ + if (!mpImpl->mpRDFaHelper.get()) + { + mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) ); + } + return *mpImpl->mpRDFaHelper; +} + void SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject, ::rtl::OUString const & i_rAbout, @@ -1994,11 +2004,8 @@ SvXMLImport::AddRDFa(uno::Reference<rdf::XMetadatable> i_xObject, { // N.B.: we only get called if i_xObject had xhtml:about attribute // (an empty attribute value is valid) - if (!mpImpl->mpRDFaHelper.get()) - { - mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) ); - } - mpImpl->mpRDFaHelper->AddRDFa(i_xObject, + ::xmloff::RDFaImportHelper & rRDFaHelper( GetRDFaImportHelper() ); + rRDFaHelper.ParseAndAddRDFa(i_xObject, i_rAbout, i_rProperty, i_rContent, i_rDatatype); } diff --git a/xmloff/source/core/xmlkywd.cxx b/xmloff/source/core/xmlkywd.cxx deleted file mode 100644 index 87ce105d456e..000000000000 --- a/xmloff/source/core/xmlkywd.cxx +++ /dev/null @@ -1,38 +0,0 @@ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_xmloff.hxx" - -#ifndef _XMLOFF_XMLKYWD_HXX -#define XML_DEFINE_KEYWORDS -#include "xmlkywd.hxx" -#undef XML_DEFINE_KEYWORDS -#endif - - - diff --git a/xmloff/source/draw/XMLReplacementImageContext.cxx b/xmloff/source/draw/XMLReplacementImageContext.cxx index c6d63511cbd6..4eb607e0403b 100644 --- a/xmloff/source/draw/XMLReplacementImageContext.cxx +++ b/xmloff/source/draw/XMLReplacementImageContext.cxx @@ -33,7 +33,6 @@ #include <xmloff/xmlimp.hxx> #include <xmloff/xmltoken.hxx> #include "xmlnmspe.hxx" -#include "xmlkywd.hxx" #include <xmloff/nmspmap.hxx> #include <xmloff/XMLBase64ImportContext.hxx> #include "XMLReplacementImageContext.hxx" diff --git a/xmloff/source/draw/animationexport.cxx b/xmloff/source/draw/animationexport.cxx index 7ebcef8ffde4..eaf83444114c 100644 --- a/xmloff/source/draw/animationexport.cxx +++ b/xmloff/source/draw/animationexport.cxx @@ -28,24 +28,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateColor_HPP_ #include <com/sun/star/animations/XAnimateColor.hpp> -#endif -#ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateSet_HPP_ #include <com/sun/star/animations/XAnimateSet.hpp> -#endif #include <com/sun/star/animations/XCommand.hpp> #include <com/sun/star/animations/Timing.hpp> #include <com/sun/star/animations/Event.hpp> -#ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateMotion_HPP_ #include <com/sun/star/animations/XAnimateMotion.hpp> -#endif -#ifndef _COM_SUN_STAR_ANIMATIONS_XAnimateTransform_HPP_ #include <com/sun/star/animations/XAnimateTransform.hpp> -#endif -#ifndef _COM_SUN_STAR_ANIMATIONS_XTransitionFilter_HPP_ #include <com/sun/star/animations/XTransitionFilter.hpp> -#endif #include <com/sun/star/animations/XIterateContainer.hpp> #include <com/sun/star/animations/XAudio.hpp> #include <com/sun/star/animations/AnimationColorSpace.hpp> @@ -64,19 +54,12 @@ #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/presentation/EffectNodeType.hpp> -#ifndef _COM_SUN_STAR_PRESENTATION_EffectPresetClass_HPP_ #include <com/sun/star/presentation/EffectPresetClass.hpp> -#endif -#ifndef _COM_SUN_STAR_PRESENTATION_ParagraphTarget_HPP_ #include <com/sun/star/presentation/ParagraphTarget.hpp> -#endif #include <com/sun/star/presentation/TextAnimationType.hpp> #include <com/sun/star/presentation/ShapeAnimationSubType.hpp> #include <com/sun/star/presentation/EffectCommands.hpp> - -#ifndef _COM_SUN_STAR_DRAWING_XShape_HPP_ #include <com/sun/star/drawing/XShape.hpp> -#endif #include <tools/debug.hxx> #include <tools/time.hxx> @@ -780,7 +763,10 @@ void AnimationsExporterImpl::exportNode( const Reference< XAnimationNode >& xNod const OUString& rExportIdentifier = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xNode ); if( rExportIdentifier.getLength() ) - mrExport.AddAttribute( XML_NAMESPACE_ANIMATION, XML_ID, rExportIdentifier ); + { + mrExport.AddAttributeIdLegacy( + XML_NAMESPACE_ANIMATION, rExportIdentifier); + } Any aTemp( xNode->getBegin() ); if( aTemp.hasValue() ) diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx index 4fc6bc93302b..17bba5170c79 100644 --- a/xmloff/source/draw/animationimport.cxx +++ b/xmloff/source/draw/animationimport.cxx @@ -47,18 +47,14 @@ #include <com/sun/star/animations/XAudio.hpp> #include <com/sun/star/animations/ValuePair.hpp> #include <com/sun/star/animations/AnimationColorSpace.hpp> -#ifndef _COM_SUN_STAR_PRESENTATION_EffectPresetClass_HPP_ #include <com/sun/star/presentation/EffectPresetClass.hpp> -#endif #include <com/sun/star/animations/Timing.hpp> #include <com/sun/star/animations/Event.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp> #include <com/sun/star/text/XTextCursor.hpp> #include <com/sun/star/text/XTextRangeCompare.hpp> -#ifndef _COM_SUN_STAR_PRESENTATION_ParagraphTarget_HPP_ #include <com/sun/star/presentation/ParagraphTarget.hpp> -#endif #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/animations/EventTrigger.hpp> @@ -237,7 +233,8 @@ enum AnimationNodeAttributes ANA_IterateType, ANA_IterateInterval, ANA_Formula, - ANA_ID, + ANA_ANIMID, + ANA_XMLID, ANA_Group_Id, ANA_Command, ANA_Volume @@ -294,8 +291,8 @@ const SvXMLTokenMap& AnimationsImportHelperImpl::getAnimationNodeAttributeTokenM { XML_NAMESPACE_ANIMATION, XML_ITERATE_TYPE, (sal_uInt16)ANA_IterateType }, { XML_NAMESPACE_ANIMATION, XML_ITERATE_INTERVAL, (sal_uInt16)ANA_IterateInterval }, { XML_NAMESPACE_ANIMATION, XML_FORMULA, (sal_uInt16)ANA_Formula }, - { XML_NAMESPACE_ANIMATION, XML_ID, (sal_uInt16)ANA_ID }, - { XML_NAMESPACE_XML, XML_ID, (sal_uInt16)ANA_ID }, + { XML_NAMESPACE_ANIMATION, XML_ID, (sal_uInt16)ANA_ANIMID }, + { XML_NAMESPACE_XML, XML_ID, (sal_uInt16)ANA_XMLID }, { XML_NAMESPACE_PRESENTATION, XML_GROUP_ID, (sal_uInt16)ANA_Group_Id }, { XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, (sal_uInt16)ANA_Volume }, { XML_NAMESPACE_ANIMATION, XML_COMMAND, (sal_uInt16)ANA_Command }, @@ -808,6 +805,8 @@ void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference< : std::list< NamedValue > aUserData; XMLTokenEnum meAttributeName = XML_TOKEN_INVALID; OUString aFrom, aBy, aTo, aValues; + bool bHaveXmlId( false ); + OUString sXmlId; const sal_Int16 nCount = xAttrList.is() ? xAttrList->getLength() : 0; sal_uInt16 nEnum; @@ -1054,13 +1053,15 @@ void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference< : } break; - case ANA_ID: + case ANA_ANIMID: { - if( rValue.getLength() ) - { - Reference< XInterface > xRef( mxNode, UNO_QUERY ); - GetImport().getInterfaceToIdentifierMapper().registerReference( rValue, xRef ); - } + if (!bHaveXmlId) { sXmlId = rValue; } + } + break; + case ANA_XMLID: + { + sXmlId = rValue; + bHaveXmlId = true; } break; @@ -1251,6 +1252,13 @@ void AnimationNodeContext::init_node( const ::com::sun::star::uno::Reference< : } } + if (sXmlId.getLength()) + { + Reference< XInterface > const xRef( mxNode, UNO_QUERY ); + GetImport().getInterfaceToIdentifierMapper().registerReference( + sXmlId, xRef ); + } + sal_Int32 nUserDataCount = aUserData.size(); if( nUserDataCount ) { diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx index eae1925e4105..9dac5b4cd469 100644 --- a/xmloff/source/draw/sdpropls.cxx +++ b/xmloff/source/draw/sdpropls.cxx @@ -323,8 +323,9 @@ const XMLPropertyMapEntry aXMLSDPresPageProps[] = DPMAP( "FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SD_TYPE_FILLSTYLE, 0 ), DPMAP( "FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0 ), DPMAP( "FillGradientName", XML_NAMESPACE_DRAW, XML_FILL_GRADIENT_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLGRADIENTNAME ), - DPMAP( "FillGradientStepCount", XML_NAMESPACE_DRAW, XML_GRADIENT_STEP_COUNT, XML_TYPE_NUMBER16, 0 ), + DPMAP( "FillGradientStepCount", XML_NAMESPACE_DRAW, XML_GRADIENT_STEP_COUNT, XML_TYPE_NUMBER, 0 ), DPMAP( "FillHatchName", XML_NAMESPACE_DRAW, XML_FILL_HATCH_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLHATCHNAME ), + GMAP( "FillBackground", XML_NAMESPACE_DRAW, XML_FILL_HATCH_SOLID, XML_TYPE_BOOL, 0 ), DPMAP( "FillBitmapName", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLBITMAPNAME ), DPMAP( "FillTransparenceGradientName", XML_NAMESPACE_DRAW, XML_OPACITY_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_FILLTRANSNAME ), DPMAP( "FillBitmapSizeX", XML_NAMESPACE_DRAW, XML_FILL_IMAGE_WIDTH, XML_SD_TYPE_FILLBITMAPSIZE|MID_FLAG_MULTI_PROPERTY, 0 ), diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index bc6f72abd2b0..249ce18331d9 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2011,7 +2011,9 @@ void SdXMLExport::_ExportContent() // write draw:id const OUString aPageId = getInterfaceToIdentifierMapper().getIdentifier( xDrawPage ); if( aPageId.getLength() != 0 ) - AddAttribute ( XML_NAMESPACE_DRAW, XML_ID, aPageId ); + { + AddAttributeIdLegacy(XML_NAMESPACE_DRAW, aPageId); + } // write page SvXMLElementExport aDPG(*this, XML_NAMESPACE_DRAW, XML_PAGE, sal_True, sal_True); diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 8ec97697b138..76942cf817db 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -665,8 +665,8 @@ const SvXMLTokenMap& SdXMLImport::GetDrawPageAttrTokenMap() { XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_DRAWPAGE_STYLE_NAME }, { XML_NAMESPACE_DRAW, XML_MASTER_PAGE_NAME, XML_TOK_DRAWPAGE_MASTER_PAGE_NAME }, { XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME }, - { XML_NAMESPACE_DRAW, XML_ID, XML_TOK_DRAWPAGE_ID }, - { XML_NAMESPACE_XML, XML_ID, XML_TOK_DRAWPAGE_ID }, + { XML_NAMESPACE_DRAW, XML_ID, XML_TOK_DRAWPAGE_DRAWID }, + { XML_NAMESPACE_XML, XML_ID, XML_TOK_DRAWPAGE_XMLID }, { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_DRAWPAGE_HREF }, { XML_NAMESPACE_PRESENTATION, XML_USE_HEADER_NAME, XML_TOK_DRAWPAGE_USE_HEADER_NAME }, { XML_NAMESPACE_PRESENTATION, XML_USE_FOOTER_NAME, XML_TOK_DRAWPAGE_USE_FOOTER_NAME }, diff --git a/xmloff/source/draw/sdxmlimp_impl.hxx b/xmloff/source/draw/sdxmlimp_impl.hxx index 1c0b883c9b59..d1cd0df80563 100644 --- a/xmloff/source/draw/sdxmlimp_impl.hxx +++ b/xmloff/source/draw/sdxmlimp_impl.hxx @@ -130,7 +130,8 @@ enum SdXMLDrawPageAttrTokenMap XML_TOK_DRAWPAGE_STYLE_NAME, XML_TOK_DRAWPAGE_MASTER_PAGE_NAME, XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME, - XML_TOK_DRAWPAGE_ID, + XML_TOK_DRAWPAGE_DRAWID, + XML_TOK_DRAWPAGE_XMLID, XML_TOK_DRAWPAGE_HREF, XML_TOK_DRAWPAGE_USE_HEADER_NAME, XML_TOK_DRAWPAGE_USE_FOOTER_NAME, diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 709677c6ae07..c4f398524a2f 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -27,7 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" + +#include <memory> + #include "unointerfacetouniqueidentifiermapper.hxx" +#include <com/sun/star/presentation/ClickAction.hpp> #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/text/XText.hpp> @@ -43,9 +47,7 @@ #include <xmloff/xmluconv.hxx> #include "PropertySetMerger.hxx" -#ifndef _XMLOFF_SHAPEEXPORT_HXX #include <xmloff/shapeexport.hxx> -#endif #include "sdpropls.hxx" #include "sdxmlexp_impl.hxx" #include <xmloff/families.hxx> @@ -75,6 +77,8 @@ XMLShapeExport::XMLShapeExport(SvXMLExport& rExp, SvXMLExportPropertyMapper *pExtMapper ) : mrExport( rExp ), mnNextUniqueShapeId(1), + maShapesInfos(), + maCurrentShapesIter(maShapesInfos.end()), mbExportLayer( sal_False ), // #88546# init to FALSE mbHandleProgressBar( sal_False ), @@ -538,6 +542,38 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape } sal_Int32 nZIndex = 0; uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY ); + + + ::std::auto_ptr< SvXMLElementExport > mpHyperlinkElement; + + // export hyperlinks with <a><shape/></a>. Currently only in draw since draw + // does not support document events + if( xSet.is() && (GetExport().GetModelType() == SvtModuleOptions::E_DRAW) ) try + { + presentation::ClickAction eAction = presentation::ClickAction_NONE; + xSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("OnClick"))) >>= eAction; + + if( (eAction == presentation::ClickAction_DOCUMENT) || + (eAction == presentation::ClickAction_BOOKMARK) ) + { + OUString sURL; + xSet->getPropertyValue(msBookmark) >>= sURL; + + if( sURL.getLength() ) + { + mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL ); + mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); + mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED ); + mpHyperlinkElement.reset( new SvXMLElementExport(mrExport, XML_NAMESPACE_DRAW, XML_A, sal_True, sal_True) ); + } + } + } + catch( uno::Exception& ) + { + DBG_ERROR("XMLShapeExport::exportShape(): exception during hyperlink export"); + } + + if( xSet.is() ) xSet->getPropertyValue(msZIndex) >>= nZIndex; @@ -639,7 +675,9 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY ); const OUString& rShapeId = mrExport.getInterfaceToIdentifierMapper().getIdentifier( xRef ); if( rShapeId.getLength() ) - mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_ID, rShapeId ); + { + mrExport.AddAttributeIdLegacy(XML_NAMESPACE_DRAW, rShapeId); + } } // -------------------------- @@ -845,6 +883,8 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape } } + mpHyperlinkElement.reset(); + // #97489# #97111# // if there was an error and no element for the shape was exported // we need to clear the attribute list or the attributes will be diff --git a/xmloff/source/draw/ximpbody.cxx b/xmloff/source/draw/ximpbody.cxx index 9b5290254b46..af5fef0ff9dc 100644 --- a/xmloff/source/draw/ximpbody.cxx +++ b/xmloff/source/draw/ximpbody.cxx @@ -62,6 +62,9 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport, : SdXMLGenericPageContext( rImport, nPrfx, rLocalName, xAttrList, rShapes ) , mbHadSMILNodes( false ) { + bool bHaveXmlId( false ); + OUString sXmlId; + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for(sal_Int16 i=0; i < nAttrCount; i++) @@ -109,13 +112,17 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport, maUseDateTimeDeclName = sValue; break; } - - case XML_TOK_DRAWPAGE_ID: + case XML_TOK_DRAWPAGE_DRAWID: { - uno::Reference< uno::XInterface > xRef( rShapes.get() ); - GetImport().getInterfaceToIdentifierMapper().registerReference( sValue, xRef ); - break; + if (!bHaveXmlId) { sXmlId = sValue; } } + break; + case XML_TOK_DRAWPAGE_XMLID: + { + sXmlId = sValue; + bHaveXmlId = true; + } + break; case XML_TOK_DRAWPAGE_HREF: { maHREF = sValue; @@ -124,6 +131,12 @@ SdXMLDrawPageContext::SdXMLDrawPageContext( SdXMLImport& rImport, } } + if (sXmlId.getLength()) + { + uno::Reference< uno::XInterface > const xRef( rShapes.get() ); + GetImport().getInterfaceToIdentifierMapper().registerReference( + sXmlId, xRef ); + } GetImport().GetShapeImport()->startPage( rShapes ); uno::Reference< drawing::XDrawPage > xShapeDrawPage(rShapes, uno::UNO_QUERY); diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index f4e7c1466ecd..dc362136a3fe 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -372,31 +372,46 @@ void SdXMLShapeContext::EndElement() if( msHyperlink.getLength() != 0 ) try { - Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY_THROW ); - Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW ); + const OUString sBookmark( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) ); - uno::Sequence< beans::PropertyValue > aProperties( 3 ); - aProperties[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) ); - aProperties[0].Handle = -1; - aProperties[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") ); - aProperties[0].State = beans::PropertyState_DIRECT_VALUE; + Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY ); + if( xEventsSupplier.is() ) + { + const OUString sEventType( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) ); + const OUString sClickAction( RTL_CONSTASCII_USTRINGPARAM( "ClickAction" ) ); + + Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW ); + + uno::Sequence< beans::PropertyValue > aProperties( 3 ); + aProperties[0].Name = sEventType; + aProperties[0].Handle = -1; + aProperties[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") ); + aProperties[0].State = beans::PropertyState_DIRECT_VALUE; - aProperties[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ClickAction" ) ); - aProperties[1].Handle = -1; - aProperties[1].Value <<= ::com::sun::star::presentation::ClickAction_DOCUMENT; - aProperties[1].State = beans::PropertyState_DIRECT_VALUE; + aProperties[1].Name = sClickAction; + aProperties[1].Handle = -1; + aProperties[1].Value <<= ::com::sun::star::presentation::ClickAction_DOCUMENT; + aProperties[1].State = beans::PropertyState_DIRECT_VALUE; - aProperties[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) ); - aProperties[2].Handle = -1; - aProperties[2].Value <<= msHyperlink; - aProperties[2].State = beans::PropertyState_DIRECT_VALUE; + aProperties[2].Name = sBookmark; + aProperties[2].Handle = -1; + aProperties[2].Value <<= msHyperlink; + aProperties[2].State = beans::PropertyState_DIRECT_VALUE; - const OUString sAPIEventName( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ); - xEvents->replaceByName( sAPIEventName, Any( aProperties ) ); + const OUString sAPIEventName( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ); + xEvents->replaceByName( sAPIEventName, Any( aProperties ) ); + } + else + { + // in draw use the Bookmark property + Reference< beans::XPropertySet > xSet( mxShape, UNO_QUERY_THROW ); + xSet->setPropertyValue( sBookmark, Any( msHyperlink ) ); + xSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ), Any( ::com::sun::star::presentation::ClickAction_DOCUMENT ) ); + } } catch( Exception& ) { - DBG_ERROR("xmloff::SdXMLShapeContext::EndElement(), exception caught!"); + DBG_ERROR("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!"); } if( mxLockable.is() ) @@ -761,6 +776,7 @@ void SdXMLShapeContext::SetThumbnail() // this is called from the parent group for each unparsed attribute in the attribute list void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) { + bool bHaveXmlId( false ); if( XML_NAMESPACE_DRAW == nPrefix ) { if( IsXMLToken( rLocalName, XML_ZINDEX ) ) @@ -769,7 +785,7 @@ void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUStr } else if( IsXMLToken( rLocalName, XML_ID ) ) { - maShapeId = rValue; + if (!bHaveXmlId) { maShapeId = rValue; }; } else if( IsXMLToken( rLocalName, XML_NAME ) ) { @@ -862,6 +878,7 @@ void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUStr if( IsXMLToken( rLocalName, XML_ID ) ) { maShapeId = rValue; + bHaveXmlId = true; } } } @@ -3668,7 +3685,7 @@ void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl:: SvXMLImportContext* SdXMLTableShapeContext::CreateChildContext( USHORT nPrefix, const ::rtl::OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList ) { - if( mxTableImportContext.Is() ) + if( mxTableImportContext.Is() && (nPrefix == XML_NAMESPACE_TABLE) ) return mxTableImportContext->CreateChildContext(nPrefix, rLocalName, xAttrList); else return SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList); diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 9baf402e5ea7..88abf8ad988a 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -313,10 +313,8 @@ namespace xmloff if (CCA_CONTROL_ID & m_nIncludeCommon) { OSL_ENSURE(m_sControlId.getLength(), "OControlExport::exportInnerAttributes: have no control id for the control!"); - AddAttribute( - OAttributeMetaData::getCommonControlAttributeNamespace(CCA_CONTROL_ID), - OAttributeMetaData::getCommonControlAttributeName(CCA_CONTROL_ID), - m_sControlId); + m_rContext.getGlobalContext().AddAttributeIdLegacy( + XML_NAMESPACE_FORM, m_sControlId); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking m_nIncludeCommon = m_nIncludeCommon & ~CCA_CONTROL_ID; @@ -693,7 +691,7 @@ namespace xmloff if (m_nIncludeCommon & CCA_TARGET_LOCATION) { - exportTargetLocationAttribute(); + exportTargetLocationAttribute(false); #if OSL_DEBUG_LEVEL > 0 // reset the bit for later checking m_nIncludeCommon = m_nIncludeCommon & ~CCA_TARGET_LOCATION; @@ -2035,6 +2033,12 @@ namespace xmloff OAttributeMetaData::getFormAttributeNamespace(eStringPropertyIds[i]), OAttributeMetaData::getFormAttributeName(eStringPropertyIds[i]), aStringPropertyNames[i]); + + // Since as per ODF 1.2, xlink:href and xlink:type need to exist either both or none, + // we need to write xlink:type, too, even if it carries no information. + // #i111035# / 2010-04-141/ frank.schoenheit@sun.com + AddAttributeASCII( XML_NAMESPACE_XLINK, "type", "simple" ); + // now export the data source name or databaselocation or connection resource ::rtl::OUString sPropValue; m_xProps->getPropertyValue( PROPERTY_DATASOURCENAME ) >>= sPropValue; @@ -2134,7 +2138,7 @@ namespace xmloff // the target frame exportTargetFrameAttribute(); // the target URL - exportTargetLocationAttribute(); + exportTargetLocationAttribute(true); // #i110911# add type attribute (for form, but not for control) // master fields exportStringSequenceAttribute( diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index a39576bd2184..b946c4a20941 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -586,12 +586,21 @@ namespace xmloff //--------------------------------------------------------------------- void OControlImport::handleAttribute(sal_uInt16 _nNamespaceKey, const ::rtl::OUString& _rLocalName, const ::rtl::OUString& _rValue) { - static const sal_Char* pControlIdAttributeName = OAttributeMetaData::getCommonControlAttributeName(CCA_CONTROL_ID); static const sal_Char* pLinkedCellAttributeName = OAttributeMetaData::getBindingAttributeName(BA_LINKED_CELL); - if ( !m_sControlId.getLength() && _rLocalName.equalsAscii( pControlIdAttributeName ) ) + if (IsXMLToken(_rLocalName, XML_ID)) { // it's the control id - m_sControlId = _rValue; + if (XML_NAMESPACE_XML == _nNamespaceKey) + { + m_sControlId = _rValue; + } + else if (XML_NAMESPACE_FORM == _nNamespaceKey) + { + if (!m_sControlId.getLength()) + { + m_sControlId = _rValue; + } + } } else if ( _rLocalName.equalsAscii( pLinkedCellAttributeName ) ) { // it's the address of a spreadsheet cell diff --git a/xmloff/source/forms/formattributes.cxx b/xmloff/source/forms/formattributes.cxx index fbe388a6a81a..0e2ef69ab9f8 100644 --- a/xmloff/source/forms/formattributes.cxx +++ b/xmloff/source/forms/formattributes.cxx @@ -53,7 +53,7 @@ namespace xmloff case CCA_NAME: return "name"; case CCA_SERVICE_NAME: return "control-implementation"; case CCA_BUTTON_TYPE: return "button-type"; - case CCA_CONTROL_ID: return "id"; +// disabled(AddAttributeIdLegacy) case CCA_CONTROL_ID: return "id"; case CCA_CURRENT_SELECTED: return "current-selected"; case CCA_CURRENT_VALUE: return "current-value"; case CCA_DISABLED: return "disabled"; diff --git a/xmloff/source/forms/propertyexport.cxx b/xmloff/source/forms/propertyexport.cxx index 1586c9a7a439..2a485566cf9d 100644 --- a/xmloff/source/forms/propertyexport.cxx +++ b/xmloff/source/forms/propertyexport.cxx @@ -420,7 +420,7 @@ namespace xmloff } //--------------------------------------------------------------------- - void OPropertyExport::exportRelativeTargetLocation(const ConstAsciiString& _sPropertyName,sal_Int32 _nProperty) + void OPropertyExport::exportRelativeTargetLocation(const ConstAsciiString& _sPropertyName,sal_Int32 _nProperty,bool _bAddType) { DBG_CHECK_PROPERTY( _sPropertyName, ::rtl::OUString ); @@ -433,6 +433,10 @@ namespace xmloff ,OAttributeMetaData::getCommonControlAttributeName(_nProperty) , sTargetLocation); + // #i110911# add xlink:type="simple" if required + if (_bAddType) + AddAttribute(XML_NAMESPACE_XLINK, token::XML_TYPE, token::XML_SIMPLE); + exportedProperty(_sPropertyName); } //--------------------------------------------------------------------- diff --git a/xmloff/source/forms/propertyexport.hxx b/xmloff/source/forms/propertyexport.hxx index 5e1f683e339d..ab17912e4df4 100644 --- a/xmloff/source/forms/propertyexport.hxx +++ b/xmloff/source/forms/propertyexport.hxx @@ -69,7 +69,7 @@ namespace xmloff StringSet m_aRemainingProps; // see examinePersistence - void exportRelativeTargetLocation(const ConstAsciiString& _sPropertyName,sal_Int32 _nProperty); + void exportRelativeTargetLocation(const ConstAsciiString& _sPropertyName,sal_Int32 _nProperty,bool _bAddType); protected: IFormsExportContext& m_rContext; @@ -230,8 +230,10 @@ namespace xmloff <p>The value of this attribute is extracted from the TargetURL property of the object given.</p> <p>The property needs a special handling because the URL's need to be made relative</p> + + <p>If _bAddType is set, an additional xlink:type="simple" attribute is also added.</p> */ - inline void exportTargetLocationAttribute() { exportRelativeTargetLocation(PROPERTY_TARGETURL,CCA_TARGET_LOCATION); } + inline void exportTargetLocationAttribute(bool _bAddType) { exportRelativeTargetLocation(PROPERTY_TARGETURL,CCA_TARGET_LOCATION,_bAddType); } /** add the form:image attribute to the export context. @@ -239,7 +241,7 @@ namespace xmloff <p>The property needs a special handling because the URL's need to be made relative</p> */ - inline void exportImageDataAttribute() { exportRelativeTargetLocation(PROPERTY_IMAGEURL,CCA_IMAGE_DATA); } + inline void exportImageDataAttribute() { exportRelativeTargetLocation(PROPERTY_IMAGEURL,CCA_IMAGE_DATA,false); } /** flag the style properties as 'already exported' diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index 597798f01ce7..45fa2f5b4744 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -363,7 +363,7 @@ void OPropertyImport::handleAttribute(sal_uInt16 /*_nNamespaceKey*/, const ::rtl implPushBackPropertyValue( aNewValue ); } #if OSL_DEBUG_LEVEL > 0 - else + else if (!token::IsXMLToken(_rLocalName, token::XML_TYPE)) // xlink:type is valid but ignored for <form:form> { ::rtl::OString sMessage( "OPropertyImport::handleAttribute: Can't handle the following:\n" ); sMessage += ::rtl::OString( " Attribute name: " ); diff --git a/xmloff/source/meta/xmlmetae.cxx b/xmloff/source/meta/xmlmetae.cxx index 8aa0a4054821..aab4686339ba 100644 --- a/xmloff/source/meta/xmlmetae.cxx +++ b/xmloff/source/meta/xmlmetae.cxx @@ -475,7 +475,9 @@ SvXMLMetaExport::startElement(const ::rtl::OUString & i_rName, } // finally, start the element - mrExport.StartElement(i_rName, sal_True); //FIXME:whitespace? + // #i107240# no whitespace here, because the DOM may already contain + // whitespace, which is not cleared when loading and thus accumulates. + mrExport.StartElement(i_rName, (m_level > 1) ? sal_False : sal_True); ++m_level; } diff --git a/xmloff/source/script/XMLScriptExportHandler.cxx b/xmloff/source/script/XMLScriptExportHandler.cxx index 724b6b0d2337..e04467d1e491 100644 --- a/xmloff/source/script/XMLScriptExportHandler.cxx +++ b/xmloff/source/script/XMLScriptExportHandler.cxx @@ -75,6 +75,9 @@ void XMLScriptExportHandler::Export( OUString sTmp; rValues[i].Value >>= sTmp; rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, sTmp); + + // #i110911# xlink:type="simple" is required + rExport.AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE); } // else: disregard } diff --git a/xmloff/source/style/WordWrapPropertyHdl.cxx b/xmloff/source/style/WordWrapPropertyHdl.cxx index 86792847b2c3..f3717b95c9cd 100644 --- a/xmloff/source/style/WordWrapPropertyHdl.cxx +++ b/xmloff/source/style/WordWrapPropertyHdl.cxx @@ -29,7 +29,6 @@ #include "precompiled_xmloff.hxx" #include <xmloff/xmlimp.hxx> #include <xmloff/WordWrapPropertyHdl.hxx> -#include "xmlkywd.hxx" #include <xmloff/xmltoken.hxx> #include <xmloff/xmluconv.hxx> #include <comphelper/extract.hxx> diff --git a/xmloff/source/style/XMLClipPropertyHandler.cxx b/xmloff/source/style/XMLClipPropertyHandler.cxx index 35b5c166a991..f90e3346c1ba 100644 --- a/xmloff/source/style/XMLClipPropertyHandler.cxx +++ b/xmloff/source/style/XMLClipPropertyHandler.cxx @@ -32,7 +32,6 @@ #include <rtl/ustrbuf.hxx> #include <com/sun/star/text/GraphicCrop.hpp> #include <xmloff/xmluconv.hxx> -#include <xmlkywd.hxx> #include <xmloff/xmltoken.hxx> using ::rtl::OUString; @@ -77,7 +76,7 @@ sal_Bool XMLClipPropertyHandler::importXML( const OUString& rStrImpValue, uno::A sal_Bool bRet = sal_False; sal_Int32 nLen = rStrImpValue.getLength(); if( nLen > 6 && - 0 == rStrImpValue.compareToAscii( sXML_rect, 4 ) && + 0 == rStrImpValue.compareTo( GetXMLToken(XML_RECT), 4 ) && rStrImpValue[4] == '(' && rStrImpValue[nLen-1] == ')' ) { diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx index 68f77790ac49..dcc81ccf9f89 100644 --- a/xmloff/source/style/XMLFontAutoStylePool.cxx +++ b/xmloff/source/style/XMLFontAutoStylePool.cxx @@ -27,18 +27,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" + #include <tools/debug.hxx> #include <svl/cntnrsrt.hxx> #include <tools/fontenum.hxx> + #include "xmlnmspe.hxx" #include <xmloff/xmltoken.hxx> #include <xmloff/xmluconv.hxx> -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include "fonthdl.hxx" -#endif #include <xmloff/xmlexp.hxx> #include <xmloff/XMLFontAutoStylePool.hxx> + using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/XMLFontStylesContext.cxx b/xmloff/source/style/XMLFontStylesContext.cxx index 37b8aa2196f3..49dd6ddac91e 100644 --- a/xmloff/source/style/XMLFontStylesContext.cxx +++ b/xmloff/source/style/XMLFontStylesContext.cxx @@ -28,25 +28,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#ifndef _COM_SUN_STAR_AWT_FONTFAMILY_HPP #include <com/sun/star/awt/FontFamily.hpp> -#endif -#ifndef _COM_SUN_STAR_AWT_FONTPITCH_HPP #include <com/sun/star/awt/FontPitch.hpp> -#endif + +#include <rtl/logfile.hxx> + #include <xmloff/nmspmap.hxx> #include "xmlnmspe.hxx" #include <xmloff/xmltoken.hxx> -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include "fonthdl.hxx" -#endif #include <xmloff/xmlimp.hxx> #include <xmloff/maptype.hxx> - -#ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX #include <xmloff/XMLFontStylesContext.hxx> -#endif -#include <rtl/logfile.hxx> + + using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/XMLRectangleMembersHandler.cxx b/xmloff/source/style/XMLRectangleMembersHandler.cxx index 07334f2137db..acd53e2dfd4e 100644 --- a/xmloff/source/style/XMLRectangleMembersHandler.cxx +++ b/xmloff/source/style/XMLRectangleMembersHandler.cxx @@ -48,11 +48,6 @@ XMLRectangleMembersHdl::XMLRectangleMembersHdl( sal_Int32 nType ) { } - sal_Int32 X; - sal_Int32 Y; - sal_Int32 Width; - sal_Int32 Height; - XMLRectangleMembersHdl::~XMLRectangleMembersHdl() { } diff --git a/xmloff/source/style/adjushdl.cxx b/xmloff/source/style/adjushdl.cxx index 7e7ceb961c36..027bebdb8075 100644 --- a/xmloff/source/style/adjushdl.cxx +++ b/xmloff/source/style/adjushdl.cxx @@ -35,10 +35,6 @@ #include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/uno/Any.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using namespace ::com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/backhdl.cxx b/xmloff/source/style/backhdl.cxx index 476a9a0a97e9..df02a6504bac 100644 --- a/xmloff/source/style/backhdl.cxx +++ b/xmloff/source/style/backhdl.cxx @@ -34,10 +34,6 @@ #include <com/sun/star/uno/Any.hxx> #include <rtl/ustrbuf.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/bordrhdl.cxx b/xmloff/source/style/bordrhdl.cxx index cddf587184b6..5611bbd1f472 100644 --- a/xmloff/source/style/bordrhdl.cxx +++ b/xmloff/source/style/bordrhdl.cxx @@ -34,10 +34,6 @@ #include <xmloff/xmluconv.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Any.hxx> - -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif #include <com/sun/star/table/BorderLine.hpp> using ::rtl::OUString; diff --git a/xmloff/source/style/breakhdl.cxx b/xmloff/source/style/breakhdl.cxx index 0ebe3af8a385..d95cd2e5e91a 100644 --- a/xmloff/source/style/breakhdl.cxx +++ b/xmloff/source/style/breakhdl.cxx @@ -34,10 +34,6 @@ #include <com/sun/star/style/BreakType.hpp> #include <com/sun/star/uno/Any.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/cdouthdl.cxx b/xmloff/source/style/cdouthdl.cxx index f314a2b813f0..c5f764cf9ac4 100644 --- a/xmloff/source/style/cdouthdl.cxx +++ b/xmloff/source/style/cdouthdl.cxx @@ -32,15 +32,9 @@ #include <xmloff/xmluconv.hxx> #include <rtl/ustrbuf.hxx> -#ifndef _COM_SUN_STAR_AWT_FONTSTRIKEOUT_HPP #include <com/sun/star/awt/FontStrikeout.hpp> -#endif #include <com/sun/star/uno/Any.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/chrhghdl.cxx b/xmloff/source/style/chrhghdl.cxx index a3076ca4c864..1a70696583d2 100644 --- a/xmloff/source/style/chrhghdl.cxx +++ b/xmloff/source/style/chrhghdl.cxx @@ -35,10 +35,6 @@ #include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Any.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/chrlohdl.cxx b/xmloff/source/style/chrlohdl.cxx index b1b0a01d93f8..06778d67576f 100644 --- a/xmloff/source/style/chrlohdl.cxx +++ b/xmloff/source/style/chrlohdl.cxx @@ -34,10 +34,6 @@ #include <xmloff/xmluconv.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Any.hxx> - -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif #include <com/sun/star/lang/Locale.hpp> using ::rtl::OUString; diff --git a/xmloff/source/style/csmaphdl.cxx b/xmloff/source/style/csmaphdl.cxx index 023153eda552..0a29de364bce 100644 --- a/xmloff/source/style/csmaphdl.cxx +++ b/xmloff/source/style/csmaphdl.cxx @@ -32,14 +32,8 @@ #include <xmloff/xmluconv.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/style/CaseMap.hpp> - - #include <com/sun/star/uno/Any.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/escphdl.cxx b/xmloff/source/style/escphdl.cxx index 337ff5cdbb60..548f867d6606 100644 --- a/xmloff/source/style/escphdl.cxx +++ b/xmloff/source/style/escphdl.cxx @@ -35,10 +35,6 @@ #include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Any.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/fonthdl.cxx b/xmloff/source/style/fonthdl.cxx index 04e0b36609cd..89ad6e9db8b8 100644 --- a/xmloff/source/style/fonthdl.cxx +++ b/xmloff/source/style/fonthdl.cxx @@ -28,18 +28,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include <fonthdl.hxx> -#endif #include <xmloff/xmltoken.hxx> #include <xmloff/xmluconv.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/uno/Any.hxx> #include <tools/fontenum.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif #include <tools/string.hxx> using ::rtl::OUString; diff --git a/xmloff/source/style/fonthdl.hxx b/xmloff/source/style/fonthdl.hxx index 49d027579af3..18ddae73af14 100644 --- a/xmloff/source/style/fonthdl.hxx +++ b/xmloff/source/style/fonthdl.hxx @@ -25,8 +25,8 @@ * ************************************************************************/ -#ifndef _XMLOFF_PROPERTYHANDLER_FONTYPES_HXX -#define _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX +#ifndef XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX +#define XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include <xmloff/xmlprhdl.hxx> @@ -79,4 +79,4 @@ public: }; -#endif // _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX +#endif // XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX diff --git a/xmloff/source/style/lspachdl.cxx b/xmloff/source/style/lspachdl.cxx index dd47749d205b..6ea6221a0b27 100644 --- a/xmloff/source/style/lspachdl.cxx +++ b/xmloff/source/style/lspachdl.cxx @@ -37,10 +37,6 @@ #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/postuhdl.cxx b/xmloff/source/style/postuhdl.cxx index 28cda4eba8b6..b0885b539d4b 100644 --- a/xmloff/source/style/postuhdl.cxx +++ b/xmloff/source/style/postuhdl.cxx @@ -35,10 +35,6 @@ #include <com/sun/star/awt/FontSlant.hpp> #include <tools/fontenum.hxx> -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif - using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/prhdlfac.cxx b/xmloff/source/style/prhdlfac.cxx index af5448040896..27af64469daf 100644 --- a/xmloff/source/style/prhdlfac.cxx +++ b/xmloff/source/style/prhdlfac.cxx @@ -27,10 +27,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" + #include <com/sun/star/drawing/ColorMode.hpp> #include <com/sun/star/text/HorizontalAdjust.hpp> #include <com/sun/star/text/WritingMode2.hpp> + #include <tools/debug.hxx> + #include <xmloff/prhdlfac.hxx> #include <xmloff/xmltypes.hxx> #include <xmloff/xmltoken.hxx> @@ -39,9 +42,7 @@ #include <xmloff/XMLConstantsPropertyHandler.hxx> #include "cdouthdl.hxx" #include "csmaphdl.hxx" -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include "fonthdl.hxx" -#endif #include "kernihdl.hxx" #include <postuhdl.hxx> #include "shadwhdl.hxx" diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index 5292b92d4128..cb666d899fb7 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -39,7 +39,6 @@ //#include "xmlitmap.hxx" #endif #include <xmloff/xmluconv.hxx> -#include "xmlkywd.hxx" #include <xmloff/attrlist.hxx> #include <xmloff/xmlprmap.hxx> #include <xmloff/xmlexppr.hxx> diff --git a/xmloff/source/style/undlihdl.cxx b/xmloff/source/style/undlihdl.cxx index bbe9eea647b3..226ae3207e50 100644 --- a/xmloff/source/style/undlihdl.cxx +++ b/xmloff/source/style/undlihdl.cxx @@ -34,13 +34,7 @@ #include <com/sun/star/uno/Any.hxx> -#ifndef _COM_SUN_STAR_AWT_FONTUNDERLINE_HPP #include <com/sun/star/awt/FontUnderline.hpp> -#endif - -#ifndef _XMLOFF_XMLEMENT_HXX -#include <xmloff/xmlelement.hxx> -#endif using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/style/xmlimppr.cxx b/xmloff/source/style/xmlimppr.cxx index e81e73cf90b2..812071ff1b03 100644 --- a/xmloff/source/style/xmlimppr.cxx +++ b/xmloff/source/style/xmlimppr.cxx @@ -40,7 +40,6 @@ #include <xmloff/xmlimppr.hxx> #include <xmloff/xmlimp.hxx> -#include "xmlkywd.hxx" #include "unoatrcn.hxx" #include "xmlnmspe.hxx" #include <xmloff/xmltoken.hxx> diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx index 681fff7ea229..5bc581c7af0b 100644 --- a/xmloff/source/style/xmlnume.cxx +++ b/xmloff/source/style/xmlnume.cxx @@ -27,15 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#include <rtl/ustrbuf.hxx> -#include <tools/debug.hxx> -#include <xmloff/nmspmap.hxx> -#include "xmlnmspe.hxx" -#include <xmloff/xmltoken.hxx> -#include <xmloff/xmluconv.hxx> -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX -#include "fonthdl.hxx" -#endif + #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/style/NumberingType.hpp> #include <com/sun/star/style/XStyle.hpp> @@ -52,11 +44,22 @@ // <-- #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> + +#include <rtl/ustrbuf.hxx> + +#include <tools/debug.hxx> + +#include <xmloff/nmspmap.hxx> +#include "xmlnmspe.hxx" +#include <xmloff/xmltoken.hxx> +#include <xmloff/xmluconv.hxx> +#include "fonthdl.hxx" #include "XMLTextListAutoStylePool.hxx" #include <xmloff/xmlnume.hxx> #include <xmloff/xmlexp.hxx> #include <tools/fontenum.hxx> + using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -294,9 +297,12 @@ void SvxXMLNumRuleExport::exportLevelStyle( INT32 nLevel, OUStringBuffer sTmp; sTmp.append( nLevel + 1 ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL, sTmp.makeStringAndClear() ); - if( sTextStyleName.getLength() > 0 ) + // #i110694#: no style-name on list-level-style-image + if ((sTextStyleName.getLength() > 0) && (NumberingType::BITMAP != eType)) + { GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( sTextStyleName ) ); + } if( sPrefix.getLength() > 0 ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_NUM_PREFIX, sPrefix ); if( sSuffix.getLength() > 0 ) diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index d223ba19db05..a192baa2216b 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -2149,7 +2149,7 @@ sal_Bool lcl_IsAtEnd( rtl::OUStringBuffer& rBuffer, const String& rToken ) if ( nTokLen > nBufLen ) return sal_False; - sal_Int32 nStartPos = nTokLen - nBufLen; + sal_Int32 nStartPos = nBufLen - nTokLen; for ( xub_StrLen nTokPos = 0; nTokPos < nTokLen; nTokPos++ ) if ( rToken.GetChar( nTokPos ) != rBuffer.charAt( nStartPos + nTokPos ) ) return sal_False; diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx index d64c22be0179..7306c7d5f0de 100644 --- a/xmloff/source/style/xmlnumi.cxx +++ b/xmloff/source/style/xmlnumi.cxx @@ -27,16 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" -#include <rtl/ustrbuf.hxx> -#include <tools/urlobj.hxx> -#include <tools/debug.hxx> -#include <tools/fontenum.hxx> -#include <xmloff/xmltkmap.hxx> -#include <xmloff/nmspmap.hxx> -#include "xmlnmspe.hxx" -#include <xmloff/xmlimp.hxx> -#include <xmloff/XMLBase64ImportContext.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/Size.hpp> @@ -51,26 +42,33 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/style/XStyle.hpp> #include <com/sun/star/io/XOutputStream.hpp> + +#include <rtl/ustrbuf.hxx> + +#include <tools/urlobj.hxx> +#include <tools/debug.hxx> +#include <tools/fontenum.hxx> + +#include <xmloff/xmltkmap.hxx> +#include <xmloff/nmspmap.hxx> +#include "xmlnmspe.hxx" +#include <xmloff/xmlimp.hxx> +#include <xmloff/XMLBase64ImportContext.hxx> #include <xmloff/xmltoken.hxx> #include "i18nmap.hxx" #include <xmloff/xmluconv.hxx> -#ifndef _XMLOFF_PROPERTYHANDLER_FONTTYPES_HXX #include "fonthdl.hxx" -#endif -#ifndef _XMLOFF_XMLFONTSTYLESCONTEXT_HXX #include <xmloff/XMLFontStylesContext.hxx> -#endif -#ifndef _XMLOFF_FAMILIES_HXX #include <xmloff/families.hxx> -#endif #include <xmloff/maptype.hxx> - #include <xmloff/xmlnumi.hxx> #define _SVSTDARR_USHORTS #include <svl/svstdarr.hxx> + + using ::rtl::OUString; using ::rtl::OUStringBuffer; diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx index 7e46c66442f4..52e4ccc8e048 100644 --- a/xmloff/source/text/XMLChangedRegionImportContext.cxx +++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx @@ -68,6 +68,7 @@ void XMLChangedRegionImportContext::StartElement( const Reference<XAttributeList> & xAttrList) { // process attributes: id + bool bHaveXmlId( false ); sal_Int16 nLength = xAttrList->getLength(); for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) { @@ -77,11 +78,19 @@ void XMLChangedRegionImportContext::StartElement( &sLocalName ); const OUString sValue = xAttrList->getValueByIndex(nAttr); - if ( XML_NAMESPACE_TEXT == nPrefix ) + if (XML_NAMESPACE_XML == nPrefix) { - if( IsXMLToken( sLocalName, XML_ID ) ) + if (IsXMLToken(sLocalName, XML_ID)) { sID = sValue; + bHaveXmlId = true; + } + } + else if (XML_NAMESPACE_TEXT == nPrefix) + { + if (IsXMLToken(sLocalName, XML_ID)) + { + if (!bHaveXmlId) { sID = sValue; } } else if( IsXMLToken( sLocalName, XML_MERGE_LAST_PARAGRAPH ) ) { diff --git a/xmloff/source/text/XMLIndexTOCContext.cxx b/xmloff/source/text/XMLIndexTOCContext.cxx index daf0703803d7..ad9f7ce10d7a 100644 --- a/xmloff/source/text/XMLIndexTOCContext.cxx +++ b/xmloff/source/text/XMLIndexTOCContext.cxx @@ -50,14 +50,11 @@ #include <xmloff/txtimp.hxx> #include <xmloff/nmspmap.hxx> #include "xmlnmspe.hxx" -#include "xmlkywd.hxx" #include <xmloff/xmltoken.hxx> #include <xmloff/prstylei.hxx> #include "xmlerror.hxx" #include <xmloff/xmluconv.hxx> -#include <tools/debug.hxx> #include <rtl/ustring.hxx> -#include <tools/debug.hxx> using namespace ::com::sun::star::uno; @@ -85,15 +82,15 @@ static const sal_Char* aIndexServiceMap[] = "com.sun.star.text.IllustrationsIndex" }; -static const sal_Char* aIndexSourceElementMap[] = +static const XMLTokenEnum aIndexSourceElementMap[] = { - sXML_table_of_content_source, - sXML_alphabetical_index_source, - sXML_table_index_source, - sXML_object_index_source, - sXML_bibliography_source, - sXML_user_index_source, - sXML_illustration_index_source + XML_TABLE_OF_CONTENT_SOURCE, + XML_ALPHABETICAL_INDEX_SOURCE, + XML_TABLE_INDEX_SOURCE, + XML_OBJECT_INDEX_SOURCE, + XML_BIBLIOGRAPHY_SOURCE, + XML_USER_INDEX_SOURCE, + XML_ILLUSTRATION_INDEX_SOURCE }; SvXMLEnumMapEntry __READONLY_DATA aIndexTypeMap[] = @@ -117,7 +114,6 @@ XMLIndexTOCContext::XMLIndexTOCContext( , sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")) , sIsProtected(RTL_CONSTASCII_USTRINGPARAM("IsProtected")) , sName(RTL_CONSTASCII_USTRINGPARAM("Name")) -, pSourceElementName(NULL) , bValid(sal_False) { if (XML_NAMESPACE_TEXT == nPrfx) @@ -126,13 +122,12 @@ XMLIndexTOCContext::XMLIndexTOCContext( if (SvXMLUnitConverter::convertEnum(nTmp, rLocalName, aIndexTypeMap)) { // check for array index: - DBG_ASSERT(nTmp < (sizeof(aIndexServiceMap)/sizeof(sal_Char*)), "index out of range"); - DBG_ASSERT(sizeof(aIndexServiceMap) == + OSL_ENSURE(nTmp < (sizeof(aIndexServiceMap)/sizeof(sal_Char*)), "index out of range"); + OSL_ENSURE(sizeof(aIndexServiceMap) == sizeof(aIndexSourceElementMap), "service and source element maps must be same size"); - eIndexType = (enum IndexTypeEnum)nTmp; - pSourceElementName = aIndexSourceElementMap[eIndexType]; + eIndexType = static_cast<IndexTypeEnum>(nTmp); bValid = sal_True; } } @@ -201,10 +196,6 @@ void XMLIndexTOCContext::StartElement( OUString::createFromAscii(aIndexServiceMap[eIndexType])); if( xIfc.is() ) { - - // xml:id for RDF metadata - GetImport().SetXmlId(xIfc, sXmlId); - // get Property set Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY); xTOCPropertySet = xPropSet; @@ -246,6 +237,9 @@ void XMLIndexTOCContext::StartElement( return; } + // xml:id for RDF metadata + GetImport().SetXmlId(xIfc, sXmlId); + // b) insert marker and move cursor rImport->InsertString(sMarker); rImport->GetCursor()->goLeft(2, sal_False); @@ -326,7 +320,7 @@ SvXMLImportContext* XMLIndexTOCContext::CreateChildContext( xBodyContextRef = pContext; } } - else if (0 == rLocalName.compareToAscii(pSourceElementName)) + else if (IsXMLToken(rLocalName, aIndexSourceElementMap[eIndexType])) { // instantiate source context for the appropriate index type switch (eIndexType) @@ -367,7 +361,7 @@ SvXMLImportContext* XMLIndexTOCContext::CreateChildContext( break; default: - DBG_ERROR("index type not implemented"); + OSL_ENSURE(false, "index type not implemented"); break; } } diff --git a/xmloff/source/text/XMLIndexTOCContext.hxx b/xmloff/source/text/XMLIndexTOCContext.hxx index accaca5a3c53..66f045a5467d 100644 --- a/xmloff/source/text/XMLIndexTOCContext.hxx +++ b/xmloff/source/text/XMLIndexTOCContext.hxx @@ -73,9 +73,6 @@ class XMLIndexTOCContext : public SvXMLImportContext enum IndexTypeEnum eIndexType; - /** source element name (for CreateChildContext) */ - const sal_Char* pSourceElementName; - sal_Bool bValid; SvXMLImportContextRef xBodyContextRef; diff --git a/xmloff/source/text/XMLPropertyBackpatcher.cxx b/xmloff/source/text/XMLPropertyBackpatcher.cxx index 45c5f63c6ec7..364096ad8185 100644 --- a/xmloff/source/text/XMLPropertyBackpatcher.cxx +++ b/xmloff/source/text/XMLPropertyBackpatcher.cxx @@ -30,9 +30,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/uno/Reference.h> -#ifndef _RTL_USTRING #include <rtl/ustring.hxx> -#endif #include <tools/debug.hxx> #include "XMLPropertyBackpatcher.hxx" #include <xmloff/txtimp.hxx> // XMLTextImportHelper partially implemented here @@ -206,7 +204,34 @@ void XMLPropertyBackpatcher<A>::SetDefault() template class XMLPropertyBackpatcher<sal_Int16>; template class XMLPropertyBackpatcher<OUString>; +struct SAL_DLLPRIVATE XMLTextImportHelper::BackpatcherImpl +{ + /// backpatcher for references to footnotes and endnotes + ::std::auto_ptr< XMLPropertyBackpatcher<sal_Int16> > + m_pFootnoteBackpatcher; + + /// backpatchers for references to sequences + ::std::auto_ptr< XMLPropertyBackpatcher<sal_Int16> > + m_pSequenceIdBackpatcher; + + ::std::auto_ptr< XMLPropertyBackpatcher< ::rtl::OUString> > + m_pSequenceNameBackpatcher; +}; + +::boost::shared_ptr<XMLTextImportHelper::BackpatcherImpl> +XMLTextImportHelper::MakeBackpatcherImpl() +{ + // n.b.: the shared_ptr stores the dtor! + return ::boost::shared_ptr<BackpatcherImpl>(new BackpatcherImpl); +} + +static ::rtl::OUString const& GetSequenceNumber() +{ + static ::rtl::OUString s_SequenceNumber( + RTL_CONSTASCII_USTRINGPARAM("SequenceNumber")); + return s_SequenceNumber; +} // // XMLTextImportHelper @@ -224,32 +249,34 @@ template class XMLPropertyBackpatcher<OUString>; XMLPropertyBackpatcher<sal_Int16>& XMLTextImportHelper::GetFootnoteBP() { - if (NULL == pFootnoteBackpatcher) + if (!m_pBackpatcherImpl->m_pFootnoteBackpatcher.get()) { - pFootnoteBackpatcher = - new XMLPropertyBackpatcher<sal_Int16>(sSequenceNumber); + m_pBackpatcherImpl->m_pFootnoteBackpatcher.reset( + new XMLPropertyBackpatcher<sal_Int16>(GetSequenceNumber())); } - return *pFootnoteBackpatcher; + return *m_pBackpatcherImpl->m_pFootnoteBackpatcher; } XMLPropertyBackpatcher<sal_Int16>& XMLTextImportHelper::GetSequenceIdBP() { - if (NULL == pSequenceIdBackpatcher) + if (!m_pBackpatcherImpl->m_pSequenceIdBackpatcher.get()) { - pSequenceIdBackpatcher = - new XMLPropertyBackpatcher<sal_Int16>(sSequenceNumber); + m_pBackpatcherImpl->m_pSequenceIdBackpatcher.reset( + new XMLPropertyBackpatcher<sal_Int16>(GetSequenceNumber())); } - return *pSequenceIdBackpatcher; + return *m_pBackpatcherImpl->m_pSequenceIdBackpatcher; } XMLPropertyBackpatcher<OUString>& XMLTextImportHelper::GetSequenceNameBP() { - if (NULL == pSequenceNameBackpatcher) + static ::rtl::OUString s_SourceName( + RTL_CONSTASCII_USTRINGPARAM("SourceName")); + if (!m_pBackpatcherImpl->m_pSequenceNameBackpatcher.get()) { - pSequenceNameBackpatcher = - new XMLPropertyBackpatcher<OUString>(sSourceName); + m_pBackpatcherImpl->m_pSequenceNameBackpatcher.reset( + new XMLPropertyBackpatcher<OUString>(s_SourceName)); } - return *pSequenceNameBackpatcher; + return *m_pBackpatcherImpl->m_pSequenceNameBackpatcher; } void XMLTextImportHelper::InsertFootnoteID( @@ -283,9 +310,3 @@ void XMLTextImportHelper::ProcessSequenceReference( GetSequenceNameBP().SetProperty(xPropSet, sXMLId); } -void XMLTextImportHelper::_FinitBackpatcher() -{ - delete pFootnoteBackpatcher; - delete pSequenceIdBackpatcher; - delete pSequenceNameBackpatcher; -} diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx index d4ab361f1688..67970330f3ef 100644 --- a/xmloff/source/text/XMLRedlineExport.cxx +++ b/xmloff/source/text/XMLRedlineExport.cxx @@ -374,7 +374,7 @@ void XMLRedlineExport::ExportChangedRegion( const Reference<XPropertySet> & rPropSet) { // Redline-ID - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_ID, GetRedlineID(rPropSet) ); + rExport.AddAttributeIdLegacy(XML_NAMESPACE_TEXT, GetRedlineID(rPropSet)); // merge-last-paragraph Any aAny = rPropSet->getPropertyValue(sMergeLastPara); diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index 2129c54ad874..0a0437426a3c 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -28,7 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" #include "XMLSectionExport.hxx" -#include <tools/debug.hxx> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> @@ -53,7 +52,6 @@ #include <com/sun/star/text/XTextFieldsSupplier.hpp> #include <com/sun/star/text/XChapterNumberingSupplier.hpp> #include <com/sun/star/text/ChapterFormat.hpp> //i90246 -#include "xmlkywd.hxx" #include <xmloff/xmltoken.hxx> #include "xmlnmspe.hxx" #include <xmloff/families.hxx> @@ -306,7 +304,7 @@ void XMLSectionExport::ExportSectionEnd( break; default: - DBG_ERROR("unknown index type"); + OSL_ENSURE(false, "unknown index type"); // default: skip index! break; } @@ -332,7 +330,7 @@ void XMLSectionExport::ExportSectionEnd( } else { - DBG_ERROR("Need element name!"); + OSL_ENSURE(false, "Need element name!"); } } // else: autostyles -> ignore @@ -376,7 +374,7 @@ void XMLSectionExport::ExportIndexStart( default: // skip index - DBG_ERROR("unknown index type"); + OSL_ENSURE(false, "unknown index type"); break; } } @@ -809,15 +807,15 @@ void XMLSectionExport::ExportBaseIndexStart( GetExport().StartElement( XML_NAMESPACE_TEXT, eElement, sal_False ); } -static const sal_Char* aTypeSourceElementNameMap[] = +static const XMLTokenEnum aTypeSourceElementNameMap[] = { - sXML_table_of_content_source, // TOC - sXML_table_index_source, // table index - sXML_illustration_index_source, // illustration index - sXML_object_index_source, // object index - sXML_user_index_source, // user index - sXML_alphabetical_index_source, // alphabetical index - sXML_bibliography_source // bibliography + XML_TABLE_OF_CONTENT_SOURCE, // TOC + XML_TABLE_INDEX_SOURCE, // table index + XML_ILLUSTRATION_INDEX_SOURCE, // illustration index + XML_OBJECT_INDEX_SOURCE, // object index + XML_USER_INDEX_SOURCE, // user index + XML_ALPHABETICAL_INDEX_SOURCE, // alphabetical index + XML_BIBLIOGRAPHY_SOURCE // bibliography }; void XMLSectionExport::ExportBaseIndexSource( @@ -825,8 +823,8 @@ void XMLSectionExport::ExportBaseIndexSource( const Reference<XPropertySet> & rPropertySet) { // check type - DBG_ASSERT(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type"); - DBG_ASSERT(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type"); + OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type"); + OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type"); Any aAny; @@ -854,8 +852,9 @@ void XMLSectionExport::ExportBaseIndexSource( // the index source element (all indices) SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_TEXT, - aTypeSourceElementNameMap[ - eType - TEXT_SECTION_TYPE_TOC], + GetXMLToken( + aTypeSourceElementNameMap[ + eType - TEXT_SECTION_TYPE_TOC]), sal_True, sal_True); // scope for title template (all indices) @@ -925,8 +924,8 @@ void XMLSectionExport::ExportBaseIndexBody( const Reference<XPropertySet> &) { // type not used; checked anyway. - DBG_ASSERT(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type"); - DBG_ASSERT(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type"); + OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type"); + OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type"); // export start only @@ -969,23 +968,23 @@ void XMLSectionExport::ExportTableAndIllustrationIndexSourceAttributes( // map index of LevelFormats to attribute value; // level 0 is always the header -static const sal_Char* aLevelNameTOCMap[] = - { NULL, sXML_1, sXML_2, sXML_3, sXML_4, sXML_5, sXML_6, sXML_7, - sXML_8, sXML_9, sXML_10, NULL }; -static const sal_Char* aLevelNameTableMap[] = - { NULL, "", NULL }; -static const sal_Char* aLevelNameAlphaMap[] = - { NULL, sXML_separator, sXML_1, sXML_2, sXML_3, NULL }; -static const sal_Char* aLevelNameBibliographyMap[] = - { NULL, sXML_article, sXML_book, sXML_booklet, sXML_conference, - sXML_custom1, sXML_custom2, sXML_custom3, sXML_custom4, - sXML_custom5, sXML_email, sXML_inbook, sXML_incollection, - sXML_inproceedings, sXML_journal, - sXML_manual, sXML_mastersthesis, sXML_misc, sXML_phdthesis, - sXML_proceedings, sXML_techreport, sXML_unpublished, sXML_www, - NULL }; - -static const sal_Char** aTypeLevelNameMap[] = +static const XMLTokenEnum aLevelNameTOCMap[] = + { XML_TOKEN_INVALID, XML_1, XML_2, XML_3, XML_4, XML_5, XML_6, XML_7, + XML_8, XML_9, XML_10, XML_TOKEN_INVALID }; +static const XMLTokenEnum aLevelNameTableMap[] = + { XML_TOKEN_INVALID, XML__EMPTY, XML_TOKEN_INVALID }; +static const XMLTokenEnum aLevelNameAlphaMap[] = + { XML_TOKEN_INVALID, XML_SEPARATOR, XML_1, XML_2, XML_3, XML_TOKEN_INVALID }; +static const XMLTokenEnum aLevelNameBibliographyMap[] = + { XML_TOKEN_INVALID, XML_ARTICLE, XML_BOOK, XML_BOOKLET, XML_CONFERENCE, + XML_CUSTOM1, XML_CUSTOM2, XML_CUSTOM3, XML_CUSTOM4, + XML_CUSTOM5, XML_EMAIL, XML_INBOOK, XML_INCOLLECTION, + XML_INPROCEEDINGS, XML_JOURNAL, + XML_MANUAL, XML_MASTERSTHESIS, XML_MISC, XML_PHDTHESIS, + XML_PROCEEDINGS, XML_TECHREPORT, XML_UNPUBLISHED, XML_WWW, + XML_TOKEN_INVALID }; + +static const XMLTokenEnum* aTypeLevelNameMap[] = { aLevelNameTOCMap, // TOC aLevelNameTableMap, // table index @@ -1029,26 +1028,26 @@ static const sal_Char** aTypeLevelStylePropNameMap[] = aLevelStylePropNameBibliographyMap // bibliography }; -static const sal_Char* aTypeLevelAttrMap[] = +static const XMLTokenEnum aTypeLevelAttrMap[] = { - sXML_outline_level, // TOC - NULL, // table index - NULL, // illustration index - NULL, // object index - sXML_outline_level, // user index - sXML_outline_level, // alphabetical index - sXML_bibliography_type // bibliography + XML_OUTLINE_LEVEL, // TOC + XML_TOKEN_INVALID, // table index + XML_TOKEN_INVALID, // illustration index + XML_TOKEN_INVALID, // object index + XML_OUTLINE_LEVEL, // user index + XML_OUTLINE_LEVEL, // alphabetical index + XML_BIBLIOGRAPHY_TYPE // bibliography }; -static const sal_Char* aTypeElementNameMap[] = +static const XMLTokenEnum aTypeElementNameMap[] = { - sXML_table_of_content_entry_template, // TOC - sXML_table_index_entry_template, // table index - sXML_illustration_index_entry_template, // illustration index - sXML_object_index_entry_template, // object index - sXML_user_index_entry_template, // user index - sXML_alphabetical_index_entry_template, // alphabetical index - sXML_bibliography_entry_template // bibliography + XML_TABLE_OF_CONTENT_ENTRY_TEMPLATE, // TOC + XML_TABLE_INDEX_ENTRY_TEMPLATE, // table index + XML_ILLUSTRATION_INDEX_ENTRY_TEMPLATE, // illustration index + XML_OBJECT_INDEX_ENTRY_TEMPLATE, // object index + XML_USER_INDEX_ENTRY_TEMPLATE, // user index + XML_ALPHABETICAL_INDEX_ENTRY_TEMPLATE, // alphabetical index + XML_BIBLIOGRAPHY_ENTRY_TEMPLATE // bibliography }; @@ -1058,44 +1057,44 @@ sal_Bool XMLSectionExport::ExportIndexTemplate( const Reference<XPropertySet> & rPropertySet, Sequence<Sequence<PropertyValue> > & rValues) { - DBG_ASSERT(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type"); - DBG_ASSERT(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type"); - DBG_ASSERT(nOutlineLevel >= 0, "illegal outline level"); + OSL_ENSURE(eType >= TEXT_SECTION_TYPE_TOC, "illegal index type"); + OSL_ENSURE(eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY, "illegal index type"); + OSL_ENSURE(nOutlineLevel >= 0, "illegal outline level"); if ( (eType >= TEXT_SECTION_TYPE_TOC) && (eType <= TEXT_SECTION_TYPE_BIBLIOGRAPHY) && (nOutlineLevel >= 0) ) { // get level name and level attribute name from aLevelNameMap; - const sal_Char* pLevelAttrName = - aTypeLevelAttrMap[eType-TEXT_SECTION_TYPE_TOC]; - const sal_Char* pLevelName = - aTypeLevelNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]; + const XMLTokenEnum eLevelAttrName( + aTypeLevelAttrMap[eType-TEXT_SECTION_TYPE_TOC]); + const XMLTokenEnum eLevelName( + aTypeLevelNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]); // #92124#: some old documents may be broken, then they have // too many template levels; we need to recognize this and // export only as many as is legal for the respective index // type. To do this, we simply return an error flag, which // will then abort further template level exports. - DBG_ASSERT(NULL != pLevelName, "can't find level name"); - if ( NULL == pLevelName ) + OSL_ENSURE(XML_TOKEN_INVALID != eLevelName, "can't find level name"); + if ( XML_TOKEN_INVALID == eLevelName ) { // output level not found? Then end of templates! #91214# return sal_False; } // output level name - if ((NULL != pLevelName) && (NULL != pLevelAttrName)) + if ((XML_TOKEN_INVALID != eLevelName) && (XML_TOKEN_INVALID != eLevelAttrName)) { - GetExport().AddAttributeASCII(XML_NAMESPACE_TEXT, - pLevelAttrName, - pLevelName); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + GetXMLToken(eLevelAttrName), + GetXMLToken(eLevelName)); } // paragraph level style name - const sal_Char* pPropName = - aTypeLevelStylePropNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]; - DBG_ASSERT(NULL != pPropName, "can't find property name"); + const sal_Char* pPropName( + aTypeLevelStylePropNameMap[eType-TEXT_SECTION_TYPE_TOC][nOutlineLevel]); + OSL_ENSURE(NULL != pPropName, "can't find property name"); if (NULL != pPropName) { Any aAny = rPropertySet->getPropertyValue( @@ -1108,11 +1107,11 @@ sal_Bool XMLSectionExport::ExportIndexTemplate( } // template element - const sal_Char* pElementName = - aTypeElementNameMap[eType - TEXT_SECTION_TYPE_TOC]; + const XMLTokenEnum eElementName( + aTypeElementNameMap[eType - TEXT_SECTION_TYPE_TOC]); SvXMLElementExport aLevelTemplate(GetExport(), XML_NAMESPACE_TEXT, - pElementName, + GetXMLToken(eElementName), sal_True, sal_True); // export sequence @@ -1353,39 +1352,46 @@ void XMLSectionExport::ExportIndexTemplateElement( } // convert type to token (and check validity) ... - sal_Char* pElement = NULL; + XMLTokenEnum eElement(XML_TOKEN_INVALID); switch(nTokenType) { case TOK_TTYPE_ENTRY_TEXT: - pElement = sXML_index_entry_text; + eElement = XML_INDEX_ENTRY_TEXT; break; case TOK_TTYPE_TAB_STOP: // test validity - pElement = ( bRightAligned || bTabPositionOK || bFillCharOK ) - ? sXML_index_entry_tab_stop : NULL; + if ( bRightAligned || bTabPositionOK || bFillCharOK ) + { + eElement = XML_INDEX_ENTRY_TAB_STOP; + } break; case TOK_TTYPE_TEXT: // test validity - pElement = bTextOK ? sXML_index_entry_span : NULL; + if (bTextOK) + { + eElement = XML_INDEX_ENTRY_SPAN; + } break; case TOK_TTYPE_PAGE_NUMBER: - pElement = sXML_index_entry_page_number; + eElement = XML_INDEX_ENTRY_PAGE_NUMBER; break; case TOK_TTYPE_CHAPTER_INFO: // keyword index - pElement = sXML_index_entry_chapter; + eElement = XML_INDEX_ENTRY_CHAPTER; break; case TOK_TTYPE_ENTRY_NUMBER: // table of content - pElement = sXML_index_entry_chapter; + eElement = XML_INDEX_ENTRY_CHAPTER; break; case TOK_TTYPE_HYPERLINK_START: - pElement = sXML_index_entry_link_start; + eElement = XML_INDEX_ENTRY_LINK_START; break; case TOK_TTYPE_HYPERLINK_END: - pElement = sXML_index_entry_link_end; + eElement = XML_INDEX_ENTRY_LINK_END; break; case TOK_TTYPE_BIBLIOGRAPHY: - pElement = bBibliographyDataOK - ? sXML_index_entry_bibliography : NULL; + if (bBibliographyDataOK) + { + eElement = XML_INDEX_ENTRY_BIBLIOGRAPHY; + } break; default: ; // unknown/unimplemented template @@ -1404,7 +1410,7 @@ void XMLSectionExport::ExportIndexTemplateElement( //it's not permitted in other indexes if (eType != TEXT_SECTION_TYPE_ALPHABETICAL) { - pElement = NULL; //not permitted, null the element + eElement = XML_TOKEN_INVALID; //not permitted, invalidate the element } else //maps format for 1.1 & 1.0 { @@ -1447,7 +1453,7 @@ void XMLSectionExport::ExportIndexTemplateElement( //<--- // ... and write Element - if (pElement != NULL) + if (eElement != XML_TOKEN_INVALID) { // character style (for most templates) if (bCharStyleOK) @@ -1510,7 +1516,7 @@ void XMLSectionExport::ExportIndexTemplateElement( // bibliography data if (TOK_TTYPE_BIBLIOGRAPHY == nTokenType) { - DBG_ASSERT(bBibliographyDataOK, "need bibl data"); + OSL_ENSURE(bBibliographyDataOK, "need bibl data"); OUStringBuffer sBuf; if (SvXMLUnitConverter::convertEnum( sBuf, nBibliographyData, aBibliographyDataFieldMap ) ) @@ -1524,7 +1530,7 @@ void XMLSectionExport::ExportIndexTemplateElement( // chapter info if (TOK_TTYPE_CHAPTER_INFO == nTokenType) { - DBG_ASSERT(bChapterFormatOK, "need chapter info"); + OSL_ENSURE(bChapterFormatOK, "need chapter info"); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_DISPLAY, XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat)); @@ -1550,7 +1556,9 @@ void XMLSectionExport::ExportIndexTemplateElement( //<--- // export template SvXMLElementExport aTemplateElement(GetExport(), XML_NAMESPACE_TEXT, - pElement, sal_True, sal_False); + GetXMLToken(eElement), + sal_True, sal_False) + ; // entry text or span element: write text if (TOK_TTYPE_TEXT == nTokenType) @@ -1614,7 +1622,7 @@ void XMLSectionExport::ExportBoolean( sal_Bool bDefault, sal_Bool bInvert) { - DBG_ASSERT(eAttributeName != XML_TOKEN_INVALID, "Need attribute name"); + OSL_ENSURE(eAttributeName != XML_TOKEN_INVALID, "Need attribute name"); Any aAny = rPropSet->getPropertyValue(sPropertyName); sal_Bool bTmp = *(sal_Bool*)aAny.getValue(); @@ -1656,7 +1664,7 @@ void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport) Reference<XPropertySet> xPropSet; aAny >>= xPropSet; - DBG_ASSERT( xPropSet.is(), "field master must have XPropSet" ); + OSL_ENSURE( xPropSet.is(), "field master must have XPropSet" ); const OUString sBracketBefore( RTL_CONSTASCII_USTRINGPARAM("BracketBefore")); @@ -1843,7 +1851,7 @@ sal_Bool XMLSectionExport::IsInSection( { // default: like default argument sal_Bool bRet = bDefault; - DBG_ASSERT(rEnclosingSection.is(), "enclosing section expected"); + OSL_ENSURE(rEnclosingSection.is(), "enclosing section expected"); Reference<XPropertySet> xPropSet(rContent, UNO_QUERY); if (xPropSet.is()) diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx index f31ce783565f..4b9b94b1ced7 100644 --- a/xmloff/source/text/XMLSectionImportContext.cxx +++ b/xmloff/source/text/XMLSectionImportContext.cxx @@ -161,9 +161,6 @@ void XMLSectionImportContext::StartElement( // save PropertySet (for CreateChildContext) xSectionPropertySet = xPropSet; - // xml:id for RDF metadata - GetImport().SetXmlId(xIfc, sXmlId); - // name Reference<XNamed> xNamed(xPropSet, UNO_QUERY); xNamed->setName(sName); @@ -253,6 +250,9 @@ void XMLSectionImportContext::StartElement( // finally, check for redlines that should start at // the section start node rHelper->RedlineAdjustStartNodeCursor(sal_True); // start ??? + + // xml:id for RDF metadata + GetImport().SetXmlId(xIfc, sXmlId); } } } diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index c15bb1a64055..accaa49d5ea4 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -43,7 +43,6 @@ #include <xmloff/xmlimp.hxx> #include <xmloff/xmltoken.hxx> #include "xmlnmspe.hxx" -#include "xmlkywd.hxx" #include <xmloff/nmspmap.hxx> #include <xmloff/xmluconv.hxx> #include "XMLAnchorTypePropHdl.hxx" @@ -1032,10 +1031,11 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( { OUString sValue( rValue ); sValue.trim(); - const sal_Int32 nRotateLen = sizeof(sXML_rotate)-1; + const OUString aRotate(GetXMLToken(XML_ROTATE)); + const sal_Int32 nRotateLen(aRotate.getLength()); sal_Int32 nLen = sValue.getLength(); if( nLen >= nRotateLen+3 && - 0 == sValue.compareToAscii( sXML_rotate, nRotateLen ) && + 0 == sValue.compareTo( aRotate, nRotateLen ) && '(' == sValue[nRotateLen] && ')' == sValue[nLen-1] ) { @@ -1241,6 +1241,14 @@ void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef, const OUString& rTargetFrameName, sal_Bool bMap ) { + static ::rtl::OUString s_HyperLinkURL( + RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")); + static ::rtl::OUString s_HyperLinkName( + RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")); + static ::rtl::OUString s_HyperLinkTarget( + RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")); + static ::rtl::OUString s_ServerMap( + RTL_CONSTASCII_USTRINGPARAM("ServerMap")); if( !xPropSet.is() ) return; @@ -1248,29 +1256,29 @@ void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef, Reference < XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); if( !xPropSetInfo.is() || - !xPropSetInfo->hasPropertyByName( xTxtImp->sHyperLinkURL ) ) + !xPropSetInfo->hasPropertyByName(s_HyperLinkURL)) return; Any aAny; aAny <<= rHRef; - xPropSet->setPropertyValue( xTxtImp->sHyperLinkURL, aAny ); + xPropSet->setPropertyValue( s_HyperLinkURL, aAny ); - if( xPropSetInfo->hasPropertyByName( xTxtImp->sHyperLinkName ) ) + if (xPropSetInfo->hasPropertyByName(s_HyperLinkName)) { aAny <<= rName; - xPropSet->setPropertyValue( xTxtImp->sHyperLinkName, aAny ); + xPropSet->setPropertyValue(s_HyperLinkName, aAny); } - if( xPropSetInfo->hasPropertyByName( xTxtImp->sHyperLinkTarget ) ) + if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget)) { aAny <<= rTargetFrameName; - xPropSet->setPropertyValue( xTxtImp->sHyperLinkTarget, aAny ); + xPropSet->setPropertyValue( s_HyperLinkTarget, aAny ); } - if( xPropSetInfo->hasPropertyByName( xTxtImp->sServerMap ) ) + if (xPropSetInfo->hasPropertyByName(s_ServerMap)) { aAny.setValue( &bMap, ::getBooleanCppuType() ); - xPropSet->setPropertyValue( xTxtImp->sServerMap, aAny ); + xPropSet->setPropertyValue(s_ServerMap, aAny); } } diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx index fdf1da1c9aff..fd2cb58b257f 100644 --- a/xmloff/source/text/XMLTextListBlockContext.cxx +++ b/xmloff/source/text/XMLTextListBlockContext.cxx @@ -79,6 +79,8 @@ XMLTextListBlockContext::XMLTextListBlockContext( , msContinueListId() // <-- { + static ::rtl::OUString s_PropNameDefaultListId( + RTL_CONSTASCII_USTRINGPARAM("DefaultListId")); { // get the parent list block context (if any); this is a bit ugly... XMLTextListBlockContext * pLB(0); @@ -180,10 +182,12 @@ XMLTextListBlockContext::XMLTextListBlockContext( { uno::Reference< beans::XPropertySetInfo > xNumRulePropSetInfo( xNumRuleProps->getPropertySetInfo()); - if ( xNumRulePropSetInfo.is() && - xNumRulePropSetInfo->hasPropertyByName( mrTxtImport.sPropNameDefaultListId) ) + if (xNumRulePropSetInfo.is() && + xNumRulePropSetInfo->hasPropertyByName( + s_PropNameDefaultListId)) { - xNumRuleProps->getPropertyValue( mrTxtImport.sPropNameDefaultListId ) >>= sListStyleDefaultListId; + xNumRuleProps->getPropertyValue(s_PropNameDefaultListId) + >>= sListStyleDefaultListId; DBG_ASSERT( sListStyleDefaultListId.getLength() != 0, "no default list id found at numbering rules instance. Serious defect -> please inform OD." ); } diff --git a/xmloff/source/text/XMLTextListItemContext.cxx b/xmloff/source/text/XMLTextListItemContext.cxx index 2f26f15c7c5c..b9a6dc1915e5 100644 --- a/xmloff/source/text/XMLTextListItemContext.cxx +++ b/xmloff/source/text/XMLTextListItemContext.cxx @@ -69,6 +69,8 @@ XMLTextListItemContext::XMLTextListItemContext( mxNumRulesOverride() // <-- { + static ::rtl::OUString s_NumberingRules( + RTL_CONSTASCII_USTRINGPARAM("NumberingRules")); sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for( sal_Int16 i=0; i < nAttrCount; i++ ) { @@ -105,7 +107,7 @@ XMLTextListItemContext::XMLTextListItemContext( aAny >>= xStyle; uno::Reference< beans::XPropertySet > xPropSet( xStyle, UNO_QUERY ); - aAny = xPropSet->getPropertyValue( rTxtImp.sNumberingRules ); + aAny = xPropSet->getPropertyValue(s_NumberingRules); aAny >>= mxNumRulesOverride; } else diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index 91fe01dfcc3a..af51f5f56d98 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -49,10 +49,13 @@ #include <com/sun/star/text/XFormField.hpp> +#include "RDFaImportHelper.hxx" + using ::rtl::OUString; using ::rtl::OUStringBuffer; +using namespace ::com::sun::star; using namespace ::com::sun::star::text; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -113,7 +116,6 @@ XMLTextMarkImportContext::XMLTextMarkImportContext( const OUString& rLocalName ) : SvXMLImportContext(rImport, nPrefix, rLocalName) , m_rHelper(rHlp) - , m_bHaveAbout(false) { } @@ -190,13 +192,13 @@ void XMLTextMarkImportContext::EndElement() { SvXMLImportContext::EndElement(); - const OUString sAPI_reference_mark( + static const OUString sAPI_reference_mark( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.ReferenceMark")); - const OUString sAPI_bookmark( + static const OUString sAPI_bookmark( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Bookmark")); - const OUString sAPI_fieldmark( + static const OUString sAPI_fieldmark( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Fieldmark")); - const OUString sAPI_formfieldmark( + static const OUString sAPI_formfieldmark( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.FormFieldmark")); if (m_sBookmarkName.getLength() > 0) @@ -228,13 +230,6 @@ void XMLTextMarkImportContext::EndElement() m_sBookmarkName, m_rHelper.GetCursorAsRange()->getStart(), m_sXmlId) ); - if (m_bHaveAbout) - { - const Reference<com::sun::star::rdf::XMetadatable> - xMeta( xContent, UNO_QUERY); - GetImport().AddRDFa(xMeta, - m_sAbout, m_sProperty, m_sContent, m_sDatatype); - } if ((lcl_MarkType)nTmp==TypeFieldmark) { if (xContent.is() && bImportAsField) { // setup fieldmark... @@ -252,9 +247,22 @@ void XMLTextMarkImportContext::EndElement() case TypeFieldmarkStart: case TypeBookmarkStart: // save XTextRange for later construction of bookmark - m_rHelper.InsertBookmarkStartRange( - m_sBookmarkName, m_rHelper.GetCursorAsRange()->getStart(), - m_sXmlId); + { + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > + pRDFaAttributes; + if (m_bHaveAbout && (TypeBookmarkStart + == static_cast<lcl_MarkType>(nTmp))) + { + pRDFaAttributes = + GetImport().GetRDFaImportHelper().ParseRDFa( + m_sAbout, m_sProperty, + m_sContent, m_sDatatype); + } + m_rHelper.InsertBookmarkStartRange( + m_sBookmarkName, + m_rHelper.GetCursorAsRange()->getStart(), + m_sXmlId, pRDFaAttributes); + } break; case TypeFieldmarkEnd: @@ -262,8 +270,11 @@ void XMLTextMarkImportContext::EndElement() { // get old range, and construct Reference<XTextRange> xStartRange; - if (m_rHelper.FindAndRemoveBookmarkStartRange(m_sBookmarkName, - xStartRange, m_sXmlId)) + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > + pRDFaAttributes; + if (m_rHelper.FindAndRemoveBookmarkStartRange( + m_sBookmarkName, xStartRange, + m_sXmlId, pRDFaAttributes)) { Reference<XTextRange> xEndRange( m_rHelper.GetCursorAsRange()->getStart()); @@ -295,12 +306,12 @@ void XMLTextMarkImportContext::EndElement() m_sBookmarkName, xInsertionRange, m_sXmlId) ); - if (m_bHaveAbout) + if (pRDFaAttributes) { - const Reference<com::sun::star::rdf::XMetadatable> - xMeta( xContent, UNO_QUERY); - GetImport().AddRDFa(xMeta, - m_sAbout, m_sProperty, m_sContent, m_sDatatype); + const Reference<rdf::XMetadatable> + xMeta(xContent, UNO_QUERY); + GetImport().GetRDFaImportHelper().AddRDFa( + xMeta, pRDFaAttributes); } if ((lcl_MarkType)nTmp==TypeFieldmarkEnd) { diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 335276a6865d..579ad91ddfe9 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -212,87 +212,6 @@ const sal_Char sAPI_TextRange[] = "TextRange"; const sal_Char sAPI_true[] = "TRUE"; -static __FAR_DATA SvXMLTokenMapEntry aTextFieldAttrTokenMap[] = -{ - { XML_NAMESPACE_TEXT, XML_FIXED, XML_TOK_TEXTFIELD_FIXED }, - { XML_NAMESPACE_TEXT, XML_DESCRIPTION, XML_TOK_TEXTFIELD_DESCRIPTION }, - { XML_NAMESPACE_TEXT, XML_HELP, XML_TOK_TEXTFIELD_HELP }, - { XML_NAMESPACE_TEXT, XML_HINT, XML_TOK_TEXTFIELD_HINT }, - { XML_NAMESPACE_TEXT, XML_PLACEHOLDER_TYPE, - XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE }, - { XML_NAMESPACE_TEXT, XML_NAME, XML_TOK_TEXTFIELD_NAME }, - { XML_NAMESPACE_TEXT, XML_FORMULA, XML_TOK_TEXTFIELD_FORMULA }, - { XML_NAMESPACE_STYLE, XML_NUM_FORMAT, XML_TOK_TEXTFIELD_NUM_FORMAT }, - { XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC, - XML_TOK_TEXTFIELD_NUM_LETTER_SYNC }, - { XML_NAMESPACE_TEXT, XML_DISPLAY_FORMULA, - XML_TOK_TEXTFIELD_DISPLAY_FORMULA }, - { XML_NAMESPACE_TEXT, XML_VALUE_TYPE, XML_TOK_TEXTFIELD_VALUE_TYPE }, // #i32362#: src680m48++ saves text:value-type - { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_TEXTFIELD_VALUE_TYPE }, - { XML_NAMESPACE_TEXT, XML_VALUE, XML_TOK_TEXTFIELD_VALUE }, - { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_TEXTFIELD_VALUE }, - { XML_NAMESPACE_TEXT, XML_STRING_VALUE, XML_TOK_TEXTFIELD_STRING_VALUE }, - { XML_NAMESPACE_OFFICE, XML_STRING_VALUE, XML_TOK_TEXTFIELD_STRING_VALUE }, - { XML_NAMESPACE_TEXT, XML_DATE_VALUE, XML_TOK_TEXTFIELD_DATE_VALUE }, - { XML_NAMESPACE_OFFICE, XML_DATE_VALUE, XML_TOK_TEXTFIELD_DATE_VALUE }, - { XML_NAMESPACE_TEXT, XML_TIME_VALUE, XML_TOK_TEXTFIELD_TIME_VALUE }, - { XML_NAMESPACE_OFFICE, XML_TIME_VALUE, XML_TOK_TEXTFIELD_TIME_VALUE }, - { XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TOK_TEXTFIELD_BOOL_VALUE}, - { XML_NAMESPACE_OFFICE, XML_CURRENCY, XML_TOK_TEXTFIELD_CURRENCY}, - { XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, - XML_TOK_TEXTFIELD_DATA_STYLE_NAME }, - { XML_NAMESPACE_TEXT, XML_DISPLAY_OUTLINE_LEVEL, - XML_TOK_TEXTFIELD_NUMBERING_LEVEL }, - { XML_NAMESPACE_TEXT, XML_SEPARATION_CHARACTER, - XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR }, - { XML_NAMESPACE_TEXT, XML_DISPLAY, XML_TOK_TEXTFIELD_DISPLAY }, - { XML_NAMESPACE_TEXT, XML_TIME_ADJUST, XML_TOK_TEXTFIELD_TIME_ADJUST }, - { XML_NAMESPACE_TEXT, XML_DATE_ADJUST, XML_TOK_TEXTFIELD_DATE_ADJUST }, - { XML_NAMESPACE_TEXT, XML_PAGE_ADJUST, XML_TOK_TEXTFIELD_PAGE_ADJUST }, - { XML_NAMESPACE_TEXT, XML_SELECT_PAGE, XML_TOK_TEXTFIELD_SELECT_PAGE }, - { XML_NAMESPACE_TEXT, XML_DATABASE_NAME, XML_TOK_TEXTFIELD_DATABASE_NAME}, - { XML_NAMESPACE_TEXT, XML_TABLE_NAME, XML_TOK_TEXTFIELD_TABLE_NAME }, - { XML_NAMESPACE_TEXT, XML_COLUMN_NAME, XML_TOK_TEXTFIELD_COLUMN_NAME }, - { XML_NAMESPACE_TEXT, XML_ROW_NUMBER, XML_TOK_TEXTFIELD_ROW_NUMBER }, - { XML_NAMESPACE_TEXT, XML_CONDITION, XML_TOK_TEXTFIELD_CONDITION }, - { XML_NAMESPACE_TEXT, XML_STRING_VALUE_IF_TRUE, - XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE }, - { XML_NAMESPACE_TEXT, XML_STRING_VALUE_IF_FALSE, - XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE }, - { XML_NAMESPACE_TEXT, XML_EDITING_CYCLES, XML_TOK_TEXTFIELD_REVISION }, - { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, XML_TOK_TEXTFIELD_OUTLINE_LEVEL}, - { XML_NAMESPACE_TEXT, XML_ACTIVE, XML_TOK_TEXTFIELD_ACTIVE }, - { XML_NAMESPACE_TEXT, XML_NOTE_CLASS, XML_TOK_TEXTFIELD_NOTE_CLASS }, - { XML_NAMESPACE_TEXT, XML_REFERENCE_FORMAT, - XML_TOK_TEXTFIELD_REFERENCE_FORMAT }, - { XML_NAMESPACE_TEXT, XML_REF_NAME, XML_TOK_TEXTFIELD_REF_NAME }, - { XML_NAMESPACE_TEXT, XML_CONNECTION_NAME, - XML_TOK_TEXTFIELD_CONNECTION_NAME }, - { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXTFIELD_HREF }, - { XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, - XML_TOK_TEXTFIELD_TARGET_FRAME }, - { XML_NAMESPACE_TEXT, XML_ANNOTATION, XML_TOK_TEXTFIELD_ANNOTATION }, - { XML_NAMESPACE_SCRIPT, XML_LANGUAGE, XML_TOK_TEXTFIELD_LANGUAGE }, - { XML_NAMESPACE_TEXT, XML_KIND, XML_TOK_TEXTFIELD_MEASURE_KIND }, - { XML_NAMESPACE_TEXT, XML_IS_HIDDEN, XML_TOK_TEXTFIELD_IS_HIDDEN }, - { XML_NAMESPACE_TEXT, XML_CURRENT_VALUE, - XML_TOK_TEXTFIELD_CURRENT_VALUE }, - { XML_NAMESPACE_TEXT, XML_TABLE_TYPE, XML_TOK_TEXTFIELD_TABLE_TYPE }, - - XML_TOKEN_MAP_END -}; - -const SvXMLTokenMap& XMLTextImportHelper::GetTextFieldAttrTokenMap() -{ - if ( !pTextFieldAttrTokenMap.get() ) { - pTextFieldAttrTokenMap.reset( - new SvXMLTokenMap(aTextFieldAttrTokenMap) ); - } - - return *pTextFieldAttrTokenMap; - -} - TYPEINIT1( XMLTextFieldImportContext, SvXMLImportContext); XMLTextFieldImportContext::XMLTextFieldImportContext( diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 7ffbe6b81d71..ca369f85b01d 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -27,6 +27,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_xmloff.hxx" + +#include <vector> + +#include <boost/scoped_array.hpp> +#include <boost/tuple/tuple.hpp> + #include <tools/solar.h> #include <tools/debug.hxx> #ifndef _SVSTDARR_STRINGSDTOR_DECL @@ -45,6 +51,7 @@ #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/text/XTextFrame.hpp> +#include <com/sun/star/text/XFormField.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/util/DateTime.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -56,6 +63,8 @@ #include <xmloff/families.hxx> #include <xmloff/xmlnumfi.hxx> #include <xmloff/xmlnumi.hxx> +#include <xmloff/xmlictxt.hxx> +#include <xmloff/xmlimppr.hxx> #include "txtparai.hxx" #include <xmloff/txtimp.hxx> @@ -97,6 +106,7 @@ using ::rtl::OUStringBuffer; using ::com::sun::star::ucb::XAnyCompare; using namespace ::std; +using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::text; @@ -333,11 +343,11 @@ static __FAR_DATA SvXMLTokenMapEntry aTextPAttrTokenMap[] = { 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_ID, XML_TOK_TEXT_P_TEXTID }, { 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 }, { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL,XML_TOK_TEXT_P_LEVEL }, - { XML_NAMESPACE_TEXT, XML_ID, XML_TOK_TEXT_P_ID }, { XML_NAMESPACE_TEXT, XML_IS_LIST_HEADER,XML_TOK_TEXT_P_IS_LIST_HEADER }, { XML_NAMESPACE_TEXT, XML_RESTART_NUMBERING,XML_TOK_TEXT_P_RESTART_NUMBERING }, { XML_NAMESPACE_TEXT, XML_START_VALUE,XML_TOK_TEXT_P_START_VALUE }, @@ -444,9 +454,436 @@ static __FAR_DATA SvXMLTokenMapEntry aTextMasterPageElemTokenMap[] = XML_TOKEN_MAP_END }; +static __FAR_DATA SvXMLTokenMapEntry aTextFieldAttrTokenMap[] = +{ + { XML_NAMESPACE_TEXT, XML_FIXED, XML_TOK_TEXTFIELD_FIXED }, + { XML_NAMESPACE_TEXT, XML_DESCRIPTION, XML_TOK_TEXTFIELD_DESCRIPTION }, + { XML_NAMESPACE_TEXT, XML_HELP, XML_TOK_TEXTFIELD_HELP }, + { XML_NAMESPACE_TEXT, XML_HINT, XML_TOK_TEXTFIELD_HINT }, + { XML_NAMESPACE_TEXT, XML_PLACEHOLDER_TYPE, + XML_TOK_TEXTFIELD_PLACEHOLDER_TYPE }, + { XML_NAMESPACE_TEXT, XML_NAME, XML_TOK_TEXTFIELD_NAME }, + { XML_NAMESPACE_TEXT, XML_FORMULA, XML_TOK_TEXTFIELD_FORMULA }, + { XML_NAMESPACE_STYLE, XML_NUM_FORMAT, XML_TOK_TEXTFIELD_NUM_FORMAT }, + { XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC, + XML_TOK_TEXTFIELD_NUM_LETTER_SYNC }, + { XML_NAMESPACE_TEXT, XML_DISPLAY_FORMULA, + XML_TOK_TEXTFIELD_DISPLAY_FORMULA }, + { XML_NAMESPACE_TEXT, XML_VALUE_TYPE, XML_TOK_TEXTFIELD_VALUE_TYPE }, // #i32362#: src680m48++ saves text:value-type + { XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_TOK_TEXTFIELD_VALUE_TYPE }, + { XML_NAMESPACE_TEXT, XML_VALUE, XML_TOK_TEXTFIELD_VALUE }, + { XML_NAMESPACE_OFFICE, XML_VALUE, XML_TOK_TEXTFIELD_VALUE }, + { XML_NAMESPACE_TEXT, XML_STRING_VALUE, XML_TOK_TEXTFIELD_STRING_VALUE }, + { XML_NAMESPACE_OFFICE, XML_STRING_VALUE, XML_TOK_TEXTFIELD_STRING_VALUE }, + { XML_NAMESPACE_TEXT, XML_DATE_VALUE, XML_TOK_TEXTFIELD_DATE_VALUE }, + { XML_NAMESPACE_OFFICE, XML_DATE_VALUE, XML_TOK_TEXTFIELD_DATE_VALUE }, + { XML_NAMESPACE_TEXT, XML_TIME_VALUE, XML_TOK_TEXTFIELD_TIME_VALUE }, + { XML_NAMESPACE_OFFICE, XML_TIME_VALUE, XML_TOK_TEXTFIELD_TIME_VALUE }, + { XML_NAMESPACE_OFFICE, XML_BOOLEAN_VALUE, XML_TOK_TEXTFIELD_BOOL_VALUE}, + { XML_NAMESPACE_OFFICE, XML_CURRENCY, XML_TOK_TEXTFIELD_CURRENCY}, + { XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, + XML_TOK_TEXTFIELD_DATA_STYLE_NAME }, + { XML_NAMESPACE_TEXT, XML_DISPLAY_OUTLINE_LEVEL, + XML_TOK_TEXTFIELD_NUMBERING_LEVEL }, + { XML_NAMESPACE_TEXT, XML_SEPARATION_CHARACTER, + XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR }, + { XML_NAMESPACE_TEXT, XML_DISPLAY, XML_TOK_TEXTFIELD_DISPLAY }, + { XML_NAMESPACE_TEXT, XML_TIME_ADJUST, XML_TOK_TEXTFIELD_TIME_ADJUST }, + { XML_NAMESPACE_TEXT, XML_DATE_ADJUST, XML_TOK_TEXTFIELD_DATE_ADJUST }, + { XML_NAMESPACE_TEXT, XML_PAGE_ADJUST, XML_TOK_TEXTFIELD_PAGE_ADJUST }, + { XML_NAMESPACE_TEXT, XML_SELECT_PAGE, XML_TOK_TEXTFIELD_SELECT_PAGE }, + { XML_NAMESPACE_TEXT, XML_DATABASE_NAME, XML_TOK_TEXTFIELD_DATABASE_NAME}, + { XML_NAMESPACE_TEXT, XML_TABLE_NAME, XML_TOK_TEXTFIELD_TABLE_NAME }, + { XML_NAMESPACE_TEXT, XML_COLUMN_NAME, XML_TOK_TEXTFIELD_COLUMN_NAME }, + { XML_NAMESPACE_TEXT, XML_ROW_NUMBER, XML_TOK_TEXTFIELD_ROW_NUMBER }, + { XML_NAMESPACE_TEXT, XML_CONDITION, XML_TOK_TEXTFIELD_CONDITION }, + { XML_NAMESPACE_TEXT, XML_STRING_VALUE_IF_TRUE, + XML_TOK_TEXTFIELD_STRING_VALUE_IF_TRUE }, + { XML_NAMESPACE_TEXT, XML_STRING_VALUE_IF_FALSE, + XML_TOK_TEXTFIELD_STRING_VALUE_IF_FALSE }, + { XML_NAMESPACE_TEXT, XML_EDITING_CYCLES, XML_TOK_TEXTFIELD_REVISION }, + { XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, XML_TOK_TEXTFIELD_OUTLINE_LEVEL}, + { XML_NAMESPACE_TEXT, XML_ACTIVE, XML_TOK_TEXTFIELD_ACTIVE }, + { XML_NAMESPACE_TEXT, XML_NOTE_CLASS, XML_TOK_TEXTFIELD_NOTE_CLASS }, + { XML_NAMESPACE_TEXT, XML_REFERENCE_FORMAT, + XML_TOK_TEXTFIELD_REFERENCE_FORMAT }, + { XML_NAMESPACE_TEXT, XML_REF_NAME, XML_TOK_TEXTFIELD_REF_NAME }, + { XML_NAMESPACE_TEXT, XML_CONNECTION_NAME, + XML_TOK_TEXTFIELD_CONNECTION_NAME }, + { XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_TEXTFIELD_HREF }, + { XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, + XML_TOK_TEXTFIELD_TARGET_FRAME }, + { XML_NAMESPACE_TEXT, XML_ANNOTATION, XML_TOK_TEXTFIELD_ANNOTATION }, + { XML_NAMESPACE_SCRIPT, XML_LANGUAGE, XML_TOK_TEXTFIELD_LANGUAGE }, + { XML_NAMESPACE_TEXT, XML_KIND, XML_TOK_TEXTFIELD_MEASURE_KIND }, + { XML_NAMESPACE_TEXT, XML_IS_HIDDEN, XML_TOK_TEXTFIELD_IS_HIDDEN }, + { XML_NAMESPACE_TEXT, XML_CURRENT_VALUE, + XML_TOK_TEXTFIELD_CURRENT_VALUE }, + { XML_NAMESPACE_TEXT, XML_TABLE_TYPE, XML_TOK_TEXTFIELD_TABLE_TYPE }, + + XML_TOKEN_MAP_END +}; + + // maximum allowed length of combined characters field #define MAX_COMBINED_CHARACTERS 6 +struct SAL_DLLPRIVATE XMLTextImportHelper::Impl + : private ::boost::noncopyable +{ + ::std::auto_ptr<SvXMLTokenMap> m_pTextElemTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextPElemTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextPAttrTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextFieldAttrTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextNumberedParagraphAttrTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextListBlockAttrTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextListBlockElemTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextFrameAttrTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextContourAttrTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextHyperlinkAttrTokenMap; + ::std::auto_ptr<SvXMLTokenMap> m_pTextMasterPageElemTokenMap; + ::std::auto_ptr<SvStringsDtor> m_pPrevFrmNames; + ::std::auto_ptr<SvStringsDtor> m_pNextFrmNames; + + // --> OD 2008-04-25 #refactorlists# + ::std::auto_ptr<XMLTextListsHelper> m_pTextListsHelper; + // <-- + + SvXMLImportContextRef m_xAutoStyles; + SvXMLImportContextRef m_xFontDecls; + + XMLSectionList_Impl m_SectionList; + + UniReference< SvXMLImportPropertyMapper > m_xParaImpPrMap; + UniReference< SvXMLImportPropertyMapper > m_xTextImpPrMap; + UniReference< SvXMLImportPropertyMapper > m_xFrameImpPrMap; + UniReference< SvXMLImportPropertyMapper > m_xSectionImpPrMap; + UniReference< SvXMLImportPropertyMapper > m_xRubyImpPrMap; + + ::std::auto_ptr<SvI18NMap> m_pRenameMap; + // --> OD 2006-10-12 #i69629# - change and extend data structure: + // - data structure contains candidates of paragraph styles, which + // will be assigned to the outline style + // - data structure contains more than one candidate for each list level + // of the outline style + ::boost::scoped_array< ::std::vector< ::rtl::OUString > > + m_pOutlineStylesCandidates; + // <-- + + // start range, xml:id, RDFa stuff + typedef ::boost::tuple< + uno::Reference<text::XTextRange>, ::rtl::OUString, + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > > + BookmarkMapEntry_t; + /// start ranges for open bookmarks + ::std::map< ::rtl::OUString, BookmarkMapEntry_t, + ::comphelper::UStringLess> m_BookmarkStartRanges; + + typedef ::std::vector< ::rtl::OUString > BookmarkVector_t; + BookmarkVector_t m_BookmarkVector; + + /// name of the last 'open' redline that started between paragraphs + ::rtl::OUString m_sOpenRedlineIdentifier; + + uno::Reference<text::XText> m_xText; + uno::Reference<text::XTextCursor> m_xCursor; + uno::Reference<text::XTextRange> m_xCursorAsRange; + uno::Reference<container::XNameContainer> m_xParaStyles; + uno::Reference<container::XNameContainer> m_xTextStyles; + uno::Reference<container::XNameContainer> m_xNumStyles; + uno::Reference<container::XNameContainer> m_xFrameStyles; + uno::Reference<container::XNameContainer> m_xPageStyles; + uno::Reference<container::XIndexReplace> m_xChapterNumbering; + uno::Reference<container::XNameAccess> m_xTextFrames; + uno::Reference<container::XNameAccess> m_xGraphics; + uno::Reference<container::XNameAccess> m_xObjects; + uno::Reference<lang::XMultiServiceFactory> m_xServiceFactory; + + SvXMLImport & m_rSvXMLImport; + + bool m_bInsertMode : 1; + bool m_bStylesOnlyMode : 1; + bool m_bBlockMode : 1; + bool m_bProgress : 1; + bool m_bOrganizerMode : 1; + bool m_bBodyContentStarted : 1; + + // #107848# + // One more flag to remember if we are inside a deleted redline section + bool m_bInsideDeleteContext : 1; + + typedef ::std::pair< ::rtl::OUString, ::rtl::OUString> field_name_type_t; + typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > field_param_t; + typedef ::std::vector< field_param_t > field_params_t; + typedef ::std::pair< field_name_type_t, field_params_t > field_stack_item_t; + typedef ::std::stack< field_stack_item_t > field_stack_t; + + field_stack_t m_FieldStack; + + ::rtl::OUString m_sCellParaStyleDefault; + + Impl( uno::Reference<frame::XModel> const& rModel, + SvXMLImport & rImport, + bool const bInsertMode, bool const bStylesOnlyMode, + bool const bProgress, bool const bBlockMode, + bool const bOrganizerMode) + : m_pTextElemTokenMap( 0 ) + , m_pTextPElemTokenMap( 0 ) + , m_pTextPAttrTokenMap( 0 ) + , m_pTextFieldAttrTokenMap( 0 ) + , m_pTextNumberedParagraphAttrTokenMap( 0 ) + , m_pTextListBlockAttrTokenMap( 0 ) + , m_pTextListBlockElemTokenMap( 0 ) + , m_pTextFrameAttrTokenMap( 0 ) + , m_pTextContourAttrTokenMap( 0 ) + , m_pTextHyperlinkAttrTokenMap( 0 ) + , m_pTextMasterPageElemTokenMap( 0 ) + , m_pPrevFrmNames( 0 ) + , m_pNextFrmNames( 0 ) + // --> OD 2008-04-25 #refactorlists# + , m_pTextListsHelper( new XMLTextListsHelper() ) + // <-- + , m_pRenameMap( 0 ) + // --> OD 2006-10-12 #i69629# + , m_pOutlineStylesCandidates( 0 ) + // <-- + , m_xServiceFactory( rModel, UNO_QUERY ) + , m_rSvXMLImport( rImport ) + , m_bInsertMode( bInsertMode ) + , m_bStylesOnlyMode( bStylesOnlyMode ) + , m_bBlockMode( bBlockMode ) + , m_bProgress( bProgress ) + , m_bOrganizerMode( bOrganizerMode ) + , m_bBodyContentStarted( true ) + // #107848# Initialize inside_deleted_section flag correctly + , m_bInsideDeleteContext( false ) + { + } + + void InitOutlineStylesCandidates() + { + if (!m_pOutlineStylesCandidates) + { + size_t const size(m_xChapterNumbering->getCount()); + m_pOutlineStylesCandidates.reset( + new ::std::vector< ::rtl::OUString >[size] ); + } + } + +}; + + +uno::Reference< text::XText > & XMLTextImportHelper::GetText() +{ + return m_pImpl->m_xText; +} + +uno::Reference< text::XTextCursor > & XMLTextImportHelper::GetCursor() +{ + return m_pImpl->m_xCursor; +} + +uno::Reference< text::XTextRange > & XMLTextImportHelper::GetCursorAsRange() +{ + return m_pImpl->m_xCursorAsRange; +} + +bool XMLTextImportHelper::IsInsertMode() const +{ + return m_pImpl->m_bInsertMode; +} + +bool XMLTextImportHelper::IsStylesOnlyMode() const +{ + return m_pImpl->m_bStylesOnlyMode; +} + +bool XMLTextImportHelper::IsBlockMode() const +{ + return m_pImpl->m_bBlockMode; +} + +bool XMLTextImportHelper::IsOrganizerMode() const +{ + return m_pImpl->m_bOrganizerMode; +} + +bool XMLTextImportHelper::IsProgress() const +{ + return m_pImpl->m_bProgress; +} + +XMLSectionList_Impl & XMLTextImportHelper::GetSectionList() +{ + return m_pImpl->m_SectionList; +} + +uno::Reference<container::XNameContainer> const& +XMLTextImportHelper::GetParaStyles() const +{ + return m_pImpl->m_xParaStyles; +} + +uno::Reference<container::XNameContainer> const& +XMLTextImportHelper::GetTextStyles() const +{ + return m_pImpl->m_xTextStyles; +} + +uno::Reference<container::XNameContainer> const& +XMLTextImportHelper::GetNumberingStyles() const +{ + return m_pImpl->m_xNumStyles; +} + +uno::Reference<container::XNameContainer> const& +XMLTextImportHelper::GetFrameStyles() const +{ + return m_pImpl->m_xFrameStyles; +} + +uno::Reference<container::XNameContainer> const& +XMLTextImportHelper::GetPageStyles() const +{ + return m_pImpl->m_xPageStyles; +} + +uno::Reference<container::XIndexReplace> const& +XMLTextImportHelper::GetChapterNumbering() const +{ + return m_pImpl->m_xChapterNumbering; +} + +UniReference< SvXMLImportPropertyMapper > const& +XMLTextImportHelper::GetParaImportPropertySetMapper() const +{ + return m_pImpl->m_xParaImpPrMap; +} + +UniReference< SvXMLImportPropertyMapper > const& +XMLTextImportHelper::GetTextImportPropertySetMapper() const +{ + return m_pImpl->m_xTextImpPrMap; +} + +UniReference< SvXMLImportPropertyMapper > const& +XMLTextImportHelper::GetFrameImportPropertySetMapper() const +{ + return m_pImpl->m_xFrameImpPrMap; +} + +UniReference< SvXMLImportPropertyMapper > const& +XMLTextImportHelper::GetSectionImportPropertySetMapper() const +{ + return m_pImpl->m_xSectionImpPrMap; +} + +UniReference< SvXMLImportPropertyMapper > const& +XMLTextImportHelper::GetRubyImportPropertySetMapper() const +{ + return m_pImpl->m_xRubyImpPrMap; +} + +void XMLTextImportHelper::SetInsideDeleteContext(bool const bNew) +{ + m_pImpl->m_bInsideDeleteContext = bNew; +} + +bool XMLTextImportHelper::IsInsideDeleteContext() const +{ + return m_pImpl->m_bInsideDeleteContext; +} + +SvXMLImport & XMLTextImportHelper::GetXMLImport() +{ + return m_pImpl->m_rSvXMLImport; +} + +XMLTextListsHelper & XMLTextImportHelper::GetTextListHelper() +{ + return *m_pImpl->m_pTextListsHelper; +} + +const SvXMLTokenMap& XMLTextImportHelper::GetTextElemTokenMap() +{ + if (!m_pImpl->m_pTextElemTokenMap.get()) + { + m_pImpl->m_pTextElemTokenMap.reset( + new SvXMLTokenMap( aTextElemTokenMap )); + } + return *m_pImpl->m_pTextElemTokenMap; +} + +const SvXMLTokenMap& XMLTextImportHelper::GetTextPElemTokenMap() +{ + if (!m_pImpl->m_pTextPElemTokenMap.get()) + { + m_pImpl->m_pTextPElemTokenMap.reset( + new SvXMLTokenMap( aTextPElemTokenMap )); + } + return *m_pImpl->m_pTextPElemTokenMap; +} + +const SvXMLTokenMap& XMLTextImportHelper::GetTextPAttrTokenMap() +{ + if (!m_pImpl->m_pTextPAttrTokenMap.get()) + { + m_pImpl->m_pTextPAttrTokenMap.reset( + new SvXMLTokenMap( aTextPAttrTokenMap )); + } + return *m_pImpl->m_pTextPAttrTokenMap; +} + +const SvXMLTokenMap& XMLTextImportHelper::GetTextFrameAttrTokenMap() +{ + if (!m_pImpl->m_pTextFrameAttrTokenMap.get()) + { + m_pImpl->m_pTextFrameAttrTokenMap.reset( + new SvXMLTokenMap( aTextFrameAttrTokenMap )); + } + return *m_pImpl->m_pTextFrameAttrTokenMap; +} + +const SvXMLTokenMap& XMLTextImportHelper::GetTextContourAttrTokenMap() +{ + if (!m_pImpl->m_pTextContourAttrTokenMap.get()) + { + m_pImpl->m_pTextContourAttrTokenMap.reset( + new SvXMLTokenMap( aTextContourAttrTokenMap )); + } + return *m_pImpl->m_pTextContourAttrTokenMap; +} + +const SvXMLTokenMap& XMLTextImportHelper::GetTextHyperlinkAttrTokenMap() +{ + if (!m_pImpl->m_pTextHyperlinkAttrTokenMap.get()) + { + m_pImpl->m_pTextHyperlinkAttrTokenMap.reset( + new SvXMLTokenMap( aTextHyperlinkAttrTokenMap )); + } + return *m_pImpl->m_pTextHyperlinkAttrTokenMap; +} + +const SvXMLTokenMap& XMLTextImportHelper::GetTextMasterPageElemTokenMap() +{ + if (!m_pImpl->m_pTextMasterPageElemTokenMap.get()) + { + m_pImpl->m_pTextMasterPageElemTokenMap.reset( + new SvXMLTokenMap( aTextMasterPageElemTokenMap )); + } + return *m_pImpl->m_pTextMasterPageElemTokenMap; +} + +const SvXMLTokenMap& XMLTextImportHelper::GetTextFieldAttrTokenMap() +{ + if (!m_pImpl->m_pTextFieldAttrTokenMap.get()) + { + m_pImpl->m_pTextFieldAttrTokenMap.reset( + new SvXMLTokenMap( aTextFieldAttrTokenMap )); + } + return *m_pImpl->m_pTextFieldAttrTokenMap; +} + namespace { @@ -513,111 +950,48 @@ namespace } XMLTextImportHelper::XMLTextImportHelper( - const Reference < XModel >& rModel, + uno::Reference<frame::XModel> const& rModel, SvXMLImport& rImport, - sal_Bool bInsertM, sal_Bool bStylesOnlyM, - sal_Bool bPrg, - sal_Bool bBlockM, - sal_Bool bOrganizerM ) -: pTextElemTokenMap( 0 ) -, pTextPElemTokenMap( 0 ) -, pTextPAttrTokenMap( 0 ) -, pTextFieldAttrTokenMap( 0 ) -, pTextNumberedParagraphAttrTokenMap( 0 ) -, pTextListBlockAttrTokenMap( 0 ) -, pTextListBlockElemTokenMap( 0 ) -, pTextFrameAttrTokenMap( 0 ) -, pTextContourAttrTokenMap( 0 ) -, pTextHyperlinkAttrTokenMap( 0 ) -, pTextMasterPageElemTokenMap( 0 ) -, pPrevFrmNames( 0 ) -, pNextFrmNames( 0 ) - -// --> OD 2008-04-25 #refactorlists# -, mpTextListsHelper( new XMLTextListsHelper() ) -// <-- - -, pRenameMap( 0 ) -// --> OD 2006-10-12 #i69629# -, mpOutlineStylesCandidates( 0 ) -// <-- - -, pFootnoteBackpatcher( NULL ) -, pSequenceIdBackpatcher( NULL ) -, pSequenceNameBackpatcher( NULL ) - -, xServiceFactory( rModel, UNO_QUERY ) - -, rSvXMLImport( rImport ) - -, bInsertMode( bInsertM ) -, bStylesOnlyMode( bStylesOnlyM ) -, bBlockMode( bBlockM ) -, bProgress( bPrg ) -, bOrganizerMode( bOrganizerM ) -, bBodyContentStarted( sal_True ) - - // #107848# - // Initialize inside_deleted_section flag correctly -, bInsideDeleteContext( sal_False ) - -, sParaStyleName(RTL_CONSTASCII_USTRINGPARAM("ParaStyleName")) -, sCharStyleName(RTL_CONSTASCII_USTRINGPARAM("CharStyleName")) -, sHeadingStyleName(RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName")) -, sNumberingLevel(RTL_CONSTASCII_USTRINGPARAM("NumberingLevel")) -, sNumberingStartValue(RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue")) -, sNumberingRules(RTL_CONSTASCII_USTRINGPARAM("NumberingRules")) -, sParaIsNumberingRestart(RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart")) -, sNumberingIsNumber(RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber")) -, sCurrentPresentation(RTL_CONSTASCII_USTRINGPARAM("CurrentPresentation")) -, sSequenceNumber(RTL_CONSTASCII_USTRINGPARAM("SequenceNumber")) -, sSourceName(RTL_CONSTASCII_USTRINGPARAM("SourceName")) -, sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")) -, sChainPrevName(RTL_CONSTASCII_USTRINGPARAM("ChainPrevName")) -, 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")) -, sTextFrame(RTL_CONSTASCII_USTRINGPARAM("TextFrame")) -, sPageDescName(RTL_CONSTASCII_USTRINGPARAM("PageDescName")) -, sServerMap(RTL_CONSTASCII_USTRINGPARAM("ServerMap")) -, sHyperLinkEvents(RTL_CONSTASCII_USTRINGPARAM("HyperLinkEvents")) -, sContent(RTL_CONSTASCII_USTRINGPARAM("Content")) -, sServiceCombinedCharacters(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField.CombinedCharacters")) -, sNumberingStyleName(RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName")) -// --> OD 2008-04-23 #refactorlists# -, sPropNameDefaultListId(RTL_CONSTASCII_USTRINGPARAM("DefaultListId")) -, sPropNameListId(RTL_CONSTASCII_USTRINGPARAM("ListId")) -, sOutlineLevel( RTL_CONSTASCII_USTRINGPARAM("OutlineLevel")) //#outline level,add by zhaojianwei -// <-- + bool const bInsertMode, bool const bStylesOnlyMode, + bool const bProgress, bool const bBlockMode, + bool const bOrganizerMode) + : m_pImpl( new Impl(rModel, rImport, bInsertMode, bStylesOnlyMode, + bProgress, bBlockMode, bOrganizerMode) ) + , m_pBackpatcherImpl( MakeBackpatcherImpl() ) { + static ::rtl::OUString s_PropNameDefaultListId( + RTL_CONSTASCII_USTRINGPARAM("DefaultListId")); + Reference< XChapterNumberingSupplier > xCNSupplier( rModel, UNO_QUERY ); if( xCNSupplier.is() ) { - xChapterNumbering = xCNSupplier->getChapterNumberingRules(); + m_pImpl->m_xChapterNumbering = xCNSupplier->getChapterNumberingRules(); // --> OD 2008-05-15 #refactorlists# - if ( xChapterNumbering.is() ) + if (m_pImpl->m_xChapterNumbering.is()) { - Reference< XPropertySet > xNumRuleProps( xChapterNumbering, UNO_QUERY ); + Reference< XPropertySet > const xNumRuleProps( + m_pImpl->m_xChapterNumbering, UNO_QUERY); if ( xNumRuleProps.is() ) { Reference< XPropertySetInfo > xNumRulePropSetInfo( xNumRuleProps->getPropertySetInfo()); - if ( xNumRulePropSetInfo.is() && - xNumRulePropSetInfo->hasPropertyByName( sPropNameDefaultListId) ) + if (xNumRulePropSetInfo.is() && + xNumRulePropSetInfo->hasPropertyByName( + s_PropNameDefaultListId)) { ::rtl::OUString sListId; - xNumRuleProps->getPropertyValue( sPropNameDefaultListId ) >>= sListId; + xNumRuleProps->getPropertyValue(s_PropNameDefaultListId) + >>= sListId; DBG_ASSERT( sListId.getLength() != 0, "no default list id found at chapter numbering rules instance. Serious defect -> please inform OD." ); if ( sListId.getLength() ) { - Reference< XNamed > xChapterNumNamed( xChapterNumbering, UNO_QUERY ); + Reference< XNamed > const xChapterNumNamed( + m_pImpl->m_xChapterNumbering, UNO_QUERY); if ( xChapterNumNamed.is() ) { - mpTextListsHelper->KeepListAsProcessed( + m_pImpl->m_pTextListsHelper->KeepListAsProcessed( sListId, xChapterNumNamed->getName(), ::rtl::OUString() ); @@ -639,72 +1013,81 @@ XMLTextImportHelper::XMLTextImportHelper( const OUString aParaStyles(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles")); if( xFamilies->hasByName( aParaStyles ) ) { - xParaStyles.set(xFamilies->getByName( aParaStyles ), UNO_QUERY); + m_pImpl->m_xParaStyles.set(xFamilies->getByName(aParaStyles), + UNO_QUERY); } const OUString aCharStyles(RTL_CONSTASCII_USTRINGPARAM("CharacterStyles")); if( xFamilies->hasByName( aCharStyles ) ) { - xTextStyles.set(xFamilies->getByName( aCharStyles ), UNO_QUERY); + m_pImpl->m_xTextStyles.set(xFamilies->getByName(aCharStyles), + UNO_QUERY); } const OUString aNumStyles(RTL_CONSTASCII_USTRINGPARAM("NumberingStyles")); if( xFamilies->hasByName( aNumStyles ) ) { - xNumStyles.set(xFamilies->getByName( aNumStyles ), UNO_QUERY); + m_pImpl->m_xNumStyles.set(xFamilies->getByName(aNumStyles), + UNO_QUERY); } const OUString aFrameStyles(RTL_CONSTASCII_USTRINGPARAM("FrameStyles")); if( xFamilies->hasByName( aFrameStyles ) ) { - xFrameStyles.set(xFamilies->getByName( aFrameStyles ), UNO_QUERY); + m_pImpl->m_xFrameStyles.set(xFamilies->getByName(aFrameStyles), + UNO_QUERY); } const OUString aPageStyles(RTL_CONSTASCII_USTRINGPARAM("PageStyles")); if( xFamilies->hasByName( aPageStyles ) ) { - xPageStyles.set(xFamilies->getByName( aPageStyles ), UNO_QUERY); + m_pImpl->m_xPageStyles.set(xFamilies->getByName(aPageStyles), + UNO_QUERY); } } Reference < XTextFramesSupplier > xTFS( rModel, UNO_QUERY ); if( xTFS.is() ) - xTextFrames.set(xTFS->getTextFrames()); + { + m_pImpl->m_xTextFrames.set(xTFS->getTextFrames()); + } Reference < XTextGraphicObjectsSupplier > xTGOS( rModel, UNO_QUERY ); if( xTGOS.is() ) - xGraphics.set(xTGOS->getGraphicObjects()); + { + m_pImpl->m_xGraphics.set(xTGOS->getGraphicObjects()); + } Reference < XTextEmbeddedObjectsSupplier > xTEOS( rModel, UNO_QUERY ); if( xTEOS.is() ) - xObjects.set(xTEOS->getEmbeddedObjects()); + { + m_pImpl->m_xObjects.set(xTEOS->getEmbeddedObjects()); + } XMLPropertySetMapper *pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_PARA ); - xParaImpPrMap = new XMLTextImportPropertyMapper( pPropMapper, rImport ); + m_pImpl->m_xParaImpPrMap = + new XMLTextImportPropertyMapper( pPropMapper, rImport ); pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_TEXT ); - xTextImpPrMap = new XMLTextImportPropertyMapper( pPropMapper, rImport ); + m_pImpl->m_xTextImpPrMap = + new XMLTextImportPropertyMapper( pPropMapper, rImport ); pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_FRAME ); - xFrameImpPrMap = new XMLTextImportPropertyMapper( pPropMapper, rImport ); + m_pImpl->m_xFrameImpPrMap = + new XMLTextImportPropertyMapper( pPropMapper, rImport ); pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_SECTION ); - xSectionImpPrMap = new XMLTextImportPropertyMapper( pPropMapper, rImport ); + m_pImpl->m_xSectionImpPrMap = + new XMLTextImportPropertyMapper( pPropMapper, rImport ); pPropMapper = new XMLTextPropertySetMapper( TEXT_PROP_MAP_RUBY ); - xRubyImpPrMap = new SvXMLImportPropertyMapper( pPropMapper, rImport ); + m_pImpl->m_xRubyImpPrMap = + new SvXMLImportPropertyMapper( pPropMapper, rImport ); } XMLTextImportHelper::~XMLTextImportHelper() { - // --> OD 2006-10-12 #i69629# - delete [] mpOutlineStylesCandidates; - // <-- - - aBookmarkVector.clear(); - - _FinitBackpatcher(); } SvXMLImportPropertyMapper *XMLTextImportHelper::CreateShapeExtPropMapper(SvXMLImport& rImport) @@ -771,75 +1154,46 @@ SvXMLImportPropertyMapper* void XMLTextImportHelper::SetCursor( const Reference < XTextCursor > & rCursor ) { - xCursor.set(rCursor); - xText.set(rCursor->getText()); - xCursorAsRange.set( rCursor, UNO_QUERY ); + m_pImpl->m_xCursor.set(rCursor); + m_pImpl->m_xText.set(rCursor->getText()); + m_pImpl->m_xCursorAsRange.set( rCursor, UNO_QUERY ); } void XMLTextImportHelper::ResetCursor() { - xCursor.set(0); - xText.set(0); - xCursorAsRange.set(0); + m_pImpl->m_xCursor.set(0); + m_pImpl->m_xText.set(0); + m_pImpl->m_xCursorAsRange.set(0); } -SvXMLTokenMap *XMLTextImportHelper::_GetTextElemTokenMap() -{ - return new SvXMLTokenMap( aTextElemTokenMap ); -} - -SvXMLTokenMap *XMLTextImportHelper::_GetTextPElemTokenMap() -{ - return new SvXMLTokenMap( aTextPElemTokenMap ); -} - -SvXMLTokenMap *XMLTextImportHelper::_GetTextPAttrTokenMap() -{ - return new SvXMLTokenMap( aTextPAttrTokenMap ); -} - -SvXMLTokenMap *XMLTextImportHelper::_GetTextFrameAttrTokenMap() -{ - return new SvXMLTokenMap( aTextFrameAttrTokenMap ); -} - -SvXMLTokenMap *XMLTextImportHelper::_GetTextContourAttrTokenMap() -{ - return new SvXMLTokenMap( aTextContourAttrTokenMap ); -} - - -SvXMLTokenMap *XMLTextImportHelper::_GetTextHyperlinkAttrTokenMap() -{ - return new SvXMLTokenMap( aTextHyperlinkAttrTokenMap ); -} - -SvXMLTokenMap *XMLTextImportHelper::_GetTextMasterPageElemTokenMap() -{ - return new SvXMLTokenMap( aTextMasterPageElemTokenMap ); -} sal_Bool XMLTextImportHelper::HasFrameByName( const OUString& rName ) const { - return ( xTextFrames.is() && xTextFrames->hasByName( rName ) ) || - ( xGraphics.is() && xGraphics->hasByName( rName ) ) || - ( xObjects.is() && xObjects->hasByName( rName ) ); + return (m_pImpl->m_xTextFrames.is() && + m_pImpl->m_xTextFrames->hasByName(rName)) + || (m_pImpl->m_xGraphics.is() && + m_pImpl->m_xGraphics->hasByName(rName)) + || (m_pImpl->m_xObjects.is() && + m_pImpl->m_xObjects->hasByName(rName)); } void XMLTextImportHelper::InsertString( const OUString& rChars ) { - DBG_ASSERT( xText.is(), "no text" ); - DBG_ASSERT( xCursorAsRange.is(), "no range" ); - if( xText.is() ) - xText->insertString( xCursorAsRange, rChars, sal_False ); + DBG_ASSERT(m_pImpl->m_xText.is(), "no text"); + DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range"); + if (m_pImpl->m_xText.is()) + { + m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange, + rChars, sal_False); + } } void XMLTextImportHelper::InsertString( const OUString& rChars, sal_Bool& rIgnoreLeadingSpace ) { - DBG_ASSERT( xText.is(), "no text" ); - DBG_ASSERT( xCursorAsRange.is(), "no range" ); - if( xText.is() ) + DBG_ASSERT(m_pImpl->m_xText.is(), "no text"); + DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range"); + if (m_pImpl->m_xText.is()) { sal_Int32 nLen = rChars.getLength(); OUStringBuffer sChars( nLen ); @@ -863,35 +1217,43 @@ void XMLTextImportHelper::InsertString( const OUString& rChars, break; } } - xText->insertString( xCursorAsRange, sChars.makeStringAndClear(), - sal_False ); + m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange, + sChars.makeStringAndClear(), sal_False); } } + void XMLTextImportHelper::InsertControlCharacter( sal_Int16 nControl ) { - DBG_ASSERT( xText.is(), "no text" ); - DBG_ASSERT( xCursorAsRange.is(), "no range" ); - if( xText.is() ) - xText->insertControlCharacter( xCursorAsRange, nControl, sal_False ); + DBG_ASSERT(m_pImpl->m_xText.is(), "no text"); + DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range"); + if (m_pImpl->m_xText.is()) + { + m_pImpl->m_xText->insertControlCharacter( + m_pImpl->m_xCursorAsRange, nControl, sal_False); + } } void XMLTextImportHelper::InsertTextContent( Reference < XTextContent > & xContent ) { - DBG_ASSERT( xText.is(), "no text" ); - DBG_ASSERT( xCursorAsRange.is(), "no range" ); - if( xText.is() ) - xText->insertTextContent( xCursorAsRange, xContent, sal_False ); + DBG_ASSERT(m_pImpl->m_xText.is(), "no text"); + DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range"); + if (m_pImpl->m_xText.is()) + { + m_pImpl->m_xText->insertTextContent( + m_pImpl->m_xCursorAsRange, xContent, sal_False); + } } void XMLTextImportHelper::DeleteParagraph() { - DBG_ASSERT( xText.is(), "no text" ); - DBG_ASSERT( xCursor.is(), "no cursor" ); - DBG_ASSERT( xCursorAsRange.is(), "no range" ); + DBG_ASSERT(m_pImpl->m_xText.is(), "no text"); + DBG_ASSERT(m_pImpl->m_xCursor.is(), "no cursor"); + DBG_ASSERT(m_pImpl->m_xCursorAsRange.is(), "no range"); sal_Bool bDelete = sal_True; - Reference < XEnumerationAccess > xEnumAccess( xCursor, UNO_QUERY ); + Reference < XEnumerationAccess > const xEnumAccess( + m_pImpl->m_xCursor, UNO_QUERY); if( xEnumAccess.is() ) { Reference < XEnumeration > xEnum(xEnumAccess->createEnumeration()); @@ -909,10 +1271,11 @@ void XMLTextImportHelper::DeleteParagraph() } if( bDelete ) { - if( xCursor->goLeft( 1, sal_True ) ) + if (m_pImpl->m_xCursor->goLeft( 1, sal_True )) { OUString sEmpty; - xText->insertString( xCursorAsRange, sEmpty, sal_True ); + m_pImpl->m_xText->insertString(m_pImpl->m_xCursorAsRange, + sEmpty, sal_True); } } } @@ -935,9 +1298,10 @@ OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars, XMLTextStyleContext *pStyle = 0; sal_uInt16 nFamily = bPara ? XML_STYLE_FAMILY_TEXT_PARAGRAPH : XML_STYLE_FAMILY_TEXT_TEXT; - if( rStyleName.getLength() && xAutoStyles.Is() ) + if (rStyleName.getLength() && m_pImpl->m_xAutoStyles.Is()) { - const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)-> + const SvXMLStyleContext* pTempStyle = + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)-> FindStyleChildContext( nFamily, rStyleName, sal_True ); pStyle = PTR_CAST( XMLTextStyleContext,pTempStyle); @@ -949,7 +1313,8 @@ OUString XMLTextImportHelper::ConvertStarFonts( const OUString& rChars, if( nCount ) { UniReference < SvXMLImportPropertyMapper > xImpPrMap = - ((SvXMLStylesContext *)&xAutoStyles)->GetImportPropertyMapper(nFamily); + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles) + ->GetImportPropertyMapper(nFamily); if( xImpPrMap.is() ) { UniReference<XMLPropertySetMapper> rPropMapper = @@ -1135,13 +1500,41 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( sal_Bool bSetListAttrs ) // <-- { + static ::rtl::OUString s_ParaStyleName( + RTL_CONSTASCII_USTRINGPARAM("ParaStyleName")); + static ::rtl::OUString s_CharStyleName( + RTL_CONSTASCII_USTRINGPARAM("CharStyleName")); + static ::rtl::OUString s_NumberingRules( + RTL_CONSTASCII_USTRINGPARAM("NumberingRules")); + static ::rtl::OUString s_NumberingIsNumber( + RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber")); + static ::rtl::OUString s_NumberingLevel( + RTL_CONSTASCII_USTRINGPARAM("NumberingLevel")); + static ::rtl::OUString s_ParaIsNumberingRestart( + RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart")); + static ::rtl::OUString s_NumberingStartValue( + RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue")); + static ::rtl::OUString s_PropNameListId( + RTL_CONSTASCII_USTRINGPARAM("ListId")); + static ::rtl::OUString s_PageDescName( + RTL_CONSTASCII_USTRINGPARAM("PageDescName")); + static ::rtl::OUString s_ServiceCombinedCharacters( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.text.TextField.CombinedCharacters")); + static ::rtl::OUString s_Content(RTL_CONSTASCII_USTRINGPARAM("Content")); + static ::rtl::OUString s_OutlineLevel( + RTL_CONSTASCII_USTRINGPARAM("OutlineLevel")); + static ::rtl::OUString s_NumberingStyleName( + RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName")); + const sal_uInt16 nFamily = bPara ? XML_STYLE_FAMILY_TEXT_PARAGRAPH : XML_STYLE_FAMILY_TEXT_TEXT; XMLTextStyleContext *pStyle = 0; OUString sStyleName( rStyleName ); - if( sStyleName.getLength() && xAutoStyles.Is() ) + if (sStyleName.getLength() && m_pImpl->m_xAutoStyles.Is()) { - const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)-> + const SvXMLStyleContext* pTempStyle = + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)-> FindStyleChildContext( nFamily, sStyleName, sal_True ); pStyle = PTR_CAST( XMLTextStyleContext,pTempStyle); } @@ -1156,9 +1549,10 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( if( sStyleName.getLength() ) { sStyleName = rImport.GetStyleDisplayName( nFamily, sStyleName ); - const String& rPropName = bPara ? sParaStyleName : sCharStyleName; - const Reference < XNameContainer > & rStyles = bPara ? xParaStyles - : xTextStyles; + const String& rPropName = (bPara) ? s_ParaStyleName : s_CharStyleName; + const Reference < XNameContainer > & rStyles = (bPara) + ? m_pImpl->m_xParaStyles + : m_pImpl->m_xTextStyles; if( rStyles.is() && xPropSetInfo->hasPropertyByName( rPropName ) && rStyles->hasByName( sStyleName ) ) @@ -1174,11 +1568,13 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( // is not inside a list and if it by default applies the outline style. bool bApplyOutlineLevelAsListLevel( false ); // --> OD 2007-08-17 #i80724# - if ( bSetListAttrs && bPara && xPropSetInfo->hasPropertyByName( sNumberingRules ) ) + if (bSetListAttrs && bPara + && xPropSetInfo->hasPropertyByName( s_NumberingRules)) // <-- { // Set numbering rules - Reference < XIndexReplace > xNumRules(xPropSet->getPropertyValue( sNumberingRules ), UNO_QUERY); + Reference< XIndexReplace > const xNumRules( + xPropSet->getPropertyValue(s_NumberingRules), UNO_QUERY); XMLTextListBlockContext * pListBlock(0); XMLTextListItemContext * pListItem(0); @@ -1214,7 +1610,8 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( } // --> OD 2008-08-15 #i92811# - sListId = mpTextListsHelper->GetListIdForListBlock( *pListBlock ); + sListId = m_pImpl->m_pTextListsHelper->GetListIdForListBlock( + *pListBlock); // <-- } else if (pNumberedParagraph) @@ -1268,7 +1665,8 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( // gracefully. try { - xPropSet->setPropertyValue( sNumberingRules, makeAny(xNewNumRules) ); + xPropSet->setPropertyValue( + s_NumberingRules, makeAny(xNewNumRules) ); } catch( Exception e ) { @@ -1279,37 +1677,37 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( } if (!bNumberingIsNumber && - xPropSetInfo->hasPropertyByName( sNumberingIsNumber ) ) + xPropSetInfo->hasPropertyByName(s_NumberingIsNumber)) { - xPropSet->setPropertyValue( sNumberingIsNumber, Any(sal_False) ); + xPropSet->setPropertyValue(s_NumberingIsNumber, Any(sal_False)); } - xPropSet->setPropertyValue( sNumberingLevel, Any(nLevel) ); + xPropSet->setPropertyValue( s_NumberingLevel, Any(nLevel) ); if( pListBlock && pListBlock->IsRestartNumbering() ) { // TODO: property missing - if( xPropSetInfo->hasPropertyByName( sParaIsNumberingRestart ) ) + if (xPropSetInfo->hasPropertyByName(s_ParaIsNumberingRestart)) { sal_Bool bTmp = sal_True; - xPropSet->setPropertyValue(sParaIsNumberingRestart, + xPropSet->setPropertyValue(s_ParaIsNumberingRestart, makeAny(bTmp) ); } pListBlock->ResetRestartNumbering(); } if ( 0 <= nStartValue && - xPropSetInfo->hasPropertyByName( sNumberingStartValue ) ) + xPropSetInfo->hasPropertyByName(s_NumberingStartValue)) { - xPropSet->setPropertyValue(sNumberingStartValue, + xPropSet->setPropertyValue(s_NumberingStartValue, makeAny(nStartValue)); } // --> OD 2008-04-23 #refactorlists# - if ( xPropSetInfo->hasPropertyByName( sPropNameListId ) ) + if (xPropSetInfo->hasPropertyByName(s_PropNameListId)) { if (sListId.getLength()) { - xPropSet->setPropertyValue( sPropNameListId, + xPropSet->setPropertyValue(s_PropNameListId, makeAny(sListId) ); } } @@ -1338,10 +1736,11 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( if ( ( bBuildIdFound && nUPD == 680 ) || !pStyle || !pStyle->IsListStyleSet() ) { - if ( xChapterNumbering.is() ) + if (m_pImpl->m_xChapterNumbering.is()) { Reference< XNamed > xNumNamed( xNumRules, UNO_QUERY ); - Reference< XNamed > xChapterNumNamed( xChapterNumbering, UNO_QUERY ); + Reference< XNamed > const xChapterNumNamed ( + m_pImpl->m_xChapterNumbering, UNO_QUERY); if ( xNumNamed.is() && xChapterNumNamed.is() && xNumNamed->getName() == xChapterNumNamed->getName() ) { @@ -1355,7 +1754,7 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( // <-- if ( bRemove ) { - xPropSet->setPropertyValue( sNumberingRules, Any() ); + xPropSet->setPropertyValue( s_NumberingRules, Any() ); } } // <-- @@ -1367,27 +1766,28 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( { pStyle->FillPropertySet( xPropSet ); if( bPara && pStyle->HasMasterPageName() && - xPropSetInfo->hasPropertyByName( sPageDescName ) ) + xPropSetInfo->hasPropertyByName(s_PageDescName)) { OUString sDisplayName( rImport.GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE, pStyle->GetMasterPageName()) ); if( !sDisplayName.getLength() || - (xPageStyles.is() && - xPageStyles->hasByName( sDisplayName )) ) + (m_pImpl->m_xPageStyles.is() && + m_pImpl->m_xPageStyles->hasByName( sDisplayName))) { - xPropSet->setPropertyValue( sPageDescName, makeAny(sDisplayName) ); + xPropSet->setPropertyValue(s_PageDescName, + makeAny(sDisplayName)); } } if( bPara && pStyle->GetDropCapStyleName().getLength() && - xTextStyles.is() ) + m_pImpl->m_xTextStyles.is()) { OUString sDisplayName( rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_TEXT, pStyle->GetDropCapStyleName()) ); - if( xTextStyles->hasByName( sDisplayName ) && + if (m_pImpl->m_xTextStyles->hasByName(sDisplayName) && xPropSetInfo->hasPropertyByName( sDisplayName ) ) { xPropSet->setPropertyValue( pStyle->sDropCapCharStyleName, makeAny(sDisplayName) ); @@ -1398,9 +1798,11 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( if (!bPara && pStyle->HasCombinedCharactersLetter()) { // insert combined characters text field - if( xServiceFactory.is() ) + if (m_pImpl->m_xServiceFactory.is()) { - Reference<XPropertySet> xTmp( xServiceFactory->createInstance(sServiceCombinedCharacters), UNO_QUERY ); + uno::Reference<beans::XPropertySet> const xTmp( + m_pImpl->m_xServiceFactory->createInstance( + s_ServiceCombinedCharacters), UNO_QUERY); if( xTmp.is() ) { // fix cursor if larger than possible for @@ -1413,17 +1815,17 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( } // set field value (the combined character string) - xTmp->setPropertyValue(sContent, makeAny(rCursor->getString())); + xTmp->setPropertyValue(s_Content, + makeAny(rCursor->getString())); // insert the field over it's original text Reference<XTextRange> xRange(rCursor, UNO_QUERY); Reference<XTextContent> xTextContent(xTmp, UNO_QUERY); - if (xText.is() && xRange.is()) + if (m_pImpl->m_xText.is() && xRange.is()) { // #i107225# the combined characters need to be inserted first // the selected text has to be removed afterwards - xText->insertTextContent( xRange->getStart(), xTextContent, - sal_True ); + xText->insertTextContent( xRange->getStart(), xTextContent, sal_True ); if( xRange->getString().getLength() ) { @@ -1465,10 +1867,12 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( { // --> OD 2009-08-18 #i103817# sal_Int16 nCurrentOutlineLevelInheritedFromParagraphStyle = 0; - const bool bHasOutlineLevelProp( xPropSetInfo->hasPropertyByName( sOutlineLevel ) ); + const bool bHasOutlineLevelProp( + xPropSetInfo->hasPropertyByName(s_OutlineLevel)); if ( bHasOutlineLevelProp ) { - xPropSet->getPropertyValue( sOutlineLevel ) >>= nCurrentOutlineLevelInheritedFromParagraphStyle; + xPropSet->getPropertyValue(s_OutlineLevel) + >>= nCurrentOutlineLevelInheritedFromParagraphStyle; } // <-- //if ( bPara && nOutlineLevel != -1 ) //#outline level,removed by zhaojianwei @@ -1481,7 +1885,7 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( // attribute outline level, the paragraph attribute value is left unset if ( nCurrentOutlineLevelInheritedFromParagraphStyle != nOutlineLevel ) { - xPropSet->setPropertyValue( sOutlineLevel, + xPropSet->setPropertyValue( s_OutlineLevel, makeAny( static_cast<sal_Int16>(nOutlineLevel) ) ); } }//<-end,zhaojianwei @@ -1490,11 +1894,11 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( if ( bApplyOutlineLevelAsListLevel ) { sal_Int16 nNumLevel = -1; - xPropSet->getPropertyValue( sNumberingLevel ) >>= nNumLevel; + xPropSet->getPropertyValue( s_NumberingLevel ) >>= nNumLevel; if ( nNumLevel == -1 || nNumLevel != (nOutlineLevel - 1) ) { - xPropSet->setPropertyValue( sNumberingLevel, + xPropSet->setPropertyValue( s_NumberingLevel, makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) ); } } @@ -1507,7 +1911,7 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( // a candidate for an assignment to the list level of the outline // style, if it has no direct list style property and (if exists) the // automatic paragraph style has also no direct list style set. - if( xParaStyles->hasByName( sStyleName ) ) + if (m_pImpl->m_xParaStyles->hasByName(sStyleName)) { bool bOutlineStyleCandidate( false ); @@ -1559,19 +1963,19 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( // Assure that heading applies the outline style if ( ( !pStyle || !pStyle->IsListStyleSet() ) && !bOutlineStyleCandidate && - xChapterNumbering.is() ) + m_pImpl->m_xChapterNumbering.is()) { OUString sEmptyStr; if ( !lcl_HasListStyle( sStyleName, - xParaStyles, GetXMLImport(), - sNumberingStyleName, + m_pImpl->m_xParaStyles, GetXMLImport(), + s_NumberingStyleName, sEmptyStr ) ) { // heading not in a list --> apply outline style - xPropSet->setPropertyValue( sNumberingRules, - makeAny(xChapterNumbering) ); - xPropSet->setPropertyValue( sNumberingLevel, - makeAny( static_cast<sal_Int8>(nOutlineLevel - 1) ) ); + xPropSet->setPropertyValue( s_NumberingRules, + makeAny(m_pImpl->m_xChapterNumbering) ); + xPropSet->setPropertyValue( s_NumberingLevel, + makeAny(static_cast<sal_Int8>(nOutlineLevel - 1))); } } // <-- @@ -1585,7 +1989,8 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( if ( nCurrentOutlineLevelInheritedFromParagraphStyle != 0 ) { sal_Int16 nZero = 0; - xPropSet->setPropertyValue( sOutlineLevel, makeAny( static_cast<sal_Int16>(nZero) ) ); + xPropSet->setPropertyValue(s_OutlineLevel, + makeAny( static_cast<sal_Int16>(nZero) )); } }//<-end,zhaojianwei } @@ -1597,38 +2002,39 @@ OUString XMLTextImportHelper::SetStyleAndAttrs( void XMLTextImportHelper::FindOutlineStyleName( ::rtl::OUString& rStyleName, sal_Int8 nOutlineLevel ) { + static ::rtl::OUString s_HeadingStyleName( + RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName")); + // style name empty? if( rStyleName.getLength() == 0 ) { // Empty? Then we need o do stuff. Let's do error checking first. - if( xChapterNumbering.is() && + if (m_pImpl->m_xChapterNumbering.is() && ( nOutlineLevel > 0 ) && - ( nOutlineLevel <= xChapterNumbering->getCount() ) ) + (nOutlineLevel <= m_pImpl->m_xChapterNumbering->getCount())) { nOutlineLevel--; // for the remainder, the level's are 0-based // empty style name: look-up previously used name // if we don't have a previously used name, we'll use the default - if ( mpOutlineStylesCandidates == NULL ) - { - mpOutlineStylesCandidates = new ::std::vector<OUString>[xChapterNumbering->getCount()]; - } - - if ( mpOutlineStylesCandidates[nOutlineLevel].empty() ) + m_pImpl->InitOutlineStylesCandidates(); + if (m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel].empty()) { // no other name used previously? Then use default // iterate over property value sequence to find the style name Sequence<PropertyValue> aProperties; - xChapterNumbering->getByIndex( nOutlineLevel ) >>= aProperties; + m_pImpl->m_xChapterNumbering->getByIndex( nOutlineLevel ) + >>= aProperties; for( sal_Int32 i = 0; i < aProperties.getLength(); i++ ) { - if( aProperties[i].Name == sHeadingStyleName ) + if (aProperties[i].Name == s_HeadingStyleName) { rtl::OUString aOutlineStyle; aProperties[i].Value >>= aOutlineStyle; - mpOutlineStylesCandidates[nOutlineLevel].push_back( aOutlineStyle ); + m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel] + .push_back( aOutlineStyle ); break; // early out, if we found it!. } } @@ -1637,7 +2043,8 @@ void XMLTextImportHelper::FindOutlineStyleName( ::rtl::OUString& rStyleName, // finally, we'll use the previously used style name for this // format (or the default we've just put into that style) // --> OD 2006-11-06 #i71249# - take last added one - rStyleName = mpOutlineStylesCandidates[nOutlineLevel].back(); + rStyleName = + m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel].back(); // <-- } // else: nothing we can do, so we'll leave it empty @@ -1648,23 +2055,27 @@ void XMLTextImportHelper::FindOutlineStyleName( ::rtl::OUString& rStyleName, void XMLTextImportHelper::AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel, const OUString& rStyleName ) { - if ( rStyleName.getLength() && - xChapterNumbering.is() && - nOutlineLevel > 0 && nOutlineLevel <= xChapterNumbering->getCount() ) + if (rStyleName.getLength() + && m_pImpl->m_xChapterNumbering.is() + && (nOutlineLevel > 0) + && (nOutlineLevel <= m_pImpl->m_xChapterNumbering->getCount())) { - if( !mpOutlineStylesCandidates ) - { - mpOutlineStylesCandidates = new ::std::vector<OUString>[xChapterNumbering->getCount()]; - } - mpOutlineStylesCandidates[nOutlineLevel-1].push_back( rStyleName ); + m_pImpl->InitOutlineStylesCandidates(); + m_pImpl->m_pOutlineStylesCandidates[nOutlineLevel-1].push_back( + rStyleName); } } void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels ) { - if ( ( mpOutlineStylesCandidates != NULL || bSetEmptyLevels ) && - xChapterNumbering.is() && - !IsInsertMode() ) + static ::rtl::OUString s_NumberingStyleName( + RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName")); + static ::rtl::OUString s_HeadingStyleName( + RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName")); + + if ((m_pImpl->m_pOutlineStylesCandidates != NULL || bSetEmptyLevels) && + m_pImpl->m_xChapterNumbering.is() && + !IsInsertMode()) { bool bChooseLastOne( false ); { @@ -1687,12 +2098,13 @@ void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels ) OUString sOutlineStyleName; { - Reference<XPropertySet> xChapterNumRule( xChapterNumbering, UNO_QUERY ); + Reference<XPropertySet> xChapterNumRule( + m_pImpl->m_xChapterNumbering, UNO_QUERY); const OUString sName(RTL_CONSTASCII_USTRINGPARAM("Name")); xChapterNumRule->getPropertyValue(sName) >>= sOutlineStyleName; } - const sal_Int32 nCount = xChapterNumbering->getCount(); + const sal_Int32 nCount = m_pImpl->m_xChapterNumbering->getCount(); // --> OD 2009-11-13 #i106218# // First collect all paragraph styles choosen for assignment to each // list level of the outline style, then perform the intrinsic assignment. @@ -1704,28 +2116,33 @@ void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels ) for( sal_Int32 i=0; i < nCount; ++i ) { if ( bSetEmptyLevels || - ( mpOutlineStylesCandidates && - !mpOutlineStylesCandidates[i].empty() ) ) + (m_pImpl->m_pOutlineStylesCandidates && + !m_pImpl->m_pOutlineStylesCandidates[i].empty())) { // determine, which candidate is one to be assigned to the list // level of the outline style - if ( mpOutlineStylesCandidates && - !mpOutlineStylesCandidates[i].empty() ) + if (m_pImpl->m_pOutlineStylesCandidates && + !m_pImpl->m_pOutlineStylesCandidates[i].empty()) { if ( bChooseLastOne ) { - sChosenStyles[i] = mpOutlineStylesCandidates[i].back(); + sChosenStyles[i] = + m_pImpl->m_pOutlineStylesCandidates[i].back(); } else { - for ( sal_uInt32 j = 0; j < mpOutlineStylesCandidates[i].size(); ++j ) + for (sal_uInt32 j = 0; + j < m_pImpl->m_pOutlineStylesCandidates[i].size(); + ++j) { - if ( !lcl_HasListStyle( mpOutlineStylesCandidates[i][j], - xParaStyles, GetXMLImport(), - sNumberingStyleName, - sOutlineStyleName ) ) + if (!lcl_HasListStyle( + m_pImpl->m_pOutlineStylesCandidates[i][j], + m_pImpl->m_xParaStyles, GetXMLImport(), + s_NumberingStyleName, + sOutlineStyleName)) { - sChosenStyles[i] = mpOutlineStylesCandidates[i][j]; + sChosenStyles[i] = + m_pImpl->m_pOutlineStylesCandidates[i][j]; break; } } @@ -1736,7 +2153,7 @@ void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels ) // --> OD 2009-11-13 #i106218# Sequence < PropertyValue > aProps( 1 ); PropertyValue *pProps = aProps.getArray(); - pProps->Name = sHeadingStyleName; + pProps->Name = s_HeadingStyleName; for ( sal_Int32 i = 0; i < nCount; ++i ) { // --> OD 2009-12-11 #i107610# @@ -1745,7 +2162,8 @@ void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels ) // <-- { pProps->Value <<= sChosenStyles[i]; - xChapterNumbering->replaceByIndex( i, makeAny( aProps ) ); + m_pImpl->m_xChapterNumbering->replaceByIndex(i, + makeAny( aProps )); } } // <-- @@ -1762,62 +2180,79 @@ void XMLTextImportHelper::SetHyperlink( const OUString& rVisitedStyleName, XMLEventsImportContext* pEvents) { + static ::rtl::OUString s_HyperLinkURL( + RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")); + static ::rtl::OUString s_HyperLinkName( + RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")); + static ::rtl::OUString s_HyperLinkTarget( + RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")); + static ::rtl::OUString s_UnvisitedCharStyleName( + RTL_CONSTASCII_USTRINGPARAM("UnvisitedCharStyleName")); + static ::rtl::OUString s_VisitedCharStyleName( + RTL_CONSTASCII_USTRINGPARAM("VisitedCharStyleName")); + static ::rtl::OUString s_HyperLinkEvents( + RTL_CONSTASCII_USTRINGPARAM("HyperLinkEvents")); + Reference < XPropertySet > xPropSet( rCursor, UNO_QUERY ); Reference < XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo()); - if( !xPropSetInfo.is() || !xPropSetInfo->hasPropertyByName(sHyperLinkURL) ) + if (!xPropSetInfo.is() || !xPropSetInfo->hasPropertyByName(s_HyperLinkURL)) return; - xPropSet->setPropertyValue( sHyperLinkURL, makeAny(rHRef) ); + xPropSet->setPropertyValue(s_HyperLinkURL, makeAny(rHRef)); - if( xPropSetInfo->hasPropertyByName( sHyperLinkName ) ) + if (xPropSetInfo->hasPropertyByName(s_HyperLinkName)) { - xPropSet->setPropertyValue( sHyperLinkName, makeAny(rName) ); + xPropSet->setPropertyValue(s_HyperLinkName, makeAny(rName)); } - if( xPropSetInfo->hasPropertyByName( sHyperLinkTarget ) ) + if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget)) { - xPropSet->setPropertyValue( sHyperLinkTarget, makeAny(rTargetFrameName) ); + xPropSet->setPropertyValue(s_HyperLinkTarget, + makeAny(rTargetFrameName)); } if ( (pEvents != NULL) && - xPropSetInfo->hasPropertyByName( sHyperLinkEvents )) + xPropSetInfo->hasPropertyByName(s_HyperLinkEvents)) { // The API treats events at hyperlinks differently from most // other properties: You have to set a name replace with the // events in it. The easiest way to to this is to 1) get // events, 2) set new ones, and 3) then put events back. - Reference<XNameReplace> xReplace(xPropSet->getPropertyValue( sHyperLinkEvents ), UNO_QUERY); + uno::Reference<XNameReplace> const xReplace( + xPropSet->getPropertyValue(s_HyperLinkEvents), UNO_QUERY); if (xReplace.is()) { // set events pEvents->SetEvents(xReplace); // put events - xPropSet->setPropertyValue( sHyperLinkEvents, makeAny(xReplace) ); + xPropSet->setPropertyValue(s_HyperLinkEvents, makeAny(xReplace)); } } - if( xTextStyles.is() ) + if (m_pImpl->m_xTextStyles.is()) { OUString sDisplayName( rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_TEXT, rStyleName ) ); if( sDisplayName.getLength() && - xPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) && - xTextStyles->hasByName( sDisplayName ) ) + xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) && + m_pImpl->m_xTextStyles->hasByName(sDisplayName)) { - xPropSet->setPropertyValue( sUnvisitedCharStyleName, makeAny(sDisplayName) ); + xPropSet->setPropertyValue(s_UnvisitedCharStyleName, + makeAny(sDisplayName)); } sDisplayName = rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_TEXT, rVisitedStyleName ); if( sDisplayName.getLength() && - xPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) && - xTextStyles->hasByName( sDisplayName ) ) + xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) && + m_pImpl->m_xTextStyles->hasByName(sDisplayName)) { - xPropSet->setPropertyValue( sVisitedCharStyleName, makeAny(sDisplayName) ); + xPropSet->setPropertyValue(s_VisitedCharStyleName, + makeAny(sDisplayName)); } } } @@ -1843,9 +2278,10 @@ void XMLTextImportHelper::SetRuby( // the ruby style (ruby-adjust) XMLPropStyleContext *pStyle = 0; - if( rStyleName.getLength() && xAutoStyles.Is() ) + if (rStyleName.getLength() && m_pImpl->m_xAutoStyles.Is()) { - const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)-> + const SvXMLStyleContext* pTempStyle = + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)-> FindStyleChildContext( XML_STYLE_FAMILY_TEXT_RUBY, rStyleName, sal_True ); pStyle = PTR_CAST(XMLPropStyleContext,pTempStyle); @@ -1855,14 +2291,14 @@ void XMLTextImportHelper::SetRuby( } // the ruby text character style - if( xTextStyles.is() ) + if (m_pImpl->m_xTextStyles.is()) { OUString sDisplayName( rImport.GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_TEXT, rTextStyleName ) ); if( (sDisplayName.getLength() > 0) && // xPropSetInfo->hasPropertyByName( sRubyCharStyleName ) && - xTextStyles->hasByName( sDisplayName ) ) + m_pImpl->m_xTextStyles->hasByName( sDisplayName )) { xPropSet->setPropertyValue(sRubyCharStyleName, makeAny(sDisplayName)); } @@ -1872,21 +2308,21 @@ void XMLTextImportHelper::SetRuby( void XMLTextImportHelper::SetAutoStyles( SvXMLStylesContext *pStyles ) { - xAutoStyles = pStyles; + m_pImpl->m_xAutoStyles = pStyles; } void XMLTextImportHelper::SetFontDecls( XMLFontStylesContext *pFontDecls ) { - xFontDecls = pFontDecls; - ((XMLTextImportPropertyMapper *)xParaImpPrMap.get()) + m_pImpl->m_xFontDecls = pFontDecls; + ((XMLTextImportPropertyMapper *)m_pImpl->m_xParaImpPrMap.get()) ->SetFontDecls( pFontDecls ); - ((XMLTextImportPropertyMapper *)xTextImpPrMap.get()) + ((XMLTextImportPropertyMapper *)m_pImpl->m_xTextImpPrMap.get()) ->SetFontDecls( pFontDecls ); } const XMLFontStylesContext *XMLTextImportHelper::GetFontDecls() const { - return (XMLFontStylesContext *)&xFontDecls; + return (XMLFontStylesContext *)&m_pImpl->m_xFontDecls; } sal_Bool XMLTextImportHelper::HasDrawNameAttribute( @@ -1931,7 +2367,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( pContext = new XMLParaContext( rImport, nPrefix, rLocalName, xAttrList, bHeading ); - if( bProgress && XML_TEXT_TYPE_SHAPE != eType ) + if (m_pImpl->m_bProgress && XML_TEXT_TYPE_SHAPE != eType) { rImport.GetProgressBarHelper()->Increment(); } @@ -1956,7 +2392,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( xAttrList ); break; case XML_TOK_TEXT_SEQUENCE_DECLS: - if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) || + if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) || XML_TEXT_TYPE_HEADER_FOOTER == eType ) { pContext = new XMLVariableDeclsImportContext( @@ -1966,7 +2402,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( break; case XML_TOK_TEXT_VARFIELD_DECLS: - if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) || + if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) || XML_TEXT_TYPE_HEADER_FOOTER == eType ) { pContext = new XMLVariableDeclsImportContext( @@ -1976,7 +2412,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( break; case XML_TOK_TEXT_USERFIELD_DECLS: - if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted)|| + if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted)|| XML_TEXT_TYPE_HEADER_FOOTER == eType ) { pContext = new XMLVariableDeclsImportContext( @@ -1986,7 +2422,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( break; case XML_TOK_TEXT_DDE_DECLS: - if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) || + if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) || XML_TEXT_TYPE_HEADER_FOOTER == eType ) { pContext = new XMLDdeFieldDeclsImportContext( @@ -1996,7 +2432,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( break; case XML_TOK_TEXT_FRAME_PAGE: - if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) || + if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) || XML_TEXT_TYPE_TEXTBOX == eType || XML_TEXT_TYPE_CHANGED_REGION == eType ) { @@ -2011,7 +2447,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( break; case XML_TOK_DRAW_A_PAGE: - if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) || + if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) || XML_TEXT_TYPE_TEXTBOX == eType || XML_TEXT_TYPE_CHANGED_REGION == eType) { @@ -2101,7 +2537,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( break; default: - if( (XML_TEXT_TYPE_BODY == eType && bBodyContentStarted) || + if ((XML_TEXT_TYPE_BODY == eType && m_pImpl->m_bBodyContentStarted) || XML_TEXT_TYPE_TEXTBOX == eType || XML_TEXT_TYPE_CHANGED_REGION == eType ) { @@ -2124,7 +2560,9 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( } if( XML_TEXT_TYPE_BODY == eType && bContent ) - bBodyContentStarted = sal_False; + { + m_pImpl->m_bBodyContentStarted = sal_False; + } return pContext; } @@ -2141,7 +2579,8 @@ SvXMLImportContext *XMLTextImportHelper::CreateTableChildContext( sal_Int32 XMLTextImportHelper::GetDataStyleKey(const OUString& sStyleName, sal_Bool* pIsSystemLanguage ) { - const SvXMLStyleContext* pStyle = ((SvXMLStylesContext *)&xAutoStyles)-> + const SvXMLStyleContext* pStyle = + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)-> FindStyleChildContext( XML_STYLE_FAMILY_DATA_STYLE, sStyleName, sal_True ); @@ -2174,9 +2613,10 @@ sal_Int32 XMLTextImportHelper::GetDataStyleKey(const OUString& sStyleName, const SvxXMLListStyleContext *XMLTextImportHelper::FindAutoListStyle( const OUString& rName ) const { const SvxXMLListStyleContext *pStyle = 0; - if( xAutoStyles.Is() ) + if (m_pImpl->m_xAutoStyles.Is()) { - const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)-> + const SvXMLStyleContext* pTempStyle = + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)-> FindStyleChildContext( XML_STYLE_FAMILY_TEXT_LIST, rName, sal_True ); pStyle = PTR_CAST( SvxXMLListStyleContext ,pTempStyle); @@ -2188,9 +2628,10 @@ const SvxXMLListStyleContext *XMLTextImportHelper::FindAutoListStyle( const OUSt XMLPropStyleContext *XMLTextImportHelper::FindAutoFrameStyle( const OUString& rName ) const { XMLPropStyleContext *pStyle = 0; - if( xAutoStyles.Is() ) + if (m_pImpl->m_xAutoStyles.Is()) { - const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)-> + const SvXMLStyleContext* pTempStyle = + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)-> FindStyleChildContext( XML_STYLE_FAMILY_SD_GRAPHICS_ID, rName, sal_True ); pStyle = PTR_CAST( XMLPropStyleContext ,pTempStyle); @@ -2203,9 +2644,10 @@ XMLPropStyleContext* XMLTextImportHelper::FindSectionStyle( const OUString& rName ) const { XMLPropStyleContext* pStyle = NULL; - if (xAutoStyles.Is() ) + if (m_pImpl->m_xAutoStyles.Is()) { - const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)-> + const SvXMLStyleContext* pTempStyle = + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)-> FindStyleChildContext( XML_STYLE_FAMILY_TEXT_SECTION, rName, sal_True ); @@ -2219,9 +2661,10 @@ XMLPropStyleContext* XMLTextImportHelper::FindPageMaster( const OUString& rName ) const { XMLPropStyleContext* pStyle = NULL; - if (xAutoStyles.Is() ) + if (m_pImpl->m_xAutoStyles.Is()) { - const SvXMLStyleContext* pTempStyle = ((SvXMLStylesContext *)&xAutoStyles)-> + const SvXMLStyleContext* pTempStyle = + ((SvXMLStylesContext *)&m_pImpl->m_xAutoStyles)-> FindStyleChildContext( XML_STYLE_FAMILY_PAGE_MASTER, rName, sal_True ); @@ -2245,63 +2688,75 @@ void XMLTextImportHelper::PopListContext() const SvXMLTokenMap& XMLTextImportHelper::GetTextNumberedParagraphAttrTokenMap() { - if( !pTextNumberedParagraphAttrTokenMap.get() ) - pTextNumberedParagraphAttrTokenMap.reset( + if (!m_pImpl->m_pTextNumberedParagraphAttrTokenMap.get()) + { + m_pImpl->m_pTextNumberedParagraphAttrTokenMap.reset( new SvXMLTokenMap( aTextNumberedParagraphAttrTokenMap ) ); - - return *pTextNumberedParagraphAttrTokenMap; + } + return *m_pImpl->m_pTextNumberedParagraphAttrTokenMap; } const SvXMLTokenMap& XMLTextImportHelper::GetTextListBlockAttrTokenMap() { - if( !pTextListBlockAttrTokenMap.get() ) - pTextListBlockAttrTokenMap.reset( + if (!m_pImpl->m_pTextListBlockAttrTokenMap.get()) + { + m_pImpl->m_pTextListBlockAttrTokenMap.reset( new SvXMLTokenMap( aTextListBlockAttrTokenMap ) ); - - return *pTextListBlockAttrTokenMap; + } + return *m_pImpl->m_pTextListBlockAttrTokenMap; } const SvXMLTokenMap& XMLTextImportHelper::GetTextListBlockElemTokenMap() { - if( !pTextListBlockElemTokenMap.get() ) - pTextListBlockElemTokenMap.reset( + if (!m_pImpl->m_pTextListBlockElemTokenMap.get()) + { + m_pImpl->m_pTextListBlockElemTokenMap.reset( new SvXMLTokenMap( aTextListBlockElemTokenMap ) ); - - return *pTextListBlockElemTokenMap; + } + return *m_pImpl->m_pTextListBlockElemTokenMap; } SvI18NMap& XMLTextImportHelper::GetRenameMap() { - if( !pRenameMap.get() ) - pRenameMap.reset( new SvI18NMap() ); - return *pRenameMap; + if (!m_pImpl->m_pRenameMap.get()) + { + m_pImpl->m_pRenameMap.reset( new SvI18NMap() ); + } + return *m_pImpl->m_pRenameMap; } void XMLTextImportHelper::InsertBookmarkStartRange( const OUString sName, const Reference<XTextRange> & rRange, - const OUString& i_rXmlId) + OUString const& i_rXmlId, + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & i_rpRDFaAttributes) { - aBookmarkStartRanges[sName] = std::make_pair(rRange, i_rXmlId); - aBookmarkVector.push_back(sName); + m_pImpl->m_BookmarkStartRanges[sName] = + ::boost::make_tuple(rRange, i_rXmlId, i_rpRDFaAttributes); + m_pImpl->m_BookmarkVector.push_back(sName); } sal_Bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange( const OUString sName, Reference<XTextRange> & o_rRange, - OUString& o_rXmlId) + OUString & o_rXmlId, + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes) { - if (aBookmarkStartRanges.count(sName)) + if (m_pImpl->m_BookmarkStartRanges.count(sName)) { - o_rRange.set(aBookmarkStartRanges[sName].first); - o_rXmlId = aBookmarkStartRanges[sName].second; - aBookmarkStartRanges.erase(sName); - BookmarkVector_t::iterator it=aBookmarkVector.begin(); - while(it!=aBookmarkVector.end() && it->compareTo(sName)!=0) { + Impl::BookmarkMapEntry_t & rEntry = + (*m_pImpl->m_BookmarkStartRanges.find(sName)).second; + o_rRange.set(rEntry.get<0>()); + o_rXmlId = rEntry.get<1>(); + o_rpRDFaAttributes = rEntry.get<2>(); + m_pImpl->m_BookmarkStartRanges.erase(sName); + Impl::BookmarkVector_t::iterator it(m_pImpl->m_BookmarkVector.begin()); + while (it != m_pImpl->m_BookmarkVector.end() && it->compareTo(sName)!=0) + { it++; } - if (it!=aBookmarkVector.end()) { - aBookmarkVector.erase(it); + if (it!=m_pImpl->m_BookmarkVector.end()) { + m_pImpl->m_BookmarkVector.erase(it); } return sal_True; } @@ -2313,62 +2768,68 @@ sal_Bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange( ::rtl::OUString XMLTextImportHelper::FindActiveBookmarkName() { - if ( !aBookmarkVector.empty() ) { - return aBookmarkVector.back(); + if (!m_pImpl->m_BookmarkVector.empty()) { + return m_pImpl->m_BookmarkVector.back(); } else return ::rtl::OUString(); // return the empty string on error... } ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > XMLTextImportHelper::GetRangeFor(::rtl::OUString &sName) { - return aBookmarkStartRanges[sName].first; + return m_pImpl->m_BookmarkStartRanges[sName].get<0>(); } void XMLTextImportHelper::pushFieldCtx( ::rtl::OUString name, ::rtl::OUString type ) { - aFieldStack.push(field_stack_item_t(field_name_type_t(name, type), field_params_t())); + m_pImpl->m_FieldStack.push(Impl::field_stack_item_t( + Impl::field_name_type_t(name, type), Impl::field_params_t())); } void XMLTextImportHelper::popFieldCtx() { - aFieldStack.pop(); + m_pImpl->m_FieldStack.pop(); } void XMLTextImportHelper::addFieldParam( ::rtl::OUString name, ::rtl::OUString value ) { - DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before..."); - if (!aFieldStack.empty()) { - field_stack_item_t &aFieldStackItem=aFieldStack.top(); - aFieldStackItem.second.push_back(field_param_t( name, value )); + DBG_ASSERT(!m_pImpl->m_FieldStack.empty(), + "stack is empty: not good! Do a pushFieldCtx before..."); + if (!m_pImpl->m_FieldStack.empty()) { + Impl::field_stack_item_t & FieldStackItem(m_pImpl->m_FieldStack.top()); + FieldStackItem.second.push_back(Impl::field_param_t( name, value )); } } ::rtl::OUString XMLTextImportHelper::getCurrentFieldName() { - DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before..."); - if (!aFieldStack.empty()) { - return aFieldStack.top().first.first; + DBG_ASSERT(!m_pImpl->m_FieldStack.empty(), + "stack is empty: not good! Do a pushFieldCtx before..."); + if (!m_pImpl->m_FieldStack.empty()) { + return m_pImpl->m_FieldStack.top().first.first; } else return ::rtl::OUString(); } ::rtl::OUString XMLTextImportHelper::getCurrentFieldType() { - DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before..."); - if (!aFieldStack.empty()) { - return aFieldStack.top().first.second; + DBG_ASSERT(!m_pImpl->m_FieldStack.empty(), + "stack is empty: not good! Do a pushFieldCtx before..."); + if (!m_pImpl->m_FieldStack.empty()) { + return m_pImpl->m_FieldStack.top().first.second; } else return ::rtl::OUString(); } bool XMLTextImportHelper::hasCurrentFieldCtx() { - return !aFieldStack.empty(); + return !m_pImpl->m_FieldStack.empty(); } void XMLTextImportHelper::setCurrentFieldParamsTo(::com::sun::star::uno::Reference< ::com::sun::star::text::XFormField> &xFormField) { - DBG_ASSERT(!aFieldStack.empty(), "stack is empty: not good! Do a pushFieldCtx before..."); - if (!aFieldStack.empty() && xFormField.is()) + DBG_ASSERT(!m_pImpl->m_FieldStack.empty(), + "stack is empty: not good! Do a pushFieldCtx before..."); + if (!m_pImpl->m_FieldStack.empty() && xFormField.is()) { - FieldParamImporter(&aFieldStack.top().second, xFormField->getParameters()).Import(); + FieldParamImporter(&m_pImpl->m_FieldStack.top().second, + xFormField->getParameters()).Import(); } } @@ -2378,6 +2839,11 @@ void XMLTextImportHelper::ConnectFrameChains( const OUString& rNextFrmName, const Reference < XPropertySet >& rFrmPropSet ) { + static ::rtl::OUString s_ChainNextName( + RTL_CONSTASCII_USTRINGPARAM("ChainNextName")); + static ::rtl::OUString s_ChainPrevName( + RTL_CONSTASCII_USTRINGPARAM("ChainPrevName")); + if( !rFrmName.getLength() ) return; @@ -2385,39 +2851,42 @@ void XMLTextImportHelper::ConnectFrameChains( { OUString sNextFrmName(GetRenameMap().Get( XML_TEXT_RENAME_TYPE_FRAME, rNextFrmName )); - if( xTextFrames.is() && xTextFrames->hasByName( sNextFrmName ) ) + if (m_pImpl->m_xTextFrames.is() + && m_pImpl->m_xTextFrames->hasByName(sNextFrmName)) { - rFrmPropSet->setPropertyValue( sChainNextName, makeAny(sNextFrmName) ); + rFrmPropSet->setPropertyValue(s_ChainNextName, + makeAny(sNextFrmName)); } else { - if( !pPrevFrmNames.get() ) + if (!m_pImpl->m_pPrevFrmNames.get()) { - pPrevFrmNames.reset( new SvStringsDtor ); - pNextFrmNames.reset( new SvStringsDtor ); + m_pImpl->m_pPrevFrmNames.reset( new SvStringsDtor ); + m_pImpl->m_pNextFrmNames.reset( new SvStringsDtor ); } - pPrevFrmNames->Insert( new String( rFrmName ), - pPrevFrmNames->Count() ); - pNextFrmNames->Insert( new String( sNextFrmName ), - pNextFrmNames->Count() ); + m_pImpl->m_pPrevFrmNames->Insert( new String( rFrmName ), + m_pImpl->m_pPrevFrmNames->Count() ); + m_pImpl->m_pNextFrmNames->Insert( new String( sNextFrmName ), + m_pImpl->m_pNextFrmNames->Count() ); } } - if( pPrevFrmNames.get() && pPrevFrmNames->Count() ) + if (m_pImpl->m_pPrevFrmNames.get() && m_pImpl->m_pPrevFrmNames->Count()) { - sal_uInt16 nCount = pPrevFrmNames->Count(); + sal_uInt16 nCount = m_pImpl->m_pPrevFrmNames->Count(); for( sal_uInt16 i=0; i<nCount; i++ ) { - String *pNext = (*pNextFrmNames)[i]; + String *pNext = (*m_pImpl->m_pNextFrmNames)[i]; if( OUString(*pNext) == rFrmName ) { // The previuous frame must exist, because it existing than // inserting the entry - String *pPrev = (*pPrevFrmNames)[i]; + String *pPrev = (*m_pImpl->m_pPrevFrmNames)[i]; - rFrmPropSet->setPropertyValue( sChainPrevName, makeAny(OUString( *pPrev )) ); + rFrmPropSet->setPropertyValue(s_ChainPrevName, + makeAny(OUString( *pPrev ))); - pPrevFrmNames->Remove( i, 1 ); - pNextFrmNames->Remove( i, 1 ); + m_pImpl->m_pPrevFrmNames->Remove( i, 1 ); + m_pImpl->m_pNextFrmNames->Remove( i, 1 ); delete pPrev; delete pNext; @@ -2430,6 +2899,9 @@ void XMLTextImportHelper::ConnectFrameChains( sal_Bool XMLTextImportHelper::IsInFrame() const { + static ::rtl::OUString s_TextFrame( + RTL_CONSTASCII_USTRINGPARAM("TextFrame")); + sal_Bool bIsInFrame = sal_False; // are we currently in a text frame? yes, if the cursor has a @@ -2437,9 +2909,10 @@ sal_Bool XMLTextImportHelper::IsInFrame() const Reference<XPropertySet> xPropSet(((XMLTextImportHelper *)this)->GetCursor(), UNO_QUERY); if (xPropSet.is()) { - if (xPropSet->getPropertySetInfo()->hasPropertyByName(sTextFrame)) + if (xPropSet->getPropertySetInfo()->hasPropertyByName(s_TextFrame)) { - Reference<XTextFrame> xFrame(xPropSet->getPropertyValue(sTextFrame), UNO_QUERY); + uno::Reference<XTextFrame> const xFrame( + xPropSet->getPropertyValue(s_TextFrame), UNO_QUERY); if (xFrame.is()) { @@ -2562,12 +3035,12 @@ void XMLTextImportHelper::SetChangesProtectionKey(const Sequence<sal_Int8> &) OUString XMLTextImportHelper::GetOpenRedlineId() { - return sOpenRedlineIdentifier; + return m_pImpl->m_sOpenRedlineIdentifier; } void XMLTextImportHelper::SetOpenRedlineId( ::rtl::OUString& rId) { - sOpenRedlineIdentifier = rId; + m_pImpl->m_sOpenRedlineIdentifier = rId; } void XMLTextImportHelper::ResetOpenRedlineId() @@ -2576,3 +3049,14 @@ void XMLTextImportHelper::ResetOpenRedlineId() SetOpenRedlineId(sEmpty); } +void +XMLTextImportHelper::SetCellParaStyleDefault(::rtl::OUString const& rNewValue) +{ + m_pImpl->m_sCellParaStyleDefault = rNewValue; +} + +::rtl::OUString const& XMLTextImportHelper::GetCellParaStyleDefault() +{ + return m_pImpl->m_sCellParaStyleDefault; +} + diff --git a/xmloff/source/text/txtlists.cxx b/xmloff/source/text/txtlists.cxx index 24c09bde6e7f..ab90e2ae4000 100644 --- a/xmloff/source/text/txtlists.cxx +++ b/xmloff/source/text/txtlists.cxx @@ -453,6 +453,8 @@ XMLTextListsHelper::MakeNumRule( sal_Bool* o_pRestartNumbering, sal_Bool* io_pSetDefaults) { + static ::rtl::OUString s_NumberingRules( + RTL_CONSTASCII_USTRINGPARAM("NumberingRules")); uno::Reference<container::XIndexReplace> xNumRules(i_rNumRule); if ( i_StyleName.getLength() && i_StyleName != i_ParentStyleName ) @@ -479,8 +481,7 @@ XMLTextListsHelper::MakeNumRule( uno::Reference< beans::XPropertySet > xPropSet( xStyle, uno::UNO_QUERY ); - any = xPropSet->getPropertyValue( - i_rImport.GetTextImport()->sNumberingRules ); + any = xPropSet->getPropertyValue(s_NumberingRules); any >>= xNumRules; } else diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index f1cf89cb0640..140656fd4298 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -90,7 +90,6 @@ #include <com/sun/star/text/XEndnotesSupplier.hpp> #include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/util/DateTime.hpp> -#include "xmlkywd.hxx" #include "xmlnmspe.hxx" #include <xmloff/xmlaustp.hxx> #include <xmloff/families.hxx> @@ -1999,7 +1998,18 @@ void XMLTextParagraphExport::exportParagraph( { const OUString& rIdentifier = GetExport().getInterfaceToIdentifierMapper().getIdentifier( xRef ); if( rIdentifier.getLength() ) - GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_ID, rIdentifier ); + { + // FIXME: this is just temporary until EditEngine + // paragraphs implement XMetadatable. + // then that must be used and not the mapper, because + // when both can be used we get two xml:id! + uno::Reference<rdf::XMetadatable> const xMeta(xRef, + uno::UNO_QUERY); + OSL_ENSURE(!xMeta.is(), "paragraph that implements " + "XMetadatable used in interfaceToIdentifierMapper?"); + GetExport().AddAttributeIdLegacy(XML_NAMESPACE_TEXT, + rIdentifier); + } } OUString sAutoStyle( sStyle ); diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index d1d7273ddd46..566c94ed166a 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -1917,6 +1917,7 @@ XMLParaContext::XMLParaContext( const SvXMLTokenMap& rTokenMap = GetImport().GetTextImport()->GetTextPAttrTokenMap(); + bool bHaveXmlId( false ); OUString aCondStyleName, sClassNames; sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; @@ -1933,6 +1934,7 @@ XMLParaContext::XMLParaContext( { case XML_TOK_TEXT_P_XMLID: m_sXmlId = rValue; + bHaveXmlId = true; break; case XML_TOK_TEXT_P_ABOUT: m_sAbout = rValue; @@ -1947,6 +1949,9 @@ XMLParaContext::XMLParaContext( case XML_TOK_TEXT_P_DATATYPE: m_sDatatype = rValue; break; + case XML_TOK_TEXT_P_TEXTID: + if (!bHaveXmlId) { m_sXmlId = rValue; } + break; case XML_TOK_TEXT_P_STYLE_NAME: sStyleName = rValue; break; @@ -1979,9 +1984,6 @@ XMLParaContext::XMLParaContext( } } break; - case XML_TOK_TEXT_P_ID: - sId = rValue; - break; case XML_TOK_TEXT_P_RESTART_NUMBERING: { sal_Bool bBool; @@ -2020,14 +2022,17 @@ XMLParaContext::~XMLParaContext() // if we have an id set for this paragraph, get a cursor for this // paragraph and register it with the given identifier - if( sId.getLength() ) + // FIXME: this is just temporary, and should be removed when + // EditEngine paragraphs implement XMetadatable! + if (m_sXmlId.getLength()) { Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange( xStart ) ); if( xIdCursor.is() ) { xIdCursor->gotoRange( xEnd, sal_True ); Reference< XInterface > xRef( xIdCursor, UNO_QUERY ); - GetImport().getInterfaceToIdentifierMapper().registerReference( sId, xRef ); + GetImport().getInterfaceToIdentifierMapper().registerReference( + m_sXmlId, xRef); } } @@ -2067,7 +2072,7 @@ XMLParaContext::~XMLParaContext() } } - OUString sCellParaStyleName = xTxtImport->sCellParaStyleDefault; + OUString const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault()); if( sCellParaStyleName.getLength() > 0 ) { // --> OD 2007-08-16 #i80724# diff --git a/xmloff/source/text/txtparai.hxx b/xmloff/source/text/txtparai.hxx index 9c911a5b639c..ecd593ca3d4f 100644 --- a/xmloff/source/text/txtparai.hxx +++ b/xmloff/source/text/txtparai.hxx @@ -46,7 +46,6 @@ class XMLParaContext : public SvXMLImportContext ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextRange > xStart; // xub_StrLen nStart; ::rtl::OUString sStyleName; - ::rtl::OUString sId; ::rtl::OUString m_sXmlId; ::rtl::OUString m_sAbout; ::rtl::OUString m_sProperty; diff --git a/xmloff/source/transform/makefile.mk b/xmloff/source/transform/makefile.mk index 473cec556212..bba8deb6db2b 100644 --- a/xmloff/source/transform/makefile.mk +++ b/xmloff/source/transform/makefile.mk @@ -86,7 +86,7 @@ SHL1STDLIBS = \ .ELSE SHL1STDLIBS += ixo.lib .ENDIF -SHL1VERSIONMAP = xof.map +SHL1VERSIONMAP = $(SOLARENV)/src/component.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) diff --git a/xmloff/source/transform/xof.map b/xmloff/source/transform/xof.map deleted file mode 100644 index f4ed78b9e970..000000000000 --- a/xmloff/source/transform/xof.map +++ /dev/null @@ -1,8 +0,0 @@ -UDK_3_0_0 { - global: - component_getImplementationEnvironment; - component_writeInfo; - component_getFactory; - local: - *; -}; |