[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source solenv/bin xmloff/inc xmloff/source xmloff/util
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 25 07:21:55 UTC 2019
sc/qa/unit/copy_paste_test.cxx | 59 ++++++++++++++++++++++++++++++++++++++++
sc/source/ui/inc/impex.hxx | 4 +-
sc/source/ui/undo/undoblk.cxx | 6 ++--
solenv/bin/native-code.py | 1
xmloff/inc/facreg.hxx | 7 ----
xmloff/source/core/facreg.cxx | 5 ---
xmloff/source/draw/sdxmlimp.cxx | 23 +++++----------
xmloff/util/xo.component | 3 +-
8 files changed, 77 insertions(+), 31 deletions(-)
New commits:
commit 3f471651049a318d7d8917855929e0535daf14b9
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jul 24 21:26:11 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 25 09:21:20 2019 +0200
xmloff: create XMLImportStylesImportOasis instances with an uno constructor
See tdf#74608 for motivation.
Change-Id: I7e56486339d5fd436d4dba723bac8bb9bbed170b
Reviewed-on: https://gerrit.libreoffice.org/76275
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index f7858cdd49d4..fc5e2f725c21 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -273,6 +273,7 @@ core_constructor_list = [
"com_sun_star_comp_Impress_XMLOasisMetaExporter_get_implementation",
"com_sun_star_comp_Impress_XMLOasisMetaImporter_get_implementation",
"com_sun_star_comp_Impress_XMLOasisContentImporter_get_implementation",
+ "com_sun_star_comp_Impress_XMLOasisStylesImporter_get_implementation",
"com_sun_star_comp_Impress_XMLOasisSettingsExporter_get_implementation",
"com_sun_star_comp_Impress_XMLOasisSettingsImporter_get_implementation",
"com_sun_star_comp_Draw_XMLOasisImporter_get_implementation",
diff --git a/xmloff/inc/facreg.hxx b/xmloff/inc/facreg.hxx
index 8541b7842b17..7cb149cac9f1 100644
--- a/xmloff/inc/facreg.hxx
+++ b/xmloff/inc/facreg.hxx
@@ -33,13 +33,6 @@ namespace com { namespace sun { namespace star {
namespace uno { class XInterface; }
} } }
-// impress oasis import
-OUString XMLImpressStylesImportOasis_getImplementationName() throw();
-css::uno::Sequence<OUString> XMLImpressStylesImportOasis_getSupportedServiceNames() throw();
-/// @throws css::uno::Exception
-css::uno::Reference<css::uno::XInterface> XMLImpressStylesImportOasis_createInstance(
- css::uno::Reference<css::lang::XMultiServiceFactory> const & rSMgr);
-
// impress OOo export
OUString XMLImpressExportOOO_getImplementationName() throw();
css::uno::Sequence<OUString> XMLImpressExportOOO_getSupportedServiceNames() throw();
diff --git a/xmloff/source/core/facreg.cxx b/xmloff/source/core/facreg.cxx
index cba072106f97..0190e6b0d818 100644
--- a/xmloff/source/core/facreg.cxx
+++ b/xmloff/source/core/facreg.cxx
@@ -56,10 +56,7 @@ XMLOFF_DLLPUBLIC void * xo_component_getFactory( const sal_Char * pImplName, voi
const sal_Int32 nImplNameLen = strlen( pImplName );
- // impress oasis import
- SINGLEFACTORY( XMLImpressStylesImportOasis )
-
- else SINGLEFACTORY( AnimationsImport )
+ SINGLEFACTORY( AnimationsImport )
// impress OOo export
else SINGLEFACTORY( XMLImpressExportOOO )
diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx
index d161d68d657b..5b5b1ad63ee2 100644
--- a/xmloff/source/draw/sdxmlimp.cxx
+++ b/xmloff/source/draw/sdxmlimp.cxx
@@ -260,20 +260,6 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SdXMLFlatDocContext_Imp
}
}
-#define SERVICE(classname,servicename,implementationname,draw,flags)\
-uno::Sequence< OUString > classname##_getSupportedServiceNames() throw()\
-{\
- return uno::Sequence< OUString > { servicename };\
-}\
-OUString classname##_getImplementationName() throw()\
-{\
- return OUString( implementationname );\
-}\
-uno::Reference< uno::XInterface > classname##_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr)\
-{\
- return static_cast<cppu::OWeakObject*>(new SdXMLImport( comphelper::getComponentContext(rSMgr), implementationname, draw, flags )); \
-}
-
extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLOasisImporter_get_implementation(
uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
@@ -324,7 +310,14 @@ com_sun_star_comp_Draw_XMLOasisSettingsImporter_get_implementation(
new SdXMLImport(pCtx, "XMLDrawSettingsImportOasis", true, SvXMLImportFlags::SETTINGS));
}
-SERVICE( XMLImpressStylesImportOasis, "com.sun.star.comp.Impress.XMLOasisStylesImporter", "XMLImpressStylesImportOasis", false, SvXMLImportFlags::STYLES|SvXMLImportFlags::AUTOSTYLES|SvXMLImportFlags::MASTERSTYLES )
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+com_sun_star_comp_Impress_XMLOasisStylesImporter_get_implementation(
+ uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
+{
+ return cppu::acquire(new SdXMLImport(pCtx, "XMLImpressStylesImportOasis", false,
+ SvXMLImportFlags::STYLES | SvXMLImportFlags::AUTOSTYLES
+ | SvXMLImportFlags::MASTERSTYLES));
+}
extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLOasisContentImporter_get_implementation(
diff --git a/xmloff/util/xo.component b/xmloff/util/xo.component
index abf03a6e9dfc..936b7b627103 100644
--- a/xmloff/util/xo.component
+++ b/xmloff/util/xo.component
@@ -155,7 +155,8 @@
constructor="com_sun_star_comp_Impress_XMLOasisStylesExporter_get_implementation">
<service name="com.sun.star.comp.Impress.XMLOasisStylesExporter"/>
</implementation>
- <implementation name="XMLImpressStylesImportOasis">
+ <implementation name="XMLImpressStylesImportOasis"
+ constructor="com_sun_star_comp_Impress_XMLOasisStylesImporter_get_implementation">
<service name="com.sun.star.comp.Impress.XMLOasisStylesImporter"/>
</implementation>
<implementation name="XMLDrawStylesImportOasis"
commit 4840880148318dc384e28f9a8df9990b8690a4b6
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jul 24 14:40:21 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 25 09:21:13 2019 +0200
tdf#107394 sc ui: fix lack of row height update on undo of paste
This is a problem since commit df9243626b39742a9a148bea95796f8824fee68a
(fdo#73606: Avoid excessive and unnecessary heap allocation of array
objects., 2014-01-14), though it seems this uncovered a problem that was
introduced earlier.
Reading ScViewFunc::AdjustBlockHeight(), commit
64a36fd4f4085ed05e4c0ee40ac109452ff81a78 (ScUndoPaste to handle multiple
ranges., 2011-09-09) changed ScUndoPaste::DoChange(), so that
AdjustBlockHeight() is invoked in a loop, but always with the same
arguments. In case AdjustBlockHeight() doesn't get a mark data, the
function takes the mark data from the view data, which is empty in the
"undo of paste" case, so no row height gets updated.
Fix the problem by explicitly providing the mark data to
AdjustBlockHeight(), probably that was the intention in the second
commit.
[ Testing this from CppunitTest_sc_copypaste means ScImportExport has to
be dllpublic, but that seems still better than having a view shell in
CppunitTest_sc_ucalc. ]
Change-Id: I140b53588d59d231772152c0e820e5fdedf6894c
Reviewed-on: https://gerrit.libreoffice.org/76265
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx
index 4087b9d48946..adc736553953 100644
--- a/sc/qa/unit/copy_paste_test.cxx
+++ b/sc/qa/unit/copy_paste_test.cxx
@@ -13,6 +13,7 @@
#include <docsh.hxx>
#include <tabvwsh.hxx>
+#include <impex.hxx>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XModel2.hpp>
@@ -34,12 +35,14 @@ public:
void testTdf84411();
void testTdf124565();
void testTdf126421();
+ void testTdf107394();
CPPUNIT_TEST_SUITE(ScCopyPasteTest);
CPPUNIT_TEST(testCopyPasteXLS);
CPPUNIT_TEST(testTdf84411);
CPPUNIT_TEST(testTdf124565);
CPPUNIT_TEST(testTdf126421);
+ CPPUNIT_TEST(testTdf107394);
CPPUNIT_TEST_SUITE_END();
private:
@@ -362,6 +365,62 @@ void ScCopyPasteTest::testTdf126421()
xDocSh->DoClose();
}
+void ScCopyPasteTest::testTdf107394()
+{
+ uno::Reference<frame::XDesktop2> xDesktop
+ = frame::Desktop::create(::comphelper::getProcessComponentContext());
+ CPPUNIT_ASSERT(xDesktop.is());
+
+ uno::Reference<lang::XComponent> xComponent
+ = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, {});
+ CPPUNIT_ASSERT(xComponent.is());
+
+ auto pModelObj = dynamic_cast<ScModelObj*>(xComponent.get());
+ CPPUNIT_ASSERT(pModelObj);
+ CPPUNIT_ASSERT(pModelObj->GetDocument());
+
+ ScDocument& rDoc = *pModelObj->GetDocument();
+
+ sal_uInt16 nFirstRowHeight = rDoc.GetRowHeight(0, 0);
+ sal_uInt16 nSecondRowHeight = rDoc.GetRowHeight(1, 0);
+ CPPUNIT_ASSERT_EQUAL(nFirstRowHeight, nSecondRowHeight);
+
+ // Import values to A1:A2.
+ ScImportExport aObj(&rDoc, ScAddress(0,0,0));
+ aObj.SetImportBroadcast(true);
+
+ OString aHTML("<pre>First\nVery long sentence.</pre>");
+ SvMemoryStream aStream;
+ aStream.WriteOString(aHTML);
+ aStream.Seek(0);
+ CPPUNIT_ASSERT(aObj.ImportStream(aStream, OUString(), SotClipboardFormatId::HTML));
+
+ CPPUNIT_ASSERT_EQUAL(OUString("First"), rDoc.GetString(ScAddress(0,0,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Very long sentence."), rDoc.GetString(ScAddress(0,1,0)));
+
+ nFirstRowHeight = rDoc.GetRowHeight(0, 0);
+ nSecondRowHeight = rDoc.GetRowHeight(1, 0);
+ CPPUNIT_ASSERT_GREATER(nFirstRowHeight, nSecondRowHeight);
+
+ // Undo, and check the result.
+ SfxUndoManager* pUndoMgr = rDoc.GetUndoManager();
+ CPPUNIT_ASSERT_MESSAGE("Failed to get the undo manager.", pUndoMgr);
+ pUndoMgr->Undo();
+
+ CPPUNIT_ASSERT(rDoc.GetString(ScAddress(0,0,0)).isEmpty());
+ CPPUNIT_ASSERT(rDoc.GetString(ScAddress(0,1,0)).isEmpty());
+
+ nFirstRowHeight = rDoc.GetRowHeight(0, 0);
+ nSecondRowHeight = rDoc.GetRowHeight(1, 0);
+ // Without the accompanying fix in place, this test would have failed:
+ // - Expected: 256
+ // - Actual : 477
+ // i.e. the increased height of the second row remained after undo.
+ CPPUNIT_ASSERT_EQUAL(nFirstRowHeight, nSecondRowHeight);
+
+ xComponent->dispose();
+}
+
ScCopyPasteTest::ScCopyPasteTest()
: ScBootstrapFixture( "sc/qa/unit/data" )
{
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
index 1b703d821373..3ddba5d9b89a 100644
--- a/sc/source/ui/inc/impex.hxx
+++ b/sc/source/ui/inc/impex.hxx
@@ -44,7 +44,7 @@ struct ScExportTextOptions
bool mbAddQuotes;
};
-class ScImportExport
+class SC_DLLPUBLIC ScImportExport
{
ScDocShell* pDocSh;
ScDocument* pDoc;
@@ -101,7 +101,7 @@ public:
const ScRange& GetRange() const { return aRange; }
- SC_DLLPUBLIC static void EmbeddedNullTreatment( OUString & rStr );
+ static void EmbeddedNullTreatment( OUString & rStr );
static bool IsFormatSupported( SotClipboardFormatId nFormat );
static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p,
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 15d6a8e3e273..54d50c38ac8c 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1079,6 +1079,8 @@ void ScUndoPaste::DoChange(bool bUndo)
{
ScRange& rDrawRange = aDrawRanges[i];
rDoc.ExtendMerge(rDrawRange, true); // only needed for single sheet (text/rtf etc.)
+ ScRangeList aRangeList(rDrawRange);
+ ScMarkData aData(aRangeList);
if (bPaintAll)
{
rDrawRange.aStart.SetCol(0);
@@ -1087,7 +1089,7 @@ void ScUndoPaste::DoChange(bool bUndo)
rDrawRange.aEnd.SetRow(MAXROW);
nPaint |= PaintPartFlags::Top | PaintPartFlags::Left;
if (pViewShell)
- pViewShell->AdjustBlockHeight(false);
+ pViewShell->AdjustBlockHeight(false, &aData);
}
else
{
@@ -1101,7 +1103,7 @@ void ScUndoPaste::DoChange(bool bUndo)
nPaint |= PaintPartFlags::Left;
rDrawRange.aEnd.SetRow(MAXROW);
}
- if (pViewShell && pViewShell->AdjustBlockHeight(false))
+ if (pViewShell && pViewShell->AdjustBlockHeight(false, &aData))
{
rDrawRange.aStart.SetCol(0);
rDrawRange.aStart.SetRow(0);
More information about the Libreoffice-commits
mailing list