diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-24 10:40:06 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-24 13:45:46 +0100 |
commit | 2df20dc87554957716d810b0c91804d535f561a7 (patch) | |
tree | 9a5ca20b2cadde1d8c9583203e2711d91004b140 /sw/source/core/edit | |
parent | d599122730a84be29b2649b66a582d2269c4ed2b (diff) |
sw classification: put the relevant field to the header if policy wants so
Change-Id: I56d37a8c143dd5108bbc9f6444fe3e058378bf5e
Diffstat (limited to 'sw/source/core/edit')
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index c5ced4b8f81a..6bc2e683b9d8 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -17,10 +17,13 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <editsh.hxx> + +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> + #include <hintids.hxx> #include <editeng/formatbreakitem.hxx> #include <sfx2/classificationhelper.hxx> -#include <editsh.hxx> #include <doc.hxx> #include <IDocumentUndoRedo.hxx> #include <edimp.hxx> @@ -33,6 +36,7 @@ #include <swundo.hxx> #include <docary.hxx> #include <docsh.hxx> +#include <unoprnms.hxx> SwTextFormatColl& SwEditShell::GetDfltTextFormatColl() const { @@ -56,7 +60,32 @@ void SwEditShell::SetClassification(const OUString& rName) return; SfxClassificationHelper aHelper(*pDocShell); + // This updates the infobar as well. aHelper.SetBACName(rName); + + if (aHelper.HasDocumentHeader()) + { + uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel(); + uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPageStyle(xStyleFamily->getByName("Standard"), uno::UNO_QUERY); + + // If the header is off, turn it on. + bool bHeaderIsOn = false; + xPageStyle->getPropertyValue(UNO_NAME_HEADER_IS_ON) >>= bHeaderIsOn; + if (!bHeaderIsOn) + xPageStyle->setPropertyValue(UNO_NAME_HEADER_IS_ON, uno::makeAny(true)); + + // Append a field to the end of the header text. + uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(xModel, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xField(xMultiServiceFactory->createInstance("com.sun.star.text.TextField.DocInfo.Custom"), uno::UNO_QUERY); + xField->setPropertyValue(UNO_NAME_NAME, uno::makeAny(SfxClassificationHelper::PROP_DOCHEADER())); + uno::Reference<text::XText> xHeaderText; + xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT) >>= xHeaderText; + uno::Reference<text::XTextContent> xTextContent(xField, uno::UNO_QUERY); + xHeaderText->insertTextContent(xHeaderText->getEnd(), xTextContent, /*bAbsorb=*/false); + } } // #i62675# |