sd/sdi/sdraw.sdi                                     |    2 
 sd/source/ui/func/fupage.cxx                         |   53 +++++++++++++------
 sd/source/ui/inc/fupage.hxx                          |    2 
 sd/source/ui/sidebar/MasterPageDescriptor.cxx        |    1 
 sd/source/ui/sidebar/SlideBackground.cxx             |    9 +++
 sd/source/ui/slidesorter/controller/SlsClipboard.cxx |   10 +--
 vcl/source/control/combobox.cxx                      |   10 ++-
 vcl/source/control/listbox.cxx                       |    9 ++-
 8 files changed, 68 insertions(+), 28 deletions(-)

New commits:
commit 1445e909204d4991e75af95609a775b4ba12b764
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Fri Nov 23 00:00:28 2018 -0500
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Sep 3 13:37:37 2019 +0200

    LOK: dialogs: limit listbox/combobox drop-down length
    
    Dialogs routed to the LOK client have limited real
    estate on the screen because dialogs are rendered
    on a canvas. When the listbox drop-down bleeds outside
    the dialog area, on the desktop it's no problem, but
    in the browser, that requires a larger canvas and
    that brings a host of problems.
    
    Here we limit the maximum length of listbox/combobox
    drop-down lists to avoid this situation.
    
    This would ideally be configured via ListBoxMaximumLineCount
    alas it doesn't work.
    
    Change-Id: I55fff28dbfc59dec36714e221f76cf4160ba1505
    (cherry picked from commit 9c5321f577940a0cd78a3af4461e94c4fdb78d63)
    Reviewed-on: https://gerrit.libreoffice.org/78435
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index ee0309aba33a..99203e61b793 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -34,7 +34,7 @@
 #include <svdata.hxx>
 #include <listbox.hxx>
 #include <controldata.hxx>
-
+#include <comphelper/lok.hxx>
 
 struct ComboBoxBounds
 {
@@ -530,8 +530,12 @@ void ComboBox::SetDropDownLineCount( sal_uInt16 nLines )
 
 void ComboBox::AdaptDropDownLineCountToMaximum()
 {
-    // adapt to maximum allowed number
-    
SetDropDownLineCount(GetSettings().GetStyleSettings().GetListBoxMaximumLineCount());
+    // Adapt to maximum allowed number.
+    // Limit for LOK as we can't render outside of the dialog canvas.
+    if (comphelper::LibreOfficeKit::isActive())
+        SetDropDownLineCount(11);
+    else
+        
SetDropDownLineCount(GetSettings().GetStyleSettings().GetListBoxMaximumLineCount());
 }
 
 sal_uInt16 ComboBox::GetDropDownLineCount() const
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index e85a61c4f4a4..f3d9526e09d6 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -35,6 +35,7 @@
 #include <controldata.hxx>
 #include <listbox.hxx>
 #include <dndeventdispatcher.hxx>
+#include <comphelper/lok.hxx>
 
 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
 
@@ -537,8 +538,12 @@ void ListBox::SetDropDownLineCount( sal_uInt16 nLines )
 
 void ListBox::AdaptDropDownLineCountToMaximum()
 {
-    // adapt to maximum allowed number
-    
SetDropDownLineCount(GetSettings().GetStyleSettings().GetListBoxMaximumLineCount());
+    // Adapt to maximum allowed number.
+    // Limit for LOK as we can't render outside of the dialog canvas.
+    if (comphelper::LibreOfficeKit::isActive())
+        SetDropDownLineCount(11);
+    else
+        
SetDropDownLineCount(GetSettings().GetStyleSettings().GetListBoxMaximumLineCount());
 }
 
 sal_uInt16 ListBox::GetDropDownLineCount() const
commit 6643bf368ac439888dce58104ac31a93f247abc5
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Wed Sep 12 20:03:11 2018 -0400
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Sep 3 13:37:19 2019 +0200

    sd: support inserting background image from file via .uno:SelectBackground
    
    The UNO command always prompted the user via file open dialog.
    This change allows for passing the filename as an argument
    to allow for inserting slide background programatically.
    
    Also, hide the Insert Image button in the sidebar
    since we can't use that (just yet), because
    it invokes .uno:SelectBackground directly. We would
    need to send LOOL a notification to invoke this on
    its own end to first prompt the user for a file.
    
    (cherry picked from commit 2118143bdd246921439ba9e835207585203dd45f)
    (cherry picked from commit d581c7723550187f5185ccd22b8c42d34cab64b4)
    
    Change-Id: I20c0e33d66f8bcd72a6388e39c4ac92e64978f45
    Reviewed-on: https://gerrit.libreoffice.org/78434
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>
    Tested-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
index 5bfc1100cd4e..e0c6e03b254f 100644
--- a/sd/sdi/sdraw.sdi
+++ b/sd/sdi/sdraw.sdi
@@ -4043,7 +4043,7 @@ SfxVoidItem CloseMasterView SID_CLOSE_MASTER_VIEW()
 ]
 
 SfxVoidItem SelectBackground SID_SELECT_BACKGROUND
-()
+(SfxStringItem FileName SID_SELECT_BACKGROUND,SfxStringItem FilterName 
FN_PARAM_FILTER,SfxBoolItem AsLink FN_PARAM_1,SfxStringItem Style FN_PARAM_2)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 1fe20d09b107..a8f31373d8fb 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -126,7 +126,7 @@ rtl::Reference<FuPoor> FuPage::Create( ViewShell* pViewSh, 
::sd::Window* pWin, :
     return xFunc;
 }
 
-void FuPage::DoExecute( SfxRequest& )
+void FuPage::DoExecute(SfxRequest& rReq)
 {
     mpDrawViewShell = dynamic_cast<DrawViewShell*>(mpViewShell);
     DBG_ASSERT( mpDrawViewShell, "sd::FuPage::FuPage(), called without a 
current DrawViewShell!" );
@@ -142,11 +142,12 @@ void FuPage::DoExecute( SfxRequest& )
 
     if( mpPage )
     {
-        // if there are no arguments given, open the dialog
-        if( !mpArgs )
+        // If there are no arguments given, open the dialog, or if we have 
SelectBackground params, process first.
+        const SfxPoolItem* pItem;
+        if (!mpArgs || mpArgs->GetItemState(SID_SELECT_BACKGROUND, true, 
&pItem) == SfxItemState::SET)
         {
             mpView->SdrEndTextEdit();
-            mpArgs = ExecuteDialog(mpWindow ? mpWindow->GetFrameWeld() : 
nullptr);
+            mpArgs = ExecuteDialog(mpWindow ? mpWindow->GetFrameWeld() : 
nullptr, rReq);
         }
 
         // if we now have arguments, apply them to current page
@@ -204,7 +205,7 @@ void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet 
*pStyleSheet, bool b
     }
 }
 
-const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent)
+const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, SfxRequest& 
rReq)
 {
     if (!mpDrawViewShell)
         return nullptr;
@@ -303,15 +304,40 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* 
pParent)
     }
     else if (nId == SID_SELECT_BACKGROUND)
     {
-        SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE), 
pParent);
+        OUString aFileName;
+        OUString aFilterName;
+        Graphic aGraphic;
+        ErrCode nError = ERRCODE_GRFILTER_OPENERROR;
 
-        if( aDlg.Execute() == ERRCODE_NONE )
+        const SfxItemSet* pArgs = rReq.GetArgs();
+        const SfxPoolItem* pItem;
+
+        if (pArgs && pArgs->GetItemState(SID_SELECT_BACKGROUND, true, &pItem) 
== SfxItemState::SET)
+        {
+            aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
+
+            if (pArgs->GetItemState(FN_PARAM_FILTER, true, &pItem) == 
SfxItemState::SET)
+                aFilterName = static_cast<const 
SfxStringItem*>(pItem)->GetValue();
+
+            nError = GraphicFilter::LoadGraphic(aFileName, aFilterName, 
aGraphic,
+                                                
&GraphicFilter::GetGraphicFilter());
+        }
+        else
         {
-            Graphic     aGraphic;
-            ErrCode nError = aDlg.GetGraphic(aGraphic);
-            if( nError == ERRCODE_NONE )
+            SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE), 
pParent);
+
+            nError = aDlg.Execute();
+            if (nError != ERRCODE_NONE)
             {
-                pTempSet.reset( new SfxItemSet( mpDoc->GetPool(), 
svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}) );
+                nError = aDlg.GetGraphic(aGraphic);
+                aFileName = aDlg.GetPath();
+                aFilterName = aDlg.GetDetectedFilter();
+            }
+        }
+
+        if (nError == ERRCODE_NONE)
+        {
+            pTempSet.reset( new SfxItemSet( mpDoc->GetPool(), 
svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}) );
 
                 pTempSet->Put( XFillStyleItem( drawing::FillStyle_BITMAP ) );
 
@@ -320,9 +346,8 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* 
pParent)
                 aMigrateSet.Put(XFillBitmapItem("background", aGraphic));
                 SdrModel::MigrateItemSet( &aMigrateSet, pTempSet.get(), mpDoc 
);
 
-                pTempSet->Put( XFillBmpStretchItem( true ));
-                pTempSet->Put( XFillBmpTileItem( false ));
-            }
+            pTempSet->Put( XFillBmpStretchItem( true ));
+            pTempSet->Put( XFillBmpTileItem( false ));
         }
     }
 
diff --git a/sd/source/ui/inc/fupage.hxx b/sd/source/ui/inc/fupage.hxx
index a33277d9fa3e..a17ce7b1adc5 100644
--- a/sd/source/ui/inc/fupage.hxx
+++ b/sd/source/ui/inc/fupage.hxx
@@ -42,7 +42,7 @@ class FuPage
     virtual void Activate() override;
     virtual void Deactivate() override;
 
-    const SfxItemSet* ExecuteDialog(weld::Window* pParent);
+    const SfxItemSet* ExecuteDialog(weld::Window* pParent, SfxRequest& rReq);
 
 protected:
     virtual ~FuPage() override;
diff --git a/sd/source/ui/sidebar/MasterPageDescriptor.cxx 
b/sd/source/ui/sidebar/MasterPageDescriptor.cxx
index 2f87f3db6423..4b1e0b139b8c 100644
--- a/sd/source/ui/sidebar/MasterPageDescriptor.cxx
+++ b/sd/source/ui/sidebar/MasterPageDescriptor.cxx
@@ -205,6 +205,7 @@ bool MasterPageDescriptor::UpdatePreview (
         {
             pPage = mpMasterPage;
         }
+        //TODO: Notify LOOL of preview updates.
         maLargePreview = (*mpPreviewProvider)(
             rLargeSize.Width(),
             pPage,
diff --git a/sd/source/ui/sidebar/SlideBackground.cxx 
b/sd/source/ui/sidebar/SlideBackground.cxx
index d1c7bdcdb8ef..945ff195325e 100644
--- a/sd/source/ui/sidebar/SlideBackground.cxx
+++ b/sd/source/ui/sidebar/SlideBackground.cxx
@@ -72,6 +72,7 @@
 #include <editeng/ulspitem.hxx>
 #include <editeng/lrspitem.hxx>
 #include <svl/itemset.hxx>
+#include <comphelper/lok.hxx>
 
 using namespace ::com::sun::star;
 
@@ -296,6 +297,14 @@ void SlideBackground::HandleContextChange(
             mpInsertImage->Show();
         }
 
+        // The Insert Image button in the sidebar issues .uno:SelectBackground,
+        // which when invoked without arguments will open the file-open-dialog
+        // to prompt the user to select a file. This is useless in LOOL.
+        // Hide for now so the user will only be able to use the menu to insert
+        // background image, which prompts the user for file selection in the 
browser.
+        if (comphelper::LibreOfficeKit::isActive())
+            mpInsertImage->Hide();
+
         // Need to do a relayouting, otherwise the panel size is not updated 
after show / hide controls
         sfx2::sidebar::Panel* pPanel = 
dynamic_cast<sfx2::sidebar::Panel*>(GetParent());
         if(pPanel)
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx 
b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index 31f64af88d7f..6218dd7e0c75 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -609,13 +609,9 @@ IMPL_LINK(Clipboard, ProcessDragFinished, void*, 
pUserData, void)
         // Remove the pages that have been moved to another place (possibly
         // in the same document.)
         rSelector.DeselectAllPages();
-        PageList::iterator aDraggedPage;
-        for (aDraggedPage=maPagesToRemove.begin();
-             aDraggedPage!=maPagesToRemove.end();
-             ++aDraggedPage)
-        {
-            rSelector.SelectPage(*aDraggedPage);
-        }
+        for (const auto& aDraggedPage : maPagesToRemove)
+            rSelector.SelectPage(aDraggedPage);
+
         mrController.GetSelectionManager()->DeleteSelectedPages();
     }
     mxUndoContext.reset();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to