diff options
author | Michael Stahl <mst@openoffice.org> | 2010-03-16 11:28:35 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2010-03-16 11:28:35 +0100 |
commit | a396d6e9a01b9c1428118728c980fc75c1815b9e (patch) | |
tree | 53ad8a954586beb59c8c46c00e238e8ba0291c27 /sw | |
parent | d2568e9a7481f403836224d486efc28edb467a48 (diff) |
odfmetadata4: #i109599#,#i109600#: SwSectionFmt: support for xml:id at section.
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/section.hxx | 15 | ||||
-rw-r--r-- | sw/source/core/docnode/section.cxx | 44 |
2 files changed, 57 insertions, 2 deletions
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 34bb75fdc8ef..db99cfdf4d52 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -32,10 +32,11 @@ #include <com/sun/star/uno/Sequence.h> -#include <sfx2/lnkbase.hxx> #include <tools/rtti.hxx> #include <tools/ref.hxx> #include <svl/svarray.hxx> +#include <sfx2/lnkbase.hxx> +#include <sfx2/Metadatable.hxx> #include <frmfmt.hxx> @@ -282,7 +283,9 @@ public: enum SectionSort { SORTSECT_NOT, SORTSECT_NAME, SORTSECT_POS }; -class SW_DLLPUBLIC SwSectionFmt : public SwFrmFmt +class SW_DLLPUBLIC SwSectionFmt + : public SwFrmFmt + , public ::sfx2::Metadatable { friend class SwDoc; @@ -342,6 +345,14 @@ public: ::com::sun::star::text::XTextSection> const& xTextSection) { m_wXTextSection = xTextSection; } + // sfx2::Metadatable + virtual ::sfx2::IXmlIdRegistry& GetRegistry(); + virtual bool IsInClipboard() const; + virtual bool IsInUndo() const; + virtual bool IsInContent() const; + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > MakeUnoObject(); + }; // -------------- inlines --------------------------------- diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 75bb7e23bdba..2d54cb88f2e6 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -68,6 +68,7 @@ #include <fmteiro.hxx> // <-- #include <swerror.h> +#include <unosection.hxx> using namespace ::com::sun::star; @@ -1183,6 +1184,49 @@ const SwSection* SwSectionFmt::GetGlobalDocSection() const return 0; } +// sw::Metadatable +::sfx2::IXmlIdRegistry& SwSectionFmt::GetRegistry() +{ + return GetDoc()->GetXmlIdRegistry(); +} + +bool SwSectionFmt::IsInClipboard() const +{ + return GetDoc()->IsClipBoard(); +} + +bool SwSectionFmt::IsInUndo() const +{ + return !IsInNodesArr(); +} + +bool SwSectionFmt::IsInContent() const +{ + SwNodeIndex const*const pIdx = GetCntnt(FALSE).GetCntntIdx(); + OSL_ENSURE(pIdx, "SwSectionFmt::IsInContent: no index?"); + return (pIdx) ? !GetDoc()->IsInHeaderFooter(*pIdx) : true; +} + +// n.b.: if the section format represents an index, then there is both a +// SwXDocumentIndex and a SwXTextSection instance for this single core object. +// these two can both implement XMetadatable and forward to the same core +// section format. but here only one UNO object can be returned, +// so always return the text section. +uno::Reference< rdf::XMetadatable > +SwSectionFmt::MakeUnoObject() +{ + uno::Reference<rdf::XMetadatable> xMeta; + SwSection *const pSection( GetSection() ); + if (pSection) + { + xMeta.set( SwXTextSection::CreateXTextSection(this, + TOX_HEADER_SECTION == pSection->GetType()), + uno::UNO_QUERY ); + } + return xMeta; +} + + // --> OD 2007-02-14 #b6521322# // Method to break section links inside a linked section void lcl_BreakSectionLinksInSect( const SwSectionNode& rSectNd ) |