sw/source/core/edit/edfcol.cxx |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit b409a1a6680cd1a1189e34feb820539ff4d81c5a
Author: Miklos Vajna <vmik...@collabora.co.uk>
Date:   Thu Feb 25 09:40:14 2016 +0100

    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

diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 9acb496..5f38a96 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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to