[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - embeddedobj/Library_embobj.mk embeddedobj/source filter/source include/sfx2 sfx2/source sw/source

Szymon Kłos szymon.klos at collabora.com
Fri Jul 14 14:02:33 UTC 2017


 embeddedobj/Library_embobj.mk            |    1 +
 embeddedobj/source/general/docholder.cxx |   16 ++++++++++++++++
 embeddedobj/source/inc/commonembobj.hxx  |    1 +
 embeddedobj/source/msole/oleembed.cxx    |    3 +++
 filter/source/msfilter/msdffimp.cxx      |    8 ++++++++
 include/sfx2/sfx.hrc                     |    2 +-
 sfx2/source/appl/app.src                 |    5 +++++
 sw/source/core/unocore/unoframe.cxx      |    7 +++++++
 8 files changed, 42 insertions(+), 1 deletion(-)

New commits:
commit 077e11ea9bb4caf5c02314eefd668e41ea08491d
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Tue Jul 11 17:56:23 2017 +0200

    Show document title for embedded documents
    
    Embedded documents had "Untitled" name.
    This patch shows "<root document> (Embedded document)"
    string in the title bar.
    
    Change-Id: I6283240415f9e0c07c4c69672732a7c14eea9f5d
    Reviewed-on: https://gerrit.libreoffice.org/39835
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Reviewed-on: https://gerrit.libreoffice.org/39934
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/embeddedobj/Library_embobj.mk b/embeddedobj/Library_embobj.mk
index 7de4e48dd5e8..551a41013387 100644
--- a/embeddedobj/Library_embobj.mk
+++ b/embeddedobj/Library_embobj.mk
@@ -29,6 +29,7 @@ $(eval $(call gb_Library_use_libraries,embobj,\
 	svt \
 	vcl \
 	tl \
+	i18nlangtag \
 	$(gb_UWINAPI) \
 ))
 
diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx
index d465c215356c..a67091ff3f5d 100644
--- a/embeddedobj/source/general/docholder.cxx
+++ b/embeddedobj/source/general/docholder.cxx
@@ -19,6 +19,8 @@
 
 #include <com/sun/star/embed/Aspects.hpp>
 #include <com/sun/star/frame/TaskCreator.hpp>
+#include <com/sun/star/frame/XTitle.hpp>
+#include <com/sun/star/frame/TerminationVetoException.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -65,6 +67,9 @@
 #include <rtl/process.h>
 #include <vcl/svapp.hxx>
 #include <svtools/embedhlp.hxx>
+#include <tools/resmgr.hxx>
+#include <vcl/settings.hxx>
+#include <sfx2/sfx.hrc>
 
 #include <comphelper/processfactory.hxx>
 #include <comphelper/namedvaluecollection.hxx>
@@ -971,6 +976,17 @@ bool DocumentHolder::LoadDocToFrame( bool bInPlace )
             ::comphelper::NamedValueCollection aArgs;
             aArgs.put( "Model", m_xComponent );
             aArgs.put( "ReadOnly", m_bReadOnly );
+
+            // set document title to show in the title bar
+            css::uno::Reference< css::frame::XTitle > xModelTitle( xDoc, css::uno::UNO_QUERY );
+            if( xModelTitle.is() )
+            {
+                LanguageTag aLocale( Application::GetSettings().GetUILanguageTag() );
+                ResMgr* pResMgr = ResMgr::SearchCreateResMgr( "sfx", aLocale );
+                OUString nTitle = ResId( STR_EMBEDDED_TITLE, *pResMgr );
+                xModelTitle->setTitle( m_pEmbedObj->getContainerName() + nTitle );
+            }
+
             if ( bInPlace )
                 aArgs.put( "PluginMode", sal_Int16(1) );
             OUString sUrl;
diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx
index 174e110b3d10..b1e95020bcd5 100644
--- a/embeddedobj/source/inc/commonembobj.hxx
+++ b/embeddedobj/source/inc/commonembobj.hxx
@@ -247,6 +247,7 @@ public:
     // not a real listener and should not be
     void PostEvent_Impl( const OUString& aEventName );
 
+    OUString getContainerName() { return m_aContainerName; }
 // XInterface
 
     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType )
diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx
index b43904fa14d1..11a037c0cd2f 100644
--- a/embeddedobj/source/msole/oleembed.cxx
+++ b/embeddedobj/source/msole/oleembed.cxx
@@ -356,6 +356,9 @@ bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >&
                 nStep = 4;
                 m_xWrappedObject.set( xEmbCreator->createInstanceInitFromEntry( m_xParentStorage, m_aEntryName, uno::Sequence< beans::PropertyValue >(), uno::Sequence< beans::PropertyValue >() ), uno::UNO_QUERY_THROW );
 
+                // remember parent document name to show in the title bar
+                m_xWrappedObject->setContainerName( m_aContainerName );
+
                 bResult = true; // the change is no more revertable
                 try
                 {
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index de9f0d489111..207a9012a45c 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -7154,6 +7154,10 @@ SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
                             rVisArea, rBaseURL));
                     if ( xObj.is() )
                     {
+                        // remember file name to use in the title bar
+                        INetURLObject aURL(rBaseURL);
+                        xObj->setContainerName(aURL.GetLastName(INetURLObject::DecodeMechanism::DECODE_WITH_CHARSET));
+
                         svt::EmbeddedObjectRef aObj( xObj, nAspect );
 
                         // TODO/LATER: need MediaType
@@ -7216,6 +7220,10 @@ SdrOle2Obj* SvxMSDffManager::CreateSdrOLEFromStorage(
             uno::Reference < embed::XEmbeddedObject > xObj = aCnt.GetEmbeddedObject( aDstStgName );
             if( xObj.is() )
             {
+                // remember file name to use in the title bar
+                INetURLObject aURL( rBaseURL );
+                xObj->setContainerName( aURL.GetLastName( INetURLObject::DecodeMechanism::DECODE_WITH_CHARSET ) );
+
                 // the visual area must be retrieved from the metafile (object doesn't know it so far)
 
                 if ( nAspect != embed::Aspects::MSOLE_ICON )
diff --git a/include/sfx2/sfx.hrc b/include/sfx2/sfx.hrc
index df385999e1a7..137aed9c6b18 100644
--- a/include/sfx2/sfx.hrc
+++ b/include/sfx2/sfx.hrc
@@ -138,7 +138,7 @@
 #define STR_ERRUNOEVENTBINDUNG              (RID_SFX_START+119)
 #define STR_SHARED                          (RID_SFX_START+120)
 #define RID_XMLSEC_DOCUMENTSIGNED           (RID_SFX_START+121)
-// Here is a gap, STR_PASSWORD was removed  RID_SFX_START+122
+#define STR_EMBEDDED_TITLE                  (RID_SFX_START+122)
 #define STR_PASSWD_EMPTY                    (RID_SFX_START+123)
 #define STR_PASSWD_MIN_LEN                  (RID_SFX_START+124)
 #define STR_NONCHECKEDOUT_DOCUMENT          (RID_SFX_START+125)
diff --git a/sfx2/source/appl/app.src b/sfx2/source/appl/app.src
index 21c5f9175f2e..ff9e83e273aa 100644
--- a/sfx2/source/appl/app.src
+++ b/sfx2/source/appl/app.src
@@ -311,6 +311,11 @@ String RID_XMLSEC_DOCUMENTSIGNED
     Text [ en-US ] = " (Signed)" ;
 };
 
+String STR_EMBEDDED_TITLE
+{
+    Text [ en-US ] = " (Embedded document)" ;
+};
+
 String STR_STANDARD
 {
     Text [ en-US ] = "Standard" ;
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index e428e5b51cda..92134b0408a3 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/embed/XComponentSupplier.hpp>
 #include <com/sun/star/embed/EmbedStates.hpp>
 #include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/frame/XTitle.hpp>
 #include <com/sun/star/graphic/XGraphicProvider.hpp>
 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
 #include <o3tl/any.hxx>
@@ -2989,6 +2990,12 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
 
                     ::svt::EmbeddedObjectRef xObjRef( xIPObj, m_nDrawAspect );
                     pFormat2 = pDoc->getIDocumentContentOperations().Insert(aPam, xObjRef, &aFrameSet );
+
+                    // store main document name to show in the title bar
+                    uno::Reference< frame::XTitle > xModelTitle( pDoc->GetDocShell()->GetModel(), css::uno::UNO_QUERY );
+                    if( xModelTitle.is() )
+                        xIPObj->setContainerName( xModelTitle->getTitle() );
+
                     assert(pFormat2 && "Doc->Insert(notxt) failed.");
 
                     pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, nullptr);


More information about the Libreoffice-commits mailing list