diff options
-rw-r--r-- | xmloff/inc/xmloff/txtimp.hxx | 27 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextMarkImportContext.cxx | 55 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 18 |
3 files changed, 64 insertions, 36 deletions
diff --git a/xmloff/inc/xmloff/txtimp.hxx b/xmloff/inc/xmloff/txtimp.hxx index 2cdbaffbbde3..da181b463b3f 100644 --- a/xmloff/inc/xmloff/txtimp.hxx +++ b/xmloff/inc/xmloff/txtimp.hxx @@ -36,6 +36,8 @@ #include <vector> #include <memory> #include <boost/utility.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/shared_ptr.hpp> #include <tools/list.hxx> #include <xmloff/xmlictxt.hxx> @@ -66,6 +68,10 @@ class XMLFontStylesContext; template<class A> class XMLPropertyBackpatcher; class XMLEventsImportContext; +namespace xmloff { + struct ParsedRDFaAttributes; +} + namespace com { namespace sun { namespace star { namespace text { class XText; class XTextCursor; class XTextRange; class XTextContent; } namespace frame { class XModel; } @@ -417,13 +423,14 @@ class XMLOFF_DLLPUBLIC XMLTextImportHelper : public UniRefBase, ::std::vector< ::rtl::OUString >* mpOutlineStylesCandidates; // <-- + + // start range, xml:id, RDFa stuff + typedef ::boost::tuple< + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange>, + ::rtl::OUString, ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > > + BookmarkMapEntry_t; /// start ranges for open bookmarks - ::std::map< ::rtl::OUString, - // start range, xml:id - ::std::pair< - ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange>, - ::rtl::OUString>, + ::std::map< ::rtl::OUString, BookmarkMapEntry_t, ::comphelper::UStringLess> aBookmarkStartRanges; typedef ::std::vector< ::rtl::OUString> BookmarkVector_t; @@ -757,14 +764,18 @@ public: const ::rtl::OUString sName, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange> & rRange, - const ::rtl::OUString & i_rXmlId); + ::rtl::OUString const& i_rXmlId, + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & + i_rpRDFaAttributes); /// process the start of a range reference sal_Bool FindAndRemoveBookmarkStartRange( const ::rtl::OUString sName, ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange> & o_rRange, - ::rtl::OUString& o_rXmlId); + ::rtl::OUString & o_rXmlId, + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & + o_rpRDFaAttributes); ::rtl::OUString FindActiveBookmarkName(); ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > GetRangeFor(::rtl::OUString &sName); diff --git a/xmloff/source/text/XMLTextMarkImportContext.cxx b/xmloff/source/text/XMLTextMarkImportContext.cxx index dd16ab983a7b..b817a64e6788 100644 --- a/xmloff/source/text/XMLTextMarkImportContext.cxx +++ b/xmloff/source/text/XMLTextMarkImportContext.cxx @@ -48,10 +48,13 @@ #include <com/sun/star/text/XFormField.hpp> +#include "RDFaImportHelper.hxx" + using ::rtl::OUString; using ::rtl::OUStringBuffer; +using namespace ::com::sun::star; using namespace ::com::sun::star::text; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -112,7 +115,6 @@ XMLTextMarkImportContext::XMLTextMarkImportContext( const OUString& rLocalName ) : SvXMLImportContext(rImport, nPrefix, rLocalName) , m_rHelper(rHlp) - , m_bHaveAbout(false) { } @@ -162,13 +164,13 @@ void XMLTextMarkImportContext::EndElement() { SvXMLImportContext::EndElement(); - const OUString sAPI_reference_mark( + static const OUString sAPI_reference_mark( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.ReferenceMark")); - const OUString sAPI_bookmark( + static const OUString sAPI_bookmark( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Bookmark")); - const OUString sAPI_fieldmark( + static const OUString sAPI_fieldmark( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Fieldmark")); - const OUString sAPI_formfieldmark( + static const OUString sAPI_formfieldmark( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.FormFieldmark")); if (m_sBookmarkName.getLength() > 0) @@ -199,13 +201,6 @@ void XMLTextMarkImportContext::EndElement() m_sBookmarkName, m_rHelper.GetCursorAsRange()->getStart(), m_sXmlId) ); - if (m_bHaveAbout) - { - const Reference<com::sun::star::rdf::XMetadatable> - xMeta( xContent, UNO_QUERY); - GetImport().AddRDFa(xMeta, - m_sAbout, m_sProperty, m_sContent, m_sDatatype); - } if ((lcl_MarkType)nTmp==TypeFieldmark) { if (xContent.is() && bImportAsField) { // setup fieldmark... @@ -225,9 +220,22 @@ void XMLTextMarkImportContext::EndElement() case TypeFieldmarkStart: case TypeBookmarkStart: // save XTextRange for later construction of bookmark - m_rHelper.InsertBookmarkStartRange( - m_sBookmarkName, m_rHelper.GetCursorAsRange()->getStart(), - m_sXmlId); + { + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > + pRDFaAttributes; + if (m_bHaveAbout && (TypeBookmarkStart + == static_cast<lcl_MarkType>(nTmp))) + { + pRDFaAttributes = + GetImport().GetRDFaImportHelper().ParseRDFa( + m_sAbout, m_sProperty, + m_sContent, m_sDatatype); + } + m_rHelper.InsertBookmarkStartRange( + m_sBookmarkName, + m_rHelper.GetCursorAsRange()->getStart(), + m_sXmlId, pRDFaAttributes); + } break; case TypeFieldmarkEnd: @@ -235,8 +243,11 @@ void XMLTextMarkImportContext::EndElement() { // get old range, and construct Reference<XTextRange> xStartRange; - if (m_rHelper.FindAndRemoveBookmarkStartRange(m_sBookmarkName, - xStartRange, m_sXmlId)) + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > + pRDFaAttributes; + if (m_rHelper.FindAndRemoveBookmarkStartRange( + m_sBookmarkName, xStartRange, + m_sXmlId, pRDFaAttributes)) { Reference<XTextRange> xEndRange( m_rHelper.GetCursorAsRange()->getStart()); @@ -273,12 +284,12 @@ void XMLTextMarkImportContext::EndElement() m_sBookmarkName, xInsertionRange, m_sXmlId) ); - if (m_bHaveAbout) + if (pRDFaAttributes) { - const Reference<com::sun::star::rdf::XMetadatable> - xMeta( xContent, UNO_QUERY); - GetImport().AddRDFa(xMeta, - m_sAbout, m_sProperty, m_sContent, m_sDatatype); + const Reference<rdf::XMetadatable> + xMeta(xContent, UNO_QUERY); + GetImport().GetRDFaImportHelper().AddRDFa( + xMeta, pRDFaAttributes); } if ((lcl_MarkType)nTmp==TypeFieldmarkEnd) { diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index a7b7b4cb6782..53d14f219219 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2191,21 +2191,27 @@ SvI18NMap& XMLTextImportHelper::GetRenameMap() void XMLTextImportHelper::InsertBookmarkStartRange( const OUString sName, const Reference<XTextRange> & rRange, - const OUString& i_rXmlId) + OUString const& i_rXmlId, + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & i_rpRDFaAttributes) { - aBookmarkStartRanges[sName] = std::make_pair(rRange, i_rXmlId); + aBookmarkStartRanges[sName] = + ::boost::make_tuple(rRange, i_rXmlId, i_rpRDFaAttributes); aBookmarkVector.push_back(sName); } sal_Bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange( const OUString sName, Reference<XTextRange> & o_rRange, - OUString& o_rXmlId) + OUString & o_rXmlId, + ::boost::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes) { if (aBookmarkStartRanges.count(sName)) { - o_rRange.set(aBookmarkStartRanges[sName].first); - o_rXmlId = aBookmarkStartRanges[sName].second; + BookmarkMapEntry_t & rEntry = + (*aBookmarkStartRanges.find(sName)).second; + o_rRange.set(rEntry.get<0>()); + o_rXmlId = rEntry.get<1>(); + o_rpRDFaAttributes = rEntry.get<2>(); aBookmarkStartRanges.erase(sName); BookmarkVector_t::iterator it=aBookmarkVector.begin(); while(it!=aBookmarkVector.end() && it->compareTo(sName)!=0) { @@ -2231,7 +2237,7 @@ sal_Bool XMLTextImportHelper::FindAndRemoveBookmarkStartRange( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > XMLTextImportHelper::GetRangeFor(::rtl::OUString &sName) { - return aBookmarkStartRanges[sName].first; + return aBookmarkStartRanges[sName].get<0>(); } |