diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-01-25 11:15:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-01-27 08:54:00 +0000 |
commit | 4fca4a93c688f2233294b76cb39da2b23dd56cef (patch) | |
tree | f370ac1d268746031ee4eaad836a198c6e68280a | |
parent | 5137342893421e4b7ffeb24f6b174aead36a1e76 (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.
(cherry picked from commit cbc84a6599c08e5c79e544212c69c6946d0cdbf0)
Conflicts:
sd/qa/unit/tiledrendering/tiledrendering.cxx
Change-Id: I3a9ba2b99bcaa2e355b6fcdafdd142d4a809bce6
Reviewed-on: https://gerrit.libreoffice.org/33590
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | include/svx/sdr/table/tablecontroller.hxx | 3 | ||||
-rw-r--r-- | include/svx/selectioncontroller.hxx | 4 | ||||
-rw-r--r-- | sd/source/ui/func/futext.cxx | 43 | ||||
-rw-r--r-- | svx/source/svdraw/selectioncontroller.cxx | 4 |
4 files changed, 53 insertions, 1 deletions
diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx index b8cf893c772c..da36f4632202 100644 --- a/include/svx/sdr/table/tablecontroller.hxx +++ b/include/svx/sdr/table/tablecontroller.hxx @@ -97,7 +97,8 @@ public: /// @see sdr::SelectionController::setCursorLogicPosition(). SVX_DLLPRIVATE virtual bool setCursorLogicPosition(const Point& rPosition, bool bPoint) override; - void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos ); + /// @see sdr::SelectionController::getSelectedCells(). + void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos ) override; void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos ); void clearSelection(); void selectAll(); diff --git a/include/svx/selectioncontroller.hxx b/include/svx/selectioncontroller.hxx index 4c4a8e5c6020..d2fb9c4b9964 100644 --- a/include/svx/selectioncontroller.hxx +++ b/include/svx/selectioncontroller.hxx @@ -37,6 +37,8 @@ class Point; namespace sdr { +namespace table { struct CellPos; } + class SVX_DLLPUBLIC SelectionController: public cppu::OWeakObject { public: @@ -74,6 +76,8 @@ public: virtual bool hasSelectedCells() const; /// Allows adjusting the point or mark of the selection to a document coordinate. 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); }; } diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index 3498c40462d9..12d0247857ce 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> @@ -1363,6 +1364,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 ) @@ -1382,8 +1401,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. diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx index 3138f379d307..0fc2d526e1c1 100644 --- a/svx/source/svdraw/selectioncontroller.cxx +++ b/svx/source/svdraw/selectioncontroller.cxx @@ -110,6 +110,10 @@ bool SelectionController::hasSelectedCells() const return false; } +void SelectionController::getSelectedCells(table::CellPos& /*rFirstPos*/, table::CellPos& /*rLastPos*/) +{ +} + bool SelectionController::setCursorLogicPosition(const Point& /*rPosition*/, bool /*bPoint*/) { return false; |