Rebased ref, commits from common ancestor:
commit 3dfd05124786aeaaac6feeddbbdbf5df91d71fee
Author: Tamás Zolnai <[email protected]>
AuthorDate: Thu Oct 2 08:43:56 2025 +0200
Commit: Tamás Zolnai <[email protected]>
CommitDate: Mon Oct 6 05:19:20 2025 +0200
First fix + first unit test.
Change-Id: I844024be411d7b90dfc288a056187f003995f019
diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx
index 4311726b1831..541f59dc127c 100644
--- a/svx/source/svdraw/svdsnpv.cxx
+++ b/svx/source/svdraw/svdsnpv.cxx
@@ -260,6 +260,7 @@ Point SdrSnapView::GetSnapPos(const Point& rPnt, const
SdrPageView* pPV) const
#define NOT_SNAPPED 0x7FFFFFFF
SdrSnap SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
{
+ SAL_WARN( "SdrSnapView", "SdrSnapView::SnapPos");
if (!mbSnapEnab) return SdrSnap::NOTSNAPPED;
tools::Long x=rPnt.X();
tools::Long y=rPnt.Y();
@@ -267,6 +268,8 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const
SdrPageView* pPV) const
pPV=GetSdrPageView();
if (pPV==nullptr) return SdrSnap::NOTSNAPPED;
}
+ SAL_WARN( "SdrSnapView", "SdrSnapView::SnapPos, x: " << x);
+ SAL_WARN( "SdrSnapView", "SdrSnapView::SnapPos, y: " << y);
tools::Long dx=NOT_SNAPPED;
tools::Long dy=NOT_SNAPPED;
@@ -275,6 +278,7 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const
SdrPageView* pPV) const
tools::Long my=maMagnSiz.Height();
if (mbHlplVisible && mbHlplSnap && !IsDragHelpLine())
{
+ SAL_WARN( "SdrSnapView", "mbHlplVisible");
const SdrHelpLineList& rHLL=pPV->GetHelpLines();
sal_uInt16 nCount=rHLL.GetCount();
for (sal_uInt16 i=nCount; i>0;) {
@@ -302,6 +306,7 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const
SdrPageView* pPV) const
}
}
if (mbBordVisible && mbBordSnap) {
+ SAL_WARN( "SdrSnapView", "mbBordVisible && mbBordSnap");
SdrPage* pPage=pPV->GetPage();
tools::Long xs=pPage->GetWidth();
tools::Long ys=pPage->GetHeight();
@@ -320,6 +325,7 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const
SdrPageView* pPV) const
a=y- ys ; if (std::abs(a)<=my) { dy1=-a; if
(std::abs(dy1)<std::abs(dy)) dy=dy1; } // right edge of paper
}
if (mbOFrmSnap || mbOPntSnap) {
+ SAL_WARN( "SdrSnapView", "mbOFrmSnap || mbOPntSnap");
sal_uInt32 nMaxPointSnapCount=200;
sal_uInt32 nMaxFrameSnapCount=200;
@@ -336,6 +342,7 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const
SdrPageView* pPV) const
if (aRect.Contains(rPnt)) {
if (mbOPntSnap && nMaxPointSnapCount>0)
{
+ SAL_WARN( "SdrSnapView", "mbOPntSnap");
sal_uInt32 nCount(pO->GetSnapPointCount());
for (sal_uInt32 i(0); i < nCount && nMaxPointSnapCount >
0; i++)
{
@@ -350,6 +357,7 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const
SdrPageView* pPV) const
}
}
if (mbOFrmSnap && nMaxFrameSnapCount>0) {
+ SAL_WARN( "SdrSnapView", "mbOFrmSnap");
tools::Rectangle aLog(pO->GetSnapRect());
tools::Rectangle aR1(aLog);
aR1.AdjustLeft( -mx );
@@ -369,35 +377,61 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const
SdrPageView* pPV) const
}
if(mbGridSnap)
{
+ SAL_WARN( "SdrSnapView", "mbGridSnap");
+ SAL_WARN( "SdrSnapView", "mbGridSnap, maSnapWdtX: " << maSnapWdtX);
+
+ const SdrPageGridFrameList* pFrames =
pPV->GetPage()->GetGridFrameList(pPV, nullptr);
+ SAL_WARN( "SdrSnapView", "mbGridSnap, pFrames->GetCount(): " <<
(!pFrames ? 0 : pFrames->GetCount()));
+ Point gridOrigin = pPV->GetPageOrigin();
+ if (pFrames != nullptr) {
+ for (sal_uInt16 nFrame = 0; nFrame < pFrames->GetCount(); nFrame++)
+ {
+ const SdrPageGridFrame& rGridFrame = (*pFrames)[nFrame];
+ if(rGridFrame.GetPaperRect().Contains(rPnt))
+ {
+ gridOrigin = rGridFrame.GetUserArea().TopLeft();
+ break;
+ }
+ }
+ }
+
+ SAL_WARN( "SdrSnapView", "mbGridSnap, gridOrigin.X(): " <<
gridOrigin.X());
double fSnapWidth(maSnapWdtX);
if(dx == NOT_SNAPPED && fSnapWidth != 0.0)
{
double fx = static_cast<double>(x);
// round instead of trunc
- if(fx - static_cast<double>(pPV->GetPageOrigin().X()) >= 0.0)
+ if(fx - static_cast<double>(gridOrigin.X()) >= 0.0)
fx += fSnapWidth / 2.0;
else
fx -= fSnapWidth / 2.0;
- x = static_cast<tools::Long>((fx -
static_cast<double>(pPV->GetPageOrigin().X())) / fSnapWidth);
- x = static_cast<tools::Long>(static_cast<double>(x) * fSnapWidth +
static_cast<double>(pPV->GetPageOrigin().X()));
+ x = static_cast<tools::Long>((fx -
static_cast<double>(gridOrigin.X())) / fSnapWidth);
+ x = static_cast<tools::Long>(static_cast<double>(x) * fSnapWidth +
static_cast<double>(gridOrigin.X()));
dx = 0;
+ SAL_WARN( "SdrSnapView", "mbGridSnap, new x: " << x);
}
fSnapWidth = double(maSnapWdtY);
+ SAL_WARN( "SdrSnapView", "mbGridSnap, maSnapWdtY: " << maSnapWdtY);
+ SAL_WARN( "SdrSnapView", "mbGridSnap, gridOrigin.Y(): " <<
gridOrigin.Y());
if(dy == NOT_SNAPPED && fSnapWidth)
{
double fy = static_cast<double>(y);
// round instead of trunc
- if(fy - static_cast<double>(pPV->GetPageOrigin().Y()) >= 0.0)
+ if(fy - static_cast<double>(gridOrigin.Y()) >= 0.0)
fy += fSnapWidth / 2.0;
else
fy -= fSnapWidth / 2.0;
- y = static_cast<tools::Long>((fy -
static_cast<double>(pPV->GetPageOrigin().Y())) / fSnapWidth);
- y = static_cast<tools::Long>(static_cast<double>(y) * fSnapWidth +
static_cast<double>(pPV->GetPageOrigin().Y()));
+ SAL_WARN( "SdrSnapView", "mbGridSnap, fy: " << fy);
+ y = static_cast<tools::Long>((fy -
static_cast<double>(gridOrigin.Y())) / fSnapWidth);
+ SAL_WARN( "SdrSnapView", "mbGridSnap, y: " << y);
+ y = static_cast<tools::Long>(static_cast<double>(y) * fSnapWidth +
static_cast<double>(gridOrigin.Y()));
+ SAL_WARN( "SdrSnapView", "mbGridSnap, y: " << y);
dy = 0;
+ SAL_WARN( "SdrSnapView", "mbGridSnap, new y: " << y);
}
}
SdrSnap bRet=SdrSnap::NOTSNAPPED;
@@ -405,6 +439,8 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const
SdrPageView* pPV) const
if (dy==NOT_SNAPPED) dy=0; else bRet|=SdrSnap::YSNAPPED;
rPnt.setX(x+dx );
rPnt.setY(y+dy );
+
+ SAL_WARN( "SdrSnapView", "SdrSnapView::SnapPos, rPnt: " << rPnt);
return bRet;
}
diff --git a/sw/qa/extras/uiwriter/data/snapToGridShape.fodt
b/sw/qa/extras/uiwriter/data/snapToGridShape.fodt
new file mode 100644
index 000000000000..bb58bd14c821
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/snapToGridShape.fodt
@@ -0,0 +1,311 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"
xmlns:grddl="http://www.w3.org/2003/g/data-view#"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:dom="http://www.w3.org/2001/xml-events"
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
xmlns:math="http://www.w3.org/1998/Math/MathML"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:ooo="http://openoffice.org/2004/office"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
xmlns:ooow="http://openoffice.org/2004/writer"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:drawooo="http://openoffice.org/2010/draw"
xmlns:oooc="http://openoffice.org/2004/calc"
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:c
alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
xmlns:tableooo="http://openoffice.org/2009/table"
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
xmlns:rpt="http://openoffice.org/2005/report"
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
xmlns:officeooo="http://openoffice.org/2009/office"
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0"
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
meta:1.0"
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text">
+
<office:meta><meta:creation-date>2025-10-02T13:59:47.055516525</meta:creation-date><dc:date>2025-10-03T15:33:13.627427844</dc:date><meta:editing-duration>PT1M38S</meta:editing-duration><meta:editing-cycles>2</meta:editing-cycles><meta:generator>LibreOfficeDev/26.2.0.0.alpha0$Linux_X86_64
LibreOffice_project/c1e6c1258715316678fac4b7c1286aeb410cc05f</meta:generator><meta:document-statistic
meta:table-count="0" meta:image-count="0" meta:object-count="0"
meta:page-count="1" meta:paragraph-count="0" meta:word-count="0"
meta:character-count="0" meta:non-whitespace-character-count="0"/></office:meta>
+ <office:settings>
+ <config:config-item-set config:name="ooo:view-settings">
+ <config:config-item config:name="ViewAreaTop"
config:type="long">0</config:config-item>
+ <config:config-item config:name="ViewAreaLeft"
config:type="long">0</config:config-item>
+ <config:config-item config:name="ViewAreaWidth"
config:type="long">30496</config:config-item>
+ <config:config-item config:name="ViewAreaHeight"
config:type="long">12321</config:config-item>
+ <config:config-item config:name="ShowRedlineChanges"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="InBrowseMode"
config:type="boolean">false</config:config-item>
+ <config:config-item-map-indexed config:name="Views">
+ <config:config-item-map-entry>
+ <config:config-item config:name="ViewId"
config:type="string">view2</config:config-item>
+ <config:config-item config:name="ViewLeft"
config:type="long">6452</config:config-item>
+ <config:config-item config:name="ViewTop"
config:type="long">2501</config:config-item>
+ <config:config-item config:name="VisibleLeft"
config:type="long">0</config:config-item>
+ <config:config-item config:name="VisibleTop"
config:type="long">0</config:config-item>
+ <config:config-item config:name="VisibleRight"
config:type="long">30494</config:config-item>
+ <config:config-item config:name="VisibleBottom"
config:type="long">12319</config:config-item>
+ <config:config-item config:name="ZoomType"
config:type="short">0</config:config-item>
+ <config:config-item config:name="ViewLayoutColumns"
config:type="short">1</config:config-item>
+ <config:config-item config:name="ViewLayoutBookMode"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ZoomFactor"
config:type="short">160</config:config-item>
+ <config:config-item config:name="IsSelectedFrame"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="KeepRatio"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="WindowState"
config:type="string">0,28,1806,875;5;0,28,1921,903;</config:config-item>
+ <config:config-item config:name="AnchoredTextOverflowLegacy"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="LegacySingleLineFontwork"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ConnectorUseSnapRect"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="IgnoreBreakAfterMultilineField"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="UseTrailingEmptyLinesInLayout"
config:type="boolean">false</config:config-item>
+ </config:config-item-map-entry>
+ </config:config-item-map-indexed>
+ </config:config-item-set>
+ <config:config-item-set config:name="ooo:configuration-settings">
+ <config:config-item config:name="PrintProspectRTL"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrintPageBackground"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="PrintDrawings"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="PrintFaxName" config:type="string"/>
+ <config:config-item config:name="PrintReversed"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrintAnnotationMode"
config:type="short">0</config:config-item>
+ <config:config-item config:name="PrintHiddenText"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrintEmptyPages"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="AdjustTableLineHeightsToGridHeight"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="BalanceSpacesAndIdeographicSpaces"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="MsWordCompGridMetrics"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PaintHellOverHeaderFooter"
config:type="boolean">false</config:config-item>
+ <config:config-item
config:name="ApplyParagraphMarkFormatToEmptyLineAtEndOfParagraph"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrintGraphics"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="NoNumberingShowFollowBy"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="MinRowHeightInclBorder"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="HyphenateURLs"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ImagePreferredDPI"
config:type="int">0</config:config-item>
+ <config:config-item config:name="FootnoteInColumnToPageEnd"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="GutterAtTop"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ContinuousEndnotes"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="MsWordUlTrailSpace"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="FrameAutowidthWithMorePara"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="SubtractFlysAnchoredAtFlys"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="SurroundTextWrapSmall"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrintControls"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="TreatSingleColumnBreakAsPageBreak"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="TabOverSpacing"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="AutoFirstLineIndentDisregardLineSpace"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="TabOverMargin"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="EmbedComplexScriptFonts"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="EmbedAsianScriptFonts"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="PrintTextPlaceholder"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ApplyTextAttrToEmptyLineAtEndOfParagraph"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="EmbedSystemFonts"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="EmbedFonts"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="NoClippingWithWrapPolygon"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="DisableOffPagePositioning"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="BackgroundParaOverDrawings"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="TabOverflow"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="SmallCapsPercentage66"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="AllowPrintJobCancel"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="AddVerticalFrameOffsets"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ProtectBookmarks"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="AddFrameOffsets"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrintBlackFonts"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="TableRowKeep"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ApplyParagraphMarkFormatToNumbering"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrinterIndependentLayout"
config:type="string">high-resolution</config:config-item>
+ <config:config-item config:name="JustifyLinesWithShrinking"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="RsidRoot"
config:type="int">218355</config:config-item>
+ <config:config-item config:name="PrintProspect"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="CollapseEmptyCellPara"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="PrintPaperFromSetup"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="CurrentDatabaseCommand"
config:type="string"/>
+ <config:config-item config:name="CurrentDatabaseDataSource"
config:type="string"/>
+ <config:config-item config:name="SaveThumbnail"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="EmbeddedDatabaseName"
config:type="string"/>
+ <config:config-item config:name="UnbreakableNumberings"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="SaveGlobalDocumentLinks"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="MsWordCompTrailingBlanks"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrintTables"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="PrintLeftPages"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="AddParaTableSpacing"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="PrinterPaperFromSetup"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="CurrentDatabaseCommandType"
config:type="int">0</config:config-item>
+ <config:config-item config:name="ChartAutoUpdate"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="OutlineLevelYieldsNumbering"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ForceTopAlignmentInCellWithFloatingAnchor"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="UseOldNumbering"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="AddParaSpacingToTableCells"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="FieldAutoUpdate"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="PropLineSpacingShrinksFirstLine"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="TabAtLeftIndentForParagraphsInList"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrintRightPages"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="DoNotCaptureDrawObjsOnPage"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="LoadReadonly"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="HeaderSpacingBelowLastPara"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="SaveVersionOnClose"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="UseFormerLineSpacing"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="PrinterName" config:type="string"/>
+ <config:config-item config:name="AddParaLineSpacingToTableCells"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="IsKernAsianPunctuation"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="DoNotJustifyLinesWithManualBreak"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="CharacterCompressionType"
config:type="short">0</config:config-item>
+ <config:config-item config:name="IsLabelDocument"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="EmbedLatinScriptFonts"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="PrinterSetup" config:type="base64Binary"/>
+ <config:config-item config:name="UseVariableWidthNBSP"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="EmbedOnlyUsedFonts"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ApplyUserData"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="AddParaTableSpacingAtStart"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="InvertBorderSpacing"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ProtectFields"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="AddExternalLeading"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="LinkUpdateMode"
config:type="short">1</config:config-item>
+ <config:config-item config:name="UseFormerObjectPositioning"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="UnxForceZeroExtLeading"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="UseFormerTextWrapping"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ConsiderTextWrapOnObjPos"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="StylesNoDefault"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="IgnoreFirstLineIndentInNumbering"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="NoGapAfterNoteNumber"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="EmptyDbFieldHidesPara"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="DoNotResetParaAttrsForNumFont"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="IgnoreTabsAndBlanksForLineCalculation"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="ClippedPictures"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="MathBaselineAlignment"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="AlignTabStopPosition"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="IgnoreHiddenCharsForLineCalculation"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="ClipAsCharacterAnchoredWriterFlyFrames"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="DropCapPunctuation"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="UseOldPrinterMetrics"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="RedlineProtectionKey"
config:type="base64Binary"/>
+ <config:config-item config:name="TabsRelativeToIndent"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="Rsid"
config:type="int">234371</config:config-item>
+ <config:config-item config:name="UpdateFromTemplate"
config:type="boolean">true</config:config-item>
+ <config:config-item config:name="ProtectForm"
config:type="boolean">false</config:config-item>
+ <config:config-item config:name="MsWordCompMinLineHeightByFly"
config:type="boolean">false</config:config-item>
+ </config:config-item-set>
+ </office:settings>
+ <office:scripts>
+ <office:script script:language="ooo:Basic">
+ <ooo:libraries xmlns:ooo="http://openoffice.org/2004/office"
xmlns:xlink="http://www.w3.org/1999/xlink"/>
+ </office:script>
+ </office:scripts>
+ <office:font-face-decls>
+ <style:font-face style:name="Liberation Sans"
svg:font-family="'Liberation Sans'" style:font-family-generic="swiss"
style:font-pitch="variable"/>
+ <style:font-face style:name="Liberation Serif"
svg:font-family="'Liberation Serif'"
style:font-family-generic="roman" style:font-pitch="variable"/>
+ <style:font-face style:name="Noto Sans" svg:font-family="'Noto
Sans'" style:font-family-generic="system" style:font-pitch="variable"/>
+ </office:font-face-decls>
+ <office:styles>
+ <style:default-style style:family="graphic">
+ <style:graphic-properties svg:stroke-color="#3465a4"
draw:fill-color="#729fcf" fo:wrap-option="no-wrap"
draw:shadow-offset-x="0.1181in" draw:shadow-offset-y="0.1181in"
draw:start-line-spacing-horizontal="0.1114in"
draw:start-line-spacing-vertical="0.1114in"
draw:end-line-spacing-horizontal="0.1114in"
draw:end-line-spacing-vertical="0.1114in" style:writing-mode="lr-tb"
style:flow-with-text="false"/>
+ <style:paragraph-properties style:text-autospace="ideograph-alpha"
style:line-break="strict" loext:tab-stop-distance="0in"
style:font-independent-line-spacing="false">
+ <style:tab-stops/>
+ </style:paragraph-properties>
+ <style:text-properties style:use-window-font-color="true"
loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt"
fo:language="en" fo:country="US" style:letter-kerning="true"
style:font-name-asian="Noto Sans" style:font-size-asian="10.5pt"
style:language-asian="zh" style:country-asian="CN"
style:font-name-complex="Noto Sans" style:font-size-complex="12pt"
style:language-complex="hi" style:country-complex="IN"/>
+ </style:default-style>
+ <style:default-style style:family="paragraph">
+ <style:paragraph-properties fo:orphans="2" fo:widows="2"
fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto"
loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="false"
style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging"
style:line-break="strict" style:tab-stop-distance="0.4925in"
style:writing-mode="page"/>
+ <style:text-properties style:use-window-font-color="true"
loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt"
fo:language="en" fo:country="US" style:letter-kerning="true"
style:font-name-asian="Noto Sans" style:font-size-asian="10.5pt"
style:language-asian="zh" style:country-asian="CN"
style:font-name-complex="Noto Sans" style:font-size-complex="12pt"
style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false"
fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"
loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false"
loext:hyphenation-word-char-count="5" loext:hyphenation-zone="no-limit"/>
+ </style:default-style>
+ <style:default-style style:family="table">
+ <style:table-properties table:border-model="collapsing"/>
+ </style:default-style>
+ <style:default-style style:family="table-row">
+ <style:table-row-properties fo:keep-together="auto"/>
+ </style:default-style>
+ <style:style style:name="Standard" style:family="paragraph"
style:class="text"/>
+ <style:style style:name="Heading" style:family="paragraph"
style:parent-style-name="Standard" style:next-style-name="Text_20_body"
style:class="chapter">
+ <style:paragraph-properties fo:margin-top="0.1665in"
fo:margin-bottom="0.0835in" style:contextual-spacing="false"
fo:keep-with-next="always"/>
+ <style:text-properties style:font-name="Liberation Sans"
fo:font-family="'Liberation Sans'" style:font-family-generic="swiss"
style:font-pitch="variable" fo:font-size="14pt" style:font-name-asian="Noto
Sans" style:font-family-asian="'Noto Sans'"
style:font-family-generic-asian="system" style:font-pitch-asian="variable"
style:font-size-asian="14pt" style:font-name-complex="Noto Sans"
style:font-family-complex="'Noto Sans'"
style:font-family-generic-complex="system" style:font-pitch-complex="variable"
style:font-size-complex="14pt"/>
+ </style:style>
+ <style:style style:name="Text_20_body" style:display-name="Text body"
style:family="paragraph" style:parent-style-name="Standard" style:class="text">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0.0972in"
style:contextual-spacing="false" fo:line-height="115%"/>
+ </style:style>
+ <style:style style:name="List" style:family="paragraph"
style:parent-style-name="Text_20_body" style:class="list">
+ <style:text-properties style:font-size-asian="12pt"/>
+ </style:style>
+ <style:style style:name="Caption" style:family="paragraph"
style:parent-style-name="Standard" style:class="extra">
+ <style:paragraph-properties fo:margin-top="0.0835in"
fo:margin-bottom="0.0835in" style:contextual-spacing="false"
text:number-lines="false" text:line-number="0"/>
+ <style:text-properties fo:font-size="12pt" fo:font-style="italic"
style:font-size-asian="12pt" style:font-style-asian="italic"
style:font-size-complex="12pt" style:font-style-complex="italic"/>
+ </style:style>
+ <style:style style:name="Index" style:family="paragraph"
style:parent-style-name="Standard" style:class="index">
+ <style:paragraph-properties text:number-lines="false" text:line-number="0"/>
+ <style:text-properties style:font-size-asian="12pt"/>
+ </style:style>
+ <text:outline-style style:name="Outline">
+ <text:outline-level-style text:level="1" loext:num-list-format="%1%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="2" loext:num-list-format="%2%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="3" loext:num-list-format="%3%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="4" loext:num-list-format="%4%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="5" loext:num-list-format="%5%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="6" loext:num-list-format="%6%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="7" loext:num-list-format="%7%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="8" loext:num-list-format="%8%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="9" loext:num-list-format="%9%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ <text:outline-level-style text:level="10" loext:num-list-format="%10%"
style:num-format="">
+ <style:list-level-properties
text:list-level-position-and-space-mode="label-alignment">
+ <style:list-level-label-alignment text:label-followed-by="listtab"/>
+ </style:list-level-properties>
+ </text:outline-level-style>
+ </text:outline-style>
+ <text:notes-configuration text:note-class="footnote" style:num-format="1"
text:start-value="0" text:footnotes-position="page"
text:start-numbering-at="document"/>
+ <text:notes-configuration text:note-class="endnote" style:num-format="i"
text:start-value="0"/>
+ <text:linenumbering-configuration text:number-lines="false"
text:offset="0.1965in" style:num-format="1" text:number-position="left"
text:increment="5"/>
+ <loext:theme loext:name="Office">
+ <loext:theme-colors loext:name="LibreOffice">
+ <loext:color loext:name="dark1" loext:color="#000000"/>
+ <loext:color loext:name="light1" loext:color="#ffffff"/>
+ <loext:color loext:name="dark2" loext:color="#000000"/>
+ <loext:color loext:name="light2" loext:color="#ffffff"/>
+ <loext:color loext:name="accent1" loext:color="#18a303"/>
+ <loext:color loext:name="accent2" loext:color="#0369a3"/>
+ <loext:color loext:name="accent3" loext:color="#a33e03"/>
+ <loext:color loext:name="accent4" loext:color="#8e03a3"/>
+ <loext:color loext:name="accent5" loext:color="#c99c00"/>
+ <loext:color loext:name="accent6" loext:color="#c9211e"/>
+ <loext:color loext:name="hyperlink" loext:color="#0000ee"/>
+ <loext:color loext:name="followed-hyperlink" loext:color="#551a8b"/>
+ </loext:theme-colors>
+ </loext:theme>
+ </office:styles>
+ <office:automatic-styles>
+ <style:style style:name="gr1" style:family="graphic">
+ <style:graphic-properties draw:textarea-horizontal-align="justify"
draw:textarea-vertical-align="middle" draw:auto-grow-height="false"
fo:min-height="0.4in" fo:min-width="0.4in" loext:decorative="false"
style:run-through="foreground" style:wrap="run-through"
style:number-wrapped-paragraphs="no-limit" style:vertical-pos="from-top"
style:vertical-rel="paragraph" style:horizontal-pos="from-left"
style:horizontal-rel="paragraph"
draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true"
style:flow-with-text="false"/>
+ </style:style>
+ <style:page-layout style:name="pm1">
+ <style:page-layout-properties fo:page-width="8.5in" fo:page-height="11in"
style:num-format="1" style:print-orientation="portrait"
fo:margin-top="0.7874in" fo:margin-bottom="0.7874in" fo:margin-left="0.7874in"
fo:margin-right="0.7874in" style:writing-mode="lr-tb"
style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20"
style:layout-grid-base-height="0.278in" style:layout-grid-ruby-height="0.139in"
style:layout-grid-mode="none" style:layout-grid-ruby-below="false"
style:layout-grid-print="false" style:layout-grid-display="false"
style:footnote-max-height="0in" loext:margin-gutter="0in">
+ <style:footnote-sep style:width="0.0071in"
style:distance-before-sep="0.0398in" style:distance-after-sep="0.0398in"
style:line-style="solid" style:adjustment="left" style:rel-width="25%"
style:color="#000000"/>
+ </style:page-layout-properties>
+ <style:header-style/>
+ <style:footer-style/>
+ </style:page-layout>
+ <style:style style:name="dp1" style:family="drawing-page">
+ <style:drawing-page-properties draw:background-size="full"/>
+ </style:style>
+ </office:automatic-styles>
+ <office:master-styles>
+ <style:master-page style:name="Standard" style:page-layout-name="pm1"
draw:style-name="dp1"/>
+ </office:master-styles>
+ <office:body>
+ <office:text>
+ <text:sequence-decls>
+ <text:sequence-decl text:display-outline-level="0"
text:name="Illustration"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
+ <text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
+ </text:sequence-decls>
+ <text:p text:style-name="Standard"><draw:custom-shape
text:anchor-type="paragraph" draw:z-index="0" draw:name="Shape 1"
draw:style-name="gr1" svg:width="0.4004in" svg:height="0.4004in" svg:x="1.6in"
svg:y="0.4in">
+ <text:p/>
+ <draw:enhanced-geometry svg:viewBox="0 0 21600 21600"
draw:type="rectangle" draw:enhanced-path="M 0 0 L 21600 0 21600 21600 0 21600 0
0 Z N"/>
+ </draw:custom-shape></text:p>
+ </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter11.cxx
b/sw/qa/extras/uiwriter/uiwriter11.cxx
index 5e4d2b10e5b9..f250a2f82601 100644
--- a/sw/qa/extras/uiwriter/uiwriter11.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter11.cxx
@@ -18,14 +18,20 @@
#include <AnnotationWin.hxx>
#include <cmdid.h>
#include <docufld.hxx>
+#include <drawdoc.hxx>
#include <edtwin.hxx>
#include <PostItMgr.hxx>
#include <view.hxx>
#include <wrtsh.hxx>
#include <unotxdoc.hxx>
#include <ndtxt.hxx>
-#include <IDocumentLayoutAccess.hxx>
#include <svx/svxids.hrc>
+#include <svx/svdpage.hxx>
+#include <swdtflvr.hxx>
+#include <IDocumentLayoutAccess.hxx>
+#include <IDocumentDrawModelAccess.hxx>
+#include <officecfg/Office/Writer.hxx>
+#include <vcl/event.hxx>
namespace
{
@@ -374,6 +380,65 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testTdf108791)
}
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest11, testSnapToGridShape)
+{
+ // Apply grid settings
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(
+ comphelper::ConfigurationChanges::create());
+ officecfg::Office::Writer::Grid::Option::VisibleGrid::set(true, batch);
+ officecfg::Office::Writer::Grid::Option::SnapToGrid::set(true, batch);
+ officecfg::Office::Writer::Grid::Resolution::XAxis::set(1016, batch);
+ officecfg::Office::Writer::Grid::Resolution::YAxis::set(1016, batch);
+ officecfg::Office::Writer::Grid::Subdivision::XAxis::set(1, batch);
+ officecfg::Office::Writer::Grid::Subdivision::YAxis::set(1, batch);
+ batch->commit();
+
+ // Given a document with a single shape
+ createSwDoc("snapToGridShape.fodt");
+
+ // Check original position / size of the shape
+ uno::Reference<css::drawing::XShape> xShape = getShape(1);
+ CPPUNIT_ASSERT(xShape.is());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4064), xShape->getPosition().X);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getPosition().Y);
+
+ // Select the shape
+ SwDoc* pDoc = getSwDoc();
+ CPPUNIT_ASSERT(pDoc);
+ SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+ SdrPage* pPage =
pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+ CPPUNIT_ASSERT(pPage);
+ SdrObject* pObject = pPage->GetObj(0);
+ CPPUNIT_ASSERT(pObject);
+ const bool bSelected = pWrtShell->SelectObj(Point(), 0, pObject);
+ CPPUNIT_ASSERT(bSelected);
+ const tools::Rectangle& rBoundRect = pObject->GetLastBoundRect();
+
+ // Move shape
+ Point ptFrom(rBoundRect.Center().X(), rBoundRect.Center().Y());
+ Point ptTo(rBoundRect.Center().X() + 600, rBoundRect.Center().Y());
+ vcl::Window& rEditWin = getSwDocShell()->GetView()->GetEditWin();
+ Point aFrom = rEditWin.LogicToPixel(ptFrom);
+ Point aTo = rEditWin.LogicToPixel(ptTo);
+ MouseEvent aClickEvent(aFrom, 1, MouseEventModifiers::SIMPLECLICK,
MOUSE_LEFT);
+ rEditWin.MouseButtonDown(aClickEvent);
+ MouseEvent aClickEvent2(aTo, 0, MouseEventModifiers::SIMPLEMOVE,
MOUSE_LEFT);
+ rEditWin.MouseMove(aClickEvent2);
+ rEditWin.MouseMove(aClickEvent2);
+ MouseEvent aClickEvent3(aTo, 1, MouseEventModifiers::SIMPLECLICK,
MOUSE_LEFT);
+ rEditWin.MouseButtonUp(aClickEvent3);
+ Scheduler::ProcessEventsToIdle();
+
+ // Check new position / size of the shape
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Width);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getSize().Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(5080), xShape->getPosition().X);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1016), xShape->getPosition().Y);
+}
+
} // end of anonymous namespace
CPPUNIT_PLUGIN_IMPLEMENT();