[Libreoffice-commits] core.git: sw/qa

2020-02-28 Thread Grzegorz Araminowicz (via logerrit)
 sw/qa/extras/tiledrendering/data/hyperlink.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   38 +
 2 files changed, 38 insertions(+)

New commits:
commit f752602f08bb975058a50feb47b0856735ad23a2
Author: Grzegorz Araminowicz 
AuthorDate: Tue Nov 5 16:40:05 2019 +0100
Commit: Muhammet Kara 
CommitDate: Fri Feb 28 19:09:29 2020 +0100

add hyperlink info unit test

Change-Id: I72c07837ac7ef0bb1ebe10c8dde2adcc9970464a
Reviewed-on: https://gerrit.libreoffice.org/82077
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89703
Tested-by: Jenkins
Reviewed-by: Muhammet Kara 

diff --git a/sw/qa/extras/tiledrendering/data/hyperlink.odt 
b/sw/qa/extras/tiledrendering/data/hyperlink.odt
new file mode 100644
index ..4a97bf76b665
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/hyperlink.odt 
differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 16196e1327ba..214b6352f9f6 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -123,6 +123,7 @@ public:
 void testAnchorTypes();
 void testLanguageStatus();
 void testRedlineNotificationDuringSave();
+void testHyperlink();
 
 CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
 CPPUNIT_TEST(testRegisterCallback);
@@ -185,6 +186,7 @@ public:
 CPPUNIT_TEST(testAnchorTypes);
 CPPUNIT_TEST(testLanguageStatus);
 CPPUNIT_TEST(testRedlineNotificationDuringSave);
+CPPUNIT_TEST(testHyperlink);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -203,6 +205,8 @@ private:
 int m_nRedlineTableSizeChanged;
 int m_nRedlineTableEntryModified;
 int m_nTrackedChangeIndex;
+OString m_sHyperlinkText;
+OString m_sHyperlinkLink;
 };
 
 SwTiledRenderingTest::SwTiledRenderingTest()
@@ -334,6 +338,19 @@ void SwTiledRenderingTest::callbackImpl(int nType, const 
char* pPayload)
 }
 }
 break;
+case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
+{
+if (comphelper::LibreOfficeKit::isViewIdForVisCursorInvalidation())
+{
+boost::property_tree::ptree aTree;
+std::stringstream aStream(pPayload);
+boost::property_tree::read_json(aStream, aTree);
+boost::property_tree::ptree  = aTree.get_child("hyperlink");
+m_sHyperlinkText = aChild.get("text", "").c_str();
+m_sHyperlinkLink = aChild.get("link", "").c_str();
+}
+}
+break;
 }
 }
 
@@ -2478,6 +2495,27 @@ void 
SwTiledRenderingTest::testRedlineNotificationDuringSave()
 xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
 }
 
+void SwTiledRenderingTest::testHyperlink()
+{
+comphelper::LibreOfficeKit::setActive();
+comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
+SwXTextDocument* pXTextDocument = createDoc("hyperlink.odt");
+SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+
pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(::callback,
 this);
+SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
+
+Point aStart = pShellCursor->GetSttPos();
+aStart.setX(aStart.getX() + 1800);
+pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, 
aStart.getX(), aStart.getY(), 1,
+   MOUSE_LEFT, 0);
+pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, 
aStart.getX(), aStart.getY(), 1,
+   MOUSE_LEFT, 0);
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(OString("hyperlink"), m_sHyperlinkText);
+CPPUNIT_ASSERT_EQUAL(OString("http://example.com/;), m_sHyperlinkLink);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: editeng/source

2020-02-28 Thread Grzegorz Araminowicz (via logerrit)
 editeng/source/editeng/impedit.cxx |   17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 79f1490f93c3ebe933baba52c6a3eacf1e37fb61
Author: Grzegorz Araminowicz 
AuthorDate: Tue Oct 29 21:56:16 2019 +0100
Commit: Muhammet Kara 
CommitDate: Fri Feb 28 19:08:41 2020 +0100

lok: send hyperlink info also in editeng

Change-Id: I64691497778a59b519cafd656772d5e79cb132f3
Reviewed-on: https://gerrit.libreoffice.org/81719
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89679
Tested-by: Jenkins
Reviewed-by: Muhammet Kara 

diff --git a/editeng/source/editeng/impedit.cxx 
b/editeng/source/editeng/impedit.cxx
index 6107f950608a..842119a5b4ae 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -1105,7 +1106,21 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool 
bForceVisCursor )
 Reference< linguistic2::XSpellChecker1 >  xSpeller( 
pEditEngine->pImpEditEngine->GetSpeller() );
 bool bIsWrong = xSpeller.is() && IsWrongSpelledWord(aPaM, 
/*bMarkIfWrong*/ false);
 
-SfxLokHelper::notifyVisCursorInvalidation(mpViewShell, sRect, 
bIsWrong);
+OString sHyperlink;
+if (const SvxFieldItem* pFld = GetField(aPos, nullptr, 
nullptr))
+{
+if (auto pUrlField = dynamic_cast(pFld->GetField()))
+{
+boost::property_tree::ptree aTree;
+aTree.put("text", pUrlField->GetRepresentation());
+aTree.put("link", pUrlField->GetURL());
+std::stringstream aStream;
+boost::property_tree::write_json(aStream, aTree, 
false);
+sHyperlink = OString(aStream.str().c_str()).trim();
+}
+}
+
+SfxLokHelper::notifyVisCursorInvalidation(mpViewShell, sRect, 
bIsWrong, sHyperlink);
 
mpViewShell->NotifyOtherViews(LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", 
sRect);
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/sfx2 sfx2/source sw/source

2020-02-28 Thread Grzegorz Araminowicz (via logerrit)
 include/sfx2/lokhelper.hxx |2 +-
 sfx2/source/view/lokhelper.cxx |7 +--
 sw/source/core/crsr/viscrs.cxx |   18 --
 3 files changed, 22 insertions(+), 5 deletions(-)

New commits:
commit ee78313613605f50795d8ba0fbcd4138c9845a51
Author: Grzegorz Araminowicz 
AuthorDate: Mon Oct 21 12:59:12 2019 +0200
Commit: Muhammet Kara 
CommitDate: Fri Feb 28 13:25:21 2020 +0100

lok: send hyperlink text and address under cursor

Change-Id: I827c51ae859b3d3649ec9d293b5ae8eaf4cbd630
Reviewed-on: https://gerrit.libreoffice.org/81219
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89691
Tested-by: Jenkins
Reviewed-by: Muhammet Kara 

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index f87432c792b8..e1827ef1967f 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -83,7 +83,7 @@ public:
 /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to 
setOptionalFeatures() if needed.
 static void notifyInvalidation(SfxViewShell const* pThisView, const 
OString& rPayload);
 /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, but tweaks it 
according to setOptionalFeatures() if needed.
-static void notifyVisCursorInvalidation(OutlinerViewShell const* 
pThisView, const OString& rRectangle, bool bMispelledWord = false);
+static void notifyVisCursorInvalidation(OutlinerViewShell const* 
pThisView, const OString& rRectangle, bool bMispelledWord = false, const 
OString& rHyperlink = "");
 /// Notifies all views with the given type and payload.
 static void notifyAllViews(int nType, const OString& rPayload);
 
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index f924ca8edaf4..56f7d7f4bc32 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -367,7 +367,7 @@ void 
SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc
 }
 }
 
-void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* 
pThisView, const OString& rRectangle, bool bMispelledWord)
+void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* 
pThisView, const OString& rRectangle, bool bMispelledWord, const OString& 
rHyperlink)
 {
 if (DisableCallbacks::disabled())
 return;
@@ -375,8 +375,11 @@ void 
SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisVie
 OString sPayload;
 if (comphelper::LibreOfficeKit::isViewIdForVisCursorInvalidation())
 {
+OString sHyperlink = rHyperlink.isEmpty() ? "{}" : rHyperlink;
 sPayload = OStringLiteral("{ \"viewId\": \"") + 
OString::number(SfxLokHelper::getView()) +
-"\", \"rectangle\": \"" + rRectangle + "\", \"mispelledWord\": \"" 
+  OString::number(bMispelledWord ? 1 : 0) + "\" }";
+"\", \"rectangle\": \"" + rRectangle +
+"\", \"mispelledWord\": \"" +  OString::number(bMispelledWord ? 1 
: 0) +
+"\", \"hyperlink\": " + sHyperlink + " }";
 }
 else
 {
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 4c61a86bfbd5..400b79c869e1 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -49,6 +49,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -238,18 +239,31 @@ void SwVisibleCursor::SetPosAndShow(SfxViewShell const * 
pViewShell)
 }
 }
 
+OString sHyperlink;
+SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr);
+if 
(const_cast(m_pCursorShell)->GetContentAtPos(aRect.Pos(), 
aContentAtPos))
+{
+const SwFormatINetFormat* pItem = static_cast(aContentAtPos.aFnd.pAttr);
+boost::property_tree::ptree aTree;
+aTree.put("text", aContentAtPos.sStr);
+aTree.put("link", pItem->GetValue());
+std::stringstream aStream;
+boost::property_tree::write_json(aStream, aTree, false);
+sHyperlink = OString(aStream.str().c_str()).trim();
+}
+
 if (pViewShell)
 {
 if (pViewShell == m_pCursorShell->GetSfxViewShell())
 {
-SfxLokHelper::notifyVisCursorInvalidation(pViewShell, sRect, 
bIsWrong);
+SfxLokHelper::notifyVisCursorInvalidation(pViewShell, sRect, 
bIsWrong, sHyperlink);
 }
 else
 
SfxLokHelper::notifyOtherView(m_pCursorShell->GetSfxViewShell(), pViewShell, 
LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect);
 }
 else
 {
-
SfxLokHelper::notifyVisCursorInvalidation(m_pCursorShell->GetSfxViewShell(), 
sRect, bIsWrong);
+
SfxLokHelper::notifyVisCursorInvalidation(m_pCursorShell->GetSfxViewShell(), 
sRect, bIsWrong, sHyperlink);
 SfxLokHelper::notifyOtherViews(m_pCursorShell->GetSfxViewShell(), 

[Libreoffice-commits] online.git: loleaflet/src

2019-11-25 Thread Grzegorz Araminowicz (via logerrit)
 loleaflet/src/layer/tile/TileLayer.js |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit af6fe6a2f09e1b36093206e6048188d6cb9e6a6a
Author: Grzegorz Araminowicz 
AuthorDate: Mon Nov 25 18:40:05 2019 +0100
Commit: Grzegorz Araminowicz 
CommitDate: Mon Nov 25 18:42:17 2019 +0100

remove duplicated condition

Change-Id: If96be0eb426371f9a146def406cd002e241a56e8
Reviewed-on: https://gerrit.libreoffice.org/83705
Reviewed-by: Grzegorz Araminowicz 
Tested-by: Grzegorz Araminowicz 

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 9ae10c84d..85c82b826 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2012,12 +2012,12 @@ L.TileLayer = L.GridLayer.extend({
var cursorPos = this._visibleCursor.getNorthWest();
var docLayer = this._map._docLayer;
 
-   if ((!zoom && scroll !== false) && 
!this._map.getBounds().contains(this._visibleCursor) && this._isCursorVisible) {
+   if (!zoom && scroll !== false && 
!this._map.getBounds().contains(this._visibleCursor) && this._isCursorVisible) {
var center = this._map.project(cursorPos);
center = 
center.subtract(this._map.getSize().divideBy(2));
center.x = Math.round(center.x < 0 ? 0 : center.x);
center.y = Math.round(center.y < 0 ? 0 : center.y);
-   if (!zoom && !(this._selectionHandles.start && 
this._selectionHandles.start.isDragged) &&
+   if (!(this._selectionHandles.start && 
this._selectionHandles.start.isDragged) &&
!(this._selectionHandles.end && 
this._selectionHandles.end.isDragged) &&
!(docLayer._followEditor || docLayer._followUser)) {
this._map.fire('scrollto', {x: center.x, y: 
center.y, calledFromInvalidateCursorMsg: scroll !== undefined});
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: loleaflet/src

2019-11-25 Thread Grzegorz Araminowicz (via logerrit)
 loleaflet/src/layer/marker/Cursor.js |   17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 37eacf06ce320ba6373f9326dc1eda66889e7697
Author: Grzegorz Araminowicz 
AuthorDate: Sun Nov 24 14:21:43 2019 +0100
Commit: Grzegorz Araminowicz 
CommitDate: Mon Nov 25 16:12:32 2019 +0100

Enable zoom animation for cursor

It prevents cursor from appearing in old position on large zoom level
difference (pinch to zoom).
It also provides nicer visual effect on desktop.

Change-Id: I9e2504dc54c47196441a1ea16e3422cce137d5a2
Reviewed-on: https://gerrit.libreoffice.org/83610
Reviewed-by: Grzegorz Araminowicz 
Tested-by: Grzegorz Araminowicz 

diff --git a/loleaflet/src/layer/marker/Cursor.js 
b/loleaflet/src/layer/marker/Cursor.js
index 592658dca..b7a0ba1a9 100644
--- a/loleaflet/src/layer/marker/Cursor.js
+++ b/loleaflet/src/layer/marker/Cursor.js
@@ -7,7 +7,8 @@ L.Cursor = L.Layer.extend({
 
options: {
opacity: 1,
-   zIndex: 1000
+   zIndex: 1000,
+   zoomAnimation: true
},
 
initialize: function (latlng, size, options) {
@@ -22,6 +23,11 @@ L.Cursor = L.Layer.extend({
this._initLayout();
}
 
+   this._zoomAnimated = this._zoomAnimated && 
this.options.zoomAnimation;
+   if (this._zoomAnimated) {
+   L.DomUtil.addClass(this._container, 
'leaflet-zoom-animated');
+   }
+
this.update();
this.getPane().appendChild(this._container);
},
@@ -35,6 +41,10 @@ L.Cursor = L.Layer.extend({
getEvents: function () {
var events = {viewreset: this.update};
 
+   if (this._zoomAnimated) {
+   events.zoomanim = this._animateZoom;
+   }
+
return events;
},
 
@@ -117,6 +127,11 @@ L.Cursor = L.Layer.extend({
_setSize: function () {
this._cursor.style.height = this._size.y + 'px';
this._container.style.top = '-' + (this._container.clientHeight 
- this._size.y - 2) / 2 + 'px';
+   },
+
+   _animateZoom: function (opt) {
+   var pos = this._map._latLngToNewLayerPoint(this._latlng, 
opt.zoom, opt.center).round();
+   L.DomUtil.setPosition(this._container, pos);
}
 });
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: loleaflet/src

2019-11-11 Thread Grzegorz Araminowicz (via logerrit)
 loleaflet/src/control/Toolbar.js |   18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

New commits:
commit d10257cf0979eb076d3d942d35dbe55fdecb70d6
Author: Grzegorz Araminowicz 
AuthorDate: Fri Nov 8 22:17:16 2019 +0100
Commit: Grzegorz Araminowicz 
CommitDate: Mon Nov 11 18:39:51 2019 +0100

Pre-populate hyperlink dialog text field with selected text

using existing textselectioncontent message

Change-Id: I64ad932e8462d2318532bb5b9899b5e546831e32
Reviewed-on: https://gerrit.libreoffice.org/82334
Reviewed-by: Grzegorz Araminowicz 
Tested-by: Grzegorz Araminowicz 

diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 8c9ee5750..45770d65e 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -404,14 +404,28 @@ L.Map.include({
});
},
 
+   extractContent: function(html) {
+   var parser = new DOMParser;
+   return parser.parseFromString(html, 
'text/html').documentElement.getElementsByTagName('body')[0].textContent;
+   },
+
showHyperlinkDialog: function() {
var map = this;
+   var text = '';
+   var link = '';
+   if (this.hyperlinkUnderCursor && this.hyperlinkUnderCursor.text 
&& this.hyperlinkUnderCursor.link) {
+   text = this.hyperlinkUnderCursor.text;
+   link = this.hyperlinkUnderCursor.link;
+   } else if (this._clip._selectionType == 'text') {
+   text = 
this.extractContent(this._clip._selectionContent);
+   }
+
vex.dialog.open({
contentClassName: 'hyperlink-dialog',
message: _('Insert hyperlink'),
input: [
-   _('Text') + '',
-   _('Link') + ''
+   _('Text') + '',
+   _('Link') + ''
].join(''),
buttons: [
$.extend({}, vex.dialog.buttons.YES, { text: 
_('OK') }),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sw/qa

2019-11-05 Thread Grzegorz Araminowicz (via logerrit)
 sw/qa/extras/tiledrendering/data/hyperlink.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   38 +
 2 files changed, 38 insertions(+)

New commits:
commit 92c13df41e0b0b40c9a9b92b6b0bdb4730cd7f5d
Author: Grzegorz Araminowicz 
AuthorDate: Tue Nov 5 16:40:05 2019 +0100
Commit: Grzegorz Araminowicz 
CommitDate: Tue Nov 5 17:46:11 2019 +0100

add hyperlink info unit test

Change-Id: I72c07837ac7ef0bb1ebe10c8dde2adcc9970464a
Reviewed-on: https://gerrit.libreoffice.org/82077
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Grzegorz Araminowicz 

diff --git a/sw/qa/extras/tiledrendering/data/hyperlink.odt 
b/sw/qa/extras/tiledrendering/data/hyperlink.odt
new file mode 100644
index ..4a97bf76b665
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/hyperlink.odt 
differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 3a3fbf4e162e..bbc91370dc2d 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -118,6 +118,7 @@ public:
 void testSemiTransparent();
 void testAnchorTypes();
 void testLanguageStatus();
+void testHyperlink();
 
 CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
 CPPUNIT_TEST(testRegisterCallback);
@@ -178,6 +179,7 @@ public:
 CPPUNIT_TEST(testSemiTransparent);
 CPPUNIT_TEST(testAnchorTypes);
 CPPUNIT_TEST(testLanguageStatus);
+CPPUNIT_TEST(testHyperlink);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -196,6 +198,8 @@ private:
 int m_nRedlineTableSizeChanged;
 int m_nRedlineTableEntryModified;
 int m_nTrackedChangeIndex;
+OString m_sHyperlinkText;
+OString m_sHyperlinkLink;
 };
 
 SwTiledRenderingTest::SwTiledRenderingTest()
@@ -328,6 +332,19 @@ void SwTiledRenderingTest::callbackImpl(int nType, const 
char* pPayload)
 }
 }
 break;
+case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
+{
+if (comphelper::LibreOfficeKit::isViewIdForVisCursorInvalidation())
+{
+boost::property_tree::ptree aTree;
+std::stringstream aStream(pPayload);
+boost::property_tree::read_json(aStream, aTree);
+boost::property_tree::ptree  = aTree.get_child("hyperlink");
+m_sHyperlinkText = aChild.get("text", "").c_str();
+m_sHyperlinkLink = aChild.get("link", "").c_str();
+}
+}
+break;
 }
 }
 
@@ -2542,6 +2559,27 @@ void SwTiledRenderingTest::testLanguageStatus()
 CPPUNIT_ASSERT_EQUAL(OUString("English (USA);en-US"), aList[0]);
 }
 
+void SwTiledRenderingTest::testHyperlink()
+{
+comphelper::LibreOfficeKit::setActive();
+comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(true);
+SwXTextDocument* pXTextDocument = createDoc("hyperlink.odt");
+SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+
pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(::callback,
 this);
+SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
+
+Point aStart = pShellCursor->GetSttPos();
+aStart.setX(aStart.getX() + 1800);
+pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, 
aStart.getX(), aStart.getY(), 1,
+   MOUSE_LEFT, 0);
+pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, 
aStart.getX(), aStart.getY(), 1,
+   MOUSE_LEFT, 0);
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(OString("hyperlink"), m_sHyperlinkText);
+CPPUNIT_ASSERT_EQUAL(OString("http://example.com/;), m_sHyperlinkLink);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: loleaflet/src

2019-11-05 Thread Grzegorz Araminowicz (via logerrit)
 loleaflet/src/layer/tile/TileLayer.js |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 76dadbeea045e91aa3ba896b28fab12689083586
Author: Grzegorz Araminowicz 
AuthorDate: Mon Oct 28 13:49:28 2019 +0100
Commit: Grzegorz Araminowicz 
CommitDate: Tue Nov 5 17:44:06 2019 +0100

display popup with address when cursor is over hyperlink

Change-Id: Icc480c8e9936af4abe500d78704a9b49c9426230
Reviewed-on: https://gerrit.libreoffice.org/81603
Reviewed-by: Grzegorz Araminowicz 
Tested-by: Grzegorz Araminowicz 

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 439f058e2..912a7e3d8 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1048,7 +1048,16 @@ L.TileLayer = L.GridLayer.extend({
this._map._setFollowing(false, null);
}
this._map.lastActionByUser = false;
+
this._map.hyperlinkUnderCursor = obj.hyperlink;
+   this._map.closePopup(this._map.hyperlinkPopup);
+   this._map.hyperlinkPopup = null;
+   if (obj.hyperlink.link) {
+   this._map.hyperlinkPopup = new L.Popup({className: 
'hyperlink-popup', closeButton: false, closeOnClick: false})
+   .setContent('' + obj.hyperlink.link + '')
+   .setLatLng(cursorPos)
+   .openOn(this._map);
+   }
 
if (!this._map._isFocused && (modifierViewId === this._viewId) 
&& (this._map.getWinId === 0) && (this._map._permission === 'edit')) {
// Regain cursor if we had been out of focus and now 
have input.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: loleaflet/src

2019-10-31 Thread Grzegorz Araminowicz (via logerrit)
 loleaflet/src/control/Toolbar.js  |4 ++--
 loleaflet/src/layer/tile/TileLayer.js |1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 058398ee1b05ba64b323749cabd9ffe4883b749f
Author: Grzegorz Araminowicz 
AuthorDate: Mon Oct 21 13:15:31 2019 +0200
Commit: Jan Holesovsky 
CommitDate: Thu Oct 31 12:43:31 2019 +0100

hyperlink dialog: load existing text and link under cursor

Change-Id: Icf5a9e9bce01e311e745845b738e333ee3c5954c
Reviewed-on: https://gerrit.libreoffice.org/81231
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 2628a5190..822a20154 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -354,8 +354,8 @@ L.Map.include({
contentClassName: 'hyperlink-dialog',
message: _('Insert hyperlink'),
input: [
-   _('Text') + '',
-   _('Link') + ''
+   _('Text') + '',
+   _('Link') + ''
].join(''),
buttons: [
$.extend({}, vex.dialog.buttons.YES, { text: 
_('OK') }),
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 2644a9215..439f058e2 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1048,6 +1048,7 @@ L.TileLayer = L.GridLayer.extend({
this._map._setFollowing(false, null);
}
this._map.lastActionByUser = false;
+   this._map.hyperlinkUnderCursor = obj.hyperlink;
 
if (!this._map._isFocused && (modifierViewId === this._viewId) 
&& (this._map.getWinId === 0) && (this._map._permission === 'edit')) {
// Regain cursor if we had been out of focus and now 
have input.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - editeng/source

2019-10-31 Thread Grzegorz Araminowicz (via logerrit)
 editeng/source/editeng/impedit.cxx |   17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 5ebf83e24554b3a5a6c2398209d10f72d720c6d4
Author: Grzegorz Araminowicz 
AuthorDate: Tue Oct 29 21:56:16 2019 +0100
Commit: Jan Holesovsky 
CommitDate: Thu Oct 31 12:40:03 2019 +0100

lok: send hyperlink info also in editeng

Change-Id: I64691497778a59b519cafd656772d5e79cb132f3
Reviewed-on: https://gerrit.libreoffice.org/81719
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/editeng/source/editeng/impedit.cxx 
b/editeng/source/editeng/impedit.cxx
index 8fd2c913c93e..6e4b2082c831 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -1122,7 +1123,21 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool 
bForceVisCursor )
 Reference< linguistic2::XSpellChecker1 >  xSpeller( 
pEditEngine->pImpEditEngine->GetSpeller() );
 bool bIsWrong = xSpeller.is() && IsWrongSpelledWord(aPaM, 
/*bMarkIfWrong*/ false);
 
-SfxLokHelper::notifyVisCursorInvalidation(mpViewShell, sRect, 
bIsWrong);
+OString sHyperlink;
+if (const SvxFieldItem* pFld = GetField(aPos, nullptr, 
nullptr))
+{
+if (auto pUrlField = dynamic_cast(pFld->GetField()))
+{
+boost::property_tree::ptree aTree;
+aTree.put("text", pUrlField->GetRepresentation());
+aTree.put("link", pUrlField->GetURL());
+std::stringstream aStream;
+boost::property_tree::write_json(aStream, aTree, 
false);
+sHyperlink = OString(aStream.str().c_str()).trim();
+}
+}
+
+SfxLokHelper::notifyVisCursorInvalidation(mpViewShell, sRect, 
bIsWrong, sHyperlink);
 
mpViewShell->NotifyOtherViews(LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", 
sRect);
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/sfx2 sfx2/source sw/source

2019-10-31 Thread Grzegorz Araminowicz (via logerrit)
 include/sfx2/lokhelper.hxx |2 +-
 sfx2/source/view/lokhelper.cxx |7 +--
 sw/source/core/crsr/viscrs.cxx |   17 +++--
 3 files changed, 21 insertions(+), 5 deletions(-)

New commits:
commit da7d8464b19b7bcda08bdee2db5d2a2b7e8bde07
Author: Grzegorz Araminowicz 
AuthorDate: Mon Oct 21 12:59:12 2019 +0200
Commit: Jan Holesovsky 
CommitDate: Thu Oct 31 12:38:55 2019 +0100

lok: send hyperlink text and address under cursor

Change-Id: I827c51ae859b3d3649ec9d293b5ae8eaf4cbd630
Reviewed-on: https://gerrit.libreoffice.org/81219
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index ae796e0c7120..57ff680cfdb0 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -55,7 +55,7 @@ public:
 /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to 
setOptionalFeatures() if needed.
 static void notifyInvalidation(SfxViewShell const* pThisView, const 
OString& rPayload);
 /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, but tweaks it 
according to setOptionalFeatures() if needed.
-static void notifyVisCursorInvalidation(OutlinerViewShell const* 
pThisView, const OString& rRectangle, bool bMispelledWord = false);
+static void notifyVisCursorInvalidation(OutlinerViewShell const* 
pThisView, const OString& rRectangle, bool bMispelledWord = false, const 
OString& rHyperlink = "");
 /// Notifies all views with the given type and payload.
 static void notifyAllViews(int nType, const OString& rPayload);
 
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index e1c1b42a0e53..035c4c7fff06 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -254,13 +254,16 @@ void 
SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc
 }
 }
 
-void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* 
pThisView, const OString& rRectangle, bool bMispelledWord)
+void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* 
pThisView, const OString& rRectangle, bool bMispelledWord, const OString& 
rHyperlink)
 {
 OString sPayload;
 if (comphelper::LibreOfficeKit::isViewIdForVisCursorInvalidation())
 {
+OString sHyperlink = rHyperlink.isEmpty() ? "{}" : rHyperlink;
 sPayload = OString("{ \"viewId\": \"") + 
OString::number(SfxLokHelper::getView()) +
-"\", \"rectangle\": \"" + rRectangle + "\", \"mispelledWord\": \"" 
+  OString::number(bMispelledWord) + "\" }";
+"\", \"rectangle\": \"" + rRectangle +
+"\", \"mispelledWord\": \"" + OString::number(bMispelledWord) +
+"\", \"hyperlink\": " + sHyperlink + " }";
 }
 else
 {
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 2b14ffa27093..a1c1555858aa 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -241,18 +241,31 @@ void SwVisibleCursor::SetPosAndShow(SfxViewShell const * 
pViewShell)
 }
 }
 
+OString sHyperlink;
+SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr);
+if 
(const_cast(m_pCursorShell)->GetContentAtPos(aRect.Pos(), 
aContentAtPos))
+{
+const SwFormatINetFormat* pItem = static_cast(aContentAtPos.aFnd.pAttr);
+boost::property_tree::ptree aTree;
+aTree.put("text", aContentAtPos.sStr);
+aTree.put("link", pItem->GetValue());
+std::stringstream aStream;
+boost::property_tree::write_json(aStream, aTree, false);
+sHyperlink = OString(aStream.str().c_str()).trim();
+}
+
 if (pViewShell)
 {
 if (pViewShell == m_pCursorShell->GetSfxViewShell())
 {
-SfxLokHelper::notifyVisCursorInvalidation(pViewShell, sRect, 
bIsWrong);
+SfxLokHelper::notifyVisCursorInvalidation(pViewShell, sRect, 
bIsWrong, sHyperlink);
 }
 else
 
SfxLokHelper::notifyOtherView(m_pCursorShell->GetSfxViewShell(), pViewShell, 
LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect);
 }
 else
 {
-
SfxLokHelper::notifyVisCursorInvalidation(m_pCursorShell->GetSfxViewShell(), 
sRect, bIsWrong);
+
SfxLokHelper::notifyVisCursorInvalidation(m_pCursorShell->GetSfxViewShell(), 
sRect, bIsWrong, sHyperlink);
 SfxLokHelper::notifyOtherViews(m_pCursorShell->GetSfxViewShell(), 
LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect);
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: loleaflet/src

2019-10-18 Thread Grzegorz Araminowicz (via logerrit)
 loleaflet/src/control/Toolbar.js |1 +
 1 file changed, 1 insertion(+)

New commits:
commit a9f8c321a2fffa009656a97d94ee956d6a604315
Author: Grzegorz Araminowicz 
AuthorDate: Fri Oct 18 15:04:26 2019 +0200
Commit: Szymon Kłos 
CommitDate: Fri Oct 18 15:06:19 2019 +0200

hyperlink dialog div class

Change-Id: Iee2c260c940b15c9729eca37e9f04060bfbaa2e9
Reviewed-on: https://gerrit.libreoffice.org/81043
Reviewed-by: Szymon Kłos 
Tested-by: Szymon Kłos 

diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 18ad41850..2628a5190 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -351,6 +351,7 @@ L.Map.include({
showHyperlinkDialog: function() {
var map = this;
vex.dialog.open({
+   contentClassName: 'hyperlink-dialog',
message: _('Insert hyperlink'),
input: [
_('Text') + '',
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: loleaflet/src

2019-10-07 Thread Grzegorz Araminowicz (via logerrit)
 loleaflet/src/control/Control.AlertDialog.js |2 -
 loleaflet/src/control/Control.Menubar.js |8 ---
 loleaflet/src/control/Control.Toolbar.js |5 +++-
 loleaflet/src/control/Toolbar.js |   30 +++
 4 files changed, 40 insertions(+), 5 deletions(-)

New commits:
commit 34251c1d13e0c0f261f7164a0d7cedb399ebde47
Author: Grzegorz Araminowicz 
AuthorDate: Mon Oct 7 15:56:51 2019 +0200
Commit: Michael Meeks 
CommitDate: Mon Oct 7 16:20:18 2019 +0200

Add "Insert Hyperlink" vex dialog

Change-Id: I6a136a1e0b7887ef0b5d9e027a5336d962a9af26
Reviewed-on: https://gerrit.libreoffice.org/80390
Reviewed-by: Szymon Kłos 
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/loleaflet/src/control/Control.AlertDialog.js 
b/loleaflet/src/control/Control.AlertDialog.js
index 82c050948..d0f72e988 100644
--- a/loleaflet/src/control/Control.AlertDialog.js
+++ b/loleaflet/src/control/Control.AlertDialog.js
@@ -54,8 +54,8 @@ L.Control.AlertDialog = L.Control.extend({
type: 'button',
className: 'vex-dialog-button-secondary',
click: function editClick () {
-   
e.map.toggleCommandState('HyperlinkDialog');
vex.closeAll();
+   e.map.showHyperlinkDialog();
}
});
 
diff --git a/loleaflet/src/control/Control.Menubar.js 
b/loleaflet/src/control/Control.Menubar.js
index 9df4099df..9f26fe60b 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -105,7 +105,7 @@ L.Control.Menubar = L.Control.extend({
{uno: '.uno:InsertPagebreak'},
{uno: '.uno:InsertColumnBreak'},
{type: 'separator'},
-   {uno: '.uno:HyperlinkDialog'},
+   {name: _UNO('.uno:HyperlinkDialog'), id: 
'hyperlink', type: 'action'},
{uno: '.uno:InsertSymbol'},
{name: _UNO('.uno:FormattingMarkMenu', 'text'), 
type: 'menu', menu: [
{uno: '.uno:InsertNonBreakingSpace'},
@@ -294,7 +294,7 @@ L.Control.Menubar = L.Control.extend({
{name: _UNO('.uno:InsertAnnotation', 
'presentation'), id: 'insertcomment', type: 'action'},
{uno: '.uno:InsertObjectChart'},
{type: 'separator'},
-   {uno: '.uno:HyperlinkDialog'},
+   {name: _UNO('.uno:HyperlinkDialog'), id: 
'hyperlink', type: 'action'},
{type: 'separator'},
{uno: '.uno:InsertSymbol'},
{type: 'separator'},
@@ -388,7 +388,7 @@ L.Control.Menubar = L.Control.extend({
{uno: '.uno:InsertObjectChart'},
{name: _UNO('.uno:InsertAnnotation', 
'spreadsheet'), id: 'insertcomment', type: 'action'},
{type: 'separator'},
-   {uno: '.uno:HyperlinkDialog'},
+   {name: _UNO('.uno:HyperlinkDialog'), id: 
'hyperlink', type: 'action'},
{uno: '.uno:InsertSymbol'},
{uno: '.uno:EditHeaderAndFooter'}
]},
@@ -890,6 +890,8 @@ L.Control.Menubar = L.Control.extend({
});
} else if (id === 'about') {
this._map.showLOAboutDialog();
+   } else if (id === 'hyperlink') {
+   this._map.showHyperlinkDialog();
} else if (id === 'keyboard-shortcuts') {
this._map.showLOKeyboardHelp();
} else if (revHistoryEnabled && (id === 'rev-history' || id === 
'last-mod')) {
diff --git a/loleaflet/src/control/Control.Toolbar.js 
b/loleaflet/src/control/Control.Toolbar.js
index f0656b0dc..965fc9c56 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -342,6 +342,9 @@ function onClick(e, id, item, subItem) {
toolbar.check(id);
}
}
+   else if (id == 'link') {
+   map.showHyperlinkDialog();
+   }
else {
map.handleSigningClickEvent(id, item); // this handles a bunch 
of signing bar click events
}
@@ -857,7 +860,7 @@ function initNormalToolbar() {
{type: 'drop',  id: 'insertshapes',  img: 
'basicshapes_ellipse', hint: _('Insert shapes'), overlay: {onShow: 
insertShapes},
html: ''},
 
-   {type: 'button',  

[Libreoffice-commits] core.git: oox/inc oox/source

2019-10-01 Thread Grzegorz Araminowicz (via logerrit)
 oox/inc/drawingml/textbody.hxx |1 +
 oox/source/drawingml/diagram/datamodel.cxx |9 -
 oox/source/drawingml/textbody.cxx  |8 
 3 files changed, 13 insertions(+), 5 deletions(-)

New commits:
commit a8356ceb0f9345ebd5171439e3b882642f5fbad5
Author: Grzegorz Araminowicz 
AuthorDate: Mon Sep 30 13:09:13 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Tue Oct 1 21:25:02 2019 +0200

SmartArt edit UI: fix crash on empty node text

Change-Id: Idacbbb50cbdd8ae4c78f3159bc362c7ee2137149
Reviewed-on: https://gerrit.libreoffice.org/79848
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx
index 835f1c34b792..38996abe03ea 100644
--- a/oox/inc/drawingml/textbody.hxx
+++ b/oox/inc/drawingml/textbody.hxx
@@ -62,6 +62,7 @@ public:
 const TextCharacterProperties& 
rTextStyleProperties,
 const TextListStylePtr& pMasterTextListStyle ) 
const;
 bool isEmpty() const;
+OUString toString() const;
 
 voidApplyStyleEmpty(
 const ::oox::core::XmlFilterBase& rFilterBase,
diff --git a/oox/source/drawingml/diagram/datamodel.cxx 
b/oox/source/drawingml/diagram/datamodel.cxx
index bfbd67537171..fcad85bd3d6a 100644
--- a/oox/source/drawingml/diagram/datamodel.cxx
+++ b/oox/source/drawingml/diagram/datamodel.cxx
@@ -96,7 +96,7 @@ void DiagramData::getChildrenString(OUStringBuffer& rBuf, 
const dgm::Point* pPoi
 rBuf.append('\t');
 rBuf.append('+');
 rBuf.append(' ');
-
rBuf.append(pPoint->mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText());
+rBuf.append(pPoint->mpShape->getTextBody()->toString());
 rBuf.append('\n');
 }
 
@@ -136,7 +136,7 @@ std::vector> 
DiagramData::getChildren(const OUStri
 if (pChild != maPointNameMap.end())
 aChildren[rCxn.mnSourceOrder] = std::make_pair(
 pChild->second->msModelId,
-
pChild->second->mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText());
+pChild->second->mpShape->getTextBody()->toString());
 }
 
 // HACK: empty items shouldn't appear there
@@ -361,8 +361,7 @@ void DiagramData::build()
 // does currpoint have any text set?
 if( point.mpShape &&
 point.mpShape->getTextBody() &&
-!point.mpShape->getTextBody()->getParagraphs().empty() &&
-
!point.mpShape->getTextBody()->getParagraphs().front()->getRuns().empty() )
+!point.mpShape->getTextBody()->isEmpty() )
 {
 #ifdef DEBUG_OOX_DIAGRAM
 static sal_Int32 nCount=0;
@@ -371,7 +370,7 @@ void DiagramData::build()
<< " ["
<< "label=\""
<< OUStringToOString(
-   
point.mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText(),
+   point.mpShape->getTextBody()->toString(),
RTL_TEXTENCODING_UTF8).getStr()
<< "\"" << "];" << std::endl;
 output << "\t"
diff --git a/oox/source/drawingml/textbody.cxx 
b/oox/source/drawingml/textbody.cxx
index 55989a470a3f..80ebb4d2287d 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -96,6 +96,14 @@ bool TextBody::isEmpty() const
 return aRuns[0]->getText().getLength() <= 0;
 }
 
+OUString TextBody::toString() const
+{
+if (!isEmpty())
+return maParagraphs.front()->getRuns().front()->getText();
+else
+return OUString();
+}
+
 void TextBody::ApplyStyleEmpty(
 const ::oox::core::XmlFilterBase& rFilterBase,
 const Reference < XText > & xText,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: cui/source cui/uiconfig include/svx oox/source

2019-09-25 Thread Grzegorz Araminowicz (via logerrit)
 cui/source/dialogs/DiagramDialog.cxx   |   19 +++-
 cui/source/inc/DiagramDialog.hxx   |2 
 cui/uiconfig/ui/diagramdialog.ui   |   14 +
 include/svx/DiagramDataInterface.hxx   |6 +-
 oox/source/drawingml/diagram/datamodel.cxx |   68 +++--
 oox/source/drawingml/diagram/datamodel.hxx |3 -
 6 files changed, 104 insertions(+), 8 deletions(-)

New commits:
commit 711c0b6331958da4fd53eb6c4f9ecd5a422bb186
Author: Grzegorz Araminowicz 
AuthorDate: Fri Sep 20 12:53:45 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Wed Sep 25 09:31:08 2019 +0200

SmartArt Edit UI: remove node

Removes data node from data model including associated presentation nodes,
transition nodes and all connections between them (child-parent and
presentation-of).
It still doesn't update order of remaining connections after removal, so
empty entries can happen. Additional step is needed or using better data
structures.

Change-Id: I96e0752b6ec5a19ae8e972dbd421314e6c442b53
Reviewed-on: https://gerrit.libreoffice.org/79279
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/cui/source/dialogs/DiagramDialog.cxx 
b/cui/source/dialogs/DiagramDialog.cxx
index 4891ef93daee..f3a4a069a19c 100644
--- a/cui/source/dialogs/DiagramDialog.cxx
+++ b/cui/source/dialogs/DiagramDialog.cxx
@@ -20,10 +20,12 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow,
 , mpBtnOk(m_xBuilder->weld_button("btnOk"))
 , mpBtnCancel(m_xBuilder->weld_button("btnCancel"))
 , mpBtnAdd(m_xBuilder->weld_button("btnAdd"))
+, mpBtnRemove(m_xBuilder->weld_button("btnRemove"))
 , mpTreeDiagram(m_xBuilder->weld_tree_view("treeDiagram"))
 , mpTextAdd(m_xBuilder->weld_text_view("textAdd"))
 {
 mpBtnAdd->connect_clicked(LINK(this, DiagramDialog, OnAddClick));
+mpBtnRemove->connect_clicked(LINK(this, DiagramDialog, OnRemoveClick));
 
 populateTree(nullptr, OUString());
 
@@ -40,15 +42,28 @@ IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, 
void)
 OUString sText = mpTextAdd->get_text();
 if (!sText.isEmpty())
 {
+OUString sNodeId = mpDiagramData->addNode(sText);
 std::unique_ptr pEntry(mpTreeDiagram->make_iterator());
-mpTreeDiagram->insert(nullptr, -1, , nullptr, nullptr, nullptr, 
nullptr, false,
+mpTreeDiagram->insert(nullptr, -1, , , nullptr, nullptr, 
nullptr, false,
   pEntry.get());
 mpTreeDiagram->select(*pEntry);
-mpDiagramData->addNode(sText);
 comphelper::dispatchCommand(".uno:RegenerateDiagram", {});
 }
 }
 
+IMPL_LINK_NOARG(DiagramDialog, OnRemoveClick, weld::Button&, void)
+{
+std::unique_ptr pEntry(mpTreeDiagram->make_iterator());
+if (mpTreeDiagram->get_selected(pEntry.get()))
+{
+if (mpDiagramData->removeNode(mpTreeDiagram->get_id(*pEntry)))
+{
+mpTreeDiagram->remove(*pEntry);
+comphelper::dispatchCommand(".uno:RegenerateDiagram", {});
+}
+}
+}
+
 void DiagramDialog::populateTree(const weld::TreeIter* pParent, const 
OUString& rParentId)
 {
 auto aItems = mpDiagramData->getChildren(rParentId);
diff --git a/cui/source/inc/DiagramDialog.hxx b/cui/source/inc/DiagramDialog.hxx
index 461ffee9a7e6..e97144050a0e 100644
--- a/cui/source/inc/DiagramDialog.hxx
+++ b/cui/source/inc/DiagramDialog.hxx
@@ -27,10 +27,12 @@ private:
 std::unique_ptr mpBtnOk;
 std::unique_ptr mpBtnCancel;
 std::unique_ptr mpBtnAdd;
+std::unique_ptr mpBtnRemove;
 std::unique_ptr mpTreeDiagram;
 std::unique_ptr mpTextAdd;
 
 DECL_LINK(OnAddClick, weld::Button&, void);
+DECL_LINK(OnRemoveClick, weld::Button&, void);
 
 void populateTree(const weld::TreeIter* pParent, const OUString& 
rParentId);
 };
diff --git a/cui/uiconfig/ui/diagramdialog.ui b/cui/uiconfig/ui/diagramdialog.ui
index 98a67717209a..c05031f19bc4 100644
--- a/cui/uiconfig/ui/diagramdialog.ui
+++ b/cui/uiconfig/ui/diagramdialog.ui
@@ -129,6 +129,20 @@
 1
   
 
+
+  
+gtk-remove
+True
+True
+True
+True
+  
+  
+False
+True
+2
+  
+
   
   
 False
diff --git a/include/svx/DiagramDataInterface.hxx 
b/include/svx/DiagramDataInterface.hxx
index aaa3a46968b3..f64dc3a09316 100644
--- a/include/svx/DiagramDataInterface.hxx
+++ b/include/svx/DiagramDataInterface.hxx
@@ -38,8 +38,10 @@ public:
 virtual std::vector>
 getChildren(const OUString& rParentId) const = 0;
 
-// add new top-level node to data model
-virtual void addNode(const OUString& rText) = 0;
+// add new top-level node to data model, returns its id
+virtual OUString addNode(const OUString& rText) = 0;
+
+

[Libreoffice-commits] core.git: oox/Library_oox.mk oox/source solenv/clang-format

2019-09-17 Thread Grzegorz Araminowicz (via logerrit)
 oox/Library_oox.mk|1 
 oox/source/drawingml/diagram/datamodel.cxx|  417 ++
 oox/source/drawingml/diagram/datamodel.hxx|  207 ++
 oox/source/drawingml/diagram/datamodelcontext.hxx |4 
 oox/source/drawingml/diagram/diagram.cxx  |  387 
 oox/source/drawingml/diagram/diagram.hxx  |  172 -
 oox/source/drawingml/diagram/diagramdefinitioncontext.cxx |3 
 solenv/clang-format/blacklist |2 
 8 files changed, 631 insertions(+), 562 deletions(-)

New commits:
commit 29855141a874fa2d0d36959af6ae765eb3a05408
Author: Grzegorz Araminowicz 
AuthorDate: Tue Sep 17 16:17:14 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Tue Sep 17 17:52:31 2019 +0200

SmartArt: separate data model from diagram.cxx

data model is having more and more code, so separate it from diagram.cxx
as this file is getting too big

Change-Id: I05193c518c47958d24739d97f7b6afbf821b5361
Reviewed-on: https://gerrit.libreoffice.org/79067
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 7b5a26866f5d..dbc54f9ff4fb 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -139,6 +139,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
 oox/source/drawingml/customshapepresetdata \
 oox/source/drawingml/customshapeproperties \
 oox/source/drawingml/diagram/constraintlistcontext \
+oox/source/drawingml/diagram/datamodel \
 oox/source/drawingml/diagram/datamodelcontext \
 oox/source/drawingml/diagram/diagram \
 oox/source/drawingml/diagram/diagramdefinitioncontext \
diff --git a/oox/source/drawingml/diagram/datamodel.cxx 
b/oox/source/drawingml/diagram/datamodel.cxx
new file mode 100644
index ..1f1794b31854
--- /dev/null
+++ b/oox/source/drawingml/diagram/datamodel.cxx
@@ -0,0 +1,417 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "datamodel.hxx"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+using namespace ::com::sun::star;
+
+namespace oox { namespace drawingml {
+
+namespace dgm {
+
+void Connection::dump() const
+{
+SAL_INFO(
+"oox.drawingml",
+"cnx modelId " << msModelId << ", srcId " << msSourceId << ", dstId "
+<< msDestId << ", parTransId " << msParTransId << ", presId "
+<< msPresId << ", sibTransId " << msSibTransId << ", srcOrd "
+<< mnSourceOrder << ", dstOrd " << mnDestOrder);
+}
+
+void Point::dump() const
+{
+SAL_INFO(
+"oox.drawingml",
+"pt text " << mpShape.get() << ", cnxId " << msCnxId << ", modelId "
+<< msModelId << ", type " << mnType);
+}
+
+} // dgm namespace
+
+DiagramData::DiagramData() :
+mpFillProperties( new FillProperties )
+{
+}
+
+const dgm::Point* DiagramData::getRootPoint() const
+{
+for (const auto & aCurrPoint : maPoints)
+if (aCurrPoint.mnType == XML_doc)
+return 
+
+SAL_WARN("oox.drawingml", "No root point");
+return nullptr;
+}
+
+void DiagramData::dump() const
+{
+SAL_INFO("oox.drawingml", "Dgm: DiagramData # of cnx: " << 
maConnections.size() );
+for (const auto& rConnection : maConnections)
+rConnection.dump();
+
+SAL_INFO("oox.drawingml", "Dgm: DiagramData # of pt: " << maPoints.size() 
);
+for (const auto& rPoint : maPoints)
+rPoint.dump();
+}
+
+void DiagramData::getChildrenString(OUStringBuffer& rBuf, const dgm::Point* 
pPoint, sal_Int32 nLevel) const
+{
+if (!pPoint)
+return;
+
+if (nLevel > 0)
+{
+for (sal_Int32 i = 0; i < nLevel-1; i++)
+rBuf.append('\t');
+rBuf.append('+');
+rBuf.append(' ');
+
rBuf.append(pPoint->mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText());
+rBuf.append('\n');
+}
+
+std::vector aChildren;
+for (const auto& rCxn : maConnections)
+ 

[Libreoffice-commits] core.git: cui/source cui/uiconfig include/svx oox/source

2019-09-02 Thread Grzegorz Araminowicz (via logerrit)
 cui/source/dialogs/DiagramDialog.cxx |   20 
 cui/source/inc/DiagramDialog.hxx |4 +
 cui/uiconfig/ui/diagramdialog.ui |   39 +++
 include/svx/DiagramDataInterface.hxx |3 +
 oox/source/drawingml/diagram/diagram.cxx |   76 +++
 oox/source/drawingml/diagram/diagram.hxx |2 
 6 files changed, 142 insertions(+), 2 deletions(-)

New commits:
commit 6eb7dd4a2683fb4c28506a464317d7ee54cfe1de
Author: Grzegorz Araminowicz 
AuthorDate: Fri Aug 30 10:20:38 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Mon Sep 2 12:38:31 2019 +0200

SmartArt edit UI: add new node

First approach to adding new node. Currently it's possible only to add
top-level node to the end of diagram.

Change-Id: Icd9530ab2fb8987a1690ffc96c244cc845b72eba
Reviewed-on: https://gerrit.libreoffice.org/78286
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/cui/source/dialogs/DiagramDialog.cxx 
b/cui/source/dialogs/DiagramDialog.cxx
index c48e8f58089d..f3b84c0fcc4e 100644
--- a/cui/source/dialogs/DiagramDialog.cxx
+++ b/cui/source/dialogs/DiagramDialog.cxx
@@ -9,7 +9,9 @@
 
 #include 
 
+#include 
 #include 
+#include 
 
 DiagramDialog::DiagramDialog(weld::Window* pWindow,
  std::shared_ptr 
pDiagramData)
@@ -17,8 +19,12 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow,
 , mpDiagramData(pDiagramData)
 , mpBtnOk(m_xBuilder->weld_button("btnOk"))
 , mpBtnCancel(m_xBuilder->weld_button("btnCancel"))
+, mpBtnAdd(m_xBuilder->weld_button("btnAdd"))
 , mpTreeDiagram(m_xBuilder->weld_tree_view("treeDiagram"))
+, mpTextAdd(m_xBuilder->weld_text_view("textAdd"))
 {
+mpBtnAdd->connect_clicked(LINK(this, DiagramDialog, OnAddClick));
+
 populateTree(nullptr, OUString());
 
 // expand all items
@@ -29,6 +35,20 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow,
 });
 }
 
+IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, void)
+{
+OUString sText = mpTextAdd->get_text();
+if (!sText.isEmpty())
+{
+std::unique_ptr pEntry(mpTreeDiagram->make_iterator());
+mpTreeDiagram->insert(nullptr, -1, , nullptr, nullptr, nullptr, 
nullptr, false,
+  pEntry.get());
+mpTreeDiagram->select(*pEntry);
+mpDiagramData->addNode(sText);
+comphelper::dispatchCommand(".uno:RegenerateDiagram", {});
+}
+}
+
 void DiagramDialog::populateTree(weld::TreeIter* pParent, const OUString& 
rParentId)
 {
 auto aItems = mpDiagramData->getChildren(rParentId);
diff --git a/cui/source/inc/DiagramDialog.hxx b/cui/source/inc/DiagramDialog.hxx
index ec47de6414bd..c1ce3316427e 100644
--- a/cui/source/inc/DiagramDialog.hxx
+++ b/cui/source/inc/DiagramDialog.hxx
@@ -26,7 +26,11 @@ private:
 std::shared_ptr mpDiagramData;
 std::unique_ptr mpBtnOk;
 std::unique_ptr mpBtnCancel;
+std::unique_ptr mpBtnAdd;
 std::unique_ptr mpTreeDiagram;
+std::unique_ptr mpTextAdd;
+
+DECL_LINK(OnAddClick, weld::Button&, void);
 
 void populateTree(weld::TreeIter* pParent, const OUString& rParentId);
 };
diff --git a/cui/uiconfig/ui/diagramdialog.ui b/cui/uiconfig/ui/diagramdialog.ui
index 000f340f028a..c52376f0b3a3 100644
--- a/cui/uiconfig/ui/diagramdialog.ui
+++ b/cui/uiconfig/ui/diagramdialog.ui
@@ -49,7 +49,7 @@
   
 False
 False
-1
+2
   
 
 
@@ -57,7 +57,6 @@
 True
 True
 False
-True
 
   
 
@@ -68,6 +67,42 @@
 0
   
 
+
+  
+True
+False
+
+  
+True
+True
+  
+  
+True
+True
+0
+  
+
+
+  
+gtk-add
+True
+True
+True
+True
+  
+  
+False
+True
+1
+  
+
+  
+  
+False
+True
+1
+  
+
   
 
 
diff --git a/include/svx/DiagramDataInterface.hxx 
b/include/svx/DiagramDataInterface.hxx
index 9174a2b2fefe..aaa3a46968b3 100644
--- a/include/svx/DiagramDataInterface.hxx
+++ b/include/svx/DiagramDataInterface.hxx
@@ -38,6 +38,9 @@ public:
 virtual std::vector>
 getChildren(const OUString& rParentId) const = 0;
 
+// add new top-level node to data model
+virtual void addNode(const OUString& rText) = 0;
+
 protected:
 ~DiagramDataInterface() throw() {}
 };
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 4fcfbe760699..a6e8ee28acf5 100644
--- 

[Libreoffice-commits] core.git: cui/source cui/uiconfig include/svx oox/source

2019-08-27 Thread Grzegorz Araminowicz (via logerrit)
 cui/source/dialogs/DiagramDialog.cxx |   23 +--
 cui/source/inc/DiagramDialog.hxx |4 +++-
 cui/uiconfig/ui/diagramdialog.ui |7 ++-
 include/svx/DiagramDataInterface.hxx |9 +
 oox/source/drawingml/diagram/diagram.cxx |   18 ++
 oox/source/drawingml/diagram/diagram.hxx |1 +
 6 files changed, 58 insertions(+), 4 deletions(-)

New commits:
commit fae4eb717427f542305d2978f5fa78cbf27eaafa
Author: Grzegorz Araminowicz 
AuthorDate: Tue Aug 27 08:47:26 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue Aug 27 15:05:24 2019 +0200

SmartArt edit UI: change plain text widget to tree view

Added getChildren() data interface method, so that it's possible to
recursively fill tree view with (id, text) pairs

Change-Id: Ic100ded3a3e125bf79f5caa421cd8f91e5210954
Reviewed-on: https://gerrit.libreoffice.org/78169
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/cui/source/dialogs/DiagramDialog.cxx 
b/cui/source/dialogs/DiagramDialog.cxx
index f93b3bbdf28b..c48e8f58089d 100644
--- a/cui/source/dialogs/DiagramDialog.cxx
+++ b/cui/source/dialogs/DiagramDialog.cxx
@@ -17,9 +17,28 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow,
 , mpDiagramData(pDiagramData)
 , mpBtnOk(m_xBuilder->weld_button("btnOk"))
 , mpBtnCancel(m_xBuilder->weld_button("btnCancel"))
-, mpTextDiagram(m_xBuilder->weld_text_view("textDiagram"))
+, mpTreeDiagram(m_xBuilder->weld_tree_view("treeDiagram"))
 {
-mpTextDiagram->set_text(mpDiagramData->getString());
+populateTree(nullptr, OUString());
+
+// expand all items
+weld::TreeView* pTreeDiagram = mpTreeDiagram.get();
+pTreeDiagram->all_foreach([pTreeDiagram](weld::TreeIter& rEntry) {
+pTreeDiagram->expand_row(rEntry);
+return false;
+});
+}
+
+void DiagramDialog::populateTree(weld::TreeIter* pParent, const OUString& 
rParentId)
+{
+auto aItems = mpDiagramData->getChildren(rParentId);
+for (auto& aItem : aItems)
+{
+std::unique_ptr pEntry(mpTreeDiagram->make_iterator());
+mpTreeDiagram->insert(pParent, -1, , , 
nullptr, nullptr, nullptr,
+  false, pEntry.get());
+populateTree(pEntry.get(), aItem.first);
+}
 }
 
 DiagramDialog::~DiagramDialog() {}
diff --git a/cui/source/inc/DiagramDialog.hxx b/cui/source/inc/DiagramDialog.hxx
index 55a948c15cc4..ec47de6414bd 100644
--- a/cui/source/inc/DiagramDialog.hxx
+++ b/cui/source/inc/DiagramDialog.hxx
@@ -26,7 +26,9 @@ private:
 std::shared_ptr mpDiagramData;
 std::unique_ptr mpBtnOk;
 std::unique_ptr mpBtnCancel;
-std::unique_ptr mpTextDiagram;
+std::unique_ptr mpTreeDiagram;
+
+void populateTree(weld::TreeIter* pParent, const OUString& rParentId);
 };
 
 #endif // INCLUDED_CUI_SOURCE_INC_DIAGRAMDIALOG_HXX
diff --git a/cui/uiconfig/ui/diagramdialog.ui b/cui/uiconfig/ui/diagramdialog.ui
index 6b6c08df..000f340f028a 100644
--- a/cui/uiconfig/ui/diagramdialog.ui
+++ b/cui/uiconfig/ui/diagramdialog.ui
@@ -53,9 +53,14 @@
   
 
 
-  
+  
 True
 True
+False
+True
+
+  
+
   
   
 True
diff --git a/include/svx/DiagramDataInterface.hxx 
b/include/svx/DiagramDataInterface.hxx
index 439f2efeefdb..9174a2b2fefe 100644
--- a/include/svx/DiagramDataInterface.hxx
+++ b/include/svx/DiagramDataInterface.hxx
@@ -22,6 +22,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 /// Interface class to access diagram data for UI
 class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI DiagramDataInterface
 {
@@ -29,6 +32,12 @@ public:
 // get text representation of data tree
 virtual OUString getString() const = 0;
 
+// get children of provided data node
+// use empty string for top-level nodes
+// returns vector of (id, text)
+virtual std::vector>
+getChildren(const OUString& rParentId) const = 0;
+
 protected:
 ~DiagramDataInterface() throw() {}
 };
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index d690cdc40991..4fcfbe760699 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -138,6 +138,24 @@ OUString DiagramData::getString() const
 return aBuf.makeStringAndClear();
 }
 
+std::vector> DiagramData::getChildren(const 
OUString& rParentId) const
+{
+const OUString sModelId = rParentId.isEmpty() ? getRootPoint()->msModelId 
: rParentId;
+std::vector> aChildren;
+for (const auto& rCxn : maConnections)
+if (rCxn.mnType == XML_parOf && rCxn.msSourceId == sModelId)
+{
+if (rCxn.mnSourceOrder >= static_cast(aChildren.size()))
+aChildren.resize(rCxn.mnSourceOrder + 1);
+const auto pChild = maPointNameMap.find(rCxn.msDestId);
+if (pChild != 

[Libreoffice-commits] core.git: cui/Library_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk include/vcl officecfg/registry sd/inc sd/sdi sd/source

2019-08-23 Thread Grzegorz Araminowicz (via logerrit)
 cui/Library_cui.mk   |1 
 cui/UIConfig_cui.mk  |1 
 cui/source/dialogs/DiagramDialog.cxx |   27 +++
 cui/source/factory/dlgfact.cxx   |   13 +
 cui/source/factory/dlgfact.hxx   |   21 ++
 cui/source/inc/DiagramDialog.hxx |   34 

 cui/uiconfig/ui/diagramdialog.ui |   73 
++
 include/vcl/abstdlg.hxx  |   12 +
 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu |5 
 sd/inc/app.hrc   |1 
 sd/sdi/_drvwsh.sdi   |5 
 sd/sdi/sdraw.sdi |   17 ++
 sd/source/ui/view/drviews3.cxx   |   21 ++
 13 files changed, 231 insertions(+)

New commits:
commit 5457ddf2f529daf5962abcba76dbaeccff0de826
Author: Grzegorz Araminowicz 
AuthorDate: Sun Aug 18 16:23:51 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri Aug 23 09:53:09 2019 +0200

SmartArt: add Edit Diagram dialog

Currently it displays only text representation of diagram.

Change-Id: I3ff12c4abf2ed32f68ea9d7437905afc13279e62
Reviewed-on: https://gerrit.libreoffice.org/77873
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index 1822dc311097..f770cb08158a 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -110,6 +110,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
 cui/source/dialogs/cuiimapwnd \
 cui/source/dialogs/cuitbxform \
 cui/source/dialogs/dlgname \
+cui/source/dialogs/DiagramDialog \
 cui/source/dialogs/FontFeaturesDialog \
 cui/source/dialogs/hangulhanjadlg \
 cui/source/dialogs/hldocntp \
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index e25d8fbe6a13..f953af64a954 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/croppage \
cui/uiconfig/ui/cuiimapdlg \
cui/uiconfig/ui/databaselinkdialog \
+   cui/uiconfig/ui/diagramdialog \
cui/uiconfig/ui/dimensionlinestabpage \
cui/uiconfig/ui/editdictionarydialog \
cui/uiconfig/ui/editmodulesdialog \
diff --git a/cui/source/dialogs/DiagramDialog.cxx 
b/cui/source/dialogs/DiagramDialog.cxx
new file mode 100644
index ..f93b3bbdf28b
--- /dev/null
+++ b/cui/source/dialogs/DiagramDialog.cxx
@@ -0,0 +1,27 @@
+/* -*- 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/.
+*/
+
+#include 
+
+#include 
+
+DiagramDialog::DiagramDialog(weld::Window* pWindow,
+ std::shared_ptr 
pDiagramData)
+: GenericDialogController(pWindow, "cui/ui/diagramdialog.ui", 
"DiagramDialog")
+, mpDiagramData(pDiagramData)
+, mpBtnOk(m_xBuilder->weld_button("btnOk"))
+, mpBtnCancel(m_xBuilder->weld_button("btnCancel"))
+, mpTextDiagram(m_xBuilder->weld_text_view("textDiagram"))
+{
+mpTextDiagram->set_text(mpDiagramData->getString());
+}
+
+DiagramDialog::~DiagramDialog() {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 37460b879aa0..289c79ccf8be 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -87,6 +87,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::frame;
@@ -1384,6 +1385,11 @@ short AbstractTipOfTheDayDialog_Impl::Execute()
 return m_xDlg->run();
 }
 
+short AbstractDiagramDialog_Impl::Execute()
+{
+return m_xDlg->run();
+}
+
 VclPtr AbstractDialogFactory_Impl::CreateSvxMacroAssignDlg(
 weld::Window* _pParent, const Reference< XFrame >& _rxDocumentFrame, const 
bool _bUnoDialogMode,
 const Reference< XNameReplace >& _rxEvents, const sal_uInt16 
_nInitiallySelectedEvent )
@@ -1641,4 +1647,11 @@ 
AbstractDialogFactory_Impl::CreateTipOfTheDayDialog(weld::Window* pParent)
 return 
VclPtr::Create(std::make_unique(pParent));
 }
 
+VclPtr
+AbstractDialogFactory_Impl::CreateDiagramDialog(weld::Window* pParent, 
std::shared_ptr pDiagramData)
+{
+return VclPtr::Create(
+std::make_unique(pParent, pDiagramData));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 9948e71fcf24..7d579b22ae20 

[Libreoffice-commits] core.git: oox/source

2019-08-18 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagram.cxx |   38 +++
 oox/source/drawingml/diagram/diagram.hxx |4 ++-
 2 files changed, 41 insertions(+), 1 deletion(-)

New commits:
commit 8639ef9b70b8242651ef4d1a3b23b8c8eeeda52b
Author: Grzegorz Araminowicz 
AuthorDate: Sun Aug 18 16:27:54 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Sun Aug 18 18:09:28 2019 +0200

SmartArt: implement DiagramData::getString()

Allows to get data representation of diagram as text.
It will be useful as a starting point for displaying data on diagram dialog.

Change-Id: I9765d7de64a68224a6d36b7c3bc4862ce6610bdf
Reviewed-on: https://gerrit.libreoffice.org/77669
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 2c0c47899ffa..fb1fc916c349 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -100,6 +100,44 @@ void DiagramData::dump() const
 rPoint.dump();
 }
 
+void DiagramData::getChildrenString(OUStringBuffer& rBuf, const dgm::Point* 
pPoint, sal_Int32 nLevel) const
+{
+if (!pPoint)
+return;
+
+if (nLevel > 0)
+{
+for (sal_Int32 i = 0; i < nLevel-1; i++)
+rBuf.append('\t');
+rBuf.append('+');
+rBuf.append(' ');
+
rBuf.append(pPoint->mpShape->getTextBody()->getParagraphs().front()->getRuns().front()->getText());
+rBuf.append('\n');
+}
+
+std::vector aChildren;
+for (const auto& rCxn : maConnections)
+if (rCxn.mnType == XML_parOf && rCxn.msSourceId == pPoint->msModelId)
+{
+if (rCxn.mnSourceOrder >= static_cast(aChildren.size()))
+aChildren.resize(rCxn.mnSourceOrder + 1);
+const auto pChild = maPointNameMap.find(rCxn.msDestId);
+if (pChild != maPointNameMap.end())
+aChildren[rCxn.mnSourceOrder] = pChild->second;
+}
+
+for (auto pChild : aChildren)
+getChildrenString(rBuf, pChild, nLevel + 1);
+}
+
+OUString DiagramData::getString() const
+{
+OUStringBuffer aBuf;
+const dgm::Point* pPoint = getRootPoint();
+getChildrenString(aBuf, pPoint, 0);
+return aBuf.makeStringAndClear();
+}
+
 #ifdef DEBUG_OOX_DIAGRAM
 OString normalizeDotName( const OUString& rStr )
 {
diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index 656caacadb3a..62609b39fab1 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -192,9 +192,11 @@ public:
 { return maExtDrawings; }
 const dgm::Point* getRootPoint() const;
 void dump() const;
-OUString getString() const override { return OUString(); }
+OUString getString() const override;
 
 private:
+void getChildrenString(OUStringBuffer& rBuf, const dgm::Point* pPoint, 
sal_Int32 nLevel) const;
+
 ::std::vector  maExtDrawings;
 FillPropertiesPtr mpFillProperties;
 dgm::Connections  maConnections;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/oox include/svx oox/source sd/source svx/source

2019-08-05 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/diagram/diagram.hxx |   10 ++-
 include/oox/drawingml/shape.hxx   |5 +
 include/svx/DiagramDataInterface.hxx  |   38 ++
 include/svx/svdobj.hxx|4 +
 oox/source/drawingml/diagram/diagram.cxx  |   79 ++
 oox/source/drawingml/diagram/diagram.hxx  |8 ++-
 oox/source/drawingml/shape.cxx|9 +++
 sd/source/ui/view/drviews3.cxx|3 -
 svx/source/svdraw/svdobj.cxx  |   12 
 9 files changed, 118 insertions(+), 50 deletions(-)

New commits:
commit 8a029e4a39d9afda5334bc546338645241f656d6
Author: Grzegorz Araminowicz 
AuthorDate: Mon Jul 22 15:04:15 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Aug 5 09:52:00 2019 +0200

SmartArt: store diagram data model in SdrObject

It will allow modifying loaded diagram and exporting it. This data is used 
for
regenerating diagram instead of parsing xml fragment every time.
Also provided an interface for UI that can be extended to show, add and 
remove
nodes from data model.

It is stored as SdrObject field because diagram top-level shape is group 
shape.
Item set doesn't exist for them and storing data in child shapes is not
possible here because children are removed and recreated on every diagram
reload.

Change-Id: I84e5ec955f638b254fef9ef9d1731ca7938982b7
Reviewed-on: https://gerrit.libreoffice.org/76121
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/include/oox/drawingml/diagram/diagram.hxx 
b/include/oox/drawingml/diagram/diagram.hxx
index a449014e4be9..a5f69b4d56bd 100644
--- a/include/oox/drawingml/diagram/diagram.hxx
+++ b/include/oox/drawingml/diagram/diagram.hxx
@@ -23,13 +23,16 @@
 #include 
 #include 
 #include 
+#include 
 
-#include 
 #include 
 #include 
 
 namespace oox { namespace drawingml {
 
+class DiagramData;
+typedef std::shared_ptr DiagramDataPtr;
+
 /** load diagram data, and put resulting graphic into shape
 
 This method loads the diagram data fragments from the given paths,
@@ -45,14 +48,13 @@ void loadDiagram( ShapePtr const & pShape,
   const oox::core::Relations& rRelations );
 
 void loadDiagram(ShapePtr const& pShape,
- const css::uno::Reference& dataDom,
+ DiagramDataPtr pDiagramData,
  const css::uno::Reference& 
layoutDom,
  const css::uno::Reference& styleDom,
  const css::uno::Reference& colorDom,
  core::XmlFilterBase& rFilter);
 
-OOX_DLLPUBLIC void reloadDiagram(css::uno::Reference& 
rXShape,
- core::XmlFilterBase& rFilter);
+OOX_DLLPUBLIC void reloadDiagram(SdrObject* pObj, core::XmlFilterBase& 
rFilter);
 
 } }
 
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 5aa6f00318a8..d55e92ae5058 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -77,6 +77,9 @@ struct ShapeStyleRef
 
 typedef ::std::map< sal_Int32, ShapeStyleRef > ShapeStyleRefMap;
 
+class DiagramData;
+typedef std::shared_ptr DiagramDataPtr;
+
 /** Additional information for a chart embedded in a drawing shape. */
 struct ChartShapeInfo
 {
@@ -202,6 +205,7 @@ public:
 const css::uno::Sequence &
 getDiagramDoms() { return maDiagramDoms; }
 voidsetDiagramDoms(const 
css::uno::Sequence& rDiagramDoms) { maDiagramDoms = 
rDiagramDoms; }
+voidsetDiagramData(const DiagramDataPtr& pDiagramData) { 
mpDiagramData = pDiagramData; }
 css::uno::Sequence< css::uno::Sequence< css::uno::Any > 
>resolveRelationshipsOfTypeFromOfficeDoc(
   
core::XmlFilterBase& rFilter, const OUString& sFragment, const OUString& sType 
);
 voidsetLinkedTxbxAttributes(const LinkedTxbxAttr& rhs){ 
maLinkedTxbxAttr = rhs; };
@@ -352,6 +356,7 @@ private:
 boolmbHasLinkedTxbx; // this text box has 
linked text box ?
 
 css::uno::Sequence maDiagramDoms;
+DiagramDataPtr mpDiagramData;
 
 /// Z-Order.
 sal_Int32 mnZOrder = 0;
diff --git a/include/svx/DiagramDataInterface.hxx 
b/include/svx/DiagramDataInterface.hxx
new file mode 100644
index ..439f2efeefdb
--- /dev/null
+++ b/include/svx/DiagramDataInterface.hxx
@@ -0,0 +1,38 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - oox/source sd/qa

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   30 
 sd/qa/unit/import-tests-smartart.cxx|5 ++-
 2 files changed, 4 insertions(+), 31 deletions(-)

New commits:
commit 128b02cf56c929fd9d5e39a4aa214e081a58bb6a
Author: Grzegorz Araminowicz 
AuthorDate: Wed Jul 10 10:27:08 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 11:31:24 2019 +0200

SmartArt: hide connectors in org chart as they don't work correctly

Fixing them would require a lot of effort.
Changes are needed in data part (connector shapes are not created in group
shapes associated with data shapes) and in layout part - routing them
differently in all 4 or 5 hierBranch styles, with assistants and without.

Change-Id: I48840454b0272dff9ba42db2eb5d65945642459a
Reviewed-on: https://gerrit.libreoffice.org/75339
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/75397
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 93d12f23db8d..46d058b9ad68 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -104,28 +104,6 @@ bool containsDataNodeType(const oox::drawingml::ShapePtr& 
pShape, sal_Int32 nTyp
 
 return false;
 }
-
-/// Sets the position and size of a connector inside a hierChild algorithm.
-void setHierChildConnPosSize(const oox::drawingml::ShapePtr& pShape)
-{
-// Connect to the top center of the child.
-awt::Point aShapePoint = pShape->getPosition();
-awt::Size aShapeSize = pShape->getSize();
-tools::Rectangle aRectangle(Point(aShapePoint.X, aShapePoint.Y),
-Size(aShapeSize.Width, aShapeSize.Height));
-Point aTo = aRectangle.TopCenter();
-
-// Connect from the bottom center of the parent.
-Point aFrom = aTo;
-aFrom.setY(aFrom.getY() - aRectangle.getHeight() * 0.3);
-
-tools::Rectangle aRect(aFrom, aTo);
-aRect.Justify();
-aShapePoint = awt::Point(aRect.Left(), aRect.Top());
-aShapeSize = awt::Size(aRect.getWidth(), aRect.getHeight());
-pShape->setPosition(aShapePoint);
-pShape->setSize(aShapeSize);
-}
 }
 
 namespace oox { namespace drawingml {
@@ -407,7 +385,7 @@ sal_Int32 AlgAtom::getConnectorType()
 nEndSty = maMap.find(oox::XML_endSty)->second;
 
 if (nConnRout == oox::XML_bend)
-return oox::XML_bentConnector3;
+return 0; // was oox::XML_bentConnector3 - connectors are hidden in 
org chart as they don't work anyway
 if (nBegSty == oox::XML_arr && nEndSty == oox::XML_arr)
 return oox::XML_leftRightArrow;
 if (nBegSty == oox::XML_arr)
@@ -571,12 +549,6 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 
 rShape->setSubType(nType);
 rShape->getCustomShapeProperties()->setShapePresetType(nType);
-
-if (nType == XML_bentConnector3)
-{
-setHierChildConnPosSize(rShape);
-break;
-}
 }
 
 // Parse constraints to adjust the size.
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 8e5632801b45..6e615afdc5bc 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -745,10 +745,11 @@ void SdImportTestSmartArt::testOrgChart()
 uno::Reference xAssistantConnector(
 getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 0), 
uno::UNO_QUERY);
 CPPUNIT_ASSERT(xAssistantConnector.is());
-awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
+//awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
 // This failed, the vertical positions of the connector and the shape of
 // the assistant were the same.
-CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
+//CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
+// connectors are hidden as they don't work correctly
 
 // Make sure the height of xManager and xManager2 is the same.
 uno::Reference xManager2(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/oox oox/source sd/qa

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/shape.hxx|6 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|  107 -
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|1 
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |4 
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   22 ++-
 oox/source/drawingml/diagram/layoutatomvisitors.hxx|4 
 sd/qa/unit/data/pptx/smartart-org-chart2.pptx  |binary
 sd/qa/unit/import-tests-smartart.cxx   |   60 +
 8 files changed, 168 insertions(+), 36 deletions(-)

New commits:
commit 53af44593672cd456b32d4aba56220f10dad16ae
Author: Grzegorz Araminowicz 
AuthorDate: Sun Jul 7 14:12:05 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 10:59:16 2019 +0200

SmartArt: improve organization chart layout

layout shapes in two steps:
  * first calculate vertical child shapes count for every shape
(taking into accout hierBranch alg variable)
  * then actual layout using that count to calculate size for subtrees

Change-Id: I2e5ca34ed3383aa9502c52511cc1fb2bee215572
Reviewed-on: https://gerrit.libreoffice.org/75195
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/75396
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Grzegorz Araminowicz 

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 73fb85ad8dc9..4396a17a69f9 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -223,6 +223,9 @@ public:
 
 double getAspectRatio() const { return mfAspectRatio; }
 
+void setVerticalShapesCount(sal_Int32 nVerticalShapesCount) { 
mnVerticalShapesCount = nVerticalShapesCount; }
+sal_Int32 getVerticalShapesCount() const { return mnVerticalShapesCount; }
+
 /// Changes reference semantics to value semantics for fill properties.
 void cloneFillProperties();
 
@@ -357,6 +360,9 @@ private:
 
 /// Aspect ratio for an in-diagram shape.
 double mfAspectRatio = 0;
+
+/// Number of child shapes to be layouted vertically inside org chart 
in-diagram shape.
+sal_Int32 mnVerticalShapesCount = 0;
 };
 
 } }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 9c83d95fea5d..93d12f23db8d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -418,6 +418,40 @@ sal_Int32 AlgAtom::getConnectorType()
 return oox::XML_rightArrow;
 }
 
+sal_Int32 AlgAtom::getVerticalShapesCount(const ShapePtr& rShape)
+{
+if (rShape->getChildren().empty())
+return (rShape->getSubType() != XML_conn) ? 1 : 0;
+
+sal_Int32 nDir = XML_fromL;
+if (mnType == XML_hierRoot)
+nDir = XML_fromT;
+else if (maMap.count(XML_linDir))
+nDir = maMap.find(XML_linDir)->second;
+
+const sal_Int32 nSecDir = maMap.count(XML_secLinDir) ? 
maMap.find(XML_secLinDir)->second : 0;
+
+sal_Int32 nCount = 0;
+if (nDir == XML_fromT || nDir == XML_fromB)
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount += pChild->getVerticalShapesCount();
+}
+else if ((nDir == XML_fromL || nDir == XML_fromR) && nSecDir == XML_fromT)
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount += pChild->getVerticalShapesCount();
+nCount = (nCount + 1) / 2;
+}
+else
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount = std::max(nCount, pChild->getVerticalShapesCount());
+}
+
+return nCount;
+}
+
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rConstraints )
 {
@@ -621,6 +655,9 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 case XML_hierChild:
 case XML_hierRoot:
 {
+if (rShape->getChildren().empty() || rShape->getSize().Width == 0 
|| rShape->getSize().Height == 0)
+break;
+
 // hierRoot is the manager -> employees vertical linear path,
 // hierChild is the first employee -> last employee horizontal
 // linear path.
@@ -630,31 +667,20 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 else if (maMap.count(XML_linDir))
 nDir = maMap.find(XML_linDir)->second;
 
-if (rShape->getChildren().empty() || rShape->getSize().Width == 0
-|| rShape->getSize().Height == 0)
-break;
+const sal_Int32 nSecDir = maMap.count(XML_secLinDir) ? 
maMap.find(XML_secLinDir)->second : 0;
 
 sal_Int32 nCount = rShape->getChildren().size();
 
 if (mnType == XML_hierChild)
 {
-// Connectors should not influence the size of non-connect
-// shapes.
+// Connectors should not 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - oox/source sd/qa

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   76 ++--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |3 
 2 files changed, 28 insertions(+), 51 deletions(-)

New commits:
commit e222aa0d7882d5365e6ea28e82613795f5a8629a
Author: Grzegorz Araminowicz 
AuthorDate: Thu Apr 11 14:56:37 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 10:27:56 2019 +0200

SmartArt: better detecting connector arrow type

* basing on provided conn alg params
* also moved setting arrow direction from getConnectorType() to algorithms

Change-Id: I76898a4ccad961edd389677c31e7d8c05bcdf5fe
Reviewed-on: https://gerrit.libreoffice.org/70598
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/75395
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 8d569bc8fa3b..9c83d95fea5d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -87,56 +87,6 @@ sal_Int32 getPropertyFromConstraint(sal_Int32 nConstraint)
 return 0;
 }
 
-/// Determines the connector shape type from a linear alg.
-sal_Int32 getConnectorType(const oox::drawingml::LayoutNode* pNode)
-{
-sal_Int32 nType = oox::XML_rightArrow;
-
-if (!pNode)
-return nType;
-
-// This is cheaper than visiting the whole sub-tree.
-if (pNode->getName().startsWith("hierChild"))
-return oox::XML_bentConnector3;
-
-for (const auto& pChild : pNode->getChildren())
-{
-auto pAlgAtom = dynamic_cast(pChild.get());
-if (!pAlgAtom)
-continue;
-
-switch (pAlgAtom->getType())
-{
-case oox::XML_lin:
-{
-sal_Int32 nDir = oox::XML_fromL;
-if (pAlgAtom->getMap().count(oox::XML_linDir))
-nDir = pAlgAtom->getMap().find(oox::XML_linDir)->second;
-
-switch (nDir)
-{
-case oox::XML_fromL:
-nType = oox::XML_rightArrow;
-break;
-case oox::XML_fromR:
-nType = oox::XML_leftArrow;
-break;
-}
-break;
-}
-case oox::XML_hierChild:
-{
-// TODO  should be able
-// to customize this.
-nType = oox::XML_bentConnector3;
-break;
-}
-}
-}
-
-return nType;
-}
-
 /**
  * Determines if pShape is (or contains) a presentation of a data node of type
  * nType.
@@ -444,6 +394,30 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
 rVisitor.visit(*this);
 }
 
+sal_Int32 AlgAtom::getConnectorType()
+{
+sal_Int32 nConnRout = 0;
+sal_Int32 nBegSty = 0;
+sal_Int32 nEndSty = 0;
+if (maMap.count(oox::XML_connRout))
+nConnRout = maMap.find(oox::XML_connRout)->second;
+if (maMap.count(oox::XML_begSty))
+nBegSty = maMap.find(oox::XML_begSty)->second;
+if (maMap.count(oox::XML_endSty))
+nEndSty = maMap.find(oox::XML_endSty)->second;
+
+if (nConnRout == oox::XML_bend)
+return oox::XML_bentConnector3;
+if (nBegSty == oox::XML_arr && nEndSty == oox::XML_arr)
+return oox::XML_leftRightArrow;
+if (nBegSty == oox::XML_arr)
+return oox::XML_leftArrow;
+if (nEndSty == oox::XML_arr)
+return oox::XML_rightArrow;
+
+return oox::XML_rightArrow;
+}
+
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rConstraints )
 {
@@ -559,7 +533,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 {
 // There is no shape type "conn", replace it by an arrow based
 // on the direction of the parent linear layout.
-sal_Int32 nType = 
getConnectorType(getLayoutNode().getParentLayoutNode());
+sal_Int32 nType = getConnectorType();
 
 rShape->setSubType(nType);
 rShape->getCustomShapeProperties()->setShapePresetType(nType);
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 726e75e2b01e..c742f604a409 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -178,6 +178,9 @@ private:
 ParamMap  maMap;
 /// Aspect ratio is not integer, so not part of maMap.
 double mfAspectRatio = 0;
+
+/// Determines the connector shape type for conn algorithm
+sal_Int32 getConnectorType();
 };
 
 typedef std::shared_ptr< AlgAtom > AlgAtomPtr;
diff --git a/sd/qa/unit/data/pptx/smartart-mutidirectional.pptx 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - oox/source

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|3 +--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|   12 +---
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |2 --
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |4 +---
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   15 +--
 5 files changed, 12 insertions(+), 24 deletions(-)

New commits:
commit 338630cdaf6121c057a3f6e519a281315ee2778b
Author: Grzegorz Araminowicz 
AuthorDate: Sun Jul 7 11:31:22 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 09:56:10 2019 +0200

Revert "SmartArt: support multiple levels of shapes in LayoutNodes"

As we have presentation node - shape mapping, keeping shape level 
information is no longer needed.

This reverts commit 596a03b65e1b870be671ea1a44f4fba9fc66e4ae.

Change-Id: Ibde1b4afde41778304138253c1548422c5b173c3
Reviewed-on: https://gerrit.libreoffice.org/75173
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75393
Tested-by: Jenkins CollaboraOffice 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index eff192868c61..8d569bc8fa3b 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -445,8 +445,7 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
 }
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
-   const std::vector& rConstraints,
-   sal_Int32 /*nShapeLevel*/ )
+   const std::vector& rConstraints )
 {
 switch(mnType)
 {
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index f3833434950a..726e75e2b01e 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -161,8 +161,7 @@ public:
 void addParam( sal_Int32 nType, sal_Int32 nVal )
 { maMap[nType]=nVal; }
 void layoutShape( const ShapePtr& rShape,
-  const std::vector& rConstraints,
-  sal_Int32 nShapeLevel );
+  const std::vector& rConstraints );
 
 /// Gives access to .
 sal_Int32 getType() const { return mnType; }
@@ -240,7 +239,6 @@ class LayoutNode
 {
 public:
 typedef std::map VarMap;
-typedef std::map> ShapeLevelMap;
 
 LayoutNode(const Diagram& rDgm) : LayoutAtom(*this), mrDgm(rDgm), 
mnChildOrder(0) {}
 const Diagram& getDiagram() const
@@ -258,10 +256,10 @@ public:
 { mpExistingShape = pShape; }
 const ShapePtr& getExistingShape() const
 { return mpExistingShape; }
-const ShapeLevelMap& getNodeShapes() const
+const std::vector & getNodeShapes() const
 { return mpNodeShapes; }
-void addNodeShape(const ShapePtr& pShape, sal_Int32 nLevel)
-{ mpNodeShapes[nLevel].push_back(pShape); }
+void addNodeShape(const ShapePtr& pShape)
+{ mpNodeShapes.push_back(pShape); }
 
 bool setupShape( const ShapePtr& rShape,
  const dgm::Point* pPresNode ) const;
@@ -274,7 +272,7 @@ private:
 OUString msMoveWith;
 OUString msStyleLabel;
 ShapePtr mpExistingShape;
-ShapeLevelMapmpNodeShapes;
+std::vectormpNodeShapes;
 sal_Int32mnChildOrder;
 };
 
diff --git a/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
index c8761ffa3d67..98206433653a 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
@@ -131,11 +131,9 @@ void LayoutAtomVisitorBase::visit(LayoutNode& rAtom)
 
 const dgm::Point* pPreviousNode = mpCurrentNode;
 mpCurrentNode = pNewNode;
-mnCurrLevel++;
 
 defaultVisit(rAtom);
 
-mnCurrLevel--;
 mpCurrentNode = pPreviousNode;
 }
 
diff --git a/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx 
b/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
index 25f2b4dea54b..7007cf283070 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
@@ -50,8 +50,7 @@ public:
 mpCurrentNode(pRootPoint),
 mnCurrIdx(0),
 mnCurrStep(0),
-mnCurrCnt(0),
-mnCurrLevel(0)
+mnCurrCnt(0)
 {}
 
 void defaultVisit(LayoutAtom const& rAtom);
@@ -68,7 +67,6 @@ protected:
 sal_Int32 mnCurrIdx;
 sal_Int32 mnCurrStep;
 sal_Int32 mnCurrCnt;
-sal_Int32 mnCurrLevel;
 };
 
 class ShallowPresNameVisitor : public LayoutAtomVisitorBase
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - oox/source sd/qa

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   57 
 sd/qa/unit/import-tests-smartart.cxx|5 +
 2 files changed, 5 insertions(+), 57 deletions(-)

New commits:
commit 8eafe9d63e6c265f6104fba3c21fc404a118621d
Author: Grzegorz Araminowicz 
AuthorDate: Thu Jul 4 16:16:47 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 09:35:25 2019 +0200

SmartArt: remove calculateHierChildOffsetScale() from org chart algorithm

Its purpose was to center subtree if sibling parent has no children.
It was not working correctly for complex charts causing shapes to overlap.
Without it chart is still readable (just sometimes not centered).
Remove it for now until more universal solution is found.

Change-Id: I397bd4264d6ce0fadf5c5fa1352f22e72d5d163a
Reviewed-on: https://gerrit.libreoffice.org/75092
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75392
Tested-by: Jenkins CollaboraOffice 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 503f141a4fa7..eff192868c61 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -155,53 +155,6 @@ bool containsDataNodeType(const oox::drawingml::ShapePtr& 
pShape, sal_Int32 nTyp
 return false;
 }
 
-/**
- * Calculates the offset and scaling for pShape (laid out with the hierChild
- * algorithm) based on the siblings of pParent.
- */
-void calculateHierChildOffsetScale(const oox::drawingml::ShapePtr& pShape,
-   const oox::drawingml::LayoutNode* pParent, 
sal_Int32& rXOffset,
-   double& rWidthScale, sal_Int32 nLevel)
-{
-if (!pParent)
-return;
-
-auto pShapes = pParent->getNodeShapes().find(nLevel - 1);
-if (pShapes == pParent->getNodeShapes().end())
-return;
-
-const std::vector& rParents = pShapes->second;
-for (size_t nParent = 0; nParent < rParents.size(); ++nParent)
-{
-const oox::drawingml::ShapePtr& pParentShape = rParents[nParent];
-const std::vector& rChildren = 
pParentShape->getChildren();
-auto it = std::find_if(
-rChildren.begin(), rChildren.end(),
-[pShape](const oox::drawingml::ShapePtr& pChild) { return pChild 
== pShape; });
-if (it == rChildren.end())
-// This is not our parent.
-continue;
-
-if (nParent > 0)
-{
-if (rParents[nParent - 1]->getChildren().size() == 1)
-{
-// Previous sibling of our parent has no children: can use that
-// space, so shift to the left and scale up.
-rWidthScale += 1.0;
-rXOffset -= pShape->getSize().Width;
-}
-}
-if (nParent < rParents.size() - 1)
-{
-if (rParents[nParent + 1]->getChildren().size() == 1)
-// Next sibling of our parent has no children: can use that
-// space, so scale up.
-rWidthScale += 1.0;
-}
-}
-}
-
 /// Sets the position and size of a connector inside a hierChild algorithm.
 void setHierChildConnPosSize(const oox::drawingml::ShapePtr& pShape)
 {
@@ -493,7 +446,7 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rConstraints,
-   sal_Int32 nShapeLevel )
+   sal_Int32 /*nShapeLevel*/ )
 {
 switch(mnType)
 {
@@ -739,11 +692,6 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 std::swap(rChildren[1], rChildren[2]);
 }
 
-sal_Int32 nXOffset = 0;
-double fWidthScale = 1.0;
-if (mnType == XML_hierChild)
-calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale, nShapeLevel);
-
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromT)
 {
@@ -752,11 +700,10 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 else
 aChildSize.Width /= nCount;
 aChildSize.Height *= fHeightScale;
-aChildSize.Width *= fWidthScale;
 awt::Size aConnectorSize = aChildSize;
 aConnectorSize.Width = 1;
 
-awt::Point aChildPos(nXOffset, 0);
+awt::Point aChildPos(0, 0);
 for (auto& pChild : rShape->getChildren())
 {
 pChild->setPosition(aChildPos);
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 1a5fe78decf4..e10d407ee359 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -699,7 +699,7 @@ void 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/oox oox/source

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/helper/attributelist.hxx   |4 +
 oox/source/drawingml/diagram/diagram.cxx   |5 -
 oox/source/drawingml/diagram/diagram.hxx   |5 -
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|   51 -
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|2 
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |2 
 oox/source/helper/attributelist.cxx|   13 
 7 files changed, 44 insertions(+), 38 deletions(-)

New commits:
commit f3e1a315cf95e6d798e031afdb9be879052f25f3
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jul 2 16:53:40 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 09:00:59 2019 +0200

SmartArt: make if-node functions relative to current presentation node

* maxDepth calculates maximum depth of associated data node children
  (instead of per-diagram max depth)
* cnt counts children of associated data node (instead of looking up presOf
  node and if not found counting presentation node children)

Change-Id: Ifb50510acb9e6a3d2655197102060ec1c207075b
Reviewed-on: https://gerrit.libreoffice.org/75000
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75391
Tested-by: Jenkins CollaboraOffice 

diff --git a/include/oox/helper/attributelist.hxx 
b/include/oox/helper/attributelist.hxx
index 524d7f769a51..2d65ad889699 100644
--- a/include/oox/helper/attributelist.hxx
+++ b/include/oox/helper/attributelist.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
 #define INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
 
+#include 
+
 #include 
 #include 
 #include 
@@ -164,6 +166,8 @@ public:
 value if the attribute is missing or not convertible to a date/time 
value. */
 css::util::DateTime getDateTime( sal_Int32 nAttrToken, const 
css::util::DateTime& rDefault ) const;
 
+std::vector getTokenList(sal_Int32 nAttrToken) const;
+
 private:
 css::uno::Reference< css::xml::sax::XFastAttributeList >
 mxAttribs;
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index c53b983526a9..5b0f9eac69ea 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -68,8 +68,7 @@ void Point::dump() const
 } // dgm namespace
 
 DiagramData::DiagramData() :
-mpFillProperties( new FillProperties ),
-mnMaxDepth(0)
+mpFillProperties( new FillProperties )
 {
 }
 
@@ -327,8 +326,6 @@ void Diagram::build(  )
 {
 const sal_Int32 nDepth = calcDepth(elem.second.msSourceId, 
getData()->getConnections());
 elem.second.mnDepth = nDepth != 0 ? nDepth : -1;
-if (nDepth > getData()->getMaxDepth())
-getData()->setMaxDepth(nDepth);
 }
 }
 #ifdef DEBUG_OOX_DIAGRAM
diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index 2e4ceae304c8..abe8e87fc8d7 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -189,10 +189,6 @@ public:
 ::std::vector ()
 { return maExtDrawings; }
 const dgm::Point* getRootPoint() const;
-sal_Int32 getMaxDepth() const
-{ return mnMaxDepth; }
-void setMaxDepth(sal_Int32 nDepth)
-{ mnMaxDepth = nDepth; }
 void dump() const;
 private:
 FillPropertiesPtr mpFillProperties;
@@ -202,7 +198,6 @@ private:
 PointsNameMap maPointsPresNameMap;
 ConnectionNameMap maConnectionNameMap;
 StringMap maPresOfNameMap;
-sal_Int32 mnMaxDepth;
 };
 
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index b5c7a23738f7..503f141a4fa7 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -228,8 +228,7 @@ void setHierChildConnPosSize(const 
oox::drawingml::ShapePtr& pShape)
 namespace oox { namespace drawingml {
 
 IteratorAttr::IteratorAttr( )
-: mnAxis( 0 )
-, mnCnt( -1 )
+: mnCnt( -1 )
 , mbHideLastTrans( true )
 , mnPtType( 0 )
 , mnSt( 0 )
@@ -240,12 +239,15 @@ IteratorAttr::IteratorAttr( )
 void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr 
)
 {
 AttributeList attr( xAttr );
-mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
+maAxis = attr.getTokenList(XML_axis);
 mnCnt = attr.getInteger( XML_cnt, -1 );
 mbHideLastTrans = attr.getBool( XML_hideLastTrans, true );
-mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
 mnSt = attr.getInteger( XML_st, 0 );
 mnStep = attr.getInteger( XML_step, 1 );
+
+// better to keep first token instead of error when multiple values
+std::vector aPtTypes = attr.getTokenList(XML_ptType);
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - oox/Library_oox.mk oox/source sd/qa solenv/clang-format

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 oox/Library_oox.mk |1 
 oox/source/drawingml/diagram/diagram.cxx   |7 
 oox/source/drawingml/diagram/diagram.hxx   |4 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|  130 +--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|   26 --
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |  173 ++
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |   99 
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|  197 ++---
 oox/source/drawingml/diagram/layoutatomvisitors.hxx|   93 ++--
 sd/qa/unit/data/pptx/smartart-data-follow.pptx |binary
 sd/qa/unit/import-tests-smartart.cxx   |   40 +++
 solenv/clang-format/blacklist  |2 
 12 files changed, 445 insertions(+), 327 deletions(-)

New commits:
commit 100b6232b4a0cea8aea852d55dfc850b510bdf1f
Author: Grzegorz Araminowicz 
AuthorDate: Wed Jun 26 10:42:28 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 08:33:52 2019 +0200

SmartArt: all visitors follow data presentation nodes

* visitors now are keeping track of current presentation node instead of
  looking it up by name
* extracted visitor base class that follows if/else and for-each nodes
* moved condition logic from ConditionAtom to visitor, as it depends on
  visitor state

Change-Id: Iede86cd74a6098f2398a77b6cb3e9c6272dbfe4b
Reviewed-on: https://gerrit.libreoffice.org/74732
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/75390
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index f924d27543ba..34976d7ac35b 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -144,6 +144,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
 oox/source/drawingml/diagram/diagramdefinitioncontext \
 oox/source/drawingml/diagram/diagramfragmenthandler \
 oox/source/drawingml/diagram/diagramlayoutatoms \
+oox/source/drawingml/diagram/layoutatomvisitorbase \
 oox/source/drawingml/diagram/layoutatomvisitors \
 oox/source/drawingml/diagram/layoutnodecontext \
 oox/source/drawingml/drawingmltypes \
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index be49c85d40aa..c53b983526a9 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -347,15 +347,16 @@ void Diagram::addTo( const ShapePtr & pParentShape )
 
 pParentShape->setChildSize(pParentShape->getSize());
 
-if( mpLayout->getNode() )
+const dgm::Point* pRootPoint = mpData->getRootPoint();
+if (mpLayout->getNode() && pRootPoint)
 {
 // create Shape hierarchy
-ShapeCreationVisitor aCreationVisitor(pParentShape, *this);
+ShapeCreationVisitor aCreationVisitor(*this, pRootPoint, pParentShape);
 mpLayout->getNode()->setExistingShape(pParentShape);
 mpLayout->getNode()->accept(aCreationVisitor);
 
 // layout shapes - now all shapes are created
-ShapeLayoutingVisitor aLayoutingVisitor;
+ShapeLayoutingVisitor aLayoutingVisitor(*this, pRootPoint);
 mpLayout->getNode()->accept(aLayoutingVisitor);
 
 sortChildrenByZOrder(pParentShape);
diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index c5b8ec10eaf6..2e4ceae304c8 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -208,6 +208,7 @@ private:
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
 
 typedef std::map LayoutAtomMap;
+typedef std::map PresPointShapeMap;
 
 class DiagramLayout
 {
@@ -239,6 +240,8 @@ public:
 { return mpStyleData; }
 LayoutAtomMap & getLayoutAtomMap()
 { return maLayoutAtomMap; }
+PresPointShapeMap & getPresPointShapeMap()
+{ return maPresPointShapeMap; }
 
 private:
 const Diagram& mrDgm;
@@ -256,6 +259,7 @@ private:
 // clrData
 
 LayoutAtomMap maLayoutAtomMap;
+PresPointShapeMap maPresPointShapeMap;
 };
 
 typedef std::shared_ptr< DiagramLayout > DiagramLayoutPtr;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 909efaebf751..b5c7a23738f7 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -19,6 +19,8 @@
 
 #include "diagramlayoutatoms.hxx"
 
+#include "layoutatomvisitorbase.hxx"
+
 #include 
 #include 
 
@@ -300,17 +302,6 @@ void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
 rVisitor.visit(*this);
 }
 
-const std::vector& ChooseAtom::getChildren() const
-{
-for (const auto& pChild : mpChildNodes)
-{
-const ConditionAtomPtr pCond = 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - oox/source sd/qa

2019-07-10 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |4 ++--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |5 -
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |   12 
 oox/source/drawingml/diagram/layoutnodecontext.cxx  |1 -
 sd/qa/unit/import-tests-smartart.cxx|7 +++
 5 files changed, 13 insertions(+), 16 deletions(-)

New commits:
commit 583a3140c01e6140022b846e6b067c2846812e56
Author: Grzegorz Araminowicz 
AuthorDate: Mon Jun 24 16:31:48 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 07:25:21 2019 +0200

SmartArt: move setting shape aspect ratio to alg atom visit

it allows to correctly follow if/else nodes instead of using once assigned
alg atom

Change-Id: I8c321b638524df3ca68242da6300bc8c2a838bbf
Reviewed-on: https://gerrit.libreoffice.org/74648
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75385
Tested-by: Jenkins CollaboraOffice 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 842acc0757f6..4dcee899a4c0 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -274,10 +274,6 @@ public:
 
 const LayoutNode* getParentLayoutNode() const;
 
-void setAlgAtom(AlgAtomPtr pAlgAtom) { mpAlgAtom = pAlgAtom; }
-
-AlgAtomPtr getAlgAtom() const { return mpAlgAtom.lock(); }
-
 private:
 const Diagram&   mrDgm;
 VarMap   mVariables;
@@ -286,7 +282,6 @@ private:
 ShapePtr mpExistingShape;
 ShapeLevelMapmpNodeShapes;
 sal_Int32mnChildOrder;
-std::weak_ptr   mpAlgAtom;
 };
 
 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index 5d6f0065241d..aa1d21b179f1 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -43,7 +43,7 @@ void ShapeCreationVisitor::visit(ConstraintAtom& /*rAtom*/)
 
 void ShapeCreationVisitor::visit(AlgAtom& rAtom)
 {
-defaultVisit(rAtom);
+mpParentShape->setAspectRatio(rAtom.getAspectRatio());
 }
 
 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
@@ -140,8 +140,6 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
 if (rAtom.setupShape(pShape, pNewNode))
 {
 pShape->setInternalName(rAtom.getName());
-if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
-pShape->setAspectRatio(pAlgAtom->getAspectRatio());
 rAtom.addNodeShape(pShape, mnCurrLevel);
 }
 }
@@ -161,8 +159,6 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
 if (rAtom.setupShape(pShape, pNewNode))
 {
 pShape->setInternalName(rAtom.getName());
-if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
-pShape->setAspectRatio(pAlgAtom->getAspectRatio());
 pCurrParent->addChild(pShape);
 pCurrParent = pShape;
 rAtom.addNodeShape(pShape, mnCurrLevel);
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx 
b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index 0d022ca41504..27b5917b1ac9 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -234,7 +234,6 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
 // CT_Algorithm
 AlgAtomPtr pAtom( new AlgAtom(mpNode->getLayoutNode()) );
 LayoutAtom::connect(mpNode, pAtom);
-mpNode->getLayoutNode().setAlgAtom(pAtom);
 return new AlgorithmContext( *this, rAttribs, pAtom );
 }
 case DGM_TOKEN( choose ):
commit 4ddc21029514865d706d84f7fdf3fa47a172d95c
Author: Grzegorz Araminowicz 
AuthorDate: Tue Apr 9 13:25:11 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 07:25:08 2019 +0200

SmartArt: omit last atom in forEach loop only when necessary

now all transition arrows are created in cycle diagrams

Change-Id: I69e932f0060786b702dbecae72245bb624fa602b
Reviewed-on: https://gerrit.libreoffice.org/70457
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/75384
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 63aceb0df920..909efaebf751 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -228,7 +228,7 @@ namespace oox { namespace drawingml {
 IteratorAttr::IteratorAttr( )
 : mnAxis( 0 )
 , mnCnt( 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - oox/source sd/qa

2019-07-10 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagram.hxx|   10 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   27 ++--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |   18 ++--
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |   38 ++
 oox/source/drawingml/diagram/layoutatomvisitors.hxx |6 ++
 oox/source/drawingml/diagram/layoutnodecontext.cxx  |5 +-
 sd/qa/unit/data/pptx/smartart-recursion.pptx|binary
 sd/qa/unit/import-tests-smartart.cxx|   42 
 8 files changed, 128 insertions(+), 18 deletions(-)

New commits:
commit 674d58312a3682df6be2cf8680aab4e3d1528789
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jun 11 08:31:18 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Wed Jul 10 22:11:24 2019 +0200

SmartArt: support ForEach references

ForEach 'ref' parameter causes specified ForEach node to be used instead.
Used to create recursive structures like organisation charts.

Change-Id: Iee61b2e103759355b59beb8d3f33eb3cce47c590
Reviewed-on: https://gerrit.libreoffice.org/74271
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75340
Tested-by: Jenkins CollaboraOffice 

diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index a0955b124230..c5b8ec10eaf6 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -149,6 +149,8 @@ typedef std::vector< Point >Points;
 class Diagram;
 class LayoutNode;
 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
+class LayoutAtom;
+typedef std::shared_ptr LayoutAtomPtr;
 
 typedef std::map< OUString, css::uno::Reference > 
DiagramDomMap;
 
@@ -205,6 +207,8 @@ private:
 
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
 
+typedef std::map LayoutAtomMap;
+
 class DiagramLayout
 {
 public:
@@ -233,6 +237,8 @@ public:
 { return mpStyleData; }
 const DiagramDataPtr & getStyleData() const
 { return mpStyleData; }
+LayoutAtomMap & getLayoutAtomMap()
+{ return maLayoutAtomMap; }
 
 private:
 const Diagram& mrDgm;
@@ -248,6 +254,8 @@ private:
 // TODO
 // catLst
 // clrData
+
+LayoutAtomMap maLayoutAtomMap;
 };
 
 typedef std::shared_ptr< DiagramLayout > DiagramLayoutPtr;
@@ -283,6 +291,8 @@ public:
 { return mpData; }
 void setLayout( const DiagramLayoutPtr & pLayout )
 { mpLayout = pLayout; }
+const DiagramLayoutPtr& getLayout() const
+{ return mpLayout; }
 
 DiagramQStyleMap& getStyles() { return maStyles; }
 const DiagramQStyleMap& getStyles() const { return maStyles; }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index ad4e8962a4a4..63aceb0df920 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -281,6 +281,20 @@ void ForEachAtom::accept( LayoutAtomVisitor& rVisitor )
 rVisitor.visit(*this);
 }
 
+LayoutAtomPtr ForEachAtom::getRefAtom()
+{
+if (!msRef.isEmpty())
+{
+const LayoutAtomMap& rLayoutAtomMap = 
getLayoutNode().getDiagram().getLayout()->getLayoutAtomMap();
+LayoutAtomMap::const_iterator pRefAtom = rLayoutAtomMap.find(msRef);
+if (pRefAtom != rLayoutAtomMap.end())
+return pRefAtom->second;
+else
+SAL_WARN("oox.drawingml", "ForEach reference \"" << msRef << "\" 
not found");
+}
+return LayoutAtomPtr();
+}
+
 void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
 {
 rVisitor.visit(*this);
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 0291b87cc97a..842acc0757f6 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -191,10 +191,16 @@ public:
 
 IteratorAttr & iterator()
 { return maIter; }
+void setRef(const OUString& rsRef)
+{ msRef = rsRef; }
+const OUString& getRef() const
+{ return msRef; }
 virtual void accept( LayoutAtomVisitor& ) override;
+LayoutAtomPtr getRefAtom();
 
 private:
 IteratorAttr maIter;
+OUString msRef;
 };
 
 typedef std::shared_ptr< ForEachAtom > ForEachAtomPtr;
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index 5b79dafbc46b..d7c8448666fb 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -48,6 +48,13 @@ void ShapeCreationVisitor::visit(AlgAtom& rAtom)
 
 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
 {
+if (!rAtom.getRef().isEmpty())
+{
+if (LayoutAtomPtr pRefAtom = rAtom.getRefAtom())
+pRefAtom->accept(*this);
+return;
+}
+
 if 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source sd/qa

2019-07-10 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   30 
 sd/qa/unit/import-tests-smartart.cxx|5 ++-
 2 files changed, 4 insertions(+), 31 deletions(-)

New commits:
commit 4220b3caa405d301f8c15ea25049a33e4bc8138a
Author: Grzegorz Araminowicz 
AuthorDate: Wed Jul 10 10:27:08 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed Jul 10 16:21:56 2019 +0200

SmartArt: hide connectors in org chart as they don't work correctly

Fixing them would require a lot of effort.
Changes are needed in data part (connector shapes are not created in group
shapes associated with data shapes) and in layout part - routing them
differently in all 4 or 5 hierBranch styles, with assistants and without.

Change-Id: I48840454b0272dff9ba42db2eb5d65945642459a
Reviewed-on: https://gerrit.libreoffice.org/75339
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/75348

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 7f77880b28e8..12dcae71663c 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -104,28 +104,6 @@ bool containsDataNodeType(const oox::drawingml::ShapePtr& 
pShape, sal_Int32 nTyp
 
 return false;
 }
-
-/// Sets the position and size of a connector inside a hierChild algorithm.
-void setHierChildConnPosSize(const oox::drawingml::ShapePtr& pShape)
-{
-// Connect to the top center of the child.
-awt::Point aShapePoint = pShape->getPosition();
-awt::Size aShapeSize = pShape->getSize();
-tools::Rectangle aRectangle(Point(aShapePoint.X, aShapePoint.Y),
-Size(aShapeSize.Width, aShapeSize.Height));
-Point aTo = aRectangle.TopCenter();
-
-// Connect from the bottom center of the parent.
-Point aFrom = aTo;
-aFrom.setY(aFrom.getY() - aRectangle.getHeight() * 0.3);
-
-tools::Rectangle aRect(aFrom, aTo);
-aRect.Justify();
-aShapePoint = awt::Point(aRect.Left(), aRect.Top());
-aShapeSize = awt::Size(aRect.getWidth(), aRect.getHeight());
-pShape->setPosition(aShapePoint);
-pShape->setSize(aShapeSize);
-}
 }
 
 namespace oox { namespace drawingml {
@@ -407,7 +385,7 @@ sal_Int32 AlgAtom::getConnectorType()
 nEndSty = maMap.find(oox::XML_endSty)->second;
 
 if (nConnRout == oox::XML_bend)
-return oox::XML_bentConnector3;
+return 0; // was oox::XML_bentConnector3 - connectors are hidden in 
org chart as they don't work anyway
 if (nBegSty == oox::XML_arr && nEndSty == oox::XML_arr)
 return oox::XML_leftRightArrow;
 if (nBegSty == oox::XML_arr)
@@ -571,12 +549,6 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 
 rShape->setSubType(nType);
 rShape->getCustomShapeProperties()->setShapePresetType(nType);
-
-if (nType == XML_bentConnector3)
-{
-setHierChildConnPosSize(rShape);
-break;
-}
 }
 
 // Parse constraints to adjust the size.
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index ffb3a8add28a..9226bbe79152 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -878,10 +878,11 @@ void SdImportTestSmartArt::testOrgChart()
 uno::Reference xAssistantConnector(
 getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 0), 
uno::UNO_QUERY);
 CPPUNIT_ASSERT(xAssistantConnector.is());
-awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
+//awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
 // This failed, the vertical positions of the connector and the shape of
 // the assistant were the same.
-CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
+//CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
+// connectors are hidden as they don't work correctly
 
 // Make sure the height of xManager and xManager2 is the same.
 uno::Reference xManager2(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: oox/source sd/qa

2019-07-10 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   30 
 sd/qa/unit/import-tests-smartart.cxx|5 ++-
 2 files changed, 4 insertions(+), 31 deletions(-)

New commits:
commit a913c93260b5c35dc188a19f2e041bac479ac2c7
Author: Grzegorz Araminowicz 
AuthorDate: Wed Jul 10 10:27:08 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed Jul 10 13:56:13 2019 +0200

SmartArt: hide connectors in org chart as they don't work correctly

Fixing them would require a lot of effort.
Changes are needed in data part (connector shapes are not created in group
shapes associated with data shapes) and in layout part - routing them
differently in all 4 or 5 hierBranch styles, with assistants and without.

Change-Id: I48840454b0272dff9ba42db2eb5d65945642459a
Reviewed-on: https://gerrit.libreoffice.org/75339
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 7f77880b28e8..12dcae71663c 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -104,28 +104,6 @@ bool containsDataNodeType(const oox::drawingml::ShapePtr& 
pShape, sal_Int32 nTyp
 
 return false;
 }
-
-/// Sets the position and size of a connector inside a hierChild algorithm.
-void setHierChildConnPosSize(const oox::drawingml::ShapePtr& pShape)
-{
-// Connect to the top center of the child.
-awt::Point aShapePoint = pShape->getPosition();
-awt::Size aShapeSize = pShape->getSize();
-tools::Rectangle aRectangle(Point(aShapePoint.X, aShapePoint.Y),
-Size(aShapeSize.Width, aShapeSize.Height));
-Point aTo = aRectangle.TopCenter();
-
-// Connect from the bottom center of the parent.
-Point aFrom = aTo;
-aFrom.setY(aFrom.getY() - aRectangle.getHeight() * 0.3);
-
-tools::Rectangle aRect(aFrom, aTo);
-aRect.Justify();
-aShapePoint = awt::Point(aRect.Left(), aRect.Top());
-aShapeSize = awt::Size(aRect.getWidth(), aRect.getHeight());
-pShape->setPosition(aShapePoint);
-pShape->setSize(aShapeSize);
-}
 }
 
 namespace oox { namespace drawingml {
@@ -407,7 +385,7 @@ sal_Int32 AlgAtom::getConnectorType()
 nEndSty = maMap.find(oox::XML_endSty)->second;
 
 if (nConnRout == oox::XML_bend)
-return oox::XML_bentConnector3;
+return 0; // was oox::XML_bentConnector3 - connectors are hidden in 
org chart as they don't work anyway
 if (nBegSty == oox::XML_arr && nEndSty == oox::XML_arr)
 return oox::XML_leftRightArrow;
 if (nBegSty == oox::XML_arr)
@@ -571,12 +549,6 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 
 rShape->setSubType(nType);
 rShape->getCustomShapeProperties()->setShapePresetType(nType);
-
-if (nType == XML_bentConnector3)
-{
-setHierChildConnPosSize(rShape);
-break;
-}
 }
 
 // Parse constraints to adjust the size.
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index ffb3a8add28a..9226bbe79152 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -878,10 +878,11 @@ void SdImportTestSmartArt::testOrgChart()
 uno::Reference xAssistantConnector(
 getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 0), 
uno::UNO_QUERY);
 CPPUNIT_ASSERT(xAssistantConnector.is());
-awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
+//awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
 // This failed, the vertical positions of the connector and the shape of
 // the assistant were the same.
-CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
+//CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
+// connectors are hidden as they don't work correctly
 
 // Make sure the height of xManager and xManager2 is the same.
 uno::Reference xManager2(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - include/oox oox/source sd/qa

2019-07-10 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/shape.hxx|6 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|  107 -
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|1 
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |4 
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   22 ++-
 oox/source/drawingml/diagram/layoutatomvisitors.hxx|4 
 sd/qa/unit/data/pptx/smartart-org-chart2.pptx  |binary
 sd/qa/unit/import-tests-smartart.cxx   |   60 +
 8 files changed, 168 insertions(+), 36 deletions(-)

New commits:
commit d4aa418fbfb9bd23e05fa739f20363bc299570d5
Author: Grzegorz Araminowicz 
AuthorDate: Sun Jul 7 14:12:05 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed Jul 10 12:20:01 2019 +0200

SmartArt: improve organization chart layout

layout shapes in two steps:
  * first calculate vertical child shapes count for every shape
(taking into accout hierBranch alg variable)
  * then actual layout using that count to calculate size for subtrees

Change-Id: I2e5ca34ed3383aa9502c52511cc1fb2bee215572
Reviewed-on: https://gerrit.libreoffice.org/75195
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/75311

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 1f8b163b5d35..5aa6f00318a8 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -225,6 +225,9 @@ public:
 
 double getAspectRatio() const { return mfAspectRatio; }
 
+void setVerticalShapesCount(sal_Int32 nVerticalShapesCount) { 
mnVerticalShapesCount = nVerticalShapesCount; }
+sal_Int32 getVerticalShapesCount() const { return mnVerticalShapesCount; }
+
 /// Changes reference semantics to value semantics for fill properties.
 void cloneFillProperties();
 
@@ -361,6 +364,9 @@ private:
 
 /// Aspect ratio for an in-diagram shape.
 double mfAspectRatio = 0;
+
+/// Number of child shapes to be layouted vertically inside org chart 
in-diagram shape.
+sal_Int32 mnVerticalShapesCount = 0;
 };
 
 } }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index f3c3f52dce04..7f77880b28e8 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -418,6 +418,40 @@ sal_Int32 AlgAtom::getConnectorType()
 return oox::XML_rightArrow;
 }
 
+sal_Int32 AlgAtom::getVerticalShapesCount(const ShapePtr& rShape)
+{
+if (rShape->getChildren().empty())
+return (rShape->getSubType() != XML_conn) ? 1 : 0;
+
+sal_Int32 nDir = XML_fromL;
+if (mnType == XML_hierRoot)
+nDir = XML_fromT;
+else if (maMap.count(XML_linDir))
+nDir = maMap.find(XML_linDir)->second;
+
+const sal_Int32 nSecDir = maMap.count(XML_secLinDir) ? 
maMap.find(XML_secLinDir)->second : 0;
+
+sal_Int32 nCount = 0;
+if (nDir == XML_fromT || nDir == XML_fromB)
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount += pChild->getVerticalShapesCount();
+}
+else if ((nDir == XML_fromL || nDir == XML_fromR) && nSecDir == XML_fromT)
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount += pChild->getVerticalShapesCount();
+nCount = (nCount + 1) / 2;
+}
+else
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount = std::max(nCount, pChild->getVerticalShapesCount());
+}
+
+return nCount;
+}
+
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rConstraints )
 {
@@ -660,6 +694,9 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 case XML_hierChild:
 case XML_hierRoot:
 {
+if (rShape->getChildren().empty() || rShape->getSize().Width == 0 
|| rShape->getSize().Height == 0)
+break;
+
 // hierRoot is the manager -> employees vertical linear path,
 // hierChild is the first employee -> last employee horizontal
 // linear path.
@@ -669,31 +706,20 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 else if (maMap.count(XML_linDir))
 nDir = maMap.find(XML_linDir)->second;
 
-if (rShape->getChildren().empty() || rShape->getSize().Width == 0
-|| rShape->getSize().Height == 0)
-break;
+const sal_Int32 nSecDir = maMap.count(XML_secLinDir) ? 
maMap.find(XML_secLinDir)->second : 0;
 
 sal_Int32 nCount = rShape->getChildren().size();
 
 if (mnType == XML_hierChild)
 {
-// Connectors should not influence the size of non-connect
-// shapes.
+// Connectors should not influence the size of non-connect 
shapes.
 nCount = std::count_if(
  

[Libreoffice-commits] core.git: include/oox oox/source sd/qa

2019-07-09 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/shape.hxx|6 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|  107 -
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|1 
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |4 
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   22 ++-
 oox/source/drawingml/diagram/layoutatomvisitors.hxx|4 
 sd/qa/unit/data/pptx/smartart-org-chart2.pptx  |binary
 sd/qa/unit/import-tests-smartart.cxx   |   60 +
 8 files changed, 168 insertions(+), 36 deletions(-)

New commits:
commit 4a96a5d862ed46bbcb64d34b32720b5b1b3d7ca8
Author: Grzegorz Araminowicz 
AuthorDate: Sun Jul 7 14:12:05 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue Jul 9 17:02:28 2019 +0200

SmartArt: improve organization chart layout

layout shapes in two steps:
  * first calculate vertical child shapes count for every shape
(taking into accout hierBranch alg variable)
  * then actual layout using that count to calculate size for subtrees

Change-Id: I2e5ca34ed3383aa9502c52511cc1fb2bee215572
Reviewed-on: https://gerrit.libreoffice.org/75195
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 1f8b163b5d35..5aa6f00318a8 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -225,6 +225,9 @@ public:
 
 double getAspectRatio() const { return mfAspectRatio; }
 
+void setVerticalShapesCount(sal_Int32 nVerticalShapesCount) { 
mnVerticalShapesCount = nVerticalShapesCount; }
+sal_Int32 getVerticalShapesCount() const { return mnVerticalShapesCount; }
+
 /// Changes reference semantics to value semantics for fill properties.
 void cloneFillProperties();
 
@@ -361,6 +364,9 @@ private:
 
 /// Aspect ratio for an in-diagram shape.
 double mfAspectRatio = 0;
+
+/// Number of child shapes to be layouted vertically inside org chart 
in-diagram shape.
+sal_Int32 mnVerticalShapesCount = 0;
 };
 
 } }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index f3c3f52dce04..7f77880b28e8 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -418,6 +418,40 @@ sal_Int32 AlgAtom::getConnectorType()
 return oox::XML_rightArrow;
 }
 
+sal_Int32 AlgAtom::getVerticalShapesCount(const ShapePtr& rShape)
+{
+if (rShape->getChildren().empty())
+return (rShape->getSubType() != XML_conn) ? 1 : 0;
+
+sal_Int32 nDir = XML_fromL;
+if (mnType == XML_hierRoot)
+nDir = XML_fromT;
+else if (maMap.count(XML_linDir))
+nDir = maMap.find(XML_linDir)->second;
+
+const sal_Int32 nSecDir = maMap.count(XML_secLinDir) ? 
maMap.find(XML_secLinDir)->second : 0;
+
+sal_Int32 nCount = 0;
+if (nDir == XML_fromT || nDir == XML_fromB)
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount += pChild->getVerticalShapesCount();
+}
+else if ((nDir == XML_fromL || nDir == XML_fromR) && nSecDir == XML_fromT)
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount += pChild->getVerticalShapesCount();
+nCount = (nCount + 1) / 2;
+}
+else
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount = std::max(nCount, pChild->getVerticalShapesCount());
+}
+
+return nCount;
+}
+
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rConstraints )
 {
@@ -660,6 +694,9 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 case XML_hierChild:
 case XML_hierRoot:
 {
+if (rShape->getChildren().empty() || rShape->getSize().Width == 0 
|| rShape->getSize().Height == 0)
+break;
+
 // hierRoot is the manager -> employees vertical linear path,
 // hierChild is the first employee -> last employee horizontal
 // linear path.
@@ -669,31 +706,20 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 else if (maMap.count(XML_linDir))
 nDir = maMap.find(XML_linDir)->second;
 
-if (rShape->getChildren().empty() || rShape->getSize().Width == 0
-|| rShape->getSize().Height == 0)
-break;
+const sal_Int32 nSecDir = maMap.count(XML_secLinDir) ? 
maMap.find(XML_secLinDir)->second : 0;
 
 sal_Int32 nCount = rShape->getChildren().size();
 
 if (mnType == XML_hierChild)
 {
-// Connectors should not influence the size of non-connect
-// shapes.
+// Connectors should not influence the size of non-connect 
shapes.
 nCount = std::count_if(
 rShape->getChildren().begin(), 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source

2019-07-08 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|3 +--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|   12 +---
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |2 --
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |4 +---
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   15 +--
 5 files changed, 12 insertions(+), 24 deletions(-)

New commits:
commit ca042fea20d86aad2deac34d88010b0ab185c901
Author: Grzegorz Araminowicz 
AuthorDate: Sun Jul 7 11:31:22 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jul 8 13:46:28 2019 +0200

Revert "SmartArt: support multiple levels of shapes in LayoutNodes"

As we have presentation node - shape mapping, keeping shape level 
information is no longer needed.

This reverts commit 596a03b65e1b870be671ea1a44f4fba9fc66e4ae.

Change-Id: Ibde1b4afde41778304138253c1548422c5b173c3
Reviewed-on: https://gerrit.libreoffice.org/75173
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75204
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index a981dd99138c..f3c3f52dce04 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -419,8 +419,7 @@ sal_Int32 AlgAtom::getConnectorType()
 }
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
-   const std::vector& rConstraints,
-   sal_Int32 /*nShapeLevel*/ )
+   const std::vector& rConstraints )
 {
 switch(mnType)
 {
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index eafe8ce1f1ae..d77a98135c02 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -161,8 +161,7 @@ public:
 void addParam( sal_Int32 nType, sal_Int32 nVal )
 { maMap[nType]=nVal; }
 void layoutShape( const ShapePtr& rShape,
-  const std::vector& rConstraints,
-  sal_Int32 nShapeLevel );
+  const std::vector& rConstraints );
 
 void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
 
@@ -237,7 +236,6 @@ class LayoutNode
 {
 public:
 typedef std::map VarMap;
-typedef std::map> ShapeLevelMap;
 
 LayoutNode(const Diagram& rDgm) : LayoutAtom(*this), mrDgm(rDgm), 
mnChildOrder(0) {}
 const Diagram& getDiagram() const
@@ -255,10 +253,10 @@ public:
 { mpExistingShape = pShape; }
 const ShapePtr& getExistingShape() const
 { return mpExistingShape; }
-const ShapeLevelMap& getNodeShapes() const
+const std::vector & getNodeShapes() const
 { return mpNodeShapes; }
-void addNodeShape(const ShapePtr& pShape, sal_Int32 nLevel)
-{ mpNodeShapes[nLevel].push_back(pShape); }
+void addNodeShape(const ShapePtr& pShape)
+{ mpNodeShapes.push_back(pShape); }
 
 bool setupShape( const ShapePtr& rShape,
  const dgm::Point* pPresNode ) const;
@@ -271,7 +269,7 @@ private:
 OUString msMoveWith;
 OUString msStyleLabel;
 ShapePtr mpExistingShape;
-ShapeLevelMapmpNodeShapes;
+std::vectormpNodeShapes;
 sal_Int32mnChildOrder;
 };
 
diff --git a/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
index c8761ffa3d67..98206433653a 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
@@ -131,11 +131,9 @@ void LayoutAtomVisitorBase::visit(LayoutNode& rAtom)
 
 const dgm::Point* pPreviousNode = mpCurrentNode;
 mpCurrentNode = pNewNode;
-mnCurrLevel++;
 
 defaultVisit(rAtom);
 
-mnCurrLevel--;
 mpCurrentNode = pPreviousNode;
 }
 
diff --git a/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx 
b/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
index 25f2b4dea54b..7007cf283070 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
@@ -50,8 +50,7 @@ public:
 mpCurrentNode(pRootPoint),
 mnCurrIdx(0),
 mnCurrStep(0),
-mnCurrCnt(0),
-mnCurrLevel(0)
+mnCurrCnt(0)
 {}
 
 void defaultVisit(LayoutAtom const& rAtom);
@@ -68,7 +67,6 @@ protected:
 sal_Int32 mnCurrIdx;
 sal_Int32 mnCurrStep;
 sal_Int32 mnCurrCnt;
-sal_Int32 mnCurrLevel;
 };
 
 class ShallowPresNameVisitor : public LayoutAtomVisitorBase
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source sd/qa

2019-07-08 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   55 
 sd/qa/unit/import-tests-smartart.cxx|5 +
 2 files changed, 5 insertions(+), 55 deletions(-)

New commits:
commit dc063e223cc12df52fa377d4009b30b46c62acaf
Author: Grzegorz Araminowicz 
AuthorDate: Thu Jul 4 16:16:47 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jul 8 12:10:08 2019 +0200

SmartArt: remove calculateHierChildOffsetScale() from org chart algorithm

Its purpose was to center subtree if sibling parent has no children.
It was not working correctly for complex charts causing shapes to overlap.
Without it chart is still readable (just sometimes not centered).
Remove it for now until more universal solution is found.

Change-Id: I397bd4264d6ce0fadf5c5fa1352f22e72d5d163a
Reviewed-on: https://gerrit.libreoffice.org/75092
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75138
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 6a8ffd2c4b3e..a981dd99138c 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -105,51 +105,6 @@ bool containsDataNodeType(const oox::drawingml::ShapePtr& 
pShape, sal_Int32 nTyp
 return false;
 }
 
-/**
- * Calculates the offset and scaling for pShape (laid out with the hierChild
- * algorithm) based on the siblings of pParent.
- */
-void calculateHierChildOffsetScale(const oox::drawingml::ShapePtr& pShape,
-   const oox::drawingml::LayoutNode* pParent, 
sal_Int32& rXOffset,
-   double& rWidthScale, sal_Int32 nLevel)
-{
-if (!pParent)
-return;
-
-auto pShapes = pParent->getNodeShapes().find(nLevel - 1);
-if (pShapes == pParent->getNodeShapes().end())
-return;
-
-const std::vector& rParents = pShapes->second;
-for (size_t nParent = 0; nParent < rParents.size(); ++nParent)
-{
-const oox::drawingml::ShapePtr& pParentShape = rParents[nParent];
-const std::vector& rChildren = 
pParentShape->getChildren();
-if (std::none_of(rChildren.begin(), rChildren.end(),
- [pShape](const oox::drawingml::ShapePtr& pChild) { 
return pChild == pShape; }))
-// This is not our parent.
-continue;
-
-if (nParent > 0)
-{
-if (rParents[nParent - 1]->getChildren().size() == 1)
-{
-// Previous sibling of our parent has no children: can use that
-// space, so shift to the left and scale up.
-rWidthScale += 1.0;
-rXOffset -= pShape->getSize().Width;
-}
-}
-if (nParent < rParents.size() - 1)
-{
-if (rParents[nParent + 1]->getChildren().size() == 1)
-// Next sibling of our parent has no children: can use that
-// space, so scale up.
-rWidthScale += 1.0;
-}
-}
-}
-
 /// Sets the position and size of a connector inside a hierChild algorithm.
 void setHierChildConnPosSize(const oox::drawingml::ShapePtr& pShape)
 {
@@ -465,7 +420,7 @@ sal_Int32 AlgAtom::getConnectorType()
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rConstraints,
-   sal_Int32 nShapeLevel )
+   sal_Int32 /*nShapeLevel*/ )
 {
 switch(mnType)
 {
@@ -750,11 +705,6 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 std::swap(rChildren[1], rChildren[2]);
 }
 
-sal_Int32 nXOffset = 0;
-double fWidthScale = 1.0;
-if (mnType == XML_hierChild)
-calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale, nShapeLevel);
-
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromT)
 {
@@ -763,11 +713,10 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 else
 aChildSize.Width /= nCount;
 aChildSize.Height *= fHeightScale;
-aChildSize.Width *= fWidthScale;
 awt::Size aConnectorSize = aChildSize;
 aConnectorSize.Width = 1;
 
-awt::Point aChildPos(nXOffset, 0);
+awt::Point aChildPos(0, 0);
 for (auto& pChild : rShape->getChildren())
 {
 pChild->setPosition(aChildPos);
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index fde35bd0a48d..e40b364d6b58 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -832,7 +832,7 @@ void SdImportTestSmartArt::testOrgChart()
 

[Libreoffice-commits] core.git: oox/source

2019-07-07 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|3 +--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|   12 +---
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |2 --
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |4 +---
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   15 +--
 5 files changed, 12 insertions(+), 24 deletions(-)

New commits:
commit ce7398b028b8d7ef5c914d75d259a6a0979e4644
Author: Grzegorz Araminowicz 
AuthorDate: Sun Jul 7 11:31:22 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Sun Jul 7 12:47:58 2019 +0200

Revert "SmartArt: support multiple levels of shapes in LayoutNodes"

As we have presentation node - shape mapping, keeping shape level 
information is no longer needed.

This reverts commit 596a03b65e1b870be671ea1a44f4fba9fc66e4ae.

Change-Id: Ibde1b4afde41778304138253c1548422c5b173c3
Reviewed-on: https://gerrit.libreoffice.org/75173
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index a981dd99138c..f3c3f52dce04 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -419,8 +419,7 @@ sal_Int32 AlgAtom::getConnectorType()
 }
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
-   const std::vector& rConstraints,
-   sal_Int32 /*nShapeLevel*/ )
+   const std::vector& rConstraints )
 {
 switch(mnType)
 {
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index eafe8ce1f1ae..d77a98135c02 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -161,8 +161,7 @@ public:
 void addParam( sal_Int32 nType, sal_Int32 nVal )
 { maMap[nType]=nVal; }
 void layoutShape( const ShapePtr& rShape,
-  const std::vector& rConstraints,
-  sal_Int32 nShapeLevel );
+  const std::vector& rConstraints );
 
 void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
 
@@ -237,7 +236,6 @@ class LayoutNode
 {
 public:
 typedef std::map VarMap;
-typedef std::map> ShapeLevelMap;
 
 LayoutNode(const Diagram& rDgm) : LayoutAtom(*this), mrDgm(rDgm), 
mnChildOrder(0) {}
 const Diagram& getDiagram() const
@@ -255,10 +253,10 @@ public:
 { mpExistingShape = pShape; }
 const ShapePtr& getExistingShape() const
 { return mpExistingShape; }
-const ShapeLevelMap& getNodeShapes() const
+const std::vector & getNodeShapes() const
 { return mpNodeShapes; }
-void addNodeShape(const ShapePtr& pShape, sal_Int32 nLevel)
-{ mpNodeShapes[nLevel].push_back(pShape); }
+void addNodeShape(const ShapePtr& pShape)
+{ mpNodeShapes.push_back(pShape); }
 
 bool setupShape( const ShapePtr& rShape,
  const dgm::Point* pPresNode ) const;
@@ -271,7 +269,7 @@ private:
 OUString msMoveWith;
 OUString msStyleLabel;
 ShapePtr mpExistingShape;
-ShapeLevelMapmpNodeShapes;
+std::vectormpNodeShapes;
 sal_Int32mnChildOrder;
 };
 
diff --git a/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
index c8761ffa3d67..98206433653a 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitorbase.cxx
@@ -131,11 +131,9 @@ void LayoutAtomVisitorBase::visit(LayoutNode& rAtom)
 
 const dgm::Point* pPreviousNode = mpCurrentNode;
 mpCurrentNode = pNewNode;
-mnCurrLevel++;
 
 defaultVisit(rAtom);
 
-mnCurrLevel--;
 mpCurrentNode = pPreviousNode;
 }
 
diff --git a/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx 
b/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
index 25f2b4dea54b..7007cf283070 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitorbase.hxx
@@ -50,8 +50,7 @@ public:
 mpCurrentNode(pRootPoint),
 mnCurrIdx(0),
 mnCurrStep(0),
-mnCurrCnt(0),
-mnCurrLevel(0)
+mnCurrCnt(0)
 {}
 
 void defaultVisit(LayoutAtom const& rAtom);
@@ -68,7 +67,6 @@ protected:
 sal_Int32 mnCurrIdx;
 sal_Int32 mnCurrStep;
 sal_Int32 mnCurrCnt;
-sal_Int32 mnCurrLevel;
 };
 
 class ShallowPresNameVisitor : public LayoutAtomVisitorBase
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index b72133033470..31b853664577 100644
--- 

[Libreoffice-commits] core.git: oox/source sd/qa

2019-07-05 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   55 
 sd/qa/unit/import-tests-smartart.cxx|5 +
 2 files changed, 5 insertions(+), 55 deletions(-)

New commits:
commit 329c814d28c7773e64e5902ffb1aa4877e4131f1
Author: Grzegorz Araminowicz 
AuthorDate: Thu Jul 4 16:16:47 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Fri Jul 5 15:23:40 2019 +0200

SmartArt: remove calculateHierChildOffsetScale() from org chart algorithm

Its purpose was to center subtree if sibling parent has no children.
It was not working correctly for complex charts causing shapes to overlap.
Without it chart is still readable (just sometimes not centered).
Remove it for now until more universal solution is found.

Change-Id: I397bd4264d6ce0fadf5c5fa1352f22e72d5d163a
Reviewed-on: https://gerrit.libreoffice.org/75092
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 6a8ffd2c4b3e..a981dd99138c 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -105,51 +105,6 @@ bool containsDataNodeType(const oox::drawingml::ShapePtr& 
pShape, sal_Int32 nTyp
 return false;
 }
 
-/**
- * Calculates the offset and scaling for pShape (laid out with the hierChild
- * algorithm) based on the siblings of pParent.
- */
-void calculateHierChildOffsetScale(const oox::drawingml::ShapePtr& pShape,
-   const oox::drawingml::LayoutNode* pParent, 
sal_Int32& rXOffset,
-   double& rWidthScale, sal_Int32 nLevel)
-{
-if (!pParent)
-return;
-
-auto pShapes = pParent->getNodeShapes().find(nLevel - 1);
-if (pShapes == pParent->getNodeShapes().end())
-return;
-
-const std::vector& rParents = pShapes->second;
-for (size_t nParent = 0; nParent < rParents.size(); ++nParent)
-{
-const oox::drawingml::ShapePtr& pParentShape = rParents[nParent];
-const std::vector& rChildren = 
pParentShape->getChildren();
-if (std::none_of(rChildren.begin(), rChildren.end(),
- [pShape](const oox::drawingml::ShapePtr& pChild) { 
return pChild == pShape; }))
-// This is not our parent.
-continue;
-
-if (nParent > 0)
-{
-if (rParents[nParent - 1]->getChildren().size() == 1)
-{
-// Previous sibling of our parent has no children: can use that
-// space, so shift to the left and scale up.
-rWidthScale += 1.0;
-rXOffset -= pShape->getSize().Width;
-}
-}
-if (nParent < rParents.size() - 1)
-{
-if (rParents[nParent + 1]->getChildren().size() == 1)
-// Next sibling of our parent has no children: can use that
-// space, so scale up.
-rWidthScale += 1.0;
-}
-}
-}
-
 /// Sets the position and size of a connector inside a hierChild algorithm.
 void setHierChildConnPosSize(const oox::drawingml::ShapePtr& pShape)
 {
@@ -465,7 +420,7 @@ sal_Int32 AlgAtom::getConnectorType()
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rConstraints,
-   sal_Int32 nShapeLevel )
+   sal_Int32 /*nShapeLevel*/ )
 {
 switch(mnType)
 {
@@ -750,11 +705,6 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 std::swap(rChildren[1], rChildren[2]);
 }
 
-sal_Int32 nXOffset = 0;
-double fWidthScale = 1.0;
-if (mnType == XML_hierChild)
-calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale, nShapeLevel);
-
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromT)
 {
@@ -763,11 +713,10 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 else
 aChildSize.Width /= nCount;
 aChildSize.Height *= fHeightScale;
-aChildSize.Width *= fWidthScale;
 awt::Size aConnectorSize = aChildSize;
 aConnectorSize.Width = 1;
 
-awt::Point aChildPos(nXOffset, 0);
+awt::Point aChildPos(0, 0);
 for (auto& pChild : rShape->getChildren())
 {
 pChild->setPosition(aChildPos);
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index fde35bd0a48d..e40b364d6b58 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -832,7 +832,7 @@ void SdImportTestSmartArt::testOrgChart()
 CPPUNIT_ASSERT(xEmployee2Shape.is());
 
 awt::Point aEmployee2Pos = xEmployee2Shape->getPosition();
-

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - include/oox oox/source

2019-07-02 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/helper/attributelist.hxx   |4 +
 oox/source/drawingml/diagram/diagram.cxx   |5 -
 oox/source/drawingml/diagram/diagram.hxx   |5 -
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|   51 -
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|2 
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |2 
 oox/source/helper/attributelist.cxx|   13 
 7 files changed, 44 insertions(+), 38 deletions(-)

New commits:
commit d3d6661956e6681cdba7eabad0abfec559db45b9
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jul 2 16:53:40 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Tue Jul 2 19:36:06 2019 +0200

SmartArt: make if-node functions relative to current presentation node

* maxDepth calculates maximum depth of associated data node children
  (instead of per-diagram max depth)
* cnt counts children of associated data node (instead of looking up presOf
  node and if not found counting presentation node children)

Change-Id: Ifb50510acb9e6a3d2655197102060ec1c207075b
Reviewed-on: https://gerrit.libreoffice.org/75000
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75006

diff --git a/include/oox/helper/attributelist.hxx 
b/include/oox/helper/attributelist.hxx
index 524d7f769a51..2d65ad889699 100644
--- a/include/oox/helper/attributelist.hxx
+++ b/include/oox/helper/attributelist.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
 #define INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
 
+#include 
+
 #include 
 #include 
 #include 
@@ -164,6 +166,8 @@ public:
 value if the attribute is missing or not convertible to a date/time 
value. */
 css::util::DateTime getDateTime( sal_Int32 nAttrToken, const 
css::util::DateTime& rDefault ) const;
 
+std::vector getTokenList(sal_Int32 nAttrToken) const;
+
 private:
 css::uno::Reference< css::xml::sax::XFastAttributeList >
 mxAttribs;
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 2a5f2d054721..0edd94a874be 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -72,8 +72,7 @@ void Point::dump() const
 } // dgm namespace
 
 DiagramData::DiagramData() :
-mpFillProperties( new FillProperties ),
-mnMaxDepth(0)
+mpFillProperties( new FillProperties )
 {
 }
 
@@ -328,8 +327,6 @@ void Diagram::build(  )
 {
 const sal_Int32 nDepth = calcDepth(elem.second.msSourceId, 
getData()->getConnections());
 elem.second.mnDepth = nDepth != 0 ? nDepth : -1;
-if (nDepth > getData()->getMaxDepth())
-getData()->setMaxDepth(nDepth);
 }
 }
 #ifdef DEBUG_OOX_DIAGRAM
diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index e8839d1b0fe6..8e615ea5fd24 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -188,10 +188,6 @@ public:
 ::std::vector ()
 { return maExtDrawings; }
 const dgm::Point* getRootPoint() const;
-sal_Int32 getMaxDepth() const
-{ return mnMaxDepth; }
-void setMaxDepth(sal_Int32 nDepth)
-{ mnMaxDepth = nDepth; }
 void dump() const;
 private:
 ::std::vector  maExtDrawings;
@@ -202,7 +198,6 @@ private:
 PointsNameMap maPointsPresNameMap;
 ConnectionNameMap maConnectionNameMap;
 StringMap maPresOfNameMap;
-sal_Int32 mnMaxDepth;
 };
 
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index d4845c768331..6a8ffd2c4b3e 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -176,8 +176,7 @@ void setHierChildConnPosSize(const 
oox::drawingml::ShapePtr& pShape)
 namespace oox { namespace drawingml {
 
 IteratorAttr::IteratorAttr( )
-: mnAxis( 0 )
-, mnCnt( -1 )
+: mnCnt( -1 )
 , mbHideLastTrans( true )
 , mnPtType( 0 )
 , mnSt( 0 )
@@ -188,12 +187,15 @@ IteratorAttr::IteratorAttr( )
 void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr 
)
 {
 AttributeList attr( xAttr );
-mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
+maAxis = attr.getTokenList(XML_axis);
 mnCnt = attr.getInteger( XML_cnt, -1 );
 mbHideLastTrans = attr.getBool( XML_hideLastTrans, true );
-mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
 mnSt = attr.getInteger( XML_st, 0 );
 mnStep = attr.getInteger( XML_step, 1 );
+
+// better to keep first token instead of error when multiple values
+std::vector aPtTypes = attr.getTokenList(XML_ptType);
+mnPtType = aPtTypes.empty() ? XML_all : 

[Libreoffice-commits] core.git: include/oox oox/source

2019-07-02 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/helper/attributelist.hxx   |4 +
 oox/source/drawingml/diagram/diagram.cxx   |5 -
 oox/source/drawingml/diagram/diagram.hxx   |5 -
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|   51 -
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|2 
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |2 
 oox/source/helper/attributelist.cxx|   13 
 7 files changed, 44 insertions(+), 38 deletions(-)

New commits:
commit b21f84cc58d102ba0e9e99dffcbe5c9a8339308c
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jul 2 16:53:40 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Tue Jul 2 18:16:22 2019 +0200

SmartArt: make if-node functions relative to current presentation node

* maxDepth calculates maximum depth of associated data node children
  (instead of per-diagram max depth)
* cnt counts children of associated data node (instead of looking up presOf
  node and if not found counting presentation node children)

Change-Id: Ifb50510acb9e6a3d2655197102060ec1c207075b
Reviewed-on: https://gerrit.libreoffice.org/75000
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/include/oox/helper/attributelist.hxx 
b/include/oox/helper/attributelist.hxx
index 524d7f769a51..2d65ad889699 100644
--- a/include/oox/helper/attributelist.hxx
+++ b/include/oox/helper/attributelist.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
 #define INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
 
+#include 
+
 #include 
 #include 
 #include 
@@ -164,6 +166,8 @@ public:
 value if the attribute is missing or not convertible to a date/time 
value. */
 css::util::DateTime getDateTime( sal_Int32 nAttrToken, const 
css::util::DateTime& rDefault ) const;
 
+std::vector getTokenList(sal_Int32 nAttrToken) const;
+
 private:
 css::uno::Reference< css::xml::sax::XFastAttributeList >
 mxAttribs;
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 2a5f2d054721..0edd94a874be 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -72,8 +72,7 @@ void Point::dump() const
 } // dgm namespace
 
 DiagramData::DiagramData() :
-mpFillProperties( new FillProperties ),
-mnMaxDepth(0)
+mpFillProperties( new FillProperties )
 {
 }
 
@@ -328,8 +327,6 @@ void Diagram::build(  )
 {
 const sal_Int32 nDepth = calcDepth(elem.second.msSourceId, 
getData()->getConnections());
 elem.second.mnDepth = nDepth != 0 ? nDepth : -1;
-if (nDepth > getData()->getMaxDepth())
-getData()->setMaxDepth(nDepth);
 }
 }
 #ifdef DEBUG_OOX_DIAGRAM
diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index e8839d1b0fe6..8e615ea5fd24 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -188,10 +188,6 @@ public:
 ::std::vector ()
 { return maExtDrawings; }
 const dgm::Point* getRootPoint() const;
-sal_Int32 getMaxDepth() const
-{ return mnMaxDepth; }
-void setMaxDepth(sal_Int32 nDepth)
-{ mnMaxDepth = nDepth; }
 void dump() const;
 private:
 ::std::vector  maExtDrawings;
@@ -202,7 +198,6 @@ private:
 PointsNameMap maPointsPresNameMap;
 ConnectionNameMap maConnectionNameMap;
 StringMap maPresOfNameMap;
-sal_Int32 mnMaxDepth;
 };
 
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index d4845c768331..6a8ffd2c4b3e 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -176,8 +176,7 @@ void setHierChildConnPosSize(const 
oox::drawingml::ShapePtr& pShape)
 namespace oox { namespace drawingml {
 
 IteratorAttr::IteratorAttr( )
-: mnAxis( 0 )
-, mnCnt( -1 )
+: mnCnt( -1 )
 , mbHideLastTrans( true )
 , mnPtType( 0 )
 , mnSt( 0 )
@@ -188,12 +187,15 @@ IteratorAttr::IteratorAttr( )
 void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr 
)
 {
 AttributeList attr( xAttr );
-mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
+maAxis = attr.getTokenList(XML_axis);
 mnCnt = attr.getInteger( XML_cnt, -1 );
 mbHideLastTrans = attr.getBool( XML_hideLastTrans, true );
-mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
 mnSt = attr.getInteger( XML_st, 0 );
 mnStep = attr.getInteger( XML_step, 1 );
+
+// better to keep first token instead of error when multiple values
+std::vector aPtTypes = attr.getTokenList(XML_ptType);
+mnPtType = aPtTypes.empty() ? XML_all : aPtTypes.front();
 }
 
 ConditionAttr::ConditionAttr()
@@ 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/Library_oox.mk oox/source sd/qa solenv/clang-format

2019-07-01 Thread Grzegorz Araminowicz (via logerrit)
 oox/Library_oox.mk |1 
 oox/source/drawingml/diagram/diagram.cxx   |7 
 oox/source/drawingml/diagram/diagram.hxx   |4 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|  128 +--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|   26 --
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |  173 ++
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |   99 
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|  197 ++---
 oox/source/drawingml/diagram/layoutatomvisitors.hxx|   93 ++--
 sd/qa/unit/data/pptx/smartart-data-follow.pptx |binary
 sd/qa/unit/import-tests-smartart.cxx   |   40 +++
 solenv/clang-format/blacklist  |2 
 12 files changed, 445 insertions(+), 325 deletions(-)

New commits:
commit b3ee043d469cd1b67fd66e929df58a42a8f12015
Author: Grzegorz Araminowicz 
AuthorDate: Wed Jun 26 10:42:28 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Mon Jul 1 14:11:10 2019 +0200

SmartArt: all visitors follow data presentation nodes

* visitors now are keeping track of current presentation node instead of
  looking it up by name
* extracted visitor base class that follows if/else and for-each nodes
* moved condition logic from ConditionAtom to visitor, as it depends on
  visitor state

Change-Id: Iede86cd74a6098f2398a77b6cb3e9c6272dbfe4b
Reviewed-on: https://gerrit.libreoffice.org/74732
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/74951
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 7da04f81a6ce..2d4718a320cb 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -144,6 +144,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
 oox/source/drawingml/diagram/diagramdefinitioncontext \
 oox/source/drawingml/diagram/diagramfragmenthandler \
 oox/source/drawingml/diagram/diagramlayoutatoms \
+oox/source/drawingml/diagram/layoutatomvisitorbase \
 oox/source/drawingml/diagram/layoutatomvisitors \
 oox/source/drawingml/diagram/layoutnodecontext \
 oox/source/drawingml/drawingmltypes \
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 7460c52f1fed..2a5f2d054721 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -348,15 +348,16 @@ void Diagram::addTo( const ShapePtr & pParentShape )
 
 pParentShape->setChildSize(pParentShape->getSize());
 
-if( mpLayout->getNode() )
+const dgm::Point* pRootPoint = mpData->getRootPoint();
+if (mpLayout->getNode() && pRootPoint)
 {
 // create Shape hierarchy
-ShapeCreationVisitor aCreationVisitor(pParentShape, *this);
+ShapeCreationVisitor aCreationVisitor(*this, pRootPoint, pParentShape);
 mpLayout->getNode()->setExistingShape(pParentShape);
 mpLayout->getNode()->accept(aCreationVisitor);
 
 // layout shapes - now all shapes are created
-ShapeLayoutingVisitor aLayoutingVisitor;
+ShapeLayoutingVisitor aLayoutingVisitor(*this, pRootPoint);
 mpLayout->getNode()->accept(aLayoutingVisitor);
 
 sortChildrenByZOrder(pParentShape);
diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index cf12dce576a7..e8839d1b0fe6 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -208,6 +208,7 @@ private:
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
 
 typedef std::map LayoutAtomMap;
+typedef std::map PresPointShapeMap;
 
 class DiagramLayout
 {
@@ -239,6 +240,8 @@ public:
 { return mpStyleData; }
 LayoutAtomMap & getLayoutAtomMap()
 { return maLayoutAtomMap; }
+PresPointShapeMap & getPresPointShapeMap()
+{ return maPresPointShapeMap; }
 
 private:
 const Diagram& mrDgm;
@@ -256,6 +259,7 @@ private:
 // clrData
 
 LayoutAtomMap maLayoutAtomMap;
+PresPointShapeMap maPresPointShapeMap;
 };
 
 typedef std::shared_ptr< DiagramLayout > DiagramLayoutPtr;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 6497e3ba22cf..d4845c768331 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -19,6 +19,8 @@
 
 #include "diagramlayoutatoms.hxx"
 
+#include "layoutatomvisitorbase.hxx"
+
 #include 
 #include 
 
@@ -248,17 +250,6 @@ void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
 rVisitor.visit(*this);
 }
 
-const std::vector& ChooseAtom::getChildren() const
-{
-for (const auto& pChild : mpChildNodes)
-{
-const ConditionAtomPtr pCond = 
std::dynamic_pointer_cast(pChild);
-if (pCond && 

[Libreoffice-commits] core.git: oox/Library_oox.mk oox/source sd/qa solenv/clang-format

2019-07-01 Thread Grzegorz Araminowicz (via logerrit)
 oox/Library_oox.mk |1 
 oox/source/drawingml/diagram/diagram.cxx   |7 
 oox/source/drawingml/diagram/diagram.hxx   |4 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|  128 +--
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|   26 --
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |  173 ++
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |   99 
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|  197 ++---
 oox/source/drawingml/diagram/layoutatomvisitors.hxx|   93 ++--
 sd/qa/unit/data/pptx/smartart-data-follow.pptx |binary
 sd/qa/unit/import-tests-smartart.cxx   |   40 +++
 solenv/clang-format/blacklist  |2 
 12 files changed, 445 insertions(+), 325 deletions(-)

New commits:
commit 5cdf0c71ae8bc9f1e4a52e6e4e2ea6d8550f1edd
Author: Grzegorz Araminowicz 
AuthorDate: Wed Jun 26 10:42:28 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jul 1 12:04:14 2019 +0200

SmartArt: all visitors follow data presentation nodes

* visitors now are keeping track of current presentation node instead of
  looking it up by name
* extracted visitor base class that follows if/else and for-each nodes
* moved condition logic from ConditionAtom to visitor, as it depends on
  visitor state

Change-Id: Iede86cd74a6098f2398a77b6cb3e9c6272dbfe4b
Reviewed-on: https://gerrit.libreoffice.org/74732
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 7da04f81a6ce..2d4718a320cb 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -144,6 +144,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
 oox/source/drawingml/diagram/diagramdefinitioncontext \
 oox/source/drawingml/diagram/diagramfragmenthandler \
 oox/source/drawingml/diagram/diagramlayoutatoms \
+oox/source/drawingml/diagram/layoutatomvisitorbase \
 oox/source/drawingml/diagram/layoutatomvisitors \
 oox/source/drawingml/diagram/layoutnodecontext \
 oox/source/drawingml/drawingmltypes \
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 7460c52f1fed..2a5f2d054721 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -348,15 +348,16 @@ void Diagram::addTo( const ShapePtr & pParentShape )
 
 pParentShape->setChildSize(pParentShape->getSize());
 
-if( mpLayout->getNode() )
+const dgm::Point* pRootPoint = mpData->getRootPoint();
+if (mpLayout->getNode() && pRootPoint)
 {
 // create Shape hierarchy
-ShapeCreationVisitor aCreationVisitor(pParentShape, *this);
+ShapeCreationVisitor aCreationVisitor(*this, pRootPoint, pParentShape);
 mpLayout->getNode()->setExistingShape(pParentShape);
 mpLayout->getNode()->accept(aCreationVisitor);
 
 // layout shapes - now all shapes are created
-ShapeLayoutingVisitor aLayoutingVisitor;
+ShapeLayoutingVisitor aLayoutingVisitor(*this, pRootPoint);
 mpLayout->getNode()->accept(aLayoutingVisitor);
 
 sortChildrenByZOrder(pParentShape);
diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index cf12dce576a7..e8839d1b0fe6 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -208,6 +208,7 @@ private:
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
 
 typedef std::map LayoutAtomMap;
+typedef std::map PresPointShapeMap;
 
 class DiagramLayout
 {
@@ -239,6 +240,8 @@ public:
 { return mpStyleData; }
 LayoutAtomMap & getLayoutAtomMap()
 { return maLayoutAtomMap; }
+PresPointShapeMap & getPresPointShapeMap()
+{ return maPresPointShapeMap; }
 
 private:
 const Diagram& mrDgm;
@@ -256,6 +259,7 @@ private:
 // clrData
 
 LayoutAtomMap maLayoutAtomMap;
+PresPointShapeMap maPresPointShapeMap;
 };
 
 typedef std::shared_ptr< DiagramLayout > DiagramLayoutPtr;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 6497e3ba22cf..d4845c768331 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -19,6 +19,8 @@
 
 #include "diagramlayoutatoms.hxx"
 
+#include "layoutatomvisitorbase.hxx"
+
 #include 
 #include 
 
@@ -248,17 +250,6 @@ void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
 rVisitor.visit(*this);
 }
 
-const std::vector& ChooseAtom::getChildren() const
-{
-for (const auto& pChild : mpChildNodes)
-{
-const ConditionAtomPtr pCond = 
std::dynamic_pointer_cast(pChild);
-if (pCond && pCond->getDecision())
-return pCond->getChildren();
-}
-return maEmptyChildren;
-}
-
 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source

2019-06-25 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |5 -
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |6 +-
 oox/source/drawingml/diagram/layoutnodecontext.cxx  |1 -
 3 files changed, 1 insertion(+), 11 deletions(-)

New commits:
commit 5780e11ccaf9c3fd006d4412290e59dacb8b3368
Author: Grzegorz Araminowicz 
AuthorDate: Mon Jun 24 16:31:48 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Tue Jun 25 22:39:02 2019 +0200

SmartArt: move setting shape aspect ratio to alg atom visit

it allows to correctly follow if/else nodes instead of using once assigned
alg atom

Change-Id: I8c321b638524df3ca68242da6300bc8c2a838bbf
Reviewed-on: https://gerrit.libreoffice.org/74648
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/74702

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 9fff33686dd6..ef99229b66ab 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -271,10 +271,6 @@ public:
 
 const LayoutNode* getParentLayoutNode() const;
 
-void setAlgAtom(AlgAtomPtr pAlgAtom) { mpAlgAtom = pAlgAtom; }
-
-AlgAtomPtr getAlgAtom() const { return mpAlgAtom.lock(); }
-
 private:
 const Diagram&   mrDgm;
 VarMap   mVariables;
@@ -283,7 +279,6 @@ private:
 ShapePtr mpExistingShape;
 ShapeLevelMapmpNodeShapes;
 sal_Int32mnChildOrder;
-std::weak_ptr   mpAlgAtom;
 };
 
 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index 5d6f0065241d..aa1d21b179f1 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -43,7 +43,7 @@ void ShapeCreationVisitor::visit(ConstraintAtom& /*rAtom*/)
 
 void ShapeCreationVisitor::visit(AlgAtom& rAtom)
 {
-defaultVisit(rAtom);
+mpParentShape->setAspectRatio(rAtom.getAspectRatio());
 }
 
 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
@@ -140,8 +140,6 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
 if (rAtom.setupShape(pShape, pNewNode))
 {
 pShape->setInternalName(rAtom.getName());
-if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
-pShape->setAspectRatio(pAlgAtom->getAspectRatio());
 rAtom.addNodeShape(pShape, mnCurrLevel);
 }
 }
@@ -161,8 +159,6 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
 if (rAtom.setupShape(pShape, pNewNode))
 {
 pShape->setInternalName(rAtom.getName());
-if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
-pShape->setAspectRatio(pAlgAtom->getAspectRatio());
 pCurrParent->addChild(pShape);
 pCurrParent = pShape;
 rAtom.addNodeShape(pShape, mnCurrLevel);
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx 
b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index 8e3e3c2f6eb4..3547aad28a7a 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -233,7 +233,6 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
 // CT_Algorithm
 AlgAtomPtr pAtom( new AlgAtom(mpNode->getLayoutNode()) );
 LayoutAtom::connect(mpNode, pAtom);
-mpNode->getLayoutNode().setAlgAtom(pAtom);
 return new AlgorithmContext( *this, rAttribs, pAtom );
 }
 case DGM_TOKEN( choose ):
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: oox/source

2019-06-25 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |5 -
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |6 +-
 oox/source/drawingml/diagram/layoutnodecontext.cxx  |1 -
 3 files changed, 1 insertion(+), 11 deletions(-)

New commits:
commit cd7fd73714ac9b727f64b8d9fa6795fb71b1251c
Author: Grzegorz Araminowicz 
AuthorDate: Mon Jun 24 16:31:48 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Tue Jun 25 16:09:34 2019 +0200

SmartArt: move setting shape aspect ratio to alg atom visit

it allows to correctly follow if/else nodes instead of using once assigned
alg atom

Change-Id: I8c321b638524df3ca68242da6300bc8c2a838bbf
Reviewed-on: https://gerrit.libreoffice.org/74648
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 9fff33686dd6..ef99229b66ab 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -271,10 +271,6 @@ public:
 
 const LayoutNode* getParentLayoutNode() const;
 
-void setAlgAtom(AlgAtomPtr pAlgAtom) { mpAlgAtom = pAlgAtom; }
-
-AlgAtomPtr getAlgAtom() const { return mpAlgAtom.lock(); }
-
 private:
 const Diagram&   mrDgm;
 VarMap   mVariables;
@@ -283,7 +279,6 @@ private:
 ShapePtr mpExistingShape;
 ShapeLevelMapmpNodeShapes;
 sal_Int32mnChildOrder;
-std::weak_ptr   mpAlgAtom;
 };
 
 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index 5d6f0065241d..aa1d21b179f1 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -43,7 +43,7 @@ void ShapeCreationVisitor::visit(ConstraintAtom& /*rAtom*/)
 
 void ShapeCreationVisitor::visit(AlgAtom& rAtom)
 {
-defaultVisit(rAtom);
+mpParentShape->setAspectRatio(rAtom.getAspectRatio());
 }
 
 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
@@ -140,8 +140,6 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
 if (rAtom.setupShape(pShape, pNewNode))
 {
 pShape->setInternalName(rAtom.getName());
-if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
-pShape->setAspectRatio(pAlgAtom->getAspectRatio());
 rAtom.addNodeShape(pShape, mnCurrLevel);
 }
 }
@@ -161,8 +159,6 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
 if (rAtom.setupShape(pShape, pNewNode))
 {
 pShape->setInternalName(rAtom.getName());
-if (AlgAtomPtr pAlgAtom = rAtom.getAlgAtom())
-pShape->setAspectRatio(pAlgAtom->getAspectRatio());
 pCurrParent->addChild(pShape);
 pCurrParent = pShape;
 rAtom.addNodeShape(pShape, mnCurrLevel);
diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx 
b/oox/source/drawingml/diagram/layoutnodecontext.cxx
index 8e3e3c2f6eb4..3547aad28a7a 100644
--- a/oox/source/drawingml/diagram/layoutnodecontext.cxx
+++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx
@@ -233,7 +233,6 @@ LayoutNodeContext::onCreateContext( ::sal_Int32 aElement,
 // CT_Algorithm
 AlgAtomPtr pAtom( new AlgAtom(mpNode->getLayoutNode()) );
 LayoutAtom::connect(mpNode, pAtom);
-mpNode->getLayoutNode().setAlgAtom(pAtom);
 return new AlgorithmContext( *this, rAttribs, pAtom );
 }
 case DGM_TOKEN( choose ):
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source sd/qa

2019-06-19 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagram.hxx|   10 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   14 ++
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |6 ++
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |   14 ++
 oox/source/drawingml/diagram/layoutnodecontext.cxx  |5 +-
 sd/qa/unit/data/pptx/smartart-recursion.pptx|binary
 sd/qa/unit/import-tests-smartart.cxx|   42 
 7 files changed, 90 insertions(+), 1 deletion(-)

New commits:
commit a95d04250f6921730c6164fbd207ed1222c4315f
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jun 11 08:31:18 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Wed Jun 19 14:31:53 2019 +0200

SmartArt: support ForEach references

ForEach 'ref' parameter causes specified ForEach node to be used instead.
Used to create recursive structures like organisation charts.

Change-Id: Iee61b2e103759355b59beb8d3f33eb3cce47c590
Reviewed-on: https://gerrit.libreoffice.org/74271
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
(cherry picked from commit 76478f9938a5f6d96ac65b3b633280024b60baed)
Reviewed-on: https://gerrit.libreoffice.org/74337

diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index 91cb0f39fd2c..cf12dce576a7 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -149,6 +149,8 @@ typedef std::vector< Point >Points;
 class Diagram;
 class LayoutNode;
 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
+class LayoutAtom;
+typedef std::shared_ptr LayoutAtomPtr;
 
 typedef std::map< OUString, css::uno::Reference > 
DiagramDomMap;
 
@@ -205,6 +207,8 @@ private:
 
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
 
+typedef std::map LayoutAtomMap;
+
 class DiagramLayout
 {
 public:
@@ -233,6 +237,8 @@ public:
 { return mpStyleData; }
 const DiagramDataPtr & getStyleData() const
 { return mpStyleData; }
+LayoutAtomMap & getLayoutAtomMap()
+{ return maLayoutAtomMap; }
 
 private:
 const Diagram& mrDgm;
@@ -248,6 +254,8 @@ private:
 // TODO
 // catLst
 // clrData
+
+LayoutAtomMap maLayoutAtomMap;
 };
 
 typedef std::shared_ptr< DiagramLayout > DiagramLayoutPtr;
@@ -283,6 +291,8 @@ public:
 { return mpData; }
 void setLayout( const DiagramLayoutPtr & pLayout )
 { mpLayout = pLayout; }
+const DiagramLayoutPtr& getLayout() const
+{ return mpLayout; }
 
 DiagramQStyleMap& getStyles() { return maStyles; }
 const DiagramQStyleMap& getStyles() const { return maStyles; }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index f9c443c5d626..6497e3ba22cf 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -229,6 +229,20 @@ void ForEachAtom::accept( LayoutAtomVisitor& rVisitor )
 rVisitor.visit(*this);
 }
 
+LayoutAtomPtr ForEachAtom::getRefAtom()
+{
+if (!msRef.isEmpty())
+{
+const LayoutAtomMap& rLayoutAtomMap = 
getLayoutNode().getDiagram().getLayout()->getLayoutAtomMap();
+LayoutAtomMap::const_iterator pRefAtom = rLayoutAtomMap.find(msRef);
+if (pRefAtom != rLayoutAtomMap.end())
+return pRefAtom->second;
+else
+SAL_WARN("oox.drawingml", "ForEach reference \"" << msRef << "\" 
not found");
+}
+return LayoutAtomPtr();
+}
+
 void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
 {
 rVisitor.visit(*this);
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 8a11ed5cbac8..9fff33686dd6 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -188,10 +188,16 @@ public:
 
 IteratorAttr & iterator()
 { return maIter; }
+void setRef(const OUString& rsRef)
+{ msRef = rsRef; }
+const OUString& getRef() const
+{ return msRef; }
 virtual void accept( LayoutAtomVisitor& ) override;
+LayoutAtomPtr getRefAtom();
 
 private:
 IteratorAttr maIter;
+OUString msRef;
 };
 
 typedef std::shared_ptr< ForEachAtom > ForEachAtomPtr;
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index cd7b82aa9efd..5d6f0065241d 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -48,6 +48,13 @@ void ShapeCreationVisitor::visit(AlgAtom& rAtom)
 
 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
 {
+if (!rAtom.getRef().isEmpty())
+{
+if (LayoutAtomPtr pRefAtom = rAtom.getRefAtom())
+pRefAtom->accept(*this);
+return;
+}
+
 if (rAtom.iterator().mbHideLastTrans && 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source

2019-06-19 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   13 +++---
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |   12 +-
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |   24 ++--
 oox/source/drawingml/diagram/layoutatomvisitors.hxx |6 -
 4 files changed, 38 insertions(+), 17 deletions(-)

New commits:
commit c94a452d0a6a2224a8b0c610e8e41024f5d5f735
Author: Grzegorz Araminowicz 
AuthorDate: Fri Jun 14 15:12:33 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Wed Jun 19 11:55:01 2019 +0200

SmartArt: support multiple levels of shapes in LayoutNodes

it is needed for recurrent ForEach node, so that shapes on different levels
are divided and can be layouted separately

Change-Id: Iefbc82925078fe2346858748259680fa8ea252d6
Reviewed-on: https://gerrit.libreoffice.org/74043
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
(cherry picked from commit 596a03b65e1b870be671ea1a44f4fba9fc66e4ae)
Reviewed-on: https://gerrit.libreoffice.org/74341

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 2c612233251d..f9c443c5d626 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -109,12 +109,16 @@ bool containsDataNodeType(const oox::drawingml::ShapePtr& 
pShape, sal_Int32 nTyp
  */
 void calculateHierChildOffsetScale(const oox::drawingml::ShapePtr& pShape,
const oox::drawingml::LayoutNode* pParent, 
sal_Int32& rXOffset,
-   double& rWidthScale)
+   double& rWidthScale, sal_Int32 nLevel)
 {
 if (!pParent)
 return;
 
-const std::vector& rParents = 
pParent->getNodeShapes();
+auto pShapes = pParent->getNodeShapes().find(nLevel - 1);
+if (pShapes == pParent->getNodeShapes().end())
+return;
+
+const std::vector& rParents = pShapes->second;
 for (size_t nParent = 0; nParent < rParents.size(); ++nParent)
 {
 const oox::drawingml::ShapePtr& pParentShape = rParents[nParent];
@@ -469,7 +473,8 @@ sal_Int32 AlgAtom::getConnectorType()
 }
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
-   const std::vector& rConstraints )
+   const std::vector& rConstraints,
+   sal_Int32 nShapeLevel )
 {
 switch(mnType)
 {
@@ -752,7 +757,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 sal_Int32 nXOffset = 0;
 double fWidthScale = 1.0;
 if (mnType == XML_hierChild)
-calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale);
+calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale, nShapeLevel);
 
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromT)
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index e56539eb8717..8a11ed5cbac8 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -161,7 +161,8 @@ public:
 void addParam( sal_Int32 nType, sal_Int32 nVal )
 { maMap[nType]=nVal; }
 void layoutShape( const ShapePtr& rShape,
-  const std::vector& rConstraints );
+  const std::vector& rConstraints,
+  sal_Int32 nShapeLevel );
 
 void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
 
@@ -236,6 +237,7 @@ class LayoutNode
 {
 public:
 typedef std::map VarMap;
+typedef std::map> ShapeLevelMap;
 
 LayoutNode(const Diagram& rDgm) : LayoutAtom(*this), mrDgm(rDgm), 
mnChildOrder(0) {}
 const Diagram& getDiagram() const
@@ -253,10 +255,10 @@ public:
 { mpExistingShape = pShape; }
 const ShapePtr& getExistingShape() const
 { return mpExistingShape; }
-const std::vector & getNodeShapes() const
+const ShapeLevelMap& getNodeShapes() const
 { return mpNodeShapes; }
-void addNodeShape(const ShapePtr& pShape)
-{ mpNodeShapes.push_back(pShape); }
+void addNodeShape(const ShapePtr& pShape, sal_Int32 nLevel)
+{ mpNodeShapes[nLevel].push_back(pShape); }
 
 bool setupShape( const ShapePtr& rShape,
  const dgm::Point* pPresNode ) const;
@@ -273,7 +275,7 @@ private:
 OUString msMoveWith;
 OUString msStyleLabel;
 ShapePtr mpExistingShape;
-std::vectormpNodeShapes;
+ShapeLevelMapmpNodeShapes;
 sal_Int32mnChildOrder;
 std::weak_ptr   mpAlgAtom;
 };
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 

[Libreoffice-commits] core.git: oox/source sd/qa

2019-06-18 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagram.hxx|   10 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   14 ++
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |6 ++
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |   14 ++
 oox/source/drawingml/diagram/layoutnodecontext.cxx  |5 +-
 sd/qa/unit/data/pptx/smartart-recursion.pptx|binary
 sd/qa/unit/import-tests-smartart.cxx|   42 
 7 files changed, 90 insertions(+), 1 deletion(-)

New commits:
commit 76478f9938a5f6d96ac65b3b633280024b60baed
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jun 11 08:31:18 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Tue Jun 18 16:10:50 2019 +0200

SmartArt: support ForEach references

ForEach 'ref' parameter causes specified ForEach node to be used instead.
Used to create recursive structures like organisation charts.

Change-Id: Iee61b2e103759355b59beb8d3f33eb3cce47c590
Reviewed-on: https://gerrit.libreoffice.org/74271
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index 91cb0f39fd2c..cf12dce576a7 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -149,6 +149,8 @@ typedef std::vector< Point >Points;
 class Diagram;
 class LayoutNode;
 typedef std::shared_ptr< LayoutNode > LayoutNodePtr;
+class LayoutAtom;
+typedef std::shared_ptr LayoutAtomPtr;
 
 typedef std::map< OUString, css::uno::Reference > 
DiagramDomMap;
 
@@ -205,6 +207,8 @@ private:
 
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
 
+typedef std::map LayoutAtomMap;
+
 class DiagramLayout
 {
 public:
@@ -233,6 +237,8 @@ public:
 { return mpStyleData; }
 const DiagramDataPtr & getStyleData() const
 { return mpStyleData; }
+LayoutAtomMap & getLayoutAtomMap()
+{ return maLayoutAtomMap; }
 
 private:
 const Diagram& mrDgm;
@@ -248,6 +254,8 @@ private:
 // TODO
 // catLst
 // clrData
+
+LayoutAtomMap maLayoutAtomMap;
 };
 
 typedef std::shared_ptr< DiagramLayout > DiagramLayoutPtr;
@@ -283,6 +291,8 @@ public:
 { return mpData; }
 void setLayout( const DiagramLayoutPtr & pLayout )
 { mpLayout = pLayout; }
+const DiagramLayoutPtr& getLayout() const
+{ return mpLayout; }
 
 DiagramQStyleMap& getStyles() { return maStyles; }
 const DiagramQStyleMap& getStyles() const { return maStyles; }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index f9c443c5d626..6497e3ba22cf 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -229,6 +229,20 @@ void ForEachAtom::accept( LayoutAtomVisitor& rVisitor )
 rVisitor.visit(*this);
 }
 
+LayoutAtomPtr ForEachAtom::getRefAtom()
+{
+if (!msRef.isEmpty())
+{
+const LayoutAtomMap& rLayoutAtomMap = 
getLayoutNode().getDiagram().getLayout()->getLayoutAtomMap();
+LayoutAtomMap::const_iterator pRefAtom = rLayoutAtomMap.find(msRef);
+if (pRefAtom != rLayoutAtomMap.end())
+return pRefAtom->second;
+else
+SAL_WARN("oox.drawingml", "ForEach reference \"" << msRef << "\" 
not found");
+}
+return LayoutAtomPtr();
+}
+
 void ChooseAtom::accept( LayoutAtomVisitor& rVisitor )
 {
 rVisitor.visit(*this);
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index 8a11ed5cbac8..9fff33686dd6 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -188,10 +188,16 @@ public:
 
 IteratorAttr & iterator()
 { return maIter; }
+void setRef(const OUString& rsRef)
+{ msRef = rsRef; }
+const OUString& getRef() const
+{ return msRef; }
 virtual void accept( LayoutAtomVisitor& ) override;
+LayoutAtomPtr getRefAtom();
 
 private:
 IteratorAttr maIter;
+OUString msRef;
 };
 
 typedef std::shared_ptr< ForEachAtom > ForEachAtomPtr;
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index cd7b82aa9efd..5d6f0065241d 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -48,6 +48,13 @@ void ShapeCreationVisitor::visit(AlgAtom& rAtom)
 
 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
 {
+if (!rAtom.getRef().isEmpty())
+{
+if (LayoutAtomPtr pRefAtom = rAtom.getRefAtom())
+pRefAtom->accept(*this);
+return;
+}
+
 if (rAtom.iterator().mbHideLastTrans && rAtom.iterator().mnAxis == 
XML_followSib)
 {
 // If last transition is hidden and the axis is the follow sibling,
@@ -276,6 +283,13 

[Libreoffice-commits] core.git: oox/source

2019-06-17 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   13 +++---
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |   12 +-
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |   24 ++--
 oox/source/drawingml/diagram/layoutatomvisitors.hxx |6 -
 4 files changed, 38 insertions(+), 17 deletions(-)

New commits:
commit 596a03b65e1b870be671ea1a44f4fba9fc66e4ae
Author: Grzegorz Araminowicz 
AuthorDate: Fri Jun 14 15:12:33 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Mon Jun 17 12:07:29 2019 +0200

SmartArt: support multiple levels of shapes in LayoutNodes

it is needed for recurrent ForEach node, so that shapes on different levels
are divided and can be layouted separately

Change-Id: Iefbc82925078fe2346858748259680fa8ea252d6
Reviewed-on: https://gerrit.libreoffice.org/74043
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 2c612233251d..f9c443c5d626 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -109,12 +109,16 @@ bool containsDataNodeType(const oox::drawingml::ShapePtr& 
pShape, sal_Int32 nTyp
  */
 void calculateHierChildOffsetScale(const oox::drawingml::ShapePtr& pShape,
const oox::drawingml::LayoutNode* pParent, 
sal_Int32& rXOffset,
-   double& rWidthScale)
+   double& rWidthScale, sal_Int32 nLevel)
 {
 if (!pParent)
 return;
 
-const std::vector& rParents = 
pParent->getNodeShapes();
+auto pShapes = pParent->getNodeShapes().find(nLevel - 1);
+if (pShapes == pParent->getNodeShapes().end())
+return;
+
+const std::vector& rParents = pShapes->second;
 for (size_t nParent = 0; nParent < rParents.size(); ++nParent)
 {
 const oox::drawingml::ShapePtr& pParentShape = rParents[nParent];
@@ -469,7 +473,8 @@ sal_Int32 AlgAtom::getConnectorType()
 }
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
-   const std::vector& rConstraints )
+   const std::vector& rConstraints,
+   sal_Int32 nShapeLevel )
 {
 switch(mnType)
 {
@@ -752,7 +757,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 sal_Int32 nXOffset = 0;
 double fWidthScale = 1.0;
 if (mnType == XML_hierChild)
-calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale);
+calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale, nShapeLevel);
 
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromT)
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index e56539eb8717..8a11ed5cbac8 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -161,7 +161,8 @@ public:
 void addParam( sal_Int32 nType, sal_Int32 nVal )
 { maMap[nType]=nVal; }
 void layoutShape( const ShapePtr& rShape,
-  const std::vector& rConstraints );
+  const std::vector& rConstraints,
+  sal_Int32 nShapeLevel );
 
 void setAspectRatio(double fAspectRatio) { mfAspectRatio = fAspectRatio; }
 
@@ -236,6 +237,7 @@ class LayoutNode
 {
 public:
 typedef std::map VarMap;
+typedef std::map> ShapeLevelMap;
 
 LayoutNode(const Diagram& rDgm) : LayoutAtom(*this), mrDgm(rDgm), 
mnChildOrder(0) {}
 const Diagram& getDiagram() const
@@ -253,10 +255,10 @@ public:
 { mpExistingShape = pShape; }
 const ShapePtr& getExistingShape() const
 { return mpExistingShape; }
-const std::vector & getNodeShapes() const
+const ShapeLevelMap& getNodeShapes() const
 { return mpNodeShapes; }
-void addNodeShape(const ShapePtr& pShape)
-{ mpNodeShapes.push_back(pShape); }
+void addNodeShape(const ShapePtr& pShape, sal_Int32 nLevel)
+{ mpNodeShapes[nLevel].push_back(pShape); }
 
 bool setupShape( const ShapePtr& rShape,
  const dgm::Point* pPresNode ) const;
@@ -273,7 +275,7 @@ private:
 OUString msMoveWith;
 OUString msStyleLabel;
 ShapePtr mpExistingShape;
-std::vectormpNodeShapes;
+ShapeLevelMapmpNodeShapes;
 sal_Int32mnChildOrder;
 std::weak_ptr   mpAlgAtom;
 };
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index c6532243ec6c..cd7b82aa9efd 100644
--- 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - oox/source sd/qa

2019-06-14 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   22 +++--
 sd/qa/unit/data/pptx/smartart-bullet-list.pptx  |binary
 sd/qa/unit/import-tests-smartart.cxx|   32 +++-
 3 files changed, 43 insertions(+), 11 deletions(-)

New commits:
commit c3e0d46062c6b37dfa74b6b388767c61912145f4
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jun 4 13:51:40 2019 +0200
Commit: Andras Timar 
CommitDate: Sat Jun 15 07:36:33 2019 +0200

SmartArt: bullet list improvements

by default start bullet list at second level
use stBulletLvl parameter to change this behaviour

Change-Id: I5084e7bf1902fdca83bea6d57a8c1f37dd2e65be
Reviewed-on: https://gerrit.libreoffice.org/73440
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/74086
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index d7d6fda1e1e0..a4b80548e3dd 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -1196,27 +1196,30 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 nBaseLevel = aParagraph->getProperties().getLevel();
 }
 
