officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu   |    
3 +
 officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs |    
4 +
 sdext/Library_PresentationMinimizer.mk                                    |    
1 
 sdext/source/minimizer/optimizerdialog.cxx                                |   
28 ++++++++++
 sdext/source/minimizer/pppoptimizertoken.cxx                              |    
1 
 sdext/source/minimizer/pppoptimizertoken.hxx                              |    
2 
 6 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit a5977185efb5728382f5ead19c715a59d5691eb7
Author:     Vasily Melenchuk <vasily.melenc...@cib.de>
AuthorDate: Wed Nov 28 15:26:33 2018 +0300
Commit:     Thorsten Behrens <thorsten.behr...@cib.de>
CommitDate: Tue Dec 11 13:15:50 2018 +0100

    presentation minimizer: warn user about unsaved presentation
    
    If minimizer is used on current presentation without making
    a copy and it has local modification we should suggest user
    to save it before, since not all minimization opearions could
    be reverted later.
    
    Change-Id: I12600c9a818698418f3ec957d43b13c6044609d2
    Reviewed-on: https://gerrit.libreoffice.org/64261
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git 
a/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu 
b/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu
index c5ea67d39c2b..28a54ab92b06 100644
--- a/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu
@@ -199,6 +199,9 @@ The current presentation contains no OLE objects.</value>
         <prop oor:name="STR_FILENAME_SUFFIX">
             <value xml:lang="en-US">(minimized)</value>
         </prop>
+        <prop oor:name="STR_WARN_UNSAVED_PRESENTATION">
+            <value xml:lang="en-US">Do you want to minimize presentation 
without saving?</value>
+        </prop>
     </node>
     <node oor:name="LastUsedSettings">
         <prop oor:name="Name">
diff --git 
a/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs 
b/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs
index f57c1ad42837..a841f97d2ce6 100644
--- a/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs
@@ -365,6 +365,10 @@ The current presentation contains no OLE objects.</value>
                <info><desc>String STR_FILENAME_SUFFIX.</desc></info>
                                <value>(minimized)</value>
                        </prop>
+                       <prop oor:name="STR_WARN_UNSAVED_PRESENTATION" 
oor:type="xs:string" oor:localized="true">
+               <info><desc>String STR_WARN_UNSAVED_PRESENTATION.</desc></info>
+                               <value>Do you want to minimize presentation 
without saving?</value>
+                       </prop>
                </group>
                <node-ref oor:name="LastUsedSettings" 
oor:node-type="OptimizerSettings">
                        <info>
diff --git a/sdext/Library_PresentationMinimizer.mk 
b/sdext/Library_PresentationMinimizer.mk
index c1f2a00a49b5..933877b16738 100644
--- a/sdext/Library_PresentationMinimizer.mk
+++ b/sdext/Library_PresentationMinimizer.mk
@@ -30,6 +30,7 @@ $(eval $(call gb_Library_set_include,PresentationMinimizer,\
 ))
 
 $(eval $(call gb_Library_use_libraries,PresentationMinimizer,\
+    comphelper \
     cppu \
     cppuhelper \
     sal \
diff --git a/sdext/source/minimizer/optimizerdialog.cxx 
b/sdext/source/minimizer/optimizerdialog.cxx
index 717f06a08340..a1056b3a2542 100644
--- a/sdext/source/minimizer/optimizerdialog.cxx
+++ b/sdext/source/minimizer/optimizerdialog.cxx
@@ -28,9 +28,12 @@
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/io/IOException.hpp>
 #include <com/sun/star/util/XCloseBroadcaster.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
 #include <sal/macros.h>
 #include <osl/time.h>
 #include <vcl/errinf.hxx>
+#include <vcl/weld.hxx>
+#include <vcl/layout.hxx>
 #include <svtools/sfxecode.hxx>
 #include <svtools/ehdl.hxx>
 #include <tools/urlobj.hxx>
@@ -498,6 +501,7 @@ void ActionListener::actionPerformed( const ActionEvent& 
rEvent )
             mrOptimizerDialog.getControlProperty( "RadioButton1Pg4", "State" ) 
>>= nInt16;
             if ( nInt16 )
             {
+                // Duplicate presentation before applying changes
                 OUString aSaveAsURL;
                 FileOpenDialog aFileOpenDialog( 
mrOptimizerDialog.GetComponentContext() );
 
@@ -550,6 +554,30 @@ void ActionListener::actionPerformed( const ActionEvent& 
rEvent )
                     mrOptimizerDialog.mxReschedule->reschedule();
                 }
             }
+            else
+            {
+                // Apply changes to current presentation
+                Reference<XModifiable> 
xModifiable(mrOptimizerDialog.mxController->getModel(),
+                                                   UNO_QUERY_THROW );
+                if ( xModifiable->isModified() )
+                {
+                    SolarMutexGuard aSolarGuard;
+                    std::unique_ptr<weld::MessageDialog> 
popupDlg(Application::CreateMessageDialog(
+                        nullptr, VclMessageType::Question, 
VclButtonsType::YesNo,
+                        
mrOptimizerDialog.getString(STR_WARN_UNSAVED_PRESENTATION)));
+                    if (popupDlg->run() != RET_YES)
+                    {
+                        // Selected not "yes" ("no" or dialog was cancelled) 
so return to previous step
+                        mrOptimizerDialog.setControlProperty("btnNavBack", 
"Enabled",
+                                                                  Any(true));
+                        mrOptimizerDialog.setControlProperty("btnNavNext", 
"Enabled", Any(false));
+                        mrOptimizerDialog.setControlProperty("btnNavFinish", 
"Enabled", Any(true));
+                        mrOptimizerDialog.setControlProperty("btnNavCancel", 
"Enabled", Any(true));
+                        mrOptimizerDialog.EnablePage(ITEM_ID_SUMMARY);
+                        return;
+                    }
+                }
+            }
             if ( bSuccessfullyExecuted )
             {   // now check if we have to store a session template
                 nInt16 = 0;
diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx 
b/sdext/source/minimizer/pppoptimizertoken.cxx
index 5470811249d5..e51045ea5caa 100644
--- a/sdext/source/minimizer/pppoptimizertoken.cxx
+++ b/sdext/source/minimizer/pppoptimizertoken.cxx
@@ -153,6 +153,7 @@ static const TokenTable pTokenTableArray[] =
     { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS },
     { "STR_FileSizeSeparator",      STR_FILESIZESEPARATOR },
     { "STR_FILENAME_SUFFIX",        STR_FILENAME_SUFFIX },
+    { "STR_WARN_UNSAVED_PRESENTATION", STR_WARN_UNSAVED_PRESENTATION },
 
 
     { "NotFound",           TK_NotFound }
diff --git a/sdext/source/minimizer/pppoptimizertoken.hxx 
b/sdext/source/minimizer/pppoptimizertoken.hxx
index a72afd3ef83d..8f83e8dd8f8e 100644
--- a/sdext/source/minimizer/pppoptimizertoken.hxx
+++ b/sdext/source/minimizer/pppoptimizertoken.hxx
@@ -136,7 +136,7 @@ enum PPPOptimizerTokenEnum
     STR_CREATING_OLE_REPLACEMENTS,
     STR_FILESIZESEPARATOR,
     STR_FILENAME_SUFFIX,
-
+    STR_WARN_UNSAVED_PRESENTATION,
     TK_NotFound
 };
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to