summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-01-25 11:15:46 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-01-25 14:38:53 +0000
commitcbc84a6599c08e5c79e544212c69c6946d0cdbf0 (patch)
tree3e12052a05d30fff0e75075384048b85a32f03ae /sd
parent6310fa8a70db81334b710b06377e20b4ecb378da (diff)
tdf#105502 sd increase font size: handle table selection
In part of a table shape is selected, then only operate on the selected cells, not on all of them. Change-Id: I3a9ba2b99bcaa2e355b6fcdafdd142d4a809bce6 Reviewed-on: https://gerrit.libreoffice.org/33524 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/tiledrendering/data/tdf105502.odpbin0 -> 11376 bytes
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx53
-rw-r--r--sd/source/ui/func/futext.cxx43
3 files changed, 96 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/data/tdf105502.odp b/sd/qa/unit/tiledrendering/data/tdf105502.odp
new file mode 100644
index 000000000000..6fe818090c8b
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/data/tdf105502.odp
Binary files differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 65079fc84bf9..cbb8703b30be 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -42,6 +42,8 @@
#include <unomodel.hxx>
#include <drawdoc.hxx>
#include <undo/undomanager.hxx>
+#include <sfx2/request.hxx>
+#include <svx/svxids.hrc>
using namespace css;
@@ -84,6 +86,7 @@ public:
void testTdf103083();
void testTdf104405();
void testTdf81754();
+ void testTdf105502();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -116,6 +119,7 @@ public:
CPPUNIT_TEST(testTdf103083);
CPPUNIT_TEST(testTdf104405);
CPPUNIT_TEST(testTdf81754);
+ CPPUNIT_TEST(testTdf105502);
CPPUNIT_TEST_SUITE_END();
@@ -1505,6 +1509,55 @@ void SdTiledRenderingTest::testTdf81754()
xDocShRef->DoClose();
}
+void SdTiledRenderingTest::testTdf105502()
+{
+ // Load the document.
+ comphelper::LibreOfficeKit::setActive();
+ SdXImpressDocument* pXImpressDocument = createDoc("tdf105502.odp");
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ sd::Window* pWindow = pViewShell->GetActiveWindow();
+ CPPUNIT_ASSERT(pWindow);
+ SdPage* pActualPage = pViewShell->GetActualPage();
+ SdrObject* pObject = pActualPage->GetObj(0);
+ auto pTableObject = dynamic_cast<sdr::table::SdrTableObj*>(pObject);
+ CPPUNIT_ASSERT(pTableObject);
+
+ // Select the first row.
+ sd::View* pView = pViewShell->GetView();
+ pView->MarkObj(pObject, pView->GetSdrPageView());
+ pView->SdrBeginTextEdit(pObject);
+ rtl::Reference<sdr::SelectionController> xSelectionController(pView->getSelectionController());
+ CPPUNIT_ASSERT(xSelectionController.is());
+ SfxRequest aRequest(pViewShell->GetViewFrame(), SID_TABLE_SELECT_ROW);
+ xSelectionController->Execute(aRequest);
+
+ // Assert that the A1:B1 selection succeeded.
+ CPPUNIT_ASSERT(xSelectionController->hasSelectedCells());
+ sdr::table::CellPos aFirstCell;
+ sdr::table::CellPos aLastCell;
+ xSelectionController->getSelectedCells(aFirstCell, aLastCell);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aFirstCell.mnCol);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aFirstCell.mnRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aLastCell.mnCol);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aLastCell.mnRow);
+
+ // Grow font size for the selection.
+ comphelper::dispatchCommand(".uno:Grow", {});
+ Scheduler::ProcessEventsToIdle();
+
+ // Assert that the selected A1 has now a larger font than the unselected
+ // A2.
+ xmlDocPtr pXmlDoc = parseXmlDump();
+ sal_Int32 nA1Height = getXPath(pXmlDoc, "//Cell[1]/SdrText/OutlinerParaObject/EditTextObject/ContentInfo/attribs[1]/SvxFontHeightItem", "height").toInt32();
+ sal_Int32 nA2Height = getXPath(pXmlDoc, "//Cell[3]/SdrText/OutlinerParaObject/EditTextObject/ContentInfo/attribs[1]/SvxFontHeightItem", "height").toInt32();
+ // This failed when FuText::ChangeFontSize() never did "continue" in the
+ // text loop, instead of doing so depending on what IsInSelection() returns.
+ CPPUNIT_ASSERT(nA1Height > nA2Height);
+ xmlFreeDoc(pXmlDoc);
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx
index 17aa2141e8bf..ff426e26b566 100644
--- a/sd/source/ui/func/futext.cxx
+++ b/sd/source/ui/func/futext.cxx
@@ -40,6 +40,7 @@
#include <sfx2/request.hxx>
#include <editeng/editeng.hxx>
#include <svx/svdoutl.hxx>
+#include <svx/svdotable.hxx>
#include <svx/svxids.hrc>
#include <sfx2/docfile.hxx>
#include <comphelper/processfactory.hxx>
@@ -1358,6 +1359,24 @@ bool FuText::cancel()
}
}
+/// Is rCell covered by the rFirst - rLast selection?
+static bool IsInSelection(const sdr::table::CellPos& rFirst, const sdr::table::CellPos& rLast, sdr::table::CellPos& rCell)
+{
+ if (rCell.mnCol < rFirst.mnCol)
+ return false;
+
+ if (rCell.mnCol > rLast.mnCol)
+ return false;
+
+ if (rCell.mnRow < rFirst.mnRow)
+ return false;
+
+ if (rCell.mnRow > rLast.mnRow)
+ return false;
+
+ return true;
+}
+
void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFontList, ::sd::View* pView )
{
if( !pFontList || !pView )
@@ -1377,8 +1396,32 @@ void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFo
SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( rMarkList.GetMark(nMark)->GetMarkedSdrObj() );
if( pTextObj )
{
+ rtl::Reference<sdr::SelectionController> xSelectionController(pView->getSelectionController());
+ sdr::table::CellPos aFirstCell;
+ sdr::table::CellPos aLastCell;
+ sdr::table::SdrTableObj* pTableObject = nullptr;
+ if (xSelectionController.is() && xSelectionController->hasSelectedCells())
+ {
+ // This is a table object, and one or more of its cells are
+ // selected.
+ xSelectionController->getSelectedCells(aFirstCell, aLastCell);
+ pTableObject = dynamic_cast<sdr::table::SdrTableObj*>(pTextObj);
+ }
for( sal_Int32 nText = 0; nText < pTextObj->getTextCount(); nText++ )
{
+ if (pTableObject)
+ {
+ sal_Int32 nColCount = pTableObject->getColumnCount();
+ if (nColCount > 0)
+ {
+ sdr::table::CellPos aPos(nText % nColCount, nText / nColCount);
+ if (!IsInSelection(aFirstCell, aLastCell, aPos))
+ // There is a selection, but this cell is not
+ // part of it: don't change font size.
+ continue;
+ }
+ }
+
pTextObj->setActiveText( nText );
// Put text object into edit mode.