[Libreoffice-commits] core.git: comphelper/source include/comphelper include/sal svx/source svx/uiconfig

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Tue Nov 1 14:54:33 UTC 2016


 comphelper/source/misc/backupfilehelper.cxx |   81 ++++++++++++++++
 include/comphelper/backupfilehelper.hxx     |    3 
 include/sal/log-areas.dox                   |    1 
 svx/source/dialog/SafeModeDialog.cxx        |   12 ++
 svx/source/dialog/SafeModeDialog.hxx        |    1 
 svx/uiconfig/ui/safemodedialog.ui           |  137 +++++++++++++++-------------
 6 files changed, 172 insertions(+), 63 deletions(-)

New commits:
commit 1161de521e2a828d292f673a05c1344a295e4cae
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Thu Oct 20 18:15:05 2016 +0200

    safemode: Add option to disable H/W acceleration
    
    Change-Id: Ic6751717c14d317b5a4bc64c4fd1cf2b2f5efabf
    Reviewed-on: https://gerrit.libreoffice.org/30112
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
    Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/comphelper/source/misc/backupfilehelper.cxx b/comphelper/source/misc/backupfilehelper.cxx
index f9587ce..6686d08 100644
--- a/comphelper/source/misc/backupfilehelper.cxx
+++ b/comphelper/source/misc/backupfilehelper.cxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/xml/dom/DocumentBuilder.hpp>
 #include <com/sun/star/xml/dom/XElement.hpp>
 #include <com/sun/star/xml/dom/XNodeList.hpp>
+#include <com/sun/star/xml/dom/XText.hpp>
 #include <com/sun/star/xml/sax/XSAXSerializable.hpp>
 #include <com/sun/star/xml/sax/Writer.hpp>
 #include <com/sun/star/xml/sax/XWriter.hpp>
@@ -35,6 +36,8 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 
 using namespace css;
+using namespace css::xml::dom;
+
 static const sal_uInt32 BACKUP_FILE_HELPER_BLOCK_SIZE = 16384;
 
 namespace
@@ -836,7 +839,7 @@ namespace
                                 }
 
 #if OSL_DEBUG_LEVEL > 1
-                                SAL_WARN_IF(osl::FileBase::E_None != osl::File::move(aTempURL, rUnoPackagReg), "comphelper:backupfileheler", "could not copy back modified Extension configuration file");
+                                SAL_WARN_IF(osl::FileBase::E_None != osl::File::move(aTempURL, rUnoPackagReg), "comphelper.backupfilehelper", "could not copy back modified Extension configuration file");
 #else
                                 osl::File::move(aTempURL, rUnoPackagReg);
 #endif
@@ -2073,6 +2076,82 @@ namespace comphelper
         return aFileNames;
     }
 
