include/svx/sdr/table/tablecontroller.hxx | 3 + include/svx/selectioncontroller.hxx | 3 + sd/qa/unit/tiledrendering/data/tdf105502.odp |binary sd/qa/unit/tiledrendering/tiledrendering.cxx | 12 +++++-- sd/source/ui/func/futext.cxx | 41 +----------------------- svx/source/svdraw/selectioncontroller.cxx | 6 +++ svx/source/table/tablecontroller.cxx | 46 +++++++++++++++++++++++++++ 7 files changed, 70 insertions(+), 41 deletions(-)
New commits: commit a8a34468f9988ef7633a7b63f825cc484b5dc60f Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Sat Oct 28 18:02:46 2017 +0200 tdf#110357: Impress table looses selection when clicking on ... ... Increase \ decrease font button Change-Id: I52cf853de01b06c6c9db9779f15174f895789da8 Reviewed-on: https://gerrit.libreoffice.org/43962 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/50049 Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx index d08f5abc0ceb..1b8d41013325 100644 --- a/include/svx/sdr/table/tablecontroller.hxx +++ b/include/svx/sdr/table/tablecontroller.hxx @@ -100,6 +100,9 @@ public: /// @see sdr::SelectionController::getSelectedCells(). void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos ) override; void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos ); + + virtual bool ChangeFontSize(bool bGrow, const FontList* pFontList) override; + void clearSelection(); void selectAll(); diff --git a/include/svx/selectioncontroller.hxx b/include/svx/selectioncontroller.hxx index d2fb9c4b9964..7510a830e645 100644 --- a/include/svx/selectioncontroller.hxx +++ b/include/svx/selectioncontroller.hxx @@ -33,6 +33,7 @@ class SfxStyleSheet; class SdrPage; class SdrModel; class Point; +class FontList; namespace sdr { @@ -78,6 +79,8 @@ public: virtual bool setCursorLogicPosition(const Point& rPosition, bool bPoint); /// Get the position of the first and the last selected cell. virtual void getSelectedCells(table::CellPos& rFirstPos, table::CellPos& rLastPos); + /// Changes the font (grow/shrink) according to the input parameters. + virtual bool ChangeFontSize(bool bGrow, const FontList* pFontList); }; } diff --git a/sd/qa/unit/tiledrendering/data/tdf105502.odp b/sd/qa/unit/tiledrendering/data/tdf105502.odp index 6fe818090c8b..2150f1152ba7 100644 Binary files a/sd/qa/unit/tiledrendering/data/tdf105502.odp and b/sd/qa/unit/tiledrendering/data/tdf105502.odp differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 721efa9be498..34ff527549df 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1590,13 +1590,21 @@ void SdTiledRenderingTest::testTdf105502() // 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 nA1Height = getXPath(pXmlDoc, "//Cell[1]/SdrText/OutlinerParaObject/EditTextObject/ContentInfo/SfxItemSet/SvxFontHeightItem[1]", "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); + // Check that selection remains the same + CPPUNIT_ASSERT(xSelectionController->hasSelectedCells()); + 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); + + xmlFreeDoc(pXmlDoc); comphelper::LibreOfficeKit::setActive(false); } diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index 96f595c6a12b..090b590c003f 100644 --- a/sd/source/ui/func/futext.cxx +++ b/sd/source/ui/func/futext.cxx @@ -1361,24 +1361,6 @@ 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 ) @@ -1399,31 +1381,12 @@ void FuText::ChangeFontSize( bool bGrow, OutlinerView* pOLV, const FontList* pFo 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()) + if (xSelectionController.is() && xSelectionController->ChangeFontSize(bGrow, pFontList)) { - // 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); + continue; } 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. diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx index 0fc2d526e1c1..e8e6383e3a8c 100644 --- a/svx/source/svdraw/selectioncontroller.cxx +++ b/svx/source/svdraw/selectioncontroller.cxx @@ -119,6 +119,12 @@ bool SelectionController::setCursorLogicPosition(const Point& /*rPosition*/, boo return false; } + +bool SelectionController::ChangeFontSize(bool /*bGrow*/, const FontList* /*pFontList*/) +{ + return false; +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index 6921f1d4190c..49399815ee93 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -73,6 +73,7 @@ #include <cppuhelper/implbase.hxx> #include <comphelper/lok.hxx> #include <sfx2/viewsh.hxx> +#include <editeng/editview.hxx> using ::editeng::SvxBorderLine; using namespace sdr::table; @@ -2030,6 +2031,51 @@ void SvxTableController::setSelectedCells( const CellPos& rStart, const CellPos& } +bool SvxTableController::ChangeFontSize(bool bGrow, const FontList* pFontList) +{ + if (mxTable.is()) + { + if (mpView->IsTextEdit()) + return true; + + CellPos aStart, aEnd; + if(hasSelectedCells()) + { + getSelectedCells(aStart, aEnd); + } + else + { + aStart.mnRow = 0; + aStart.mnCol = 0; + aEnd.mnRow = mxTable->getRowCount() - 1; + aEnd.mnCol = mxTable->getColumnCount() - 1; + } + + for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++) + { + for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++) + { + CellRef xCell(dynamic_cast< Cell* >(mxTable->getCellByPosition(nCol, nRow).get())); + if (xCell.is()) + { + if (mpModel && mpModel->IsUndoEnabled()) + xCell->AddUndo(); + + SfxItemSet aCellSet(xCell->GetItemSet()); + if (EditView::ChangeFontSize(bGrow, aCellSet, pFontList)) + { + xCell->SetMergedItemSetAndBroadcast(aCellSet, false); + } + } + } + } + UpdateTableShape(); + return true; + } + return false; +} + + void SvxTableController::UpdateSelection( const CellPos& rPos ) { maCursorLastPos = rPos; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits