diff options
Diffstat (limited to 'xmloff')
28 files changed, 1896 insertions, 1901 deletions
diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx index 44f68d98d2de..2d2050976b69 100644 --- a/xmloff/source/text/XMLChangedRegionImportContext.cxx +++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx @@ -160,24 +160,24 @@ void XMLChangedRegionImportContext::SetChangeInfo( void XMLChangedRegionImportContext::UseRedlineText() { // if we haven't already installed the redline cursor, do it now - if (! xOldCursor.is()) - { - // get TextImportHelper and old Cursor - rtl::Reference<XMLTextImportHelper> rHelper(GetImport().GetTextImport()); - Reference<XTextCursor> xCursor( rHelper->GetCursor() ); + if ( xOldCursor.is()) + return; - // create Redline and new Cursor - Reference<XTextCursor> xNewCursor = - rHelper->RedlineCreateText(xCursor, sID); + // get TextImportHelper and old Cursor + rtl::Reference<XMLTextImportHelper> rHelper(GetImport().GetTextImport()); + Reference<XTextCursor> xCursor( rHelper->GetCursor() ); - if (xNewCursor.is()) - { - // save old cursor and install new one - xOldCursor = xCursor; - rHelper->SetCursor( xNewCursor ); - } - // else: leave as is + // create Redline and new Cursor + Reference<XTextCursor> xNewCursor = + rHelper->RedlineCreateText(xCursor, sID); + + if (xNewCursor.is()) + { + // save old cursor and install new one + xOldCursor = xCursor; + rHelper->SetCursor( xNewCursor ); } + // else: leave as is } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx index 05764ebd0fb9..7245750f9edd 100644 --- a/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteConfigurationImportContext.cxx @@ -320,25 +320,25 @@ SvXMLImportContextRef XMLFootnoteConfigurationImportContext::CreateChildContext( void XMLFootnoteConfigurationImportContext::Finish( bool bOverwrite ) { - if (bOverwrite) + if (!bOverwrite) + return; + + if (bIsEndnote) { - if (bIsEndnote) + Reference<XEndnotesSupplier> xSupplier( + GetImport().GetModel(), UNO_QUERY); + if (xSupplier.is()) { - Reference<XEndnotesSupplier> xSupplier( - GetImport().GetModel(), UNO_QUERY); - if (xSupplier.is()) - { - ProcessSettings(xSupplier->getEndnoteSettings()); - } + ProcessSettings(xSupplier->getEndnoteSettings()); } - else + } + else + { + Reference<XFootnotesSupplier> xSupplier( + GetImport().GetModel(), UNO_QUERY); + if (xSupplier.is()) { - Reference<XFootnotesSupplier> xSupplier( - GetImport().GetModel(), UNO_QUERY); - if (xSupplier.is()) - { - ProcessSettings(xSupplier->getFootnoteSettings()); - } + ProcessSettings(xSupplier->getFootnoteSettings()); } } // else: ignore (there's only one configuration, so we can only overwrite) diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx index 80a1369a7152..24d1912b8939 100644 --- a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx +++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx @@ -204,41 +204,41 @@ void XMLIndexBibliographyConfigurationContext::CreateAndInsert(bool) // first: get field master // (we'll create one, and get the only master for this type) Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY); - if( xFactory.is() ) - { - Sequence<OUString> aServices = xFactory->getAvailableServiceNames(); - // here we should use a method which compares in reverse order if available - if (comphelper::findValue(aServices, gsFieldMaster_Bibliography) != -1) - { - Reference<XInterface> xIfc = - xFactory->createInstance(gsFieldMaster_Bibliography); - if( xIfc.is() ) - { - Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY ); - Any aAny; + if( !xFactory.is() ) + return; - xPropSet->setPropertyValue(gsBracketAfter, Any(sSuffix)); - xPropSet->setPropertyValue(gsBracketBefore, Any(sPrefix)); - xPropSet->setPropertyValue(gsIsNumberEntries, Any(bNumberedEntries)); - xPropSet->setPropertyValue(gsIsSortByPosition, Any(bSortByPosition)); + Sequence<OUString> aServices = xFactory->getAvailableServiceNames(); + // here we should use a method which compares in reverse order if available + if (comphelper::findValue(aServices, gsFieldMaster_Bibliography) == -1) + return; - if( !maLanguageTagODF.isEmpty() ) - { - aAny <<= maLanguageTagODF.getLanguageTag().getLocale( false); - xPropSet->setPropertyValue(gsLocale, aAny); - } + Reference<XInterface> xIfc = + xFactory->createInstance(gsFieldMaster_Bibliography); + if( !xIfc.is() ) + return; - if( !sAlgorithm.isEmpty() ) - { - xPropSet->setPropertyValue(gsSortAlgorithm, Any(sAlgorithm)); - } + Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY ); + Any aAny; - Sequence<Sequence<PropertyValue> > aKeysSeq = comphelper::containerToSequence(aSortKeys); - xPropSet->setPropertyValue(gsSortKeys, Any(aKeysSeq)); - } - // else: can't get FieldMaster -> ignore - } + xPropSet->setPropertyValue(gsBracketAfter, Any(sSuffix)); + xPropSet->setPropertyValue(gsBracketBefore, Any(sPrefix)); + xPropSet->setPropertyValue(gsIsNumberEntries, Any(bNumberedEntries)); + xPropSet->setPropertyValue(gsIsSortByPosition, Any(bSortByPosition)); + + if( !maLanguageTagODF.isEmpty() ) + { + aAny <<= maLanguageTagODF.getLanguageTag().getLocale( false); + xPropSet->setPropertyValue(gsLocale, aAny); } + + if( !sAlgorithm.isEmpty() ) + { + xPropSet->setPropertyValue(gsSortAlgorithm, Any(sAlgorithm)); + } + + Sequence<Sequence<PropertyValue> > aKeysSeq = comphelper::containerToSequence(aSortKeys); + xPropSet->setPropertyValue(gsSortKeys, Any(aKeysSeq)); + // else: can't get FieldMaster -> ignore // else: can't even get Factory -> ignore } diff --git a/xmloff/source/text/XMLIndexTOCStylesContext.cxx b/xmloff/source/text/XMLIndexTOCStylesContext.cxx index f310776dfee0..ed0b77f41cd5 100644 --- a/xmloff/source/text/XMLIndexTOCStylesContext.cxx +++ b/xmloff/source/text/XMLIndexTOCStylesContext.cxx @@ -85,26 +85,26 @@ void XMLIndexTOCStylesContext::StartElement( void XMLIndexTOCStylesContext::EndElement() { // if valid... - if (nOutlineLevel >= 0) + if (nOutlineLevel < 0) + return; + + // copy vector into sequence + const sal_Int32 nCount = aStyleNames.size(); + Sequence<OUString> aStyleNamesSequence(nCount); + for(sal_Int32 i = 0; i < nCount; i++) { - // copy vector into sequence - const sal_Int32 nCount = aStyleNames.size(); - Sequence<OUString> aStyleNamesSequence(nCount); - for(sal_Int32 i = 0; i < nCount; i++) - { - aStyleNamesSequence[i] = GetImport().GetStyleDisplayName( - XmlStyleFamily::TEXT_PARAGRAPH, - aStyleNames[i] ); - } + aStyleNamesSequence[i] = GetImport().GetStyleDisplayName( + XmlStyleFamily::TEXT_PARAGRAPH, + aStyleNames[i] ); + } - // get index replace - Any aAny = rTOCPropertySet->getPropertyValue("LevelParagraphStyles"); - Reference<XIndexReplace> xIndexReplace; - aAny >>= xIndexReplace; + // get index replace + Any aAny = rTOCPropertySet->getPropertyValue("LevelParagraphStyles"); + Reference<XIndexReplace> xIndexReplace; + aAny >>= xIndexReplace; - // set style names - xIndexReplace->replaceByIndex(nOutlineLevel, Any(aStyleNamesSequence)); - } + // set style names + xIndexReplace->replaceByIndex(nOutlineLevel, Any(aStyleNamesSequence)); } SvXMLImportContextRef XMLIndexTOCStylesContext::CreateChildContext( diff --git a/xmloff/source/text/XMLIndexTemplateContext.cxx b/xmloff/source/text/XMLIndexTemplateContext.cxx index 5d3ec9b12d4f..f0aac4bb3563 100644 --- a/xmloff/source/text/XMLIndexTemplateContext.cxx +++ b/xmloff/source/text/XMLIndexTemplateContext.cxx @@ -142,46 +142,46 @@ void XMLIndexTemplateContext::StartElement( void XMLIndexTemplateContext::EndElement() { - if (bOutlineLevelOK) - { - const sal_Int32 nCount = aValueVector.size(); - Sequence<PropertyValues> aValueSequence(nCount); - for(sal_Int32 i = 0; i<nCount; i++) - { - aValueSequence[i] = aValueVector[i]; - } - - // get LevelFormat IndexReplace ... - Any aAny = rPropertySet->getPropertyValue("LevelFormat"); - Reference<XIndexReplace> xIndexReplace; - aAny >>= xIndexReplace; + if (!bOutlineLevelOK) + return; - // ... and insert - xIndexReplace->replaceByIndex(nOutlineLevel, Any(aValueSequence)); - - if (bStyleNameOK) - { - const char* pStyleProperty = - pOutlineLevelStylePropMap[nOutlineLevel]; + const sal_Int32 nCount = aValueVector.size(); + Sequence<PropertyValues> aValueSequence(nCount); + for(sal_Int32 i = 0; i<nCount; i++) + { + aValueSequence[i] = aValueVector[i]; + } - DBG_ASSERT(nullptr != pStyleProperty, "need property name"); - if (nullptr != pStyleProperty) - { - OUString sDisplayStyleName = - GetImport().GetStyleDisplayName( - XmlStyleFamily::TEXT_PARAGRAPH, - sStyleName ); - // #i50288#: Check if style exists - const Reference < css::container::XNameContainer > & rStyles = - GetImport().GetTextImport()->GetParaStyles(); - if( rStyles.is() && - rStyles->hasByName( sDisplayStyleName ) ) - { - rPropertySet->setPropertyValue( - OUString::createFromAscii(pStyleProperty), css::uno::Any(sDisplayStyleName)); - } - } - } + // get LevelFormat IndexReplace ... + Any aAny = rPropertySet->getPropertyValue("LevelFormat"); + Reference<XIndexReplace> xIndexReplace; + aAny >>= xIndexReplace; + + // ... and insert + xIndexReplace->replaceByIndex(nOutlineLevel, Any(aValueSequence)); + + if (!bStyleNameOK) + return; + + const char* pStyleProperty = + pOutlineLevelStylePropMap[nOutlineLevel]; + + DBG_ASSERT(nullptr != pStyleProperty, "need property name"); + if (nullptr == pStyleProperty) + return; + + OUString sDisplayStyleName = + GetImport().GetStyleDisplayName( + XmlStyleFamily::TEXT_PARAGRAPH, + sStyleName ); + // #i50288#: Check if style exists + const Reference < css::container::XNameContainer > & rStyles = + GetImport().GetTextImport()->GetParaStyles(); + if( rStyles.is() && + rStyles->hasByName( sDisplayStyleName ) ) + { + rPropertySet->setPropertyValue( + OUString::createFromAscii(pStyleProperty), css::uno::Any(sDisplayStyleName)); } } diff --git a/xmloff/source/text/XMLLineNumberingExport.cxx b/xmloff/source/text/XMLLineNumberingExport.cxx index 1b39593bb0ab..c531f657ebe3 100644 --- a/xmloff/source/text/XMLLineNumberingExport.cxx +++ b/xmloff/source/text/XMLLineNumberingExport.cxx @@ -58,128 +58,127 @@ void XMLLineNumberingExport::Export() // export element if we have line numbering info Reference<XLineNumberingProperties> xSupplier(rExport.GetModel(), UNO_QUERY); - if (xSupplier.is()) + if (!xSupplier.is()) + return; + + Reference<XPropertySet> xLineNumbering = + xSupplier->getLineNumberingProperties(); + + if (!xLineNumbering.is()) + return; + + // char style + Any aAny = xLineNumbering->getPropertyValue("CharStyleName"); + OUString sTmp; + aAny >>= sTmp; + if (!sTmp.isEmpty()) { - Reference<XPropertySet> xLineNumbering = - xSupplier->getLineNumberingProperties(); - - if (xLineNumbering.is()) - { - // char style - Any aAny = xLineNumbering->getPropertyValue("CharStyleName"); - OUString sTmp; - aAny >>= sTmp; - if (!sTmp.isEmpty()) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, - rExport.EncodeStyleName( sTmp )); - } - - // enable - aAny = xLineNumbering->getPropertyValue("IsOn"); - if (! *o3tl::doAccess<bool>(aAny)) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, - XML_NUMBER_LINES, XML_FALSE); - } - - // count empty lines - aAny = xLineNumbering->getPropertyValue("CountEmptyLines"); - if (! *o3tl::doAccess<bool>(aAny)) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, - XML_COUNT_EMPTY_LINES, XML_FALSE); - } - - // count in frames - aAny = xLineNumbering->getPropertyValue("CountLinesInFrames"); - if (*o3tl::doAccess<bool>(aAny)) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, - XML_COUNT_IN_TEXT_BOXES, XML_TRUE); - } - - // restart numbering - aAny = xLineNumbering->getPropertyValue("RestartAtEachPage"); - if (*o3tl::doAccess<bool>(aAny)) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, - XML_RESTART_ON_PAGE, XML_TRUE); - } - - // Distance - aAny = xLineNumbering->getPropertyValue("Distance"); - sal_Int32 nLength = 0; - aAny >>= nLength; - if (nLength != 0) - { - OUStringBuffer sBuf; - rExport.GetMM100UnitConverter().convertMeasureToXML( - sBuf, nLength); - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_OFFSET, - sBuf.makeStringAndClear()); - } - - // NumberingType - OUStringBuffer sNumPosBuf; - aAny = xLineNumbering->getPropertyValue("NumberingType"); - sal_Int16 nFormat = 0; - aAny >>= nFormat; - rExport.GetMM100UnitConverter().convertNumFormat( sNumPosBuf, nFormat ); - rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT, - sNumPosBuf.makeStringAndClear()); - SvXMLUnitConverter::convertNumLetterSync( sNumPosBuf, nFormat ); - if( !sNumPosBuf.isEmpty() ) - { - rExport.AddAttribute(XML_NAMESPACE_STYLE, - XML_NUM_LETTER_SYNC, - sNumPosBuf.makeStringAndClear() ); - } - - // number position - aAny = xLineNumbering->getPropertyValue("NumberPosition"); - sal_uInt16 nPosition = 0; - aAny >>= nPosition; - if (SvXMLUnitConverter::convertEnum(sNumPosBuf, nPosition, - aLineNumberPositionMap)) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NUMBER_POSITION, - sNumPosBuf.makeStringAndClear()); - } - - // sInterval - aAny = xLineNumbering->getPropertyValue("Interval"); - sal_Int16 nLineInterval = 0; - aAny >>= nLineInterval; - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT, - OUString::number(nLineInterval)); - - SvXMLElementExport aConfigElem(rExport, XML_NAMESPACE_TEXT, - XML_LINENUMBERING_CONFIGURATION, - true, true); - - // line separator - aAny = xLineNumbering->getPropertyValue("SeparatorText"); - OUString sSeparator; - aAny >>= sSeparator; - if (!sSeparator.isEmpty()) - { - - // SeparatorInterval - aAny = xLineNumbering->getPropertyValue("SeparatorInterval"); - sal_Int16 nLineDistance = 0; - aAny >>= nLineDistance; - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT, - OUString::number(nLineDistance)); - - SvXMLElementExport aSeparatorElem(rExport, XML_NAMESPACE_TEXT, - XML_LINENUMBERING_SEPARATOR, - true, false); - rExport.Characters(sSeparator); - } - } - // else: no configuration: don't save -> default + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, + rExport.EncodeStyleName( sTmp )); } + + // enable + aAny = xLineNumbering->getPropertyValue("IsOn"); + if (! *o3tl::doAccess<bool>(aAny)) + { + rExport.AddAttribute(XML_NAMESPACE_TEXT, + XML_NUMBER_LINES, XML_FALSE); + } + + // count empty lines + aAny = xLineNumbering->getPropertyValue("CountEmptyLines"); + if (! *o3tl::doAccess<bool>(aAny)) + { + rExport.AddAttribute(XML_NAMESPACE_TEXT, + XML_COUNT_EMPTY_LINES, XML_FALSE); + } + + // count in frames + aAny = xLineNumbering->getPropertyValue("CountLinesInFrames"); + if (*o3tl::doAccess<bool>(aAny)) + { + rExport.AddAttribute(XML_NAMESPACE_TEXT, + XML_COUNT_IN_TEXT_BOXES, XML_TRUE); + } + + // restart numbering + aAny = xLineNumbering->getPropertyValue("RestartAtEachPage"); + if (*o3tl::doAccess<bool>(aAny)) + { + rExport.AddAttribute(XML_NAMESPACE_TEXT, + XML_RESTART_ON_PAGE, XML_TRUE); + } + + // Distance + aAny = xLineNumbering->getPropertyValue("Distance"); + sal_Int32 nLength = 0; + aAny >>= nLength; + if (nLength != 0) + { + OUStringBuffer sBuf; + rExport.GetMM100UnitConverter().convertMeasureToXML( + sBuf, nLength); + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_OFFSET, + sBuf.makeStringAndClear()); + } + + // NumberingType + OUStringBuffer sNumPosBuf; + aAny = xLineNumbering->getPropertyValue("NumberingType"); + sal_Int16 nFormat = 0; + aAny >>= nFormat; + rExport.GetMM100UnitConverter().convertNumFormat( sNumPosBuf, nFormat ); + rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT, + sNumPosBuf.makeStringAndClear()); + SvXMLUnitConverter::convertNumLetterSync( sNumPosBuf, nFormat ); + if( !sNumPosBuf.isEmpty() ) + { + rExport.AddAttribute(XML_NAMESPACE_STYLE, + XML_NUM_LETTER_SYNC, + sNumPosBuf.makeStringAndClear() ); + } + + // number position + aAny = xLineNumbering->getPropertyValue("NumberPosition"); + sal_uInt16 nPosition = 0; + aAny >>= nPosition; + if (SvXMLUnitConverter::convertEnum(sNumPosBuf, nPosition, + aLineNumberPositionMap)) + { + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NUMBER_POSITION, + sNumPosBuf.makeStringAndClear()); + } + + // sInterval + aAny = xLineNumbering->getPropertyValue("Interval"); + sal_Int16 nLineInterval = 0; + aAny >>= nLineInterval; + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT, + OUString::number(nLineInterval)); + + SvXMLElementExport aConfigElem(rExport, XML_NAMESPACE_TEXT, + XML_LINENUMBERING_CONFIGURATION, + true, true); + + // line separator + aAny = xLineNumbering->getPropertyValue("SeparatorText"); + OUString sSeparator; + aAny >>= sSeparator; + if (sSeparator.isEmpty()) + return; + + // SeparatorInterval + aAny = xLineNumbering->getPropertyValue("SeparatorInterval"); + sal_Int16 nLineDistance = 0; + aAny >>= nLineDistance; + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_INCREMENT, + OUString::number(nLineDistance)); + + SvXMLElementExport aSeparatorElem(rExport, XML_NAMESPACE_TEXT, + XML_LINENUMBERING_SEPARATOR, + true, false); + rExport.Characters(sSeparator); + // else: no configuration: don't save -> default // can't even get supplier: don't save -> default } diff --git a/xmloff/source/text/XMLLineNumberingImportContext.cxx b/xmloff/source/text/XMLLineNumberingImportContext.cxx index 3e56ab088182..7370d60dc628 100644 --- a/xmloff/source/text/XMLLineNumberingImportContext.cxx +++ b/xmloff/source/text/XMLLineNumberingImportContext.cxx @@ -198,50 +198,50 @@ void XMLLineNumberingImportContext::CreateAndInsert(bool) // we'll try to get the LineNumberingProperties Reference<XLineNumberingProperties> xSupplier(GetImport().GetModel(), UNO_QUERY); - if (xSupplier.is()) - { - Reference<XPropertySet> xLineNumbering = - xSupplier->getLineNumberingProperties(); + if (!xSupplier.is()) + return; - if (xLineNumbering.is()) - { - Any aAny; + Reference<XPropertySet> xLineNumbering = + xSupplier->getLineNumberingProperties(); - // set style name (if it exists) - if ( GetImport().GetStyles()->FindStyleChildContext( - XmlStyleFamily::TEXT_TEXT, sStyleName ) != nullptr ) - { - aAny <<= GetImport().GetStyleDisplayName( - XmlStyleFamily::TEXT_TEXT, sStyleName ); - xLineNumbering->setPropertyValue(gsCharStyleName, aAny); - } + if (!xLineNumbering.is()) + return; - xLineNumbering->setPropertyValue(gsSeparatorText, Any(sSeparator)); - xLineNumbering->setPropertyValue(gsDistance, Any(nOffset)); - xLineNumbering->setPropertyValue(gsNumberPosition, Any(nNumberPosition)); + Any aAny; - if (nIncrement >= 0) - { - xLineNumbering->setPropertyValue(gsInterval, Any(nIncrement)); - } + // set style name (if it exists) + if ( GetImport().GetStyles()->FindStyleChildContext( + XmlStyleFamily::TEXT_TEXT, sStyleName ) != nullptr ) + { + aAny <<= GetImport().GetStyleDisplayName( + XmlStyleFamily::TEXT_TEXT, sStyleName ); + xLineNumbering->setPropertyValue(gsCharStyleName, aAny); + } - if (nSeparatorIncrement >= 0) - { - xLineNumbering->setPropertyValue(gsSeparatorInterval, Any(nSeparatorIncrement)); - } + xLineNumbering->setPropertyValue(gsSeparatorText, Any(sSeparator)); + xLineNumbering->setPropertyValue(gsDistance, Any(nOffset)); + xLineNumbering->setPropertyValue(gsNumberPosition, Any(nNumberPosition)); - xLineNumbering->setPropertyValue(gsIsOn, Any(bNumberLines)); - xLineNumbering->setPropertyValue(gsCountEmptyLines, Any(bCountEmptyLines)); - xLineNumbering->setPropertyValue(gsCountLinesInFrames, Any(bCountInFloatingFrames)); - xLineNumbering->setPropertyValue(gsRestartAtEachPage, Any(bRestartNumbering)); + if (nIncrement >= 0) + { + xLineNumbering->setPropertyValue(gsInterval, Any(nIncrement)); + } - sal_Int16 nNumType = NumberingType::ARABIC; - GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, - sNumFormat, - sNumLetterSync ); - xLineNumbering->setPropertyValue(gsNumberingType, Any(nNumType)); - } + if (nSeparatorIncrement >= 0) + { + xLineNumbering->setPropertyValue(gsSeparatorInterval, Any(nSeparatorIncrement)); } + + xLineNumbering->setPropertyValue(gsIsOn, Any(bNumberLines)); + xLineNumbering->setPropertyValue(gsCountEmptyLines, Any(bCountEmptyLines)); + xLineNumbering->setPropertyValue(gsCountLinesInFrames, Any(bCountInFloatingFrames)); + xLineNumbering->setPropertyValue(gsRestartAtEachPage, Any(bRestartNumbering)); + + sal_Int16 nNumType = NumberingType::ARABIC; + GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, + sNumFormat, + sNumLetterSync ); + xLineNumbering->setPropertyValue(gsNumberingType, Any(nNumType)); } SvXMLImportContextRef XMLLineNumberingImportContext::CreateChildContext( diff --git a/xmloff/source/text/XMLPropertyBackpatcher.cxx b/xmloff/source/text/XMLPropertyBackpatcher.cxx index ea4db1d5024b..a2e4ac3a6fc0 100644 --- a/xmloff/source/text/XMLPropertyBackpatcher.cxx +++ b/xmloff/source/text/XMLPropertyBackpatcher.cxx @@ -55,22 +55,22 @@ void XMLPropertyBackpatcher<A>::ResolveId( // backpatch old references, if backpatch list exists auto it = aBackpatchListMap.find(sName); - if (it != aBackpatchListMap.end()) - { - // aah, we have a backpatch list! - std::unique_ptr<BackpatchListType> pList = std::move(it->second); + if (it == aBackpatchListMap.end()) + return; - // a) remove list from list map - aBackpatchListMap.erase(it); + // aah, we have a backpatch list! + std::unique_ptr<BackpatchListType> pList = std::move(it->second); - // b) for every item, set SequenceNumber - // (and preserve Property, if appropriate) - Any aAny; - aAny <<= aValue; - for(const auto& rBackpatch : *pList) - { - rBackpatch->setPropertyValue(sPropertyName, aAny); - } + // a) remove list from list map + aBackpatchListMap.erase(it); + + // b) for every item, set SequenceNumber + // (and preserve Property, if appropriate) + Any aAny; + aAny <<= aValue; + for(const auto& rBackpatch : *pList) + { + rBackpatch->setPropertyValue(sPropertyName, aAny); } // else: no backpatch list -> then we're finished } diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx index a17d10423c3b..f03bc1a98149 100644 --- a/xmloff/source/text/XMLRedlineExport.cxx +++ b/xmloff/source/text/XMLRedlineExport.cxx @@ -123,26 +123,26 @@ void XMLRedlineExport::ExportChangesList( // look for changes list for this XText ChangesMapType::iterator aFind = aChangeMap.find(rText); - if (aFind != aChangeMap.end()) - { - ChangesVectorType* pChangesList = aFind->second.get(); + if (aFind == aChangeMap.end()) + return; - // export only if changes are found - if (!pChangesList->empty()) - { - // changes container element - SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT, - XML_TRACKED_CHANGES, - true, true); + ChangesVectorType* pChangesList = aFind->second.get(); - // iterate over changes list - for (auto const& change : *pChangesList) - { - ExportChangedRegion(change); - } - } - // else: changes list empty -> ignore + // export only if changes are found + if (pChangesList->empty()) + return; + + // changes container element + SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT, + XML_TRACKED_CHANGES, + true, true); + + // iterate over changes list + for (auto const& change : *pChangesList) + { + ExportChangedRegion(change); } + // else: changes list empty -> ignore // else: no changes list found -> empty } @@ -179,60 +179,60 @@ void XMLRedlineExport::ExportChangesListElements() { // get redlines (aka tracked changes) from the model Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY); - if (xSupplier.is()) - { - Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines(); + if (!xSupplier.is()) + return; - // redline protection key - Reference<XPropertySet> aDocPropertySet( rExport.GetModel(), - uno::UNO_QUERY ); - // redlining enabled? - bool bEnabled = *o3tl::doAccess<bool>(aDocPropertySet->getPropertyValue( - "RecordChanges" )); + Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines(); - // only export if we have redlines or attributes - if ( aEnumAccess->hasElements() || bEnabled ) - { + // redline protection key + Reference<XPropertySet> aDocPropertySet( rExport.GetModel(), + uno::UNO_QUERY ); + // redlining enabled? + bool bEnabled = *o3tl::doAccess<bool>(aDocPropertySet->getPropertyValue( + "RecordChanges" )); - // export only if we have changes, but tracking is not enabled - if ( !bEnabled != !aEnumAccess->hasElements() ) - { - rExport.AddAttribute( - XML_NAMESPACE_TEXT, XML_TRACK_CHANGES, - bEnabled ? XML_TRUE : XML_FALSE ); - } + // only export if we have redlines or attributes + if ( !(aEnumAccess->hasElements() || bEnabled) ) + return; + + + // export only if we have changes, but tracking is not enabled + if ( !bEnabled != !aEnumAccess->hasElements() ) + { + rExport.AddAttribute( + XML_NAMESPACE_TEXT, XML_TRACK_CHANGES, + bEnabled ? XML_TRUE : XML_FALSE ); + } - // changes container element - SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT, - XML_TRACKED_CHANGES, - true, true); + // changes container element + SvXMLElementExport aChanges(rExport, XML_NAMESPACE_TEXT, + XML_TRACKED_CHANGES, + true, true); - // get enumeration and iterate over elements - Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration(); - while (aEnum->hasMoreElements()) + // get enumeration and iterate over elements + Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration(); + while (aEnum->hasMoreElements()) + { + Any aAny = aEnum->nextElement(); + Reference<XPropertySet> xPropSet; + aAny >>= xPropSet; + + DBG_ASSERT(xPropSet.is(), + "can't get XPropertySet; skipping Redline"); + if (xPropSet.is()) + { + // export only if not in header or footer + // (those must be exported with their XText) + aAny = xPropSet->getPropertyValue("IsInHeaderFooter"); + if (! *o3tl::doAccess<bool>(aAny)) { - Any aAny = aEnum->nextElement(); - Reference<XPropertySet> xPropSet; - aAny >>= xPropSet; - - DBG_ASSERT(xPropSet.is(), - "can't get XPropertySet; skipping Redline"); - if (xPropSet.is()) - { - // export only if not in header or footer - // (those must be exported with their XText) - aAny = xPropSet->getPropertyValue("IsInHeaderFooter"); - if (! *o3tl::doAccess<bool>(aAny)) - { - // and finally, export change - ExportChangedRegion(xPropSet); - } - } - // else: no XPropertySet -> no export + // and finally, export change + ExportChangedRegion(xPropSet); } } - // else: no redlines -> no export + // else: no XPropertySet -> no export } + // else: no redlines -> no export // else: no XRedlineSupplier -> no export } @@ -266,34 +266,34 @@ void XMLRedlineExport::ExportChangesListAutoStyles() { // get redlines (aka tracked changes) from the model Reference<XRedlinesSupplier> xSupplier(rExport.GetModel(), uno::UNO_QUERY); - if (xSupplier.is()) + if (!xSupplier.is()) + return; + + Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines(); + + // only export if we actually have redlines + if (!aEnumAccess->hasElements()) + return; + + // get enumeration and iterate over elements + Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration(); + while (aEnum->hasMoreElements()) { - Reference<XEnumerationAccess> aEnumAccess = xSupplier->getRedlines(); + Any aAny = aEnum->nextElement(); + Reference<XPropertySet> xPropSet; + aAny >>= xPropSet; - // only export if we actually have redlines - if (aEnumAccess->hasElements()) + DBG_ASSERT(xPropSet.is(), + "can't get XPropertySet; skipping Redline"); + if (xPropSet.is()) { - // get enumeration and iterate over elements - Reference<XEnumeration> aEnum = aEnumAccess->createEnumeration(); - while (aEnum->hasMoreElements()) + + // export only if not in header or footer + // (those must be exported with their XText) + aAny = xPropSet->getPropertyValue("IsInHeaderFooter"); + if (! *o3tl::doAccess<bool>(aAny)) { - Any aAny = aEnum->nextElement(); - Reference<XPropertySet> xPropSet; - aAny >>= xPropSet; - - DBG_ASSERT(xPropSet.is(), - "can't get XPropertySet; skipping Redline"); - if (xPropSet.is()) - { - - // export only if not in header or footer - // (those must be exported with their XText) - aAny = xPropSet->getPropertyValue("IsInHeaderFooter"); - if (! *o3tl::doAccess<bool>(aAny)) - { - ExportChangeAutoStyle(xPropSet); - } - } + ExportChangeAutoStyle(xPropSet); } } } @@ -557,22 +557,22 @@ void XMLRedlineExport::ExportStartOrEndRedline( } } - if( bIdOK ) - { - SAL_WARN_IF( sId.isEmpty(), "xmloff", "Redlines must have IDs" ); + if( !bIdOK ) + return; - // TODO: use GetRedlineID or eliminate that function - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_CHANGE_ID, - "ct" + sId); - - // export the element - // (whitespace because we're not inside paragraphs) - SvXMLElementExport aChangeElem( - rExport, XML_NAMESPACE_TEXT, - bIsCollapsed ? XML_CHANGE : - ( bIsStart ? XML_CHANGE_START : XML_CHANGE_END ), - true, true); - } + SAL_WARN_IF( sId.isEmpty(), "xmloff", "Redlines must have IDs" ); + + // TODO: use GetRedlineID or eliminate that function + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_CHANGE_ID, + "ct" + sId); + + // export the element + // (whitespace because we're not inside paragraphs) + SvXMLElementExport aChangeElem( + rExport, XML_NAMESPACE_TEXT, + bIsCollapsed ? XML_CHANGE : + ( bIsStart ? XML_CHANGE_START : XML_CHANGE_END ), + true, true); } void XMLRedlineExport::ExportStartOrEndRedline( @@ -607,18 +607,18 @@ void XMLRedlineExport::ExportStartOrEndRedline( void XMLRedlineExport::WriteComment(const OUString& rComment) { - if (!rComment.isEmpty()) + if (rComment.isEmpty()) + return; + + // iterate over all string-pieces separated by return (0x0a) and + // put each inside a paragraph element. + SvXMLTokenEnumerator aEnumerator(rComment, char(0x0a)); + OUString aSubString; + while (aEnumerator.getNextToken(aSubString)) { - // iterate over all string-pieces separated by return (0x0a) and - // put each inside a paragraph element. - SvXMLTokenEnumerator aEnumerator(rComment, char(0x0a)); - OUString aSubString; - while (aEnumerator.getNextToken(aSubString)) - { - SvXMLElementExport aParagraph( - rExport, XML_NAMESPACE_TEXT, XML_P, true, false); - rExport.Characters(aSubString); - } + SvXMLElementExport aParagraph( + rExport, XML_NAMESPACE_TEXT, XML_P, true, false); + rExport.Characters(aSubString); } } diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index 3703c927105b..04fc58e4cfa4 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -182,80 +182,80 @@ void XMLSectionExport::ExportSectionEnd( bool bAutoStyles) { // no end section for styles - if (!bAutoStyles) - { - enum XMLTokenEnum eElement = XML_TOKEN_INVALID; + if (bAutoStyles) + return; - // export index or regular section end - Reference<XDocumentIndex> xIndex; - if (GetIndex(rSection, xIndex)) + enum XMLTokenEnum eElement = XML_TOKEN_INVALID; + + // export index or regular section end + Reference<XDocumentIndex> xIndex; + if (GetIndex(rSection, xIndex)) + { + if (xIndex.is()) { - if (xIndex.is()) - { - // index end: close index body element - GetExport().EndElement( XML_NAMESPACE_TEXT, XML_INDEX_BODY, - true ); - GetExport().IgnorableWhitespace(); + // index end: close index body element + GetExport().EndElement( XML_NAMESPACE_TEXT, XML_INDEX_BODY, + true ); + GetExport().IgnorableWhitespace(); - switch (MapSectionType(xIndex->getServiceName())) - { - case TEXT_SECTION_TYPE_TOC: - eElement = XML_TABLE_OF_CONTENT; - break; + switch (MapSectionType(xIndex->getServiceName())) + { + case TEXT_SECTION_TYPE_TOC: + eElement = XML_TABLE_OF_CONTENT; + break; - case TEXT_SECTION_TYPE_ILLUSTRATION: - eElement = XML_ILLUSTRATION_INDEX; - break; + case TEXT_SECTION_TYPE_ILLUSTRATION: + eElement = XML_ILLUSTRATION_INDEX; + break; - case TEXT_SECTION_TYPE_ALPHABETICAL: - eElement = XML_ALPHABETICAL_INDEX; - break; + case TEXT_SECTION_TYPE_ALPHABETICAL: + eElement = XML_ALPHABETICAL_INDEX; + break; - case TEXT_SECTION_TYPE_TABLE: - eElement = XML_TABLE_INDEX; - break; + case TEXT_SECTION_TYPE_TABLE: + eElement = XML_TABLE_INDEX; + break; - case TEXT_SECTION_TYPE_OBJECT: - eElement = XML_OBJECT_INDEX; - break; + case TEXT_SECTION_TYPE_OBJECT: + eElement = XML_OBJECT_INDEX; + break; - case TEXT_SECTION_TYPE_USER: - eElement = XML_USER_INDEX; - break; + case TEXT_SECTION_TYPE_USER: + eElement = XML_USER_INDEX; + break; - case TEXT_SECTION_TYPE_BIBLIOGRAPHY: - eElement = XML_BIBLIOGRAPHY; - break; + case TEXT_SECTION_TYPE_BIBLIOGRAPHY: + eElement = XML_BIBLIOGRAPHY; + break; - default: - OSL_FAIL("unknown index type"); - // default: skip index! - break; - } - } - else - { - eElement = XML_INDEX_TITLE; + default: + OSL_FAIL("unknown index type"); + // default: skip index! + break; } } else { - eElement = XML_SECTION; + eElement = XML_INDEX_TITLE; } + } + else + { + eElement = XML_SECTION; + } - if (XML_TOKEN_INVALID != eElement) - { - // any old attributes? - GetExport().CheckAttrList(); + if (XML_TOKEN_INVALID != eElement) + { + // any old attributes? + GetExport().CheckAttrList(); - // element surrounded by whitespace - GetExport().EndElement( XML_NAMESPACE_TEXT, eElement, true); - GetExport().IgnorableWhitespace(); - } - else - { - OSL_FAIL("Need element name!"); - } + // element surrounded by whitespace + GetExport().EndElement( XML_NAMESPACE_TEXT, eElement, true); + GetExport().IgnorableWhitespace(); + } + else + { + OSL_FAIL("Need element name!"); } // else: autostyles -> ignore } @@ -1385,117 +1385,117 @@ void XMLSectionExport::ExportIndexTemplateElement( } // ... and write Element - if (eElement != XML_TOKEN_INVALID) + if (eElement == XML_TOKEN_INVALID) + return; + + // character style (for most templates) + if (bCharStyleOK) { - // character style (for most templates) - if (bCharStyleOK) + switch (nTokenType) { - switch (nTokenType) - { - case TOK_TTYPE_ENTRY_TEXT: - case TOK_TTYPE_TEXT: - case TOK_TTYPE_PAGE_NUMBER: - case TOK_TTYPE_ENTRY_NUMBER: - case TOK_TTYPE_HYPERLINK_START: - case TOK_TTYPE_HYPERLINK_END: - case TOK_TTYPE_BIBLIOGRAPHY: - case TOK_TTYPE_CHAPTER_INFO: - case TOK_TTYPE_TAB_STOP: - GetExport().AddAttribute(XML_NAMESPACE_TEXT, - XML_STYLE_NAME, - GetExport().EncodeStyleName( sCharStyle) ); - break; - default: - ; // nothing: no character style - break; - } + case TOK_TTYPE_ENTRY_TEXT: + case TOK_TTYPE_TEXT: + case TOK_TTYPE_PAGE_NUMBER: + case TOK_TTYPE_ENTRY_NUMBER: + case TOK_TTYPE_HYPERLINK_START: + case TOK_TTYPE_HYPERLINK_END: + case TOK_TTYPE_BIBLIOGRAPHY: + case TOK_TTYPE_CHAPTER_INFO: + case TOK_TTYPE_TAB_STOP: + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + XML_STYLE_NAME, + GetExport().EncodeStyleName( sCharStyle) ); + break; + default: + ; // nothing: no character style + break; } + } - // tab properties - if (TOK_TTYPE_TAB_STOP == nTokenType) - { - // tab type - GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_TYPE, - bRightAligned ? XML_RIGHT : XML_LEFT); - - if (bTabPositionOK && (! bRightAligned)) - { - // position for left tabs (convert to measure) - OUStringBuffer sBuf; - GetExport().GetMM100UnitConverter().convertMeasureToXML(sBuf, - nTabPosition); - GetExport().AddAttribute(XML_NAMESPACE_STYLE, - XML_POSITION, - sBuf.makeStringAndClear()); - } - - // fill char ("leader char") - if (bFillCharOK && !sFillChar.isEmpty()) - { - GetExport().AddAttribute(XML_NAMESPACE_STYLE, - XML_LEADER_CHAR, sFillChar); - } - - // #i21237# - if (bWithTabStopOK && ! bWithTabStop) - { - GetExport().AddAttribute(XML_NAMESPACE_STYLE, - XML_WITH_TAB, - XML_FALSE); - } - } + // tab properties + if (TOK_TTYPE_TAB_STOP == nTokenType) + { + // tab type + GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_TYPE, + bRightAligned ? XML_RIGHT : XML_LEFT); - // bibliography data - if (TOK_TTYPE_BIBLIOGRAPHY == nTokenType) + if (bTabPositionOK && (! bRightAligned)) { - OSL_ENSURE(bBibliographyDataOK, "need bibl data"); + // position for left tabs (convert to measure) OUStringBuffer sBuf; - if (SvXMLUnitConverter::convertEnum( sBuf, nBibliographyData, - aBibliographyDataFieldMap ) ) - { - GetExport().AddAttribute(XML_NAMESPACE_TEXT, - XML_BIBLIOGRAPHY_DATA_FIELD, - sBuf.makeStringAndClear()); - } + GetExport().GetMM100UnitConverter().convertMeasureToXML(sBuf, + nTabPosition); + GetExport().AddAttribute(XML_NAMESPACE_STYLE, + XML_POSITION, + sBuf.makeStringAndClear()); } - // chapter info - if (TOK_TTYPE_CHAPTER_INFO == nTokenType) + // fill char ("leader char") + if (bFillCharOK && !sFillChar.isEmpty()) { - OSL_ENSURE(bChapterFormatOK, "need chapter info"); - GetExport().AddAttribute( - XML_NAMESPACE_TEXT, XML_DISPLAY, - XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat)); -//---> i53420 - if (bLevelOK) - GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, - OUString::number(nLevel)); + GetExport().AddAttribute(XML_NAMESPACE_STYLE, + XML_LEADER_CHAR, sFillChar); } -//--->i53420 - if (TOK_TTYPE_ENTRY_NUMBER == nTokenType) + // #i21237# + if (bWithTabStopOK && ! bWithTabStop) { - if (bChapterFormatOK) - GetExport().AddAttribute( - XML_NAMESPACE_TEXT, XML_DISPLAY, - XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat)); - - if (bLevelOK) - GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, - OUString::number(nLevel)); + GetExport().AddAttribute(XML_NAMESPACE_STYLE, + XML_WITH_TAB, + XML_FALSE); } - // export template - SvXMLElementExport aTemplateElement(GetExport(), nNamespace, - GetXMLToken(eElement), - true, false) - ; - - // entry text or span element: write text - if (TOK_TTYPE_TEXT == nTokenType) + } + + // bibliography data + if (TOK_TTYPE_BIBLIOGRAPHY == nTokenType) + { + OSL_ENSURE(bBibliographyDataOK, "need bibl data"); + OUStringBuffer sBuf; + if (SvXMLUnitConverter::convertEnum( sBuf, nBibliographyData, + aBibliographyDataFieldMap ) ) { - GetExport().Characters(sText); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, + XML_BIBLIOGRAPHY_DATA_FIELD, + sBuf.makeStringAndClear()); } } + + // chapter info + if (TOK_TTYPE_CHAPTER_INFO == nTokenType) + { + OSL_ENSURE(bChapterFormatOK, "need chapter info"); + GetExport().AddAttribute( + XML_NAMESPACE_TEXT, XML_DISPLAY, + XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat)); +//---> i53420 + if (bLevelOK) + GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, + OUString::number(nLevel)); + } + +//--->i53420 + if (TOK_TTYPE_ENTRY_NUMBER == nTokenType) + { + if (bChapterFormatOK) + GetExport().AddAttribute( + XML_NAMESPACE_TEXT, XML_DISPLAY, + XMLTextFieldExport::MapChapterDisplayFormat(nChapterFormat)); + + if (bLevelOK) + GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, + OUString::number(nLevel)); + } + // export template + SvXMLElementExport aTemplateElement(GetExport(), nNamespace, + GetXMLToken(eElement), + true, false) + ; + + // entry text or span element: write text + if (TOK_TTYPE_TEXT == nTokenType) + { + GetExport().Characters(sText); + } } void XMLSectionExport::ExportLevelParagraphStyles( @@ -1570,101 +1570,101 @@ void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport) // first: get field master (via text field supplier) Reference<XTextFieldsSupplier> xTextFieldsSupp( rExport.GetModel(), UNO_QUERY ); - if ( xTextFieldsSupp.is() ) - { - const OUString sFieldMaster_Bibliography("com.sun.star.text.FieldMaster.Bibliography"); + if ( !xTextFieldsSupp.is() ) + return; - // get bibliography field master - Reference<XNameAccess> xMasters = - xTextFieldsSupp->getTextFieldMasters(); - if ( xMasters->hasByName(sFieldMaster_Bibliography) ) - { - Any aAny = - xMasters->getByName(sFieldMaster_Bibliography); - Reference<XPropertySet> xPropSet; - aAny >>= xPropSet; + const OUString sFieldMaster_Bibliography("com.sun.star.text.FieldMaster.Bibliography"); - OSL_ENSURE( xPropSet.is(), "field master must have XPropSet" ); + // get bibliography field master + Reference<XNameAccess> xMasters = + xTextFieldsSupp->getTextFieldMasters(); + if ( !xMasters->hasByName(sFieldMaster_Bibliography) ) + return; - OUString sTmp; + Any aAny = + xMasters->getByName(sFieldMaster_Bibliography); + Reference<XPropertySet> xPropSet; + aAny >>= xPropSet; - aAny = xPropSet->getPropertyValue("BracketBefore"); - aAny >>= sTmp; - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_PREFIX, sTmp); + OSL_ENSURE( xPropSet.is(), "field master must have XPropSet" ); - aAny = xPropSet->getPropertyValue("BracketAfter"); - aAny >>= sTmp; - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SUFFIX, sTmp); + OUString sTmp; - aAny = xPropSet->getPropertyValue("IsNumberEntries"); - if (*o3tl::doAccess<bool>(aAny)) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, - XML_NUMBERED_ENTRIES, XML_TRUE); - } + aAny = xPropSet->getPropertyValue("BracketBefore"); + aAny >>= sTmp; + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_PREFIX, sTmp); - aAny = xPropSet->getPropertyValue("IsSortByPosition"); - if (! *o3tl::doAccess<bool>(aAny)) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, - XML_SORT_BY_POSITION, XML_FALSE); - } + aAny = xPropSet->getPropertyValue("BracketAfter"); + aAny >>= sTmp; + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SUFFIX, sTmp); - // sort algorithm - aAny = xPropSet->getPropertyValue("SortAlgorithm"); - OUString sAlgorithm; - aAny >>= sAlgorithm; - if( !sAlgorithm.isEmpty() ) - { - rExport.AddAttribute( XML_NAMESPACE_TEXT, - XML_SORT_ALGORITHM, sAlgorithm ); - } + aAny = xPropSet->getPropertyValue("IsNumberEntries"); + if (*o3tl::doAccess<bool>(aAny)) + { + rExport.AddAttribute(XML_NAMESPACE_TEXT, + XML_NUMBERED_ENTRIES, XML_TRUE); + } + + aAny = xPropSet->getPropertyValue("IsSortByPosition"); + if (! *o3tl::doAccess<bool>(aAny)) + { + rExport.AddAttribute(XML_NAMESPACE_TEXT, + XML_SORT_BY_POSITION, XML_FALSE); + } + + // sort algorithm + aAny = xPropSet->getPropertyValue("SortAlgorithm"); + OUString sAlgorithm; + aAny >>= sAlgorithm; + if( !sAlgorithm.isEmpty() ) + { + rExport.AddAttribute( XML_NAMESPACE_TEXT, + XML_SORT_ALGORITHM, sAlgorithm ); + } - // locale - aAny = xPropSet->getPropertyValue("Locale"); - Locale aLocale; - aAny >>= aLocale; - rExport.AddLanguageTagAttributes( XML_NAMESPACE_FO, XML_NAMESPACE_STYLE, aLocale, true); - - // configuration element - SvXMLElementExport aElement(rExport, XML_NAMESPACE_TEXT, - XML_BIBLIOGRAPHY_CONFIGURATION, - true, true); - - // sort keys - aAny = xPropSet->getPropertyValue("SortKeys"); - Sequence<Sequence<PropertyValue> > aKeys; - aAny >>= aKeys; - for(const Sequence<PropertyValue> & rKey : std::as_const(aKeys)) + // locale + aAny = xPropSet->getPropertyValue("Locale"); + Locale aLocale; + aAny >>= aLocale; + rExport.AddLanguageTagAttributes( XML_NAMESPACE_FO, XML_NAMESPACE_STYLE, aLocale, true); + + // configuration element + SvXMLElementExport aElement(rExport, XML_NAMESPACE_TEXT, + XML_BIBLIOGRAPHY_CONFIGURATION, + true, true); + + // sort keys + aAny = xPropSet->getPropertyValue("SortKeys"); + Sequence<Sequence<PropertyValue> > aKeys; + aAny >>= aKeys; + for(const Sequence<PropertyValue> & rKey : std::as_const(aKeys)) + { + for(const PropertyValue& rValue : rKey) + { + if (rValue.Name == "SortKey") { - for(const PropertyValue& rValue : rKey) + sal_Int16 nKey = 0; + rValue.Value >>= nKey; + OUStringBuffer sBuf; + if (SvXMLUnitConverter::convertEnum( sBuf, nKey, + aBibliographyDataFieldMap ) ) { - if (rValue.Name == "SortKey") - { - sal_Int16 nKey = 0; - rValue.Value >>= nKey; - OUStringBuffer sBuf; - if (SvXMLUnitConverter::convertEnum( sBuf, nKey, - aBibliographyDataFieldMap ) ) - { - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_KEY, - sBuf.makeStringAndClear()); - } - } - else if (rValue.Name == "IsSortAscending") - { - bool bTmp = *o3tl::doAccess<bool>(rValue.Value); - rExport.AddAttribute(XML_NAMESPACE_TEXT, - XML_SORT_ASCENDING, - bTmp ? XML_TRUE : XML_FALSE); - } + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_KEY, + sBuf.makeStringAndClear()); } - - SvXMLElementExport aKeyElem(rExport, - XML_NAMESPACE_TEXT, XML_SORT_KEY, - true, true); + } + else if (rValue.Name == "IsSortAscending") + { + bool bTmp = *o3tl::doAccess<bool>(rValue.Value); + rExport.AddAttribute(XML_NAMESPACE_TEXT, + XML_SORT_ASCENDING, + bTmp ? XML_TRUE : XML_FALSE); } } + + SvXMLElementExport aKeyElem(rExport, + XML_NAMESPACE_TEXT, XML_SORT_KEY, + true, true); } } diff --git a/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx b/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx index 7f59169a0e8d..1f78bc5be790 100644 --- a/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx +++ b/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx @@ -124,56 +124,56 @@ void XMLSectionFootnoteConfigExport::exportXML( } // we only make an element if we have an own footnote/endnote numbering - if (bEnd) + if (!bEnd) + return; + + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS, + GetXMLToken( bEndnote ? XML_ENDNOTE + : XML_FOOTNOTE ) ); + // start numbering + OUStringBuffer sBuf; + if (bNumRestart) { - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS, - GetXMLToken( bEndnote ? XML_ENDNOTE - : XML_FOOTNOTE ) ); - // start numbering - OUStringBuffer sBuf; - if (bNumRestart) + // restart number is stored as 0.., but interpreted as 1.. + rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE, + OUString::number(nNumRestartAt+1)); + } + + if (bNumOwn) + { + // prefix and suffix + if (!sNumPrefix.isEmpty()) { - // restart number is stored as 0.., but interpreted as 1.. - rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE, - OUString::number(nNumRestartAt+1)); + rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX, + sNumPrefix); } - - if (bNumOwn) + if (!sNumSuffix.isEmpty()) { - // prefix and suffix - if (!sNumPrefix.isEmpty()) - { - rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_PREFIX, - sNumPrefix); - } - if (!sNumSuffix.isEmpty()) - { - rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX, - sNumSuffix); - } + rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_SUFFIX, + sNumSuffix); + } - // number type: num format - rExport.GetMM100UnitConverter().convertNumFormat( sBuf, - nNumberingType ); - rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT, - sBuf.makeStringAndClear()); + // number type: num format + rExport.GetMM100UnitConverter().convertNumFormat( sBuf, + nNumberingType ); + rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT, + sBuf.makeStringAndClear()); - // and letter sync, if applicable - SvXMLUnitConverter::convertNumLetterSync( - sBuf, nNumberingType ); - if (!sBuf.isEmpty()) - { - rExport.AddAttribute(XML_NAMESPACE_STYLE, - XML_NUM_LETTER_SYNC, - sBuf.makeStringAndClear()); - } + // and letter sync, if applicable + SvXMLUnitConverter::convertNumLetterSync( + sBuf, nNumberingType ); + if (!sBuf.isEmpty()) + { + rExport.AddAttribute(XML_NAMESPACE_STYLE, + XML_NUM_LETTER_SYNC, + sBuf.makeStringAndClear()); } - - // and finally, the element - SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT, - XML_NOTES_CONFIGURATION, - true, true); } + + // and finally, the element + SvXMLElementExport rElem(rExport, XML_NAMESPACE_TEXT, + XML_NOTES_CONFIGURATION, + true, true); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx index a5c75a40e814..ee7d94426b16 100644 --- a/xmloff/source/text/XMLSectionImportContext.cxx +++ b/xmloff/source/text/XMLSectionImportContext.cxx @@ -121,108 +121,108 @@ void XMLSectionImportContext::StartElement( rtl::Reference<XMLTextImportHelper> rHelper = GetImport().GetTextImport(); // valid? - if (bValid) - { - // create text section (as XPropertySet) - Reference<XMultiServiceFactory> xFactory( - GetImport().GetModel(),UNO_QUERY); - if (xFactory.is()) - { - Reference<XInterface> xIfc = - xFactory->createInstance( bIsIndexHeader ? OUString("com.sun.star.text.IndexHeaderSection") - : OUString("com.sun.star.text.TextSection") ); - if (xIfc.is()) - { - Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY); + if (!bValid) + return; - // save PropertySet (for CreateChildContext) - xSectionPropertySet = xPropSet; + // create text section (as XPropertySet) + Reference<XMultiServiceFactory> xFactory( + GetImport().GetModel(),UNO_QUERY); + if (!xFactory.is()) + return; - // name - Reference<XNamed> xNamed(xPropSet, UNO_QUERY); - xNamed->setName(sName); + Reference<XInterface> xIfc = + xFactory->createInstance( bIsIndexHeader ? OUString("com.sun.star.text.IndexHeaderSection") + : OUString("com.sun.star.text.TextSection") ); + if (!xIfc.is()) + return; - // stylename? - if (!sStyleName.isEmpty()) - { - XMLPropStyleContext* pStyle = rHelper-> - FindSectionStyle(sStyleName); + Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY); - if (pStyle != nullptr) - { - pStyle->FillPropertySet( xPropSet ); - } - } + // save PropertySet (for CreateChildContext) + xSectionPropertySet = xPropSet; - // IsVisible and condition (not for index headers) - if (! bIsIndexHeader) - { - xPropSet->setPropertyValue( "IsVisible", Any(bIsVisible) ); + // name + Reference<XNamed> xNamed(xPropSet, UNO_QUERY); + xNamed->setName(sName); - // #97450# hidden sections must be hidden on reload - // For backwards compatibility, set flag only if it is - // present - if( bIsCurrentlyVisibleOK ) - { - xPropSet->setPropertyValue( "IsCurrentlyVisible", Any(bIsCurrentlyVisible)); - } + // stylename? + if (!sStyleName.isEmpty()) + { + XMLPropStyleContext* pStyle = rHelper-> + FindSectionStyle(sStyleName); - if (bCondOK) - { - xPropSet->setPropertyValue( "Condition", Any(sCond) ); - } - } + if (pStyle != nullptr) + { + pStyle->FillPropertySet( xPropSet ); + } + } - // password (only for regular sections) - if ( bSequenceOK && - IsXMLToken(GetLocalName(), XML_SECTION) ) - { - xPropSet->setPropertyValue("ProtectionKey", Any(aSequence)); - } + // IsVisible and condition (not for index headers) + if (! bIsIndexHeader) + { + xPropSet->setPropertyValue( "IsVisible", Any(bIsVisible) ); - // protection - xPropSet->setPropertyValue( "IsProtected", Any(bProtect) ); + // #97450# hidden sections must be hidden on reload + // For backwards compatibility, set flag only if it is + // present + if( bIsCurrentlyVisibleOK ) + { + xPropSet->setPropertyValue( "IsCurrentlyVisible", Any(bIsCurrentlyVisible)); + } + + if (bCondOK) + { + xPropSet->setPropertyValue( "Condition", Any(sCond) ); + } + } - // insert marker, <paragraph>, marker; then insert - // section over the first marker character, and delete the - // last paragraph (and marker) when closing a section. - Reference<XTextRange> xStart = - rHelper->GetCursor()->getStart(); + // password (only for regular sections) + if ( bSequenceOK && + IsXMLToken(GetLocalName(), XML_SECTION) ) + { + xPropSet->setPropertyValue("ProtectionKey", Any(aSequence)); + } + + // protection + xPropSet->setPropertyValue( "IsProtected", Any(bProtect) ); + + // insert marker, <paragraph>, marker; then insert + // section over the first marker character, and delete the + // last paragraph (and marker) when closing a section. + Reference<XTextRange> xStart = + rHelper->GetCursor()->getStart(); #ifndef DBG_UTIL - OUString sMarkerString(" "); + OUString sMarkerString(" "); #else - OUString sMarkerString("X"); + OUString sMarkerString("X"); #endif - rHelper->InsertString(sMarkerString); - rHelper->InsertControlCharacter( - ControlCharacter::APPEND_PARAGRAPH ); - rHelper->InsertString(sMarkerString); + rHelper->InsertString(sMarkerString); + rHelper->InsertControlCharacter( + ControlCharacter::APPEND_PARAGRAPH ); + rHelper->InsertString(sMarkerString); - // select first marker - rHelper->GetCursor()->gotoRange(xStart, false); - rHelper->GetCursor()->goRight(1, true); + // select first marker + rHelper->GetCursor()->gotoRange(xStart, false); + rHelper->GetCursor()->goRight(1, true); - // convert section to XTextContent - Reference<XTextContent> xTextContent(xSectionPropertySet, - UNO_QUERY); + // convert section to XTextContent + Reference<XTextContent> xTextContent(xSectionPropertySet, + UNO_QUERY); - // and insert (over marker) - rHelper->GetText()->insertTextContent( - rHelper->GetCursorAsRange(), xTextContent, true ); + // and insert (over marker) + rHelper->GetText()->insertTextContent( + rHelper->GetCursorAsRange(), xTextContent, true ); - // and delete first marker (in section) - rHelper->GetText()->insertString( - rHelper->GetCursorAsRange(), "", true); + // and delete first marker (in section) + rHelper->GetText()->insertString( + rHelper->GetCursorAsRange(), "", true); - // finally, check for redlines that should start at - // the section start node - rHelper->RedlineAdjustStartNodeCursor(); // start ??? + // finally, check for redlines that should start at + // the section start node + rHelper->RedlineAdjustStartNodeCursor(); // start ??? - // xml:id for RDF metadata - GetImport().SetXmlId(xIfc, sXmlId); - } - } - } + // xml:id for RDF metadata + GetImport().SetXmlId(xIfc, sXmlId); } void XMLSectionImportContext::ProcessAttributes( diff --git a/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx b/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx index db928cde972c..070e402fb34a 100644 --- a/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx +++ b/xmloff/source/text/XMLTextCharStyleNamesElementExport.cxx @@ -39,26 +39,26 @@ XMLTextCharStyleNamesElementExport::XMLTextCharStyleNamesElementExport( rExport( rExp ), nCount( 0 ) { - if( bDoSth ) + if( !bDoSth ) + return; + + Any aAny = rPropSet->getPropertyValue( rPropName ); + Sequence < OUString > aNames; + if( !(aAny >>= aNames) ) + return; + + nCount = aNames.getLength(); + OSL_ENSURE( nCount > 0, "no char style found" ); + if ( bAllStyles ) ++nCount; + if( nCount > 1 ) { - Any aAny = rPropSet->getPropertyValue( rPropName ); - Sequence < OUString > aNames; - if( aAny >>= aNames ) + aName = rExport.GetNamespaceMap().GetQNameByKey( + XML_NAMESPACE_TEXT, GetXMLToken(XML_SPAN) ); + for( sal_Int32 i = 1; i < nCount; ++i ) { - nCount = aNames.getLength(); - OSL_ENSURE( nCount > 0, "no char style found" ); - if ( bAllStyles ) ++nCount; - if( nCount > 1 ) - { - aName = rExport.GetNamespaceMap().GetQNameByKey( - XML_NAMESPACE_TEXT, GetXMLToken(XML_SPAN) ); - for( sal_Int32 i = 1; i < nCount; ++i ) - { - rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, - rExport.EncodeStyleName( aNames[i - 1] ) ); - rExport.StartElement( aName, false ); - } - } + rExport.AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, + rExport.EncodeStyleName( aNames[i - 1] ) ); + rExport.StartElement( aName, false ); } } } diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 408a28bbcf95..ea3deca2b963 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -280,60 +280,62 @@ XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl( OUString sContourPolyPolygon("ContourPolyPolygon"); Reference < XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo(); - if(xPropSetInfo->hasPropertyByName(sContourPolyPolygon) && nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && (bPath ? sD : sPoints).getLength()) + if(!xPropSetInfo->hasPropertyByName(sContourPolyPolygon) || + nWidth <= 0 || nHeight <= 0 || bPixelWidth != bPixelHeight || + !(bPath ? sD : sPoints).getLength()) + return; + + const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter()); + basegfx::B2DPolyPolygon aPolyPolygon; + + if( bPath ) { - const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter()); - basegfx::B2DPolyPolygon aPolyPolygon; + basegfx::utils::importFromSvgD(aPolyPolygon, sD, GetImport().needFixPositionAfterZ(), nullptr); + } + else + { + basegfx::B2DPolygon aPolygon; - if( bPath ) + if(basegfx::utils::importFromSvgPoints(aPolygon, sPoints)) { - basegfx::utils::importFromSvgD(aPolyPolygon, sD, GetImport().needFixPositionAfterZ(), nullptr); - } - else - { - basegfx::B2DPolygon aPolygon; - - if(basegfx::utils::importFromSvgPoints(aPolygon, sPoints)) - { - aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon); - } + aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon); } + } - if(aPolyPolygon.count()) + if(aPolyPolygon.count()) + { + const basegfx::B2DRange aSourceRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); + const basegfx::B2DRange aTargetRange( + 0.0, 0.0, + nWidth, nHeight); + + if(!aSourceRange.equal(aTargetRange)) { - const basegfx::B2DRange aSourceRange( - aViewBox.GetX(), aViewBox.GetY(), - aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); - const basegfx::B2DRange aTargetRange( - 0.0, 0.0, - nWidth, nHeight); - - if(!aSourceRange.equal(aTargetRange)) - { - aPolyPolygon.transform( - basegfx::utils::createSourceRangeTargetRangeTransform( - aSourceRange, - aTargetRange)); - } - - css::drawing::PointSequenceSequence aPointSequenceSequence; - basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPolygon, aPointSequenceSequence); - xPropSet->setPropertyValue( sContourPolyPolygon, Any(aPointSequenceSequence) ); + aPolyPolygon.transform( + basegfx::utils::createSourceRangeTargetRangeTransform( + aSourceRange, + aTargetRange)); } - const OUString sIsPixelContour("IsPixelContour"); + css::drawing::PointSequenceSequence aPointSequenceSequence; + basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPolygon, aPointSequenceSequence); + xPropSet->setPropertyValue( sContourPolyPolygon, Any(aPointSequenceSequence) ); + } - if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) ) - { - xPropSet->setPropertyValue( sIsPixelContour, Any(bPixelWidth) ); - } + const OUString sIsPixelContour("IsPixelContour"); + + if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) ) + { + xPropSet->setPropertyValue( sIsPixelContour, Any(bPixelWidth) ); + } - const OUString sIsAutomaticContour("IsAutomaticContour"); + const OUString sIsAutomaticContour("IsAutomaticContour"); - if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) - { - xPropSet->setPropertyValue( sIsAutomaticContour, Any(bAuto) ); - } + if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) + { + xPropSet->setPropertyValue( sIsAutomaticContour, Any(bAuto) ); } } @@ -731,47 +733,47 @@ void XMLTextFrameContext_Impl::Create() GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex ); } - if( XML_TEXT_FRAME_TEXTBOX == nType ) - { - xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet ); - Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY ); - Reference < XText > xTxt = xTxtFrame->getText(); - xOldTextCursor = xTextImportHelper->GetCursor(); - xTextImportHelper->SetCursor( xTxt->createTextCursor() ); - - // remember old list item and block (#89892#) and reset them - // for the text frame - xTextImportHelper->PushListContext(); - mbListContextPushed = true; - } + if( XML_TEXT_FRAME_TEXTBOX != nType ) + return; + + xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet ); + Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY ); + Reference < XText > xTxt = xTxtFrame->getText(); + xOldTextCursor = xTextImportHelper->GetCursor(); + xTextImportHelper->SetCursor( xTxt->createTextCursor() ); + + // remember old list item and block (#89892#) and reset them + // for the text frame + xTextImportHelper->PushListContext(); + mbListContextPushed = true; } void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) { const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext); - if(pXMLTextFrameContext_Impl) + if(!pXMLTextFrameContext_Impl) + return; + + try { - try - { - // just dispose to delete - uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY); + // just dispose to delete + uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY); - // Inform shape importer about the removal so it can adjust - // z-indexes. - uno::Reference<drawing::XShape> xShape(xComp, uno::UNO_QUERY); - GetImport().GetShapeImport()->shapeRemoved(xShape); + // Inform shape importer about the removal so it can adjust + // z-indexes. + uno::Reference<drawing::XShape> xShape(xComp, uno::UNO_QUERY); + GetImport().GetShapeImport()->shapeRemoved(xShape); - if(xComp.is()) - { - xComp->dispose(); - } - } - catch( uno::Exception& ) + if(xComp.is()) { - OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" ); + xComp->dispose(); } } + catch( uno::Exception& ) + { + OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" ); + } } OUString XMLTextFrameContext::getGraphicPackageURLFromImportContext(const SvXMLImportContext& rContext) const @@ -1295,20 +1297,20 @@ void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef, void XMLTextFrameContext_Impl::SetName() { Reference<XNamed> xNamed(xPropSet, UNO_QUERY); - if (!m_sOrigName.isEmpty() && xNamed.is()) + if (!(!m_sOrigName.isEmpty() && xNamed.is())) + return; + + OUString const name(xNamed->getName()); + if (name != m_sOrigName) { - OUString const name(xNamed->getName()); - if (name != m_sOrigName) + try { - try - { - xNamed->setName(m_sOrigName); - } - catch (uno::Exception const&) - { // fdo#71698 document contains 2 frames with same draw:name - TOOLS_INFO_EXCEPTION("xmloff.text", "SetName(): exception setting \"" - << m_sOrigName << "\""); - } + xNamed->setName(m_sOrigName); + } + catch (uno::Exception const&) + { // fdo#71698 document contains 2 frames with same draw:name + TOOLS_INFO_EXCEPTION("xmloff.text", "SetName(): exception setting \"" + << m_sOrigName << "\""); } } } @@ -1414,36 +1416,35 @@ void XMLTextFrameContext::EndElement() (pMultiContext.is()) ? pMultiContext.get() : m_xImplContext.get(); XMLTextFrameContext_Impl *pImpl = const_cast<XMLTextFrameContext_Impl*>(dynamic_cast< const XMLTextFrameContext_Impl*>( pContext )); assert(!pMultiContext.is() || pImpl); - if( pImpl ) - { - pImpl->CreateIfNotThere(); - - // fdo#68839: in case the surviving image was not the first one, - // it will have a counter added to its name - set the original name - if (pMultiContext.is()) // do this only when necessary; esp. not for text - { // frames that may have entries in GetRenameMap()! - pImpl->SetName(); - } + if( !pImpl ) + return; - if( !m_sTitle.isEmpty() ) - { - pImpl->SetTitle( m_sTitle ); - } - if( !m_sDesc.isEmpty() ) - { - pImpl->SetDesc( m_sDesc ); - } + pImpl->CreateIfNotThere(); - if( m_pHyperlink ) - { - pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(), - m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() ); - m_pHyperlink.reset(); - } + // fdo#68839: in case the surviving image was not the first one, + // it will have a counter added to its name - set the original name + if (pMultiContext.is()) // do this only when necessary; esp. not for text + { // frames that may have entries in GetRenameMap()! + pImpl->SetName(); + } - GetImport().GetTextImport()->StoreLastImportedFrameName(pImpl->GetOrigName()); + if( !m_sTitle.isEmpty() ) + { + pImpl->SetTitle( m_sTitle ); + } + if( !m_sDesc.isEmpty() ) + { + pImpl->SetDesc( m_sDesc ); + } + if( m_pHyperlink ) + { + pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(), + m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() ); + m_pHyperlink.reset(); } + + GetImport().GetTextImport()->StoreLastImportedFrameName(pImpl->GetOrigName()); } SvXMLImportContextRef XMLTextFrameContext::CreateChildContext( diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx b/xmloff/source/text/XMLTextHeaderFooterContext.cxx index 50414bd78b65..38dc32dd1e46 100644 --- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx +++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx @@ -51,45 +51,45 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa { const OUString sShareContentFirst( "FirstIsShared" ); // NOTE: if this ever handles XML_DISPLAY attr then beware of fdo#72850 ! - if( bLeft || bFirst ) - { - Any aAny = xPropSet->getPropertyValue( sOn ); - bool bOn = *o3tl::doAccess<bool>(aAny); + if( !(bLeft || bFirst) ) + return; + + Any aAny = xPropSet->getPropertyValue( sOn ); + bool bOn = *o3tl::doAccess<bool>(aAny); - if( bOn ) + if( bOn ) + { + if (bLeft) { - if (bLeft) - { - aAny = xPropSet->getPropertyValue( sShareContent ); - bool bShared = bool(); - if (!(aAny >>= bShared)) - assert(false); // should return a value! - if( bShared ) - { - // Don't share headers any longer - xPropSet->setPropertyValue( sShareContent, Any(false) ); - } - } - if (bFirst) + aAny = xPropSet->getPropertyValue( sShareContent ); + bool bShared = bool(); + if (!(aAny >>= bShared)) + assert(false); // should return a value! + if( bShared ) { - aAny = xPropSet->getPropertyValue( sShareContentFirst ); - bool bSharedFirst = bool(); - if (!(aAny >>= bSharedFirst)) - assert(false); // should return a value! - if( bSharedFirst ) - { - // Don't share first/right headers any longer - xPropSet->setPropertyValue( sShareContentFirst, Any(false) ); - } + // Don't share headers any longer + xPropSet->setPropertyValue( sShareContent, Any(false) ); } } - else + if (bFirst) { - // If headers or footers are switched off, no content must be - // inserted. - bInsertContent = false; + aAny = xPropSet->getPropertyValue( sShareContentFirst ); + bool bSharedFirst = bool(); + if (!(aAny >>= bSharedFirst)) + assert(false); // should return a value! + if( bSharedFirst ) + { + // Don't share first/right headers any longer + xPropSet->setPropertyValue( sShareContentFirst, Any(false) ); + } } } + else + { + // If headers or footers are switched off, no content must be + // inserted. + bInsertContent = false; + } } XMLTextHeaderFooterContext::~XMLTextHeaderFooterContext() diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx index 6265bcf48a9f..a3b02b5b5c71 100644 --- a/xmloff/source/text/XMLTextListBlockContext.cxx +++ b/xmloff/source/text/XMLTextListBlockContext.cxx @@ -130,98 +130,98 @@ XMLTextListBlockContext::XMLTextListBlockContext( if( !mxNumRules.is() ) return; - if ( mnLevel == 0 ) // root <list> element + if ( mnLevel != 0 ) // root <list> element + return; + + XMLTextListsHelper& rTextListsHelper( mrTxtImport.GetTextListHelper() ); + // Inconsistent behavior regarding lists (#i92811#) + OUString sListStyleDefaultListId; { - XMLTextListsHelper& rTextListsHelper( mrTxtImport.GetTextListHelper() ); - // Inconsistent behavior regarding lists (#i92811#) - OUString sListStyleDefaultListId; + uno::Reference< beans::XPropertySet > xNumRuleProps( mxNumRules, UNO_QUERY ); + if ( xNumRuleProps.is() ) { - uno::Reference< beans::XPropertySet > xNumRuleProps( mxNumRules, UNO_QUERY ); - if ( xNumRuleProps.is() ) + uno::Reference< beans::XPropertySetInfo > xNumRulePropSetInfo( + xNumRuleProps->getPropertySetInfo()); + if (xNumRulePropSetInfo.is() && + xNumRulePropSetInfo->hasPropertyByName( + s_PropNameDefaultListId)) { - uno::Reference< beans::XPropertySetInfo > xNumRulePropSetInfo( - xNumRuleProps->getPropertySetInfo()); - if (xNumRulePropSetInfo.is() && - xNumRulePropSetInfo->hasPropertyByName( - s_PropNameDefaultListId)) - { - xNumRuleProps->getPropertyValue(s_PropNameDefaultListId) - >>= sListStyleDefaultListId; - SAL_WARN_IF( sListStyleDefaultListId.isEmpty(), "xmloff", - "no default list id found at numbering rules instance. Serious defect." ); - } + xNumRuleProps->getPropertyValue(s_PropNameDefaultListId) + >>= sListStyleDefaultListId; + SAL_WARN_IF( sListStyleDefaultListId.isEmpty(), "xmloff", + "no default list id found at numbering rules instance. Serious defect." ); } } - if ( msListId.isEmpty() ) // no text:id property found + } + if ( msListId.isEmpty() ) // no text:id property found + { + sal_Int32 nUPD( 0 ); + sal_Int32 nBuild( 0 ); + const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); + if ( rImport.IsTextDocInOOoFileFormat() || + ( bBuildIdFound && nUPD == 680 ) ) { - sal_Int32 nUPD( 0 ); - sal_Int32 nBuild( 0 ); - const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); - if ( rImport.IsTextDocInOOoFileFormat() || - ( bBuildIdFound && nUPD == 680 ) ) + /* handling former documents written by OpenOffice.org: + use default list id of numbering rules instance, if existing + (#i92811#) + */ + if ( !sListStyleDefaultListId.isEmpty() ) { - /* handling former documents written by OpenOffice.org: - use default list id of numbering rules instance, if existing - (#i92811#) - */ - if ( !sListStyleDefaultListId.isEmpty() ) + msListId = sListStyleDefaultListId; + if ( !bIsContinueNumberingAttributePresent && + !mbRestartNumbering && + rTextListsHelper.IsListProcessed( msListId ) ) { - msListId = sListStyleDefaultListId; - if ( !bIsContinueNumberingAttributePresent && - !mbRestartNumbering && - rTextListsHelper.IsListProcessed( msListId ) ) - { - mbRestartNumbering = true; - } + mbRestartNumbering = true; } } - if ( msListId.isEmpty() ) - { - // generate a new list id for the list - msListId = rTextListsHelper.GenerateNewListId(); - } } + if ( msListId.isEmpty() ) + { + // generate a new list id for the list + msListId = rTextListsHelper.GenerateNewListId(); + } + } - if ( bIsContinueNumberingAttributePresent && !mbRestartNumbering && - msContinueListId.isEmpty() ) + if ( bIsContinueNumberingAttributePresent && !mbRestartNumbering && + msContinueListId.isEmpty() ) + { + const OUString& Last( rTextListsHelper.GetLastProcessedListId() ); + if ( rTextListsHelper.GetListStyleOfLastProcessedList() == msListStyleName + && Last != msListId ) { - const OUString& Last( rTextListsHelper.GetLastProcessedListId() ); - if ( rTextListsHelper.GetListStyleOfLastProcessedList() == msListStyleName - && Last != msListId ) - { - msContinueListId = Last; - } + msContinueListId = Last; } + } - if ( !msContinueListId.isEmpty() ) + if ( !msContinueListId.isEmpty() ) + { + if ( !rTextListsHelper.IsListProcessed( msContinueListId ) ) { - if ( !rTextListsHelper.IsListProcessed( msContinueListId ) ) - { - msContinueListId.clear(); - } - else + msContinueListId.clear(); + } + else + { + // search continue list chain for master list and + // continue the master list. + OUString sTmpStr = + rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId ); + while ( !sTmpStr.isEmpty() ) { - // search continue list chain for master list and - // continue the master list. - OUString sTmpStr = - rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId ); - while ( !sTmpStr.isEmpty() ) - { - msContinueListId = sTmpStr; + msContinueListId = sTmpStr; - sTmpStr = - rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId ); - } + sTmpStr = + rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId ); } } + } - if ( !rTextListsHelper.IsListProcessed( msListId ) ) - { - // Inconsistent behavior regarding lists (#i92811#) - rTextListsHelper.KeepListAsProcessed( - msListId, msListStyleName, msContinueListId, - sListStyleDefaultListId ); - } + if ( !rTextListsHelper.IsListProcessed( msListId ) ) + { + // Inconsistent behavior regarding lists (#i92811#) + rTextListsHelper.KeepListAsProcessed( + msListId, msListStyleName, msContinueListId, + sListStyleDefaultListId ); } } diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index a947f81cc376..9ffb3e5c30fd 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -200,23 +200,23 @@ static auto InsertFieldmark(SvXMLImport & rImport, rImport, "com.sun.star.text.Fieldmark", rName, rHelper.GetCursorAsRange()); - if (xContent.is()) - { - // setup fieldmark... - Reference<text::XFormField> const xFormField(xContent, UNO_QUERY); - assert(xFormField.is()); - xFormField->setFieldType(fieldmarkTypeName); - rHelper.setCurrentFieldParamsTo(xFormField); - // move cursor after setFieldType as that may delete/re-insert - rHelper.GetCursor()->gotoRange(xContent->getAnchor()->getEnd(), false); - rHelper.GetCursor()->goLeft(1, false); // move before CH_TXT_ATR_FIELDEND - // tdf#129520: AppendTextNode() ignores the content index! - // plan B: insert a spurious paragraph break now and join - // it in PopFieldmark()! - rHelper.GetText()->insertControlCharacter(rHelper.GetCursor(), - text::ControlCharacter::PARAGRAPH_BREAK, false); - rHelper.GetCursor()->goLeft(1, false); // back to previous paragraph - } + if (!xContent.is()) + return; + + // setup fieldmark... + Reference<text::XFormField> const xFormField(xContent, UNO_QUERY); + assert(xFormField.is()); + xFormField->setFieldType(fieldmarkTypeName); + rHelper.setCurrentFieldParamsTo(xFormField); + // move cursor after setFieldType as that may delete/re-insert + rHelper.GetCursor()->gotoRange(xContent->getAnchor()->getEnd(), false); + rHelper.GetCursor()->goLeft(1, false); // move before CH_TXT_ATR_FIELDEND + // tdf#129520: AppendTextNode() ignores the content index! + // plan B: insert a spurious paragraph break now and join + // it in PopFieldmark()! + rHelper.GetText()->insertControlCharacter(rHelper.GetCursor(), + text::ControlCharacter::PARAGRAPH_BREAK, false); + rHelper.GetCursor()->goLeft(1, false); // back to previous paragraph } static auto PopFieldmark(XMLTextImportHelper & rHelper) -> void @@ -224,28 +224,28 @@ static auto PopFieldmark(XMLTextImportHelper & rHelper) -> void // can't verify name because it's not written as an attribute... uno::Reference<text::XTextContent> const xField(rHelper.popFieldCtx(), uno::UNO_QUERY); - if (xField.is()) + if (!xField.is()) + return; + + if (rHelper.GetText() == xField->getAnchor()->getText()) { - if (rHelper.GetText() == xField->getAnchor()->getText()) - { - try - { // skip CH_TXT_ATR_FIELDEND - rHelper.GetCursor()->goRight(1, true); - rHelper.GetCursor()->setString(OUString()); // undo AppendTextNode from InsertFieldmark - rHelper.GetCursor()->gotoRange(xField->getAnchor()->getEnd(), false); - } - catch (uno::Exception const&) - { - assert(false); // must succeed - } + try + { // skip CH_TXT_ATR_FIELDEND + rHelper.GetCursor()->goRight(1, true); + rHelper.GetCursor()->setString(OUString()); // undo AppendTextNode from InsertFieldmark + rHelper.GetCursor()->gotoRange(xField->getAnchor()->getEnd(), false); } - else + catch (uno::Exception const&) { - SAL_INFO("xmloff.text", "fieldmark has invalid positions"); - // could either dispose it or leave it to end at the end of the document? - xField->dispose(); + assert(false); // must succeed } } + else + { + SAL_INFO("xmloff.text", "fieldmark has invalid positions"); + // could either dispose it or leave it to end at the end of the document? + xField->dispose(); + } } void XMLTextMarkImportContext::EndElement() @@ -255,183 +255,183 @@ void XMLTextMarkImportContext::EndElement() static const char sAPI_bookmark[] = "com.sun.star.text.Bookmark"; lcl_MarkType nTmp{}; - if (SvXMLUnitConverter::convertEnum(nTmp, GetLocalName(), lcl_aMarkTypeMap)) + if (!SvXMLUnitConverter::convertEnum(nTmp, GetLocalName(), lcl_aMarkTypeMap)) + return; + + if (m_sBookmarkName.isEmpty() && TypeFieldmarkEnd != nTmp) + return; + + switch (nTmp) { - if (!m_sBookmarkName.isEmpty() || TypeFieldmarkEnd == nTmp) - { - switch (nTmp) + case TypeReference: + // export point reference mark + CreateAndInsertMark(GetImport(), + "com.sun.star.text.ReferenceMark", + m_sBookmarkName, + m_rHelper.GetCursorAsRange()->getStart()); + break; + + case TypeBookmark: { - case TypeReference: - // export point reference mark + // tdf#94804: detect duplicate heading cross reference bookmarks + if (m_sBookmarkName.startsWith("__RefHeading__")) + { + if (m_rxCrossRefHeadingBookmark.is()) + { + uno::Reference<container::XNamed> const xNamed( + m_rxCrossRefHeadingBookmark, uno::UNO_QUERY); + m_rHelper.AddCrossRefHeadingMapping( + m_sBookmarkName, xNamed->getName()); + break; // don't insert + } + } + } + [[fallthrough]]; + case TypeFieldmark: + { + const char *formFieldmarkName=lcl_getFormFieldmarkName(m_sFieldName); + bool bImportAsField = (nTmp==TypeFieldmark && formFieldmarkName!=nullptr); //@TODO handle abbreviation cases... + // export point bookmark + const Reference<XInterface> xContent( CreateAndInsertMark(GetImport(), - "com.sun.star.text.ReferenceMark", + (bImportAsField ? OUString("com.sun.star.text.FormFieldmark") : OUString(sAPI_bookmark)), m_sBookmarkName, - m_rHelper.GetCursorAsRange()->getStart()); - break; - - case TypeBookmark: - { - // tdf#94804: detect duplicate heading cross reference bookmarks - if (m_sBookmarkName.startsWith("__RefHeading__")) - { - if (m_rxCrossRefHeadingBookmark.is()) - { - uno::Reference<container::XNamed> const xNamed( - m_rxCrossRefHeadingBookmark, uno::UNO_QUERY); - m_rHelper.AddCrossRefHeadingMapping( - m_sBookmarkName, xNamed->getName()); - break; // don't insert - } + m_rHelper.GetCursorAsRange()->getStart(), + m_sXmlId) ); + if (nTmp==TypeFieldmark) { + if (xContent.is() && bImportAsField) { + // setup fieldmark... + Reference< css::text::XFormField> xFormField(xContent, UNO_QUERY); + xFormField->setFieldType(OUString::createFromAscii(formFieldmarkName)); + if (xFormField.is() && m_rHelper.hasCurrentFieldCtx()) { + m_rHelper.setCurrentFieldParamsTo(xFormField); } } - [[fallthrough]]; - case TypeFieldmark: - { - const char *formFieldmarkName=lcl_getFormFieldmarkName(m_sFieldName); - bool bImportAsField = (nTmp==TypeFieldmark && formFieldmarkName!=nullptr); //@TODO handle abbreviation cases... - // export point bookmark - const Reference<XInterface> xContent( - CreateAndInsertMark(GetImport(), - (bImportAsField ? OUString("com.sun.star.text.FormFieldmark") : OUString(sAPI_bookmark)), - m_sBookmarkName, - m_rHelper.GetCursorAsRange()->getStart(), - m_sXmlId) ); - if (nTmp==TypeFieldmark) { - if (xContent.is() && bImportAsField) { - // setup fieldmark... - Reference< css::text::XFormField> xFormField(xContent, UNO_QUERY); - xFormField->setFieldType(OUString::createFromAscii(formFieldmarkName)); - if (xFormField.is() && m_rHelper.hasCurrentFieldCtx()) { - m_rHelper.setCurrentFieldParamsTo(xFormField); - } - } - m_rHelper.popFieldCtx(); - } - if (TypeBookmark == nTmp - && m_sBookmarkName.startsWith("__RefHeading__")) - { - assert(xContent.is()); - m_rxCrossRefHeadingBookmark = xContent; - } + m_rHelper.popFieldCtx(); + } + if (TypeBookmark == nTmp + && m_sBookmarkName.startsWith("__RefHeading__")) + { + assert(xContent.is()); + m_rxCrossRefHeadingBookmark = xContent; + } + } + break; + + case TypeBookmarkStart: + // save XTextRange for later construction of bookmark + { + std::shared_ptr< ::xmloff::ParsedRDFaAttributes > + xRDFaAttributes; + if (m_bHaveAbout && TypeBookmarkStart == nTmp) + { + xRDFaAttributes = + GetImport().GetRDFaImportHelper().ParseRDFa( + m_sAbout, m_sProperty, + m_sContent, m_sDatatype); + } + m_rHelper.InsertBookmarkStartRange( + m_sBookmarkName, + m_rHelper.GetCursorAsRange()->getStart(), + m_sXmlId, xRDFaAttributes); + } + break; + + case TypeBookmarkEnd: + { + // tdf#94804: detect duplicate heading cross reference bookmarks + if (m_sBookmarkName.startsWith("__RefHeading__")) + { + if (m_rxCrossRefHeadingBookmark.is()) + { + uno::Reference<container::XNamed> const xNamed( + m_rxCrossRefHeadingBookmark, uno::UNO_QUERY); + m_rHelper.AddCrossRefHeadingMapping( + m_sBookmarkName, xNamed->getName()); + break; // don't insert + } + } + + // get old range, and construct + Reference<XTextRange> xStartRange; + std::shared_ptr< ::xmloff::ParsedRDFaAttributes > + xRDFaAttributes; + if (m_rHelper.FindAndRemoveBookmarkStartRange( + m_sBookmarkName, xStartRange, + m_sXmlId, xRDFaAttributes)) + { + Reference<XTextRange> xEndRange( + m_rHelper.GetCursorAsRange()->getStart()); + + // check if beginning and end are in same XText + if (xStartRange.is() && xEndRange.is() && xStartRange->getText() == xEndRange->getText()) + { + // create range for insertion + Reference<XTextCursor> xInsertionCursor = + m_rHelper.GetText()->createTextCursorByRange( + xEndRange); + try { + xInsertionCursor->gotoRange(xStartRange, true); + } catch (uno::Exception&) { + OSL_ENSURE(false, + "cannot go to end position of bookmark"); } - break; - case TypeBookmarkStart: - // save XTextRange for later construction of bookmark - { - std::shared_ptr< ::xmloff::ParsedRDFaAttributes > - xRDFaAttributes; - if (m_bHaveAbout && TypeBookmarkStart == nTmp) - { - xRDFaAttributes = - GetImport().GetRDFaImportHelper().ParseRDFa( - m_sAbout, m_sProperty, - m_sContent, m_sDatatype); - } - m_rHelper.InsertBookmarkStartRange( + //DBG_ASSERT(! xInsertionCursor->isCollapsed(), + // "we want no point mark"); + // can't assert, because someone could + // create a file with subsequence + // start/end elements + + Reference<XInterface> xContent; + // insert reference + xContent = CreateAndInsertMark(GetImport(), + sAPI_bookmark, m_sBookmarkName, - m_rHelper.GetCursorAsRange()->getStart(), - m_sXmlId, xRDFaAttributes); + xInsertionCursor, + m_sXmlId); + if (xRDFaAttributes) + { + const Reference<rdf::XMetadatable> + xMeta(xContent, UNO_QUERY); + GetImport().GetRDFaImportHelper().AddRDFa( + xMeta, xRDFaAttributes); } - break; - - case TypeBookmarkEnd: - { - // tdf#94804: detect duplicate heading cross reference bookmarks - if (m_sBookmarkName.startsWith("__RefHeading__")) + const Reference<XPropertySet> xPropertySet(xContent, UNO_QUERY); + if (xPropertySet.is()) { - if (m_rxCrossRefHeadingBookmark.is()) - { - uno::Reference<container::XNamed> const xNamed( - m_rxCrossRefHeadingBookmark, uno::UNO_QUERY); - m_rHelper.AddCrossRefHeadingMapping( - m_sBookmarkName, xNamed->getName()); - break; // don't insert - } + xPropertySet->setPropertyValue("BookmarkHidden", uno::Any(m_rHelper.getBookmarkHidden(m_sBookmarkName))); + xPropertySet->setPropertyValue("BookmarkCondition", uno::Any(m_rHelper.getBookmarkCondition(m_sBookmarkName))); } - - // get old range, and construct - Reference<XTextRange> xStartRange; - std::shared_ptr< ::xmloff::ParsedRDFaAttributes > - xRDFaAttributes; - if (m_rHelper.FindAndRemoveBookmarkStartRange( - m_sBookmarkName, xStartRange, - m_sXmlId, xRDFaAttributes)) + if (m_sBookmarkName.startsWith("__RefHeading__")) { - Reference<XTextRange> xEndRange( - m_rHelper.GetCursorAsRange()->getStart()); - - // check if beginning and end are in same XText - if (xStartRange.is() && xEndRange.is() && xStartRange->getText() == xEndRange->getText()) - { - // create range for insertion - Reference<XTextCursor> xInsertionCursor = - m_rHelper.GetText()->createTextCursorByRange( - xEndRange); - try { - xInsertionCursor->gotoRange(xStartRange, true); - } catch (uno::Exception&) { - OSL_ENSURE(false, - "cannot go to end position of bookmark"); - } - - //DBG_ASSERT(! xInsertionCursor->isCollapsed(), - // "we want no point mark"); - // can't assert, because someone could - // create a file with subsequence - // start/end elements - - Reference<XInterface> xContent; - // insert reference - xContent = CreateAndInsertMark(GetImport(), - sAPI_bookmark, - m_sBookmarkName, - xInsertionCursor, - m_sXmlId); - if (xRDFaAttributes) - { - const Reference<rdf::XMetadatable> - xMeta(xContent, UNO_QUERY); - GetImport().GetRDFaImportHelper().AddRDFa( - xMeta, xRDFaAttributes); - } - const Reference<XPropertySet> xPropertySet(xContent, UNO_QUERY); - if (xPropertySet.is()) - { - xPropertySet->setPropertyValue("BookmarkHidden", uno::Any(m_rHelper.getBookmarkHidden(m_sBookmarkName))); - xPropertySet->setPropertyValue("BookmarkCondition", uno::Any(m_rHelper.getBookmarkCondition(m_sBookmarkName))); - } - if (m_sBookmarkName.startsWith("__RefHeading__")) - { - assert(xContent.is()); - m_rxCrossRefHeadingBookmark = xContent; - } - } - // else: beginning/end in different XText -> ignore! + assert(xContent.is()); + m_rxCrossRefHeadingBookmark = xContent; } - // else: no start found -> ignore! - break; } - case TypeFieldmarkStart: // no separator, so insert at start - { - InsertFieldmark(GetImport(), m_rHelper, m_sBookmarkName); - break; - } - case TypeFieldmarkEnd: - { - PopFieldmark(m_rHelper); - break; - } - case TypeReferenceStart: - case TypeReferenceEnd: - OSL_FAIL("reference start/end are handled in txtparai !"); - break; - - default: - OSL_FAIL("unknown mark type"); - break; + // else: beginning/end in different XText -> ignore! } + // else: no start found -> ignore! + break; + } + case TypeFieldmarkStart: // no separator, so insert at start + { + InsertFieldmark(GetImport(), m_rHelper, m_sBookmarkName); + break; + } + case TypeFieldmarkEnd: + { + PopFieldmark(m_rHelper); + break; } + case TypeReferenceStart: + case TypeReferenceEnd: + OSL_FAIL("reference start/end are handled in txtparai !"); + break; + + default: + OSL_FAIL("unknown mark type"); + break; } } diff --git a/xmloff/source/text/XMLTextMasterPageContext.cxx b/xmloff/source/text/XMLTextMasterPageContext.cxx index 890ca08b3e32..90f4167e199e 100644 --- a/xmloff/source/text/XMLTextMasterPageContext.cxx +++ b/xmloff/source/text/XMLTextMasterPageContext.cxx @@ -159,25 +159,25 @@ XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport, } SetNew( bNew ); - if( bOverwrite || bNew ) - { - Reference < XMultiPropertyStates > xMultiStates( xPropSet, - UNO_QUERY ); - OSL_ENSURE( xMultiStates.is(), - "text page style does not support multi property set" ); - if( xMultiStates.is() ) - xMultiStates->setAllPropertiesToDefault(); - - if ( xPropSetInfo->hasPropertyByName( "GridDisplay" ) ) - xPropSet->setPropertyValue( "GridDisplay", Any(false) ); - - if ( xPropSetInfo->hasPropertyByName( "GridPrint" ) ) - xPropSet->setPropertyValue( "GridPrint", Any(false) ); - - bInsertHeader = bInsertFooter = true; - bInsertHeaderLeft = bInsertFooterLeft = true; - bInsertHeaderFirst = bInsertFooterFirst = true; - } + if( !(bOverwrite || bNew) ) + return; + + Reference < XMultiPropertyStates > xMultiStates( xPropSet, + UNO_QUERY ); + OSL_ENSURE( xMultiStates.is(), + "text page style does not support multi property set" ); + if( xMultiStates.is() ) + xMultiStates->setAllPropertiesToDefault(); + + if ( xPropSetInfo->hasPropertyByName( "GridDisplay" ) ) + xPropSet->setPropertyValue( "GridDisplay", Any(false) ); + + if ( xPropSetInfo->hasPropertyByName( "GridPrint" ) ) + xPropSet->setPropertyValue( "GridPrint", Any(false) ); + + bInsertHeader = bInsertFooter = true; + bInsertHeaderLeft = bInsertFooterLeft = true; + bInsertHeaderFirst = bInsertFooterFirst = true; } XMLTextMasterPageContext::~XMLTextMasterPageContext() @@ -262,58 +262,58 @@ SvXMLImportContext *XMLTextMasterPageContext::CreateHeaderFooterContext( void XMLTextMasterPageContext::Finish( bool bOverwrite ) { - if( xStyle.is() && (IsNew() || bOverwrite) ) + if( !(xStyle.is() && (IsNew() || bOverwrite)) ) + return; + + Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY ); + XMLPropStyleContext * pDrawingPageStyle(nullptr); + if (!m_sDrawingPageStyle.isEmpty()) { - Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY ); - XMLPropStyleContext * pDrawingPageStyle(nullptr); - if (!m_sDrawingPageStyle.isEmpty()) - { - pDrawingPageStyle = GetImport().GetTextImport()->FindDrawingPage(m_sDrawingPageStyle); - } - PageStyleContext * pPageLayout(nullptr); - if( !sPageMasterName.isEmpty() ) - { - pPageLayout = static_cast<PageStyleContext *>(GetImport().GetTextImport()->FindPageMaster(sPageMasterName)); - } - if (pPageLayout) - { - pPageLayout->FillPropertySet_PageStyle(xPropSet, pDrawingPageStyle); - } - else if (pDrawingPageStyle) - { - // don't need to care about old background attributes in this case - pDrawingPageStyle->FillPropertySet(xPropSet); - } + pDrawingPageStyle = GetImport().GetTextImport()->FindDrawingPage(m_sDrawingPageStyle); + } + PageStyleContext * pPageLayout(nullptr); + if( !sPageMasterName.isEmpty() ) + { + pPageLayout = static_cast<PageStyleContext *>(GetImport().GetTextImport()->FindPageMaster(sPageMasterName)); + } + if (pPageLayout) + { + pPageLayout->FillPropertySet_PageStyle(xPropSet, pDrawingPageStyle); + } + else if (pDrawingPageStyle) + { + // don't need to care about old background attributes in this case + pDrawingPageStyle->FillPropertySet(xPropSet); + } - Reference < XNameContainer > xPageStyles = - GetImport().GetTextImport()->GetPageStyles(); - if( !xPageStyles.is() ) - return; + Reference < XNameContainer > xPageStyles = + GetImport().GetTextImport()->GetPageStyles(); + if( !xPageStyles.is() ) + return; - Reference< XPropertySetInfo > xPropSetInfo = - xPropSet->getPropertySetInfo(); - if( xPropSetInfo->hasPropertyByName( gsFollowStyle ) ) + Reference< XPropertySetInfo > xPropSetInfo = + xPropSet->getPropertySetInfo(); + if( xPropSetInfo->hasPropertyByName( gsFollowStyle ) ) + { + OUString sDisplayFollow( + GetImport().GetStyleDisplayName( + XmlStyleFamily::MASTER_PAGE, sFollow ) ); + if( sDisplayFollow.isEmpty() || + !xPageStyles->hasByName( sDisplayFollow ) ) + sDisplayFollow = xStyle->getName(); + + Any aAny = xPropSet->getPropertyValue( gsFollowStyle ); + OUString sCurrFollow; + aAny >>= sCurrFollow; + if( sCurrFollow != sDisplayFollow ) { - OUString sDisplayFollow( - GetImport().GetStyleDisplayName( - XmlStyleFamily::MASTER_PAGE, sFollow ) ); - if( sDisplayFollow.isEmpty() || - !xPageStyles->hasByName( sDisplayFollow ) ) - sDisplayFollow = xStyle->getName(); - - Any aAny = xPropSet->getPropertyValue( gsFollowStyle ); - OUString sCurrFollow; - aAny >>= sCurrFollow; - if( sCurrFollow != sDisplayFollow ) - { - xPropSet->setPropertyValue( gsFollowStyle, Any(sDisplayFollow) ); - } + xPropSet->setPropertyValue( gsFollowStyle, Any(sDisplayFollow) ); } + } - if ( xPropSetInfo->hasPropertyByName( "Hidden" ) ) - { - xPropSet->setPropertyValue( "Hidden", uno::makeAny( IsHidden( ) ) ); - } + if ( xPropSetInfo->hasPropertyByName( "Hidden" ) ) + { + xPropSet->setPropertyValue( "Hidden", uno::makeAny( IsHidden( ) ) ); } } diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx index fb1c459d304f..438b9b492f3d 100644 --- a/xmloff/source/text/txtexppr.cxx +++ b/xmloff/source/text/txtexppr.cxx @@ -328,20 +328,20 @@ void XMLTextExportPropertySetMapper::ContextFontHeightFilter( pCharHeightState->maValue.clear(); } } - if( pCharDiffHeightState ) + if( !pCharDiffHeightState ) + return; + + float nTemp = 0; + pCharDiffHeightState->maValue >>= nTemp; + if( nTemp == 0. ) { - float nTemp = 0; - pCharDiffHeightState->maValue >>= nTemp; - if( nTemp == 0. ) - { - pCharDiffHeightState->mnIndex = -1; - pCharDiffHeightState->maValue.clear(); - } - else - { - pCharHeightState->mnIndex = -1; - pCharHeightState->maValue.clear(); - } + pCharDiffHeightState->mnIndex = -1; + pCharDiffHeightState->maValue.clear(); + } + else + { + pCharHeightState->mnIndex = -1; + pCharHeightState->maValue.clear(); } } @@ -355,20 +355,20 @@ void lcl_checkMultiProperty(XMLPropertyState *const pState, XMLPropertyState *const pRelState) { - if (pState && pRelState) + if (!(pState && pRelState)) + return; + + sal_Int32 nTemp = 0; + pRelState->maValue >>= nTemp; + if (100 == nTemp) { - sal_Int32 nTemp = 0; - pRelState->maValue >>= nTemp; - if (100 == nTemp) - { - pRelState->mnIndex = -1; - pRelState->maValue.clear(); - } - else - { - pState->mnIndex = -1; - pState->maValue.clear(); - } + pRelState->mnIndex = -1; + pRelState->maValue.clear(); + } + else + { + pState->mnIndex = -1; + pState->maValue.clear(); } } @@ -466,43 +466,38 @@ void lcl_FilterBorders( } } - if( pAllBorderState ) + if( !pAllBorderState ) + return; + + if( pLeftBorderState && pRightBorderState && pTopBorderState && pBottomBorderState ) { - if( pLeftBorderState && pRightBorderState && pTopBorderState && pBottomBorderState ) + table::BorderLine2 aLeft, aRight, aTop, aBottom; + + pLeftBorderState->maValue >>= aLeft; + pRightBorderState->maValue >>= aRight; + pTopBorderState->maValue >>= aTop; + pBottomBorderState->maValue >>= aBottom; + if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth && + aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance && + aLeft.LineStyle == aRight.LineStyle && + aLeft.LineWidth == aRight.LineWidth && + aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth && + aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance && + aLeft.LineStyle == aTop.LineStyle && + aLeft.LineWidth == aTop.LineWidth && + aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth && + aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance && + aLeft.LineWidth == aBottom.LineWidth && + aLeft.LineStyle == aBottom.LineStyle ) { - table::BorderLine2 aLeft, aRight, aTop, aBottom; - - pLeftBorderState->maValue >>= aLeft; - pRightBorderState->maValue >>= aRight; - pTopBorderState->maValue >>= aTop; - pBottomBorderState->maValue >>= aBottom; - if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth && - aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance && - aLeft.LineStyle == aRight.LineStyle && - aLeft.LineWidth == aRight.LineWidth && - aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth && - aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance && - aLeft.LineStyle == aTop.LineStyle && - aLeft.LineWidth == aTop.LineWidth && - aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth && - aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance && - aLeft.LineWidth == aBottom.LineWidth && - aLeft.LineStyle == aBottom.LineStyle ) - { - pLeftBorderState->mnIndex = -1; - pLeftBorderState->maValue.clear(); - pRightBorderState->mnIndex = -1; - pRightBorderState->maValue.clear(); - pTopBorderState->mnIndex = -1; - pTopBorderState->maValue.clear(); - pBottomBorderState->mnIndex = -1; - pBottomBorderState->maValue.clear(); - } - else - { - pAllBorderState->mnIndex = -1; - pAllBorderState->maValue.clear(); - } + pLeftBorderState->mnIndex = -1; + pLeftBorderState->maValue.clear(); + pRightBorderState->mnIndex = -1; + pRightBorderState->maValue.clear(); + pTopBorderState->mnIndex = -1; + pTopBorderState->maValue.clear(); + pBottomBorderState->mnIndex = -1; + pBottomBorderState->maValue.clear(); } else { @@ -510,6 +505,11 @@ void lcl_FilterBorders( pAllBorderState->maValue.clear(); } } + else + { + pAllBorderState->mnIndex = -1; + pAllBorderState->maValue.clear(); + } } } diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index 9971a3504016..480f23baf0c1 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -2158,56 +2158,56 @@ void XMLTextFieldExport::ExportFieldDeclarations( // else: no declarations element // DDE field masters: - if ( !aDdeName.empty() ) + if ( aDdeName.empty() ) + return; + + SvXMLElementExport aElem( GetExport(), + XML_NAMESPACE_TEXT, + XML_DDE_CONNECTION_DECLS, + true, true ); + + for (const auto& sName : aDdeName) { - SvXMLElementExport aElem( GetExport(), - XML_NAMESPACE_TEXT, - XML_DDE_CONNECTION_DECLS, - true, true ); + // get field master property set + Reference<XPropertySet> xPropSet; + Any aAny = xFieldMasterNameAccess->getByName(sName); + aAny >>= xPropSet; - for (const auto& sName : aDdeName) + // check if this connection is being used by a field + Reference<XPropertySet> xDummy; + if (GetDependentFieldPropertySet(xPropSet, xDummy)) { - // get field master property set - Reference<XPropertySet> xPropSet; - Any aAny = xFieldMasterNameAccess->getByName(sName); - aAny >>= xPropSet; - // check if this connection is being used by a field - Reference<XPropertySet> xDummy; - if (GetDependentFieldPropertySet(xPropSet, xDummy)) + ProcessString(XML_NAME, + GetStringProperty(gsPropertyName, xPropSet), + false, XML_NAMESPACE_OFFICE); + + // export elements; can't use ProcessString because + // elements are in office namespace + ProcessString(XML_DDE_APPLICATION, + GetStringProperty(gsPropertyDDECommandType, + xPropSet), + false, XML_NAMESPACE_OFFICE); + ProcessString(XML_DDE_TOPIC, + GetStringProperty(gsPropertyDDECommandFile, + xPropSet), + false, XML_NAMESPACE_OFFICE); + ProcessString(XML_DDE_ITEM, + GetStringProperty(gsPropertyDDECommandElement, + xPropSet), + false, XML_NAMESPACE_OFFICE); + bool bIsAutomaticUpdate = GetBoolProperty( + gsPropertyIsAutomaticUpdate, xPropSet); + if (bIsAutomaticUpdate) { - - ProcessString(XML_NAME, - GetStringProperty(gsPropertyName, xPropSet), - false, XML_NAMESPACE_OFFICE); - - // export elements; can't use ProcessString because - // elements are in office namespace - ProcessString(XML_DDE_APPLICATION, - GetStringProperty(gsPropertyDDECommandType, - xPropSet), - false, XML_NAMESPACE_OFFICE); - ProcessString(XML_DDE_TOPIC, - GetStringProperty(gsPropertyDDECommandFile, - xPropSet), - false, XML_NAMESPACE_OFFICE); - ProcessString(XML_DDE_ITEM, - GetStringProperty(gsPropertyDDECommandElement, - xPropSet), - false, XML_NAMESPACE_OFFICE); - bool bIsAutomaticUpdate = GetBoolProperty( - gsPropertyIsAutomaticUpdate, xPropSet); - if (bIsAutomaticUpdate) - { - GetExport().AddAttribute(XML_NAMESPACE_OFFICE, - XML_AUTOMATIC_UPDATE, - XML_TRUE); - } - - ExportElement(XML_DDE_CONNECTION_DECL, true); + GetExport().AddAttribute(XML_NAMESPACE_OFFICE, + XML_AUTOMATIC_UPDATE, + XML_TRUE); } - // else: no dependent field -> no export of field declaration + + ExportElement(XML_DDE_CONNECTION_DECL, true); } + // else: no dependent field -> no export of field declaration } // else: no declarations element } @@ -2574,22 +2574,22 @@ void XMLTextFieldExport::ProcessIntegerDef(enum XMLTokenEnum eName, void XMLTextFieldExport::ProcessNumberingType(sal_Int16 nNumberingType) { // process only if real format (not: like page descriptor) - if (NumberingType::PAGE_DESCRIPTOR != nNumberingType) - { - OUStringBuffer sTmp( 10 ); - // number type: num format - GetExport().GetMM100UnitConverter().convertNumFormat( sTmp, - nNumberingType ); - GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT, - sTmp.makeStringAndClear() ); - // and letter sync, if applicable - SvXMLUnitConverter::convertNumLetterSync( sTmp, nNumberingType ); - - if (!sTmp.isEmpty()) - { - GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC, - sTmp.makeStringAndClear() ); - } + if (NumberingType::PAGE_DESCRIPTOR == nNumberingType) + return; + + OUStringBuffer sTmp( 10 ); + // number type: num format + GetExport().GetMM100UnitConverter().convertNumFormat( sTmp, + nNumberingType ); + GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_FORMAT, + sTmp.makeStringAndClear() ); + // and letter sync, if applicable + SvXMLUnitConverter::convertNumLetterSync( sTmp, nNumberingType ); + + if (!sTmp.isEmpty()) + { + GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_NUM_LETTER_SYNC, + sTmp.makeStringAndClear() ); } // else: like page descriptor => ignore } diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 2d9c33812700..5d893626a5ed 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -636,18 +636,18 @@ void XMLSenderFieldImportContext::PrepareField( rPropSet->setPropertyValue(sPropertyFixed, Any(bFixed)); // set content if fixed - if (bFixed) + if (!bFixed) + return; + + // in organizer or styles-only mode: force update + if (GetImport().GetTextImport()->IsOrganizerMode() || + GetImport().GetTextImport()->IsStylesOnlyMode() ) { - // in organizer or styles-only mode: force update - if (GetImport().GetTextImport()->IsOrganizerMode() || - GetImport().GetTextImport()->IsStylesOnlyMode() ) - { - ForceUpdate(rPropSet); - } - else - { - rPropSet->setPropertyValue(sPropertyContent, Any(GetContent())); - } + ForceUpdate(rPropSet); + } + else + { + rPropSet->setPropertyValue(sPropertyContent, Any(GetContent())); } } @@ -699,19 +699,19 @@ void XMLAuthorFieldImportContext::PrepareField( rPropSet->setPropertyValue(sPropertyFixed, Any(bFixed)); // set content if fixed - if (bFixed) + if (!bFixed) + return; + + // organizer or styles-only mode: force update + if (GetImport().GetTextImport()->IsOrganizerMode() || + GetImport().GetTextImport()->IsStylesOnlyMode() ) { - // organizer or styles-only mode: force update - if (GetImport().GetTextImport()->IsOrganizerMode() || - GetImport().GetTextImport()->IsStylesOnlyMode() ) - { - ForceUpdate(rPropSet); - } - else - { - aAny <<= GetContent(); - rPropSet->setPropertyValue(sPropertyContent, aAny); - } + ForceUpdate(rPropSet); + } + else + { + aAny <<= GetContent(); + rPropSet->setPropertyValue(sPropertyContent, aAny); } } @@ -1500,39 +1500,39 @@ void XMLSimpleDocInfoImportContext::PrepareField( { // title field in Calc has no Fixed property Reference<XPropertySetInfo> xPropertySetInfo(rPropertySet->getPropertySetInfo()); - if (xPropertySetInfo->hasPropertyByName(sPropertyFixed)) - { - Any aAny; - rPropertySet->setPropertyValue(sPropertyFixed, Any(bFixed)); + if (!xPropertySetInfo->hasPropertyByName(sPropertyFixed)) + return; - // set Content and CurrentPresentation (if fixed) - if (bFixed) - { - // in organizer-mode or styles-only-mode, only force update - if (GetImport().GetTextImport()->IsOrganizerMode() || - GetImport().GetTextImport()->IsStylesOnlyMode() ) - { - ForceUpdate(rPropertySet); - } - else - { - // set content (author, if that's the name) and current - // presentation - aAny <<= GetContent(); + Any aAny; + rPropertySet->setPropertyValue(sPropertyFixed, Any(bFixed)); - if (bFixed && bHasAuthor) - { - rPropertySet->setPropertyValue(sPropertyAuthor, aAny); - } + // set Content and CurrentPresentation (if fixed) + if (!bFixed) + return; - if (bFixed && bHasContent) - { - rPropertySet->setPropertyValue(sPropertyContent, aAny); - } + // in organizer-mode or styles-only-mode, only force update + if (GetImport().GetTextImport()->IsOrganizerMode() || + GetImport().GetTextImport()->IsStylesOnlyMode() ) + { + ForceUpdate(rPropertySet); + } + else + { + // set content (author, if that's the name) and current + // presentation + aAny <<= GetContent(); - rPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny); - } + if (bFixed && bHasAuthor) + { + rPropertySet->setPropertyValue(sPropertyAuthor, aAny); } + + if (bFixed && bHasContent) + { + rPropertySet->setPropertyValue(sPropertyContent, aAny); + } + + rPropertySet->setPropertyValue(sPropertyCurrentPresentation, aAny); } } @@ -1622,20 +1622,20 @@ void XMLRevisionDocInfoImportContext::PrepareField( // set revision number // if fixed, if not in organizer-mode, if not in styles-only-mode - if (bFixed) + if (!bFixed) + return; + + if ( GetImport().GetTextImport()->IsOrganizerMode() || + GetImport().GetTextImport()->IsStylesOnlyMode() ) { - if ( GetImport().GetTextImport()->IsOrganizerMode() || - GetImport().GetTextImport()->IsStylesOnlyMode() ) - { - ForceUpdate(rPropertySet); - } - else + ForceUpdate(rPropertySet); + } + else + { + sal_Int32 nTmp; + if (::sax::Converter::convertNumber(nTmp, GetContent())) { - sal_Int32 nTmp; - if (::sax::Converter::convertNumber(nTmp, GetContent())) - { - rPropertySet->setPropertyValue(sPropertyRevision, Any(nTmp)); - } + rPropertySet->setPropertyValue(sPropertyRevision, Any(nTmp)); } } } @@ -2256,21 +2256,21 @@ void XMLCountFieldImportContext::PrepareField( // properties optional // (only page count, but do for all to save common implementation) - if (xPropertySet->getPropertySetInfo()-> + if (!xPropertySet->getPropertySetInfo()-> hasPropertyByName(sPropertyNumberingType)) + return; + + sal_Int16 nNumType; + if( bNumberFormatOK ) { - sal_Int16 nNumType; - if( bNumberFormatOK ) - { - nNumType= style::NumberingType::ARABIC; - GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, - sNumberFormat, - sLetterSync ); - } - else - nNumType = style::NumberingType::PAGE_DESCRIPTOR; - xPropertySet->setPropertyValue(sPropertyNumberingType, Any(nNumType)); + nNumType= style::NumberingType::ARABIC; + GetImport().GetMM100UnitConverter().convertNumFormat( nNumType, + sNumberFormat, + sLetterSync ); } + else + nNumType = style::NumberingType::PAGE_DESCRIPTOR; + xPropertySet->setPropertyValue(sPropertyNumberingType, Any(nNumType)); } const char* XMLCountFieldImportContext::MapTokenToServiceName( @@ -2777,54 +2777,54 @@ void XMLDdeFieldDeclImportContext::StartElement( } // valid data? - if (bNameOK && bCommandApplicationOK && bCommandTopicOK && bCommandItemOK) - { - // create DDE TextFieldMaster - Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(), - UNO_QUERY); - if( xFactory.is() ) + if (!(bNameOK && bCommandApplicationOK && bCommandTopicOK && bCommandItemOK)) + return; + + // create DDE TextFieldMaster + Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(), + UNO_QUERY); + if( !xFactory.is() ) + return; + + /* #i6432# There might be multiple occurrences of one DDE + declaration if it is used in more than one of + header/footer/body. createInstance will throw an exception if we + try to create the second, third, etc. instance of such a + declaration. Thus we ignore the exception. Otherwise this will + lead to an unloadable document. */ + try + { + Reference<XInterface> xIfc = + xFactory->createInstance(OUStringLiteral(sAPI_fieldmaster_prefix) + sAPI_dde); + if( xIfc.is() ) { - /* #i6432# There might be multiple occurrences of one DDE - declaration if it is used in more than one of - header/footer/body. createInstance will throw an exception if we - try to create the second, third, etc. instance of such a - declaration. Thus we ignore the exception. Otherwise this will - lead to an unloadable document. */ - try + Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY ); + if (xPropSet.is() && + xPropSet->getPropertySetInfo()->hasPropertyByName( + "DDECommandType")) { - Reference<XInterface> xIfc = - xFactory->createInstance(OUStringLiteral(sAPI_fieldmaster_prefix) + sAPI_dde); - if( xIfc.is() ) - { - Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY ); - if (xPropSet.is() && - xPropSet->getPropertySetInfo()->hasPropertyByName( - "DDECommandType")) - { - xPropSet->setPropertyValue(sAPI_name, Any(sName)); + xPropSet->setPropertyValue(sAPI_name, Any(sName)); - xPropSet->setPropertyValue("DDECommandType", Any(sCommandApplication)); + xPropSet->setPropertyValue("DDECommandType", Any(sCommandApplication)); - xPropSet->setPropertyValue("DDECommandFile", Any(sCommandTopic)); + xPropSet->setPropertyValue("DDECommandFile", Any(sCommandTopic)); - xPropSet->setPropertyValue("DDECommandElement", - Any(sCommandItem)); + xPropSet->setPropertyValue("DDECommandElement", + Any(sCommandItem)); - xPropSet->setPropertyValue("IsAutomaticUpdate", - Any(bUpdate)); - } - // else: ignore (can't get XPropertySet, or DDE - // properties are not supported) - } - // else: ignore - } - catch (const Exception&) - { - //ignore + xPropSet->setPropertyValue("IsAutomaticUpdate", + Any(bUpdate)); } + // else: ignore (can't get XPropertySet, or DDE + // properties are not supported) } // else: ignore } + catch (const Exception&) + { + //ignore + } + // else: ignore // else: ignore } @@ -2855,51 +2855,45 @@ void XMLDdeFieldImportContext::ProcessAttribute( void XMLDdeFieldImportContext::EndElement() { - if (bValid) - { - // find master - OUStringBuffer sBuf; - sBuf.append(sAPI_fieldmaster_prefix); - sBuf.append(sAPI_dde); - sBuf.append('.'); - sBuf.append(sName); - OUString sMasterName = sBuf.makeStringAndClear(); + if (!bValid) + return; - Reference<XTextFieldsSupplier> xTextFieldsSupp(GetImport().GetModel(), - UNO_QUERY); - Reference<container::XNameAccess> xFieldMasterNameAccess = - xTextFieldsSupp->getTextFieldMasters(); + // find master + OUString sMasterName = OUStringLiteral(sAPI_fieldmaster_prefix) + sAPI_dde + "." + sName; - if (xFieldMasterNameAccess->hasByName(sMasterName)) - { - Reference<XPropertySet> xMaster; - Any aAny = xFieldMasterNameAccess->getByName(sMasterName); - aAny >>= xMaster; - //apply the content to the master - xMaster->setPropertyValue( sPropertyContent, uno::makeAny( GetContent())); - // master exists: create text field and attach - Reference<XPropertySet> xField; - sBuf.append(sAPI_textfield_prefix); - sBuf.append(sAPI_dde); - if (CreateField(xField, sBuf.makeStringAndClear())) - { - Reference<XDependentTextField> xDepTextField(xField,UNO_QUERY); - xDepTextField->attachTextFieldMaster(xMaster); + Reference<XTextFieldsSupplier> xTextFieldsSupp(GetImport().GetModel(), + UNO_QUERY); + Reference<container::XNameAccess> xFieldMasterNameAccess = + xTextFieldsSupp->getTextFieldMasters(); - // attach field to document - Reference<XTextContent> xTextContent(xField, UNO_QUERY); - if (xTextContent.is()) - { - GetImportHelper().InsertTextContent(xTextContent); + if (!xFieldMasterNameAccess->hasByName(sMasterName)) + return; - // we're lucky. nothing else to prepare. - } - // else: fail, because text content could not be created - } - // else: fail, because field could not be created - } - // else: fail, because no master was found (faulty document?!) + Reference<XPropertySet> xMaster; + Any aAny = xFieldMasterNameAccess->getByName(sMasterName); + aAny >>= xMaster; + //apply the content to the master + xMaster->setPropertyValue( sPropertyContent, uno::makeAny( GetContent())); + // master exists: create text field and attach + Reference<XPropertySet> xField; + OUString sFieldName = OUStringLiteral(sAPI_textfield_prefix) + sAPI_dde; + if (!CreateField(xField, sFieldName)) + return; + + Reference<XDependentTextField> xDepTextField(xField,UNO_QUERY); + xDepTextField->attachTextFieldMaster(xMaster); + + // attach field to document + Reference<XTextContent> xTextContent(xField, UNO_QUERY); + if (xTextContent.is()) + { + GetImportHelper().InsertTextContent(xTextContent); + + // we're lucky. nothing else to prepare. } + // else: fail, because text content could not be created + // else: fail, because field could not be created + // else: fail, because no master was found (faulty document?!) // not valid: ignore } diff --git a/xmloff/source/text/txtftne.cxx b/xmloff/source/text/txtftne.cxx index b794392cb687..7c26040d344a 100644 --- a/xmloff/source/text/txtftne.cxx +++ b/xmloff/source/text/txtftne.cxx @@ -339,33 +339,33 @@ void XMLTextParagraphExport::exportTextFootnoteConfigurationHelper( true, true); // two element for footnote content - if (!bIsEndnote) - { - OUString sTmp; + if (bIsEndnote) + return; - // end notice / quo vadis - aAny = rFootnoteConfig->getPropertyValue(gsEndNotice); - aAny >>= sTmp; + OUString sTmp; - if (!sTmp.isEmpty()) - { - SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_TEXT, - XML_FOOTNOTE_CONTINUATION_NOTICE_FORWARD, - true, false); - GetExport().Characters(sTmp); - } + // end notice / quo vadis + aAny = rFootnoteConfig->getPropertyValue(gsEndNotice); + aAny >>= sTmp; - // begin notice / ergo sum - aAny = rFootnoteConfig->getPropertyValue(gsBeginNotice); - aAny >>= sTmp; + if (!sTmp.isEmpty()) + { + SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_TEXT, + XML_FOOTNOTE_CONTINUATION_NOTICE_FORWARD, + true, false); + GetExport().Characters(sTmp); + } - if (!sTmp.isEmpty()) - { - SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_TEXT, - XML_FOOTNOTE_CONTINUATION_NOTICE_BACKWARD, - true, false); - GetExport().Characters(sTmp); - } + // begin notice / ergo sum + aAny = rFootnoteConfig->getPropertyValue(gsBeginNotice); + aAny >>= sTmp; + + if (!sTmp.isEmpty()) + { + SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_TEXT, + XML_FOOTNOTE_CONTINUATION_NOTICE_BACKWARD, + true, false); + GetExport().Characters(sTmp); } } diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx index b258e5bdbff0..b2016d5fd88e 100644 --- a/xmloff/source/text/txtimppr.cxx +++ b/xmloff/source/text/txtimppr.cxx @@ -333,21 +333,21 @@ void lcl_SeparateBorder( else pBorderWidths[nIndex]->mnIndex = -1; - if( pBorders[nIndex] && pBorderWidths[nIndex] ) - { - table::BorderLine2 aBorderLine; - pBorders[nIndex]->maValue >>= aBorderLine; + if( !(pBorders[nIndex] && pBorderWidths[nIndex]) ) + return; - table::BorderLine2 aBorderLineWidth; - pBorderWidths[nIndex]->maValue >>= aBorderLineWidth; + table::BorderLine2 aBorderLine; + pBorders[nIndex]->maValue >>= aBorderLine; - aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; - aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; - aBorderLine.LineDistance = aBorderLineWidth.LineDistance; - aBorderLine.LineWidth = aBorderLineWidth.LineWidth; + table::BorderLine2 aBorderLineWidth; + pBorderWidths[nIndex]->maValue >>= aBorderLineWidth; - pBorders[nIndex]->maValue <<= aBorderLine; - } + aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; + aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; + aBorderLine.LineDistance = aBorderLineWidth.LineDistance; + aBorderLine.LineWidth = aBorderLineWidth.LineWidth; + + pBorders[nIndex]->maValue <<= aBorderLine; } } @@ -814,32 +814,32 @@ void XMLTextImportPropertyMapper::finished( } } - if( bHasAnyWidth ) + if( !bHasAnyWidth ) + return; + + if( nWidthTypeIndex == -2 ) { - if( nWidthTypeIndex == -2 ) + const_cast < XMLTextImportPropertyMapper * > ( this ) + ->nWidthTypeIndex = -1; + sal_Int32 nCount = getPropertySetMapper()->GetEntryCount(); + for( sal_Int32 j=0; j < nCount; j++ ) { - const_cast < XMLTextImportPropertyMapper * > ( this ) - ->nWidthTypeIndex = -1; - sal_Int32 nCount = getPropertySetMapper()->GetEntryCount(); - for( sal_Int32 j=0; j < nCount; j++ ) + if( CTF_FRAMEWIDTH_TYPE == getPropertySetMapper() + ->GetEntryContextId( j ) ) { - if( CTF_FRAMEWIDTH_TYPE == getPropertySetMapper() - ->GetEntryContextId( j ) ) - { - const_cast < XMLTextImportPropertyMapper * > ( this ) - ->nWidthTypeIndex = j; - break; - } + const_cast < XMLTextImportPropertyMapper * > ( this ) + ->nWidthTypeIndex = j; + break; } } - if( nWidthTypeIndex != -1 ) - { - XMLPropertyState aSizeTypeState( nWidthTypeIndex ); - aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinWidth - ? SizeType::MIN - : SizeType::FIX); - rProperties.push_back( aSizeTypeState ); - } + } + if( nWidthTypeIndex != -1 ) + { + XMLPropertyState aSizeTypeState( nWidthTypeIndex ); + aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinWidth + ? SizeType::MIN + : SizeType::FIX); + rProperties.push_back( aSizeTypeState ); } // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER diff --git a/xmloff/source/text/txtlists.cxx b/xmloff/source/text/txtlists.cxx index a3831c735b4c..3a600427122c 100644 --- a/xmloff/source/text/txtlists.cxx +++ b/xmloff/source/text/txtlists.cxx @@ -126,21 +126,21 @@ void XMLTextListsHelper::KeepListAsProcessed( const OUString& sListId, msListStyleOfLastProcessedList = sListStyleName; // Inconsistent behavior regarding lists (#i92811#) - if ( !sListStyleDefaultListId.isEmpty()) + if ( sListStyleDefaultListId.isEmpty()) + return; + + if ( !mpMapListIdToListStyleDefaultListId ) { - if ( !mpMapListIdToListStyleDefaultListId ) - { - mpMapListIdToListStyleDefaultListId = std::make_unique<tMapForLists>(); - } + mpMapListIdToListStyleDefaultListId = std::make_unique<tMapForLists>(); + } - if ( mpMapListIdToListStyleDefaultListId->find( sListStyleName ) == - mpMapListIdToListStyleDefaultListId->end() ) - { - ::std::pair< OUString, OUString > - aListIdMapData( sListId, sListStyleDefaultListId ); - (*mpMapListIdToListStyleDefaultListId)[ sListStyleName ] = - aListIdMapData; - } + if ( mpMapListIdToListStyleDefaultListId->find( sListStyleName ) == + mpMapListIdToListStyleDefaultListId->end() ) + { + ::std::pair< OUString, OUString > + aListIdMapData( sListId, sListStyleDefaultListId ); + (*mpMapListIdToListStyleDefaultListId)[ sListStyleName ] = + aListIdMapData; } } diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 7ad3b2da4220..342aac84a7ee 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -567,105 +567,105 @@ void XMLTextParagraphExport::Add( XmlStyleFamily nFamily, } } - if( !aPropStates.empty() ) + if( aPropStates.empty() ) + return; + + Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo()); + OUString sParent, sCondParent; + sal_uInt16 nIgnoreProps = 0; + switch( nFamily ) { - Reference< XPropertySetInfo > xPropSetInfo(rPropSet->getPropertySetInfo()); - OUString sParent, sCondParent; - sal_uInt16 nIgnoreProps = 0; - switch( nFamily ) + case XmlStyleFamily::TEXT_PARAGRAPH: + if( xPropSetInfo->hasPropertyByName( gsParaStyleName ) ) { - case XmlStyleFamily::TEXT_PARAGRAPH: - if( xPropSetInfo->hasPropertyByName( gsParaStyleName ) ) - { - rPropSet->getPropertyValue( gsParaStyleName ) >>= sParent; - } - if( xPropSetInfo->hasPropertyByName( gsParaConditionalStyleName ) ) - { - rPropSet->getPropertyValue( gsParaConditionalStyleName ) >>= sCondParent; - } - if( xPropSetInfo->hasPropertyByName( gsNumberingRules ) ) + rPropSet->getPropertyValue( gsParaStyleName ) >>= sParent; + } + if( xPropSetInfo->hasPropertyByName( gsParaConditionalStyleName ) ) + { + rPropSet->getPropertyValue( gsParaConditionalStyleName ) >>= sCondParent; + } + if( xPropSetInfo->hasPropertyByName( gsNumberingRules ) ) + { + Reference < XIndexReplace > xNumRule(rPropSet->getPropertyValue( gsNumberingRules ), uno::UNO_QUERY); + if( xNumRule.is() && xNumRule->getCount() ) { - Reference < XIndexReplace > xNumRule(rPropSet->getPropertyValue( gsNumberingRules ), uno::UNO_QUERY); - if( xNumRule.is() && xNumRule->getCount() ) + Reference < XNamed > xNamed( xNumRule, UNO_QUERY ); + OUString sName; + if( xNamed.is() ) + sName = xNamed->getName(); + bool bAdd = sName.isEmpty(); + if( !bAdd ) { - Reference < XNamed > xNamed( xNumRule, UNO_QUERY ); - OUString sName; - if( xNamed.is() ) - sName = xNamed->getName(); - bool bAdd = sName.isEmpty(); - if( !bAdd ) + Reference < XPropertySet > xNumPropSet( xNumRule, + UNO_QUERY ); + if( xNumPropSet.is() && + xNumPropSet->getPropertySetInfo() + ->hasPropertyByName( "IsAutomatic" ) ) { - Reference < XPropertySet > xNumPropSet( xNumRule, - UNO_QUERY ); - if( xNumPropSet.is() && - xNumPropSet->getPropertySetInfo() - ->hasPropertyByName( "IsAutomatic" ) ) - { - bAdd = *o3tl::doAccess<bool>(xNumPropSet->getPropertyValue( "IsAutomatic" )); - // Check on outline style (#i73361#) - if ( bAdd && - xNumPropSet->getPropertySetInfo() - ->hasPropertyByName( "NumberingIsOutline" ) ) - { - bAdd = !(*o3tl::doAccess<bool>(xNumPropSet->getPropertyValue( "NumberingIsOutline" ))); - } - } - else + bAdd = *o3tl::doAccess<bool>(xNumPropSet->getPropertyValue( "IsAutomatic" )); + // Check on outline style (#i73361#) + if ( bAdd && + xNumPropSet->getPropertySetInfo() + ->hasPropertyByName( "NumberingIsOutline" ) ) { - bAdd = true; + bAdd = !(*o3tl::doAccess<bool>(xNumPropSet->getPropertyValue( "NumberingIsOutline" ))); } } - if( bAdd ) - maListAutoPool.Add( xNumRule ); + else + { + bAdd = true; + } } + if( bAdd ) + maListAutoPool.Add( xNumRule ); } - break; - case XmlStyleFamily::TEXT_TEXT: + } + break; + case XmlStyleFamily::TEXT_TEXT: + { + // Get parent and remove hyperlinks (they aren't of interest) + rtl::Reference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper()); + for( ::std::vector< XMLPropertyState >::iterator i(aPropStates.begin()); + nIgnoreProps < 2 && i != aPropStates.end(); ) { - // Get parent and remove hyperlinks (they aren't of interest) - rtl::Reference< XMLPropertySetMapper > xPM(xPropMapper->getPropertySetMapper()); - for( ::std::vector< XMLPropertyState >::iterator i(aPropStates.begin()); - nIgnoreProps < 2 && i != aPropStates.end(); ) + if( i->mnIndex == -1 ) { - if( i->mnIndex == -1 ) - { - ++i; - continue; - } + ++i; + continue; + } - switch( xPM->GetEntryContextId(i->mnIndex) ) - { - case CTF_CHAR_STYLE_NAME: - case CTF_HYPERLINK_URL: - i->mnIndex = -1; - nIgnoreProps++; - i = aPropStates.erase( i ); - break; - default: - ++i; - break; - } + switch( xPM->GetEntryContextId(i->mnIndex) ) + { + case CTF_CHAR_STYLE_NAME: + case CTF_HYPERLINK_URL: + i->mnIndex = -1; + nIgnoreProps++; + i = aPropStates.erase( i ); + break; + default: + ++i; + break; } } - break; - case XmlStyleFamily::TEXT_FRAME: - if( xPropSetInfo->hasPropertyByName( gsFrameStyleName ) ) - { - rPropSet->getPropertyValue( gsFrameStyleName ) >>= sParent; - } - break; - case XmlStyleFamily::TEXT_SECTION: - case XmlStyleFamily::TEXT_RUBY: - ; // section styles have no parents - break; - default: break; } - if (aPropStates.size() - nIgnoreProps) + break; + case XmlStyleFamily::TEXT_FRAME: + if( xPropSetInfo->hasPropertyByName( gsFrameStyleName ) ) { - GetAutoStylePool().Add( nFamily, sParent, aPropStates, bDontSeek ); - if( !sCondParent.isEmpty() && sParent != sCondParent ) - GetAutoStylePool().Add( nFamily, sCondParent, aPropStates ); + rPropSet->getPropertyValue( gsFrameStyleName ) >>= sParent; } + break; + case XmlStyleFamily::TEXT_SECTION: + case XmlStyleFamily::TEXT_RUBY: + ; // section styles have no parents + break; + default: break; + } + if (aPropStates.size() - nIgnoreProps) + { + GetAutoStylePool().Add( nFamily, sParent, aPropStates, bDontSeek ); + if( !sCondParent.isEmpty() && sParent != sCondParent ) + GetAutoStylePool().Add( nFamily, sCondParent, aPropStates ); } } @@ -728,33 +728,33 @@ void XMLTextParagraphExport::Add( XmlStyleFamily nFamily, } } - if( !aPropStates.empty() ) + if( aPropStates.empty() ) + return; + + OUString sParent, sCondParent; + switch( nFamily ) { - OUString sParent, sCondParent; - switch( nFamily ) + case XmlStyleFamily::TEXT_PARAGRAPH: + if( rPropSetHelper.hasProperty( PARA_STYLE_NAME_AUTO ) ) { - case XmlStyleFamily::TEXT_PARAGRAPH: - if( rPropSetHelper.hasProperty( PARA_STYLE_NAME_AUTO ) ) - { - rPropSetHelper.getValue( PARA_STYLE_NAME_AUTO, rPropSet, - true ) >>= sParent; - } - if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO ) ) - { - rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO, - rPropSet, true ) >>= sCondParent; - } - - break; - default: break; + rPropSetHelper.getValue( PARA_STYLE_NAME_AUTO, rPropSet, + true ) >>= sParent; } - - if( std::any_of( aPropStates.begin(), aPropStates.end(), lcl_validPropState ) ) + if( rPropSetHelper.hasProperty( PARA_CONDITIONAL_STYLE_NAME_AUTO ) ) { - GetAutoStylePool().Add( nFamily, sParent, aPropStates ); - if( !sCondParent.isEmpty() && sParent != sCondParent ) - GetAutoStylePool().Add( nFamily, sCondParent, aPropStates ); + rPropSetHelper.getValue( PARA_CONDITIONAL_STYLE_NAME_AUTO, + rPropSet, true ) >>= sCondParent; } + + break; + default: break; + } + + if( std::any_of( aPropStates.begin(), aPropStates.end(), lcl_validPropState ) ) + { + GetAutoStylePool().Add( nFamily, sParent, aPropStates ); + if( !sCondParent.isEmpty() && sParent != sCondParent ) + GetAutoStylePool().Add( nFamily, sCondParent, aPropStates ); } } @@ -2430,19 +2430,19 @@ void XMLTextParagraphExport::exportTextField( { Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY ); // non-Writer apps need not support Property TextField, so test first - if (xPropSet->getPropertySetInfo()->hasPropertyByName( gsTextField )) + if (!xPropSet->getPropertySetInfo()->hasPropertyByName( gsTextField )) + return; + + Reference < XTextField > xTxtFld(xPropSet->getPropertyValue( gsTextField ), uno::UNO_QUERY); + SAL_WARN_IF( !xTxtFld.is(), "xmloff", "text field missing" ); + if( xTxtFld.is() ) { - Reference < XTextField > xTxtFld(xPropSet->getPropertyValue( gsTextField ), uno::UNO_QUERY); - SAL_WARN_IF( !xTxtFld.is(), "xmloff", "text field missing" ); - if( xTxtFld.is() ) - { - exportTextField(xTxtFld, bAutoStyles, bIsProgress, true, pPrevCharIsSpace); - } - else - { - // write only characters - GetExport().Characters(rTextRange->getString()); - } + exportTextField(xTxtFld, bAutoStyles, bIsProgress, true, pPrevCharIsSpace); + } + else + { + // write only characters + GetExport().Characters(rTextRange->getString()); } } @@ -2484,63 +2484,63 @@ void XMLTextParagraphExport::exportTextMark( // This basically meaningless formatting will now been thrown away // (aka cleaned up), since mib said: ... dvo - if (!bAutoStyles) - { - // name element - Reference<XNamed> xName(rPropSet->getPropertyValue(rProperty), UNO_QUERY); - GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, - xName->getName()); + if (bAutoStyles) + return; - // start, end, or point-reference? - sal_Int8 nElement; - if( *o3tl::doAccess<bool>(rPropSet->getPropertyValue(gsIsCollapsed)) ) - { - nElement = 0; - } - else - { - nElement = *o3tl::doAccess<bool>(rPropSet->getPropertyValue(gsIsStart)) ? 1 : 2; - } + // name element + Reference<XNamed> xName(rPropSet->getPropertyValue(rProperty), UNO_QUERY); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NAME, + xName->getName()); - // bookmark, bookmark-start: xml:id and RDFa for RDF metadata - if( nElement < 2 ) { - GetExport().AddAttributeXmlId(xName); - const uno::Reference<text::XTextContent> xTextContent( - xName, uno::UNO_QUERY_THROW); - GetExport().AddAttributesRDFa(xTextContent); - } + // start, end, or point-reference? + sal_Int8 nElement; + if( *o3tl::doAccess<bool>(rPropSet->getPropertyValue(gsIsCollapsed)) ) + { + nElement = 0; + } + else + { + nElement = *o3tl::doAccess<bool>(rPropSet->getPropertyValue(gsIsStart)) ? 1 : 2; + } - // bookmark-start: add attributes hidden and condition - if (nElement == 1) + // bookmark, bookmark-start: xml:id and RDFa for RDF metadata + if( nElement < 2 ) { + GetExport().AddAttributeXmlId(xName); + const uno::Reference<text::XTextContent> xTextContent( + xName, uno::UNO_QUERY_THROW); + GetExport().AddAttributesRDFa(xTextContent); + } + + // bookmark-start: add attributes hidden and condition + if (nElement == 1) + { + Reference<XPropertySet> bkmkProps(rPropSet->getPropertyValue(rProperty), UNO_QUERY); + Reference<XPropertySetInfo> bkmkPropInfo = bkmkProps->getPropertySetInfo(); + OUString sHidden("BookmarkHidden"); + if (bkmkPropInfo->hasPropertyByName(sHidden)) { - Reference<XPropertySet> bkmkProps(rPropSet->getPropertyValue(rProperty), UNO_QUERY); - Reference<XPropertySetInfo> bkmkPropInfo = bkmkProps->getPropertySetInfo(); - OUString sHidden("BookmarkHidden"); - if (bkmkPropInfo->hasPropertyByName(sHidden)) + bool bHidden = false; + bkmkProps->getPropertyValue(sHidden) >>= bHidden; + if (bHidden) { - bool bHidden = false; - bkmkProps->getPropertyValue(sHidden) >>= bHidden; - if (bHidden) + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "hidden", "true"); + OUString sCondition("BookmarkCondition"); + if (bkmkPropInfo->hasPropertyByName(sCondition)) { - GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "hidden", "true"); - OUString sCondition("BookmarkCondition"); - if (bkmkPropInfo->hasPropertyByName(sCondition)) - { - OUString sBookmarkCondition; - bkmkProps->getPropertyValue(sCondition) >>= sBookmarkCondition; - GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "condition", sBookmarkCondition); - } + OUString sBookmarkCondition; + bkmkProps->getPropertyValue(sCondition) >>= sBookmarkCondition; + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, "condition", sBookmarkCondition); } } } - - // export element - assert(pElements != nullptr); - assert(0 <= nElement && nElement <= 2); - SvXMLElementExport aElem(GetExport(), - XML_NAMESPACE_TEXT, pElements[nElement], - false, false); } + + // export element + assert(pElements != nullptr); + assert(0 <= nElement && nElement <= 2); + SvXMLElementExport aElem(GetExport(), + XML_NAMESPACE_TEXT, pElements[nElement], + false, false); // else: no styles. (see above) } @@ -3645,25 +3645,25 @@ void XMLTextParagraphExport::exportTextDeclarations() // get XPropertySet from the document and ask for AutoMarkFileURL. // If it exists, export the auto-mark-file element. Reference<XPropertySet> xPropertySet( GetExport().GetModel(), UNO_QUERY ); - if (xPropertySet.is()) + if (!xPropertySet.is()) + return; + + OUString sUrl; + OUString sIndexAutoMarkFileURL( + "IndexAutoMarkFileURL"); + if (!xPropertySet->getPropertySetInfo()->hasPropertyByName( + sIndexAutoMarkFileURL)) + return; + + xPropertySet->getPropertyValue(sIndexAutoMarkFileURL) >>= sUrl; + if (!sUrl.isEmpty()) { - OUString sUrl; - OUString sIndexAutoMarkFileURL( - "IndexAutoMarkFileURL"); - if (xPropertySet->getPropertySetInfo()->hasPropertyByName( - sIndexAutoMarkFileURL)) - { - xPropertySet->getPropertyValue(sIndexAutoMarkFileURL) >>= sUrl; - if (!sUrl.isEmpty()) - { - GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, - GetExport().GetRelativeReference(sUrl) ); - SvXMLElementExport aAutoMarkElement( - GetExport(), XML_NAMESPACE_TEXT, - XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE, - true, true ); - } - } + GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, + GetExport().GetRelativeReference(sUrl) ); + SvXMLElementExport aAutoMarkElement( + GetExport(), XML_NAMESPACE_TEXT, + XML_ALPHABETICAL_INDEX_AUTO_MARK_FILE, + true, true ); } } diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx index 4f351d1b0787..f957f216fc0e 100644 --- a/xmloff/source/text/txtparai.cxx +++ b/xmloff/source/text/txtparai.cxx @@ -117,27 +117,27 @@ XMLCharContext::XMLCharContext( ,m_nCount(1) ,m_c(c) { - if( bCount ) + if( !bCount ) + return; + + const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap(); + sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for( sal_Int16 i=0; i < nAttrCount; i++ ) { - const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap(); - sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for( sal_Int16 i=0; i < nAttrCount; i++ ) - { - const OUString& rAttrName = xAttrList->getNameByIndex( i ); + const OUString& rAttrName = xAttrList->getNameByIndex( i ); - OUString aLocalName; - sal_uInt16 nPrefix =rMap.GetKeyByAttrName( rAttrName,&aLocalName ); - if( XML_NAMESPACE_TEXT == nPrefix && - IsXMLToken( aLocalName, XML_C ) ) + OUString aLocalName; + sal_uInt16 nPrefix =rMap.GetKeyByAttrName( rAttrName,&aLocalName ); + if( XML_NAMESPACE_TEXT == nPrefix && + IsXMLToken( aLocalName, XML_C ) ) + { + sal_Int32 nTmp = xAttrList->getValueByIndex(i).toInt32(); + if( nTmp > 0 ) { - sal_Int32 nTmp = xAttrList->getValueByIndex(i).toInt32(); - if( nTmp > 0 ) - { - if( nTmp > SAL_MAX_UINT16 ) - m_nCount = SAL_MAX_UINT16; - else - m_nCount = static_cast<sal_uInt16>(nTmp); - } + if( nTmp > SAL_MAX_UINT16 ) + m_nCount = SAL_MAX_UINT16; + else + m_nCount = static_cast<sal_uInt16>(nTmp); } } } @@ -153,24 +153,24 @@ XMLCharContext::XMLCharContext( ,m_nCount(1) ,m_c(c) { - if( bCount ) + if( !bCount ) + return; + + for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) { - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + if( aIter.getToken() == XML_ELEMENT(TEXT, XML_C) ) { - if( aIter.getToken() == XML_ELEMENT(TEXT, XML_C) ) + sal_Int32 nTmp = aIter.toInt32(); + if( nTmp > 0 ) { - sal_Int32 nTmp = aIter.toInt32(); - if( nTmp > 0 ) - { - if( nTmp > SAL_MAX_UINT16 ) - m_nCount = SAL_MAX_UINT16; - else - m_nCount = static_cast<sal_uInt16>(nTmp); - } + if( nTmp > SAL_MAX_UINT16 ) + m_nCount = SAL_MAX_UINT16; + else + m_nCount = static_cast<sal_uInt16>(nTmp); } - else - SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << " = " << aIter.toString()); } + else + SAL_WARN("xmloff", "unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) << " = " << aIter.toString()); } } @@ -352,23 +352,23 @@ XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl( OUString sName; // borrow from XMLStartReferenceContext_Impl - if (XMLStartReferenceContext_Impl::FindName(GetImport(), xAttrList, sName)) + if (!XMLStartReferenceContext_Impl::FindName(GetImport(), xAttrList, sName)) + return; + + // search for reference start + for (const auto& rHintPtr : rHints.GetHints()) { - // search for reference start - for (const auto& rHintPtr : rHints.GetHints()) + XMLHint_Impl *const pHint = rHintPtr.get(); + if ( pHint->IsReference() && + sName == static_cast<XMLReferenceHint_Impl *>(pHint)->GetRefName() ) { - XMLHint_Impl *const pHint = rHintPtr.get(); - if ( pHint->IsReference() && - sName == static_cast<XMLReferenceHint_Impl *>(pHint)->GetRefName() ) - { - // set end and stop searching - pHint->SetEnd(GetImport().GetTextImport()-> - GetCursor()->getStart() ); - break; - } + // set end and stop searching + pHint->SetEnd(GetImport().GetTextImport()-> + GetCursor()->getStart() ); + break; } - // else: no start (in this paragraph) -> ignore } + // else: no start (in this paragraph) -> ignore } namespace { diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx index db30837502b4..b80c23131f6d 100644 --- a/xmloff/source/text/txtstyli.cxx +++ b/xmloff/source/text/txtstyli.cxx @@ -355,23 +355,23 @@ void XMLTextStyleContext::Finish( bool bOverwrite ) } } - if (m_bHasMasterPageName) + if (!m_bHasMasterPageName) + return; + + OUString sDisplayName( + GetImport().GetStyleDisplayName( + XmlStyleFamily::MASTER_PAGE, m_sMasterPageName)); + // The families container must exist + const Reference < XNameContainer >& rPageStyles = + GetImport().GetTextImport()->GetPageStyles(); + + OUString const sPageDescName("PageDescName"); + if( ( sDisplayName.isEmpty() || + (rPageStyles.is() && + rPageStyles->hasByName( sDisplayName )) ) && + xPropSetInfo->hasPropertyByName( sPageDescName ) ) { - OUString sDisplayName( - GetImport().GetStyleDisplayName( - XmlStyleFamily::MASTER_PAGE, m_sMasterPageName)); - // The families container must exist - const Reference < XNameContainer >& rPageStyles = - GetImport().GetTextImport()->GetPageStyles(); - - OUString const sPageDescName("PageDescName"); - if( ( sDisplayName.isEmpty() || - (rPageStyles.is() && - rPageStyles->hasByName( sDisplayName )) ) && - xPropSetInfo->hasPropertyByName( sPageDescName ) ) - { - xPropSet->setPropertyValue( sPageDescName, Any(sDisplayName) ); - } + xPropSet->setPropertyValue( sPageDescName, Any(sDisplayName) ); } } diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx index e348fbb6ff46..833663c88ce1 100644 --- a/xmloff/source/text/txtvfldi.cxx +++ b/xmloff/source/text/txtvfldi.cxx @@ -713,96 +713,97 @@ XMLVariableDeclImportContext::XMLVariableDeclImportContext( sal_Int8 nNumLevel(-1); OUString sName; - if ( (XML_NAMESPACE_TEXT == nPrfx) && - ( ( IsXMLToken( rLocalName, XML_SEQUENCE_DECL )) || - ( IsXMLToken( rLocalName, XML_VARIABLE_DECL)) || - ( IsXMLToken( rLocalName, XML_USER_FIELD_DECL)) )) { + if ( (XML_NAMESPACE_TEXT != nPrfx) || + !( ( IsXMLToken( rLocalName, XML_SEQUENCE_DECL )) || + ( IsXMLToken( rLocalName, XML_VARIABLE_DECL)) || + ( IsXMLToken( rLocalName, XML_USER_FIELD_DECL)) ) ) + return; - // TODO: check validity (need name!) - // parse attributes - sal_Int16 nLength = xAttrList->getLength(); - for(sal_Int16 i=0; i<nLength; i++) { + // TODO: check validity (need name!) - OUString sLocalName; - sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). - GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName ); + // parse attributes + sal_Int16 nLength = xAttrList->getLength(); + for(sal_Int16 i=0; i<nLength; i++) { - sal_uInt16 nToken = rHlp. - GetTextFieldAttrTokenMap().Get(nPrefix, sLocalName); + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName ); - switch (nToken) - { - case XML_TOK_TEXTFIELD_NAME: - sName = xAttrList->getValueByIndex(i); - break; - case XML_TOK_TEXTFIELD_NUMBERING_LEVEL: - { - sal_Int32 nLevel; - bool const bRet = ::sax::Converter::convertNumber( - nLevel, xAttrList->getValueByIndex(i), 0, - GetImport().GetTextImport()->GetChapterNumbering()-> - getCount()); - if (bRet) - { - nNumLevel = static_cast< sal_Int8 >( nLevel-1 ); // API numbers -1..9 - } - break; - } - case XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR: - cSeparationChar = - static_cast<char>(xAttrList->getValueByIndex(i).toChar()); - break; - - default: - // delegate to value helper - aValueHelper.ProcessAttribute(nToken, - xAttrList->getValueByIndex(i)); - break; - } - } + sal_uInt16 nToken = rHlp. + GetTextFieldAttrTokenMap().Get(nPrefix, sLocalName); - Reference<XPropertySet> xFieldMaster; - if (FindFieldMaster(xFieldMaster, GetImport(), rHlp, - sName, eVarType)) + switch (nToken) { - // now we have a field master: process attributes! - Any aAny; - - switch (eVarType) - { - case VarTypeSequence: - xFieldMaster->setPropertyValue("ChapterNumberingLevel", Any(nNumLevel)); - - if (nNumLevel >= 0) - { - OUString sStr(&cSeparationChar, 1); - xFieldMaster->setPropertyValue( - "NumberingSeparator", Any(sStr)); - } + case XML_TOK_TEXTFIELD_NAME: + sName = xAttrList->getValueByIndex(i); break; - case VarTypeSimple: + case XML_TOK_TEXTFIELD_NUMBERING_LEVEL: + { + sal_Int32 nLevel; + bool const bRet = ::sax::Converter::convertNumber( + nLevel, xAttrList->getValueByIndex(i), 0, + GetImport().GetTextImport()->GetChapterNumbering()-> + getCount()); + if (bRet) { - // set string or non-string SubType (#93192#) - // The SubType was already set in the FindFieldMaster - // method, but it needs to be adjusted if it's a string. - aAny <<= aValueHelper.IsStringValue() - ? SetVariableType::STRING : SetVariableType::VAR; - xFieldMaster->setPropertyValue(sAPI_sub_type, aAny); + nNumLevel = static_cast< sal_Int8 >( nLevel-1 ); // API numbers -1..9 } break; - case VarTypeUserField: - { - bool bTmp = !aValueHelper.IsStringValue(); - xFieldMaster->setPropertyValue("IsExpression", Any(bTmp)); - aValueHelper.PrepareField(xFieldMaster); - break; } + case XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR: + cSeparationChar = + static_cast<char>(xAttrList->getValueByIndex(i).toChar()); + break; + default: - OSL_FAIL("unknown varfield type"); - } // switch - } // else: no field master found/constructed - } // else: no sequence-decl + // delegate to value helper + aValueHelper.ProcessAttribute(nToken, + xAttrList->getValueByIndex(i)); + break; + } + } + + Reference<XPropertySet> xFieldMaster; + if (!FindFieldMaster(xFieldMaster, GetImport(), rHlp, + sName, eVarType)) + return; + + // now we have a field master: process attributes! + Any aAny; + + switch (eVarType) + { + case VarTypeSequence: + xFieldMaster->setPropertyValue("ChapterNumberingLevel", Any(nNumLevel)); + + if (nNumLevel >= 0) + { + OUString sStr(&cSeparationChar, 1); + xFieldMaster->setPropertyValue( + "NumberingSeparator", Any(sStr)); + } + break; + case VarTypeSimple: + { + // set string or non-string SubType (#93192#) + // The SubType was already set in the FindFieldMaster + // method, but it needs to be adjusted if it's a string. + aAny <<= aValueHelper.IsStringValue() + ? SetVariableType::STRING : SetVariableType::VAR; + xFieldMaster->setPropertyValue(sAPI_sub_type, aAny); + } + break; + case VarTypeUserField: + { + bool bTmp = !aValueHelper.IsStringValue(); + xFieldMaster->setPropertyValue("IsExpression", Any(bTmp)); + aValueHelper.PrepareField(xFieldMaster); + break; + } + default: + OSL_FAIL("unknown varfield type"); + } // switch } |