summaryrefslogtreecommitdiff
path: root/sw/source/core/edit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-25 09:40:14 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-25 10:06:58 +0100
commitb409a1a6680cd1a1189e34feb820539ff4d81c5a (patch)
tree76c77d9d1caf494406ca3eddc684d205ae519ad2 /sw/source/core/edit
parent6eb6a249105cbbc48a144d72f2f7c09aeb9bed2e (diff)
sw classification: handle had watermark -> no watermark transition
Previously we returned early if the new policy wanted no watermarks, but we still need to iterate over page styles to remove the old watermarks if there are ones. Change-Id: Iebab2534e7c923e47c76562982a188a32b81ed26
Diffstat (limited to 'sw/source/core/edit')
-rw-r--r--sw/source/core/edit/edfcol.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 9acb496d82ad..5f38a96d4532 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -178,14 +178,18 @@ void SwEditShell::SetClassification(const OUString& rName)
return;
SfxClassificationHelper aHelper(*pDocShell);
+
+ bool bHadWatermark = !aHelper.GetDocumentWatermark().isEmpty();
+
// This updates the infobar as well.
aHelper.SetBACName(rName);
bool bHeaderIsNeeded = aHelper.HasDocumentHeader();
bool bFooterIsNeeded = aHelper.HasDocumentFooter();
OUString aWatermark = aHelper.GetDocumentWatermark();
+ bool bWatermarkIsNeeded = !aWatermark.isEmpty();
- if (!bHeaderIsNeeded && !bFooterIsNeeded && aWatermark.isEmpty())
+ if (!bHeaderIsNeeded && !bFooterIsNeeded && !bWatermarkIsNeeded && !bHadWatermark)
return;
uno::Reference<frame::XModel> xModel = pDocShell->GetBaseModel();
@@ -200,7 +204,7 @@ void SwEditShell::SetClassification(const OUString& rName)
OUString aServiceName = "com.sun.star.text.TextField.DocInfo.Custom";
uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(xModel, uno::UNO_QUERY);
- if (bHeaderIsNeeded || !aWatermark.isEmpty())
+ if (bHeaderIsNeeded || bWatermarkIsNeeded || bHadWatermark)
{
// If the header is off, turn it on.
bool bHeaderIsOn = false;
@@ -224,16 +228,17 @@ void SwEditShell::SetClassification(const OUString& rName)
}
}
- if (!aWatermark.isEmpty())
+ if (bWatermarkIsNeeded || bHadWatermark)
{
OUString aShapeServiceName = "com.sun.star.drawing.CustomShape";
uno::Reference<drawing::XShape> xWatermark = lcl_getWatermark(xHeaderText, aShapeServiceName, SfxClassificationHelper::PROP_DOCWATERMARK());
+ bool bDeleteWatermark = bHadWatermark && !bWatermarkIsNeeded;
if (xWatermark.is())
{
// If the header already contains a watermark, see if it its text is up to date.
uno::Reference<text::XTextRange> xTextRange(xWatermark, uno::UNO_QUERY);
- if (xTextRange->getString() != aWatermark)
+ if (xTextRange->getString() != aWatermark || bDeleteWatermark)
{
// No: delete it and we'll insert a replacement.
uno::Reference<lang::XComponent> xComponent(xWatermark, uno::UNO_QUERY);
@@ -242,7 +247,7 @@ void SwEditShell::SetClassification(const OUString& rName)
}
}
- if (!xWatermark.is())
+ if (!xWatermark.is() && bWatermarkIsNeeded)
{
// Calc the ratio.
double fRatio = 0;