+    namespace {
+        uno::Reference<XElement> lcl_getConfigElement(const uno::Reference<XDocument>& xDocument, const OUString& rPath,
+                                  const OUString& rKey, const OUString& rValue)
+        {
+            uno::Reference< XElement > itemElement = xDocument->createElement("item");
+            itemElement->setAttribute("oor:path", rPath);
+
+            uno::Reference< XElement > propElement = xDocument->createElement("prop");
+            propElement->setAttribute("oor:name", rKey);
+            propElement->setAttribute("oor:op", "replace"); // Replace any other options
+
+            uno::Reference< XElement > valueElement = xDocument->createElement("value");
+            uno::Reference< XText > textElement = xDocument->createTextNode(rValue);
+
+            valueElement->appendChild(textElement);
+            propElement->appendChild(valueElement);
+            itemElement->appendChild(propElement);
+
+            return itemElement;
+        }
+    }
+
+    void BackupFileHelper::tryDisableHWAcceleration()
+    {
+        const OUString aRegistryModifications(maUserConfigWorkURL + "/registrymodifications.xcu");
+        if (!fileExists(aRegistryModifications))
+            return;
+
+        uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+        uno::Reference< XDocumentBuilder > xBuilder = DocumentBuilder::create(xContext);
+        uno::Reference< XDocument > xDocument = xBuilder->parseURI(aRegistryModifications);
+        uno::Reference< XElement > xRootElement = xDocument->getDocumentElement();
+
+        xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/VCL",
+                                                       "UseOpenGL", "false"));
+        xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/VCL",
+                                                       "ForceOpenGL", "false"));
+        xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/Misc",
+                                                       "UseOpenCL", "false"));
+        xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/Misc",
+                                                       "UseSwInterpreter", "false"));
+
+        // write back
+        uno::Reference< xml::sax::XSAXSerializable > xSerializer(xDocument, uno::UNO_QUERY);
+
+        if (!xSerializer.is())
+            return;
+
+        // create a SAXWriter
+        uno::Reference< xml::sax::XWriter > const xSaxWriter = xml::sax::Writer::create(xContext);
+        uno::Reference< io::XStream > xTempFile(io::TempFile::create(xContext), uno::UNO_QUERY);
+        uno::Reference< io::XOutputStream > xOutStrm(xTempFile->getOutputStream(), uno::UNO_QUERY);
+
+        // set output stream and do the serialization
+        xSaxWriter->setOutputStream(uno::Reference< css::io::XOutputStream >(xOutStrm, uno::UNO_QUERY));
+        xSerializer->serialize(uno::Reference< xml::sax::XDocumentHandler >(xSaxWriter, uno::UNO_QUERY), uno::Sequence< beans::StringPair >());
+
+        // get URL from temp file
+        uno::Reference < beans::XPropertySet > xTempFileProps(xTempFile, uno::UNO_QUERY);
+        uno::Any aUrl = xTempFileProps->getPropertyValue("Uri");
+        OUString aTempURL;
+        aUrl >>= aTempURL;
+
+        // copy back file
+        if (aTempURL.isEmpty() || !fileExists(aTempURL))
+            return;
+
+        if (fileExists(aRegistryModifications))
+        {
+            osl::File::remove(aRegistryModifications);
+        }
+
+        int result = osl::File::move(aTempURL, aRegistryModifications);
+        SAL_WARN_IF(result != osl::FileBase::E_None, "comphelper.backupfilehelper", "could not copy back modified Extension configuration file");
+    }
+
     bool BackupFileHelper::isTryResetCustomizationsPossible()
     {
         // return true if not all of the customization selection dirs or files are deleted
diff --git a/include/comphelper/backupfilehelper.hxx b/include/comphelper/backupfilehelper.hxx
index 0857251..5d3173f 100644
--- a/include/comphelper/backupfilehelper.hxx
+++ b/include/comphelper/backupfilehelper.hxx
@@ -167,6 +167,9 @@ namespace comphelper
         static bool isTryDeinstallAllExtensionsPossible();
         static void tryDeinstallAllExtensions();
 
+        /// Disables OpenGL and OpenCL
+        static void tryDisableHWAcceleration();
+
         /** resets User-Customizations like Settings and UserInterface modifications
         */
         static bool isTryResetCustomizationsPossible();
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index c69beba..a27e77e 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -89,6 +89,7 @@ certain functionality.
 @section comphelper
 
 @li @c comphelper
+ at li @c comphelper.backupfilehelper
 @li @c comphelper.container - EmbeddedObjectContainer
 
 @section cppu
diff --git a/svx/source/dialog/SafeModeDialog.cxx b/svx/source/dialog/SafeModeDialog.cxx
index 61e26d0..9dd2d4d 100644
--- a/svx/source/dialog/SafeModeDialog.cxx
+++ b/svx/source/dialog/SafeModeDialog.cxx
@@ -42,6 +42,7 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
     mpCBDisableAllExtensions(),
     mpCBDeinstallUserExtensions(),
     mpCBDeinstallAllExtensions(),
+    mpCBDisableHWAcceleration(),
     mpCBResetCustomizations(),
     mpCBResetWholeUserProfile(),
 
@@ -56,6 +57,7 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
     get(mpCBDisableAllExtensions, "check_disable_all_extensions");
     get(mpCBDeinstallUserExtensions, "check_deinstall_user_extensions");
     get(mpCBDeinstallAllExtensions, "check_deinstall_all_extensions");
+    get(mpCBDisableHWAcceleration, "check_disable_hw_acceleration");
     get(mpCBResetCustomizations, "check_reset_customizations");
     get(mpCBResetWholeUserProfile, "check_reset_whole_userprofile");
 
@@ -70,6 +72,7 @@ SafeModeDialog::SafeModeDialog(vcl::Window* pParent)
     mpCBDisableAllExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
     mpCBDeinstallUserExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
     mpCBDeinstallAllExtensions->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
+    mpCBDisableHWAcceleration->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
     mpCBResetCustomizations->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
     mpCBResetWholeUserProfile->SetToggleHdl(LINK(this, SafeModeDialog, CheckBoxHdl));
 
@@ -130,6 +133,7 @@ void SafeModeDialog::dispose()
     mpCBDisableAllExtensions.clear();
     mpCBDeinstallUserExtensions.clear();
     mpCBDeinstallAllExtensions.clear();
+    mpCBDisableHWAcceleration.clear();
     mpCBResetCustomizations.clear();
     mpCBResetWholeUserProfile.clear();
 
@@ -180,6 +184,11 @@ void SafeModeDialog::applyChanges()
         comphelper::BackupFileHelper::tryDeinstallAllExtensions();
     }
 
+    if (mpCBDisableHWAcceleration->IsChecked())
+    {
+        comphelper::BackupFileHelper::tryDisableHWAcceleration();
+    }
+
     if (mpCBResetCustomizations->IsChecked())
     {
         // Reset customizations (Settings and UserInterface modifications)
@@ -210,7 +219,7 @@ IMPL_LINK(SafeModeDialog, BtnHdl, Button*, pBtn, void)
     }
     else if (pBtn == mpBtnRestart.get())
     {
-        Close();
+        //Close();
         applyChanges();
     }
 }
@@ -223,6 +232,7 @@ IMPL_LINK(SafeModeDialog, CheckBoxHdl, CheckBox&, /*pCheckBox*/, void)
         mpCBDisableAllExtensions->IsChecked() ||
         mpCBDeinstallUserExtensions->IsChecked() ||
         mpCBDeinstallAllExtensions->IsChecked() ||
+        mpCBDisableHWAcceleration->IsChecked() ||
         mpCBResetCustomizations->IsChecked() ||
         mpCBResetWholeUserProfile->IsChecked());
 
diff --git a/svx/source/dialog/SafeModeDialog.hxx b/svx/source/dialog/SafeModeDialog.hxx
index 500620a..66a83b2 100644
--- a/svx/source/dialog/SafeModeDialog.hxx
+++ b/svx/source/dialog/SafeModeDialog.hxx
@@ -41,6 +41,7 @@ private:
     VclPtr<CheckBox> mpCBDisableAllExtensions;
     VclPtr<CheckBox> mpCBDeinstallUserExtensions;
     VclPtr<CheckBox> mpCBDeinstallAllExtensions;
+    VclPtr<CheckBox> mpCBDisableHWAcceleration;
     VclPtr<CheckBox> mpCBResetCustomizations;
     VclPtr<CheckBox> mpCBResetWholeUserProfile;
 
diff --git a/svx/uiconfig/ui/safemodedialog.ui b/svx/uiconfig/ui/safemodedialog.ui
index 54bbb1e..e28cac7 100644
--- a/svx/uiconfig/ui/safemodedialog.ui
+++ b/svx/uiconfig/ui/safemodedialog.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.12"/>
   <object class="GtkDialog" id="SafeModeDialog">
@@ -13,16 +13,71 @@
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">12</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="btn_continue">
+                <property name="label" translatable="yes">_Continue in Safe Mode</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="btn_quit">
+                <property name="label" translatable="yes">_Quit</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="btn_restart">
+                <property name="label" translatable="yes">_Make Changes and Restart</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">4</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkLabel" id="label1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="xalign">0</property>
-            <property name="yalign">0</property>
             <property name="label" translatable="yes">%PRODUCTNAME is now running in Safe Mode. You can make one or more of the following changes to return to a working state.
 
 The offered possible changes get more radical from top to bottom, so it is recommended to try them thoroughly one after the other.</property>
             <property name="wrap">True</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -111,6 +166,21 @@ The offered possible changes get more radical from top to bottom, so it is recom
               </packing>
             </child>
             <child>
+              <object class="GtkCheckButton" id="check_disable_hw_acceleration">
+                <property name="label" translatable="yes">Disable hardware acceleration (OpenGL, OpenCL)</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="xalign">0</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">5</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkCheckButton" id="check_reset_customizations">
                 <property name="label" translatable="yes">Reset User Customizations (Settings, User Interface modifications, AutoCorrect, AutoText, etc.)</property>
                 <property name="visible">True</property>
@@ -122,7 +192,7 @@ The offered possible changes get more radical from top to bottom, so it is recom
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">5</property>
+                <property name="position">6</property>
               </packing>
             </child>
             <child>
@@ -137,7 +207,7 @@ The offered possible changes get more radical from top to bottom, so it is recom
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">6</property>
+                <property name="position">7</property>
               </packing>
             </child>
           </object>
@@ -161,10 +231,10 @@ The offered possible changes get more radical from top to bottom, so it is recom
                   <object class="GtkLabel" id="label3">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">If you experience problems that are not resolved by using the Safe Mode, visit the following link to get help or report a bug.
 
 You can also include the relevant parts of your User Profile. Beware that it might contain personal data.</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -203,61 +273,6 @@ You can also include the relevant parts of your User Profile. Beware that it mig
             <property name="position">3</property>
           </packing>
         </child>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="btn_continue">
-                <property name="label" translatable="yes">_Continue in Safe Mode</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="btn_quit">
-                <property name="label" translatable="yes">_Quit</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="btn_restart">
-                <property name="label" translatable="yes">_Make Changes and Restart</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">3</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">4</property>
-          </packing>
-        </child>
       </object>
     </child>
   </object>


More information about the Libreoffice-commits mailing list