editeng/Library_editeng.mk | 2 - editeng/qa/unit/core-test.cxx | 18 ++++++------- editeng/source/editeng/editobj.cxx | 28 ++++++++++----------- editeng/source/editeng/editobj2.hxx | 4 +-- editeng/source/editeng/impedit4.cxx | 12 +++------ editeng/source/editeng/section.cxx | 21 +++++++++++++++ editeng/source/editeng/sectionattribute.cxx | 21 --------------- include/editeng/editobj.hxx | 14 ++++------ include/editeng/section.hxx | 37 ++++++++++++++++++++++++++++ include/editeng/sectionattribute.hxx | 37 ---------------------------- sc/qa/unit/subsequent_export-test.cxx | 12 ++++----- sc/source/filter/xml/xmlexprt.cxx | 22 ++++++++-------- 12 files changed, 112 insertions(+), 116 deletions(-)
New commits: commit 6a4dd39379a8521a3c870d46b9702e0597a3333f Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Aug 28 14:41:12 2013 -0400 Rename SectionAttribute to Section. It fits better this way. Change-Id: I139de7858e999a6dd26633a548c47634dfad8a65 diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk index c4a9fbe..94e841b 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 ebe7b54..b1c100c 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 7377081..0a67009 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 b243647..8d7fd6d 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 similarity index 70% rename from editeng/source/editeng/sectionattribute.cxx rename to editeng/source/editeng/section.cxx index d8e0e57..2e19d0d 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 53b4cbf..4dd026c 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 similarity index 84% rename from include/editeng/sectionattribute.hxx rename to include/editeng/section.hxx index eafd4e2..4d9ebb6 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 b805e4f..c26d115 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 b083d4f..873da75 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; commit 53bb6c9871482e6d1cac133d79eb9c58f8109fc8 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Aug 28 14:00:32 2013 -0400 String to OUString. Change-Id: I35ac8e9480a7540e049dc251a1470a27f0c2eafd diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index e4de588..3b5bac3 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -2230,7 +2230,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC even out properly with VDev on transitions from wrong => right) */ - if ( !xSpeller.is() ) + if ( !xSpeller.is() ) return; EditPaM aCursorPos; @@ -2273,7 +2273,6 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC break; // Document end or end of invalid region aSel = SelectWord( aSel, i18n::WordType::DICTIONARY_WORD ); - String aWord( GetSelected( aSel ) ); // If afterwards a dot, this must be handed over! // If an abbreviation ... bool bDottAdded = false; @@ -2283,14 +2282,13 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC if ( cNext == '.' ) { aSel.Max().GetIndex()++; - aWord += cNext; bDottAdded = true; } } - + OUString aWord = GetSelected(aSel); bool bChanged = false; - if ( aWord.Len() > 0 ) + if (!aWord.isEmpty()) { sal_uInt16 nWStart = aSel.Min().GetIndex(); sal_uInt16 nWEnd= aSel.Max().GetIndex(); commit 6446ab4f2394505844dd374f3c9cad49ecefb383 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Aug 28 13:43:04 2013 -0400 No need to fully qualify these. Change-Id: Ib5177530b7af15a5574245f53acfecd0ccce4b50 diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index dd19788..e4de588 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -2272,7 +2272,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC || ( ( aSel.Max().GetNode() == pLastNode ) && ( aSel.Max().GetIndex() >= pLastNode->Len() ) ) ) break; // Document end or end of invalid region - aSel = SelectWord( aSel, ::com::sun::star::i18n::WordType::DICTIONARY_WORD ); + aSel = SelectWord( aSel, i18n::WordType::DICTIONARY_WORD ); String aWord( GetSelected( aSel ) ); // If afterwards a dot, this must be handed over! // If an abbreviation ... @@ -2345,7 +2345,7 @@ void ImpEditEngine::DoOnlineSpelling( ContentNode* pThisNodeOnly, bool bSpellAtC } EditPaM aLastEnd( aSel.Max() ); - aSel = WordRight( aSel.Max(), ::com::sun::star::i18n::WordType::DICTIONARY_WORD ); + aSel = WordRight( aSel.Max(), i18n::WordType::DICTIONARY_WORD ); if ( bChanged && ( aSel.Min().GetNode() == pNode ) && ( ( aSel.Min().GetIndex()-aLastEnd.GetIndex() > 1 ) ) ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits