[Libreoffice-commits] core.git: cui/source sc/inc sc/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 10 20:07:29 UTC 2019


 cui/source/tabpages/align.cxx         |   13 +++++++++----
 sc/inc/attrib.hxx                     |   14 +++++++++++++-
 sc/inc/globstr.hrc                    |    2 ++
 sc/source/core/data/attrib.cxx        |   20 ++++++++++++++++++++
 sc/source/core/data/docpool.cxx       |    2 +-
 sc/source/filter/excel/xistyle.cxx    |    2 +-
 sc/source/filter/oox/stylesbuffer.cxx |    2 +-
 7 files changed, 47 insertions(+), 8 deletions(-)

New commits:
commit ca19ae6e0595f8b69fc4929072636bf10ca3027e
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Dec 10 15:59:43 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Dec 10 21:06:28 2019 +0100

    Related: tdf#129300 add ScShrinkToFitCell to provide a description
    
    Change-Id: I628562f1013825e5ba3c0daaf5ee6b098616b6d0
    Reviewed-on: https://gerrit.libreoffice.org/84866
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index 940f64a1aca3..7e68685beee2 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -237,9 +237,9 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet )
         const SdrAngleItem* pAngleItem = static_cast<const SdrAngleItem*>(GetOldItem(
                                             *rSet, SID_ATTR_ALIGN_DEGREES));
         assert(pAngleItem);
-        std::unique_ptr<SdrAngleItem> pNewAngletem(static_cast<SdrAngleItem*>(pAngleItem->Clone()));
-        pNewAngletem->SetValue(m_aCtrlDial.GetRotation());
-        rSet->Put(*pNewAngletem);
+        std::unique_ptr<SdrAngleItem> pNewAngleItem(static_cast<SdrAngleItem*>(pAngleItem->Clone()));
+        pNewAngleItem->SetValue(m_aCtrlDial.GetRotation());
+        rSet->Put(*pNewAngleItem);
         bChanged = true;
     }
 
@@ -289,7 +289,12 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet )
 
     if (m_xBtnShrink->get_state_changed_from_saved())
     {
-        rSet->Put(SfxBoolItem(GetWhich(SID_ATTR_ALIGN_SHRINKTOFIT), m_xBtnShrink->get_active()));
+        const SfxBoolItem* pShrinkItem = static_cast<const SfxBoolItem*>(GetOldItem(
+                                            *rSet, SID_ATTR_ALIGN_SHRINKTOFIT));
+        assert(pShrinkItem);
+        std::unique_ptr<SfxBoolItem> pNewShrinkItem(static_cast<SfxBoolItem*>(pShrinkItem->Clone()));
+        pNewShrinkItem->SetValue(m_xBtnShrink->get_active());
+        rSet->Put(*pNewShrinkItem);
         bChanged = true;
     }
 
diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx
index 4865e1594250..a19a3ec0952d 100644
--- a/sc/inc/attrib.hxx
+++ b/sc/inc/attrib.hxx
@@ -294,7 +294,19 @@ public:
     virtual bool GetPresentation( SfxItemPresentation ePresentation,
                                   MapUnit, MapUnit,
                                   OUString& rText,
-                                  const IntlWrapper& ) const override;
+                                  const IntlWrapper& rIntl) const override;
+};
+
+class SC_DLLPUBLIC ScShrinkToFitCell final : public SfxBoolItem
+{
+public:
+    ScShrinkToFitCell(bool bShrink = false);
+    virtual ScShrinkToFitCell* Clone(SfxItemPool *pPool = nullptr) const override;
+    virtual bool GetPresentation(SfxItemPresentation ePres,
+                                 MapUnit eCoreMetric,
+                                 MapUnit ePresMetric,
+                                 OUString &rText,
+                                 const IntlWrapper& rIntl) const override;
 };
 
 #endif
diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index d9b92b5c7b6d..4582d832cfb2 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -515,6 +515,8 @@
 #define STR_ERR_NAME_INVALID_CELL_REF           NC_("STR_ERR_NAME_INVALID_CELL_REF", "Invalid name. Reference to a cell, or a range of cells not allowed.")
 #define STR_ERR_LONG_LINK_FORMULA_NEEDING_CHECK NC_("STR_ERR_LONG_LINK_FORMULA_NEEDING_CHECK", "External content disabled.")
 #define STR_TEXTORIENTANGLE                     NC_("STR_TEXTORIENTANGLE", "Text orientation angle")
+#define STR_SHRINKTOFITCELL_ON                  NC_("STR_SHRINKTOFITCELL_ON", "Shrink to fit cell: On")
+#define STR_SHRINKTOFITCELL_OFF                 NC_("STR_SHRINKTOFITCELL_OFF", "Shrink to fit cell: Off")
 
 #endif
 
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index bc2271fb56e6..4cbd076b4423 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -748,4 +748,24 @@ bool ScRotateValueItem::GetPresentation(SfxItemPresentation ePresentation,
     return bRet;
 }
 
+ScShrinkToFitCell::ScShrinkToFitCell(bool bShrink)
+    : SfxBoolItem(ATTR_SHRINKTOFIT, bShrink)
+{
+}
+
+ScShrinkToFitCell* ScShrinkToFitCell::Clone(SfxItemPool*) const
+{
+    return new ScShrinkToFitCell(GetValue());
+}
+
+bool ScShrinkToFitCell::GetPresentation(SfxItemPresentation,
+                                        MapUnit, MapUnit,
+                                        OUString& rText,
+                                        const IntlWrapper&) const
+{
+    const char* pId = GetValue() ? STR_SHRINKTOFITCELL_ON : STR_SHRINKTOFITCELL_OFF;
+    rText = ScResId(pId);
+    return true;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index db067aabb26c..d5d6918587ed 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -258,7 +258,7 @@ ScDocumentPool::ScDocumentPool()
     //  The value from the page style is set as DefaultHorizontalTextDirection for the EditEngine.
     mvPoolDefaults[ ATTR_WRITINGDIR      - ATTR_STARTINDEX ] = new SvxFrameDirectionItem( SvxFrameDirection::Environment, ATTR_WRITINGDIR );
     mvPoolDefaults[ ATTR_LINEBREAK       - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_LINEBREAK );
-    mvPoolDefaults[ ATTR_SHRINKTOFIT     - ATTR_STARTINDEX ] = new SfxBoolItem( ATTR_SHRINKTOFIT );
+    mvPoolDefaults[ ATTR_SHRINKTOFIT     - ATTR_STARTINDEX ] = new ScShrinkToFitCell();
     mvPoolDefaults[ ATTR_BORDER_TLBR     - ATTR_STARTINDEX ] = new SvxLineItem( ATTR_BORDER_TLBR );
     mvPoolDefaults[ ATTR_BORDER_BLTR     - ATTR_STARTINDEX ] = new SvxLineItem( ATTR_BORDER_BLTR );
     mvPoolDefaults[ ATTR_MARGIN          - ATTR_STARTINDEX ] = new SvxMarginItem( ATTR_MARGIN );
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index 014eb81ad699..52f5d0fffca1 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -825,7 +825,7 @@ void XclImpCellAlign::FillToItemSet( SfxItemSet& rItemSet, const XclImpFont* pFo
     ScfTools::PutItem( rItemSet, SfxUInt16Item( ATTR_INDENT, nScIndent ), bSkipPoolDefs );
 
     // shrink to fit
-    ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_SHRINKTOFIT, mbShrink ), bSkipPoolDefs );
+    ScfTools::PutItem( rItemSet, ScShrinkToFitCell( mbShrink ), bSkipPoolDefs );
 
     // text orientation/rotation (BIFF2-BIFF7 sets mnOrient)
     sal_uInt8 nXclRot = (mnOrient == EXC_ORIENT_NONE) ? mnRotation : XclTools::GetXclRotFromOrient( mnOrient );
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 48df2d7bccb4..e600c7f7ef33 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -1302,7 +1302,7 @@ void Alignment::fillToItemSet( SfxItemSet& rItemSet, bool bSkipPoolDefs ) const
     ScfTools::PutItem( rItemSet, SfxUInt16Item( ATTR_INDENT, maApiData.mnIndent ), bSkipPoolDefs );
     // line wrap
     ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_LINEBREAK, maApiData.mbWrapText ), bSkipPoolDefs );
-    ScfTools::PutItem( rItemSet, SfxBoolItem( ATTR_SHRINKTOFIT, maApiData.mbShrink ), bSkipPoolDefs );
+    ScfTools::PutItem( rItemSet, ScShrinkToFitCell( maApiData.mbShrink ), bSkipPoolDefs );
 }
 
 ProtectionModel::ProtectionModel() :


More information about the Libreoffice-commits mailing list