[Libreoffice-commits] core.git: cui/source cui/uiconfig

Heena Gupta heena.h.gupta at ericsson.com
Tue May 12 01:38:51 PDT 2015


 cui/source/dialogs/multipat.src    |    5 +
 cui/source/inc/cuires.hrc          |    1 
 cui/source/inc/numpages.hxx        |    5 +
 cui/source/tabpages/numpages.cxx   |  109 +++++++++++++++++++++++++++++++++++++
 cui/uiconfig/ui/pickgraphicpage.ui |   16 ++++-
 5 files changed, 133 insertions(+), 3 deletions(-)

New commits:
commit 511499b3ba08024e3d6853f096ad1d96f96b216d
Author: Heena Gupta <heena.h.gupta at ericsson.com>
Date:   Wed May 6 15:14:20 2015 +0530

    tdf#91904-Import Image for bullets through "Add and Resize" Button
    
    Change-Id: I25390268da3b16261d054cd4c093b35a9ee3ce26
    Reviewed-on: https://gerrit.libreoffice.org/15642
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/dialogs/multipat.src b/cui/source/dialogs/multipat.src
index 09b3718..0dfc110 100644
--- a/cui/source/dialogs/multipat.src
+++ b/cui/source/dialogs/multipat.src
@@ -39,4 +39,9 @@ String RID_SVXSTR_MULTIFILE_DBL_ERR
     Text [ en-US ] = "The file %1 already exists." ;
 };
 
+String RID_SVXSTR_ADD_IMAGE
+{
+    Text [ en-US ] = "Add Image" ;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc
index d6852c3..3214b51 100644
--- a/cui/source/inc/cuires.hrc
+++ b/cui/source/inc/cuires.hrc
@@ -208,6 +208,7 @@
 #define RID_SVXSTR_ARCHIVE_TITLE            (RID_SVX_START + 484)
 #define RID_SVXSTR_ARCHIVE_HEADLINE         (RID_SVX_START + 485)
 #define RID_SVXSTR_MULTIFILE_DBL_ERR        (RID_SVX_START + 486)
+#define RID_SVXSTR_ADD_IMAGE                (RID_SVX_START + 487)
 
 // script organizer
 #define RID_SVXSTR_DELQUERY                 (RID_SVX_START + 1027)
diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx
index fdb7219..032ad45 100644
--- a/cui/source/inc/numpages.hxx
+++ b/cui/source/inc/numpages.hxx
@@ -31,7 +31,7 @@
 #include <vcl/field.hxx>
 #include <editeng/numdef.hxx>
 #include <svtools/ctrlbox.hxx>
-
+#include <vcl/dialog.hxx>
 
 class SvxNumRule;
 class SvxBmpNumValueSet;
@@ -215,6 +215,7 @@ class SvxBitmapPickTabPage : public SfxTabPage
 
     VclPtr<FixedText>          m_pErrorText;
     VclPtr<SvxBmpNumValueSet>  m_pExamplesVS;
+    VclPtr<Button>             m_pBtBrowseFile;
 
     std::vector<OUString> aGrfNames;
     OUString            sNumCharFmtName;
@@ -231,6 +232,8 @@ protected:
         DECL_LINK(NumSelectHdl_Impl, void *);
         DECL_LINK(DoubleClickHdl_Impl, void *);
         DECL_LINK(LinkBmpHdl_Impl, void *);
+        DECL_LINK(ClickAddBrowseHdl_Impl, void * );
+
 
 public:
         SvxBitmapPickTabPage(vcl::Window* pParent,
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index c6e0f22..07de0c9 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -72,6 +72,15 @@
 #include <svl/stritem.hxx>
 #include <svl/slstitm.hxx>
 #include <boost/scoped_ptr.hpp>
+#include <sfx2/filedlghelper.hxx>
+#include "svx/gallery1.hxx"
+#include "svx/galtheme.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+#include <com/sun/star/ucb/SimpleFileAccess.hpp>
+#include <rtl/ustring.h>
+#include <comphelper/string.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/graphicfilter.hxx>
 
 using namespace css;
 using namespace css::uno;
@@ -92,6 +101,8 @@ using namespace css::style;
 
 #define MAX_BMP_WIDTH               16
 #define MAX_BMP_HEIGHT              16
+#define SEARCHPATH_DELIMITER        ((sal_Unicode)';')
+#define SEARCHFILENAME_DELIMITER    ((sal_Unicode)'/')
 
 static bool bLastRelative =         false;
 static const sal_Char cNumberingType[] = "NumberingType";
@@ -813,8 +824,11 @@ SvxBitmapPickTabPage::SvxBitmapPickTabPage(vcl::Window* pParent,
     SetExchangeSupport();
     get(m_pErrorText, "errorft");
     get(m_pExamplesVS, "valueset");
+    get(m_pBtBrowseFile, "browseBtn");
+
     m_pExamplesVS->SetSelectHdl(LINK(this, SvxBitmapPickTabPage, NumSelectHdl_Impl));
     m_pExamplesVS->SetDoubleClickHdl(LINK(this, SvxBitmapPickTabPage, DoubleClickHdl_Impl));
+    m_pBtBrowseFile->SetClickHdl(LINK(this, SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl));
 
     eCoreUnit = rSet.GetPool()->GetMetric(rSet.GetPool()->GetWhich(SID_ATTR_NUMBERING_RULE));
 
@@ -856,6 +870,7 @@ void SvxBitmapPickTabPage::dispose()
     pActNum = NULL;
     delete pSaveNum;
     pSaveNum = NULL;
+    m_pBtBrowseFile.clear();
     m_pErrorText.clear();
     m_pExamplesVS.clear();
     SfxTabPage::dispose();
@@ -1001,6 +1016,100 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, DoubleClickHdl_Impl)
     return 0;
 }
 
+IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl)
+{
+
+    sfx2::FileDialogHelper aFileDialog(0, 0);
+    aFileDialog.SetTitle(CUI_RES(RID_SVXSTR_ADD_IMAGE));
+    if ( aFileDialog.Execute() != ERRCODE_NONE )
+        return 0;
+
+    OUString aPath = SvtPathOptions().GetGalleryPath();
+    OUString aPathToken = aPath.getToken( 1 , SEARCHPATH_DELIMITER );
+
+    OUString aUserImageURL = aFileDialog.GetPath();
+
+    sal_Int32 nSub = comphelper::string::getTokenCount( aUserImageURL, '/');
+    OUString aFileName = aUserImageURL.getToken( nSub-1 , SEARCHFILENAME_DELIMITER );
+
+    OUString aUserGalleryURL = aPathToken + "/" + aFileName;
+    INetURLObject aURL( aUserImageURL );
+    DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
+
+    GraphicDescriptor aDescriptor(aURL);
+    if (aDescriptor.Detect())
+    {
+        uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
+        uno::Reference<ucb::XSimpleFileAccess3> xSimpleFileAccess(
+                     ucb::SimpleFileAccess::create( ::comphelper::getComponentContext(xFactory) ) );
+        if ( xSimpleFileAccess->exists( aUserImageURL ))
+        {
+            xSimpleFileAccess->copy( aUserImageURL, aUserGalleryURL );
+            INetURLObject gURL( aUserGalleryURL );
+                 boost::scoped_ptr<SvStream> pIn(::utl::UcbStreamHelper::CreateStream(
+                          gURL.GetMainURL( INetURLObject::NO_DECODE ), StreamMode::READ ));
+            if ( pIn )
+            {
+                Graphic aGraphic;
+                GraphicConverter::Import( *pIn, aGraphic );
+
+                BitmapEx aBitmap = aGraphic.GetBitmapEx();
+                long nPixelX = (long)(aBitmap.GetSizePixel().Width());
+                long nPixelY = (long)(aBitmap.GetSizePixel().Height());
+                double ratio = nPixelY/(double)nPixelX;
+                if(nPixelX > 30)
+                {
+                    nPixelX = 30;
+                    nPixelY = (long) (nPixelX*ratio);
+                }
+                if(nPixelY > 30)
+                {
+                    nPixelY = 30;
+                    nPixelX = (long) (nPixelY/ratio);
+                }
+
+                aBitmap.Scale( Size( nPixelX, nPixelY ), BmpScaleFlag::Fast );
+                Graphic aScaledGraphic( aBitmap );
+                GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+
+                Sequence< PropertyValue > aFilterData( 2 );
+                aFilterData[ 0 ].Name = "Compression";
+                aFilterData[ 0 ].Value <<= (sal_Int32) -1 ;
+                aFilterData[ 1 ].Name = "Quality";
+                aFilterData[ 1 ].Value <<= (sal_Int32) 1;
+
+                sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( gURL.GetFileExtension() );
+                rFilter.ExportGraphic( aScaledGraphic, gURL , nFilterFormat, &aFilterData );
+                GalleryExplorer::InsertURL( GALLERY_THEME_BULLETS, aUserGalleryURL );
+
+                aGrfNames.push_back(aUserGalleryURL);
+                size_t i = 0;
+                for(std::vector<OUString>::iterator it = aGrfNames.begin(); it != aGrfNames.end(); ++it, ++i)
+                {
+                    m_pExamplesVS->InsertItem( i + 1, i);
+                    INetURLObject aObj(*it);
+                    if(aObj.GetProtocol() == INetProtocol::File)
+                        *it = aObj.PathToFileName();
+                    m_pExamplesVS->SetItemText( i + 1, *it );
+                }
+
+                if(aGrfNames.empty())
+                {
+                    m_pErrorText->Show();
+                }
+                else
+                {
+                    m_pExamplesVS->Show();
+                    m_pExamplesVS->SetFormat();
+                }
+
+            }
+        }
+
+    }
+      return 0;
+}
+
 // static
 void SvxNumOptionsTabPage::GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove )
 {
diff --git a/cui/uiconfig/ui/pickgraphicpage.ui b/cui/uiconfig/ui/pickgraphicpage.ui
index 89fef78..2979aeb 100644
--- a/cui/uiconfig/ui/pickgraphicpage.ui
+++ b/cui/uiconfig/ui/pickgraphicpage.ui
@@ -32,8 +32,8 @@
                 <property name="vexpand">True</property>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
                 <property name="width">1</property>
                 <property name="height">1</property>
               </packing>
@@ -52,6 +52,18 @@
                 <property name="height">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="browseBtn">
+                <property name="label" translatable="yes">Add and Resize</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">end</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
           </object>
         </child>
       </object>


More information about the Libreoffice-commits mailing list