diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2018-02-27 16:56:44 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-03-13 00:23:40 +0100 |
commit | 4f29ce6a67b81e7f28e1c86d60ff15ec1d180661 (patch) | |
tree | 1b6095f1c1805fe084ac106c52d3748f9fce8783 /sc/inc | |
parent | a1a60f79c6ffccfd49034a6251031e1f9a0c63a0 (diff) |
tdf#114552 Improve image scaling in Calc
When anchor type "To cell (resize with cell)" is selected, we do now::
1. Consider aspect ratio when scaling graphic objects with cell
This only works when the image fits into one cell.
When the image is over multiple cells, we need to respect the end
anchor, so we need to keep the existing behavior (no aspect ratio considered).
2. Always scale images if anchor type is "resize with cell"
Previously it would only scale if the image is larger than the cell.
Now we always enlarge the image if the cell is enlarged, and shrink
the image if the cell is shrinked _and_ the image no longer fits
into the shrinked cell
Change-Id: Ib2a24819d0058bcebce73ea97bbf70a963d74584
Reviewed-on: https://gerrit.libreoffice.org/50451
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/drwlayer.hxx | 1 | ||||
-rw-r--r-- | sc/inc/userdat.hxx | 21 |
2 files changed, 21 insertions, 1 deletions
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx index 123463855a25..5f695160cc42 100644 --- a/sc/inc/drwlayer.hxx +++ b/sc/inc/drwlayer.hxx @@ -184,6 +184,7 @@ public: static void SetCellAnchoredFromPosition( SdrObject &rObj, const ScDocument &rDoc, SCTAB nTab, bool bResizeWithCell ); static void UpdateCellAnchorFromPositionEnd( const SdrObject &rObj, ScDrawObjData &rAnchor, const ScDocument &rDoc, SCTAB nTab, bool bUseLogicRect = true ); static ScAnchorType GetAnchorType( const SdrObject& ); + std::vector<SdrObject*> GetObjectsAnchoredToRows(SCTAB nTab, SCROW nStartRow, SCROW nEndRow); std::map<SCROW, std::vector<SdrObject*>> GetObjectsAnchoredToRange(SCTAB nTab, SCCOL nCol, SCROW nStartRow, SCROW nEndRow); bool HasObjectsAnchoredInRange(ScRange& rRange); void MoveObject(SdrObject* pObj, ScAddress& rNewPosition); diff --git a/sc/inc/userdat.hxx b/sc/inc/userdat.hxx index fd903dfc1010..04c6893faded 100644 --- a/sc/inc/userdat.hxx +++ b/sc/inc/userdat.hxx @@ -25,6 +25,7 @@ #include <svtools/imap.hxx> #include "global.hxx" #include "address.hxx" +#include "drwlayer.hxx" // Object IDs for UserData #define SC_UD_OBJDATA 1 @@ -41,13 +42,31 @@ public: Point maStartOffset; Point maEndOffset; Type meType; - tools::Rectangle maLastRect; bool mbResizeWithCell = false; + bool mbWasInHiddenRow = false; explicit ScDrawObjData(); + tools::Rectangle getShapeRect() { return maShapeRect; }; + tools::Rectangle getLastCellRect() { return maLastCellRect; }; + void setShapeRect(const ScDocument* rDoc, tools::Rectangle rNewRect, bool bIsVisible=true) + { + // bIsVisible should be false when the object is hidden obviously. we dont want to store the old cell rect in that + // case because it will have height=0 + if (maStart.IsValid() && mbResizeWithCell && bIsVisible) + maLastCellRect = ScDrawLayer::GetCellRect(*rDoc, maStart, true); + maShapeRect = rNewRect; + mbWasInHiddenRow = !bIsVisible; + }; + private: virtual ScDrawObjData* Clone( SdrObject* pObj ) const override; + + // Stores the last cell rect this shape was anchored to. + // Needed when the cell is resized to resize the image accordingly. + tools::Rectangle maLastCellRect; + // Stores the rect of the shape to which this ScDrawObjData belongs. + tools::Rectangle maShapeRect; }; class ScIMapInfo : public SdrObjUserData |