[Libreoffice-commits] core.git: 3 commits - sc/Library_scqahelper.mk sc/qa sw/qa sw/source writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Oct 10 05:16:08 PDT 2014
sc/Library_scqahelper.mk | 2
sc/qa/unit/helper/sorthelper.hxx | 55 +++++++++++++++++++++++
sc/qa/unit/ucalc_sort.cxx | 26 ++++++++--
sw/qa/extras/ooxmlexport/data/effect-extent.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 +++
sw/source/filter/ww8/docxsdrexport.cxx | 23 +++++++++
writerfilter/source/dmapper/GraphicImport.cxx | 41 ++++++++++++++---
7 files changed, 142 insertions(+), 14 deletions(-)
New commits:
commit dd1490db9acea339c8af74d62362109efdb404f8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 10 13:42:06 2014 +0200
DOCX export: improve <wp:effectExtent> handling
Change-Id: If8838529817c72f6e6a3730135a00312fe5c2ad3
diff --git a/sw/qa/extras/ooxmlexport/data/effect-extent.docx b/sw/qa/extras/ooxmlexport/data/effect-extent.docx
new file mode 100644
index 0000000..f35fc3a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/effect-extent.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index cf2c5c0..1277f7b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -447,6 +447,15 @@ DECLARE_OOXMLEXPORT_TEST(testCropPixel, "crop-pixel.docx")
}
}
+DECLARE_OOXMLEXPORT_TEST(testEffectExtent, "effect-extent.docx")
+{
+ // The problem was that in case there were no shadows on the picture, we
+ // wrote a <wp:effectExtent> full or zeros.
+ if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
+ // E.g. this was 0.
+ assertXPath(pXmlDoc, "//wp:effectExtent", "l", "114300");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index e92a2c7..d834c70 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -626,6 +626,29 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS
break;
}
}
+ else if(const SdrObject* pObject = pFrmFmt->FindRealSdrObject())
+ {
+ // No shadow, but we have an idea what was the original effectExtent.
+ uno::Any aAny;
+ pObject->GetGrabBagItem(aAny);
+ comphelper::SequenceAsHashMap aGrabBag(aAny);
+ comphelper::SequenceAsHashMap::iterator it = aGrabBag.find("CT_EffectExtent");
+ if (it != aGrabBag.end())
+ {
+ comphelper::SequenceAsHashMap aEffectExtent(it->second);
+ for (std::pair<const OUString, uno::Any>& rDirection : aEffectExtent)
+ {
+ if (rDirection.first == "l" && rDirection.second.has<sal_Int32>())
+ aLeftExt = OString::number(rDirection.second.get<sal_Int32>());
+ else if (rDirection.first == "t" && rDirection.second.has<sal_Int32>())
+ aTopExt = OString::number(rDirection.second.get<sal_Int32>());
+ else if (rDirection.first == "r" && rDirection.second.has<sal_Int32>())
+ aRightExt = OString::number(rDirection.second.get<sal_Int32>());
+ else if (rDirection.first == "b" && rDirection.second.has<sal_Int32>())
+ aBottomExt = OString::number(rDirection.second.get<sal_Int32>());
+ }
+ }
+ }
m_pImpl->m_pSerializer->singleElementNS(XML_wp, XML_effectExtent,
XML_l, aLeftExt,
commit 95c45bc25dbcb64919334c9f9a59c1132bee6d72
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Oct 10 12:54:22 2014 +0200
DOCX import: map <wp:effectExtent>
Change-Id: Ibdfdca37009df3f518133e85d1daef3a4fea9073
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index ce2b764..c44ac41 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -258,6 +258,10 @@ public:
std::queue<OUString>& m_rPositivePercentages;
OUString sAnchorId;
comphelper::SequenceAsHashMap m_aInteropGrabBag;
+ boost::optional<sal_Int32> m_oEffectExtentLeft;
+ boost::optional<sal_Int32> m_oEffectExtentTop;
+ boost::optional<sal_Int32> m_oEffectExtentRight;
+ boost::optional<sal_Int32> m_oEffectExtentBottom;
GraphicImport_Impl(GraphicImportType eImportType, DomainMapper& rDMapper, std::queue<OUString>& rPositivePercentages) :
nXSize(0)
@@ -411,6 +415,23 @@ public:
SAL_WARN("writerfilter", "failed. Message :" << e.Message);
}
}
+
+ /// Getter for m_aInteropGrabBag, but also merges in the values from other members if they are set.
+ comphelper::SequenceAsHashMap getInteropGrabBag()
+ {
+ comphelper::SequenceAsHashMap aEffectExtent;
+ if (m_oEffectExtentLeft)
+ aEffectExtent["l"] <<= *m_oEffectExtentLeft;
+ if (m_oEffectExtentTop)
+ aEffectExtent["t"] <<= *m_oEffectExtentTop;
+ if (m_oEffectExtentRight)
+ aEffectExtent["r"] <<= *m_oEffectExtentRight;
+ if (m_oEffectExtentBottom)
+ aEffectExtent["b"] <<= *m_oEffectExtentBottom;
+ if (!aEffectExtent.empty())
+ m_aInteropGrabBag["CT_EffectExtent"] <<= aEffectExtent.getAsConstPropertyValueList();
+ return m_aInteropGrabBag;
+ }
};
GraphicImport::GraphicImport(uno::Reference<uno::XComponentContext> const& xComponentContext,
@@ -530,12 +551,18 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
m_pImpl->setYSize(nDim);
}
break;
- case NS_ooxml::LN_CT_EffectExtent_l:// 90907;
- case NS_ooxml::LN_CT_EffectExtent_t:// 90908;
- case NS_ooxml::LN_CT_EffectExtent_r:// 90909;
- case NS_ooxml::LN_CT_EffectExtent_b:// 90910;
- //todo: extends the wrapping size of the object, e.g. if shadow is added
- break;
+ case NS_ooxml::LN_CT_EffectExtent_l:
+ m_pImpl->m_oEffectExtentLeft = nIntValue;
+ break;
+ case NS_ooxml::LN_CT_EffectExtent_t:
+ m_pImpl->m_oEffectExtentTop = nIntValue;
+ break;
+ case NS_ooxml::LN_CT_EffectExtent_r:
+ m_pImpl->m_oEffectExtentRight = nIntValue;
+ break;
+ case NS_ooxml::LN_CT_EffectExtent_b:
+ m_pImpl->m_oEffectExtentBottom = nIntValue;
+ break;
case NS_ooxml::LN_CT_NonVisualDrawingProps_id:// 90650;
//id of the object - ignored
break;
@@ -819,7 +846,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
// Get the grab-bag set by oox, merge with our one and then put it back.
comphelper::SequenceAsHashMap aInteropGrabBag(xShapeProps->getPropertyValue("InteropGrabBag"));
- aInteropGrabBag.update(m_pImpl->m_aInteropGrabBag);
+ aInteropGrabBag.update(m_pImpl->getInteropGrabBag());
xShapeProps->setPropertyValue("InteropGrabBag", uno::makeAny(aInteropGrabBag.getAsConstPropertyValueList()));
}
}
commit 7fabf6c28dcafb677a9081d7edbc96852266fb10
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Fri Oct 10 13:00:35 2014 +0100
Adapt sorting unit tests for new default.
Change-Id: I9885e2712753390f0597233c404ab80c0ad2b537
diff --git a/sc/Library_scqahelper.mk b/sc/Library_scqahelper.mk
index be7f230..a91d2c0 100644
--- a/sc/Library_scqahelper.mk
+++ b/sc/Library_scqahelper.mk
@@ -47,7 +47,7 @@ $(eval $(call gb_Library_use_libraries,scqahelper,\
svl \
svt \
svx \
- svxcore \
+ svxcore \
test \
tl \
unotest \
diff --git a/sc/qa/unit/helper/sorthelper.hxx b/sc/qa/unit/helper/sorthelper.hxx
new file mode 100644
index 0000000..e82b8c2
--- /dev/null
+++ b/sc/qa/unit/helper/sorthelper.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/.
+ */
+
+#ifndef INCLUDED_SC_QA_SORT_HELPER_QAHELPER_HXX
+#define INCLUDED_SC_QA_SORT_HELPER_QAHELPER_HXX
+
+// Unfortunately requires linkage to sc/ internals so
+// can't live in qahelper itself.
+#include "inputopt.hxx"
+
+/**
+ * Temporarily set the sorting type.
+ */
+class SortTypeSetter {
+ bool mbSortRefUpdate;
+public:
+ SortTypeSetter(bool bSortRefUpdate)
+ {
+ mbSortRefUpdate = changeTo(bSortRefUpdate);
+ }
+ bool changeTo(bool bSortRefUpdate)
+ {
+ ScInputOptions aInputOptions = SC_MOD()->GetInputOptions();
+ bool bRet = aInputOptions.GetSortRefUpdate();
+ aInputOptions.SetSortRefUpdate(bSortRefUpdate);
+ SC_MOD()->SetInputOptions(aInputOptions);
+ return bRet;
+ }
+ virtual ~SortTypeSetter()
+ {
+ changeTo(mbSortRefUpdate);
+ }
+};
+
+class SortRefNoUpdateSetter : private SortTypeSetter
+{
+public:
+ SortRefNoUpdateSetter() : SortTypeSetter(false) {}
+};
+
+class SortRefUpdateSetter : private SortTypeSetter
+{
+public:
+ SortRefUpdateSetter() : SortTypeSetter(true) {}
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index f81a394..ce6b9b3 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -8,6 +8,7 @@
*/
#include "ucalc.hxx"
+#include "helper/sorthelper.hxx"
#include <postit.hxx>
#include <sortparam.hxx>
@@ -18,7 +19,6 @@
#include <globalnames.hxx>
#include <dbdocfun.hxx>
#include <scitems.hxx>
-#include <inputopt.hxx>
#include <editutil.hxx>
#include <sal/config.h>
@@ -117,6 +117,8 @@ void Test::testSort()
void Test::testSortHorizontal()
{
+ SortRefUpdateSetter aUpdateSet;
+
ScFormulaOptions aOptions;
aOptions.SetFormulaSepArg(";");
aOptions.SetFormulaSepArrayCol(";");
@@ -361,6 +363,8 @@ void Test::testSortSingleRow()
// if cells in the sort are referenced by formulas
void Test::testSortWithFormulaRefs()
{
+ SortRefUpdateSetter aUpdateSet;
+
m_pDoc->InsertTab(0, "List1");
m_pDoc->InsertTab(1, "List2");
@@ -460,6 +464,8 @@ void Test::testSortWithStrings()
void Test::testSortInFormulaGroup()
{
+ SortRefUpdateSetter aUpdateSet;
+
static struct {
SCCOL nCol;
SCROW nRow;
@@ -691,6 +697,8 @@ void Test::testSortWithCellFormats()
void Test::testSortRefUpdate()
{
+ SortTypeSetter aSortTypeSet(true);
+
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
@@ -811,8 +819,7 @@ void Test::testSortRefUpdate()
m_pDoc->SetString(ScAddress(2,1+i,0), "=RC[-2]");
// Turn off reference update on sort.
- ScInputOptions aInputOption = SC_MOD()->GetInputOptions();
- aInputOption.SetSortRefUpdate(false);
+ aSortTypeSet.changeTo(false);
bSorted = aFunc.Sort(0, aSortData, true, true, true);
CPPUNIT_ASSERT(bSorted);
@@ -837,14 +844,13 @@ void Test::testSortRefUpdate()
CPPUNIT_ASSERT_EQUAL(fCheck, m_pDoc->GetValue(ScAddress(2,i+1,0))); // column C
}
- // Turn it back on.
- aInputOption.SetSortRefUpdate(true);
-
m_pDoc->DeleteTab(0);
}
void Test::testSortRefUpdate2()
{
+ SortRefUpdateSetter aUpdateSet;
+
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
@@ -932,6 +938,8 @@ void Test::testSortRefUpdate2()
void Test::testSortRefUpdate3()
{
+ SortRefUpdateSetter aUpdateSet;
+
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Sort");
@@ -1020,6 +1028,8 @@ void Test::testSortRefUpdate3()
// testRefInterne.ods
void Test::testSortRefUpdate4()
{
+ SortRefUpdateSetter aUpdateSet;
+
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Sort");
m_pDoc->InsertTab(1, "Lesson1");
@@ -1217,6 +1227,8 @@ void Test::testSortRefUpdate4()
* before midnight, ermm.. */
void Test::testSortRefUpdate5()
{
+ SortRefUpdateSetter aUpdateSet;
+
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
m_pDoc->InsertTab(0, "Sort");
@@ -1388,6 +1400,8 @@ void Test::testSortOutOfPlaceResult()
void Test::testSortPartialFormulaGroup()
{
+ SortRefUpdateSetter aUpdateSet;
+
sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
FormulaGrammarSwitch aFGSwitch(m_pDoc, formula::FormulaGrammar::GRAM_ENGLISH_XL_R1C1);
More information about the Libreoffice-commits
mailing list