diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-28 14:41:12 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-28 14:48:11 -0400 |
commit | 6a4dd39379a8521a3c870d46b9702e0597a3333f (patch) | |
tree | f9df11fee5cc108ef70391eaf000af02b1bdf73c | |
parent | 53bb6c9871482e6d1cac133d79eb9c58f8109fc8 (diff) |
Rename SectionAttribute to Section.
It fits better this way.
Change-Id: I139de7858e999a6dd26633a548c47634dfad8a65
-rw-r--r-- | editeng/Library_editeng.mk | 2 | ||||
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 18 | ||||
-rw-r--r-- | editeng/source/editeng/editobj.cxx | 28 | ||||
-rw-r--r-- | editeng/source/editeng/editobj2.hxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/section.cxx (renamed from editeng/source/editeng/sectionattribute.cxx) | 6 | ||||
-rw-r--r-- | include/editeng/editobj.hxx | 14 | ||||
-rw-r--r-- | include/editeng/section.hxx (renamed from include/editeng/sectionattribute.hxx) | 6 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 12 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 22 |
9 files changed, 55 insertions, 57 deletions
diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk index c4a9fbeb9c7d..94e841bca389 100644 --- a/editeng/Library_editeng.mk +++ b/editeng/Library_editeng.mk @@ -60,7 +60,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\ editeng/source/editeng/impedit3 \ editeng/source/editeng/impedit4 \ editeng/source/editeng/impedit5 \ - editeng/source/editeng/sectionattribute \ + editeng/source/editeng/section \ editeng/source/editeng/textconv \ editeng/source/items/borderline \ editeng/source/items/bulitem \ diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index ebe7b54aef11..b1c100c48380 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -23,7 +23,7 @@ #include "editeng/unofield.hxx" #include "editeng/wghtitem.hxx" #include "editeng/postitem.hxx" -#include "editeng/sectionattribute.hxx" +#include "editeng/section.hxx" #include "editeng/editobj.hxx" #include <com/sun/star/text/textfield/Type.hpp> @@ -342,7 +342,7 @@ void Test::testAutocorrect() } } -bool hasBold(const editeng::SectionAttribute& rSecAttr) +bool hasBold(const editeng::Section& rSecAttr) { std::vector<const SfxPoolItem*>::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end(); for (; it != itEnd; ++it) @@ -359,7 +359,7 @@ bool hasBold(const editeng::SectionAttribute& rSecAttr) return false; } -bool hasItalic(const editeng::SectionAttribute& rSecAttr) +bool hasItalic(const editeng::Section& rSecAttr) { std::vector<const SfxPoolItem*>::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end(); for (; it != itEnd; ++it) @@ -397,14 +397,14 @@ void Test::testSectionAttributes() aEngine.QuickSetAttribs(*pSet, ESelection(0,3,0,9)); // 'bbbccc' boost::scoped_ptr<EditTextObject> pEditText(aEngine.CreateTextObject()); CPPUNIT_ASSERT_MESSAGE("Failed to create text object.", pEditText.get()); - std::vector<editeng::SectionAttribute> aAttrs; - pEditText->GetAllSectionAttributes(aAttrs); + std::vector<editeng::Section> aAttrs; + pEditText->GetAllSections(aAttrs); // Now, we should have a total of 3 sections. CPPUNIT_ASSERT_MESSAGE("There should be 3 sections.", aAttrs.size() == 3); // First section should be 0-3 of paragraph 0, and it should only have boldness applied. - const editeng::SectionAttribute* pSecAttr = &aAttrs[0]; + const editeng::Section* pSecAttr = &aAttrs[0]; CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnParagraph); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnStart); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pSecAttr->mnEnd); @@ -447,13 +447,13 @@ void Test::testSectionAttributes() boost::scoped_ptr<EditTextObject> pEditText(aEngine.CreateTextObject()); CPPUNIT_ASSERT_MESSAGE("Failed to create text object.", pEditText.get()); - std::vector<editeng::SectionAttribute> aAttrs; - pEditText->GetAllSectionAttributes(aAttrs); + std::vector<editeng::Section> aAttrs; + pEditText->GetAllSections(aAttrs); size_t nSecCountCheck = 5; CPPUNIT_ASSERT_EQUAL(nSecCountCheck, aAttrs.size()); // 1st, 3rd and 5th sections should correspond with 1st, 3rd and 5th paragraphs. - const editeng::SectionAttribute* pSecAttr = &aAttrs[0]; + const editeng::Section* pSecAttr = &aAttrs[0]; CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnParagraph); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pSecAttr->mnStart); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pSecAttr->mnEnd); diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 7377081f142d..0a6700942ad0 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -28,7 +28,7 @@ #include "editeng/fieldupdater.hxx" #include "editeng/macros.hxx" -#include "editeng/sectionattribute.hxx" +#include "editeng/section.hxx" #include <editobj2.hxx> #include <editeng/editdata.hxx> #include <editattr.hxx> @@ -277,9 +277,9 @@ bool EditTextObject::RemoveCharAttribs( sal_uInt16 nWhich ) return mpImpl->RemoveCharAttribs(nWhich); } -void EditTextObject::GetAllSectionAttributes( std::vector<editeng::SectionAttribute>& rAttrs ) const +void EditTextObject::GetAllSections( std::vector<editeng::Section>& rAttrs ) const { - mpImpl->GetAllSectionAttributes(rAttrs); + mpImpl->GetAllSections(rAttrs); } void EditTextObject::GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const @@ -832,24 +832,24 @@ bool EditTextObjectImpl::RemoveCharAttribs( sal_uInt16 _nWhich ) namespace { -class FindByParagraph : std::unary_function<editeng::SectionAttribute, bool> +class FindByParagraph : std::unary_function<editeng::Section, bool> { size_t mnPara; public: FindByParagraph(size_t nPara) : mnPara(nPara) {} - bool operator() (const editeng::SectionAttribute& rAttr) const + bool operator() (const editeng::Section& rAttr) const { return rAttr.mnParagraph == mnPara; } }; -class FindBySectionStart : std::unary_function<editeng::SectionAttribute, bool> +class FindBySectionStart : std::unary_function<editeng::Section, bool> { size_t mnPara; size_t mnStart; public: FindBySectionStart(size_t nPara, size_t nStart) : mnPara(nPara), mnStart(nStart) {} - bool operator() (const editeng::SectionAttribute& rAttr) const + bool operator() (const editeng::Section& rAttr) const { return rAttr.mnParagraph == mnPara && rAttr.mnStart == mnStart; } @@ -857,7 +857,7 @@ public: } -void EditTextObjectImpl::GetAllSectionAttributes( std::vector<editeng::SectionAttribute>& rAttrs ) const +void EditTextObjectImpl::GetAllSections( std::vector<editeng::Section>& rAttrs ) const { typedef std::vector<size_t> SectionBordersType; typedef std::vector<SectionBordersType> ParagraphsType; @@ -892,7 +892,7 @@ void EditTextObjectImpl::GetAllSectionAttributes( std::vector<editeng::SectionAt rBorders.erase(itUniqueEnd, rBorders.end()); } - std::vector<editeng::SectionAttribute> aAttrs; + std::vector<editeng::Section> aAttrs; // Create storage for each section. Note that this creates storage even // for unformatted sections. The entries are sorted first by paragraph, @@ -905,7 +905,7 @@ void EditTextObjectImpl::GetAllSectionAttributes( std::vector<editeng::SectionAt if (rBorders.size() == 1 && rBorders[0] == 0) { // Empty paragraph. Push an empty section. - aAttrs.push_back(editeng::SectionAttribute(nPara, 0, 0)); + aAttrs.push_back(editeng::Section(nPara, 0, 0)); continue; } @@ -915,7 +915,7 @@ void EditTextObjectImpl::GetAllSectionAttributes( std::vector<editeng::SectionAt for (++itBorder; itBorder != itBorderEnd; ++itBorder, nPrev = nCur) { nCur = *itBorder; - aAttrs.push_back(editeng::SectionAttribute(nPara, nPrev, nCur)); + aAttrs.push_back(editeng::Section(nPara, nPrev, nCur)); } } @@ -923,7 +923,7 @@ void EditTextObjectImpl::GetAllSectionAttributes( std::vector<editeng::SectionAt return; // Go through all formatted paragraphs, and store format items. - std::vector<editeng::SectionAttribute>::iterator itAttr = aAttrs.begin(); + std::vector<editeng::Section>::iterator itAttr = aAttrs.begin(); for (size_t nPara = 0; nPara < aContents.size(); ++nPara) { const ContentInfo& rC = aContents[nPara]; @@ -941,7 +941,7 @@ void EditTextObjectImpl::GetAllSectionAttributes( std::vector<editeng::SectionAt continue; size_t nStart = rXAttr.GetStart(), nEnd = rXAttr.GetEnd(); - std::vector<editeng::SectionAttribute>::iterator itCurAttr = itAttr; + std::vector<editeng::Section>::iterator itCurAttr = itAttr; // Find the container whose start position matches. itCurAttr = std::find_if(itCurAttr, aAttrs.end(), FindBySectionStart(nPara, nStart)); @@ -951,7 +951,7 @@ void EditTextObjectImpl::GetAllSectionAttributes( std::vector<editeng::SectionAt for (; itCurAttr != aAttrs.end() && itCurAttr->mnParagraph == nPara && itCurAttr->mnEnd <= nEnd; ++itCurAttr) { - editeng::SectionAttribute& rSecAttr = *itCurAttr; + editeng::Section& rSecAttr = *itCurAttr; rSecAttr.maAttributes.push_back(pItem); } } diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx index b243647dccc1..8d7fd6d19dab 100644 --- a/editeng/source/editeng/editobj2.hxx +++ b/editeng/source/editeng/editobj2.hxx @@ -30,7 +30,7 @@ namespace editeng { -struct SectionAttribute; +struct Section; } @@ -225,7 +225,7 @@ public: bool RemoveCharAttribs( sal_uInt16 nWhich = 0 ); - void GetAllSectionAttributes( std::vector<editeng::SectionAttribute>& rAttrs ) const; + void GetAllSections( std::vector<editeng::Section>& rAttrs ) const; bool IsFieldObject() const; const SvxFieldItem* GetField() const; diff --git a/editeng/source/editeng/sectionattribute.cxx b/editeng/source/editeng/section.cxx index d8e0e575e1fb..2e19d0db186c 100644 --- a/editeng/source/editeng/sectionattribute.cxx +++ b/editeng/source/editeng/section.cxx @@ -7,13 +7,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "editeng/sectionattribute.hxx" +#include "editeng/section.hxx" namespace editeng { -SectionAttribute::SectionAttribute() : mnParagraph(0), mnStart(0), mnEnd(0) {} +Section::Section() : mnParagraph(0), mnStart(0), mnEnd(0) {} -SectionAttribute::SectionAttribute(size_t nPara, size_t nStart, size_t nEnd) : +Section::Section(size_t nPara, size_t nStart, size_t nEnd) : mnParagraph(nPara), mnStart(nStart), mnEnd(nEnd){} } diff --git a/include/editeng/editobj.hxx b/include/editeng/editobj.hxx index 53b4cbfd0cb0..4dd026cf52cd 100644 --- a/include/editeng/editobj.hxx +++ b/include/editeng/editobj.hxx @@ -45,7 +45,7 @@ namespace editeng { class FieldUpdater; class FieldUpdaterImpl; -struct SectionAttribute; +struct Section; } @@ -101,14 +101,12 @@ public: bool RemoveCharAttribs( sal_uInt16 nWhich = 0 ); /** - * Get all attributes that are applied to this content, separated by - * sections. If multiple attributes are applied to the same section, the - * object representing that section will store multiple attributes. - * 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]. + * Get all text sections in this content. Sections are non-overlapping + * segments of text split either by paragraph boundaries or format + * boundaries. Each section object contains all applied formats and/or a + * field item. */ - void GetAllSectionAttributes( std::vector<editeng::SectionAttribute>& rAttrs ) const; + void GetAllSections( std::vector<editeng::Section>& rAttrs ) const; bool IsFieldObject() const; const SvxFieldItem* GetField() const; diff --git a/include/editeng/sectionattribute.hxx b/include/editeng/section.hxx index eafd4e2e320c..4d9ebb60486d 100644 --- a/include/editeng/sectionattribute.hxx +++ b/include/editeng/section.hxx @@ -18,7 +18,7 @@ class SfxPoolItem; namespace editeng { -struct EDITENG_DLLPUBLIC SectionAttribute +struct EDITENG_DLLPUBLIC Section { size_t mnParagraph; size_t mnStart; @@ -26,8 +26,8 @@ struct EDITENG_DLLPUBLIC SectionAttribute std::vector<const SfxPoolItem*> maAttributes; - SectionAttribute(); - SectionAttribute(size_t nPara, size_t nStart, size_t nEnd); + Section(); + Section(size_t nPara, size_t nStart, size_t nEnd); }; } diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index b805e4f85efd..c26d11550e97 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -37,7 +37,7 @@ #include "editeng/editdata.hxx" #include "editeng/eeitem.hxx" #include "editeng/editobj.hxx" -#include "editeng/sectionattribute.hxx" +#include "editeng/section.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -347,7 +347,7 @@ void ScExportTest::testRichTextExportODS() { struct { - static bool isBold(const editeng::SectionAttribute& rAttr) + static bool isBold(const editeng::Section& rAttr) { if (rAttr.maAttributes.empty()) return false; @@ -364,7 +364,7 @@ void ScExportTest::testRichTextExportODS() return false; } - static bool isItalic(const editeng::SectionAttribute& rAttr) + static bool isItalic(const editeng::Section& rAttr) { if (rAttr.maAttributes.empty()) return false; @@ -392,13 +392,13 @@ void ScExportTest::testRichTextExportODS() if (pText->GetText(0) != "Bold and Italic") return false; - std::vector<editeng::SectionAttribute> aSecAttrs; - pText->GetAllSectionAttributes(aSecAttrs); + std::vector<editeng::Section> aSecAttrs; + pText->GetAllSections(aSecAttrs); if (aSecAttrs.size() != 3) return false; // Check the first bold section. - const editeng::SectionAttribute* pAttr = &aSecAttrs[0]; + const editeng::Section* pAttr = &aSecAttrs[0]; if (pAttr->mnParagraph != 0 ||pAttr->mnStart != 0 || pAttr->mnEnd != 4) return false; diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index b083d4fd49bf..873da75d9497 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -81,7 +81,7 @@ #include "editeng/kernitem.hxx" #include "editeng/langitem.hxx" #include "editeng/postitem.hxx" -#include "editeng/sectionattribute.hxx" +#include "editeng/section.hxx" #include "editeng/shdditem.hxx" #include "editeng/udlnitem.hxx" #include "editeng/wghtitem.hxx" @@ -1344,12 +1344,12 @@ void ScXMLExport::ExportCellTextAutoStyles(sal_Int32 nTable) sal_Int32 nCellCount = 0; for (const EditTextObject* pEdit = aIter.first(); pEdit; pEdit = aIter.next(), ++nCellCount) { - std::vector<editeng::SectionAttribute> aAttrs; - pEdit->GetAllSectionAttributes(aAttrs); + std::vector<editeng::Section> aAttrs; + pEdit->GetAllSections(aAttrs); if (aAttrs.empty()) continue; - std::vector<editeng::SectionAttribute>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end(); + std::vector<editeng::Section>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end(); for (; itSec != itSecEnd; ++itSec) { const std::vector<const SfxPoolItem*>& rSecAttrs = itSec->maAttributes; @@ -3163,7 +3163,7 @@ void flushParagraph( ScXMLExport& rExport, const OUString& rParaText, UniReference<XMLPropertySetMapper> xMapper, UniReference<SvXMLAutoStylePoolP> xStylePool, const ScXMLEditAttributeMap& rAttrMap, - std::vector<editeng::SectionAttribute>::const_iterator it, std::vector<editeng::SectionAttribute>::const_iterator itEnd ) + std::vector<editeng::Section>::const_iterator it, std::vector<editeng::Section>::const_iterator itEnd ) { OUString aElemName = rExport.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_TEXT, GetXMLToken(XML_P)); @@ -3171,7 +3171,7 @@ void flushParagraph( for (; it != itEnd; ++it) { - const editeng::SectionAttribute& rSec = *it; + const editeng::Section& rSec = *it; const sal_Unicode* pBeg = rParaText.getStr(); std::advance(pBeg, rSec.mnStart); @@ -3377,14 +3377,14 @@ void ScXMLExport::WriteEditCell(const EditTextObject* pText) aParaTexts.push_back(pText->GetText(i)); // Get all section data and iterate through them. - std::vector<editeng::SectionAttribute> aAttrs; - pText->GetAllSectionAttributes(aAttrs); - std::vector<editeng::SectionAttribute>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end(); - std::vector<editeng::SectionAttribute>::const_iterator itPara = itSec; + std::vector<editeng::Section> aAttrs; + pText->GetAllSections(aAttrs); + std::vector<editeng::Section>::const_iterator itSec = aAttrs.begin(), itSecEnd = aAttrs.end(); + std::vector<editeng::Section>::const_iterator itPara = itSec; size_t nCurPara = 0; // current paragraph for (; itSec != itSecEnd; ++itSec) { - const editeng::SectionAttribute& rSec = *itSec; + const editeng::Section& rSec = *itSec; if (nCurPara == rSec.mnParagraph) // Still in the same paragraph. continue; |