[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - include/svx svx/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Dec 12 20:38:55 UTC 2016


 include/svx/sdtaitm.hxx        |    1 
 include/svx/svdotable.hxx      |    1 
 svx/source/svdraw/svdattr.cxx  |    8 ++
 svx/source/svdraw/svdedxv.cxx  |  131 +++++++++++++++++++++++++----------------
 svx/source/table/svdotable.cxx |    4 +
 5 files changed, 94 insertions(+), 51 deletions(-)

New commits:
commit 2670760550608c3f51bb01eb7b86c33461e2e5c8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Dec 5 11:51:01 2016 +0200

    tdf#104405 Clone Formatting ignores vertical text alignment
    
    I removed the unit test, since it depends on some other changes to the
    dumpAsXml code that are not in this branch.
    
    Reviewed-on: https://gerrit.libreoffice.org/31623
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit d36aa2ba3132ce62a370b7260ca620642cbf7dbf)
    
    Reviewed-on: https://gerrit.libreoffice.org/31746
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    (cherry picked from commit a7d13674bc2271e6f191e8ecda78151a47d413f6)
    
    Change-Id: I56cce69ddb21f7f9336b8f59e181e91306e92019
    Reviewed-on: https://gerrit.libreoffice.org/31896
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/include/svx/sdtaitm.hxx b/include/svx/sdtaitm.hxx
index 590df23..fc20689 100644
--- a/include/svx/sdtaitm.hxx
+++ b/include/svx/sdtaitm.hxx
@@ -48,6 +48,7 @@ public:
 
     virtual OUString GetValueTextByPos(sal_uInt16 nPos) const override;
     virtual bool GetPresentation(SfxItemPresentation ePres, SfxMapUnit eCoreMetric, SfxMapUnit ePresMetric, OUString& rText, const IntlWrapper * = nullptr) const override;
+    virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
 };
 
 
diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index b0e0c5c..ac29eff 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -141,6 +141,7 @@ public:
     void getCellBounds( const sdr::table::CellPos& rPos, ::Rectangle& rCellRect );
 
     const SfxItemSet& GetActiveCellItemSet() const;
+    void SetMergedItemSetAndBroadcastOnActiveCell(const SfxItemSet& rSet, bool bClearAllItems);
 
      void setTableStyle( const css::uno::Reference< css::container::XIndexAccess >& xAutoFormatStyle );
      const css::uno::Reference< css::container::XIndexAccess >& getTableStyle() const;
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 5a0570c..3e98047 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -100,6 +100,7 @@
 #include <svx/xflclit.hxx>
 #include <svx/xlineit0.hxx>
 #include <svx/xtable.hxx>
+#include <libxml/xmlwriter.h>
 
 using namespace ::com::sun::star;
 
@@ -1129,6 +1130,13 @@ bool SdrTextVertAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberI
     return true;
 }
 
+void SdrTextVertAdjustItem::dumpAsXml(struct _xmlTextWriter* pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("SdrTextVertAdjustItem"));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
+    xmlTextWriterEndElement(pWriter);
+}
 
 SfxPoolItem* SdrTextHorzAdjustItem::Clone(SfxItemPool* /*pPool*/) const            { return new SdrTextHorzAdjustItem(*this); }
 
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 711ae93..968738c 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2098,8 +2098,9 @@ static const sal_uInt16* GetFormatRangeImpl( bool bTextOnly )
         SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
         XATTR_LINE_FIRST, XATTR_LINE_LAST,
         XATTR_FILL_FIRST, XATTRSET_FILL,
-        EE_PARA_START, EE_PARA_END,
+        EE_PARA_START, EE_PARA_END, // text-only from here on
         EE_CHAR_START, EE_CHAR_END,
+        SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, // table cell formats
         0,0
     };
     return &gRanges[ bTextOnly ? 10 : 0];
@@ -2125,6 +2126,17 @@ void SdrObjEditView::TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rForma
             const bool bOnlyHardAttr = false;
             rFormatSet->Put( GetAttrFromMarked(bOnlyHardAttr) );
         }
+
+        // check for cloning from table cell, in which case we need to copy cell-specific formatting attributes
+        const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+        if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
+        {
+            auto pTable = static_cast<const sdr::table::SdrTableObj*>(pObj);
+            if (pTable->getActiveCell().is()) {
+                SfxItemSet const & rSet = pTable->GetActiveCellItemSet();
+                rFormatSet->Put(rSet);
+            }
+        }
     }
 }
 
@@ -2189,71 +2201,88 @@ void SdrObjEditView::ApplyFormatPaintBrushToText( SfxItemSet& rFormatSet, SdrTex
 
 void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
 {
-    if( !mxSelectionController.is() || !mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) )
+    if( mxSelectionController.is() &&
+        mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) )
     {
-        const SdrMarkList& rMarkList = GetMarkedObjectList();
-        SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
-        OutlinerView* pOLV = GetTextEditOutlinerView();
+        return;
+    }
 
+    OutlinerView* pOLV = GetTextEditOutlinerView();
+    const SdrMarkList& rMarkList = GetMarkedObjectList();
+    if( !pOLV )
+    {
+        SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
         const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
 
-        if( !pOLV )
-        {
-            // if not in text edit mode (aka the user selected text or clicked on a word)
-            // apply formatting attributes to selected shape
-            // All formatting items (see ranges above) that are unequal in selected shape and
-            // the format paintbrush are hard set on the selected shape.
+        // if not in text edit mode (aka the user selected text or clicked on a word)
+        // apply formatting attributes to selected shape
+        // All formatting items (see ranges above) that are unequal in selected shape and
+        // the format paintbrush are hard set on the selected shape.
 
-            const sal_uInt16* pRanges = rFormatSet.GetRanges();
-            bool bTextOnly = true;
+        const sal_uInt16* pRanges = rFormatSet.GetRanges();
+        bool bTextOnly = true;
 
-            while( *pRanges )
+        while( *pRanges )
+        {
+            if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) )
             {
-                if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) )
-                {
-                    bTextOnly = false;
-                    break;
-                }
-                pRanges += 2;
+                bTextOnly = false;
+                break;
             }
+            pRanges += 2;
+        }
 
-            if( !bTextOnly )
-            {
-                SfxItemSet aPaintSet( CreatePaintSet( GetFormatRangeImpl(false), *rShapeSet.GetPool(), rFormatSet, rShapeSet, bNoCharacterFormats, bNoParagraphFormats ) );
-                const bool bReplaceAll = false;
-                SetAttrToMarked(aPaintSet, bReplaceAll);
-            }
+        if( !bTextOnly )
+        {
+            SfxItemSet aPaintSet( CreatePaintSet(
+                                    GetFormatRangeImpl(false), *rShapeSet.GetPool(),
+                                    rFormatSet, rShapeSet,
+                                    bNoCharacterFormats, bNoParagraphFormats ) );
+            SetAttrToMarked(aPaintSet, false/*bReplaceAll*/);
+        }
 
-            // now apply character and paragraph formatting to text, if the shape has any
-            SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
-            if( pTextObj )
-            {
-                sal_Int32 nText = pTextObj->getTextCount();
+        // now apply character and paragraph formatting to text, if the shape has any
+        SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+        if( pTextObj )
+        {
+            sal_Int32 nText = pTextObj->getTextCount();
 
-                while( --nText >= 0 )
-                {
-                    SdrText* pText = pTextObj->getText( nText );
-                    ApplyFormatPaintBrushToText( rFormatSet, *pTextObj, pText, bNoCharacterFormats, bNoParagraphFormats );
-                }
+            while( --nText >= 0 )
+            {
+                SdrText* pText = pTextObj->getText( nText );
+                ApplyFormatPaintBrushToText( rFormatSet, *pTextObj, pText, bNoCharacterFormats, bNoParagraphFormats );
             }
         }
-        else
+    }
+    else
+    {
+        ::Outliner* pOutliner = pOLV->GetOutliner();
+        if( pOutliner )
         {
-            ::Outliner* pOutliner = pOLV->GetOutliner();
-            if( pOutliner )
-            {
-                const EditEngine& rEditEngine = pOutliner->GetEditEngine();
-
-                ESelection aSel( pOLV->GetSelection() );
-                if( !aSel.HasRange() )
-                    pOLV->SetSelection( rEditEngine.GetWord( aSel, css::i18n::WordType::DICTIONARY_WORD ) );
+            const EditEngine& rEditEngine = pOutliner->GetEditEngine();
+
+            ESelection aSel( pOLV->GetSelection() );
+            if( !aSel.HasRange() )
+                pOLV->SetSelection( rEditEngine.GetWord( aSel, css::i18n::WordType::DICTIONARY_WORD ) );
+
+            const bool bRemoveParaAttribs = !bNoParagraphFormats;
+            pOLV->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
+            SfxItemSet aSet( pOLV->GetAttribs() );
+            SfxItemSet aPaintSet( CreatePaintSet(
+                                    GetFormatRangeImpl(true), *aSet.GetPool(),
+                                    rFormatSet, aSet,
+                                    bNoCharacterFormats, bNoParagraphFormats ) );
+            pOLV->SetAttribs( aPaintSet );
+        }
+    }
 
-                const bool bRemoveParaAttribs = !bNoParagraphFormats;
-                pOLV->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
-                SfxItemSet aSet( pOLV->GetAttribs() );
-                SfxItemSet aPaintSet( CreatePaintSet(GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, bNoCharacterFormats, bNoParagraphFormats ) );
-                pOLV->SetAttribs( aPaintSet );
-            }
+    // check for cloning to table cell, in which case we need to copy cell-specific formatting attributes
+    SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+    if( pObj && (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
+    {
+        auto pTable = static_cast<sdr::table::SdrTableObj*>(pObj);
+        if (pTable->getActiveCell().is()) {
+            pTable->SetMergedItemSetAndBroadcastOnActiveCell(rFormatSet, false/*bClearAllItems*/);
         }
     }
 }
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index f828907..34b78ca 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1179,6 +1179,10 @@ const SfxItemSet& SdrTableObj::GetActiveCellItemSet() const
     return getActiveCell()->GetItemSet();
 }
 
+void SdrTableObj::SetMergedItemSetAndBroadcastOnActiveCell(const SfxItemSet& rSet, bool bClearAllItems)
+{
+    return getActiveCell()->SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
+}
 
 void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle )
 {


More information about the Libreoffice-commits mailing list