cui/Library_cui.mk                       |    1 
 cui/source/tabpages/swpossizetabpage.cxx |   18 ++++++---
 include/item/base/ItemSet.hxx            |   60 +++++++++++++++++++++++++++++++
 item/source/base/ItemSet.cxx             |   19 +++++++++
 svl/source/items/itemset.cxx             |   10 +++++
 sw/Library_sw.mk                         |    1 
 sw/source/uibase/shells/drwbassh.cxx     |   21 +++++++---
 7 files changed, 118 insertions(+), 12 deletions(-)

New commits:
commit 09ef433f3ea8ab803492d4c24970e301d02fa700
Author:     Armin Le Grand <armin.le.gr...@me.com>
AuthorDate: Fri Apr 5 14:33:26 2019 +0200
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Fri Apr 5 14:33:26 2019 +0200

    WIP: Started SfxInt16Item replacement
    
    First replace SID_ATTR_TRANSFORM_ANCHOR by adding/using
    a slot for it and replacing usages. Slot is used since
    it allows using existing typed items as Item::CntInt16
    as key/value pair with an ID
    
    Change-Id: Ie6c1e5dea6dac5afb5b2cc4ad9799464f860d5f0

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index 8ede124d16be..488335bea9f9 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -59,6 +59,7 @@ $(eval $(call gb_Library_use_libraries,cui,\
     ucbhelper \
     utl \
     vcl \
+    item \
 ))
 
 $(eval $(call gb_Library_use_externals,cui,\
diff --git a/cui/source/tabpages/swpossizetabpage.cxx 
b/cui/source/tabpages/swpossizetabpage.cxx
index b2c159dda940..2c81c13b124c 100644
--- a/cui/source/tabpages/swpossizetabpage.cxx
+++ b/cui/source/tabpages/swpossizetabpage.cxx
@@ -34,6 +34,10 @@
 #include <com/sun/star/text/RelOrientation.hpp>
 #include <svx/dialogs.hrc>
 
+// I2TM
+#include <item/simple/CntInt16.hxx>
+// ~I2TM
+
 using namespace ::com::sun::star::text;
 
 #define SwFPos SvxSwFramePosString
@@ -746,7 +750,9 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet)
     bool bModified = false;
     if(bAnchorChanged)
     {
-        rSet->Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, 
static_cast<sal_Int16>(nAnchor)));
+        // I2TM
+        rSet->slotSet().SetSlot(SID_ATTR_TRANSFORM_ANCHOR, 
Item::CntInt16::Create(static_cast<sal_Int16>(nAnchor)));
+        // ~I2TM
         bModified = true;
     }
     if (m_xPositionCB->get_state_changed_from_saved())
@@ -890,12 +896,14 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet)
 
 void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet)
 {
-    const SfxPoolItem* pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_ANCHOR );
     bool bInvalidateAnchor = false;
     RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA;
-    if(pItem)
+
+    // I2TM
+    if(const auto Slot(rSet->slotSet().GetSlot<const 
Item::CntInt16>(SID_ATTR_TRANSFORM_ANCHOR)); Slot)
     {
-        nAnchorType = static_cast<RndStdIds>(static_cast<const 
SfxInt16Item*>(pItem)->GetValue());
+        nAnchorType = static_cast<RndStdIds>(Slot->GetValue());
+        // I2TM
         switch(nAnchorType)
         {
             case RndStdIds::FLY_AT_PAGE:   m_xToPageRB->set_active(true);  
break;
@@ -920,7 +928,7 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet)
         m_xToFrameRB->set_sensitive( false );
     }
 
-    pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_POS );
+    const SfxPoolItem* pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_PROTECT_POS 
);
     if (pItem)
     {
         bool bProtected = static_cast<const SfxBoolItem*>(pItem)->GetValue();
diff --git a/include/item/base/ItemSet.hxx b/include/item/base/ItemSet.hxx
index ed4e03176963..f2d42ef28247 100644
--- a/include/item/base/ItemSet.hxx
+++ b/include/item/base/ItemSet.hxx
@@ -87,6 +87,64 @@
 // static const ::sal_Int16 UNKNOWN = (sal_Int16)0;
 //
 ///////////////////////////////////////////////////////////////////////////////
+//
+// SfxItemSet::PutExtended usages:
+// void                        PutExtended( const SfxItemSet&,
+//                                          SfxItemState eDontCareAs,
+//                                          SfxItemState eDefaultAs );
+//
+//     rDestSet.PutExtended( rSourceSet, SfxItemState::DONTCARE, 
SfxItemState::DEFAULT );
+//             aDestSub.PutExtended( rSrcSub, SfxItemState::DONTCARE, 
SfxItemState::DEFAULT );
+//             aDestSub.PutExtended( rSrcSub, SfxItemState::DONTCARE, 
SfxItemState::DEFAULT );
+//     pStyles[i].pDest->GetItemSet().PutExtended(
+//         pStyles[i].pSource->GetItemSet(), SfxItemState::DONTCARE, 
SfxItemState::DEFAULT);
+// aSetItem.GetItemSet().PutExtended( rCoreSet, SfxItemState::DONTCARE, 
SfxItemState::SET );
+//    
pFound[i].pDest->GetItemSet().PutExtended(pFound[i].pSource->GetItemSet(), 
SfxItemState::DONTCARE, SfxItemState::DEFAULT);
+//
+// -> all eDontCareAs -> SfxItemState::DONTCARE -> Not needed
+// -> only one eDefaultAs different from SfxItemState::DEFAULT
+//      -> check ScViewUtil::PutItemScript is this is needed 
(sc\source\ui\view\viewutil.cxx)
+//
+// SvxScriptSetItem aSetItem( rPool.GetSlotId(nWhichId), rPool );
+// SvxScriptSetItem::SvxScriptSetItem( sal_uInt16 nSlotId, SfxItemPool& rPool )
+//     : SfxSetItem( nSlotId, std::make_unique<SfxItemSet>( rPool,
+//                         svl::Items<SID_ATTR_CHAR_FONT, 
SID_ATTR_CHAR_FONT>{} ))
+// {
+//     sal_uInt16 nLatin, nAsian, nComplex;
+//     GetWhichIds( nLatin, nAsian, nComplex );
+//     GetItemSet().MergeRange( nLatin, nLatin );
+//     GetItemSet().MergeRange( nAsian, nAsian );
+//     GetItemSet().MergeRange( nComplex, nComplex );
+// }
+//
+// -> default from pool from source-ItemSet is hard set as Item
+// -> since this *is* the default, sould not be needed for new mechanism (?)
+//
+// case SID_ATTR_CHAR_FONT:
+//     rLatin = SID_ATTR_CHAR_FONT;
+//     rAsian = SID_ATTR_CHAR_CJK_FONT;
+//     rComplex = SID_ATTR_CHAR_CTL_FONT;
+//
+// -> would be needed if ::SET state is checked for these, e.g. 
SID_ATTR_CHAR_CJK_FONT
+//
+// //get the font from itemset
+// SfxItemState eState = _pPage->GetItemSet().GetItemState( _nFontWhich );
+// if ( eState >= SfxItemState::DEFAULT )
+//
+// -> SfxItemState::DEFAULT and SfxItemState::SET are handled equal
+// but:
+//
+// nSlot = SID_ATTR_CHAR_CJK_FONT;
+// nWhich = GetWhich( nSlot );
+// if ( !bChanged && pExampleSet &&
+//      pExampleSet->GetItemState( nWhich, false, &pItem ) == 
SfxItemState::SET &&
+//      static_cast<const SvxFontItem*>(pItem)->GetFamilyName() != 
aFontItem.GetFamilyName() )
+//     bChanged = true;
+//
+// -> here used with SfxItemState::SET, but maybe OK -> needs testing (!)
+//
+///////////////////////////////////////////////////////////////////////////////
+
 
 namespace Item
 {
@@ -292,6 +350,8 @@ namespace Item
 
             return (0 != m_aItems.erase(hash_code));
         }
+
+        void SetItems(const ItemSet& rSource, bool bDontCareToDefault = true);
     };
 } // end of namespace Item
 
diff --git a/item/source/base/ItemSet.cxx b/item/source/base/ItemSet.cxx
index 69022dbf23ba..e2a2e6b8b547 100644
--- a/item/source/base/ItemSet.cxx
+++ b/item/source/base/ItemSet.cxx
@@ -78,6 +78,25 @@ namespace Item
             m_aItems[hash_code] = rItem;
         }
     }
+
+    void ItemSet::SetItems(const ItemSet& rSource, bool bDontCareToDefault)
+    {
+        for(const auto& candidate : rSource.m_aItems)
+        {
+            assert(candidate.second && "empty ItemBase::SharedPtr not allowed 
- and should be unable to be created (!)");
+
+            if(bDontCareToDefault && candidate.second.get() == 
getInvalidateItem().get())
+            {
+                // SfxItemState::DONTCARE
+                m_aItems.erase(candidate.first);
+            }
+            else
+            {
+                // SfxItemState::SET || SfxItemState::DISABLED
+                m_aItems.insert(candidate);
+            }
+        }
+    }
 } // end of namespace Item
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 7bd7530b6015..a01ed32d583e 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -183,6 +183,10 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet )
     : m_pPool( rASet.m_pPool )
     , m_pParent( rASet.m_pParent )
     , m_nCount( rASet.m_nCount )
+// I2TM copy shared ptrs - no clone
+    , m_aItemSetSharedPtr(rASet.m_aItemSetSharedPtr)
+    , m_aSlotSetSharedPtr(rASet.m_aSlotSetSharedPtr)
+// ~I2TM
 {
     // Calculate the attribute count
     sal_uInt16 nCnt = 0;
@@ -537,6 +541,12 @@ bool SfxItemSet::Put( const SfxItemSet& rSet, bool 
bInvalidAsDefault )
             pPtr += 2;
         }
     }
+
+// I2TM
+    itemSet().SetItems(rSet.itemSet(), bInvalidAsDefault);
+    slotSet().SetSlots(rSet.slotSet());
+// ~I2TM
+
     return bRet;
 }
 
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 1cd8d8cb1613..0280411164dc 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -83,6 +83,7 @@ $(eval $(call gb_Library_use_libraries,sw,\
     vcl \
     xmlreader \
     xo \
+    item \
 ))
 
 $(eval $(call gb_Library_use_externals,sw,\
diff --git a/sw/source/uibase/shells/drwbassh.cxx 
b/sw/source/uibase/shells/drwbassh.cxx
index 894f1d404f4e..a354fd3b8c18 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -62,6 +62,10 @@
 #include <memory>
 #include <fmtfollowtextflow.hxx>
 
+// I2TM
+#include <item/simple/CntInt16.hxx>
+// ~I2TM
+
 using namespace ::com::sun::star;
 
 SFX_IMPL_SUPERCLASS_INTERFACE(SwDrawBaseShell, SwBaseShell)
@@ -213,7 +217,9 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq)
                         if (bCaption)
                             pSdrView->GetAttributes( aSet );
 
-                        aSet.Put(SfxInt16Item(SID_ATTR_TRANSFORM_ANCHOR, 
static_cast<sal_Int16>(nAnchor)));
+                        // I2TM
+                        aSet.slotSet().SetSlot(SID_ATTR_TRANSFORM_ANCHOR, 
Item::CntInt16::Create(static_cast<sal_Int16>(nAnchor)));
+                        // ~I2TM
                         bool bRTL;
                         bool bVertL2R;
                         
aSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_IN_VERTICAL_TEXT, 
pSh->IsFrameVertical(true, bRTL, bVertL2R)));
@@ -261,20 +267,21 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq)
 
                             bool bSingleSelection = rMarkList.GetMarkCount() 
== 1;
 
-                            const SfxPoolItem* pAnchorItem;
-                            if(SfxItemState::SET == pOutSet->GetItemState(
-                                SID_ATTR_TRANSFORM_ANCHOR, false, 
&pAnchorItem))
+                            // I2TM
+                            if(const auto 
Slot(pOutSet->slotSet().GetSlot<const 
Item::CntInt16>(SID_ATTR_TRANSFORM_ANCHOR)); Slot)
                             {
                                 if(!bSingleSelection)
-                                    
pSh->ChgAnchor(static_cast<RndStdIds>(static_cast<const 
SfxInt16Item*>(pAnchorItem)
-                                            ->GetValue()), false, bPosCorr );
+                                {
+                                    
pSh->ChgAnchor(static_cast<RndStdIds>(Slot->GetValue()), false, bPosCorr);
+                                }
                                 else
                                 {
                                     SwFormatAnchor 
aAnchor(pFrameFormat->GetAnchor());
-                                    
aAnchor.SetType(static_cast<RndStdIds>(static_cast<const 
SfxInt16Item*>(pAnchorItem)->GetValue()));
+                                    
aAnchor.SetType(static_cast<RndStdIds>(Slot->GetValue()));
                                     aFrameAttrSet.Put( aAnchor );
                                 }
                             }
+                            // ~I2TM
                             const SfxPoolItem* pHoriOrient = nullptr;
                             const SfxPoolItem* pHoriRelation = nullptr;
                             const SfxPoolItem* pHoriPosition = nullptr;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to