+// Start bullets at:
+// 1 - top level
+// 2 - with children (default)
+int nStartBulletsAtLevel = 2;
 ParamMap::const_iterator aBulletLvl = maMap.find(XML_stBulletLvl);
-int nStartBulletsAtLevel = 0;
 if (aBulletLvl != maMap.end())
-{
-nBaseLevel -= aBulletLvl->second;
 nStartBulletsAtLevel = aBulletLvl->second;
-}
+nStartBulletsAtLevel--;
 
+bool isBulletList = false;
 for (auto & aParagraph : pTextBody->getParagraphs())
 {
-sal_Int32 nLevel = aParagraph->getProperties().getLevel();
-aParagraph->getProperties().setLevel(nLevel - nBaseLevel);
-if (nStartBulletsAtLevel > 0 && nLevel >= nStartBulletsAtLevel)
+sal_Int32 nLevel = aParagraph->getProperties().getLevel() - 
nBaseLevel;
+aParagraph->getProperties().setLevel(nLevel);
+if (nLevel >= nStartBulletsAtLevel)
 {
 // It is not possible to change the bullet style for text.
-sal_Int32 nLeftMargin = 285750 * (nLevel - 
nStartBulletsAtLevel) / EMU_PER_HMM;
+sal_Int32 nLeftMargin = 285750 * (nLevel - 
nStartBulletsAtLevel + 1) / EMU_PER_HMM;
 aParagraph->getProperties().getParaLeftMargin() = 
nLeftMargin;
 aParagraph->getProperties().getFirstLineIndentation() = 
-285750 / EMU_PER_HMM;
 OUString aBulletChar = OUString::fromUtf8(u8"•");
 
aParagraph->getProperties().getBulletList().setBulletChar(aBulletChar);
 
aParagraph->getProperties().getBulletList().setSuffixNone();
+isBulletList = true;
 }
 }
 
@@ -1229,8 +1232,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 for (auto & aParagraph : pTextBody->getParagraphs())
 aParagraph->getProperties().setParaAdjust(aAlignment);
 }
-else if (std::all_of(pTextBody->getParagraphs().begin(), 
pTextBody->getParagraphs().end(),
-[](const std::shared_ptr& aParagraph) { return 
aParagraph->getProperties().getLevel() == 0; }))
+else if (!isBulletList)
 {
 // if not list use default alignment - centered
 for (auto & aParagraph : pTextBody->getParagraphs())
diff --git a/sd/qa/unit/data/pptx/smartart-bullet-list.pptx 
b/sd/qa/unit/data/pptx/smartart-bullet-list.pptx
new file mode 100644
index ..d95bdb769140
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-bullet-list.pptx 
differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 5a0cd7679ea1..930006fd3931 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -75,6 +75,7 @@ public:
 void testBackgroundDrawingmlFallback();
 void testFontSize();
 void testVerticalBlockList();
+void testBulletList();
 
 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -112,6 +113,7 @@ public:
 CPPUNIT_TEST(testBackgroundDrawingmlFallback);
 CPPUNIT_TEST(testFontSize);
 CPPUNIT_TEST(testVerticalBlockList);
+CPPUNIT_TEST(testBulletList);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -534,7 +536,7 @@ void SdImportTestSmartArt::testAccentProcess()
 
 uno::Reference 
xRules(xPara->getPropertyValue("NumberingRules"),
uno::UNO_QUERY);
-

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source sd/qa

2019-06-08 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/export/drawingml.cxx |   18 ++
 sd/qa/unit/data/pptx/tdf125551.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |   17 +
 3 files changed, 31 insertions(+), 4 deletions(-)

New commits:
commit 3644c9ab6f15a5d539681e84a1d29aa30af561d5
Author: Grzegorz Araminowicz 
AuthorDate: Fri Jun 7 15:48:25 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Sat Jun 8 11:23:02 2019 +0200

tdf#125551 PPTX export: correct position and size of diagrams

Save position and size of diagram background instead of whole group shape.
Some diagrams contain shapes that are outside these boundaries. That caused
diagram to grow and move.

Change-Id: I909c13a5dc268f77832234b3884b91292922823c
Reviewed-on: https://gerrit.libreoffice.org/73663
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/73681

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index cd91bb12cbe0..85834a14b1b0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4074,10 +4075,19 @@ void DrawingML::WriteDiagram(const 
css::uno::Reference& rX
 
 mpFS->endElementNS(XML_p, XML_nvGraphicFramePr);
 
-awt::Point aPos = rXShape->getPosition();
-awt::Size aSize = rXShape->getSize();
-WriteTransformation(tools::Rectangle(Point(aPos.X, aPos.Y), 
Size(aSize.Width, aSize.Height)),
-XML_p, false, false, 0, false);
+// store size and position of background shape instead of group shape
+// as some shapes may be outside
+css::uno::Reference xShapes(rXShape, 
uno::UNO_QUERY);
+if (xShapes.is() && xShapes->hasElements())
+{
+css::uno::Reference 
xShapeBg(xShapes->getByIndex(0),
+   uno::UNO_QUERY);
+awt::Point aPos = xShapeBg->getPosition();
+awt::Size aSize = xShapeBg->getSize();
+WriteTransformation(
+tools::Rectangle(Point(aPos.X, aPos.Y), Size(aSize.Width, 
aSize.Height)),
+XML_p, false, false, 0, false);
+}
 
 mpFS->startElementNS(XML_a, XML_graphic);
 }
diff --git a/sd/qa/unit/data/pptx/tdf125551.pptx 
b/sd/qa/unit/data/pptx/tdf125551.pptx
new file mode 100644
index ..fb7c106d20e2
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf125551.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index bc987a018af2..9c6cc27aa804 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -205,6 +205,7 @@ public:
 void testTdf125360();
 void testTdf125360_1();
 void testTdf125360_2();
+void testTdf125551();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -292,6 +293,7 @@ public:
 CPPUNIT_TEST(testTdf125360);
 CPPUNIT_TEST(testTdf125360_1);
 CPPUNIT_TEST(testTdf125360_2);
+CPPUNIT_TEST(testTdf125551);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -2318,6 +2320,21 @@ void SdOOXMLExportTest2::testTdf125360_2()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest2::testTdf125551()
+{
+::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf125551.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+
+uno::Reference xGroupShape(getShapeFromPage(0, 0, 
xDocShRef), uno::UNO_QUERY);
+uno::Reference xShapeBg(xGroupShape->getByIndex(0), 
uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(1024), 
xShapeBg->getPosition().X);
+CPPUNIT_ASSERT_EQUAL(static_cast(576), 
xShapeBg->getPosition().Y);
+CPPUNIT_ASSERT_EQUAL(static_cast(10815), 
xShapeBg->getSize().Width);
+CPPUNIT_ASSERT_EQUAL(static_cast(8587), 
xShapeBg->getSize().Height);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: oox/source sd/qa

2019-06-07 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/export/drawingml.cxx |   18 ++
 sd/qa/unit/data/pptx/tdf125551.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |   17 +
 3 files changed, 31 insertions(+), 4 deletions(-)

New commits:
commit 8aae7e4bc8dee27bc9dce3f1478777beeeb76e2f
Author: Grzegorz Araminowicz 
AuthorDate: Fri Jun 7 15:48:25 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Fri Jun 7 23:12:45 2019 +0200

tdf#125551 PPTX export: correct position and size of diagrams

Save position and size of diagram background instead of whole group shape.
Some diagrams contain shapes that are outside these boundaries. That caused
diagram to grow and move.

Change-Id: I909c13a5dc268f77832234b3884b91292922823c
Reviewed-on: https://gerrit.libreoffice.org/73663
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index cd91bb12cbe0..85834a14b1b0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4074,10 +4075,19 @@ void DrawingML::WriteDiagram(const 
css::uno::Reference& rX
 
 mpFS->endElementNS(XML_p, XML_nvGraphicFramePr);
 
-awt::Point aPos = rXShape->getPosition();
-awt::Size aSize = rXShape->getSize();
-WriteTransformation(tools::Rectangle(Point(aPos.X, aPos.Y), 
Size(aSize.Width, aSize.Height)),
-XML_p, false, false, 0, false);
+// store size and position of background shape instead of group shape
+// as some shapes may be outside
+css::uno::Reference xShapes(rXShape, 
uno::UNO_QUERY);
+if (xShapes.is() && xShapes->hasElements())
+{
+css::uno::Reference 
xShapeBg(xShapes->getByIndex(0),
+   uno::UNO_QUERY);
+awt::Point aPos = xShapeBg->getPosition();
+awt::Size aSize = xShapeBg->getSize();
+WriteTransformation(
+tools::Rectangle(Point(aPos.X, aPos.Y), Size(aSize.Width, 
aSize.Height)),
+XML_p, false, false, 0, false);
+}
 
 mpFS->startElementNS(XML_a, XML_graphic);
 }
diff --git a/sd/qa/unit/data/pptx/tdf125551.pptx 
b/sd/qa/unit/data/pptx/tdf125551.pptx
new file mode 100644
index ..fb7c106d20e2
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf125551.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index bc987a018af2..9c6cc27aa804 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -205,6 +205,7 @@ public:
 void testTdf125360();
 void testTdf125360_1();
 void testTdf125360_2();
+void testTdf125551();
 
 CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -292,6 +293,7 @@ public:
 CPPUNIT_TEST(testTdf125360);
 CPPUNIT_TEST(testTdf125360_1);
 CPPUNIT_TEST(testTdf125360_2);
+CPPUNIT_TEST(testTdf125551);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -2318,6 +2320,21 @@ void SdOOXMLExportTest2::testTdf125360_2()
 xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest2::testTdf125551()
+{
+::sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf125551.pptx"), 
PPTX);
+utl::TempFile tempFile;
+xDocShRef = saveAndReload(xDocShRef.get(), PPTX, );
+
+uno::Reference xGroupShape(getShapeFromPage(0, 0, 
xDocShRef), uno::UNO_QUERY);
+uno::Reference xShapeBg(xGroupShape->getByIndex(0), 
uno::UNO_QUERY);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(1024), 
xShapeBg->getPosition().X);
+CPPUNIT_ASSERT_EQUAL(static_cast(576), 
xShapeBg->getPosition().Y);
+CPPUNIT_ASSERT_EQUAL(static_cast(10815), 
xShapeBg->getSize().Width);
+CPPUNIT_ASSERT_EQUAL(static_cast(8587), 
xShapeBg->getSize().Height);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - oox/source sd/qa

2019-06-06 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   22 +++--
 sd/qa/unit/data/pptx/smartart-bullet-list.pptx  |binary
 sd/qa/unit/import-tests-smartart.cxx|   32 +++-
 3 files changed, 43 insertions(+), 11 deletions(-)

New commits:
commit d966c30d2b2a0b6d71b1c107a90b22825fed55c1
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jun 4 13:51:40 2019 +0200
Commit: Miklos Vajna 
CommitDate: Thu Jun 6 10:44:03 2019 +0200

SmartArt: bullet list improvements

by default start bullet list at second level
use stBulletLvl parameter to change this behaviour

Change-Id: I5084e7bf1902fdca83bea6d57a8c1f37dd2e65be
Reviewed-on: https://gerrit.libreoffice.org/73440
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/73568

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 4d0c18c27561..2c612233251d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -1227,27 +1227,30 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 nBaseLevel = aParagraph->getProperties().getLevel();
 }
 
+// Start bullets at:
+// 1 - top level
+// 2 - with children (default)
+int nStartBulletsAtLevel = 2;
 ParamMap::const_iterator aBulletLvl = maMap.find(XML_stBulletLvl);
-int nStartBulletsAtLevel = 0;
 if (aBulletLvl != maMap.end())
-{
-nBaseLevel -= aBulletLvl->second;
 nStartBulletsAtLevel = aBulletLvl->second;
-}
+nStartBulletsAtLevel--;
 
+bool isBulletList = false;
 for (auto & aParagraph : pTextBody->getParagraphs())
 {
-sal_Int32 nLevel = aParagraph->getProperties().getLevel();
-aParagraph->getProperties().setLevel(nLevel - nBaseLevel);
-if (nStartBulletsAtLevel > 0 && nLevel >= nStartBulletsAtLevel)
+sal_Int32 nLevel = aParagraph->getProperties().getLevel() - 
nBaseLevel;
+aParagraph->getProperties().setLevel(nLevel);
+if (nLevel >= nStartBulletsAtLevel)
 {
 // It is not possible to change the bullet style for text.
-sal_Int32 nLeftMargin = 285750 * (nLevel - 
nStartBulletsAtLevel) / EMU_PER_HMM;
+sal_Int32 nLeftMargin = 285750 * (nLevel - 
nStartBulletsAtLevel + 1) / EMU_PER_HMM;
 aParagraph->getProperties().getParaLeftMargin() = 
nLeftMargin;
 aParagraph->getProperties().getFirstLineIndentation() = 
-285750 / EMU_PER_HMM;
 OUString aBulletChar = OUString::fromUtf8(u8"•");
 
aParagraph->getProperties().getBulletList().setBulletChar(aBulletChar);
 
aParagraph->getProperties().getBulletList().setSuffixNone();
+isBulletList = true;
 }
 }
 
@@ -1260,8 +1263,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 for (auto & aParagraph : pTextBody->getParagraphs())
 aParagraph->getProperties().setParaAdjust(aAlignment);
 }
-else if (std::all_of(pTextBody->getParagraphs().begin(), 
pTextBody->getParagraphs().end(),
-[](const std::shared_ptr& aParagraph) { return 
aParagraph->getProperties().getLevel() == 0; }))
+else if (!isBulletList)
 {
 // if not list use default alignment - centered
 for (auto & aParagraph : pTextBody->getParagraphs())
diff --git a/sd/qa/unit/data/pptx/smartart-bullet-list.pptx 
b/sd/qa/unit/data/pptx/smartart-bullet-list.pptx
new file mode 100644
index ..d95bdb769140
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-bullet-list.pptx 
differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 722cb142fbfc..775411c57bba 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -78,6 +78,7 @@ public:
 void testCenterCycle();
 void testFontSize();
 void testVerticalBlockList();
+void testBulletList();
 
 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -117,6 +118,7 @@ public:
 CPPUNIT_TEST(testCenterCycle);
 CPPUNIT_TEST(testFontSize);
 CPPUNIT_TEST(testVerticalBlockList);
+CPPUNIT_TEST(testBulletList);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -674,7 +676,7 @@ void SdImportTestSmartArt::testAccentProcess()
 
 uno::Reference 
xRules(xPara->getPropertyValue("NumberingRules"),
uno::UNO_QUERY);
-comphelper::SequenceAsHashMap aRule(xRules->getByIndex(1));
+

[Libreoffice-commits] core.git: oox/source sd/qa

2019-06-04 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   22 +++--
 sd/qa/unit/data/pptx/smartart-bullet-list.pptx  |binary
 sd/qa/unit/import-tests-smartart.cxx|   32 +++-
 3 files changed, 43 insertions(+), 11 deletions(-)

New commits:
commit 1e1535d46f9d89a2584409d88f35b57ef920eefa
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jun 4 13:51:40 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue Jun 4 17:23:32 2019 +0200

SmartArt: bullet list improvements

by default start bullet list at second level
use stBulletLvl parameter to change this behaviour

Change-Id: I5084e7bf1902fdca83bea6d57a8c1f37dd2e65be
Reviewed-on: https://gerrit.libreoffice.org/73440
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 4d0c18c27561..2c612233251d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -1227,27 +1227,30 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 nBaseLevel = aParagraph->getProperties().getLevel();
 }
 
+// Start bullets at:
+// 1 - top level
+// 2 - with children (default)
+int nStartBulletsAtLevel = 2;
 ParamMap::const_iterator aBulletLvl = maMap.find(XML_stBulletLvl);
-int nStartBulletsAtLevel = 0;
 if (aBulletLvl != maMap.end())
-{
-nBaseLevel -= aBulletLvl->second;
 nStartBulletsAtLevel = aBulletLvl->second;
-}
+nStartBulletsAtLevel--;
 
+bool isBulletList = false;
 for (auto & aParagraph : pTextBody->getParagraphs())
 {
-sal_Int32 nLevel = aParagraph->getProperties().getLevel();
-aParagraph->getProperties().setLevel(nLevel - nBaseLevel);
-if (nStartBulletsAtLevel > 0 && nLevel >= nStartBulletsAtLevel)
+sal_Int32 nLevel = aParagraph->getProperties().getLevel() - 
nBaseLevel;
+aParagraph->getProperties().setLevel(nLevel);
+if (nLevel >= nStartBulletsAtLevel)
 {
 // It is not possible to change the bullet style for text.
-sal_Int32 nLeftMargin = 285750 * (nLevel - 
nStartBulletsAtLevel) / EMU_PER_HMM;
+sal_Int32 nLeftMargin = 285750 * (nLevel - 
nStartBulletsAtLevel + 1) / EMU_PER_HMM;
 aParagraph->getProperties().getParaLeftMargin() = 
nLeftMargin;
 aParagraph->getProperties().getFirstLineIndentation() = 
-285750 / EMU_PER_HMM;
 OUString aBulletChar = OUString::fromUtf8(u8"•");
 
aParagraph->getProperties().getBulletList().setBulletChar(aBulletChar);
 
aParagraph->getProperties().getBulletList().setSuffixNone();
+isBulletList = true;
 }
 }
 
@@ -1260,8 +1263,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 for (auto & aParagraph : pTextBody->getParagraphs())
 aParagraph->getProperties().setParaAdjust(aAlignment);
 }
-else if (std::all_of(pTextBody->getParagraphs().begin(), 
pTextBody->getParagraphs().end(),
-[](const std::shared_ptr& aParagraph) { return 
aParagraph->getProperties().getLevel() == 0; }))
+else if (!isBulletList)
 {
 // if not list use default alignment - centered
 for (auto & aParagraph : pTextBody->getParagraphs())
diff --git a/sd/qa/unit/data/pptx/smartart-bullet-list.pptx 
b/sd/qa/unit/data/pptx/smartart-bullet-list.pptx
new file mode 100644
index ..d95bdb769140
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-bullet-list.pptx 
differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 722cb142fbfc..775411c57bba 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -78,6 +78,7 @@ public:
 void testCenterCycle();
 void testFontSize();
 void testVerticalBlockList();
+void testBulletList();
 
 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -117,6 +118,7 @@ public:
 CPPUNIT_TEST(testCenterCycle);
 CPPUNIT_TEST(testFontSize);
 CPPUNIT_TEST(testVerticalBlockList);
+CPPUNIT_TEST(testBulletList);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -674,7 +676,7 @@ void SdImportTestSmartArt::testAccentProcess()
 
 uno::Reference 
xRules(xPara->getPropertyValue("NumberingRules"),
uno::UNO_QUERY);
-comphelper::SequenceAsHashMap aRule(xRules->getByIndex(1));
+comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - oox/source sd/qa

2019-06-03 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   78 
 sd/qa/unit/import-tests-smartart.cxx|   10 +-
 2 files changed, 54 insertions(+), 34 deletions(-)

New commits:
commit 55e531de9c1fecc73b8a42e18dda34aa4de02f8b
Author: Grzegorz Araminowicz 
AuthorDate: Thu May 30 13:29:08 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 3 14:15:55 2019 +0200

SmartArt: more constraints used in linear algorithm

* both width and height of children and space is taken from constraints
* better handling of space between children (not lost in some cases)
* children centered in the other axis

Change-Id: I25b8360790de0292b2b5c313dfa55e58dc042193
Reviewed-on: https://gerrit.libreoffice.org/73201
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/73259

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index e27c573b3d28..d7d6fda1e1e0 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -788,7 +788,8 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 const sal_Int32 nIncY = nDir==XML_fromT ? 1 : (nDir==XML_fromB ? 
-1 : 0);
 
 sal_Int32 nCount = rShape->getChildren().size();
-double fSpace = 0.3;
+
+awt::Size aSpaceSize;
 
 // Find out which constraint is relevant for which (internal) name.
 LayoutPropertyMap aProperties;
@@ -800,17 +801,25 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 LayoutProperty& rProperty = aProperties[rConstraint.msForName];
 if (rConstraint.mnType == XML_w)
 rProperty[XML_w] = rShape->getSize().Width * 
rConstraint.mfFactor;
+if (rConstraint.mnType == XML_h)
+rProperty[XML_h] = rShape->getSize().Height * 
rConstraint.mfFactor;
 
 // TODO: get values from differently named constraints as well
-if (rConstraint.msForName == "sibTrans" && rConstraint.mnType 
== XML_w)
-fSpace = rConstraint.mfFactor;
+if (rConstraint.msForName == "sp" || rConstraint.msForName == 
"space" || rConstraint.msForName == "sibTrans")
+{
+if (rConstraint.mnType == XML_w)
+aSpaceSize.Width = rShape->getSize().Width * 
rConstraint.mfFactor;
+if (rConstraint.mnType == XML_h)
+aSpaceSize.Height = rShape->getSize().Height * 
rConstraint.mfFactor;
+}
 }
 
+// first approximation of children size
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromL || nDir == XML_fromR)
-aChildSize.Width /= (nCount + (nCount-1)*fSpace);
+aChildSize.Width /= nCount;
 else if (nDir == XML_fromT || nDir == XML_fromB)
-aChildSize.Height /= (nCount + (nCount-1)*fSpace);
+aChildSize.Height /= nCount;
 
 awt::Point aCurrPos(0, 0);
 if (nIncX == -1)
@@ -820,51 +829,58 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 
 // See if children requested more than 100% space in total: scale
 // down in that case.
-sal_Int32 nTotalWidth = 0;
-bool bSpaceFromConstraints = false;
+awt::Size aTotalSize;
 for (auto & aCurrShape : rShape->getChildren())
 {
-oox::OptValue oWidth
-= findProperty(aProperties, aCurrShape->getInternalName(), 
XML_w);
-
+oox::OptValue oWidth = findProperty(aProperties, 
aCurrShape->getInternalName(), XML_w);
+oox::OptValue oHeight = findProperty(aProperties, 
aCurrShape->getInternalName(), XML_h);
 awt::Size aSize = aChildSize;
 if (oWidth.has())
-{
 aSize.Width = oWidth.get();
-bSpaceFromConstraints = true;
-}
-if (nDir == XML_fromL || nDir == XML_fromR)
-nTotalWidth += aSize.Width;
+if (oHeight.has())
+aSize.Height = oHeight.get();
+aTotalSize.Width += aSize.Width;
+aTotalSize.Height += aSize.Height;
 }
 
-double fWidthScale = 1.0;
-if (nTotalWidth > rShape->getSize().Width && nTotalWidth)
-{
-fWidthScale = rShape->getSize().Width;
-fWidthScale /= nTotalWidth;
-}
+aTotalSize.Width += (nCount-1) * aSpaceSize.Width;
+aTotalSize.Height += (nCount-1) * aSpaceSize.Height;
 
-// Don't add automatic space if we take space from constraints.
-if (bSpaceFromConstraints)
-  

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - oox/source

2019-06-03 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   22 ++--
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |6 -
 2 files changed, 8 insertions(+), 20 deletions(-)

New commits:
commit 83d101158ef3726d005ae7bd47437ab22ad2a036
Author: Grzegorz Araminowicz 
AuthorDate: Tue May 28 17:37:19 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 3 14:15:38 2019 +0200

SmartArt: keep parent constraints instead of merging every time

currently for every node we were additionaly loading constraints from
parent node, merging them and then deleting
it makes more sense just to keep already loaded constraints from parent node

Change-Id: I3fcd669547f24eeeac0b77876950ff7436bd5cb3
Reviewed-on: https://gerrit.libreoffice.org/73116
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/73258

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 808960093f29..e27c573b3d28 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -499,24 +499,8 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
 }
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
-   const std::vector& rOwnConstraints )
+   const std::vector& rConstraints )
 {
-// Algorithm result may depend on the parent constraints as well.
-std::vector aMergedConstraints;
-const LayoutNode* pParent = getLayoutNode().getParentLayoutNode();
-if (pParent)
-{
-for (const auto& pChild : pParent->getChildren())
-{
-auto pConstraintAtom = dynamic_cast(pChild.get());
-if (pConstraintAtom)
-pConstraintAtom->parseConstraint(aMergedConstraints, 
/*bRequireForName=*/true);
-}
-}
-aMergedConstraints.insert(aMergedConstraints.end(), 
rOwnConstraints.begin(),
-  rOwnConstraints.end());
-const std::vector& rConstraints = aMergedConstraints;
-
 switch(mnType)
 {
 case XML_composite:
@@ -629,7 +613,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 {
 // There is no shape type "conn", replace it by an arrow based
 // on the direction of the parent linear layout.
-sal_Int32 nType = getConnectorType(pParent);
+sal_Int32 nType = 
getConnectorType(getLayoutNode().getParentLayoutNode());
 
 rShape->setSubType(nType);
 rShape->getCustomShapeProperties()->setShapePresetType(nType);
@@ -759,7 +743,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 sal_Int32 nXOffset = 0;
 double fWidthScale = 1.0;
 if (mnType == XML_hierChild)
-calculateHierChildOffsetScale(rShape, pParent, nXOffset, 
fWidthScale);
+calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale);
 
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromT)
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index 602130b6b3e3..4e1a3689e3e4 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -291,14 +291,18 @@ void ShapeLayoutingVisitor::visit(LayoutNode& rAtom)
 if (meLookFor != LAYOUT_NODE)
 return;
 
+size_t nParentConstraintsNumber = maConstraints.size();
+
 // process alg atoms first, nested layout nodes afterwards
 meLookFor = CONSTRAINT;
 defaultVisit(rAtom);
 meLookFor = ALGORITHM;
 defaultVisit(rAtom);
-maConstraints.clear();
 meLookFor = LAYOUT_NODE;
 defaultVisit(rAtom);
+
+// delete added constraints, keep parent constraints
+maConstraints.erase(maConstraints.begin() + nParentConstraintsNumber, 
maConstraints.end());
 }
 
 void ShapeLayoutingVisitor::visit(ShapeAtom& /*rAtom*/)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - oox/source sd/qa

2019-06-03 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagram.cxx   |   42 +
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   32 
 sd/qa/unit/data/pptx/smartart-vertical-block-list.pptx |binary
 sd/qa/unit/import-tests-smartart.cxx   |   41 
 4 files changed, 83 insertions(+), 32 deletions(-)

New commits:
commit 8fce4133bd427351ac269c50e02e305d9eb34321
Author: Grzegorz Araminowicz 
AuthorDate: Tue May 28 13:36:59 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 3 09:48:49 2019 +0200

SmartArt: sort shapes by Z order after layout algorithms

so that they are laid out in correct order

Change-Id: I82baa61311197880654d09f356decc666e6fa4c7
Reviewed-on: https://gerrit.libreoffice.org/73094
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/73255

diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 8efefe139dbf..be49c85d40aa 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -134,6 +134,46 @@ static sal_Int32 calcDepth( const OUString& rNodeName,
 return 0;
 }
 
+static void sortChildrenByZOrder(const ShapePtr& pShape)
+{
+std::vector& rChildren = pShape->getChildren();
+
+// Offset the children from their default z-order stacking, if necessary.
+for (size_t i = 0; i < rChildren.size(); ++i)
+rChildren[i]->setZOrder(i);
+
+for (size_t i = 0; i < rChildren.size(); ++i)
+{
+const ShapePtr& pChild = rChildren[i];
+sal_Int32 nZOrderOff = pChild->getZOrderOff();
+if (nZOrderOff <= 0)
+continue;
+
+// Increase my ZOrder by nZOrderOff.
+pChild->setZOrder(pChild->getZOrder() + nZOrderOff);
+pChild->setZOrderOff(0);
+
+for (sal_Int32 j = 0; j < nZOrderOff; ++j)
+{
+size_t nIndex = i + j + 1;
+if (nIndex >= rChildren.size())
+break;
+
+// Decrease the ZOrder of the next nZOrderOff elements by one.
+const ShapePtr& pNext = rChildren[nIndex];
+pNext->setZOrder(pNext->getZOrder() - 1);
+}
+}
+
+// Now that the ZOrders are adjusted, sort the children.
+std::sort(rChildren.begin(), rChildren.end(),
+  [](const ShapePtr& a, const ShapePtr& b) { return a->getZOrder() 
< b->getZOrder(); });
+
+// Apply also for children.
+for (auto& rChild : rChildren)
+sortChildrenByZOrder(rChild);
+}
+
 void Diagram::build(  )
 {
 // build name-object maps
@@ -317,6 +357,8 @@ void Diagram::addTo( const ShapePtr & pParentShape )
 // layout shapes - now all shapes are created
 ShapeLayoutingVisitor aLayoutingVisitor;
 mpLayout->getNode()->accept(aLayoutingVisitor);
+
+sortChildrenByZOrder(pParentShape);
 }
 
 ShapePtr pBackground(new Shape("com.sun.star.drawing.CustomShape"));
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index a45317f9ffe4..602130b6b3e3 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -187,38 +187,6 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
 std::remove_if(pCurrParent->getChildren().begin(), 
pCurrParent->getChildren().end(),
 [] (const ShapePtr & aChild) { return aChild->getServiceName() == 
"com.sun.star.drawing.GroupShape" && aChild->getChildren().empty(); }),
 pCurrParent->getChildren().end());
-
-// Offset the children from their default z-order stacking, if necessary.
-std::vector& rChildren = pCurrParent->getChildren();
-for (size_t i = 0; i < rChildren.size(); ++i)
-rChildren[i]->setZOrder(i);
-
-for (size_t i = 0; i < rChildren.size(); ++i)
-{
-const ShapePtr& pChild = rChildren[i];
-sal_Int32 nZOrderOff = pChild->getZOrderOff();
-if (nZOrderOff <= 0)
-continue;
-
-// Increase my ZOrder by nZOrderOff.
-pChild->setZOrder(pChild->getZOrder() + nZOrderOff);
-pChild->setZOrderOff(0);
-
-for (sal_Int32 j = 0; j < nZOrderOff; ++j)
-{
-size_t nIndex = i + j + 1;
-if (nIndex >= rChildren.size())
-break;
-
-// Decrease the ZOrder of the next nZOrderOff elements by one.
-const ShapePtr& pNext = rChildren[nIndex];
-pNext->setZOrder(pNext->getZOrder() - 1);
-}
-}
-
-// Now that the ZOrders are adjusted, sort the children.
-std::sort(rChildren.begin(), rChildren.end(),
-  [](const ShapePtr& a, const ShapePtr& b) { return a->getZOrder() 
< b->getZOrder(); });
 }
 
 void ShapeCreationVisitor::visit(ShapeAtom& /*rAtom*/)
diff --git a/sd/qa/unit/data/pptx/smartart-vertical-block-list.pptx 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - oox/source sd/qa

2019-06-03 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   16 -
 sd/qa/unit/data/pptx/smartart-font-size.pptx|binary
 sd/qa/unit/import-tests-smartart.cxx|   34 
 3 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit 9b4cb15e41618fb1943c6c2cb150582dccc5c96c
Author: Grzegorz Araminowicz 
AuthorDate: Mon May 27 20:00:42 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 3 09:48:01 2019 +0200

SmartArt: adjust text size to fit shapes

up to maximal size of primFontSz constraint.
Do not override text size changed by user.

Change-Id: If7ea6bbb96cb839831d877edc274a1b0eefdaf21
Reviewed-on: https://gerrit.libreoffice.org/73050
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/73251

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index bc30ec38e219..808960093f29 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -1105,6 +1106,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 // adjust text alignment
 
 // Parse constraints, only self margins as a start.
+double fFontSize = 0;
 for (const auto& rConstr : rConstraints)
 {
 if (rConstr.mnRefType == XML_w)
@@ -1124,9 +1126,10 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 
 rShape->getShapeProperties().setProperty(nProperty, 
nValue);
 }
+if (rConstr.mnType == XML_primFontSz)
+fFontSize = rConstr.mfValue;
 }
 
-// TODO: adjust text size to fit shape
 TextBodyPtr pTextBody = rShape->getTextBody();
 if (!pTextBody ||
 pTextBody->getParagraphs().empty() ||
@@ -1135,6 +1138,17 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 break;
 }
 
+// adjust text size to fit shape
+if (fFontSize != 0)
+{
+for (auto& aParagraph : pTextBody->getParagraphs())
+for (auto& aRun : aParagraph->getRuns())
+if (!aRun->getTextCharacterProperties().moHeight.has())
+aRun->getTextCharacterProperties().moHeight = 
fFontSize * 100;
+}
+
pTextBody->getTextProperties().maPropertyMap.setProperty(PROP_TextFitToSize, 
drawing::TextFitToSizeType_AUTOFIT);
+
+// ECMA-376-1:2016 21.4.7.5 ST_AutoTextRotation (Auto Text 
Rotation)
 const sal_Int32 nautoTxRot = maMap.count(XML_autoTxRot) ? 
maMap.find(XML_autoTxRot)->second : XML_upr;
 
 switch(nautoTxRot)
diff --git a/sd/qa/unit/data/pptx/smartart-font-size.pptx 
b/sd/qa/unit/data/pptx/smartart-font-size.pptx
new file mode 100644
index ..253cd4c73b65
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-font-size.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 682c775b80fe..624205c5380a 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -10,6 +10,8 @@
 #include "sdmodeltestbase.hxx"
 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -71,6 +73,7 @@ public:
 void testInteropGrabBag();
 void testBackground();
 void testBackgroundDrawingmlFallback();
+void testFontSize();
 
 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -106,6 +109,7 @@ public:
 CPPUNIT_TEST(testInteropGrabBag);
 CPPUNIT_TEST(testBackground);
 CPPUNIT_TEST(testBackgroundDrawingmlFallback);
+CPPUNIT_TEST(testFontSize);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -997,6 +1001,36 @@ void 
SdImportTestSmartArt::testBackgroundDrawingmlFallback()
 xDocShRef->DoClose();
 }
 
+void SdImportTestSmartArt::testFontSize()
+{
+sd::DrawDocShellRef xDocShRef = loadURL(
+
m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-font-size.pptx"), 
PPTX);
+
+uno::Reference xGroup1(getShapeFromPage(0, 0, 
xDocShRef), uno::UNO_QUERY);
+uno::Reference xShape1(xGroup1->getByIndex(1), 
uno::UNO_QUERY);
+uno::Reference xParagraph1(getParagraphFromShape(0, 
xShape1));
+uno::Reference xRun1(getRunFromParagraph(0, 
xParagraph1));
+uno::Reference xPropSet1(xRun1, uno::UNO_QUERY);
+double fFontSize1 = 
xPropSet1->getPropertyValue("CharHeight").get();
+CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, fFontSize1, 0.01);
+
+uno::Reference xGroup2(getShapeFromPage(1, 0, 
xDocShRef), uno::UNO_QUERY);
+uno::Reference xShape2(xGroup2->getByIndex(1), 
uno::UNO_QUERY);
+uno::Reference xParagraph2(getParagraphFromShape(0, 
xShape2));
+

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - include/oox oox/source sd/qa sw/qa

2019-05-31 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/shape.hxx  |2 
 oox/source/drawingml/diagram/diagram.cxx |   11 
 oox/source/drawingml/shape.cxx   |9 
 oox/source/shape/ShapeContextHandler.cxx |8 
 sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx |binary
 sd/qa/unit/data/pptx/smartart-background.pptx|binary
 sd/qa/unit/data/xml/n819614_0.xml|   69 ++
 sd/qa/unit/export-tests-ooxml1.cxx   |4 
 sd/qa/unit/export-tests-ooxml2.cxx   |9 
 sd/qa/unit/import-tests-smartart.cxx |  238 
++
 sd/qa/unit/import-tests.cxx  |7 
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx   |8 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |4 
 13 files changed, 270 insertions(+), 99 deletions(-)

New commits:
commit 3235ae697e1ae90e218f5c3bee280659d8a74a60
Author: Grzegorz Araminowicz 
AuthorDate: Wed May 8 21:49:34 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 31 16:46:22 2019 +0200

SmartArt: support diagram background

Solved by adding additional shape filling whole diagram.
MS PowerPoint does the same when converting SmartArt to shapes.

Background shape is also copied when loading from drawingML fallback,
appearently there is no background information.

Corrected SmartArt import tests, so that they are aware of extra shape.

Change-Id: I6154f8e1b34e5867ab582d6fc54459c7c93edbac
Reviewed-on: https://gerrit.libreoffice.org/72012
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/73250

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 9e879b47bc9c..73fb85ad8dc9 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -150,6 +150,7 @@ public:
 const OUString& getId() { return msId; }
 voidsetHidden( bool bHidden ) { mbHidden = 
bHidden; }
 voidsetHiddenMasterShape( bool 
bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; }
+voidsetLocked( bool bLocked ) { mbLocked = 
bLocked; }
 voidsetSubType( sal_Int32 nSubType ) { 
mnSubType = nSubType; }
 sal_Int32   getSubType() const { return mnSubType; }
 voidsetSubTypeIndex( sal_Int32 nSubTypeIndex ) 
{ moSubTypeIndex = nSubTypeIndex; }
@@ -336,6 +337,7 @@ private:
 boolmbHiddenMasterShape; // master shapes can 
be hidden in layout slides
  // we need separate 
flag because we don't want
  // to propagate it 
when applying reference shape
+boolmbLocked;
 bool mbLockedCanvas; ///< Is this shape part of a locked canvas?
 bool mbWps; ///< Is this a wps shape?
 bool mbTextBox; ///< This shape has a textbox.
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index d1de1c72f94d..8efefe139dbf 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -317,6 +318,16 @@ void Diagram::addTo( const ShapePtr & pParentShape )
 ShapeLayoutingVisitor aLayoutingVisitor;
 mpLayout->getNode()->accept(aLayoutingVisitor);
 }
+
+ShapePtr pBackground(new Shape("com.sun.star.drawing.CustomShape"));
+pBackground->setSubType(XML_rect);
+pBackground->getCustomShapeProperties()->setShapePresetType(XML_rect);
+pBackground->setSize(pParentShape->getSize());
+pBackground->getFillProperties() = *mpData->getFillProperties();
+pBackground->setLocked(true);
+auto& aChildren = pParentShape->getChildren();
+aChildren.insert(aChildren.begin(), pBackground);
+
 pParentShape->setDiagramDoms( getDomsAsPropertyValues() );
 }
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 4848f4086e02..23e9537f4b32 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -127,6 +127,7 @@ Shape::Shape( const sal_Char* pServiceName, bool 
bDefaultHeight )
 , mbFlipV( false )
 , mbHidden( false )
 , mbHiddenMasterShape( false )
+, mbLocked( false )
 , mbLockedCanvas( false )
 , mbWps( false )
 , mbTextBox( false )
@@ -170,6 +171,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
 , mbFlipV( pSourceShape->mbFlipV )
 , mbHidden( pSourceShape->mbHidden )
 , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
+, mbLocked( 

[Libreoffice-commits] core.git: oox/source sd/qa

2019-05-31 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   78 
 sd/qa/unit/import-tests-smartart.cxx|   10 +-
 2 files changed, 54 insertions(+), 34 deletions(-)

New commits:
commit 1b9344b95a685743d7b0e9bd831fea06d12df201
Author: Grzegorz Araminowicz 
AuthorDate: Thu May 30 13:29:08 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 31 11:59:57 2019 +0200

SmartArt: more constraints used in linear algorithm

* both width and height of children and space is taken from constraints
* better handling of space between children (not lost in some cases)
* children centered in the other axis

Change-Id: I25b8360790de0292b2b5c313dfa55e58dc042193
Reviewed-on: https://gerrit.libreoffice.org/73201
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 1b1aadf77db7..4d0c18c27561 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -797,7 +797,6 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 const sal_Int32 nIncY = nDir==XML_fromT ? 1 : (nDir==XML_fromB ? 
-1 : 0);
 
 sal_Int32 nCount = rShape->getChildren().size();
-double fSpace = 0.3;
 sal_Int32 nConnectorAngle = 0;
 switch (nDir)
 {
@@ -807,6 +806,8 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 case XML_fromB: nConnectorAngle = 90; break;
 }
 
+awt::Size aSpaceSize;
+
 // Find out which constraint is relevant for which (internal) name.
 LayoutPropertyMap aProperties;
 for (const auto& rConstraint : rConstraints)
@@ -817,17 +818,25 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 LayoutProperty& rProperty = aProperties[rConstraint.msForName];
 if (rConstraint.mnType == XML_w)
 rProperty[XML_w] = rShape->getSize().Width * 
rConstraint.mfFactor;
+if (rConstraint.mnType == XML_h)
+rProperty[XML_h] = rShape->getSize().Height * 
rConstraint.mfFactor;
 
 // TODO: get values from differently named constraints as well
-if (rConstraint.msForName == "sibTrans" && rConstraint.mnType 
== XML_w)
-fSpace = rConstraint.mfFactor;
+if (rConstraint.msForName == "sp" || rConstraint.msForName == 
"space" || rConstraint.msForName == "sibTrans")
+{
+if (rConstraint.mnType == XML_w)
+aSpaceSize.Width = rShape->getSize().Width * 
rConstraint.mfFactor;
+if (rConstraint.mnType == XML_h)
+aSpaceSize.Height = rShape->getSize().Height * 
rConstraint.mfFactor;
+}
 }
 
+// first approximation of children size
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromL || nDir == XML_fromR)
-aChildSize.Width /= (nCount + (nCount-1)*fSpace);
+aChildSize.Width /= nCount;
 else if (nDir == XML_fromT || nDir == XML_fromB)
-aChildSize.Height /= (nCount + (nCount-1)*fSpace);
+aChildSize.Height /= nCount;
 
 awt::Point aCurrPos(0, 0);
 if (nIncX == -1)
@@ -837,51 +846,58 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 
 // See if children requested more than 100% space in total: scale
 // down in that case.
-sal_Int32 nTotalWidth = 0;
-bool bSpaceFromConstraints = false;
+awt::Size aTotalSize;
 for (auto & aCurrShape : rShape->getChildren())
 {
-oox::OptValue oWidth
-= findProperty(aProperties, aCurrShape->getInternalName(), 
XML_w);
-
+oox::OptValue oWidth = findProperty(aProperties, 
aCurrShape->getInternalName(), XML_w);
+oox::OptValue oHeight = findProperty(aProperties, 
aCurrShape->getInternalName(), XML_h);
 awt::Size aSize = aChildSize;
 if (oWidth.has())
-{
 aSize.Width = oWidth.get();
-bSpaceFromConstraints = true;
-}
-if (nDir == XML_fromL || nDir == XML_fromR)
-nTotalWidth += aSize.Width;
+if (oHeight.has())
+aSize.Height = oHeight.get();
+aTotalSize.Width += aSize.Width;
+aTotalSize.Height += aSize.Height;
 }
 
-double fWidthScale = 1.0;
-if (nTotalWidth > rShape->getSize().Width && nTotalWidth)
-{
-fWidthScale = rShape->getSize().Width;
-fWidthScale /= nTotalWidth;
-}
+

[Libreoffice-commits] core.git: oox/source

2019-05-30 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   20 ++--
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |6 +-
 2 files changed, 7 insertions(+), 19 deletions(-)

New commits:
commit 0873151dd02d83122d5f6f471890410ace5e6ddb
Author: Grzegorz Araminowicz 
AuthorDate: Tue May 28 17:37:19 2019 +0200
Commit: Miklos Vajna 
CommitDate: Thu May 30 14:58:55 2019 +0200

SmartArt: keep parent constraints instead of merging every time

currently for every node we were additionaly loading constraints from
parent node, merging them and then deleting
it makes more sense just to keep already loaded constraints from parent node

Change-Id: I3fcd669547f24eeeac0b77876950ff7436bd5cb3
Reviewed-on: https://gerrit.libreoffice.org/73116
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 675806767191..1b1aadf77db7 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -469,24 +469,8 @@ sal_Int32 AlgAtom::getConnectorType()
 }
 
 void AlgAtom::layoutShape( const ShapePtr& rShape,
-   const std::vector& rOwnConstraints )
+   const std::vector& rConstraints )
 {
-// Algorithm result may depend on the parent constraints as well.
-std::vector aMergedConstraints;
-const LayoutNode* pParent = getLayoutNode().getParentLayoutNode();
-if (pParent)
-{
-for (const auto& pChild : pParent->getChildren())
-{
-auto pConstraintAtom = dynamic_cast(pChild.get());
-if (pConstraintAtom)
-pConstraintAtom->parseConstraint(aMergedConstraints, 
/*bRequireForName=*/true);
-}
-}
-aMergedConstraints.insert(aMergedConstraints.end(), 
rOwnConstraints.begin(),
-  rOwnConstraints.end());
-const std::vector& rConstraints = aMergedConstraints;
-
 switch(mnType)
 {
 case XML_composite:
@@ -768,7 +752,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 sal_Int32 nXOffset = 0;
 double fWidthScale = 1.0;
 if (mnType == XML_hierChild)
-calculateHierChildOffsetScale(rShape, pParent, nXOffset, 
fWidthScale);
+calculateHierChildOffsetScale(rShape, 
getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale);
 
 awt::Size aChildSize = rShape->getSize();
 if (nDir == XML_fromT)
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index d7d89d2968d0..c6532243ec6c 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -291,14 +291,18 @@ void ShapeLayoutingVisitor::visit(LayoutNode& rAtom)
 if (meLookFor != LAYOUT_NODE)
 return;
 
+size_t nParentConstraintsNumber = maConstraints.size();
+
 // process alg atoms first, nested layout nodes afterwards
 meLookFor = CONSTRAINT;
 defaultVisit(rAtom);
 meLookFor = ALGORITHM;
 defaultVisit(rAtom);
-maConstraints.clear();
 meLookFor = LAYOUT_NODE;
 defaultVisit(rAtom);
+
+// delete added constraints, keep parent constraints
+maConstraints.erase(maConstraints.begin() + nParentConstraintsNumber, 
maConstraints.end());
 }
 
 void ShapeLayoutingVisitor::visit(ShapeAtom& /*rAtom*/)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: oox/source sd/qa

2019-05-29 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagram.cxx   |   42 +
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   32 
 sd/qa/unit/data/pptx/smartart-vertical-block-list.pptx |binary
 sd/qa/unit/import-tests-smartart.cxx   |   41 
 4 files changed, 83 insertions(+), 32 deletions(-)

New commits:
commit 2828e3c8ec3b336bc02e7e3b6d9b5c41fc5be306
Author: Grzegorz Araminowicz 
AuthorDate: Tue May 28 13:36:59 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed May 29 08:55:00 2019 +0200

SmartArt: sort shapes by Z order after layout algorithms

so that they are laid out in correct order

Change-Id: I82baa61311197880654d09f356decc666e6fa4c7
Reviewed-on: https://gerrit.libreoffice.org/73094
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index c3c28a84db23..7460c52f1fed 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -138,6 +138,46 @@ static sal_Int32 calcDepth( const OUString& rNodeName,
 return 0;
 }
 
+static void sortChildrenByZOrder(const ShapePtr& pShape)
+{
+std::vector& rChildren = pShape->getChildren();
+
+// Offset the children from their default z-order stacking, if necessary.
+for (size_t i = 0; i < rChildren.size(); ++i)
+rChildren[i]->setZOrder(i);
+
+for (size_t i = 0; i < rChildren.size(); ++i)
+{
+const ShapePtr& pChild = rChildren[i];
+sal_Int32 nZOrderOff = pChild->getZOrderOff();
+if (nZOrderOff <= 0)
+continue;
+
+// Increase my ZOrder by nZOrderOff.
+pChild->setZOrder(pChild->getZOrder() + nZOrderOff);
+pChild->setZOrderOff(0);
+
+for (sal_Int32 j = 0; j < nZOrderOff; ++j)
+{
+size_t nIndex = i + j + 1;
+if (nIndex >= rChildren.size())
+break;
+
+// Decrease the ZOrder of the next nZOrderOff elements by one.
+const ShapePtr& pNext = rChildren[nIndex];
+pNext->setZOrder(pNext->getZOrder() - 1);
+}
+}
+
+// Now that the ZOrders are adjusted, sort the children.
+std::sort(rChildren.begin(), rChildren.end(),
+  [](const ShapePtr& a, const ShapePtr& b) { return a->getZOrder() 
< b->getZOrder(); });
+
+// Apply also for children.
+for (auto& rChild : rChildren)
+sortChildrenByZOrder(rChild);
+}
+
 void Diagram::build(  )
 {
 // build name-object maps
@@ -318,6 +358,8 @@ void Diagram::addTo( const ShapePtr & pParentShape )
 // layout shapes - now all shapes are created
 ShapeLayoutingVisitor aLayoutingVisitor;
 mpLayout->getNode()->accept(aLayoutingVisitor);
+
+sortChildrenByZOrder(pParentShape);
 }
 
 ShapePtr pBackground(new Shape("com.sun.star.drawing.CustomShape"));
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index b93c06c6a636..d7d89d2968d0 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -187,38 +187,6 @@ void ShapeCreationVisitor::visit(LayoutNode& rAtom)
 std::remove_if(pCurrParent->getChildren().begin(), 
pCurrParent->getChildren().end(),
 [] (const ShapePtr & aChild) { return aChild->getServiceName() == 
"com.sun.star.drawing.GroupShape" && aChild->getChildren().empty(); }),
 pCurrParent->getChildren().end());
-
-// Offset the children from their default z-order stacking, if necessary.
-std::vector& rChildren = pCurrParent->getChildren();
-for (size_t i = 0; i < rChildren.size(); ++i)
-rChildren[i]->setZOrder(i);
-
-for (size_t i = 0; i < rChildren.size(); ++i)
-{
-const ShapePtr& pChild = rChildren[i];
-sal_Int32 nZOrderOff = pChild->getZOrderOff();
-if (nZOrderOff <= 0)
-continue;
-
-// Increase my ZOrder by nZOrderOff.
-pChild->setZOrder(pChild->getZOrder() + nZOrderOff);
-pChild->setZOrderOff(0);
-
-for (sal_Int32 j = 0; j < nZOrderOff; ++j)
-{
-size_t nIndex = i + j + 1;
-if (nIndex >= rChildren.size())
-break;
-
-// Decrease the ZOrder of the next nZOrderOff elements by one.
-const ShapePtr& pNext = rChildren[nIndex];
-pNext->setZOrder(pNext->getZOrder() - 1);
-}
-}
-
-// Now that the ZOrders are adjusted, sort the children.
-std::sort(rChildren.begin(), rChildren.end(),
-  [](const ShapePtr& a, const ShapePtr& b) { return a->getZOrder() 
< b->getZOrder(); });
 }
 
 void ShapeCreationVisitor::visit(ShapeAtom& /*rAtom*/)
diff --git a/sd/qa/unit/data/pptx/smartart-vertical-block-list.pptx 
b/sd/qa/unit/data/pptx/smartart-vertical-block-list.pptx
new file mode 100644
index 

[Libreoffice-commits] core.git: oox/source

2019-05-28 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

New commits:
commit baef4e11dd9d8c019dcf8667f2db7d7c86fd
Author: Grzegorz Araminowicz 
AuthorDate: Tue May 28 14:41:06 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Tue May 28 19:05:15 2019 +0200

SmartArt: simplify text body empty condition

Change-Id: Ie1c14bdc4f4db6f8f919433d40ea2281736c38ed
Reviewed-on: https://gerrit.libreoffice.org/73097
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index a9b2f0c1c5a1..675806767191 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -1153,12 +1153,8 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 }
 
 TextBodyPtr pTextBody = rShape->getTextBody();
-if (!pTextBody ||
-pTextBody->getParagraphs().empty() ||
-pTextBody->getParagraphs().front()->getRuns().empty())
-{
+if (!pTextBody || pTextBody->isEmpty())
 break;
-}
 
 // adjust text size to fit shape
 if (fFontSize != 0)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: oox/source sd/qa

2019-05-28 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   15 -
 sd/qa/unit/data/pptx/smartart-font-size.pptx|binary
 sd/qa/unit/import-tests-smartart.cxx|   33 
 3 files changed, 47 insertions(+), 1 deletion(-)

New commits:
commit 14c4e6155271d04f0a86029635d0a4c0b460146a
Author: Grzegorz Araminowicz 
AuthorDate: Mon May 27 20:00:42 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue May 28 14:09:42 2019 +0200

SmartArt: adjust text size to fit shapes

up to maximal size of primFontSz constraint.
Do not override text size changed by user.

Change-Id: If7ea6bbb96cb839831d877edc274a1b0eefdaf21
Reviewed-on: https://gerrit.libreoffice.org/73050
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index dcd19a61c9e4..a9b2f0c1c5a1 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -1127,6 +1128,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 // adjust text alignment
 
 // Parse constraints, only self margins as a start.
+double fFontSize = 0;
 for (const auto& rConstr : rConstraints)
 {
 if (rConstr.mnRefType == XML_w)
@@ -1146,9 +1148,10 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 
 rShape->getShapeProperties().setProperty(nProperty, 
nValue);
 }
+if (rConstr.mnType == XML_primFontSz)
+fFontSize = rConstr.mfValue;
 }
 
-// TODO: adjust text size to fit shape
 TextBodyPtr pTextBody = rShape->getTextBody();
 if (!pTextBody ||
 pTextBody->getParagraphs().empty() ||
@@ -1157,6 +1160,16 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 break;
 }
 
+// adjust text size to fit shape
+if (fFontSize != 0)
+{
+for (auto& aParagraph : pTextBody->getParagraphs())
+for (auto& aRun : aParagraph->getRuns())
+if (!aRun->getTextCharacterProperties().moHeight.has())
+aRun->getTextCharacterProperties().moHeight = 
fFontSize * 100;
+}
+
pTextBody->getTextProperties().maPropertyMap.setProperty(PROP_TextFitToSize, 
drawing::TextFitToSizeType_AUTOFIT);
+
 // ECMA-376-1:2016 21.4.7.5 ST_AutoTextRotation (Auto Text 
Rotation)
 const sal_Int32 nautoTxRot = maMap.count(XML_autoTxRot) ? 
maMap.find(XML_autoTxRot)->second : XML_upr;
 sal_Int32 nShapeRot = rShape->getRotation();
diff --git a/sd/qa/unit/data/pptx/smartart-font-size.pptx 
b/sd/qa/unit/data/pptx/smartart-font-size.pptx
new file mode 100644
index ..253cd4c73b65
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-font-size.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 1e726a5d1339..f07cca532e1b 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -75,6 +76,7 @@ public:
 void testBackground();
 void testBackgroundDrawingmlFallback();
 void testCenterCycle();
+void testFontSize();
 
 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
 
@@ -112,6 +114,7 @@ public:
 CPPUNIT_TEST(testBackground);
 CPPUNIT_TEST(testBackgroundDrawingmlFallback);
 CPPUNIT_TEST(testCenterCycle);
+CPPUNIT_TEST(testFontSize);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -1166,6 +1169,36 @@ void SdImportTestSmartArt::testCenterCycle()
 xDocShRef->DoClose();
 }
 
+void SdImportTestSmartArt::testFontSize()
+{
+sd::DrawDocShellRef xDocShRef = loadURL(
+
m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-font-size.pptx"), 
PPTX);
+
+uno::Reference xGroup1(getShapeFromPage(0, 0, 
xDocShRef), uno::UNO_QUERY);
+uno::Reference xShape1(xGroup1->getByIndex(1), 
uno::UNO_QUERY);
+uno::Reference xParagraph1(getParagraphFromShape(0, 
xShape1));
+uno::Reference xRun1(getRunFromParagraph(0, 
xParagraph1));
+uno::Reference xPropSet1(xRun1, uno::UNO_QUERY);
+double fFontSize1 = 
xPropSet1->getPropertyValue("CharHeight").get();
+CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, fFontSize1, 0.01);
+
+uno::Reference xGroup2(getShapeFromPage(1, 0, 
xDocShRef), uno::UNO_QUERY);
+uno::Reference xShape2(xGroup2->getByIndex(1), 
uno::UNO_QUERY);
+uno::Reference xParagraph2(getParagraphFromShape(0, 
xShape2));
+uno::Reference xRun2(getRunFromParagraph(0, 
xParagraph2));
+uno::Reference 

[Libreoffice-commits] core.git: sd/qa

2019-05-23 Thread Grzegorz Araminowicz (via logerrit)
 sd/qa/unit/tiledrendering/data/regenerate-diagram.pptx |binary
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |   59 +
 2 files changed, 59 insertions(+)

New commits:
commit 6184185d0636623d8870e3e13800301d36ded850
Author: Grzegorz Araminowicz 
AuthorDate: Thu May 16 12:25:40 2019 +0200
Commit: Miklos Vajna 
CommitDate: Thu May 23 09:11:20 2019 +0200

SmartArt: regenerate diagram test

Change-Id: I6d44335ab51c92dc605ee341efaaa4bf6f7bd42f
Reviewed-on: https://gerrit.libreoffice.org/72587
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/sd/qa/unit/tiledrendering/data/regenerate-diagram.pptx 
b/sd/qa/unit/tiledrendering/data/regenerate-diagram.pptx
new file mode 100644
index ..97635a51871e
Binary files /dev/null and 
b/sd/qa/unit/tiledrendering/data/regenerate-diagram.pptx differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 8ac4be6fdd2f..6e38741acd7d 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -57,6 +57,7 @@
 #include 
 
 #include 
+#include 
 
 using namespace css;
 
@@ -119,6 +120,7 @@ public:
 void testTdf115873();
 void testTdf115873Group();
 void testCutSelectionChange();
+void testRegenerateDiagram();
 
 CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
 CPPUNIT_TEST(testRegisterCallback);
@@ -165,6 +167,7 @@ public:
 CPPUNIT_TEST(testTdf115873);
 CPPUNIT_TEST(testTdf115873Group);
 CPPUNIT_TEST(testCutSelectionChange);
+CPPUNIT_TEST(testRegenerateDiagram);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -202,6 +205,9 @@ void SdTiledRenderingTest::setUp()
 {
 test::BootstrapFixture::setUp();
 
+// prevent showing warning message box
+setenv("OOX_NO_SMARTART_WARNING", "1", 1);
+
 
mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory(;
 }
 
@@ -2251,6 +2257,59 @@ void SdTiledRenderingTest::testCutSelectionChange()
 comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SdTiledRenderingTest::testRegenerateDiagram()
+{
+// Load the document.
+comphelper::LibreOfficeKit::setActive();
+SdXImpressDocument* pXImpressDocument = 
createDoc("regenerate-diagram.pptx");
+CPPUNIT_ASSERT(pXImpressDocument);
+
+SdPage* pActualPage = 
pXImpressDocument->GetDocShell()->GetViewShell()->GetActualPage();
+CPPUNIT_ASSERT_EQUAL(static_cast(4), 
pActualPage->GetObj(0)->GetSubList()->GetObjCount());
+
+// select diagram
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
+Scheduler::ProcessEventsToIdle();
+
+// enter group
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::F3);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::F3);
+Scheduler::ProcessEventsToIdle();
+
+// select shape and delete
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, 
awt::Key::DELETE);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DELETE);
+Scheduler::ProcessEventsToIdle();
+
+// exit group
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_MOD1 | 
awt::Key::F3);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_MOD1 | 
awt::Key::F3);
+Scheduler::ProcessEventsToIdle();
+
+// select diagram
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL(static_cast(3), 
pActualPage->GetObj(0)->GetSubList()->GetObjCount());
+
+// regenerate diagram
+comphelper::dispatchCommand(".uno:RegenerateDiagram", 
uno::Sequence());
+Scheduler::ProcessEventsToIdle();
+
+// diagram content (child shape count) should be the same as in the 
beginning
+CPPUNIT_ASSERT_EQUAL(static_cast(4), 
pActualPage->GetObj(0)->GetSubList()->GetObjCount());
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - include/oox oox/source sd/qa sd/source sw/source

2019-05-22 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/export/drawingml.hxx |5 
 oox/source/export/drawingml.cxx  |  320 +++
 oox/source/token/tokens.txt  |1 
 sd/qa/unit/data/pptx/group.pptx  |binary
 sd/qa/unit/data/pptx/smartart-preserve.pptx  |binary
 sd/qa/unit/export-tests-ooxml2.cxx   |   62 -
 sd/source/filter/eppt/epptooxml.hxx  |6 
 sd/source/filter/eppt/pptx-epptooxml.cxx |   14 +
 sw/source/filter/ww8/docxattributeoutput.cxx |   34 --
 sw/source/filter/ww8/docxattributeoutput.hxx |3 
 sw/source/filter/ww8/docxsdrexport.cxx   |  275 ---
 sw/source/filter/ww8/docxsdrexport.hxx   |5 
 12 files changed, 411 insertions(+), 314 deletions(-)

New commits:
commit 03afad2a4c8293489e3da06484b3cf8b8129c845
Author: Grzegorz Araminowicz 
AuthorDate: Wed Mar 13 10:49:30 2019 +0100
Commit: Miklos Vajna 
CommitDate: Wed May 22 08:53:15 2019 +0200

PPTX export: save SmartArt as diagram instead of group of shapes

preserving SmartArt allows editing it in PowerPoint after saving as pptx 
file

* moved common parts for docx and pptx export to oox/drawingml
* fixed export tests that expected shapes on output

Change-Id: I3e70a9f4177bebf5e1671232f4cd0ef0e7212626
Reviewed-on: https://gerrit.libreoffice.org/69598
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/72474

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 2da61a6f5300..989ad7f311af 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -257,7 +257,12 @@ public:
 void WriteShape3DEffects( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet );
 void WriteArtisticEffect( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet );
 OString WriteWdpPicture( const OUString& rFileId, const 
css::uno::Sequence< sal_Int8 >& rPictureData );
+void WriteDiagram(const css::uno::Reference& 
rXShape, int nDiagramId);
+void writeDiagramRels(const 
css::uno::Sequence>& xRelSeq,
+  const css::uno::Reference& 
xOutStream,
+  const OUString& sGrabBagProperyName, int nDiagramId);
 static bool IsGroupShape( const css::uno::Reference< css::drawing::XShape 
>& rXShape );
+static bool IsDiagram(const css::uno::Reference& 
rXShape);
 sal_Int32 getBulletMarginIndentation (const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, const OUString& 
propName);
 
 static void ResetCounters();
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 30f330226788..7d0aca3c3899 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -25,10 +25,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -79,7 +81,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -97,6 +105,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2224,6 +2233,31 @@ bool DrawingML::IsGroupShape( const Reference< XShape >& 
rXShape )
 return bRet;
 }
 
+bool DrawingML::IsDiagram(const Reference& rXShape)
+{
+uno::Reference xPropSet(rXShape, uno::UNO_QUERY);
+if (!xPropSet.is())
+return false;
+
+// if the shape doesn't have the InteropGrabBag property, it's not a 
diagram
+uno::Reference xPropSetInfo = 
xPropSet->getPropertySetInfo();
+OUString aName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
+if (!xPropSetInfo->hasPropertyByName(aName))
+return false;
+
+uno::Sequence propList;
+xPropSet->getPropertyValue(aName) >>= propList;
+for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
+{
+// if we find any of the diagram components, it's a diagram
+OUString propName = propList[nProp].Name;
+if (propName == "OOXData" || propName == "OOXLayout" || propName == 
"OOXStyle"
+|| propName == "OOXColor" || propName == "OOXDrawing")
+return true;
+}
+return false;
+}
+
 sal_Int32 DrawingML::getBulletMarginIndentation (const Reference< XPropertySet 
>& rXPropSet,sal_Int16 nLevel, const OUString& propName)
 {
 if( nLevel < 0 || !GETA( NumberingRules ) )
@@ -3925,6 +3959,292 @@ OString DrawingML::WriteWdpPicture( const OUString& 
rFileId, const Sequence< sal
 return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
 }
 
+void DrawingML::WriteDiagram(const css::uno::Reference& 
rXShape, int nDiagramId)
+{
+uno::Reference xPropSet(rXShape, uno::UNO_QUERY);
+
+uno::Reference dataDom;
+uno::Reference layoutDom;
+uno::Reference styleDom;
+uno::Reference colorDom;
+uno::Reference drawingDom;
+uno::Sequence> xDataRelSeq;
+

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - include/oox oox/source sd/qa

2019-05-21 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/shape.hxx  |2 ++
 oox/source/drawingml/shape.cxx   |   17 +
 oox/source/ppt/pptshapegroupcontext.cxx  |   25 ++---
 oox/source/shape/ShapeContextHandler.cxx |   19 ++-
 sd/qa/unit/import-tests-smartart.cxx |1 +
 5 files changed, 36 insertions(+), 28 deletions(-)

New commits:
commit cdb764a6367daaa4842be57d144275a87c2802b4
Author: Grzegorz Araminowicz 
AuthorDate: Fri Mar 15 23:50:13 2019 +0100
Commit: Miklos Vajna 
CommitDate: Tue May 21 09:30:23 2019 +0200

PPTX import: save also OOXDrawing in InteropGrabBag

Change-Id: Ieaf341dd13e06046044f3523c3aad74476160402
Reviewed-on: https://gerrit.libreoffice.org/69328
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/72473

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index aaade775c00c..9e879b47bc9c 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -225,6 +225,8 @@ public:
 /// Changes reference semantics to value semantics for fill properties.
 void cloneFillProperties();
 
+void keepDiagramDrawing(::oox::core::XmlFilterBase& rFilterBase, const 
OUString& rFragmentPath);
+
 protected:
 
 enum FrameType
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 3e04f3b7494e..4848f4086e02 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1394,6 +1395,22 @@ Reference< XShape > const & Shape::createAndInsert(
 return mxShape;
 }
 
+void Shape::keepDiagramDrawing(XmlFilterBase& rFilterBase, const OUString& 
rFragmentPath)
+{
+uno::Sequence diagramDrawing(2);
+// drawingValue[0] => dom, drawingValue[1] => Sequence of associated 
relationships
+
+sal_Int32 length = maDiagramDoms.getLength();
+maDiagramDoms.realloc(length + 1);
+
+diagramDrawing[0] <<= rFilterBase.importFragment(rFragmentPath);
+diagramDrawing[1] <<= resolveRelationshipsOfTypeFromOfficeDoc(rFilterBase, 
rFragmentPath, "image");
+
+beans::PropertyValue* pValue = maDiagramDoms.getArray();
+pValue[length].Name = "OOXDrawing";
+pValue[length].Value <<= diagramDrawing;
+}
+
 void Shape::keepDiagramCompatibilityInfo()
 {
 try
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx 
b/oox/source/ppt/pptshapegroupcontext.cxx
index 9a775655518f..6535e12d3f81 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -148,17 +148,20 @@ void PPTShapeGroupContext::importExtDrawings( )
 if( pGraphicShape )
 {
 for (auto const& extDrawing : pGraphicShape->getExtDrawings())
-{
-getFilter().importFragment( new ExtDrawingFragmentHandler( 
getFilter(), getFragmentPathFromRelId(extDrawing),
-   
mpSlidePersistPtr,
-   
meShapeLocation,
-   
mpGroupShapePtr,
-   
pGraphicShape ) );
-// Apply font color imported from color fragment
-if( pGraphicShape->getFontRefColorForNodes().isUsed() )
-applyFontRefColor(mpGroupShapePtr, 
pGraphicShape->getFontRefColorForNodes());
-}
-pGraphicShape = oox::drawingml::ShapePtr( nullptr );
+{
+OUString aFragmentPath = getFragmentPathFromRelId(extDrawing);
+getFilter().importFragment( new ExtDrawingFragmentHandler( 
getFilter(), aFragmentPath,
+   
mpSlidePersistPtr,
+   
meShapeLocation,
+   
mpGroupShapePtr,
+   
pGraphicShape ) );
+pGraphicShape->keepDiagramDrawing(getFilter(), aFragmentPath);
+
+// Apply font color imported from color fragment
+if( pGraphicShape->getFontRefColorForNodes().isUsed() )
+applyFontRefColor(mpGroupShapePtr, 
pGraphicShape->getFontRefColorForNodes());
+}
+pGraphicShape = oox::drawingml::ShapePtr( nullptr );
 }
 }
 
diff --git a/oox/source/shape/ShapeContextHandler.cxx 
b/oox/source/shape/ShapeContextHandler.cxx
index b80af12ac15e..2747572f0479 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -425,23 +425,8 @@ ShapeContextHandler::getShape()
 oox::drawingml::ShapePtr pShapePtr( new Shape( 
"com.sun.star.drawing.GroupShape" ) 

[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - 2 commits - include/oox oox/source sd/qa

2019-05-21 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/shape.hxx   |   23 --
 oox/source/drawingml/shape.cxx|   35 +++---
 oox/source/ppt/extdrawingfragmenthandler.cxx  |6 ---
 oox/source/ppt/extdrawingfragmenthandler.hxx  |1 
 oox/source/ppt/pptshape.cxx   |4 ++
 oox/source/ppt/pptshapegroupcontext.cxx   |7 +++-
 sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx |binary
 sd/qa/unit/data/xml/n819614_0.xml |   10 --
 sd/qa/unit/export-tests-ooxml1.cxx|6 +--
 sd/qa/unit/export-tests-ooxml2.cxx|4 +-
 sd/qa/unit/import-tests-smartart.cxx  |   21 +
 sd/qa/unit/import-tests.cxx   |1 
 12 files changed, 75 insertions(+), 43 deletions(-)

New commits:
commit f8586c223f07ddff4bba5d5c694cee33ac811412
Author: Grzegorz Araminowicz 
AuthorDate: Thu Mar 14 08:25:12 2019 +0100
Commit: Miklos Vajna 
CommitDate: Tue May 21 09:29:50 2019 +0200

PPTX import: import SmartArt drawing into single GroupShape

before that there were imported two GroupShapes:
- empty one with properties like id, name, InteropGrapBag
- second one with actual shapes

also fixed tests that relyed on that behaviour

Change-Id: I2b94a53e21666b16725c4353448d75e916e4f9df
Reviewed-on: https://gerrit.libreoffice.org/69252
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/72472

diff --git a/oox/source/ppt/extdrawingfragmenthandler.cxx 
b/oox/source/ppt/extdrawingfragmenthandler.cxx
index a0d40ea0412c..cf8d8e50ed3c 100644
--- a/oox/source/ppt/extdrawingfragmenthandler.cxx
+++ b/oox/source/ppt/extdrawingfragmenthandler.cxx
@@ -29,7 +29,7 @@ ExtDrawingFragmentHandler::ExtDrawingFragmentHandler( 
XmlFilterBase& rFilter,
  mpSlidePersistPtr (rSlidePersistPtr ),
  meShapeLocation( eShapeLocation ),
  mpGroupShapePtr( pGroupShapePtr ),
- mpOrgShapePtr( pShapePtr )
+ mpShapePtr( pShapePtr )
 {
 }
 
@@ -49,10 +49,6 @@ ExtDrawingFragmentHandler::onCreateContext( ::sal_Int32 
aElement,
 case DSP_TOKEN( drawing ):
 break;
 case DSP_TOKEN( spTree ):
-mpShapePtr = oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, 
"com.sun.star.drawing.GroupShape" ) );
-mpShapePtr->setPosition( mpOrgShapePtr->getPosition() );
-mpShapePtr->setName( mpOrgShapePtr->getName() );
-
 return new PPTShapeGroupContext(
 *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr,
 mpShapePtr );
diff --git a/oox/source/ppt/extdrawingfragmenthandler.hxx 
b/oox/source/ppt/extdrawingfragmenthandler.hxx
index 83dfcd216e8f..cdde03777bc1 100644
--- a/oox/source/ppt/extdrawingfragmenthandler.hxx
+++ b/oox/source/ppt/extdrawingfragmenthandler.hxx
@@ -34,7 +34,6 @@ private:
 const oox::ppt::SlidePersistPtr mpSlidePersistPtr;
 const oox::ppt::ShapeLocation   meShapeLocation;
 oox::drawingml::ShapePtr const  mpGroupShapePtr;
-oox::drawingml::ShapePtrmpOrgShapePtr;  // Original 
Shape data, if any
 oox::drawingml::ShapePtrmpShapePtr;
 };
 
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx 
b/oox/source/ppt/pptshapegroupcontext.cxx
index 1180af3f10fb..9a775655518f 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -71,9 +71,12 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( 
sal_Int32 aElementToken
 {
 case PPT_TOKEN( cNvPr ):
 {
+// don't override SmartArt properties for embedded drawing's spTree
 mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
-mpGroupShapePtr->setId( rAttribs.getString( XML_id ).get() );
-mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() );
+if (mpGroupShapePtr->getId().isEmpty())
+mpGroupShapePtr->setId(rAttribs.getString(XML_id).get());
+if (mpGroupShapePtr->getName().isEmpty())
+mpGroupShapePtr->setName( rAttribs.getString( XML_name ).get() );
 break;
 }
 case PPT_TOKEN( ph ):
diff --git a/sd/qa/unit/data/xml/n819614_0.xml 
b/sd/qa/unit/data/xml/n819614_0.xml
index e51b520d3130..fc109917c460 100644
--- a/sd/qa/unit/data/xml/n819614_0.xml
+++ b/sd/qa/unit/data/xml/n819614_0.xml
@@ -14,7 +14,7 @@

   
  
- 
+ 
   

 
@@ -6824,12 +6824,4 @@

   
  
- 
-  
-  
-   
-   
-   
-  
- 
 
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx 
b/sd/qa/unit/export-tests-ooxml1.cxx
index 7cc50e21f963..3e832aad4e3f 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -231,7 +231,7 @@ void SdOOXMLExportTest1::testBnc870233_2()
 
 // Second smart art has "dk2" font color (style)
 {
-const SdrObjGroup *pObjGroup = dynamic_cast(pPage->GetObj(2)); // FIXME should be 1, 

[Libreoffice-commits] core.git: include/oox officecfg/registry oox/inc oox/source sd/CppunitTest_sd_uimpress.mk sd/inc sd/Library_sd.mk sd/sdi sd/source solenv/clang-format

2019-05-14 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/diagram/diagram.hxx|   12 +
 include/oox/shape/ShapeFilterBase.hxx|   17 +
 officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu |5 
 oox/source/core/filterbase.cxx   |2 
 oox/source/drawingml/diagram/diagram.cxx |  103 
+-
 oox/source/drawingml/diagram/diagramfragmenthandler.hxx  |2 
 oox/source/drawingml/diagram/layoutnodecontext.cxx   |1 
 oox/source/drawingml/graphicshapecontext.cxx |2 
 oox/source/shape/ShapeContextHandler.hxx |2 
 oox/source/shape/ShapeFilterBase.cxx |   29 ++
 sd/CppunitTest_sd_uimpress.mk|1 
 sd/Library_sd.mk |1 
 sd/inc/app.hrc   |1 
 sd/sdi/_drvwsh.sdi   |5 
 sd/sdi/sdraw.sdi |   17 +
 sd/source/ui/view/drviews3.cxx   |   34 +++
 solenv/clang-format/blacklist|4 
 17 files changed, 226 insertions(+), 12 deletions(-)

New commits:
commit c61b75eede5ffd6e18a44130eba25e50dccfb1d4
Author: Grzegorz Araminowicz 
AuthorDate: Mon Apr 29 13:30:42 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue May 14 16:02:26 2019 +0200

SmartArt: regenerate diagram command

It removes diagram content and rebuilds shape tree from diagram markup.
Diagram should appear unchanged - editing will be added in future commits.

Change-Id: I6bfc21956a1a23e55d3c7a74384db71d957d690d
Reviewed-on: https://gerrit.libreoffice.org/71584
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/inc/drawingml/diagram/diagram.hxx 
b/include/oox/drawingml/diagram/diagram.hxx
similarity index 73%
rename from oox/inc/drawingml/diagram/diagram.hxx
rename to include/oox/drawingml/diagram/diagram.hxx
index 73431815dadb..3db8d5f69fc1 100644
--- a/oox/inc/drawingml/diagram/diagram.hxx
+++ b/include/oox/drawingml/diagram/diagram.hxx
@@ -24,6 +24,8 @@
 #include 
 #include 
 
+#include 
+#include 
 #include 
 
 namespace oox { namespace drawingml {
@@ -42,6 +44,16 @@ void loadDiagram( ShapePtr const & pShape,
   const OUString& rColorStylePath,
   const oox::core::Relations& rRelations );
 
+void loadDiagram(ShapePtr const& pShape,
+ const css::uno::Reference& dataDom,
+ const css::uno::Reference& 
layoutDom,
+ const css::uno::Reference& styleDom,
+ const css::uno::Reference& colorDom,
+ core::XmlFilterBase& rFilter);
+
+OOX_DLLPUBLIC void reloadDiagram(css::uno::Reference& 
rXShape,
+ core::XmlFilterBase& rFilter);
+
 } }
 
 #endif
diff --git a/oox/source/shape/ShapeFilterBase.hxx 
b/include/oox/shape/ShapeFilterBase.hxx
similarity index 88%
rename from oox/source/shape/ShapeFilterBase.hxx
rename to include/oox/shape/ShapeFilterBase.hxx
index 86297cda7011..1dc7653bd314 100644
--- a/oox/source/shape/ShapeFilterBase.hxx
+++ b/include/oox/shape/ShapeFilterBase.hxx
@@ -17,20 +17,27 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_OOX_SOURCE_SHAPE_SHAPEFILTERBASE_HXX
-#define INCLUDED_OOX_SOURCE_SHAPE_SHAPEFILTERBASE_HXX
+#ifndef INCLUDED_OOX_SHAPE_SHAPEFILTERBASE_HXX
+#define INCLUDED_OOX_SHAPE_SHAPEFILTERBASE_HXX
 
 #include 
 #include 
+#include 
 #include 
-#include 
 #include 
 #include 
 
+namespace oox { namespace drawingml { namespace table {
+
+class TableStyleList;
+typedef std::shared_ptr< TableStyleList > TableStyleListPtr;
+
+}}}
+
 namespace oox {
 namespace shape {
 
-class ShapeFilterBase : public core::XmlFilterBase
+class OOX_DLLPUBLIC ShapeFilterBase : public core::XmlFilterBase
 {
 public:
 typedef std::shared_ptr Pointer_t;
@@ -59,6 +66,8 @@ public:
 
 ::Color getSchemeColor( sal_Int32 nToken ) const;
 
+void importTheme();
+
 private:
 virtual ::oox::ole::VbaProject* implCreateVbaProject() const override;
 virtual OUString SAL_CALL getImplementationName() override;
diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 7dfefa1bc10a..ee1f797e7a1d 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -7002,6 +7002,11 @@
   More Fields
 
   
+  
+
+  Regenerate Diagram
+
+  
 
   
 
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index 

[Libreoffice-commits] core.git: include/oox oox/source sd/qa sw/qa

2019-05-10 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/shape.hxx  |2 
 oox/source/drawingml/diagram/diagram.cxx |   11 
 oox/source/drawingml/shape.cxx   |9 
 oox/source/shape/ShapeContextHandler.cxx |8 
 sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx |binary
 sd/qa/unit/data/pptx/smartart-background.pptx|binary
 sd/qa/unit/data/xml/n819614_0.xml|   69 ++
 sd/qa/unit/export-tests-ooxml1.cxx   |4 
 sd/qa/unit/export-tests-ooxml2.cxx   |8 
 sd/qa/unit/import-tests-smartart.cxx |  255 
++
 sd/qa/unit/import-tests.cxx  |7 
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx   |8 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |4 
 13 files changed, 278 insertions(+), 107 deletions(-)

New commits:
commit c86cf2aaa07538e8c37dc81729905a3bb9ecc1ff
Author: Grzegorz Araminowicz 
AuthorDate: Wed May 8 21:49:34 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 10 12:18:29 2019 +0200

SmartArt: support diagram background

Solved by adding additional shape filling whole diagram.
MS PowerPoint does the same when converting SmartArt to shapes.

Background shape is also copied when loading from drawingML fallback,
appearently there is no background information.

Corrected SmartArt import tests, so that they are aware of extra shape.

Change-Id: I6154f8e1b34e5867ab582d6fc54459c7c93edbac
Reviewed-on: https://gerrit.libreoffice.org/72012
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index e7d06476656d..1f8b163b5d35 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -151,6 +151,7 @@ public:
 voidsetDescription( const OUString& rDescr ) { 
msDescription = rDescr; }
 voidsetHidden( bool bHidden ) { mbHidden = 
bHidden; }
 voidsetHiddenMasterShape( bool 
bHiddenMasterShape ) { mbHiddenMasterShape = bHiddenMasterShape; }
+voidsetLocked( bool bLocked ) { mbLocked = 
bLocked; }
 voidsetSubType( sal_Int32 nSubType ) { 
mnSubType = nSubType; }
 sal_Int32   getSubType() const { return mnSubType; }
 voidsetSubTypeIndex( sal_Int32 nSubTypeIndex ) 
{ moSubTypeIndex = nSubTypeIndex; }
@@ -340,6 +341,7 @@ private:
 boolmbHiddenMasterShape; // master shapes can 
be hidden in layout slides
  // we need separate 
flag because we don't want
  // to propagate it 
when applying reference shape
+boolmbLocked;
 bool mbLockedCanvas; ///< Is this shape part of a locked canvas?
 bool mbWps; ///< Is this a wps shape?
 bool mbTextBox; ///< This shape has a textbox.
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 76e5e9089a35..e8e661e64d51 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -314,6 +315,16 @@ void Diagram::addTo( const ShapePtr & pParentShape )
 ShapeLayoutingVisitor aLayoutingVisitor;
 mpLayout->getNode()->accept(aLayoutingVisitor);
 }
+
+ShapePtr pBackground(new Shape("com.sun.star.drawing.CustomShape"));
+pBackground->setSubType(XML_rect);
+pBackground->getCustomShapeProperties()->setShapePresetType(XML_rect);
+pBackground->setSize(pParentShape->getSize());
+pBackground->getFillProperties() = *mpData->getFillProperties();
+pBackground->setLocked(true);
+auto& aChildren = pParentShape->getChildren();
+aChildren.insert(aChildren.begin(), pBackground);
+
 pParentShape->setDiagramDoms( getDomsAsPropertyValues() );
 }
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 41c8d9493dcf..64c80568f7a8 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -128,6 +128,7 @@ Shape::Shape( const sal_Char* pServiceName, bool 
bDefaultHeight )
 , mbFlipV( false )
 , mbHidden( false )
 , mbHiddenMasterShape( false )
+, mbLocked( false )
 , mbLockedCanvas( false )
 , mbWps( false )
 , mbTextBox( false )
@@ -171,6 +172,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
 , mbFlipV( pSourceShape->mbFlipV )
 , mbHidden( pSourceShape->mbHidden )
 , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
+, mbLocked( 

[Libreoffice-commits] core.git: include/oox oox/source sd/qa

2019-04-30 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/theme.hxx|1 
 oox/source/ppt/presentationfragmenthandler.cxx |7 +-
 sd/qa/unit/data/pptx/ooxtheme.pptx |binary
 sd/qa/unit/import-tests.cxx|   28 +
 4 files changed, 35 insertions(+), 1 deletion(-)

New commits:
commit cd08835d1bd9274412c7326db32fb3752bc94fb3
Author: Grzegorz Araminowicz 
AuthorDate: Mon Apr 29 14:44:20 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue Apr 30 09:13:28 2019 +0200

PPTX import: store OOXTheme in InteropGrabBag for SmartArt re-generation

Change-Id: I343dc3a275ecbbb483e179d8cc2deebfb71b9c8f
Reviewed-on: https://gerrit.libreoffice.org/71530
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/include/oox/drawingml/theme.hxx b/include/oox/drawingml/theme.hxx
index 9593b77eb5f9..bde25e748ba8 100644
--- a/include/oox/drawingml/theme.hxx
+++ b/include/oox/drawingml/theme.hxx
@@ -97,6 +97,7 @@ public:
 Shape&   getTxDef() { return maTxDef; }
 const Shape& getTxDef() const { return maTxDef; }
 
+const css::uno::Reference& getFragment() const { 
return mxFragment; }
 void setFragment( const css::uno::Reference< 
css::xml::dom::XDocument>& xRef ) { mxFragment=xRef; }
 
 private:
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx 
b/oox/source/ppt/presentationfragmenthandler.cxx
index 90e8013b741e..689e6e162cc5 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -179,7 +179,7 @@ void PresentationFragmentHandler::saveThemeToGrabBag(const 
oox::drawingml::Theme
 // get existing grab bag
 comphelper::SequenceAsHashMap 
aGrabBag(xDocProps->getPropertyValue(aGrabBagPropName));
 
-uno::Sequence aTheme(1);
+uno::Sequence aTheme(2);
 comphelper::SequenceAsHashMap aThemesHashMap;
 
 // create current theme
@@ -204,6 +204,11 @@ void PresentationFragmentHandler::saveThemeToGrabBag(const 
oox::drawingml::Theme
 const uno::Any& rCurrentTheme = makeAny(aCurrentTheme);
 aTheme[0].Value = rCurrentTheme;
 
+// store DOM fragment for SmartArt re-generation
+aTheme[1].Name = "OOXTheme";
+const uno::Any& rOOXTheme = makeAny(pThemePtr->getFragment());
+aTheme[1].Value = rOOXTheme;
+
 aThemesHashMap << aTheme;
 
 // put the new items
diff --git a/sd/qa/unit/data/pptx/ooxtheme.pptx 
b/sd/qa/unit/data/pptx/ooxtheme.pptx
new file mode 100644
index ..f0f3f2575894
Binary files /dev/null and b/sd/qa/unit/data/pptx/ooxtheme.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 5d690c8a1491..566818755c5b 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -79,6 +79,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -199,6 +200,7 @@ public:
 void testTdf83247();
 void testTdf47365();
 void testTdf122899();
+void testOOXTheme();
 
 CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -288,6 +290,7 @@ public:
 CPPUNIT_TEST(testTdf83247);
 CPPUNIT_TEST(testTdf47365);
 CPPUNIT_TEST(testTdf122899);
+CPPUNIT_TEST(testOOXTheme);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -2743,6 +2746,31 @@ void SdImportTest::testTdf122899()
 xDocShRef->DoClose();
 }
 
+void SdImportTest::testOOXTheme()
+{
+sd::DrawDocShellRef xDocShRef
+= 
loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/ooxtheme.pptx"), 
PPTX);
+
+uno::Reference 
xPropSet(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
+uno::Sequence aGrabBag;
+xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
+
+bool bTheme = false;
+for (int i = 0; i < aGrabBag.getLength(); i++)
+{
+if (aGrabBag[i].Name == "OOXTheme")
+{
+bTheme = true;
+uno::Reference aThemeDom;
+CPPUNIT_ASSERT(aGrabBag[i].Value >>= aThemeDom); // PropertyValue 
of proper type
+CPPUNIT_ASSERT(aThemeDom.get()); // Reference not empty
+}
+}
+CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements
+
+xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: oox/source sd/qa

2019-04-15 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   97 +---
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx |3 
 sd/qa/unit/import-tests-smartart.cxx|   25 -
 3 files changed, 71 insertions(+), 54 deletions(-)

New commits:
commit 5218009f4b3f1f619d12151fc76ec14a12c6d89e
Author: Grzegorz Araminowicz 
AuthorDate: Thu Apr 11 14:56:37 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Apr 15 09:51:44 2019 +0200

SmartArt: better detecting connector arrow type

* basing on provided conn alg params
* also moved setting arrow direction from getConnectorType() to algorithms

Change-Id: I76898a4ccad961edd389677c31e7d8c05bcdf5fe
Reviewed-on: https://gerrit.libreoffice.org/70598
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 7686ddf2413c..96e305b46a00 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -84,56 +84,6 @@ sal_Int32 getPropertyFromConstraint(sal_Int32 nConstraint)
 return 0;
 }
 
-/// Determines the connector shape type from a linear alg.
-sal_Int32 getConnectorType(const oox::drawingml::LayoutNode* pNode)
-{
-sal_Int32 nType = oox::XML_rightArrow;
-
-if (!pNode)
-return nType;
-
-// This is cheaper than visiting the whole sub-tree.
-if (pNode->getName().startsWith("hierChild"))
-return oox::XML_bentConnector3;
-
-for (const auto& pChild : pNode->getChildren())
-{
-auto pAlgAtom = dynamic_cast(pChild.get());
-if (!pAlgAtom)
-continue;
-
-switch (pAlgAtom->getType())
-{
-case oox::XML_lin:
-{
-sal_Int32 nDir = oox::XML_fromL;
-if (pAlgAtom->getMap().count(oox::XML_linDir))
-nDir = pAlgAtom->getMap().find(oox::XML_linDir)->second;
-
-switch (nDir)
-{
-case oox::XML_fromL:
-nType = oox::XML_rightArrow;
-break;
-case oox::XML_fromR:
-nType = oox::XML_leftArrow;
-break;
-}
-break;
-}
-case oox::XML_hierChild:
-{
-// TODO  should be able
-// to customize this.
-nType = oox::XML_bentConnector3;
-break;
-}
-}
-}
-
-return nType;
-}
-
 /**
  * Determines if pShape is (or contains) a presentation of a data node of type
  * nType.
@@ -493,6 +443,30 @@ void AlgAtom::accept( LayoutAtomVisitor& rVisitor )
 rVisitor.visit(*this);
 }
 
+sal_Int32 AlgAtom::getConnectorType()
+{
+sal_Int32 nConnRout = 0;
+sal_Int32 nBegSty = 0;
+sal_Int32 nEndSty = 0;
+if (maMap.count(oox::XML_connRout))
+nConnRout = maMap.find(oox::XML_connRout)->second;
+if (maMap.count(oox::XML_begSty))
+nBegSty = maMap.find(oox::XML_begSty)->second;
+if (maMap.count(oox::XML_endSty))
+nEndSty = maMap.find(oox::XML_endSty)->second;
+
+if (nConnRout == oox::XML_bend)
+return oox::XML_bentConnector3;
+if (nBegSty == oox::XML_arr && nEndSty == oox::XML_arr)
+return oox::XML_leftRightArrow;
+if (nBegSty == oox::XML_arr)
+return oox::XML_leftArrow;
+if (nEndSty == oox::XML_arr)
+return oox::XML_rightArrow;
+
+return oox::XML_rightArrow;
+}
+
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rOwnConstraints )
 {
@@ -624,7 +598,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 {
 // There is no shape type "conn", replace it by an arrow based
 // on the direction of the parent linear layout.
-sal_Int32 nType = getConnectorType(pParent);
+sal_Int32 nType = getConnectorType();
 
 rShape->setSubType(nType);
 rShape->getCustomShapeProperties()->setShapePresetType(nType);
@@ -695,6 +669,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 (rShape->getSize().Width - aChildSize.Width) / 2,
 (rShape->getSize().Height - aChildSize.Height) / 2);
 const sal_Int32 nConnectorRadius = nRadius * 
cos(basegfx::deg2rad(nSpanAngle/nShapes));
+const sal_Int32 nConnectorAngle = nSpanAngle > 0 ? 0 : 180;
 
 sal_Int32 idx = 0;
 for (auto & aCurrShape : rShape->getChildren())
@@ -715,10 +690,13 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 aCurrShape->setSize(aCurrSize);
 aCurrShape->setChildSize(aCurrSize);
 
+if (nRotationPath == XML_alongPath)
+aCurrShape->setRotation(fAngle * PER_DEGREE);

[Libreoffice-commits] core.git: oox/source sd/qa

2019-04-12 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |   28 +++-
 sd/qa/unit/import-tests-smartart.cxx|   17 +++-
 2 files changed, 38 insertions(+), 7 deletions(-)

New commits:
commit c9c9c5ad3fa41f78042b44092c44a181c3b846b8
Author: Grzegorz Araminowicz 
AuthorDate: Wed Apr 10 16:19:32 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri Apr 12 09:48:38 2019 +0200

SmartArt: improve cycle algorithm

connector arrows are now correctly positioned and rotated

Change-Id: I6407ec5e2d6e29d250f751f8dc5feae878d3c74c
Reviewed-on: https://gerrit.libreoffice.org/70525
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 9b7d5323e518..7d64e82059af 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -672,6 +672,11 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 awt::Size aSize;
 aSize.Width = rParent[XML_w];
 aSize.Height = rParent[XML_h];
+// keep center position
+awt::Point aPos = rShape->getPosition();
+aPos.X += (rShape->getSize().Width - aSize.Width) / 2;
+aPos.Y += (rShape->getSize().Height - aSize.Height) / 2;
+rShape->setPosition(aPos);
 rShape->setSize(aSize);
 break;
 }
@@ -686,24 +691,35 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 const sal_Int32 nRotationPath = maMap.count(XML_rotPath) ? 
maMap.find(XML_rotPath)->second : XML_none;
 const sal_Int32 nShapes = rShape->getChildren().size();
 const awt::Size aCenter(rShape->getSize().Width / 2, 
rShape->getSize().Height / 2);
-const awt::Size aChildSize(rShape->getSize().Width / 5, 
rShape->getSize().Height / 5);
+const awt::Size aChildSize(rShape->getSize().Width / 4, 
rShape->getSize().Height / 4);
+const awt::Size aConnectorSize(rShape->getSize().Width / 12, 
rShape->getSize().Height / 12);
 const sal_Int32 nRadius = std::min(
 (rShape->getSize().Width - aChildSize.Width) / 2,
 (rShape->getSize().Height - aChildSize.Height) / 2);
+const sal_Int32 nConnectorRadius = nRadius * 
cos(basegfx::deg2rad(nSpanAngle/nShapes));
 
 sal_Int32 idx = 0;
 for (auto & aCurrShape : rShape->getChildren())
 {
 const double fAngle = 
static_cast(idx)*nSpanAngle/nShapes + nStartAngle;
+awt::Size aCurrSize = aChildSize;
+sal_Int32 nCurrRadius = nRadius;
+if (aCurrShape->getSubType() == XML_conn)
+{
+aCurrSize = aConnectorSize;
+nCurrRadius = nConnectorRadius;
+}
 const awt::Point aCurrPos(
-aCenter.Width + nRadius*sin(basegfx::deg2rad(fAngle)) - 
aChildSize.Width/2,
-aCenter.Height - nRadius*cos(basegfx::deg2rad(fAngle)) - 
aChildSize.Height/2);
+aCenter.Width + nCurrRadius*sin(basegfx::deg2rad(fAngle)) 
- aCurrSize.Width/2,
+aCenter.Height - nCurrRadius*cos(basegfx::deg2rad(fAngle)) 
- aCurrSize.Height/2);
 
 aCurrShape->setPosition(aCurrPos);
-aCurrShape->setSize(aChildSize);
-aCurrShape->setChildSize(aChildSize);
+aCurrShape->setSize(aCurrSize);
+aCurrShape->setChildSize(aCurrSize);
 
-if (nRotationPath == XML_alongPath)
+// connectors should be handled in conn, but we don't have
+// reference to previous and next child, so it's easier here
+if (nRotationPath == XML_alongPath || aCurrShape->getSubType() 
== XML_conn)
 aCurrShape->setRotation(fAngle * PER_DEGREE);
 
 idx++;
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index 33bdf6532966..001bb07678a8 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -401,10 +401,25 @@ void SdImportTestSmartArt::testCycle()
 
m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-cycle.pptx"), PPTX);
 uno::Reference xGroup(getShapeFromPage(0, 0, xDocShRef), 
uno::UNO_QUERY);
 CPPUNIT_ASSERT(xGroup.is());
+
 // 10 children: 5 shapes, 5 connectors
 CPPUNIT_ASSERT_EQUAL(static_cast(10), xGroup->getCount());
 
-//FIXME : so far this only introduce the test document, but the actual 
importer was not fixed yet.
+uno::Reference xShape0(xGroup->getByIndex(0), 
uno::UNO_QUERY_THROW);
+uno::Reference xShapeConn(xGroup->getByIndex(1), 
uno::UNO_QUERY_THROW);
+uno::Reference xShape2(xGroup->getByIndex(2), 
uno::UNO_QUERY_THROW);
+
+

[Libreoffice-commits] core.git: oox/source

2019-04-12 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagram.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a293630bb4dfed200c1c1e246acab4226a0ff08f
Author: Grzegorz Araminowicz 
AuthorDate: Thu Apr 11 15:57:52 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Fri Apr 12 09:01:54 2019 +0200

SmartArt: save diagram dump to working dir instead of /tmp

so that it works on Windows as well

Change-Id: Ia919677067c90a2c9478e3666bfe50489996756f
Reviewed-on: https://gerrit.libreoffice.org/70599
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 

diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index 97f967280631..76e5e9089a35 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -137,7 +137,7 @@ void Diagram::build(  )
 {
 // build name-object maps
 #ifdef DEBUG_OOX_DIAGRAM
-std::ofstream output("/tmp/tree.dot");
+std::ofstream output("tree.dot");
 
 output << "digraph datatree {" << std::endl;
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: oox/source sd/qa

2019-04-10 Thread Grzegorz Araminowicz (via logerrit)
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx |4 ++--
 oox/source/drawingml/diagram/layoutatomvisitors.cxx |6 +++---
 sd/qa/unit/import-tests-smartart.cxx|7 +++
 3 files changed, 12 insertions(+), 5 deletions(-)

New commits:
commit 31454f6de1246dd465c3de2b52396a827e84ea4b
Author: Grzegorz Araminowicz 
AuthorDate: Tue Apr 9 13:25:11 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed Apr 10 09:04:09 2019 +0200

SmartArt: omit last atom in forEach loop only when necessary

now all transition arrows are created in cycle diagrams

Change-Id: I69e932f0060786b702dbecae72245bb624fa602b
Reviewed-on: https://gerrit.libreoffice.org/70457
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 336760575339..9b7d5323e518 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -221,7 +221,7 @@ namespace oox { namespace drawingml {
 IteratorAttr::IteratorAttr( )
 : mnAxis( 0 )
 , mnCnt( -1 )
-, mbHideLastTrans( false )
+, mbHideLastTrans( true )
 , mnPtType( 0 )
 , mnSt( 0 )
 , mnStep( 1 )
@@ -233,7 +233,7 @@ void IteratorAttr::loadFromXAttr( const Reference< 
XFastAttributeList >& xAttr )
 AttributeList attr( xAttr );
 mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
 mnCnt = attr.getInteger( XML_cnt, -1 );
-mbHideLastTrans = attr.getBool( XML_hideLastTrans, false );
+mbHideLastTrans = attr.getBool( XML_hideLastTrans, true );
 mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
 mnSt = attr.getInteger( XML_st, 0 );
 mnStep = attr.getInteger( XML_step, 1 );
diff --git a/oox/source/drawingml/diagram/layoutatomvisitors.cxx 
b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
index a45317f9ffe4..b93c06c6a636 100644
--- a/oox/source/drawingml/diagram/layoutatomvisitors.cxx
+++ b/oox/source/drawingml/diagram/layoutatomvisitors.cxx
@@ -48,10 +48,10 @@ void ShapeCreationVisitor::visit(AlgAtom& rAtom)
 
 void ShapeCreationVisitor::visit(ForEachAtom& rAtom)
 {
-if (rAtom.iterator().mnAxis == XML_followSib)
+if (rAtom.iterator().mbHideLastTrans && rAtom.iterator().mnAxis == 
XML_followSib)
 {
-// If the axis is the follow sibling, then the last atom should not be
-// visited.
+// If last transition is hidden and the axis is the follow sibling,
+// then the last atom should not be visited.
 if (mnCurrIdx + mnCurrStep >= mnCurrCnt)
 return;
 }
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index f163068560ef..33bdf6532966 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -397,6 +397,13 @@ void SdImportTestSmartArt::testChevron()
 
 void SdImportTestSmartArt::testCycle()
 {
+sd::DrawDocShellRef xDocShRef = loadURL(
+
m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-cycle.pptx"), PPTX);
+uno::Reference xGroup(getShapeFromPage(0, 0, xDocShRef), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xGroup.is());
+// 10 children: 5 shapes, 5 connectors
+CPPUNIT_ASSERT_EQUAL(static_cast(10), xGroup->getCount());
+
 //FIXME : so far this only introduce the test document, but the actual 
importer was not fixed yet.
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: include/oox oox/source sd/qa sd/source sw/source

2019-04-08 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/export/drawingml.hxx |5 
 oox/source/export/drawingml.cxx  |  320 +++
 oox/source/token/tokens.txt  |1 
 sd/qa/unit/data/pptx/group.pptx  |binary
 sd/qa/unit/data/pptx/smartart-preserve.pptx  |binary
 sd/qa/unit/export-tests-ooxml2.cxx   |   62 -
 sd/source/filter/eppt/epptooxml.hxx  |6 
 sd/source/filter/eppt/pptx-epptooxml.cxx |   14 +
 sw/source/filter/ww8/docxattributeoutput.cxx |   34 --
 sw/source/filter/ww8/docxattributeoutput.hxx |3 
 sw/source/filter/ww8/docxsdrexport.cxx   |  275 ---
 sw/source/filter/ww8/docxsdrexport.hxx   |5 
 12 files changed, 410 insertions(+), 315 deletions(-)

New commits:
commit aafaf1f55fa413ad49d4556cf7c0a713dd206ae4
Author: Grzegorz Araminowicz 
AuthorDate: Wed Mar 13 10:49:30 2019 +0100
Commit: Miklos Vajna 
CommitDate: Mon Apr 8 10:07:35 2019 +0200

PPTX export: save SmartArt as diagram instead of group of shapes

preserving SmartArt allows editing it in PowerPoint after saving as pptx 
file

* moved common parts for docx and pptx export to oox/drawingml
* fixed export tests that expected shapes on output

Change-Id: I3e70a9f4177bebf5e1671232f4cd0ef0e7212626
Reviewed-on: https://gerrit.libreoffice.org/69598
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index fbcc25fb3db1..b3cdbb3600ba 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -258,7 +258,12 @@ public:
 void WriteShape3DEffects( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet );
 void WriteArtisticEffect( const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet );
 OString WriteWdpPicture( const OUString& rFileId, const 
css::uno::Sequence< sal_Int8 >& rPictureData );
+void WriteDiagram(const css::uno::Reference& 
rXShape, int nDiagramId);
+void writeDiagramRels(const 
css::uno::Sequence>& xRelSeq,
+  const css::uno::Reference& 
xOutStream,
+  const OUString& sGrabBagProperyName, int nDiagramId);
 static bool IsGroupShape( const css::uno::Reference< css::drawing::XShape 
>& rXShape );
+static bool IsDiagram(const css::uno::Reference& 
rXShape);
 sal_Int32 getBulletMarginIndentation (const css::uno::Reference< 
css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, const OUString& 
propName);
 
 static void ResetCounters();
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index b5047b80eb15..1cebeaa84ec1 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -25,10 +25,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -80,7 +82,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -99,6 +107,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2268,6 +2277,31 @@ bool DrawingML::IsGroupShape( const Reference< XShape >& 
rXShape )
 return bRet;
 }
 
+bool DrawingML::IsDiagram(const Reference& rXShape)
+{
+uno::Reference xPropSet(rXShape, uno::UNO_QUERY);
+if (!xPropSet.is())
+return false;
+
+// if the shape doesn't have the InteropGrabBag property, it's not a 
diagram
+uno::Reference xPropSetInfo = 
xPropSet->getPropertySetInfo();
+OUString aName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
+if (!xPropSetInfo->hasPropertyByName(aName))
+return false;
+
+uno::Sequence propList;
+xPropSet->getPropertyValue(aName) >>= propList;
+for (sal_Int32 nProp = 0; nProp < propList.getLength(); ++nProp)
+{
+// if we find any of the diagram components, it's a diagram
+OUString propName = propList[nProp].Name;
+if (propName == "OOXData" || propName == "OOXLayout" || propName == 
"OOXStyle"
+|| propName == "OOXColor" || propName == "OOXDrawing")
+return true;
+}
+return false;
+}
+
 sal_Int32 DrawingML::getBulletMarginIndentation (const Reference< XPropertySet 
>& rXPropSet,sal_Int16 nLevel, const OUString& propName)
 {
 if (nLevel < 0 || !GetProperty(rXPropSet, "NumberingRules"))
@@ -3984,6 +4018,292 @@ OString DrawingML::WriteWdpPicture( const OUString& 
rFileId, const Sequence< sal
 return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
 }
 
+void DrawingML::WriteDiagram(const css::uno::Reference& 
rXShape, int nDiagramId)
+{
+uno::Reference xPropSet(rXShape, uno::UNO_QUERY);
+
+uno::Reference dataDom;
+uno::Reference layoutDom;
+uno::Reference styleDom;
+uno::Reference colorDom;
+uno::Reference drawingDom;
+uno::Sequence> xDataRelSeq;
+uno::Sequence diagramDrawing;
+
+