diff options
Diffstat (limited to 'sw/source/core/unocore/unosett.cxx')
-rw-r--r-- | sw/source/core/unocore/unosett.cxx | 527 |
1 files changed, 98 insertions, 429 deletions
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index af6633e05222..c57c6ffe9d18 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -25,7 +25,6 @@ #include <poolfmt.hxx> #include <fmtcol.hxx> #include <unomap.hxx> -//#include <unostyle.hxx> #include <unosett.hxx> #include <unoprnms.hxx> #include <ftninfo.hxx> @@ -37,7 +36,6 @@ #include <docsh.hxx> #include <docary.hxx> #include <docstyle.hxx> -#include <fmtclds.hxx> #include <editeng/brushitem.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/text/FootnoteNumbering.hpp> @@ -47,7 +45,6 @@ #include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/style/VerticalAlignment.hpp> #include <o3tl/any.hxx> #include <o3tl/enumarray.hxx> #include <tools/UnitConversion.hxx> @@ -73,7 +70,6 @@ #include <svl/listener.hxx> #include <paratr.hxx> #include <sal/log.hxx> -#include <numeric> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -90,11 +86,6 @@ namespace return pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->GetNotifier(); } } -// Constants for the css::text::ColumnSeparatorStyle -#define API_COL_LINE_NONE 0 -#define API_COL_LINE_SOLID 1 -#define API_COL_LINE_DOTTED 2 -#define API_COL_LINE_DASHED 3 #define WID_PREFIX 0 #define WID_SUFFIX 1 @@ -123,19 +114,18 @@ static const SfxItemPropertySet* GetFootnoteSet() { static const SfxItemPropertyMapEntry aFootnoteMap_Impl[] = { - { u"" UNO_NAME_ANCHOR_CHAR_STYLE_NAME,WID_ANCHOR_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_BEGIN_NOTICE, WID_BEGIN_NOTICE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_CHAR_STYLE_NAME, WID_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_END_NOTICE, WID_END_NOTICE , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_FOOTNOTE_COUNTING, WID_FOOTNOTE_COUNTING, ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_NUMBERING_TYPE, WID_NUMBERING_TYPE, ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_PAGE_STYLE_NAME, WID_PAGE_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_PARA_STYLE_NAME, WID_PARAGRAPH_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_POSITION_END_OF_DOC, WID_POSITION_END_OF_DOC,cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_PREFIX, WID_PREFIX, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_START_AT, WID_START_AT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_SUFFIX, WID_SUFFIX, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"", 0, css::uno::Type(), 0, 0 } + { UNO_NAME_ANCHOR_CHAR_STYLE_NAME,WID_ANCHOR_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_BEGIN_NOTICE, WID_BEGIN_NOTICE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_CHAR_STYLE_NAME, WID_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_END_NOTICE, WID_END_NOTICE , ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_FOOTNOTE_COUNTING, WID_FOOTNOTE_COUNTING, ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_NUMBERING_TYPE, WID_NUMBERING_TYPE, ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_PAGE_STYLE_NAME, WID_PAGE_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_PARA_STYLE_NAME, WID_PARAGRAPH_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_POSITION_END_OF_DOC, WID_POSITION_END_OF_DOC,cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_PREFIX, WID_PREFIX, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_START_AT, WID_START_AT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_SUFFIX, WID_SUFFIX, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, }; static const SfxItemPropertySet aFootnoteSet_Impl(aFootnoteMap_Impl); return &aFootnoteSet_Impl; @@ -145,15 +135,14 @@ static const SfxItemPropertySet* GetEndnoteSet() { static const SfxItemPropertyMapEntry aEndnoteMap_Impl[] = { - { u"" UNO_NAME_ANCHOR_CHAR_STYLE_NAME,WID_ANCHOR_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_CHAR_STYLE_NAME, WID_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_NUMBERING_TYPE, WID_NUMBERING_TYPE, ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_PAGE_STYLE_NAME, WID_PAGE_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_PARA_STYLE_NAME, WID_PARAGRAPH_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_PREFIX, WID_PREFIX, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_START_AT, WID_START_AT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_SUFFIX, WID_SUFFIX, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"", 0, css::uno::Type(), 0, 0 } + { UNO_NAME_ANCHOR_CHAR_STYLE_NAME,WID_ANCHOR_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_CHAR_STYLE_NAME, WID_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_NUMBERING_TYPE, WID_NUMBERING_TYPE, ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_PAGE_STYLE_NAME, WID_PAGE_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_PARA_STYLE_NAME, WID_PARAGRAPH_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_PREFIX, WID_PREFIX, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_START_AT, WID_START_AT , ::cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_SUFFIX, WID_SUFFIX, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, }; static const SfxItemPropertySet aEndnoteSet_Impl(aEndnoteMap_Impl); return &aEndnoteSet_Impl; @@ -163,13 +152,12 @@ static const SfxItemPropertySet* GetNumberingRulesSet() { static const SfxItemPropertyMapEntry aNumberingRulesMap_Impl[] = { - { u"" UNO_NAME_IS_ABSOLUTE_MARGINS, WID_IS_ABS_MARGINS, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_IS_AUTOMATIC, WID_IS_AUTOMATIC, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_IS_CONTINUOUS_NUMBERING, WID_CONTINUOUS, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_NAME, WID_RULE_NAME , ::cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0}, - { u"" UNO_NAME_NUMBERING_IS_OUTLINE, WID_IS_OUTLINE, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_DEFAULT_LIST_ID, WID_DEFAULT_LIST_ID, ::cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0}, - { u"", 0, css::uno::Type(), 0, 0 } + { UNO_NAME_IS_ABSOLUTE_MARGINS, WID_IS_ABS_MARGINS, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_IS_AUTOMATIC, WID_IS_AUTOMATIC, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_IS_CONTINUOUS_NUMBERING, WID_CONTINUOUS, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_NAME, WID_RULE_NAME , ::cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0}, + { UNO_NAME_NUMBERING_IS_OUTLINE, WID_IS_OUTLINE, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_DEFAULT_LIST_ID, WID_DEFAULT_LIST_ID, ::cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0}, }; static const SfxItemPropertySet aNumberingRulesSet_Impl( aNumberingRulesMap_Impl ); return &aNumberingRulesSet_Impl; @@ -179,18 +167,17 @@ static const SfxItemPropertySet* GetLineNumberingSet() { static const SfxItemPropertyMapEntry aLineNumberingMap_Impl[] = { - { u"" UNO_NAME_CHAR_STYLE_NAME, WID_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_COUNT_EMPTY_LINES, WID_COUNT_EMPTY_LINES , cppu::UnoType<bool>::get(),PROPERTY_NONE, 0}, - { u"" UNO_NAME_COUNT_LINES_IN_FRAMES, WID_COUNT_LINES_IN_FRAMES, cppu::UnoType<bool>::get(),PROPERTY_NONE, 0}, - { u"" UNO_NAME_DISTANCE, WID_DISTANCE , ::cppu::UnoType<sal_Int32>::get(),PROPERTY_NONE, 0}, - { u"" UNO_NAME_IS_ON, WID_NUM_ON, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, - { u"" UNO_NAME_INTERVAL, WID_INTERVAL , ::cppu::UnoType<sal_Int16>::get(),PROPERTY_NONE, 0}, - { u"" UNO_NAME_SEPARATOR_TEXT, WID_SEPARATOR_TEXT, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_NUMBER_POSITION, WID_NUMBER_POSITION, ::cppu::UnoType<sal_Int16>::get(),PROPERTY_NONE, 0}, - { u"" UNO_NAME_NUMBERING_TYPE, WID_NUMBERING_TYPE , ::cppu::UnoType<sal_Int16>::get(),PROPERTY_NONE, 0}, - { u"" UNO_NAME_RESTART_AT_EACH_PAGE, WID_RESTART_AT_EACH_PAGE, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, - { u"" UNO_NAME_SEPARATOR_INTERVAL, WID_SEPARATOR_INTERVAL, ::cppu::UnoType<sal_Int16>::get(),PROPERTY_NONE, 0}, - { u"", 0, css::uno::Type(), 0, 0 } + { UNO_NAME_CHAR_STYLE_NAME, WID_CHARACTER_STYLE, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_COUNT_EMPTY_LINES, WID_COUNT_EMPTY_LINES , cppu::UnoType<bool>::get(),PROPERTY_NONE, 0}, + { UNO_NAME_COUNT_LINES_IN_FRAMES, WID_COUNT_LINES_IN_FRAMES, cppu::UnoType<bool>::get(),PROPERTY_NONE, 0}, + { UNO_NAME_DISTANCE, WID_DISTANCE , ::cppu::UnoType<sal_Int32>::get(),PROPERTY_NONE, 0}, + { UNO_NAME_IS_ON, WID_NUM_ON, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, + { UNO_NAME_INTERVAL, WID_INTERVAL , ::cppu::UnoType<sal_Int16>::get(),PROPERTY_NONE, 0}, + { UNO_NAME_SEPARATOR_TEXT, WID_SEPARATOR_TEXT, ::cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, + { UNO_NAME_NUMBER_POSITION, WID_NUMBER_POSITION, ::cppu::UnoType<sal_Int16>::get(),PROPERTY_NONE, 0}, + { UNO_NAME_NUMBERING_TYPE, WID_NUMBERING_TYPE , ::cppu::UnoType<sal_Int16>::get(),PROPERTY_NONE, 0}, + { UNO_NAME_RESTART_AT_EACH_PAGE, WID_RESTART_AT_EACH_PAGE, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, + { UNO_NAME_SEPARATOR_INTERVAL, WID_SEPARATOR_INTERVAL, ::cppu::UnoType<sal_Int16>::get(),PROPERTY_NONE, 0}, }; static const SfxItemPropertySet aLineNumberingSet_Impl(aLineNumberingMap_Impl); return &aLineNumberingSet_Impl; @@ -249,24 +236,14 @@ static SwPageDesc* lcl_GetPageDesc(SwDoc* pDoc, const uno::Any& aValue) } // Numbering -const o3tl::enumarray<SvxAdjust, unsigned short> aSvxToUnoAdjust +const o3tl::enumarray<SvxAdjust, sal_Int16> aSvxToUnoAdjust { text::HoriOrientation::LEFT, //3 text::HoriOrientation::RIGHT, //1 - USHRT_MAX, + sal_Int16(-1), text::HoriOrientation::CENTER, //2 - USHRT_MAX, - USHRT_MAX -}; - -const unsigned short aUnoToSvxAdjust[] = -{ - USHRT_MAX, - static_cast<unsigned short>(SvxAdjust::Right), // 1 - static_cast<unsigned short>(SvxAdjust::Center), // 3 - static_cast<unsigned short>(SvxAdjust::Left), // 0 - USHRT_MAX, - USHRT_MAX + sal_Int16(-1), + sal_Int16(-1) }; OUString SwXFootnoteProperties::getImplementationName() @@ -310,10 +287,10 @@ void SwXFootnoteProperties::setPropertyValue(const OUString& rPropertyName, cons const SfxItemPropertyMapEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); if(!pEntry) - throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, getXWeak() ); if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw PropertyVetoException("Property is read-only: " + rPropertyName, getXWeak() ); SwFootnoteInfo aFootnoteInfo(m_pDoc->GetFootnoteInfo()); switch(pEntry->nWID) { @@ -431,7 +408,7 @@ uno::Any SwXFootnoteProperties::getPropertyValue(const OUString& rPropertyName) const SfxItemPropertyMapEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); if(!pEntry) - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw UnknownPropertyException("Unknown property: " + rPropertyName, getXWeak() ); const SwFootnoteInfo& rFootnoteInfo = m_pDoc->GetFootnoteInfo(); switch(pEntry->nWID) @@ -589,10 +566,10 @@ void SwXEndnoteProperties::setPropertyValue(const OUString& rPropertyName, const const SfxItemPropertyMapEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); if(!pEntry) - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw UnknownPropertyException("Unknown property: " + rPropertyName, getXWeak() ); if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw PropertyVetoException("Property is read-only: " + rPropertyName, getXWeak() ); SwEndNoteInfo aEndInfo(m_pDoc->GetEndNoteInfo()); switch(pEntry->nWID) { @@ -663,7 +640,7 @@ uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName) { const SfxItemPropertyMapEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); if(!pEntry) - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw UnknownPropertyException("Unknown property: " + rPropertyName, getXWeak() ); const SwEndNoteInfo& rEndInfo = m_pDoc->GetEndNoteInfo(); switch(pEntry->nWID) @@ -792,10 +769,10 @@ void SwXLineNumberingProperties::setPropertyValue( const SfxItemPropertyMapEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); if(!pEntry) - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw UnknownPropertyException("Unknown property: " + rPropertyName, getXWeak() ); if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw PropertyVetoException("Property is read-only: " + rPropertyName, getXWeak() ); SwLineNumberInfo aFontMetric(m_pDoc->GetLineNumberInfo()); switch(pEntry->nWID) { @@ -846,10 +823,10 @@ void SwXLineNumberingProperties::setPropertyValue( { sal_Int32 nVal = 0; aValue >>= nVal; - sal_Int32 nTmp = convertMm100ToTwip(nVal); + sal_Int32 nTmp = o3tl::toTwips(nVal, o3tl::Length::mm100); if (nTmp > SAL_MAX_UINT16) nTmp = SAL_MAX_UINT16; - aFontMetric.SetPosFromLeft( static_cast< sal_uInt16 >(nTmp) ); + aFontMetric.SetPosFromLeft(nTmp); } break; case WID_INTERVAL : @@ -906,7 +883,7 @@ Any SwXLineNumberingProperties::getPropertyValue(const OUString& rPropertyName) const SfxItemPropertyMapEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); if(!pEntry) - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + throw UnknownPropertyException("Unknown property: " + rPropertyName, getXWeak() ); const SwLineNumberInfo& rInfo = m_pDoc->GetLineNumberInfo(); switch(pEntry->nWID) @@ -1003,7 +980,7 @@ void SwXLineNumberingProperties::removeVetoableChangeListener(const OUString& /* OSL_FAIL("not implemented"); } -constexpr OUStringLiteral aInvalidStyle = u"__XXX___invalid"; +constexpr OUString aInvalidStyle = u"__XXX___invalid"_ustr; class SwXNumberingRules::Impl : public SvtListener @@ -1019,26 +996,6 @@ bool SwXNumberingRules::isInvalidStyle(std::u16string_view rName) return rName == aInvalidStyle; } -namespace -{ -} - -const uno::Sequence< sal_Int8 > & SwXNumberingRules::getUnoTunnelId() -{ - static const UnoTunnelIdInit theSwXNumberingRulesUnoTunnelId; - return theSwXNumberingRulesUnoTunnelId.getSeq(); -} - -// return implementation specific data -sal_Int64 SwXNumberingRules::getSomething( const uno::Sequence< sal_Int8 > & rId ) -{ - if( isUnoTunnelId<SwXNumberingRules>(rId) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; -} - OUString SwXNumberingRules::getImplementationName() { return "SwXNumberingRules"; @@ -1092,6 +1049,8 @@ SwXNumberingRules::SwXNumberingRules(SwDocShell& rDocSh) : m_pPropertySet(GetNumberingRulesSet()), m_bOwnNumRuleCreated(false) { + if (!m_pDocShell->GetDoc()) + throw uno::RuntimeException("Unitialized shell passed to SwXNumberingRules constructor"); m_pImpl->StartListening(GetPageDescNotifier(m_pDocShell->GetDoc())); } @@ -1147,7 +1106,6 @@ void SwXNumberingRules::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElemen { SwNumFormat aFormat(aNumRule.Get( i )); if (!m_sNewCharStyleNames[i].isEmpty() && - m_sNewCharStyleNames[i] != UNO_NAME_CHARACTER_FORMAT_NONE && (!aFormat.GetCharFormat() || aFormat.GetCharFormat()->GetName()!= m_sNewCharStyleNames[i])) { SwCharFormat* pCharFormat = nullptr; @@ -1182,7 +1140,7 @@ void SwXNumberingRules::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElemen SwXNumberingRules::SetNumberingRuleByIndex( *pRule, *rProperties, nIndex); - pRule->Validate(); + pRule->Validate(*m_pDoc); } else throw uno::RuntimeException(); @@ -1231,7 +1189,7 @@ sal_Bool SwXNumberingRules::hasElements() return true; } -static const char* STR_POOLCOLL_HEADLINE_ARY[] +const TranslateId STR_POOLCOLL_HEADLINE_ARY[] { STR_POOLCOLL_HEADLINE1, STR_POOLCOLL_HEADLINE2, @@ -1251,7 +1209,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetNumberingRuleByIndex( SolarMutexGuard aGuard; OSL_ENSURE( 0 <= nIndex && nIndex < MAXLEVEL, "index out of range" ); - const SwNumFormat& rFormat = rNumRule.Get( static_cast<sal_uInt16>(nIndex) ); + const SwNumFormat& rFormat = rNumRule.Get( o3tl::narrowing<sal_uInt16>(nIndex) ); SwCharFormat* pCharFormat = rFormat.GetCharFormat(); OUString CharStyleName; @@ -1341,6 +1299,9 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat aPropertyValues.push_back(comphelper::makePropertyValue("ListFormat", rFormat.GetListFormat())); } + if (rFormat.GetIsLegal()) + aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_LEVEL_IS_LEGAL, true)); + //char style name aUString.clear(); SwStyleNameMapper::FillProgName( rCharFormatName, aUString, SwGetPoolIdFromName::ChrFmt); @@ -1418,7 +1379,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat nINT16 = cBullet; aPropertyValues.push_back(comphelper::makePropertyValue("BulletId", nINT16)); - const vcl::Font* pFont = rFormat.GetBulletFont(); + std::optional<vcl::Font> pFont = rFormat.GetBulletFont(); //BulletChar aUString = OUString(&cBullet, 1); @@ -1479,7 +1440,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex( SolarMutexGuard aGuard; OSL_ENSURE( 0 <= nIndex && nIndex < MAXLEVEL, "index out of range" ); - SwNumFormat aFormat(rNumRule.Get( static_cast<sal_uInt16>(nIndex) )); + SwNumFormat aFormat(rNumRule.Get( o3tl::narrowing<sal_uInt16>(nIndex) )); OUString sHeadingStyleName; OUString sParagraphStyleName; @@ -1525,7 +1486,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex( } } - rNumRule.Set(static_cast<sal_uInt16>(nIndex), aFormat); + rNumRule.Set(o3tl::narrowing<sal_uInt16>(nIndex), aFormat); } void SwXNumberingRules::SetPropertiesToNumFormat( @@ -1551,14 +1512,20 @@ void SwXNumberingRules::SetPropertiesToNumFormat( { sal_Int16 nValue = text::HoriOrientation::NONE; rProp.Value >>= nValue; - if (nValue > text::HoriOrientation::NONE && - nValue <= text::HoriOrientation::LEFT && - USHRT_MAX != aUnoToSvxAdjust[nValue]) - { - aFormat.SetNumAdjust(static_cast<SvxAdjust>(aUnoToSvxAdjust[nValue])); - } - else + switch (nValue) { + case text::HoriOrientation::RIGHT: + aFormat.SetNumAdjust(SvxAdjust::Right); + break; + case text::HoriOrientation::CENTER: + aFormat.SetNumAdjust(SvxAdjust::Center); + break; + case text::HoriOrientation::LEFT: + aFormat.SetNumAdjust(SvxAdjust::Left); + break; + default: bWrongArg = true; + break; + } } else if (rProp.Name == UNO_NAME_PARENT_NUMBERING) { @@ -1587,28 +1554,18 @@ void SwXNumberingRules::SetPropertiesToNumFormat( OUString sCharFormatName; SwStyleNameMapper::FillUIName( uTmp, sCharFormatName, SwGetPoolIdFromName::ChrFmt ); SwDoc *const pLocalDoc = pDocShell ? pDocShell->GetDoc() : pDoc; - if (sCharFormatName == UNO_NAME_CHARACTER_FORMAT_NONE) + if (sCharFormatName.isEmpty()) { - rCharStyleName = aInvalidStyle; + rCharStyleName.clear(); aFormat.SetCharFormat(nullptr); + aFormat.SetCharFormatName(""); } else if (pLocalDoc) { - const SwCharFormats* pFormats = pLocalDoc->GetCharFormats(); - const size_t nChCount = pFormats->size(); - SwCharFormat* pCharFormat = nullptr; if (!sCharFormatName.isEmpty()) { - for(size_t j = 0; j< nChCount; ++j) - { - SwCharFormat* pTmp = (*pFormats)[j]; - if(pTmp->GetName() == sCharFormatName) - { - pCharFormat = pTmp; - break; - } - } + pCharFormat = pLocalDoc->FindCharFormatByName(sCharFormatName); if(!pCharFormat) { @@ -1640,14 +1597,14 @@ void SwXNumberingRules::SetPropertiesToNumFormat( sal_Int32 nValue = 0; rProp.Value >>= nValue; // #i23727# nValue can be negative - aFormat.SetAbsLSpace(convertMm100ToTwip(nValue)); + aFormat.SetAbsLSpace(o3tl::toTwips(nValue, o3tl::Length::mm100)); } else if (rProp.Name == UNO_NAME_SYMBOL_TEXT_DISTANCE) { sal_Int32 nValue = 0; rProp.Value >>= nValue; if (nValue >= 0) - aFormat.SetCharTextDistance(static_cast<short>(convertMm100ToTwip(nValue))); + aFormat.SetCharTextDistance(o3tl::toTwips(nValue, o3tl::Length::mm100)); else bWrongArg = true; } @@ -1656,7 +1613,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat( sal_Int32 nValue = 0; rProp.Value >>= nValue; // #i23727# nValue can be positive - nValue = convertMm100ToTwip(nValue); + nValue = o3tl::toTwips(nValue, o3tl::Length::mm100); aFormat.SetFirstLineOffset(nValue); } else if (rProp.Name == UNO_NAME_POSITION_AND_SPACE_MODE) @@ -1705,7 +1662,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat( { sal_Int32 nValue = 0; rProp.Value >>= nValue; - nValue = convertMm100ToTwip(nValue); + nValue = o3tl::toTwips(nValue, o3tl::Length::mm100); if ( nValue >= 0 ) { aFormat.SetListtabPos( nValue ); @@ -1719,14 +1676,14 @@ void SwXNumberingRules::SetPropertiesToNumFormat( { sal_Int32 nValue = 0; rProp.Value >>= nValue; - nValue = convertMm100ToTwip(nValue); + nValue = o3tl::toTwips(nValue, o3tl::Length::mm100); aFormat.SetFirstLineIndent( nValue ); } else if (rProp.Name == UNO_NAME_INDENT_AT) { sal_Int32 nValue = 0; rProp.Value >>= nValue; - nValue = convertMm100ToTwip(nValue); + nValue = o3tl::toTwips(nValue, o3tl::Length::mm100); aFormat.SetIndentAt( nValue ); } else if (rProp.Name == UNO_NAME_NUMBERING_TYPE) @@ -1785,9 +1742,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat( static_cast<const SvxFontListItem* >(pLclDocShell ->GetItem( SID_ATTR_CHAR_FONTLIST )); const FontList* pList = pFontListItem->GetFontList(); - FontMetric aFontMetric = pList->Get( - sBulletFontName, WEIGHT_NORMAL, ITALIC_NONE); - vcl::Font aFont(aFontMetric); + vcl::Font aFont(pList->Get(sBulletFontName, WEIGHT_NORMAL, ITALIC_NONE)); aFormat.SetBulletFont(&aFont); } else if (pBulletFontName) @@ -1859,10 +1814,8 @@ void SwXNumberingRules::SetPropertiesToNumFormat( awt::Size size; if (rProp.Value >>= size) { - size.Width = convertMm100ToTwip(size.Width); - size.Height = convertMm100ToTwip(size.Height); - pSetSize->setWidth( size.Width ); - pSetSize->setHeight( size.Height ); + pSetSize->setWidth(o3tl::toTwips(size.Width, o3tl::Length::mm100)); + pSetSize->setHeight(o3tl::toTwips(size.Height, o3tl::Length::mm100)); } else bWrongArg = true; @@ -1925,11 +1878,15 @@ void SwXNumberingRules::SetPropertiesToNumFormat( rProp.Value >>= uTmp; aFormat.SetListFormat(uTmp); } + else if (rProp.Name == UNO_NAME_LEVEL_IS_LEGAL) + { + if (bool bVal; rProp.Value >>= bVal) + aFormat.SetIsLegal(bVal); + } else { // Invalid property name - SAL_WARN("sw.uno", "Unknown/incorrect property " << rProp.Name << ", failing"); - throw uno::RuntimeException("Unknown/incorrect property " + rProp.Name); + throw beans::UnknownPropertyException("Unknown property " + rProp.Name); } } if(!bWrongArg && (pSetBrush || pSetSize || pSetVOrient)) @@ -2041,7 +1998,7 @@ void SwXNumberingRules::setPropertyValue( const OUString& rPropertyName, const A } else if(pCreatedRule) { - pCreatedRule->Validate(); + pCreatedRule->Validate(*m_pDoc); } } @@ -2126,9 +2083,7 @@ OUString SwXNumberingRules::getName() void SwXNumberingRules::setName(const OUString& /*rName*/) { - RuntimeException aExcept; - aExcept.Message = "readonly"; - throw aExcept; + throw RuntimeException("readonly"); } void SwXNumberingRules::Impl::Notify(const SfxHint& rHint) @@ -2166,290 +2121,4 @@ SwXChapterNumbering::~SwXChapterNumbering() { } -OUString SwXTextColumns::getImplementationName() -{ - return "SwXTextColumns"; -} - -sal_Bool SwXTextColumns::supportsService(const OUString& rServiceName) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXTextColumns::getSupportedServiceNames() -{ - Sequence<OUString> aRet { "com.sun.star.text.TextColumns" }; - return aRet; -} - -SwXTextColumns::SwXTextColumns() : - m_nReference(0), - m_bIsAutomaticWidth(true), - m_nAutoDistance(0), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_COLUMS)), - m_nSepLineWidth(0), - m_nSepLineColor(0), //black - m_nSepLineHeightRelative(100),//full height - m_nSepLineVertAlign(style::VerticalAlignment_MIDDLE), - m_bSepLineIsOn(false), - m_nSepLineStyle(API_COL_LINE_NONE) // None -{ -} - -SwXTextColumns::SwXTextColumns(const SwFormatCol& rFormatCol) : - m_nReference(0), - m_aTextColumns(rFormatCol.GetNumCols()), - m_bIsAutomaticWidth(rFormatCol.IsOrtho()), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_COLUMS)) -{ - const sal_uInt16 nItemGutterWidth = rFormatCol.GetGutterWidth(); - m_nAutoDistance = m_bIsAutomaticWidth ? - USHRT_MAX == nItemGutterWidth ? DEF_GUTTER_WIDTH : static_cast<sal_Int32>(nItemGutterWidth) - : 0; - m_nAutoDistance = convertTwipToMm100(m_nAutoDistance); - - TextColumn* pColumns = m_aTextColumns.getArray(); - const SwColumns& rCols = rFormatCol.GetColumns(); - for(sal_Int32 i = 0; i < m_aTextColumns.getLength(); ++i) - { - const SwColumn* pCol = &rCols[i]; - - pColumns[i].Width = pCol->GetWishWidth(); - m_nReference += pColumns[i].Width; - pColumns[i].LeftMargin = convertTwipToMm100(pCol->GetLeft ()); - pColumns[i].RightMargin = convertTwipToMm100(pCol->GetRight()); - } - if(!m_aTextColumns.hasElements()) - m_nReference = USHRT_MAX; - - m_nSepLineWidth = rFormatCol.GetLineWidth(); - m_nSepLineColor = rFormatCol.GetLineColor(); - m_nSepLineHeightRelative = rFormatCol.GetLineHeight(); - m_bSepLineIsOn = rFormatCol.GetLineAdj() != COLADJ_NONE; - sal_Int8 nStyle = API_COL_LINE_NONE; - switch (rFormatCol.GetLineStyle()) - { - case SvxBorderLineStyle::SOLID: nStyle = API_COL_LINE_SOLID; break; - case SvxBorderLineStyle::DOTTED: nStyle= API_COL_LINE_DOTTED; break; - case SvxBorderLineStyle::DASHED: nStyle= API_COL_LINE_DASHED; break; - default: break; - } - m_nSepLineStyle = nStyle; - switch(rFormatCol.GetLineAdj()) - { - case COLADJ_TOP: m_nSepLineVertAlign = style::VerticalAlignment_TOP; break; - case COLADJ_BOTTOM: m_nSepLineVertAlign = style::VerticalAlignment_BOTTOM; break; - case COLADJ_CENTER: - case COLADJ_NONE: m_nSepLineVertAlign = style::VerticalAlignment_MIDDLE; - } -} - -SwXTextColumns::~SwXTextColumns() -{ -} - -sal_Int32 SwXTextColumns::getReferenceValue() -{ - SolarMutexGuard aGuard; - return m_nReference; -} - -sal_Int16 SwXTextColumns::getColumnCount() -{ - SolarMutexGuard aGuard; - return static_cast< sal_Int16>( m_aTextColumns.getLength() ); -} - -void SwXTextColumns::setColumnCount(sal_Int16 nColumns) -{ - SolarMutexGuard aGuard; - if(nColumns <= 0) - throw uno::RuntimeException(); - m_bIsAutomaticWidth = true; - m_aTextColumns.realloc(nColumns); - TextColumn* pCols = m_aTextColumns.getArray(); - m_nReference = USHRT_MAX; - sal_Int32 nWidth = m_nReference / nColumns; - sal_Int32 nDiff = m_nReference - nWidth * nColumns; - sal_Int32 nDist = m_nAutoDistance / 2; - for(sal_Int16 i = 0; i < nColumns; i++) - { - pCols[i].Width = nWidth; - pCols[i].LeftMargin = i == 0 ? 0 : nDist; - pCols[i].RightMargin = i == nColumns - 1 ? 0 : nDist; - } - pCols[nColumns - 1].Width += nDiff; -} - -uno::Sequence< TextColumn > SwXTextColumns::getColumns() -{ - SolarMutexGuard aGuard; - return m_aTextColumns; -} - -void SwXTextColumns::setColumns(const uno::Sequence< TextColumn >& rColumns) -{ - SolarMutexGuard aGuard; - sal_Int32 nReferenceTemp = std::accumulate(rColumns.begin(), rColumns.end(), sal_Int32(0), - [](const sal_Int32 nSum, const TextColumn& rCol) { return nSum + rCol.Width; }); - m_bIsAutomaticWidth = false; - m_nReference = !nReferenceTemp ? USHRT_MAX : nReferenceTemp; - m_aTextColumns = rColumns; -} - -uno::Reference< XPropertySetInfo > SwXTextColumns::getPropertySetInfo( ) -{ - static uno::Reference< beans::XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo(); - return aRef; -} - -void SwXTextColumns::setPropertyValue( const OUString& rPropertyName, const Any& aValue ) -{ - const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName ); - if (!pEntry) - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - - switch(pEntry->nWID) - { - case WID_TXTCOL_LINE_WIDTH: - { - sal_Int32 nTmp = 0; - aValue >>= nTmp; - if(nTmp < 0) - throw IllegalArgumentException(); - m_nSepLineWidth = convertMm100ToTwip(nTmp); - } - break; - case WID_TXTCOL_LINE_COLOR: - aValue >>= m_nSepLineColor; - break; - case WID_TXTCOL_LINE_STYLE: - { - aValue >>= m_nSepLineStyle; - } - break; - case WID_TXTCOL_LINE_REL_HGT: - { - sal_Int8 nTmp = 0; - aValue >>= nTmp; - if(nTmp < 0) - throw IllegalArgumentException(); - m_nSepLineHeightRelative = nTmp; - } - break; - case WID_TXTCOL_LINE_ALIGN: - { - style::VerticalAlignment eAlign; - if(!(aValue >>= eAlign) ) - { - sal_Int8 nTmp = 0; - if (! ( aValue >>= nTmp ) ) - throw IllegalArgumentException(); - m_nSepLineVertAlign = static_cast<style::VerticalAlignment>(nTmp); - } - else - m_nSepLineVertAlign = eAlign; - } - break; - case WID_TXTCOL_LINE_IS_ON: - m_bSepLineIsOn = *o3tl::doAccess<bool>(aValue); - break; - case WID_TXTCOL_AUTO_DISTANCE: - { - sal_Int32 nTmp = 0; - aValue >>= nTmp; - if(nTmp < 0 || nTmp >= m_nReference) - throw IllegalArgumentException(); - m_nAutoDistance = nTmp; - sal_Int32 nColumns = m_aTextColumns.getLength(); - TextColumn* pCols = m_aTextColumns.getArray(); - sal_Int32 nDist = m_nAutoDistance / 2; - for(sal_Int32 i = 0; i < nColumns; i++) - { - pCols[i].LeftMargin = i == 0 ? 0 : nDist; - pCols[i].RightMargin = i == nColumns - 1 ? 0 : nDist; - } - } - break; - } -} - -Any SwXTextColumns::getPropertyValue( const OUString& rPropertyName ) -{ - const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName ); - if (!pEntry) - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - - Any aRet; - switch(pEntry->nWID) - { - case WID_TXTCOL_LINE_WIDTH: - aRet <<= static_cast < sal_Int32 >(convertTwipToMm100(m_nSepLineWidth)); - break; - case WID_TXTCOL_LINE_COLOR: - aRet <<= m_nSepLineColor; - break; - case WID_TXTCOL_LINE_STYLE: - aRet <<= m_nSepLineStyle; - break; - case WID_TXTCOL_LINE_REL_HGT: - aRet <<= m_nSepLineHeightRelative; - break; - case WID_TXTCOL_LINE_ALIGN: - aRet <<= m_nSepLineVertAlign; - break; - case WID_TXTCOL_LINE_IS_ON: - aRet <<= m_bSepLineIsOn; - break; - case WID_TXTCOL_IS_AUTOMATIC : - aRet <<= m_bIsAutomaticWidth; - break; - case WID_TXTCOL_AUTO_DISTANCE: - aRet <<= m_nAutoDistance; - break; - } - return aRet; -} - -void SwXTextColumns::addPropertyChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ ) -{ -} - -void SwXTextColumns::removePropertyChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ ) -{ -} - -void SwXTextColumns::addVetoableChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< XVetoableChangeListener >& /*xListener*/ ) -{ -} - -void SwXTextColumns::removeVetoableChangeListener( - const OUString& /*rPropertyName*/, const uno::Reference< XVetoableChangeListener >& /*xListener*/ ) -{ -} - -namespace -{ -} - -const uno::Sequence< sal_Int8 > & SwXTextColumns::getUnoTunnelId() -{ - static const UnoTunnelIdInit theSwXTextColumnsUnoTunnelId; - return theSwXTextColumnsUnoTunnelId.getSeq(); -} - -sal_Int64 SAL_CALL SwXTextColumns::getSomething( const uno::Sequence< sal_Int8 >& rId ) -{ - if( isUnoTunnelId<SwXTextColumns>(rId) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); - } - return 0; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |