summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2019-04-10 15:13:53 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2019-05-20 10:34:16 +0200
commitc2e30949e0fb7c6a73742450f646e0d8d59d5e4f (patch)
tree593af47a02e181f6ac53be1a3e8668ea08f72a05
parenttdf#42949 Fix IWYU warnings in stoc/ (diff)
downloadcore-c2e30949e0fb7c6a73742450f646e0d8d59d5e4f.tar.gz
core-c2e30949e0fb7c6a73742450f646e0d8d59d5e4f.zip
lok: writer: svg export transformed images
Change-Id: I908a6e01573c35c0641519f4995730af0b033c33 Reviewed-on: https://gerrit.libreoffice.org/70565 Tested-by: Jenkins Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
-rw-r--r--filter/source/svg/svgexport.cxx2
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx36
-rw-r--r--svx/source/svdraw/svdmrkv.cxx37
-rw-r--r--sw/inc/cmdid.h2
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/source/core/draw/dflyobj.cxx13
-rw-r--r--sw/source/core/inc/dflyobj.hxx1
-rw-r--r--sw/source/core/unocore/unoframe.cxx31
-rw-r--r--sw/source/core/unocore/unomap1.cxx1
9 files changed, 95 insertions, 29 deletions
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 817c529f69d0..a674456be182 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -687,7 +687,7 @@ bool SVGFilter::implExportWriterTextGraphic( const Reference< view::XSelectionSu
{
uno::Reference<beans::XPropertySet> xPropertySet(xSelection, uno::UNO_QUERY);
uno::Reference<graphic::XGraphic> xGraphic;
- xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
+ xPropertySet->getPropertyValue("TransformedGraphic") >>= xGraphic;
if (!xGraphic.is())
return false;
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index a35fdc6bf785..8ac4be6fdd2f 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -871,11 +871,11 @@ void SdTiledRenderingTest::testResizeTable()
auto pTableObject = dynamic_cast<sdr::table::SdrTableObj*>(pObject);
CPPUNIT_ASSERT(pTableObject);
- SdrHdlList handleList(nullptr);
- pObject->AddToHdlList(handleList);
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), handleList.GetHdlCount());
- // Take the top left handle
- SdrHdl* pHdl = handleList.GetHdl(0);
+ // Select the table by marking it + starting and ending text edit.
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ pView->SdrBeginTextEdit(pObject);
+ pView->SdrEndTextEdit();
// Remember the original row heights.
uno::Reference<table::XColumnRowRange> xTable(pTableObject->getTable(), uno::UNO_QUERY);
@@ -886,14 +886,15 @@ void SdTiledRenderingTest::testResizeTable()
sal_Int32 nExpectedRow2 = xRow2->getPropertyValue("Size").get<sal_Int32>();
// Resize the upper row, decrease its height by 1 cm.
- pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_START, convertMm100ToTwip(pHdl->GetPos().getX()), convertMm100ToTwip(pHdl->GetPos().getY()));
- pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_END, convertMm100ToTwip(pHdl->GetPos().getX()), convertMm100ToTwip(pHdl->GetPos().getY() + 1000));
+ Point aInnerRowEdge = pObject->GetSnapRect().Center();
+ pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_START, convertMm100ToTwip(aInnerRowEdge.getX()), convertMm100ToTwip(aInnerRowEdge.getY()));
+ pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_END, convertMm100ToTwip(aInnerRowEdge.getX()), convertMm100ToTwip(aInnerRowEdge.getY() - 1000));
// Remember the resized row heights.
sal_Int32 nResizedRow1 = xRow1->getPropertyValue("Size").get<sal_Int32>();
CPPUNIT_ASSERT(nResizedRow1 < nExpectedRow1);
sal_Int32 nResizedRow2 = xRow2->getPropertyValue("Size").get<sal_Int32>();
- CPPUNIT_ASSERT(nResizedRow2 < nExpectedRow2);
+ CPPUNIT_ASSERT_EQUAL(nExpectedRow2, nResizedRow2);
// Now undo the resize.
pXImpressDocument->GetDocShell()->GetUndoManager()->Undo();
@@ -903,7 +904,7 @@ void SdTiledRenderingTest::testResizeTable()
CPPUNIT_ASSERT_EQUAL(nExpectedRow1, nActualRow1);
sal_Int32 nActualRow2 = xRow2->getPropertyValue("Size").get<sal_Int32>();
// Expected was 4000, actual was 4572, i.e. the second row after undo was larger than expected.
- CPPUNIT_ASSERT_DOUBLES_EQUAL(nExpectedRow2, nActualRow2, 1.0);
+ CPPUNIT_ASSERT_EQUAL(nExpectedRow2, nActualRow2);
comphelper::LibreOfficeKit::setActive(false);
}
@@ -918,11 +919,11 @@ void SdTiledRenderingTest::testResizeTableColumn()
auto pTableObject = dynamic_cast<sdr::table::SdrTableObj*>(pObject);
CPPUNIT_ASSERT(pTableObject);
- SdrHdlList handleList(nullptr);
- pObject->AddToHdlList(handleList);
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), handleList.GetHdlCount());
- // Take the top left handle
- SdrHdl* pHdl = handleList.GetHdl(0);
+ // Select the table by marking it + starting and ending text edit.
+ SdrView* pView = pViewShell->GetView();
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ pView->SdrBeginTextEdit(pObject);
+ pView->SdrEndTextEdit();
// Remember the original cell widths.
xmlDocPtr pXmlDoc = parseXmlDump();
@@ -933,15 +934,16 @@ void SdTiledRenderingTest::testResizeTableColumn()
pXmlDoc = nullptr;
// Resize the left column, decrease its width by 1 cm.
- pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_START, convertMm100ToTwip(pHdl->GetPos().getX()), convertMm100ToTwip(pHdl->GetPos().getY()));
- pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_END, convertMm100ToTwip(pHdl->GetPos().getX() + 1000), convertMm100ToTwip(pHdl->GetPos().getY()));
+ Point aInnerRowEdge = pObject->GetSnapRect().Center();
+ pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_START, convertMm100ToTwip(aInnerRowEdge.getX()), convertMm100ToTwip(aInnerRowEdge.getY()));
+ pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_END, convertMm100ToTwip(aInnerRowEdge.getX() - 1000), convertMm100ToTwip(aInnerRowEdge.getY()));
// Remember the resized column widths.
pXmlDoc = parseXmlDump();
sal_Int32 nResizedColumn1 = getXPath(pXmlDoc, aPrefix + "TableLayouter_Layout[1]", "size").toInt32();
CPPUNIT_ASSERT(nResizedColumn1 < nExpectedColumn1);
sal_Int32 nResizedColumn2 = getXPath(pXmlDoc, aPrefix + "TableLayouter_Layout[2]", "size").toInt32();
- CPPUNIT_ASSERT(nResizedColumn2 < nExpectedColumn2);
+ CPPUNIT_ASSERT(nResizedColumn2 > nExpectedColumn2);
xmlFreeDoc(pXmlDoc);
pXmlDoc = nullptr;
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index fa4ea376ae90..3bbf3b4a72ed 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -560,13 +560,10 @@ void SdrMarkView::showMarkHandles()
bool SdrMarkView::ImpIsFrameHandles() const
{
- // There can be multiple mark views, but we're only interested in the one that has a window associated.
- const bool bTiledRendering = comphelper::LibreOfficeKit::isActive() && GetFirstOutputDevice() && GetFirstOutputDevice()->GetOutDevType() == OUTDEV_WINDOW;
-
const size_t nMarkCount=GetMarkedObjectCount();
bool bFrmHdl=nMarkCount>static_cast<size_t>(mnFrameHandlesLimit) || mbForceFrameHandles;
bool bStdDrag=meDragMode==SdrDragMode::Move;
- if (!bTiledRendering && nMarkCount==1 && bStdDrag && bFrmHdl)
+ if (nMarkCount==1 && bStdDrag && bFrmHdl)
{
const SdrObject* pObj=GetMarkedObjectByIndex(0);
if (pObj->GetObjInventor()==SdrInventor::Default)
@@ -648,7 +645,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
bool bSingleTextObjMark=false;
bool bLimitedRotation(false);
- if (!bTiledRendering && nMarkCount==1)
+ if (nMarkCount==1)
{
mpMarkedObj=GetMarkedObjectByIndex(0);
@@ -781,15 +778,33 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
}
if(SfxViewShell* pViewShell = GetSfxViewShell())
{
-
- long nRotAngle(0);
- if(GetMarkedObjectCount())
+ if (GetMarkedObjectCount())
{
- SdrMark* pM = GetSdrMarkByIndex(0);
- SdrObject* pO = pM->GetMarkedSdrObj();
+ SdrObject* pO = mpMarkedObj;
+ long nRotAngle = pO->GetRotateAngle();
+ // true if we are delaing with a RotGrfFlyFrame
+ // (SwVirtFlyDrawObj with a SwGrfNode)
+ bool bWriterGraphic = pO->HasLimitedRotation();
+
+ if (bWriterGraphic)
+ {
+ nRotAngle *= 10;
+ }
- nRotAngle = pO->GetRotateAngle();
sSelection += OString(", ") + OString::number(nRotAngle);
+
+ OString sProperties;
+
+ if (bWriterGraphic)
+ {
+ sProperties = "{ WriterGraphic=true }";
+ }
+
+ if (!sProperties.isEmpty())
+ {
+ sSelection += ", ";
+ sSelection += sProperties;
+ }
}
if (pOtherShell)
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 9e4794dc7c3a..55ec66b1a116 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -608,6 +608,8 @@
#define FN_UNO_VISIBLE_AREA_WIDTH (FN_EXTRA2 + 125)
#define FN_UNO_VISIBLE_AREA_HEIGHT (FN_EXTRA2 + 126)
+#define FN_UNO_TRANSFORMED_GRAPHIC (FN_EXTRA2 + 125)
+
// Area: Help
// Region: Traveling & Selection
#define FN_CHAR_LEFT (FN_SELECTION + 1 ) /* */
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 731c7a719b49..8e03b0bb9c59 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -161,6 +161,7 @@
#define UNO_NAME_DROP_CAP_CHAR_STYLE_NAME "DropCapCharStyleName"
#define UNO_NAME_FILE_LINK "FileLink"
#define UNO_NAME_GRAPHIC "Graphic"
+#define UNO_NAME_TRANSFORMED_GRAPHIC "TransformedGraphic"
#define UNO_NAME_IS_PROTECTED "IsProtected"
#define UNO_NAME_PARA_KEEP_TOGETHER "ParaKeepTogether"
#define UNO_NAME_KEEP_TOGETHER "KeepTogether"
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index dd73a1d13df2..0b510dd767c9 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -1171,6 +1171,19 @@ sal_uInt16 SwVirtFlyDrawObj::getPossibleRotationFromFraphicFrame(Size& rSize) co
return nRetval;
}
+long SwVirtFlyDrawObj::GetRotateAngle() const
+{
+ if(ContainsSwGrfNode())
+ {
+ Size aSize;
+ return getPossibleRotationFromFraphicFrame(aSize);
+ }
+ else
+ {
+ return SdrVirtObj::GetRotateAngle();
+ }
+}
+
SdrObject* SwVirtFlyDrawObj::getFullDragClone() const
{
// call parent
diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx
index c3acae10198e..5ede9007ec24 100644
--- a/sw/source/core/inc/dflyobj.hxx
+++ b/sw/source/core/inc/dflyobj.hxx
@@ -96,6 +96,7 @@ public:
// we treat the size calculation completely on ourself here
virtual const tools::Rectangle& GetCurrentBoundRect() const override;
virtual const tools::Rectangle& GetLastBoundRect() const override;
+ virtual long GetRotateAngle() const override;
virtual void RecalcBoundRect() override;
virtual void RecalcSnapRect() override;
virtual const tools::Rectangle& GetSnapRect() const override;
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 25e1edcf37d5..b9806727394e 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -45,6 +45,7 @@
#include <memory>
#include <utility>
#include <hints.hxx>
+#include <cntfrm.hxx>
#include <doc.hxx>
#include <drawdoc.hxx>
#include <IDocumentUndoRedo.hxx>
@@ -2094,6 +2095,36 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName)
aAny <<= pGrfNode->GetGrf().GetXGraphic();
}
}
+ else if( FN_UNO_TRANSFORMED_GRAPHIC == pEntry->nWID )
+ {
+ const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
+ if(pIdx)
+ {
+ SwNodeIndex aIdx(*pIdx, 1);
+ SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode();
+ if(!pGrfNode)
+ throw uno::RuntimeException();
+
+ SwDoc* pDoc = pFormat->GetDoc();
+ if (pDoc)
+ {
+ const SwEditShell* pEditShell = pDoc->GetEditShell();
+ if (pEditShell)
+ {
+ SwFrame* pCurrFrame = pEditShell->GetCurrFrame(false);
+ GraphicAttr aGraphicAttr;
+ pGrfNode->GetGraphicAttr( aGraphicAttr, pCurrFrame );
+ const GraphicObject aGraphicObj = pGrfNode->GetGrfObj();
+
+ awt::Size aFrameSize = getSize();
+ Size aSize100thmm(aFrameSize.Width, aFrameSize.Height);
+ Size aSize = OutputDevice::LogicToLogic(aSize100thmm, MapMode(MapUnit::Map100thMM), aGraphicObj.GetPrefMapMode());
+ Graphic aGraphic = aGraphicObj.GetTransformedGraphic(aSize, aGraphicObj.GetPrefMapMode(), aGraphicAttr);
+ aAny <<= aGraphic.GetXGraphic();
+ }
+ }
+ }
+ }
else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID)
{
aAny <<= SwStyleNameMapper::GetProgName(pFormat->DerivedFrom()->GetName(), SwGetPoolIdFromName::FrmFmt );
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index 6bb635b0feb2..f5976ca50a4c 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -852,6 +852,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetGraphicPropertyMap(
{ OUString(UNO_NAME_GRAPHIC_FILTER), FN_UNO_GRAPHIC_FILTER, cppu::UnoType<OUString>::get(), 0, 0 },
{ OUString(UNO_NAME_GRAPHIC), FN_UNO_GRAPHIC, cppu::UnoType<css::graphic::XGraphic>::get(), 0, 0 },
{ OUString(UNO_NAME_GRAPHIC_URL), FN_UNO_GRAPHIC_URL, cppu::UnoType<css::uno::Any>::get(), 0, 0 },
+ { OUString(UNO_NAME_TRANSFORMED_GRAPHIC), FN_UNO_TRANSFORMED_GRAPHIC, cppu::UnoType<css::graphic::XGraphic>::get(), 0, 0 },
{ OUString(UNO_NAME_ACTUAL_SIZE), FN_UNO_ACTUAL_SIZE, cppu::UnoType<css::awt::Size>::get(), PropertyAttribute::READONLY, CONVERT_TWIPS},
{ OUString(UNO_NAME_CONTOUR_POLY_POLYGON), FN_PARAM_CONTOUR_PP, cppu::UnoType<css::drawing::PointSequenceSequence>::get(), PropertyAttribute::MAYBEVOID, 0 },
{ OUString(UNO_NAME_IS_PIXEL_CONTOUR), FN_UNO_IS_PIXEL_CONTOUR, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },