Commits

Anonymous committed a3e93b7

#i115372# - respect restricted paths.

Comments (0)

Files changed (5)

fpicker/source/office/iodlg.cxx

     nDelta += ( nBtnCount * n3AppFontInPixel );
 
     String aTitle( SvtResId( STR_SVT_FILEPICKER_PLACES ) );
-    _pPlacesWin = new fpicker::office::PlacesWindow( this, aTitle );
+    _pPlacesWin = new fpicker::office::PlacesWindow( this, aTitle, &m_aURLFilter );
     m_bHasPlaces = _pPlacesWin->GetEntryCount() > 0;
 
     long nXOffset = 0;

fpicker/source/office/iodlg.hxx

 #include <unotools/confignode.hxx>
 #include "svl/inettype.hxx"
 #include "svl/urlfilter.hxx"
-#include <svl/restrictedpaths.hxx>
+#include "svl/restrictedpaths.hxx"
 #include "asyncfilepicker.hxx"
 #include "OfficeControlAccess.hxx"
 #include "fpsmartcontent.hxx"
-#include <svtools/ivctrl.hxx>
+#include "svtools/ivctrl.hxx"
 #include "history.hxx"
 
 #include <set>

fpicker/source/office/iodlgimp.cxx

     {
         ResMgr * operator ()()
         {
-            return ResMgr::CreateResMgr (CREATEVERSIONRESMGR_NAME(svs));
+            return ResMgr::CreateResMgr (CREATEVERSIONRESMGR_NAME(svl));
         }
         static ResMgr * getOrCreate()
         {

fpicker/source/office/placeswin.cxx

 #include "unotools/pathoptions.hxx"
 #include "comphelper/processfactory.hxx"
 #include "unotools/ucbstreamhelper.hxx"
+#include "svl/urlfilter.hxx"
 #include "svtools/filter.hxx"
 #include "svtools/headbar.hxx"
 #include "vcl/mnemonic.hxx"
 
 // class PlacesWindow ----------------------------------------------
 
-PlacesWindow::PlacesWindow( Window* pParent, const String& rTitle )
+PlacesWindow::PlacesWindow(
+    Window* pParent, const String& rTitle, const IUrlFilter* pUrlFilter )
 : Control( pParent, WB_DIALOGCONTROL | WB_BORDER ),
   m_aIconCtrl( this,
                WB_DETAILS | WB_HIGHLIGHTFRAME | WB_TABSTOP | WB_NOHSCROLL |
                WB_NOBORDER ),
-  m_pHeaderBar( NULL )
+  m_pHeaderBar( NULL ),
+  m_pUrlFilter( pUrlFilter )
 {
-    m_aIconCtrl.SetAccessibleName(
-        String( RTL_CONSTASCII_USTRINGPARAM( "Places" ) ) );
+    m_aIconCtrl.SetAccessibleName( rTitle );
     m_aIconCtrl.SetSelectionMode( SINGLE_SELECTION );
     m_aIconCtrl.Show();
 
     sal_Int32 nInsertPos = 0;
     while ( it != end )
     {
-        rtl::OUString aTitle( (*it).getTitle() );
+        String aPlaceURL;
+        bool bFolder = (*it).isFolder();
+        if ( bFolder )
+        {
+            aPlaceURL = String( (*it).getHierarchyURL() );
+        }
+        else
+        {
+            // Target URL (mandatory for links.)
+            //bool bLink = (*it).isLink();
+            aPlaceURL = String( (*it).getTargetURL() );
 
-        bool bFolder = (*it).isFolder();
+            // TargetURL may contain a reference to the Office installation
+            // directory. To ensure a relocatable office installation, the path
+            // to the office installtion directory must never be stored
+            // directly. A placeholder is used instead. Replace it by actual
+            // installation directory.
+            if ( aPlaceURL.Len() )
+                aPlaceURL = aPathOpts.SubstituteVariable( aPlaceURL );
+        }
 
-        // Target URL (optional)
-        //bool bLink = (*it).isLink();
-        rtl::OUString aTargetURL( (*it).getTargetURL() );
+        if ( !m_pUrlFilter || m_pUrlFilter->isUrlAllowed( aPlaceURL ) )
+        {
+            rtl::OUString aTitle( (*it).getTitle() );
 
-        // TargetURL may contain a reference to the Office installation
-        // directory. To ensure a reloctable office installation, the path to
-        // the office installtion directory must never be stored directly. A
-        // placeholder is used instead. Replace it by actual installation
-        // directory.
-        if ( aTargetURL.getLength() )
-            aTargetURL = aPathOpts.SubstituteVariable( String( aTargetURL ) );
+            // QuickHelp text (optional).
+            rtl::OUString aQuickHelp( (*it).queryQuickHelpText() );
 
-        // QuickHelp text (optional).
-        rtl::OUString aQuickHelp( (*it).queryQuickHelpText() );
+            // Icon (optional)
+            rtl::OUString aIconURL( (*it).queryIconURL() );;
+            if ( aIconURL.getLength() )
+                aIconURL = aPathOpts.SubstituteVariable( String( aIconURL ) );
 
-        // Icon (optional)
-        rtl::OUString aIconURL( (*it).queryIconURL() );;
+            Image aImage;
+            if ( !aIconURL.getLength() ||
+                 !getImageFromURL( aIconURL, aIconSize, aImage, bHiContrast ) )
+                aImage = bFolder ? aFolderImage : aLinkImage;
 
-        if ( aIconURL.getLength() )
-            aIconURL = aPathOpts.SubstituteVariable( String( aIconURL ) );
+            // ReadOnly mode (optional)
+            //bool bReadOnly = (*it).queryReadOnly();
 
-        Image aImage;
-        if ( !aIconURL.getLength() ||
-             !getImageFromURL( aIconURL, aIconSize, aImage, bHiContrast ) )
-            aImage = bFolder ? aFolderImage : aLinkImage;
+            SvxIconChoiceCtrlEntry* pEntry =
+                m_aIconCtrl.InsertEntry( aTitle, aImage, nInsertPos );
+            pEntry->SetUserData( new String ( aPlaceURL ) );
+            pEntry->SetQuickHelpText( aQuickHelp );
+            m_aIconCtrl.SetEntryTextMode( IcnShowTextFull, pEntry );
 
-        // ReadOnly mode (optional)
-        //bool bReadOnly = (*it).queryReadOnly();
-
-        SvxIconChoiceCtrlEntry* pEntry =
-            m_aIconCtrl.InsertEntry( aTitle, aImage, nInsertPos );
-        pEntry->SetUserData(
-            new String( bFolder ? (*it).getHierarchyURL() : aTargetURL ) );
-        pEntry->SetQuickHelpText( aQuickHelp );
-        m_aIconCtrl.SetEntryTextMode( IcnShowTextFull, pEntry );
-
-        nInsertPos++;
+            nInsertPos++;
+        }
         it++;
     }
     m_aIconCtrl.CreateAutoMnemonics();

fpicker/source/office/placeswin.hxx

 #include <svtools/ivctrl.hxx>
 
 class HeaderBar;
+class IUrlFilter;
 
 namespace fpicker { namespace office {
 
 private:
     SvtIconChoiceCtrl   m_aIconCtrl;
     HeaderBar          *m_pHeaderBar;
+    const IUrlFilter   *m_pUrlFilter;
 
     void          initHeaderbar( const String& rTitle );
     SvxIconChoiceCtrlEntry*
                                    bool bHiContrast );
 
 public:
-    PlacesWindow( Window* pParent, const String& rTitle  );
+    PlacesWindow( Window* pParent, const String& rTitle, const IUrlFilter* pUrlFilter );
     ~PlacesWindow();
 
     virtual void Resize();