filter/source/svg/presentation_engine.js |   69 ++++++++++++++++++++++++++++++-
 sc/source/ui/view/output2.cxx            |   11 +---
 2 files changed, 71 insertions(+), 9 deletions(-)

New commits:
commit d521062dd38a0c7faf26da55574648ae0c475771
Author:     Gökay Şatır <gokaysa...@collabora.com>
AuthorDate: Tue Oct 3 10:53:31 2023 +0300
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sat Oct 14 16:49:51 2023 +0200

    Impress presentation engine (svg):
    
       * Add handlers for w and b chars.
          * These hide the content and set the color of the view to either 
black or white.
       * Add handler for p char:
          * This changes the cursor to pointer and back to default with key 
presses.
    
    Signed-off-by: Gökay Şatır <gokaysa...@collabora.com>
    Change-Id: I566f485aa676f0707a31f25a0b71f64970de2a26
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157511
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    (cherry picked from commit 427e8c0a8d9a534c54e07414cfe66648c9a90d26)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157958
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/filter/source/svg/presentation_engine.js 
b/filter/source/svg/presentation_engine.js
index ba585b6f4b3c..839bd1676ffd 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -2756,6 +2756,56 @@ function getElementsByProperty( node, name )
     return elements;
 }
 
+// User can hide / show the presentation content.
+// For that purpose, we change the background color of root node to either 
black or white.
+// To set it back to its original color (for showing the content back), we 
should have the initial background color saved somewhere to read back.
+// There may be no initial color at all, so the initial value of the saved 
initial is undefined.
+var rootNodeInitialBackgroundColor = undefined;
+
+function changeRootNodeBackgroundTo(color) {
+       if (rootNodeInitialBackgroundColor === undefined)
+               rootNodeInitialBackgroundColor = 
ROOT_NODE.style.backgroundColor;
+
+       if (color === 'initial')
+               ROOT_NODE.style.backgroundColor = 
rootNodeInitialBackgroundColor;
+       else
+               ROOT_NODE.style.backgroundColor = color;
+}
+
+var isContentHidden = false;
+var contentInitialVisibilityValues = null;
+
+function getInitialVisibilityValues() {
+       var list = ROOT_NODE.querySelectorAll('g');
+       contentInitialVisibilityValues = [];
+       for (var i = 0; i < list.length; i++) {
+               var temp = {};
+               temp.object = list[i];
+               temp.visibility = list[i].style.visibility;
+               contentInitialVisibilityValues.push(temp);
+       }
+}
+
+function hideShowContent(color) {
+       if (contentInitialVisibilityValues === null)
+               getInitialVisibilityValues();
+
+       if (isContentHidden) {
+               for (var i = 0; i < contentInitialVisibilityValues.length; i++)
+                       
contentInitialVisibilityValues[i].object.style.visibility = 
contentInitialVisibilityValues[i].visibility;
+
+               changeRootNodeBackgroundTo('initial');
+               isContentHidden = false;
+       }
+       else {
+               for (var i = 0; i < contentInitialVisibilityValues.length; i++)
+                       
contentInitialVisibilityValues[i].object.style.visibility = 'hidden';
+
+               changeRootNodeBackgroundTo(color);
+               isContentHidden = true;
+       }
+}
+
 /** Event handler for key press.
  *
  *  @param aEvt the event
@@ -2765,7 +2815,7 @@ function onKeyDown( aEvt )
     if ( !aEvt )
         aEvt = window.event;
 
-    var code = aEvt.keyCode || aEvt.charCode;
+    var code = aEvt.keyCode || aEvt.charCode || aEvt.code;
 
     // console.log('===> onKeyDown: ' + code);
 
@@ -2788,6 +2838,20 @@ function onKeyDown( aEvt )
 
         // console.log('     now: ' + code);
     }
+       else if (code === P_KEY) {
+               aEvt.preventDefault();
+               if (ROOT_NODE.style.cursor === 'pointer')
+                       ROOT_NODE.style.cursor = 'default';
+               else
+                       ROOT_NODE.style.cursor = 'pointer';
+       }
+       else if (code === W_KEY) {
+               hideShowContent('white');
+       }
+       else if (code === B_KEY) {
+               hideShowContent('black');
+       }
+
 
     if( !processingEffect && keyCodeDictionary[currentMode] && 
keyCodeDictionary[currentMode][code] )
     {
@@ -4505,7 +4569,10 @@ var END_KEY = 35;           // end keycode
 var ENTER_KEY = 13;
 var SPACE_KEY = 32;
 var ESCAPE_KEY = 27;
+var B_KEY = 66;
+var P_KEY = 80;
 var Q_KEY = 81;
+var W_KEY = 87;
 
 // Visibility Values
 var HIDDEN = 0;
commit ef4f9dca33bf38de3c2175cc4304e42281d729c2
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Oct 13 10:31:48 2023 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sat Oct 14 16:49:43 2023 +0200

    don't bother checking existing mode before seting new mode
    
    Change-Id: I2ff08283d7a3defdc7a7df5c2f86fca4cf3508ef
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157907
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 916748b0ceab..6dbd218caf61 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1482,22 +1482,17 @@ void ScOutputData::LayoutStrings(bool bPixelToLogic)
 {
     bool bOrigIsInLayoutStrings = mpDoc->IsInLayoutStrings();
     mpDoc->SetLayoutStrings(true);
-
     OSL_ENSURE( mpDev == mpRefDevice ||
                 mpDev->GetMapMode().GetMapUnit() == 
mpRefDevice->GetMapMode().GetMapUnit(),
                 "LayoutStrings: different MapUnits ?!?!" );
-
     vcl::text::ComplexTextLayoutFlags eTextLayout = mpDev->GetLayoutMode();
+    mpDev->SetLayoutMode(vcl::text::ComplexTextLayoutFlags::Default);
+
     comphelper::ScopeGuard g([this, bOrigIsInLayoutStrings, eTextLayout] {
         mpDoc->SetLayoutStrings(bOrigIsInLayoutStrings);
-
-        if (mpDev->GetLayoutMode() != eTextLayout)
-            mpDev->SetLayoutMode(eTextLayout);
+        mpDev->SetLayoutMode(eTextLayout);
     });
 
-    if (mpDev->GetLayoutMode() != vcl::text::ComplexTextLayoutFlags::Default)
-        mpDev->SetLayoutMode(vcl::text::ComplexTextLayoutFlags::Default);
-
     sc::IdleSwitch aIdleSwitch(*mpDoc, false);
 
     // Try to limit interpreting to only visible cells. Calling e.g. IsValue()

Reply via email to