framework/source/loadenv/loadenv.cxx   |   70 +++++++++++++++------------------
 include/sfx2/objsh.hxx                 |    7 +++
 sfx2/source/appl/sfxpicklist.cxx       |   16 +++----
 sfx2/source/doc/objxtor.cxx            |   65 +++++++++---------------------
 sfx2/source/view/frmload.cxx           |    3 -
 sfx2/source/view/sfxbasecontroller.cxx |    7 ++-
 6 files changed, 75 insertions(+), 93 deletions(-)

New commits:
commit dcdba6ed8984fd135a346a921b3a7888ecef9cb0
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Wed Oct 21 09:21:34 2015 +0200

    lok: Avoid adding to recent documents completely.
    
    Change-Id: I292281e300e8976bf5ae286262a6a3e20de41858

diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index e96269d..b8969a1 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -19,6 +19,7 @@
 
 #include <config_features.h>
 
+#include <comphelper/lok.hxx>
 #include <com/sun/star/document/XDocumentProperties.hpp>
 #include <unotools/historyoptions.hxx>
 #include <unotools/useroptions.hxx>
@@ -161,7 +162,7 @@ SfxPickList::PickListEntry* SfxPickList::GetPickListEntry( 
sal_uInt32 nIndex )
 
 void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh )
 {
-    if (pDocSh->IsAvoidRecentDocs())
+    if (pDocSh->IsAvoidRecentDocs() || comphelper::LibreOfficeKit::isActive())
         return;
 
     SfxMedium *pMed = pDocSh->GetMedium();
@@ -196,10 +197,9 @@ void SfxPickList::AddDocumentToPickList( SfxObjectShell* 
pDocSh )
     if ( pFilter )
         aFilter = pFilter->GetFilterName();
 
-    // generate a thumbnail
     boost::optional<OUString> aThumbnail;
-    // don't generate thumbnail when in headless mode, or on non-desktop (?)
-#if HAVE_FEATURE_DESKTOP
+
+    // generate the thumbnail
     if (!pDocSh->IsModified() && !Application::IsHeadlessModeEnabled())
     {
         // not modified => the document matches what is in the shell
@@ -227,7 +227,7 @@ void SfxPickList::AddDocumentToPickList( SfxObjectShell* 
pDocSh )
             }
         }
     }
-#endif
+
     // add to svtool history options
     SvtHistoryOptions().AppendItem( ePICKLIST,
             aURL.GetURLNoPass( INetURLObject::NO_DECODE ),
commit 9387cca95176889d171a63a46cb2d0f6d59b3d1b
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Wed Oct 21 09:09:01 2015 +0200

    tdf#95095: Implement "AvoidRecentDocs" property for loadComponentFromURL().
    
    When "AvoidRecentDocs" is set to true, the loaded document is not added to 
the
    recent documents list, avoiding the (a bit expensive) thumbnail creation.
    
    Useful when loadComponentFromURL() is called from macros, or when 
LibreOffice
    is controlled via UNO.  See the bug for an example.
    
    Change-Id: I99d516cae8b278199a01276686465f716b9b4cec

diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index ff04e3c..edbe6d1 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -216,6 +216,7 @@ private:
     bool                        bHasName :1;      // sal_True  := existing 
object,
                                                   // sal_False := new object
     bool                        bIsInGenerateThumbnail; //optimize thumbnail 
generate and store procedure to improve odt saving performance, i120030
+    bool                        mbAvoidRecentDocs; ///< Avoid adding to the 
recent documents list, if not necessary.
 
     bool                        CloseInternal();
 private:
@@ -463,6 +464,12 @@ public:
 
     bool                        IsInGenerateAndStoreThumbnail() const {return 
bIsInGenerateThumbnail;}//optimize thumbnail generate and store procedure to 
improve odt saving performance, i120030
 
+    /// Don't add to the recent documents - it's an expensive operation, 
sometimes it is not wanted.
+    bool                        IsAvoidRecentDocs() const { return 
mbAvoidRecentDocs; }
+
+    /// Don't add to the recent documents - it's an expensive operation, 
sometimes it is not wanted.
+    void                        AvoidRecentDocs(bool bAvoid = true) { 
mbAvoidRecentDocs = bAvoid; }
+
     // Transfer IFace
     void                        AbortImport();
     bool                        IsAbortingImport() const;
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 370049b..e96269d 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -161,6 +161,9 @@ SfxPickList::PickListEntry* SfxPickList::GetPickListEntry( 
sal_uInt32 nIndex )
 
 void SfxPickList::AddDocumentToPickList( SfxObjectShell* pDocSh )
 {
+    if (pDocSh->IsAvoidRecentDocs())
+        return;
+
     SfxMedium *pMed = pDocSh->GetMedium();
     if( !pMed )
         return;
@@ -411,11 +414,6 @@ void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
             break;
 
             case SFX_EVENT_OPENDOC:
-            {
-                AddDocumentToPickList(pDocSh);
-            }
-            break;
-
             case SFX_EVENT_SAVEDOCDONE:
             case SFX_EVENT_SAVEASDOCDONE:
             case SFX_EVENT_SAVETODOCDONE:
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index e5207d0..6cc3b31 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -282,12 +282,13 @@ SfxObjectShell_Impl::~SfxObjectShell_Impl()
 
 
 SfxObjectShell::SfxObjectShell( const SfxModelFlags i_nCreationFlags )
-    :   pImp( new SfxObjectShell_Impl( *this ) )
-    ,   pMedium(0)
-    ,   pStyleSheetPool(0)
-    ,   eCreateMode(SfxObjectCreateMode::STANDARD)
-    ,   bHasName( false )
-    ,   bIsInGenerateThumbnail ( false )
+    : pImp(new SfxObjectShell_Impl(*this))
+    , pMedium(0)
+    , pStyleSheetPool(0)
+    , eCreateMode(SfxObjectCreateMode::STANDARD)
+    , bHasName(false)
+    , bIsInGenerateThumbnail (false)
+    , mbAvoidRecentDocs(false)
 {
     if (i_nCreationFlags & SfxModelFlags::EMBEDDED_OBJECT)
         eCreateMode = SfxObjectCreateMode::EMBEDDED;
@@ -303,49 +304,25 @@ SfxObjectShell::SfxObjectShell( const SfxModelFlags 
i_nCreationFlags )
         pImp->m_bDocRecoverySupport = false;
 }
 
+/** Constructor of the class SfxObjectShell.
 
-
-// initializes a document from a file-description
-
-SfxObjectShell::SfxObjectShell
-(
-    SfxObjectCreateMode eMode   /*  Purpose, io which the SfxObjectShell
-                                    is created:
-
-                                    SfxObjectCreateMode::EMBEDDED (default)
-                                        as SO-Server from within another
-                                        Document
-
-                                    SfxObjectCreateMode::STANDARD,
-                                        as a normal Document open stand-alone
-
-                                    SfxObjectCreateMode::PREVIEW
-                                        to enable a Preview, if possible are
-                                        only little information is needed
-
-                                    SfxObjectCreateMode::ORGANIZER
-                                        to be displayed in the Organizer, here
-                                        nothing of the contents is used  */
-)
-
-/*  [Description]
-
-    Constructor of the class SfxObjectShell.
+    @param eMode Purpose, to which the SfxObjectShell is created:
+                 SfxObjectCreateMode::EMBEDDED (default) as SO-Server from 
within another Document
+                 SfxObjectCreateMode::STANDARD, as a normal Document open 
stand-alone
+                 SfxObjectCreateMode::PREVIEW to enable a Preview, if possible 
are only little information is needed
+                 SfxObjectCreateMode::ORGANIZER to be displayed in the 
Organizer, here nothing of the contents is used
 */
-
-:   pImp( new SfxObjectShell_Impl( *this ) ),
-    pMedium(0),
-    pStyleSheetPool(0),
-    eCreateMode(eMode),
-    bHasName( false ),
-    bIsInGenerateThumbnail ( false )
+SfxObjectShell::SfxObjectShell(SfxObjectCreateMode eMode)
+    : pImp(new SfxObjectShell_Impl(*this))
+    , pMedium(0)
+    , pStyleSheetPool(0)
+    , eCreateMode(eMode)
+    , bHasName(false)
+    , bIsInGenerateThumbnail(false)
+    , mbAvoidRecentDocs(false)
 {
 }
 
-
-
-// virtual destructor of typical base-class SfxObjectShell
-
 SfxObjectShell::~SfxObjectShell()
 {
 
diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx
index 80d893e..1ccfe7d 100644
--- a/sfx2/source/view/frmload.cxx
+++ b/sfx2/source/view/frmload.cxx
@@ -529,7 +529,8 @@ void SfxFrameLoader_Impl::impl_removeLoaderArguments( 
::comphelper::NamedValueCo
 ::comphelper::NamedValueCollection 
SfxFrameLoader_Impl::impl_extractViewCreationArgs( 
::comphelper::NamedValueCollection& io_rDescriptor )
 {
     const sal_Char* pKnownViewArgs[] = {
-        "JumpMark"
+        "JumpMark",
+        "AvoidRecentDocs"
     };
 
     ::comphelper::NamedValueCollection aViewArgs;
diff --git a/sfx2/source/view/sfxbasecontroller.cxx 
b/sfx2/source/view/sfxbasecontroller.cxx
index 2a63b2c..f8cfe0c 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -1350,8 +1350,13 @@ void SfxBaseController::ConnectSfxFrame_Impl( const 
ConnectSfxFrame i_eConnect )
             if ( !rFrame.IsInPlace() )
                 pViewFrame->Resize( true );
 
+            ::comphelper::NamedValueCollection 
aViewArgs(getCreationArguments());
+
+            // sometimes we want to avoid adding to the recent documents
+            bool bAvoidRecentDocs = aViewArgs.getOrDefault("AvoidRecentDocs", 
false);
+            
m_pData->m_pViewShell->GetObjectShell()->AvoidRecentDocs(bAvoidRecentDocs);
+
             // if there's a JumpMark given, then, well, jump to it
-            ::comphelper::NamedValueCollection aViewArgs( 
getCreationArguments() );
             const OUString sJumpMark = aViewArgs.getOrDefault( "JumpMark", 
OUString() );
             const bool bHasJumpMark = !sJumpMark.isEmpty();
             OSL_ENSURE( ( 
!m_pData->m_pViewShell->GetObjectShell()->IsLoading() )
commit b34f03271ed765795bb6131c733c3fba425b5425
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Tue Oct 20 20:02:04 2015 +0200

    impl_mergeMediaDescriptorWithMightExistingModelArgs is a sick function name.
    
    Rename to addModelArgs, and kill some whitespace.
    
    Change-Id: Ic644cb2d1074450491d271db36db92049e7d77e3

diff --git a/framework/source/loadenv/loadenv.cxx 
b/framework/source/loadenv/loadenv.cxx
index 66fa2be..4ffae06 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -199,30 +199,29 @@ css::uno::Reference< css::lang::XComponent > 
LoadEnv::loadComponentFromURL(const
     return xComponent;
 }
 
-utl::MediaDescriptor impl_mergeMediaDescriptorWithMightExistingModelArgs(const 
css::uno::Sequence< css::beans::PropertyValue >& lOutsideDescriptor)
+namespace {
+
+utl::MediaDescriptor addModelArgs(const uno::Sequence<beans::PropertyValue>& 
rDescriptor)
 {
-    utl::MediaDescriptor lDescriptor(lOutsideDescriptor);
-    css::uno::Reference< css::frame::XModel > xModel     = 
lDescriptor.getUnpackedValueOrDefault(
-                                                            
utl::MediaDescriptor::PROP_MODEL (),
-                                                            
css::uno::Reference< css::frame::XModel > ());
-    if (xModel.is ())
+    utl::MediaDescriptor rResult(rDescriptor);
+    uno::Reference<frame::XModel> 
xModel(rResult.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_MODEL(), 
uno::Reference<frame::XModel>()));
+
+    if (xModel.is())
     {
-        utl::MediaDescriptor lModelDescriptor(xModel->getArgs());
-        utl::MediaDescriptor::iterator pIt = lModelDescriptor.find( 
utl::MediaDescriptor::PROP_MACROEXECUTIONMODE() );
-        if ( pIt != lModelDescriptor.end() )
-            lDescriptor[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()] = 
pIt->second;
+        utl::MediaDescriptor aModelArgs(xModel->getArgs());
+        utl::MediaDescriptor::iterator pIt = aModelArgs.find( 
utl::MediaDescriptor::PROP_MACROEXECUTIONMODE());
+        if (pIt != aModelArgs.end())
+            rResult[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE()] = 
pIt->second;
     }
 
-    return lDescriptor;
+    return rResult;
 }
 
-void LoadEnv::initializeLoading(const OUString&                                
           sURL            ,
-                                const css::uno::Sequence< 
css::beans::PropertyValue >&           lMediaDescriptor,
-                                const css::uno::Reference< css::frame::XFrame 
>&                 xBaseFrame      ,
-                                const OUString&                                
           sTarget         ,
-                                      sal_Int32                                
                  nSearchFlags    ,
-                                      EFeature                                 
                  eFeature        , // => use default ...
-                                      EContentType                             
                  eContentType    ) // => use default ...
+}
+
+void LoadEnv::initializeLoading(const OUString& sURL, const 
uno::Sequence<beans::PropertyValue>& lMediaDescriptor,
+        const uno::Reference<frame::XFrame>& xBaseFrame, const OUString& 
sTarget,
+        sal_Int32 nSearchFlags, EFeature eFeature, EContentType eContentType)
 {
     osl::MutexGuard g(m_mutex);
 
@@ -232,15 +231,15 @@ void LoadEnv::initializeLoading(const OUString&
 
     // take over all new parameters.
     m_xTargetFrame.clear();
-    m_xBaseFrame                    = xBaseFrame;
-    m_lMediaDescriptor              = 
impl_mergeMediaDescriptorWithMightExistingModelArgs(lMediaDescriptor);
-    m_sTarget                       = sTarget;
-    m_nSearchFlags                  = nSearchFlags;
-    m_eFeature                      = eFeature;
-    m_eContentType                  = eContentType;
-    m_bCloseFrameOnError            = false;
-    m_bReactivateControllerOnError  = false;
-    m_bLoaded                       = false;
+    m_xBaseFrame = xBaseFrame;
+    m_lMediaDescriptor = addModelArgs(lMediaDescriptor);
+    m_sTarget = sTarget;
+    m_nSearchFlags = nSearchFlags;
+    m_eFeature = eFeature;
+    m_eContentType = eContentType;
+    m_bCloseFrameOnError = false;
+    m_bReactivateControllerOnError = false;
+    m_bLoaded = false;
 
     // try to find out, if its really a content, which can be loaded or must 
be "handled"
     // We use a default value for this in-parameter. Then we have to start a 
complex check method
@@ -260,7 +259,7 @@ void LoadEnv::initializeLoading(const OUString&
 
     // parse it - because some following code require that
     m_aURL.Complete = sURL;
-    css::uno::Reference< css::util::XURLTransformer > 
xParser(css::util::URLTransformer::create(m_xContext));
+    uno::Reference<util::XURLTransformer> 
xParser(util::URLTransformer::create(m_xContext));
     xParser->parseStrict(m_aURL);
 
     // BTW: Split URL and JumpMark ...
@@ -281,16 +280,11 @@ void LoadEnv::initializeLoading(const OUString&
 
     // UI mode
     const bool bUIMode =
-        ( ( m_eFeature & E_WORK_WITH_UI )                                      
                                    == E_WORK_WITH_UI ) &&
-        !m_lMediaDescriptor.getUnpackedValueOrDefault( 
utl::MediaDescriptor::PROP_HIDDEN(), false ) &&
-        !m_lMediaDescriptor.getUnpackedValueOrDefault( 
utl::MediaDescriptor::PROP_PREVIEW(), false );
-
-    initializeUIDefaults(
-        m_xContext,
-        m_lMediaDescriptor,
-        bUIMode,
-        &m_pQuietInteraction
-    );
+        ((m_eFeature & E_WORK_WITH_UI) == E_WORK_WITH_UI) &&
+        
!m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_HIDDEN(),
 false) &&
+        
!m_lMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW(),
 false);
+
+    initializeUIDefaults(m_xContext, m_lMediaDescriptor, bUIMode, 
&m_pQuietInteraction);
 }
 
 void LoadEnv::initializeUIDefaults( const css::uno::Reference< 
css::uno::XComponentContext >& i_rxContext,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to