[Libreoffice-commits] core.git: Branch 'feature/cib_contract57b' - 4 commits - dbaccess/source framework/qa framework/source include/sfx2 include/unotools offapi/com sfx2/source sw/PythonTest_sw_python.mk sw/qa sw/source unotools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Dec 17 11:13:48 UTC 2018
dbaccess/source/core/dataaccess/databasedocument.cxx | 6 +
dbaccess/source/core/dataaccess/databasedocument.hxx | 1
framework/qa/complex/XTitle/CheckXTitle.java | 34 +++++++++-
framework/source/fwe/helper/titlehelper.cxx | 15 ++++
include/sfx2/sfxbasemodel.hxx | 2
include/unotools/mediadescriptor.hxx | 1
offapi/com/sun/star/frame/XModel2.idl | 21 ++++++
sfx2/source/doc/sfxbasemodel.cxx | 30 +++++++++
sw/PythonTest_sw_python.mk | 1
sw/qa/python/check_xmodel.py | 59 +++++++++++++++++++
sw/source/uibase/uno/unotxdoc.cxx | 5 -
unotools/source/misc/mediadescriptor.cxx | 6 +
12 files changed, 174 insertions(+), 7 deletions(-)
New commits:
commit a66e11492b847a53c84211d78da2c946adaaaf4e
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Thu Dec 13 19:58:36 2018 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Dec 17 12:07:30 2018 +0100
tdf#121962 Update fields after layout has been calculated
Change-Id: Ic4a49494652dab416ddb1545da02eb8a7f533828
Reviewed-on: https://gerrit.libreoffice.org/65126
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
(cherry picked from commit 2bc1d00af6863d5c92389f1f4a99d2ab9bb73f81)
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 3a8a7ada5119..6095b8801cbe 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2594,8 +2594,6 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
bStateChanged = true;
}
- // #122919# Force field update before PDF export
- pViewShell->SwViewShell::UpdateFields(true);
if( bStateChanged )
pRenderDocShell->EnableSetModified();
@@ -2605,6 +2603,9 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
pViewShell->CalcLayout();
pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );
+ // #122919# Force field update before PDF export, but after layout init (tdf#121962)
+ pViewShell->SwViewShell::UpdateFields(true);
+
pViewShell->SetPDFExportOption( false );
// enable view again
commit f3104f39740979839135886f42caf204ddb0e477
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Thu Dec 13 09:09:52 2018 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Dec 17 12:06:24 2018 +0100
Allow setting some MediaDescriptor properties during runtime
Change-Id: Id6bb554c0e165c6d1f9c28c48fdbcd7156f42316
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 9e0ee5eceb92..6722be2e6ccb 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/lang/NoSupportException.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/script/provider/theMasterScriptProviderFactory.hpp>
#include <com/sun/star/sdb/DatabaseContext.hpp>
@@ -823,6 +824,11 @@ Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getArgs( ) throw (Runtime
return m_pImpl->getMediaDescriptor().getPropertyValues();
}
+void SAL_CALL ODatabaseDocument::setArgs(const Sequence<beans::PropertyValue>& /* aArgs */)
+{
+ throw NoSupportException();
+}
+
void SAL_CALL ODatabaseDocument::connectController( const Reference< XController >& _xController ) throw (RuntimeException, std::exception)
{
DocumentGuard aGuard(*this, DocumentGuard::DefaultMethod);
diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx
index f9d4107a07ba..80d411272b06 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.hxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.hxx
@@ -327,6 +327,7 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableViewControllerNames( ) throw (css::uno::RuntimeException, std::exception) override ;
virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createDefaultViewController( const css::uno::Reference< css::frame::XFrame >& Frame ) throw (css::lang::IllegalArgumentException, css::uno::Exception, css::uno::RuntimeException, std::exception) override ;
virtual css::uno::Reference< css::frame::XController2 > SAL_CALL createViewController( const OUString& ViewName, const css::uno::Sequence< css::beans::PropertyValue >& Arguments, const css::uno::Reference< css::frame::XFrame >& Frame ) throw (css::lang::IllegalArgumentException, css::uno::Exception, css::uno::RuntimeException, std::exception) override ;
+ virtual void SAL_CALL setArgs(const css::uno::Sequence<css::beans::PropertyValue>& aArgs) override;
// XStorable
virtual sal_Bool SAL_CALL hasLocation( ) throw (css::uno::RuntimeException, std::exception) override ;
diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx
index 8e678caf59e0..051b56f54685 100644
--- a/include/sfx2/sfxbasemodel.hxx
+++ b/include/sfx2/sfxbasemodel.hxx
@@ -350,6 +350,8 @@ public:
css::lang::IllegalArgumentException,
css::uno::Exception, std::exception ) override;
+ virtual void SAL_CALL setArgs(const css::uno::Sequence<css::beans::PropertyValue>& aArgs) override;
+
// XModifiable2
diff --git a/offapi/com/sun/star/frame/XModel2.idl b/offapi/com/sun/star/frame/XModel2.idl
index 0a0e15f1b738..41d44512149a 100644
--- a/offapi/com/sun/star/frame/XModel2.idl
+++ b/offapi/com/sun/star/frame/XModel2.idl
@@ -24,6 +24,7 @@
#include <com/sun/star/container/XEnumeration.idl>
#include <com/sun/star/awt/XWindow.idl>
#include <com/sun/star/lang/IllegalArgumentException.idl>
+#include <com/sun/star/util/InvalidStateException.idl>
module com { module sun { module star { module frame {
@@ -129,6 +130,26 @@ interface XModel2 : com::sun::star::frame::XModel
[in] com::sun::star::frame::XFrame Frame )
raises (com::sun::star::lang::IllegalArgumentException,
com::sun::star::uno::Exception );
+
+ /** Sets com::sun::star::document::MediaDescriptor properties
+ of the current model during runtime.
+
+ @since LibreOffice 6.3
+
+ @param Arguments
+ Properties which should be set
+ Supported properties:
+ <ul>
+ <li>com::sun::star::document::MediaDescriptor::SuggestedSaveAsDir</li>
+ <li>com::sun::star::document::MediaDescriptor::SuggestedSaveAsName</li>
+ </ul>
+
+ @throws com::sun::star::lang::IllegalArgumentException When trying to set an unsupported property
+ @throws com::sun::star::util::InvalidStateException When the document model can not be retrieved
+ */
+ void setArgs([in] sequence< com::sun::star::beans::PropertyValue > Arguments)
+ raises(com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::util::InvalidStateException);
};
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 6be889c2b9dd..979c34f549ce 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -51,6 +51,7 @@
#include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/util/InvalidStateException.hpp>
#include <comphelper/enumhelper.hxx>
#include <cppuhelper/implbase.hxx>
@@ -1050,6 +1051,35 @@ Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs() throw(RuntimeE
return m_pData->m_seqArguments;
}
+void SAL_CALL SfxBaseModel::setArgs(const Sequence<beans::PropertyValue>& aArgs)
+{
+ SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
+ if (!pMedium)
+ {
+ throw util::InvalidStateException(
+ "Medium could not be retrieved, unable to execute setArgs");
+ }
+
+ for (int i = 0; i < aArgs.getLength(); i++)
+ {
+ OUString sValue;
+ aArgs[i].Value >>= sValue;
+
+ if (aArgs[i].Name == "SuggestedSaveAsName")
+ {
+ pMedium->GetItemSet()->Put(SfxStringItem(SID_SUGGESTEDSAVEASNAME, sValue));
+ }
+ else if (aArgs[i].Name == "SuggestedSaveAsDir")
+ {
+ pMedium->GetItemSet()->Put(SfxStringItem(SID_SUGGESTEDSAVEASDIR, sValue));
+ }
+ else
+ {
+ throw lang::IllegalArgumentException("Setting property not supported: " + aArgs[i].Name,
+ comphelper::getProcessComponentContext(), 0);
+ }
+ }
+}
// frame::XModel
diff --git a/sw/PythonTest_sw_python.mk b/sw/PythonTest_sw_python.mk
index 774f6f8aba42..98c833915ab3 100644
--- a/sw/PythonTest_sw_python.mk
+++ b/sw/PythonTest_sw_python.mk
@@ -23,6 +23,7 @@ $(eval $(call gb_PythonTest_add_modules,sw_python,$(SRCDIR)/sw/qa/python,\
check_indexed_property_values \
check_styles \
check_table \
+ check_xmodel \
get_expression \
set_expression \
var_fields \
diff --git a/sw/qa/python/check_xmodel.py b/sw/qa/python/check_xmodel.py
new file mode 100644
index 000000000000..c5374c03c350
--- /dev/null
+++ b/sw/qa/python/check_xmodel.py
@@ -0,0 +1,59 @@
+#! /usr/bin/env python
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+import unittest
+import unohelper
+from org.libreoffice.unotest import UnoInProcess
+from com.sun.star.lang import IllegalArgumentException
+from com.sun.star.beans import PropertyValue
+import uno
+
+
+class TestXModel(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls._uno = UnoInProcess()
+ cls._uno.setUp()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls._uno.tearDown()
+
+ def test_setArgs_valid(self):
+ xDoc = self._uno.openEmptyWriterDoc()
+ self.assertIsNotNone(xDoc)
+
+ p1 = PropertyValue(Name="SuggestedSaveAsName", Value="prettyFileName")
+ p2 = PropertyValue(Name="SuggestedSaveAsDir", Value="/my/dir")
+ xDoc.setArgs([p1, p2])
+
+ # Make sure that all properties are returned with getArgs()
+ args = xDoc.getArgs()
+ self.assertTrue(p1 in args)
+ self.assertTrue(p2 in args)
+
+ xDoc.close(True)
+
+ def test_setArgs_invalid(self):
+ xDoc = self._uno.openEmptyWriterDoc()
+ self.assertIsNotNone(xDoc)
+
+ # IllegalArgumentException should be thrown when setting a non-existing property
+ p1 = PropertyValue(Name="PropertyNotExists", Value="doesntmatter")
+ with self.assertRaises(IllegalArgumentException):
+ xDoc.setArgs([p1])
+
+ xDoc.close(True)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
commit 39bf07cca1bcb181371ea5a3ee0bb2f816f58896
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Nov 20 13:12:13 2018 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Dec 17 11:42:13 2018 +0100
tdf#121537 Add test
Reviewed-on: https://gerrit.libreoffice.org/63654
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
(cherry picked from commit 9b3387f57d4a762f681ab5276aff8764426c6aa4)
Change-Id: Ifdf46dc79f9b3e2b5ab4c9635619a9d7f598affc
diff --git a/framework/qa/complex/XTitle/CheckXTitle.java b/framework/qa/complex/XTitle/CheckXTitle.java
index 8912470003af..a53363edfe5b 100644
--- a/framework/qa/complex/XTitle/CheckXTitle.java
+++ b/framework/qa/complex/XTitle/CheckXTitle.java
@@ -18,10 +18,7 @@
package complex.XTitle;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import helper.URLHelper;
import util.utils;
@@ -169,7 +166,34 @@ public class CheckXTitle
xDisProv = null;
}
- /** @short sets frame title and checks for infinite recusion
+ /** checks the if SuggestedSaveAsName is displayed in the title */
+ @Test
+ public void checkTitleSuggestedFileName() throws Exception
+ {
+ PropertyValue[] lArgs = new PropertyValue[2];
+
+ lArgs[0] = new PropertyValue();
+ lArgs[0].Name = "Hidden";
+ lArgs[0].Value = Boolean.FALSE;
+ lArgs[1] = new PropertyValue();
+ lArgs[1].Name = "SuggestedSaveAsName";
+ lArgs[1].Value = "suggestme.odt";
+
+ // load doc
+ XComponent xDoc = m_xLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, lArgs);
+ assertNotNull("Could not load temporary document", xDoc);
+
+ XModel xModel = UnoRuntime.queryInterface( XModel.class, xDoc );
+ XTitle xTitle = UnoRuntime.queryInterface( XTitle.class, xModel.getCurrentController().getFrame() );
+
+ String title = xTitle.getTitle();
+ assertTrue(title.startsWith("suggestme.odt"));
+
+ XDispatchProvider xDisProv = UnoRuntime.queryInterface( XDispatchProvider.class, xModel.getCurrentController() );
+ prepareQueryAndDispatch( xDisProv, UNO_URL_FOR_CLOSING_DOC );
+ }
+
+ /** @short sets frame title and checks for infinite recursion
@descr sets frame title. then cycles through default and
print preview. then closes the window and checks
commit 5a78981dded92944a9c288fa4f81040c39394881
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Tue Nov 20 09:12:36 2018 +0100
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Dec 17 11:38:24 2018 +0100
tdf#121537 Display SuggestedSaveAsName in title if set
Change-Id: I762eb7766a5cbe788c0a360c8a6f37b9b1106412
Reviewed-on: https://gerrit.libreoffice.org/63639
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
(cherry picked from commit 4355137901e18e24de2ab123fd0454147f1f3890)
diff --git a/framework/source/fwe/helper/titlehelper.cxx b/framework/source/fwe/helper/titlehelper.cxx
index cbd18f96af17..2d54d25824c9 100644
--- a/framework/source/fwe/helper/titlehelper.cxx
+++ b/framework/source/fwe/helper/titlehelper.cxx
@@ -32,12 +32,18 @@
#include <unotools/configmgr.hxx>
#include <unotools/bootstrap.hxx>
+#include <unotools/mediadescriptor.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <rtl/ustrbuf.hxx>
#include <osl/mutex.hxx>
#include <tools/urlobj.hxx>
#include <vcl/opengl/OpenGLWrapper.hxx>
+
+using namespace css;
+using namespace css::uno;
+using namespace css::frame;
+
namespace framework{
TitleHelper::TitleHelper(const css::uno::Reference< css::uno::XComponentContext >& rxContext)
@@ -346,6 +352,10 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram
if (xURLProvider.is())
sURL = xURLProvider->getLocation ();
+ utl::MediaDescriptor aDescriptor(xModel->getArgs());
+ const OUString sSuggestedSaveAsName = aDescriptor.getUnpackedValueOrDefault(
+ utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME(), OUString());
+
if (!sURL.isEmpty())
{
sTitle = impl_convertURL2Title(sURL);
@@ -353,6 +363,11 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram
xNumbers->releaseNumber (nLeasedNumber);
nLeasedNumber = css::frame::UntitledNumbersConst::INVALID_NUMBER;
}
+ else if (!sSuggestedSaveAsName.isEmpty())
+ {
+ // tdf#121537 Use suggested save as name for title if file has not yet been saved
+ sTitle = sSuggestedSaveAsName;
+ }
else
{
if (nLeasedNumber == css::frame::UntitledNumbersConst::INVALID_NUMBER)
diff --git a/include/unotools/mediadescriptor.hxx b/include/unotools/mediadescriptor.hxx
index cc2f02183c82..f6da605795f8 100644
--- a/include/unotools/mediadescriptor.hxx
+++ b/include/unotools/mediadescriptor.hxx
@@ -99,6 +99,7 @@ class UNOTOOLS_DLLPUBLIC MediaDescriptor : public comphelper::SequenceAsHashMap
static const OUString& PROP_MODEL();
static const OUString& PROP_VIEWONLY();
static const OUString& PROP_DOCUMENTBASEURL();
+ static const OUString& PROP_SUGGESTEDSAVEASNAME();
// interface
public:
diff --git a/unotools/source/misc/mediadescriptor.cxx b/unotools/source/misc/mediadescriptor.cxx
index e123474a1abf..9ab4fb492862 100644
--- a/unotools/source/misc/mediadescriptor.cxx
+++ b/unotools/source/misc/mediadescriptor.cxx
@@ -322,6 +322,12 @@ const OUString& MediaDescriptor::PROP_DOCUMENTBASEURL()
return sProp;
}
+const OUString& MediaDescriptor::PROP_SUGGESTEDSAVEASNAME()
+{
+ static const OUString sProp("SuggestedSaveAsName");
+ return sProp;
+}
+
MediaDescriptor::MediaDescriptor()
: SequenceAsHashMap()
{
More information about the Libreoffice-commits
mailing list