summaryrefslogtreecommitdiff
path: root/sw/qa/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-06-11 11:41:41 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-06-11 12:51:32 +0200
commit7413cc96d239f5fd5a588f13784ccb82b6968bac (patch)
tree0984f774e9f33ce60d15f0612dc4d2bbeb2f5320 /sw/qa/uibase
parent79260c7cd80107f223e0f9bcf4bd91ae40566cbe (diff)
sw image anchor type: consider a style-based custom value
The anchor type is determined during insertion, it's stored as direct formatting after that. We used to have a user-profile default for the anchor type. This commit allows customizing the Graphics or OLE styles: if they specify a custom anchor type, then that is user instead of the user profile setting. This allows creating templates where the default depends on the used template and not on the user profile. The UI for this was added in commit 5951da5175b9d7e5b3b47bd0d90989d2ef528c79 (sw image anchor type: add style UI for this, 2021-06-10). Change-Id: Id05342a5f38dc6267cdbe68b248dc50b87854ce2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117040 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/uibase')
-rw-r--r--sw/qa/uibase/frmdlg/data/image.pngbin0 -> 766 bytes
-rw-r--r--sw/qa/uibase/frmdlg/frmdlg.cxx27
2 files changed, 27 insertions, 0 deletions
diff --git a/sw/qa/uibase/frmdlg/data/image.png b/sw/qa/uibase/frmdlg/data/image.png
new file mode 100644
index 000000000000..fdad35484e7c
--- /dev/null
+++ b/sw/qa/uibase/frmdlg/data/image.png
Binary files differ
diff --git a/sw/qa/uibase/frmdlg/frmdlg.cxx b/sw/qa/uibase/frmdlg/frmdlg.cxx
index 56b96803686e..ce9367ea815b 100644
--- a/sw/qa/uibase/frmdlg/frmdlg.cxx
+++ b/sw/qa/uibase/frmdlg/frmdlg.cxx
@@ -9,6 +9,8 @@
#include <swmodeltestbase.hxx>
+#include <comphelper/propertyvalue.hxx>
+
#include <com/sun/star/text/TextContentAnchorType.hpp>
constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/uibase/frmdlg/data/";
@@ -32,6 +34,31 @@ CPPUNIT_TEST_FIXTURE(SwUibaseFrmdlgTest, testWrappedMathObject)
getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
}
+CPPUNIT_TEST_FIXTURE(SwUibaseFrmdlgTest, testAnchorTypeFromStyle)
+{
+ // Given a document with aGraphics style with anchor type set to as-character:
+ createSwDoc();
+ uno::Reference<beans::XPropertySet> xGraphics(getStyles("FrameStyles")->getByName("Graphics"),
+ uno::UNO_QUERY);
+ xGraphics->setPropertyValue("AnchorType",
+ uno::makeAny(text::TextContentAnchorType_AS_CHARACTER));
+
+ // When inserting an image:
+ OUString aImageURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "image.png";
+ uno::Sequence<beans::PropertyValue> aArgs = {
+ comphelper::makePropertyValue("FileName", aImageURL),
+ };
+ dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs);
+
+ // Then make sure the image's anchor type is as-char:
+ auto eActual = getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType");
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1 (AS_CHARACTER)
+ // - Actual : 4 (AT_CHARACTER)
+ // i.e. the anchor type from the style was ignored.
+ CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, eActual);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */