[Libreoffice-commits] core.git: 7 commits - editeng/source include/editeng sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Sat Aug 24 14:13:53 PDT 2013


 editeng/source/editeng/editobj.cxx         |    2 
 include/editeng/editobj.hxx                |    2 
 sc/source/filter/xml/XMLExportIterator.cxx |   32 +-
 sc/source/filter/xml/XMLExportIterator.hxx |   11 
 sc/source/filter/xml/xmlexprt.cxx          |  459 +++++++++++++----------------
 sc/source/filter/xml/xmlexprt.hxx          |    3 
 6 files changed, 249 insertions(+), 260 deletions(-)

New commits:
commit 3e1bc81ad888cab1e31382f5a4faa3d2f0373577
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Sat Aug 24 12:49:20 2013 -0400

    Make this a separate function.
    
    Change-Id: I387470b42e967dd549b5bcfc418e9e566d2ccecc

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 28708ba..b94ccc2 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1111,234 +1111,244 @@ void ScXMLExport::ExportExternalRefCacheStyles()
     }
 }
 
-void ScXMLExport::ExportCellTextAutoStyles(sal_Int32 nTable)
-{
-    if (!ValidTab(nTable))
-        return;
+namespace {
 
-    UniReference<XMLPropertySetMapper> xMapper = GetTextParagraphExport()->GetTextPropMapper()->getPropertySetMapper();
+void toXMLPropertyStates(
+    std::vector<XMLPropertyState>& rPropStates, const std::vector<const SfxPoolItem*>& rSecAttrs,
+    const UniReference<XMLPropertySetMapper>& xMapper, const ScXMLEditAttributeMap& rAttrMap )
+{
     sal_Int32 nEntryCount = xMapper->GetEntryCount();
-    UniReference<SvXMLAutoStylePoolP> xStylePool = GetAutoStylePool();
-    const ScXMLEditAttributeMap& rAttrMap = GetEditAttributeMap();
-
-    sc::EditTextIterator aIter(*pDoc, nTable);
-    sal_Int32 nCellCount = 0;
-    for (const EditTextObject* pEdit = aIter.first(); pEdit; pEdit = aIter.next(), ++nCellCount)
+    rPropStates.reserve(rSecAttrs.size());
+    std::vector<const SfxPoolItem*>::const_iterator it = rSecAttrs.begin(), itEnd = rSecAttrs.end();
+    for (; it != itEnd; ++it)
     {
-        std::vector<editeng::SectionAttribute> aAttrs;
-        pEdit->GetAllSectionAttributes(aAttrs);
-        if (aAttrs.empty())
+        const SfxPoolItem* p = *it;
+        const ScXMLEditAttributeMap::Entry* pEntry = rAttrMap.getEntryByItemID(p->Which());
+        if (!pEntry)
             continue;
 
-        std::vector<editeng::SectionAttribute>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end();
-        for (; itSec != itSecEnd; ++itSec)
-        {
-            const std::vector<const SfxPoolItem*>& rSecAttrs = itSec->maAttributes;
-            if (rSecAttrs.empty())
-                // No formats applied to this section. Skip it.
-                continue;
+        sal_Int32 nIndex = xMapper->GetEntryIndex(
+            pEntry->nmXMLNS, OUString::createFromAscii(pEntry->mpXMLName), 0);
 
-            std::vector<XMLPropertyState> aPropStates;
-            aPropStates.reserve(rSecAttrs.size());
-            std::vector<const SfxPoolItem*>::const_iterator it = rSecAttrs.begin(), itEnd = rSecAttrs.end();
-            for (; it != itEnd; ++it)
+        if (nIndex == -1 || nIndex >= nEntryCount)
+            continue;
+
+        uno::Any aAny;
+        switch (p->Which())
+        {
+            case EE_CHAR_FONTINFO:
+            case EE_CHAR_FONTINFO_CJK:
+            case EE_CHAR_FONTINFO_CTL:
             {
-                const SfxPoolItem* p = *it;
-                const ScXMLEditAttributeMap::Entry* pEntry = rAttrMap.getEntryByItemID(p->Which());
-                if (!pEntry)
+                if (!static_cast<const SvxFontItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
                     continue;
 
-                sal_Int32 nIndex = xMapper->GetEntryIndex(
-                    pEntry->nmXMLNS, OUString::createFromAscii(pEntry->mpXMLName), 0);
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_WEIGHT:
+            case EE_CHAR_WEIGHT_CJK:
+            case EE_CHAR_WEIGHT_CTL:
+            {
+                if (!static_cast<const SvxWeightItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                if (nIndex == -1 || nIndex >= nEntryCount)
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_FONTHEIGHT:
+            case EE_CHAR_FONTHEIGHT_CJK:
+            case EE_CHAR_FONTHEIGHT_CTL:
+            {
+                if (!static_cast<const SvxFontHeightItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
                     continue;
 
-                uno::Any aAny;
-                switch (p->Which())
-                {
-                    case EE_CHAR_FONTINFO:
-                    case EE_CHAR_FONTINFO_CJK:
-                    case EE_CHAR_FONTINFO_CTL:
-                    {
-                        if (!static_cast<const SvxFontItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_ITALIC:
+            case EE_CHAR_ITALIC_CJK:
+            case EE_CHAR_ITALIC_CTL:
+            {
+                if (!static_cast<const SvxPostureItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_UNDERLINE:
+            {
+                // Underline attribute needs to export multiple entries.
+                sal_Int32 nIndexStyle = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-underline-style", 0);
+                if (nIndexStyle == -1 || nIndexStyle > nEntryCount)
                     break;
-                    case EE_CHAR_WEIGHT:
-                    case EE_CHAR_WEIGHT_CJK:
-                    case EE_CHAR_WEIGHT_CTL:
-                    {
-                        if (!static_cast<const SvxWeightItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
+                sal_Int32 nIndexWidth = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-underline-width", 0);
+                if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
                     break;
-                    case EE_CHAR_FONTHEIGHT:
-                    case EE_CHAR_FONTHEIGHT_CJK:
-                    case EE_CHAR_FONTHEIGHT_CTL:
-                    {
-                        if (!static_cast<const SvxFontHeightItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
+                sal_Int32 nIndexColor = xMapper->FindEntryIndex("CharUnderlineColor", XML_NAMESPACE_STYLE, "text-underline-color");
+                if (nIndexColor == -1 || nIndexColor > nEntryCount)
                     break;
-                    case EE_CHAR_ITALIC:
-                    case EE_CHAR_ITALIC_CJK:
-                    case EE_CHAR_ITALIC_CTL:
-                    {
-                        if (!static_cast<const SvxPostureItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
+                sal_Int32 nIndexHasColor = xMapper->FindEntryIndex("CharUnderlineHasColor", XML_NAMESPACE_STYLE, "text-underline-color");
+                if (nIndexHasColor == -1 || nIndexHasColor > nEntryCount)
                     break;
-                    case EE_CHAR_UNDERLINE:
-                    {
-                        // Underline attribute needs to export multiple entries.
-                        sal_Int32 nIndexStyle = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-underline-style", 0);
-                        if (nIndexStyle == -1 || nIndexStyle > nEntryCount)
-                            break;
 
-                        sal_Int32 nIndexWidth = xMapper->GetEntryIndex(XML_NAMESPACE_STYLE, "text-underline-width", 0);
-                        if (nIndexWidth == -1 || nIndexWidth > nEntryCount)
-                            break;
+                const SvxUnderlineItem* pUL = static_cast<const SvxUnderlineItem*>(p);
+                pUL->QueryValue(aAny, MID_TL_STYLE);
+                rPropStates.push_back(XMLPropertyState(nIndexStyle, aAny));
+                rPropStates.push_back(XMLPropertyState(nIndexWidth, aAny));
 
-                        sal_Int32 nIndexColor = xMapper->FindEntryIndex("CharUnderlineColor", XML_NAMESPACE_STYLE, "text-underline-color");
-                        if (nIndexColor == -1 || nIndexColor > nEntryCount)
-                            break;
+                pUL->QueryValue(aAny, MID_TL_COLOR);
+                rPropStates.push_back(XMLPropertyState(nIndexColor, aAny));
 
-                        sal_Int32 nIndexHasColor = xMapper->FindEntryIndex("CharUnderlineHasColor", XML_NAMESPACE_STYLE, "text-underline-color");
-                        if (nIndexHasColor == -1 || nIndexHasColor > nEntryCount)
-                            break;
+                pUL->QueryValue(aAny, MID_TL_HASCOLOR);
+                rPropStates.push_back(XMLPropertyState(nIndexHasColor, aAny));
+            }
+            break;
+            case EE_CHAR_OVERLINE:
+            {
+                if (!static_cast<const SvxOverlineItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        const SvxUnderlineItem* pUL = static_cast<const SvxUnderlineItem*>(p);
-                        pUL->QueryValue(aAny, MID_TL_STYLE);
-                        aPropStates.push_back(XMLPropertyState(nIndexStyle, aAny));
-                        aPropStates.push_back(XMLPropertyState(nIndexWidth, aAny));
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_COLOR:
+            {
+                if (!static_cast<const SvxColorItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        pUL->QueryValue(aAny, MID_TL_COLOR);
-                        aPropStates.push_back(XMLPropertyState(nIndexColor, aAny));
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_WLM:
+            {
+                if (!static_cast<const SvxWordLineModeItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        pUL->QueryValue(aAny, MID_TL_HASCOLOR);
-                        aPropStates.push_back(XMLPropertyState(nIndexHasColor, aAny));
-                    }
-                    break;
-                    case EE_CHAR_OVERLINE:
-                    {
-                        if (!static_cast<const SvxOverlineItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_STRIKEOUT:
+            {
+                if (!static_cast<const SvxCrossedOutItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_COLOR:
-                    {
-                        if (!static_cast<const SvxColorItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_RELIEF:
+            {
+                if (!static_cast<const SvxCharReliefItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_WLM:
-                    {
-                        if (!static_cast<const SvxWordLineModeItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_OUTLINE:
+            {
+                if (!static_cast<const SvxContourItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_STRIKEOUT:
-                    {
-                        if (!static_cast<const SvxCrossedOutItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_SHADOW:
+            {
+                if (!static_cast<const SvxShadowedItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_RELIEF:
-                    {
-                        if (!static_cast<const SvxCharReliefItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_KERNING:
+            {
+                if (!static_cast<const SvxKerningItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_OUTLINE:
-                    {
-                        if (!static_cast<const SvxContourItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_PAIRKERNING:
+            {
+                if (!static_cast<const SvxAutoKernItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_SHADOW:
-                    {
-                        if (!static_cast<const SvxShadowedItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_FONTWIDTH:
+            {
+                if (!static_cast<const SvxCharScaleWidthItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_KERNING:
-                    {
-                        if (!static_cast<const SvxKerningItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_ESCAPEMENT:
+            {
+                if (!static_cast<const SvxEscapementItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_PAIRKERNING:
-                    {
-                        if (!static_cast<const SvxAutoKernItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_EMPHASISMARK:
+            {
+                if (!static_cast<const SvxEmphasisMarkItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_FONTWIDTH:
-                    {
-                        if (!static_cast<const SvxCharScaleWidthItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            case EE_CHAR_LANGUAGE:
+            case EE_CHAR_LANGUAGE_CJK:
+            case EE_CHAR_LANGUAGE_CTL:
+            {
+                if (!static_cast<const SvxLanguageItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
+                    continue;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_ESCAPEMENT:
-                    {
-                        if (!static_cast<const SvxEscapementItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+                rPropStates.push_back(XMLPropertyState(nIndex, aAny));
+            }
+            break;
+            default:
+                continue;
+        }
+    }
+}
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_EMPHASISMARK:
-                    {
-                        if (!static_cast<const SvxEmphasisMarkItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+}
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    case EE_CHAR_LANGUAGE:
-                    case EE_CHAR_LANGUAGE_CJK:
-                    case EE_CHAR_LANGUAGE_CTL:
-                    {
-                        if (!static_cast<const SvxLanguageItem*>(p)->QueryValue(aAny, pEntry->mnFlag))
-                            continue;
+void ScXMLExport::ExportCellTextAutoStyles(sal_Int32 nTable)
+{
+    if (!ValidTab(nTable))
+        return;
 
-                        aPropStates.push_back(XMLPropertyState(nIndex, aAny));
-                    }
-                    break;
-                    default:
-                        continue;
-                }
-            }
+    UniReference<XMLPropertySetMapper> xMapper = GetTextParagraphExport()->GetTextPropMapper()->getPropertySetMapper();
+    UniReference<SvXMLAutoStylePoolP> xStylePool = GetAutoStylePool();
+    const ScXMLEditAttributeMap& rAttrMap = GetEditAttributeMap();
+
+    sc::EditTextIterator aIter(*pDoc, nTable);
+    sal_Int32 nCellCount = 0;
+    for (const EditTextObject* pEdit = aIter.first(); pEdit; pEdit = aIter.next(), ++nCellCount)
+    {
+        std::vector<editeng::SectionAttribute> aAttrs;
+        pEdit->GetAllSectionAttributes(aAttrs);
+        if (aAttrs.empty())
+            continue;
 
+        std::vector<editeng::SectionAttribute>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end();
+        for (; itSec != itSecEnd; ++itSec)
+        {
+            const std::vector<const SfxPoolItem*>& rSecAttrs = itSec->maAttributes;
+            if (rSecAttrs.empty())
+                // No formats applied to this section. Skip it.
+                continue;
+
+            std::vector<XMLPropertyState> aPropStates;
+            toXMLPropertyStates(aPropStates, rSecAttrs, xMapper, rAttrMap);
             if (!aPropStates.empty())
                 xStylePool->Add(XML_STYLE_FAMILY_TEXT_TEXT, OUString(), aPropStates, false);
         }
commit 9ae7d6762b81adfdbd87034652cb2d4550a6dcf8
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Sat Aug 24 11:31:34 2013 -0400

    Change of plan - we need to include feature attributes here as well.
    
    Change-Id: I431b7ff79cffd5c9a7ff06f41a2fdd56bf2f968c

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index dbfd833..c7db485 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -950,7 +950,7 @@ void EditTextObjectImpl::GetAllSectionAttributes( std::vector<editeng::SectionAt
         {
             const XEditAttribute& rAttr = rC.aAttribs[i];
             const SfxPoolItem* pItem = rAttr.GetItem();
-            if (!pItem || pItem->Which() == EE_FEATURE_FIELD)
+            if (!pItem)
                 continue;
 
             size_t nStart = rAttr.GetStart(), nEnd = rAttr.GetEnd();
diff --git a/include/editeng/editobj.hxx b/include/editeng/editobj.hxx
index c61f682..53b4cbf 100644
--- a/include/editeng/editobj.hxx
+++ b/include/editeng/editobj.hxx
@@ -107,8 +107,6 @@ public:
      * Sections never overlap each other; if an attribute was applied to [0-6]
      * and another applied to [3-10], you would get 3 sections that are [0-3],
      * [3-6] and [6-10].
-     *
-     * <p>Note that this method skips field attributes.</p>
      */
     void GetAllSectionAttributes( std::vector<editeng::SectionAttribute>& rAttrs ) const;
 
commit a69c486a3d210d390a57b4f4a6d633e45204112e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Sat Aug 24 10:49:17 2013 -0400

    We can simplify this one too.
    
    Change-Id: I2cd9be9bf38adda0c46a01b8c4fa85fdf6299ea4

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 74955ee..28708ba 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3597,19 +3597,6 @@ bool ScXMLExport::IsEditCell(ScMyCell& rCell) const
 
 bool ScXMLExport::IsMultiLineFormulaCell(ScMyCell& rCell) const
 {
-    if (!rCell.maBaseCell.isEmpty())
-    {
-        if (rCell.maBaseCell.meType != CELLTYPE_FORMULA)
-            return false;
-
-        return rCell.maBaseCell.mpFormula->IsMultilineResult();
-    }
-
-    ScAddress aAddr(static_cast<SCCOL>(rCell.aCellAddress.Column),
-                    static_cast<SCROW>(rCell.aCellAddress.Row),
-                    static_cast<SCTAB>(rCell.aCellAddress.Sheet));
-
-    rCell.maBaseCell.assign(*pDoc, aAddr);
     if (rCell.maBaseCell.meType != CELLTYPE_FORMULA)
         return false;
 
commit f5abc665e94113a53d450af020bc534756a88072
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Sat Aug 24 10:44:48 2013 -0400

    Remove ugly and expensive hack only to see if the cell is an edit cell.
    
    We can do it much simpler now.
    
    Change-Id: I913f2a226e1f16fbc9aafaa91af5550f3c7fee05

diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index 697f2aa..2cf4325 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -608,7 +608,6 @@ ScMyCell::ScMyCell() :
     bHasDetectiveObj( false ),
     bHasDetectiveOp( false ),
     bIsEditCell( false ),
-    bKnowWhetherIsEditCell( false ),
     bHasStringValue( false ),
     bHasDoubleValue( false ),
     bHasXText( false ),
@@ -682,14 +681,18 @@ void ScMyNotEmptyCellsIterator::UpdateAddress( table::CellAddress& rAddress )
 
 void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, table::CellAddress& rAddress )
 {
+    rMyCell.maBaseCell.clear();
     rMyCell.aCellAddress = rAddress;
     rMyCell.bHasStringValue = false;
     rMyCell.bHasDoubleValue = false;
     rMyCell.bHasXText = false;
-    rMyCell.bKnowWhetherIsEditCell = false;
     rMyCell.bIsEditCell = false;
     if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) )
+    {
         mpCell = mpCellItr->GetNext(nCellCol, nCellRow);
+        if (mpCell)
+            rMyCell.maBaseCell = *mpCell;
+    }
 }
 
 void ScMyNotEmptyCellsIterator::SetMatrixCellData( ScMyCell& rMyCell )
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx
index 9938b44..98eedf4 100644
--- a/sc/source/filter/xml/XMLExportIterator.hxx
+++ b/sc/source/filter/xml/XMLExportIterator.hxx
@@ -327,7 +327,6 @@ struct ScMyCell
     bool                        bHasDetectiveOp;
 
     bool                        bIsEditCell;
-    bool                        bKnowWhetherIsEditCell;
     bool                        bHasStringValue;
     bool                        bHasDoubleValue;
     bool                        bHasXText;
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 6815f95..74955ee 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3590,31 +3590,9 @@ bool ScXMLExport::IsCellTypeEqual (const ScMyCell& aCell1, const ScMyCell& aCell
     return (aCell1.nType == aCell2.nType);
 }
 
-bool ScXMLExport::IsEditCell(const com::sun::star::table::CellAddress& aAddress, ScMyCell* pMyCell) const
-{
-    ScAddress aCoreAddress(static_cast<SCCOL>(aAddress.Column),
-                        static_cast<SCROW>(aAddress.Row),
-                        static_cast<SCTAB>(aAddress.Sheet));
-
-    ScRefCellValue aCell;
-    aCell.assign(const_cast<ScDocument&>(*GetDocument()), aCoreAddress);
-
-    if (pMyCell)
-        pMyCell->maBaseCell = aCell;
-
-    return (aCell.meType == CELLTYPE_EDIT);
-}
-
 bool ScXMLExport::IsEditCell(ScMyCell& rCell) const
 {
-    if (rCell.bKnowWhetherIsEditCell)
-        return rCell.bIsEditCell;
-    else
-    {
-         rCell.bIsEditCell = IsEditCell(rCell.aCellAddress, &rCell);
-        rCell.bKnowWhetherIsEditCell = true;
-        return rCell.bIsEditCell;
-    }
+    return rCell.maBaseCell.meType == CELLTYPE_EDIT;
 }
 
 bool ScXMLExport::IsMultiLineFormulaCell(ScMyCell& rCell) const
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index f0303e3..3f01dfe 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -187,7 +187,6 @@ class ScXMLExport : public SvXMLExport
     void SetRepeatAttribute(sal_Int32 nEqualCellCount, bool bIncProgress);
 
     bool IsCellTypeEqual (const ScMyCell& aCell1, const ScMyCell& aCell2) const;
-    bool IsEditCell(const com::sun::star::table::CellAddress& aAddress, ScMyCell* pMyCell = NULL) const;
     bool IsEditCell(ScMyCell& rCell) const;
     bool IsMultiLineFormulaCell(ScMyCell& rCell) const;
     bool IsCellEqual (ScMyCell& aCell1, ScMyCell& aCell2);
commit dcd8964ca3f05a40b18cf17ab11116011c090abc
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Sat Aug 24 10:27:34 2013 -0400

    Use smart pointer for this too.
    
    Change-Id: I7aa4a38d1392be97ce22eecbc0993e9a52151b03

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 480693e..6815f95 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -468,7 +468,6 @@ ScXMLExport::ScXMLExport(
     pCurrentCell(NULL),
     pMergedRangesContainer(NULL),
     pValidationsContainer(NULL),
-    pCellsItr(NULL),
     pChangeTrackingExportHelper(NULL),
     sLayerID( SC_LAYERID ),
     sCaptionShape("com.sun.star.drawing.CaptionShape"),
@@ -488,7 +487,7 @@ ScXMLExport::ScXMLExport(
         pRowFormatRanges = new ScRowFormatRanges();
         pMergedRangesContainer = new ScMyMergedRangesContainer();
         pValidationsContainer = new ScMyValidationsContainer();
-        pCellsItr = new ScMyNotEmptyCellsIterator(*this);
+        mpCellsItr.reset(new ScMyNotEmptyCellsIterator(*this));
         pDefaults = new ScMyDefaultStyles();
     }
     pCellStyles = new ScFormatRangeStyles();
@@ -551,7 +550,6 @@ ScXMLExport::~ScXMLExport()
         delete pValidationsContainer;
         delete pChangeTrackingExportHelper;
         delete pChartListener;
-        delete pCellsItr;
         delete pDefaults;
         delete pNumberFormatAttributesExportHelper;
 }
@@ -1939,14 +1937,14 @@ void ScXMLExport::_ExportContent()
         pMergedRangesContainer->Sort();
         pSharedData->GetDetectiveObjContainer()->Sort();
 
-        pCellsItr->Clear();
-        pCellsItr->SetShapes( pSharedData->GetShapesContainer() );
-        pCellsItr->SetNoteShapes( pSharedData->GetNoteShapes() );
-        pCellsItr->SetMergedRanges( pMergedRangesContainer );
-        pCellsItr->SetAreaLinks( &aAreaLinks );
-        pCellsItr->SetEmptyDatabaseRanges( &aEmptyRanges );
-        pCellsItr->SetDetectiveObj( pSharedData->GetDetectiveObjContainer() );
-        pCellsItr->SetDetectiveOp( &aDetectiveOpContainer );
+        mpCellsItr->Clear();
+        mpCellsItr->SetShapes( pSharedData->GetShapesContainer() );
+        mpCellsItr->SetNoteShapes( pSharedData->GetNoteShapes() );
+        mpCellsItr->SetMergedRanges( pMergedRangesContainer );
+        mpCellsItr->SetAreaLinks( &aAreaLinks );
+        mpCellsItr->SetEmptyDatabaseRanges( &aEmptyRanges );
+        mpCellsItr->SetDetectiveObj( pSharedData->GetDetectiveObjContainer() );
+        mpCellsItr->SetDetectiveOp( &aDetectiveOpContainer );
 
         if (nTableCount > 0)
             pValidationsContainer->WriteValidations(*this);
@@ -1968,7 +1966,7 @@ void ScXMLExport::_ExportContent()
                 pSheetData->AddSavePos( nTable, nNewStart, nNewEnd );
 
                 // skip iterator entries for this sheet
-                pCellsItr->SkipTable(static_cast<SCTAB>(nTable));
+                mpCellsItr->SkipTable(static_cast<SCTAB>(nTable));
             }
             else
             {
@@ -2969,7 +2967,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadshe
     table::CellRangeAddress aRange(GetEndAddress(xTable, nTable));
     pSharedData->SetLastColumn(nTable, aRange.EndColumn);
     pSharedData->SetLastRow(nTable, aRange.EndRow);
-    pCellsItr->SetCurrentTable(static_cast<SCTAB>(nTable), xCurrentTable);
+    mpCellsItr->SetCurrentTable(static_cast<SCTAB>(nTable), xCurrentTable);
     pGroupColumns->NewTable();
     pGroupRows->NewTable();
     FillColumnRowGroups();
@@ -2989,7 +2987,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadshe
     sal_Int32 nEqualCells(0);
     ScMyCell aCell;
     ScMyCell aPrevCell;
-    while(pCellsItr->GetNext(aCell, pCellStyles))
+    while (mpCellsItr->GetNext(aCell, pCellStyles))
     {
         if (bIsFirst)
         {
@@ -3206,8 +3204,14 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
 
     if (!bIsEmpty)
     {
-        if ((aCell.nType == table::CellContentType_TEXT && IsEditCell(aCell)) ||
-            (aCell.nType == table::CellContentType_FORMULA && IsMultiLineFormulaCell(aCell)))
+        if (aCell.nType == table::CellContentType_TEXT && IsEditCell(aCell))
+        {
+            bEditCell = true;
+            uno::Reference<text::XText> xText(xCurrentTableCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row), uno::UNO_QUERY);
+            if ( xText.is())
+                GetTextParagraphExport()->exportText(xText, false, false);
+        }
+        else if (aCell.nType == table::CellContentType_FORMULA && IsMultiLineFormulaCell(aCell))
         {
             bEditCell = true;
             uno::Reference<text::XText> xText(xCurrentTableCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row), uno::UNO_QUERY);
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index 2c93a59..f0303e3 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -73,6 +73,7 @@ class ScXMLExport : public SvXMLExport
     sal_Int32                   nSourceStreamPos;
 
     mutable boost::scoped_ptr<ScXMLEditAttributeMap> mpEditAttrMap;
+    boost::scoped_ptr<ScMyNotEmptyCellsIterator> mpCellsItr;
     UniReference < XMLPropertyHandlerFactory >  xScPropHdlFactory;
     UniReference < XMLPropertySetMapper >       xCellStylesPropertySetMapper;
     UniReference < XMLPropertySetMapper >       xColumnStylesPropertySetMapper;
@@ -100,7 +101,6 @@ class ScXMLExport : public SvXMLExport
 
     ScMyMergedRangesContainer*  pMergedRangesContainer;
     ScMyValidationsContainer*   pValidationsContainer;
-    ScMyNotEmptyCellsIterator*  pCellsItr;
     ScChangeTrackingExportHelper*   pChangeTrackingExportHelper;
     const OUString         sLayerID;
     const OUString         sCaptionShape;
commit 67e094ff7d21bd862bdf14d15f978bfba286a870
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Sat Aug 24 10:21:02 2013 -0400

    Provide a way to retrieve current cell instance during ods export.
    
    Change-Id: Ib35ecf6eef1e9f6b29bd639ee6f4630ac61aa104

diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index ebd3b8f..697f2aa 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -642,6 +642,7 @@ ScMyNotEmptyCellsIterator::ScMyNotEmptyCellsIterator(ScXMLExport& rTempXMLExport
     pDetectiveObj(NULL),
     pDetectiveOp(NULL),
     rExport(rTempXMLExport),
+    mpCell(NULL),
     nCurrentTable(SCTAB_MAX)
 {
 }
@@ -688,7 +689,7 @@ void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, table::CellAddre
     rMyCell.bKnowWhetherIsEditCell = false;
     rMyCell.bIsEditCell = false;
     if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) )
-        mpCellItr->GetNext(nCellCol, nCellRow);
+        mpCell = mpCellItr->GetNext(nCellCol, nCellRow);
 }
 
 void ScMyNotEmptyCellsIterator::SetMatrixCellData( ScMyCell& rMyCell )
@@ -892,4 +893,9 @@ bool ScMyNotEmptyCellsIterator::GetNext(ScMyCell& aCell, ScFormatRangeStyles* pC
     return bFoundCell;
 }
 
+const ScRefCellValue* ScMyNotEmptyCellsIterator::GetCell() const
+{
+    return mpCell;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx
index c27216e..9938b44 100644
--- a/sc/source/filter/xml/XMLExportIterator.hxx
+++ b/sc/source/filter/xml/XMLExportIterator.hxx
@@ -393,6 +393,7 @@ class ScMyNotEmptyCellsIterator : boost::noncopyable
 
     ScXMLExport&                rExport;
     boost::scoped_ptr<ScHorizontalCellIterator> mpCellItr;
+    const ScRefCellValue* mpCell;
 
     SCCOL                       nCellCol;
     SCROW                       nCellRow;
@@ -429,6 +430,8 @@ public:
     void                        SkipTable(SCTAB nSkip);
 
     bool                        GetNext(ScMyCell& aCell, ScFormatRangeStyles* pCellStyles);
+
+    const ScRefCellValue* GetCell() const;
 };
 
 #endif
commit 97872f87b3b96dea7ca836c2fcee15bc17a8683b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Sat Aug 24 10:17:38 2013 -0400

    Use smart pointer for this.
    
    Change-Id: Ic6b4b56d45a7791a065e7432446edf901ec5e967

diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx
index b192bab..ebd3b8f 100644
--- a/sc/source/filter/xml/XMLExportIterator.cxx
+++ b/sc/source/filter/xml/XMLExportIterator.cxx
@@ -642,7 +642,6 @@ ScMyNotEmptyCellsIterator::ScMyNotEmptyCellsIterator(ScXMLExport& rTempXMLExport
     pDetectiveObj(NULL),
     pDetectiveOp(NULL),
     rExport(rTempXMLExport),
-    pCellItr(NULL),
     nCurrentTable(SCTAB_MAX)
 {
 }
@@ -654,15 +653,13 @@ ScMyNotEmptyCellsIterator::~ScMyNotEmptyCellsIterator()
 
 void ScMyNotEmptyCellsIterator::Clear()
 {
-    if (pCellItr)
-        delete pCellItr;
     if (!aAnnotations.empty())
     {
         OSL_FAIL("not all Annotations saved");
         aAnnotations.clear();
     }
     maNoteExportList.clear();
-    pCellItr = NULL;
+    mpCellItr.reset();
     pShapes = NULL;
     pNoteShapes = NULL;
     pMergedRanges = NULL;
@@ -675,7 +672,7 @@ void ScMyNotEmptyCellsIterator::Clear()
 
 void ScMyNotEmptyCellsIterator::UpdateAddress( table::CellAddress& rAddress )
 {
-    if( pCellItr->GetPos( nCellCol, nCellRow ) )
+    if (mpCellItr->GetPos(nCellCol, nCellRow))
     {
         rAddress.Column = nCellCol;
         rAddress.Row = nCellRow;
@@ -691,7 +688,7 @@ void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, table::CellAddre
     rMyCell.bKnowWhetherIsEditCell = false;
     rMyCell.bIsEditCell = false;
     if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) )
-        pCellItr->GetNext( nCellCol, nCellRow );
+        mpCellItr->GetNext(nCellCol, nCellRow);
 }
 
 void ScMyNotEmptyCellsIterator::SetMatrixCellData( ScMyCell& rMyCell )
@@ -766,10 +763,12 @@ void ScMyNotEmptyCellsIterator::SetCurrentTable(const SCTAB nTable,
     {
         maNoteExportList.clear();
         nCurrentTable = nTable;
-        if (pCellItr)
-            delete pCellItr;
-        pCellItr = new ScHorizontalCellIterator(rExport.GetDocument(), nCurrentTable, 0, 0,
-            static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)), static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable)));
+
+        mpCellItr.reset(
+            new ScHorizontalCellIterator(
+                rExport.GetDocument(), nCurrentTable, 0, 0,
+                static_cast<SCCOL>(rExport.GetSharedData()->GetLastColumn(nCurrentTable)),
+                static_cast<SCROW>(rExport.GetSharedData()->GetLastRow(nCurrentTable))));
 
         ScNotes* pNotes = rExport.GetDocument()->GetNotes(nTable);
         if(pNotes)
diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx
index 4a18f68..c27216e 100644
--- a/sc/source/filter/xml/XMLExportIterator.hxx
+++ b/sc/source/filter/xml/XMLExportIterator.hxx
@@ -36,6 +36,9 @@
 #include "postit.hxx"
 #include "cellvalue.hxx"
 
+#include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
+
 class   ScHorizontalCellIterator;
 struct  ScMyCell;
 class   ScXMLExport;
@@ -371,7 +374,7 @@ struct ScNoteExportData
 typedef ::std::list< ScMyExportAnnotation > ScMyExportAnnotationList;
 typedef ::std::set< ScNoteExportData > ScMyNoteExportDataList;
 
-class ScMyNotEmptyCellsIterator
+class ScMyNotEmptyCellsIterator : boost::noncopyable
 {
     com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet> xTable;
     com::sun::star::uno::Reference<com::sun::star::table::XCellRange> xCellRange;
@@ -389,7 +392,7 @@ class ScMyNotEmptyCellsIterator
     ScMyNoteExportDataList::iterator  maNoteExportListItr;
 
     ScXMLExport&                rExport;
-    ScHorizontalCellIterator*   pCellItr;
+    boost::scoped_ptr<ScHorizontalCellIterator> mpCellItr;
 
     SCCOL                       nCellCol;
     SCROW                       nCellRow;


More information about the Libreoffice-commits mailing list