diff options
29 files changed, 2426 insertions, 2568 deletions
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index d413cda631af..e25061c79c33 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -1289,12 +1289,10 @@ sal_Unicode SwAccessibleParagraph::getCharacter( sal_Int32 nIndex ) OUString sText( GetString() ); // return character (if valid) - if( IsValidChar(nIndex, sText.getLength() ) ) - { - return sText[nIndex]; - } - else + if( !IsValidChar(nIndex, sText.getLength() ) ) throw lang::IndexOutOfBoundsException(); + + return sText[nIndex]; } css::uno::Sequence< css::style::TabStop > SwAccessibleParagraph::GetCurrentTabStop( sal_Int32 nIndex ) @@ -2515,13 +2513,11 @@ OUString SwAccessibleParagraph::getTextRange( OUString sText( GetString() ); - if ( IsValidRange( nStartIndex, nEndIndex, sText.getLength() ) ) - { - OrderRange( nStartIndex, nEndIndex ); - return sText.copy(nStartIndex, nEndIndex-nStartIndex ); - } - else + if ( !IsValidRange( nStartIndex, nEndIndex, sText.getLength() ) ) throw lang::IndexOutOfBoundsException(); + + OrderRange( nStartIndex, nEndIndex ); + return sText.copy(nStartIndex, nEndIndex-nStartIndex ); } /*accessibility::*/TextSegment SwAccessibleParagraph::getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType ) @@ -2792,44 +2788,43 @@ sal_Bool SwAccessibleParagraph::replaceText( const OUString& rText = GetString(); - if( IsValidRange( nStartIndex, nEndIndex, rText.getLength() ) ) - { - if( !IsEditableState() ) - return false; + if( !IsValidRange( nStartIndex, nEndIndex, rText.getLength() ) ) + throw lang::IndexOutOfBoundsException(); - SwTextNode* pNode = const_cast<SwTextNode*>( GetTextNode() ); + if( !IsEditableState() ) + return false; - // translate positions - sal_Int32 nStart; - sal_Int32 nEnd; - bool bSuccess = GetPortionData().GetEditableRange( - nStartIndex, nEndIndex, nStart, nEnd ); + SwTextNode* pNode = const_cast<SwTextNode*>( GetTextNode() ); - // edit only if the range is editable - if( bSuccess ) - { - // create SwPosition for nStartIndex - SwIndex aIndex( pNode, nStart ); - SwPosition aStartPos( *pNode, aIndex ); + // translate positions + sal_Int32 nStart; + sal_Int32 nEnd; + bool bSuccess = GetPortionData().GetEditableRange( + nStartIndex, nEndIndex, nStart, nEnd ); - // create SwPosition for nEndIndex - SwPosition aEndPos( aStartPos ); - aEndPos.nContent = nEnd; + // edit only if the range is editable + if( bSuccess ) + { + // create SwPosition for nStartIndex + SwIndex aIndex( pNode, nStart ); + SwPosition aStartPos( *pNode, aIndex ); - // now create XTextRange as helper and set string - const uno::Reference<text::XTextRange> xRange( - SwXTextRange::CreateXTextRange( - *pNode->GetDoc(), aStartPos, &aEndPos)); - xRange->setString(sReplacement); + // create SwPosition for nEndIndex + SwPosition aEndPos( aStartPos ); + aEndPos.nContent = nEnd; - // delete portion data - ClearPortionData(); - } + // now create XTextRange as helper and set string + const uno::Reference<text::XTextRange> xRange( + SwXTextRange::CreateXTextRange( + *pNode->GetDoc(), aStartPos, &aEndPos)); + xRange->setString(sReplacement); - return bSuccess; + // delete portion data + ClearPortionData(); } - else - throw lang::IndexOutOfBoundsException(); + + return bSuccess; + } sal_Bool SwAccessibleParagraph::setAttributes( diff --git a/sw/source/core/unocore/SwXTextDefaults.cxx b/sw/source/core/unocore/SwXTextDefaults.cxx index c90e1212a8f7..4cc17c2ab7cd 100644 --- a/sw/source/core/unocore/SwXTextDefaults.cxx +++ b/sw/source/core/unocore/SwXTextDefaults.cxx @@ -80,40 +80,37 @@ void SAL_CALL SwXTextDefaults::setPropertyValue( const OUString& rPropertyName, (RES_TXTATR_CHARFMT == pMap->nWID)) { OUString uStyle; - if(aValue >>= uStyle) + if(!(aValue >>= uStyle)) + throw lang::IllegalArgumentException(); + + OUString sStyle; + SwStyleNameMapper::FillUIName(uStyle, sStyle, SwGetPoolIdFromName::ChrFmt, true ); + SwDocStyleSheet* pStyle = + static_cast<SwDocStyleSheet*>(m_pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char)); + SwFormatDrop* pDrop = nullptr; + SwFormatCharFormat *pCharFormat = nullptr; + if(!pStyle) + throw lang::IllegalArgumentException(); + + rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *pStyle ) ); + if (xStyle->GetCharFormat() == m_pDoc->GetDfltCharFormat()) + return; // don't SetCharFormat with formats from mpDfltCharFormat + + if (RES_PARATR_DROP == pMap->nWID) { - OUString sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, SwGetPoolIdFromName::ChrFmt, true ); - SwDocStyleSheet* pStyle = - static_cast<SwDocStyleSheet*>(m_pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char)); - SwFormatDrop* pDrop = nullptr; - SwFormatCharFormat *pCharFormat = nullptr; - if(pStyle) - { - rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *pStyle ) ); - if (xStyle->GetCharFormat() == m_pDoc->GetDfltCharFormat()) - return; // don't SetCharFormat with formats from mpDfltCharFormat - - if (RES_PARATR_DROP == pMap->nWID) - { - pDrop = static_cast<SwFormatDrop*>(rItem.Clone()); // because rItem is const... - pDrop->SetCharFormat(xStyle->GetCharFormat()); - m_pDoc->SetDefault(*pDrop); - } - else // RES_TXTATR_CHARFMT == pMap->nWID - { - pCharFormat = static_cast<SwFormatCharFormat*>(rItem.Clone()); // because rItem is const... - pCharFormat->SetCharFormat(xStyle->GetCharFormat()); - m_pDoc->SetDefault(*pCharFormat); - } - } - else - throw lang::IllegalArgumentException(); - delete pDrop; - delete pCharFormat; + pDrop = static_cast<SwFormatDrop*>(rItem.Clone()); // because rItem is const... + pDrop->SetCharFormat(xStyle->GetCharFormat()); + m_pDoc->SetDefault(*pDrop); } - else - throw lang::IllegalArgumentException(); + else // RES_TXTATR_CHARFMT == pMap->nWID + { + pCharFormat = static_cast<SwFormatCharFormat*>(rItem.Clone()); // because rItem is const... + pCharFormat->SetCharFormat(xStyle->GetCharFormat()); + m_pDoc->SetDefault(*pCharFormat); + } + + delete pDrop; + delete pCharFormat; } else { diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 6574c92ff75c..94b6c8053215 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -621,11 +621,10 @@ SwXFieldmark::setPropertyValue(const OUString& PropertyName, { ::sw::mark::ICheckboxFieldmark* pCheckboxFm = getCheckboxFieldmark(); bool bChecked( false ); - if ( pCheckboxFm && ( rValue >>= bChecked ) ) - pCheckboxFm->SetChecked( bChecked ); - else + if ( !(pCheckboxFm && ( rValue >>= bChecked )) ) throw uno::RuntimeException(); + pCheckboxFm->SetChecked( bChecked ); } else SwXFieldmark_Base::setPropertyValue( PropertyName, rValue ); @@ -640,10 +639,10 @@ uno::Any SAL_CALL SwXFieldmark::getPropertyValue(const OUString& rPropertyName) if ( rPropertyName == "Checked" ) { ::sw::mark::ICheckboxFieldmark* pCheckboxFm = getCheckboxFieldmark(); - if ( pCheckboxFm ) - return uno::makeAny( pCheckboxFm->IsChecked() ); - else + if ( !pCheckboxFm ) throw uno::RuntimeException(); + + return uno::makeAny( pCheckboxFm->IsChecked() ); } return SwXFieldmark_Base::getPropertyValue( rPropertyName ); } diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 25217f56e2fa..03dac9d63e22 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -2172,13 +2172,11 @@ void SAL_CALL SwChartDataSequence::setPropertyValue( if (m_bDisposed) throw lang::DisposedException(); - if (rPropertyName == UNO_NAME_ROLE) - { - if ( !(rValue >>= m_aRole) ) - throw lang::IllegalArgumentException(); - } - else + if (rPropertyName != UNO_NAME_ROLE) throw beans::UnknownPropertyException(); + + if ( !(rValue >>= m_aRole) ) + throw lang::IllegalArgumentException(); } uno::Any SAL_CALL SwChartDataSequence::getPropertyValue( @@ -2188,13 +2186,10 @@ uno::Any SAL_CALL SwChartDataSequence::getPropertyValue( if (m_bDisposed) throw lang::DisposedException(); - uno::Any aRes; - if (rPropertyName == UNO_NAME_ROLE) - aRes <<= m_aRole; - else + if (!(rPropertyName == UNO_NAME_ROLE)) throw beans::UnknownPropertyException(); - return aRes; + return uno::Any(m_aRole); } void SAL_CALL SwChartDataSequence::addPropertyChangeListener( diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index fa647bcf9f18..b02349a9e483 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -860,58 +860,55 @@ uno::Any SAL_CALL SwXTextTables::getByIndex(sal_Int32 nInputIndex) { SolarMutexGuard aGuard; uno::Any aRet; - if (IsValid()) - { - if (nInputIndex < 0) - throw IndexOutOfBoundsException(); + if (!IsValid()) + throw uno::RuntimeException(); - SwAutoFormatGetDocNode aGetHt( &GetDoc()->GetNodes() ); - size_t nIndex = static_cast<size_t>(nInputIndex); - size_t nCurrentIndex = 0; + if (nInputIndex < 0) + throw IndexOutOfBoundsException(); - for (SwFrameFormat* const & pFormat : *GetDoc()->GetTableFrameFormats()) + SwAutoFormatGetDocNode aGetHt( &GetDoc()->GetNodes() ); + size_t nIndex = static_cast<size_t>(nInputIndex); + size_t nCurrentIndex = 0; + + for (SwFrameFormat* const & pFormat : *GetDoc()->GetTableFrameFormats()) + { + if (!pFormat->GetInfo(aGetHt)) { - if (!pFormat->GetInfo(aGetHt)) + if (nCurrentIndex == nIndex) { - if (nCurrentIndex == nIndex) - { - uno::Reference<XTextTable> xTable = SwXTextTables::GetObject(*pFormat); - aRet <<= xTable; - return aRet; - } - else - nCurrentIndex++; + uno::Reference<XTextTable> xTable = SwXTextTables::GetObject(*pFormat); + aRet <<= xTable; + return aRet; } + else + nCurrentIndex++; } - throw IndexOutOfBoundsException(); } - else - throw uno::RuntimeException(); + throw IndexOutOfBoundsException(); } uno::Any SwXTextTables::getByName(const OUString& rItemName) { SolarMutexGuard aGuard; uno::Any aRet; - if(IsValid()) + if(!IsValid()) + throw uno::RuntimeException(); + + const size_t nCount = GetDoc()->GetTableFrameFormatCount(true); + uno::Reference< XTextTable > xTable; + for( size_t i = 0; i < nCount; ++i) { - const size_t nCount = GetDoc()->GetTableFrameFormatCount(true); - uno::Reference< XTextTable > xTable; - for( size_t i = 0; i < nCount; ++i) + SwFrameFormat& rFormat = GetDoc()->GetTableFrameFormat(i, true); + if (rItemName == rFormat.GetName()) { - SwFrameFormat& rFormat = GetDoc()->GetTableFrameFormat(i, true); - if (rItemName == rFormat.GetName()) - { - xTable = SwXTextTables::GetObject(rFormat); - aRet <<= xTable; - break; - } + xTable = SwXTextTables::GetObject(rFormat); + aRet <<= xTable; + break; } - if(!xTable.is()) - throw NoSuchElementException(); } - else - throw uno::RuntimeException(); + if(!xTable.is()) + throw NoSuchElementException(); + return aRet; } @@ -939,21 +936,19 @@ sal_Bool SwXTextTables::hasByName(const OUString& rName) { SolarMutexGuard aGuard; bool bRet= false; - if(IsValid()) + if(!IsValid()) + throw uno::RuntimeException(); + + const size_t nCount = GetDoc()->GetTableFrameFormatCount(true); + for( size_t i = 0; i < nCount; ++i) { - const size_t nCount = GetDoc()->GetTableFrameFormatCount(true); - for( size_t i = 0; i < nCount; ++i) + SwFrameFormat& rFormat = GetDoc()->GetTableFrameFormat(i, true); + if (rName == rFormat.GetName()) { - SwFrameFormat& rFormat = GetDoc()->GetTableFrameFormat(i, true); - if (rName == rFormat.GetName()) - { - bRet = true; - break; - } + bRet = true; + break; } } - else - throw uno::RuntimeException(); return bRet; } @@ -1416,31 +1411,28 @@ uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex) { SolarMutexGuard aGuard; uno::Reference< XTextSection > xRet; - if(IsValid()) - { - SwSectionFormats& rFormats = GetDoc()->GetSections(); + if(!IsValid()) + throw uno::RuntimeException(); - const SwSectionFormats& rSectFormats = GetDoc()->GetSections(); - const size_t nCount = rSectFormats.size(); - for(size_t i = 0; i < nCount; ++i) - { - if( !rSectFormats[i]->IsInNodesArr()) - nIndex ++; - else if(static_cast<size_t>(nIndex) == i) - break; - if(static_cast<size_t>(nIndex) == i) - break; - } - if(nIndex >= 0 && static_cast<size_t>(nIndex) < rFormats.size()) - { - SwSectionFormat* pFormat = rFormats[nIndex]; - xRet = GetObject(*pFormat); - } - else - throw IndexOutOfBoundsException(); + SwSectionFormats& rFormats = GetDoc()->GetSections(); + + const SwSectionFormats& rSectFormats = GetDoc()->GetSections(); + const size_t nCount = rSectFormats.size(); + for(size_t i = 0; i < nCount; ++i) + { + if( !rSectFormats[i]->IsInNodesArr()) + nIndex ++; + else if(static_cast<size_t>(nIndex) == i) + break; + if(static_cast<size_t>(nIndex) == i) + break; } - else - throw uno::RuntimeException(); + if(!(nIndex >= 0 && static_cast<size_t>(nIndex) < rFormats.size())) + throw IndexOutOfBoundsException(); + + SwSectionFormat* pFormat = rFormats[nIndex]; + xRet = GetObject(*pFormat); + return makeAny(xRet); } @@ -1448,26 +1440,25 @@ uno::Any SwXTextSections::getByName(const OUString& rName) { SolarMutexGuard aGuard; uno::Any aRet; - if(IsValid()) + if(!IsValid()) + throw uno::RuntimeException(); + + SwSectionFormats& rFormats = GetDoc()->GetSections(); + uno::Reference< XTextSection > xSect; + for(size_t i = 0; i < rFormats.size(); ++i) { - SwSectionFormats& rFormats = GetDoc()->GetSections(); - uno::Reference< XTextSection > xSect; - for(size_t i = 0; i < rFormats.size(); ++i) + SwSectionFormat* pFormat = rFormats[i]; + if (pFormat->IsInNodesArr() + && (rName == pFormat->GetSection()->GetSectionName())) { - SwSectionFormat* pFormat = rFormats[i]; - if (pFormat->IsInNodesArr() - && (rName == pFormat->GetSection()->GetSectionName())) - { - xSect = GetObject(*pFormat); - aRet <<= xSect; - break; - } + xSect = GetObject(*pFormat); + aRet <<= xSect; + break; } - if(!xSect.is()) - throw NoSuchElementException(); } - else - throw uno::RuntimeException(); + if(!xSect.is()) + throw NoSuchElementException(); + return aRet; } @@ -1538,13 +1529,12 @@ sal_Bool SwXTextSections::hasElements() { SolarMutexGuard aGuard; size_t nCount = 0; - if(IsValid()) - { - SwSectionFormats& rFormats = GetDoc()->GetSections(); - nCount = rFormats.size(); - } - else + if(!IsValid()) throw uno::RuntimeException(); + + SwSectionFormats& rFormats = GetDoc()->GetSections(); + nCount = rFormats.size(); + return nCount > 0; } @@ -1723,20 +1713,19 @@ uno::Any SwXNumberingRulesCollection::getByIndex(sal_Int32 nIndex) { SolarMutexGuard aGuard; uno::Any aRet; - if(IsValid()) - { - uno::Reference< XIndexReplace > xRef; - if ( static_cast<size_t>(nIndex) < GetDoc()->GetNumRuleTable().size() ) - { - xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTable()[ nIndex ], GetDoc()); - aRet <<= xRef; - } + if(!IsValid()) + throw uno::RuntimeException(); - if(!xRef.is()) - throw IndexOutOfBoundsException(); + uno::Reference< XIndexReplace > xRef; + if ( static_cast<size_t>(nIndex) < GetDoc()->GetNumRuleTable().size() ) + { + xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTable()[ nIndex ], GetDoc()); + aRet <<= xRef; } - else - throw uno::RuntimeException(); + + if(!xRef.is()) + throw IndexOutOfBoundsException(); + return aRet; } @@ -1803,32 +1792,31 @@ uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) SolarMutexGuard aGuard; uno::Any aRet; sal_Int32 nCount = 0; - if(IsValid()) + if(!IsValid()) + throw uno::RuntimeException(); + + const size_t nFootnoteCnt = GetDoc()->GetFootnoteIdxs().size(); + SwTextFootnote* pTextFootnote; + uno::Reference< XFootnote > xRef; + for( size_t n = 0; n < nFootnoteCnt; ++n ) { - const size_t nFootnoteCnt = GetDoc()->GetFootnoteIdxs().size(); - SwTextFootnote* pTextFootnote; - uno::Reference< XFootnote > xRef; - for( size_t n = 0; n < nFootnoteCnt; ++n ) - { - pTextFootnote = GetDoc()->GetFootnoteIdxs()[ n ]; - const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote(); - if ( rFootnote.IsEndNote() != m_bEndnote ) - continue; + pTextFootnote = GetDoc()->GetFootnoteIdxs()[ n ]; + const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote(); + if ( rFootnote.IsEndNote() != m_bEndnote ) + continue; - if(nCount == nIndex) - { - xRef = SwXFootnote::CreateXFootnote(*GetDoc(), - &const_cast<SwFormatFootnote&>(rFootnote)); - aRet <<= xRef; - break; - } - nCount++; + if(nCount == nIndex) + { + xRef = SwXFootnote::CreateXFootnote(*GetDoc(), + &const_cast<SwFormatFootnote&>(rFootnote)); + aRet <<= xRef; + break; } - if(!xRef.is()) - throw IndexOutOfBoundsException(); + nCount++; } - else - throw uno::RuntimeException(); + if(!xRef.is()) + throw IndexOutOfBoundsException(); + return aRet; } @@ -1909,21 +1897,18 @@ uno::Any SwXReferenceMarks::getByName(const OUString& rName) { SolarMutexGuard aGuard; uno::Any aRet; - if(IsValid()) - { - SwFormatRefMark *const pMark = - const_cast<SwFormatRefMark*>(GetDoc()->GetRefMark(rName)); - if(pMark) - { - uno::Reference<XTextContent> const xRef = - SwXReferenceMark::CreateXReferenceMark(*GetDoc(), pMark); - aRet <<= xRef; - } - else - throw NoSuchElementException(); - } - else + if(!IsValid()) throw uno::RuntimeException(); + + SwFormatRefMark *const pMark = + const_cast<SwFormatRefMark*>(GetDoc()->GetRefMark(rName)); + if(!pMark) + throw NoSuchElementException(); + + uno::Reference<XTextContent> const xRef = + SwXReferenceMark::CreateXReferenceMark(*GetDoc(), pMark); + aRet <<= xRef; + return aRet; } @@ -1931,17 +1916,16 @@ uno::Sequence< OUString > SwXReferenceMarks::getElementNames() { SolarMutexGuard aGuard; uno::Sequence<OUString> aRet; - if(IsValid()) - { - std::vector<OUString> aStrings; - const sal_uInt16 nCount = GetDoc()->GetRefMarks( &aStrings ); - aRet.realloc(nCount); - OUString* pNames = aRet.getArray(); - for(sal_uInt16 i = 0; i < nCount; i++) - pNames[i] = aStrings[i]; - } - else + if(!IsValid()) throw uno::RuntimeException(); + + std::vector<OUString> aStrings; + const sal_uInt16 nCount = GetDoc()->GetRefMarks( &aStrings ); + aRet.realloc(nCount); + OUString* pNames = aRet.getArray(); + for(sal_uInt16 i = 0; i < nCount; i++) + pNames[i] = aStrings[i]; + return aRet; } diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 6a6da5c57d9e..f76260626e28 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -673,20 +673,19 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape) if( pDesc && (xRg = pDesc->GetTextRange()).is() ) { pInternalPam = new SwUnoInternalPaM(*pDoc); - if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg)) + if (!::sw::XTextRangeToSwPaM(*pInternalPam, xRg)) + throw uno::RuntimeException(); + + if(RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() && + !pInternalPam->GetNode().FindFlyStartNode()) { - if(RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() && - !pInternalPam->GetNode().FindFlyStartNode()) - { - aAnchor.SetType(RndStdIds::FLY_AS_CHAR); - } - else if (RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId()) - { - aAnchor.SetAnchor(pInternalPam->Start()); - } + aAnchor.SetType(RndStdIds::FLY_AS_CHAR); } - else - throw uno::RuntimeException(); + else if (RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId()) + { + aAnchor.SetAnchor(pInternalPam->Start()); + } + } else if ((aAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE) && pDoc->getIDocumentLayoutAccess().GetCurrentLayout()) { @@ -1128,49 +1127,48 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a new SwUnoInternalPaM( *(pFormat->GetDoc()) )); uno::Reference< text::XTextRange > xRg; aValue >>= xRg; - if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) ) + if (!::sw::XTextRangeToSwPaM(*pInternalPam, xRg) ) { - if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR) - { - //delete old SwFormatFlyCnt - //With AnchorAsCharacter the current TextAttribute has to be deleted. - //Tbis removes the frame format too. - //To prevent this the connection between format and attribute has to be broken before. - const SwPosition *pPos = aAnchor.GetContentAnchor(); - SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode(); - SAL_WARN_IF( !pTextNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." ); - const sal_Int32 nIdx = pPos->nContent.GetIndex(); - SwTextAttr * const pHint = - pTextNode->GetTextAttrForCharAt( - nIdx, RES_TXTATR_FLYCNT ); - assert(pHint && "Missing Hint."); - SAL_WARN_IF( pHint->Which() != RES_TXTATR_FLYCNT, - "sw.uno", "Missing FlyInCnt-Hint." ); - SAL_WARN_IF( pHint->GetFlyCnt().GetFrameFormat() != pFormat, - "sw.uno", "Wrong TextFlyCnt-Hint." ); - const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()) - .SetFlyFormat(); - - //The connection is removed now the attribute can be deleted. - pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx ); - //create a new one - SwTextNode *pNd = pInternalPam->GetNode().GetTextNode(); - SAL_WARN_IF( !pNd, "sw.uno", "Cursor not at TextNode." ); - SwFormatFlyCnt aFormat( pFormat ); - pNd->InsertItem(aFormat, pInternalPam->GetPoint() - ->nContent.GetIndex(), 0 ); - } - else - { - aAnchor.SetAnchor( pInternalPam->GetPoint() ); - aSet.Put(aAnchor); - pFormat->SetFormatAttr(aSet); - } + throw uno::RuntimeException(); + } + + if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR) + { + //delete old SwFormatFlyCnt + //With AnchorAsCharacter the current TextAttribute has to be deleted. + //Tbis removes the frame format too. + //To prevent this the connection between format and attribute has to be broken before. + const SwPosition *pPos = aAnchor.GetContentAnchor(); + SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode(); + SAL_WARN_IF( !pTextNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." ); + const sal_Int32 nIdx = pPos->nContent.GetIndex(); + SwTextAttr * const pHint = + pTextNode->GetTextAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); + assert(pHint && "Missing Hint."); + SAL_WARN_IF( pHint->Which() != RES_TXTATR_FLYCNT, + "sw.uno", "Missing FlyInCnt-Hint." ); + SAL_WARN_IF( pHint->GetFlyCnt().GetFrameFormat() != pFormat, + "sw.uno", "Wrong TextFlyCnt-Hint." ); + const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt()) + .SetFlyFormat(); + + //The connection is removed now the attribute can be deleted. + pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx ); + //create a new one + SwTextNode *pNd = pInternalPam->GetNode().GetTextNode(); + SAL_WARN_IF( !pNd, "sw.uno", "Cursor not at TextNode." ); + SwFormatFlyCnt aFormat( pFormat ); + pNd->InsertItem(aFormat, pInternalPam->GetPoint() + ->nContent.GetIndex(), 0 ); } else { - throw uno::RuntimeException(); + aAnchor.SetAnchor( pInternalPam->GetPoint() ); + aSet.Put(aAnchor); + pFormat->SetFormatAttr(aSet); } + } } else if (pEntry->nWID == FN_TEXT_BOX) @@ -1760,112 +1758,111 @@ uno::Sequence< beans::PropertyState > SwXShape::getPropertyStates( SolarMutexGuard aGuard; SwFrameFormat* pFormat = GetFrameFormat(); uno::Sequence< beans::PropertyState > aRet(aPropertyNames.getLength()); - if(xShapeAgg.is()) + if(!xShapeAgg.is()) + throw uno::RuntimeException(); + + SvxShape* pSvxShape = GetSvxShape(); + bool bGroupMember = false; + bool bFormControl = false; + SdrObject* pObject = pSvxShape ? pSvxShape->GetSdrObject() : nullptr; + if(pObject) { - SvxShape* pSvxShape = GetSvxShape(); - bool bGroupMember = false; - bool bFormControl = false; - SdrObject* pObject = pSvxShape ? pSvxShape->GetSdrObject() : nullptr; - if(pObject) - { - bGroupMember = pObject->GetUpGroup() != nullptr; - bFormControl = pObject->GetObjInventor() == SdrInventor::FmForm; - } - const OUString* pNames = aPropertyNames.getConstArray(); - beans::PropertyState* pRet = aRet.getArray(); - uno::Reference< XPropertyState > xShapePrState; - for(sal_Int32 nProperty = 0; nProperty < aPropertyNames.getLength(); nProperty++) + bGroupMember = pObject->GetUpGroup() != nullptr; + bFormControl = pObject->GetObjInventor() == SdrInventor::FmForm; + } + const OUString* pNames = aPropertyNames.getConstArray(); + beans::PropertyState* pRet = aRet.getArray(); + uno::Reference< XPropertyState > xShapePrState; + for(sal_Int32 nProperty = 0; nProperty < aPropertyNames.getLength(); nProperty++) + { + const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( pNames[nProperty] ); + if(pEntry) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( pNames[nProperty] ); - if(pEntry) + if(RES_OPAQUE == pEntry->nWID) + pRet[nProperty] = bFormControl ? + beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE; + else if(FN_ANCHOR_POSITION == pEntry->nWID) + pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; + else if(FN_TEXT_RANGE == pEntry->nWID) + pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; + else if(bGroupMember) + pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE; + else if (pEntry->nWID == RES_FRM_SIZE && + (pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT_RELATION || + pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION)) + pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; + else if (pEntry->nWID == FN_TEXT_BOX) { - if(RES_OPAQUE == pEntry->nWID) - pRet[nProperty] = bFormControl ? - beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE; - else if(FN_ANCHOR_POSITION == pEntry->nWID) - pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; - else if(FN_TEXT_RANGE == pEntry->nWID) + // The TextBox property is set, if we can find a textbox for this shape. + if (pFormat && SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT)) pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; - else if(bGroupMember) + else pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE; - else if (pEntry->nWID == RES_FRM_SIZE && - (pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT_RELATION || - pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION)) - pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; - else if (pEntry->nWID == FN_TEXT_BOX) - { - // The TextBox property is set, if we can find a textbox for this shape. - if (pFormat && SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT)) - pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; - else - pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE; - } - else if(pFormat) - { - const SwAttrSet& rSet = pFormat->GetAttrSet(); - SfxItemState eItemState = rSet.GetItemState(pEntry->nWID, false); + } + else if(pFormat) + { + const SwAttrSet& rSet = pFormat->GetAttrSet(); + SfxItemState eItemState = rSet.GetItemState(pEntry->nWID, false); - if(SfxItemState::SET == eItemState) - pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; - else if(SfxItemState::DEFAULT == eItemState) - pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE; - else - pRet[nProperty] = beans::PropertyState_AMBIGUOUS_VALUE; - } + if(SfxItemState::SET == eItemState) + pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; + else if(SfxItemState::DEFAULT == eItemState) + pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE; else + pRet[nProperty] = beans::PropertyState_AMBIGUOUS_VALUE; + } + else + { + SfxPoolItem* pItem = nullptr; + switch(pEntry->nWID) { - SfxPoolItem* pItem = nullptr; - switch(pEntry->nWID) + case RES_ANCHOR: + pItem = pImpl->GetAnchor(); + break; + case RES_HORI_ORIENT: + pItem = pImpl->GetHOrient(); + break; + case RES_VERT_ORIENT: + pItem = pImpl->GetVOrient(); + break; + case RES_LR_SPACE: + pItem = pImpl->GetLRSpace(); + break; + case RES_UL_SPACE: + pItem = pImpl->GetULSpace(); + break; + case RES_SURROUND: + pItem = pImpl->GetSurround(); + break; + // #i28701# + case RES_WRAP_INFLUENCE_ON_OBJPOS: { - case RES_ANCHOR: - pItem = pImpl->GetAnchor(); - break; - case RES_HORI_ORIENT: - pItem = pImpl->GetHOrient(); - break; - case RES_VERT_ORIENT: - pItem = pImpl->GetVOrient(); - break; - case RES_LR_SPACE: - pItem = pImpl->GetLRSpace(); - break; - case RES_UL_SPACE: - pItem = pImpl->GetULSpace(); - break; - case RES_SURROUND: - pItem = pImpl->GetSurround(); - break; - // #i28701# - case RES_WRAP_INFLUENCE_ON_OBJPOS: - { - pItem = pImpl->GetWrapInfluenceOnObjPos(); - } - break; + pItem = pImpl->GetWrapInfluenceOnObjPos(); } - if(pItem) - pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; - else - pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE; + break; } + if(pItem) + pRet[nProperty] = beans::PropertyState_DIRECT_VALUE; + else + pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE; } - else + } + else + { + if(!xShapePrState.is()) { - if(!xShapePrState.is()) - { - const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get(); - uno::Any aPState = xShapeAgg->queryAggregation(rPStateType); - auto ps = o3tl::tryAccess<uno::Reference<XPropertyState>>( - aPState); - if(!ps) - throw uno::RuntimeException(); - xShapePrState = *ps; - } - pRet[nProperty] = xShapePrState->getPropertyState(pNames[nProperty]); + const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get(); + uno::Any aPState = xShapeAgg->queryAggregation(rPStateType); + auto ps = o3tl::tryAccess<uno::Reference<XPropertyState>>( + aPState); + if(!ps) + throw uno::RuntimeException(); + xShapePrState = *ps; } + pRet[nProperty] = xShapePrState->getPropertyState(pNames[nProperty]); } } - else - throw uno::RuntimeException(); + return aRet; } @@ -1873,62 +1870,61 @@ void SwXShape::setPropertyToDefault( const OUString& rPropertyName ) { SolarMutexGuard aGuard; SwFrameFormat* pFormat = GetFrameFormat(); - if(xShapeAgg.is()) + if(!xShapeAgg.is()) + throw uno::RuntimeException(); + + const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName ); + if(pEntry) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName ); - if(pEntry) + if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) + throw uno::RuntimeException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + if(pFormat) { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw uno::RuntimeException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - if(pFormat) - { - const SfxItemSet& rSet = pFormat->GetAttrSet(); - SfxItemSet aSet(pFormat->GetDoc()->GetAttrPool(), {{pEntry->nWID, pEntry->nWID}}); - aSet.SetParent(&rSet); - aSet.ClearItem(pEntry->nWID); - pFormat->GetDoc()->SetAttr(aSet, *pFormat); - } - else + const SfxItemSet& rSet = pFormat->GetAttrSet(); + SfxItemSet aSet(pFormat->GetDoc()->GetAttrPool(), {{pEntry->nWID, pEntry->nWID}}); + aSet.SetParent(&rSet); + aSet.ClearItem(pEntry->nWID); + pFormat->GetDoc()->SetAttr(aSet, *pFormat); + } + else + { + switch(pEntry->nWID) { - switch(pEntry->nWID) + case RES_ANCHOR: pImpl->RemoveAnchor(); break; + case RES_HORI_ORIENT: pImpl->RemoveHOrient(); break; + case RES_VERT_ORIENT: pImpl->RemoveVOrient(); break; + case RES_LR_SPACE: pImpl->RemoveLRSpace(); break; + case RES_UL_SPACE: pImpl->RemoveULSpace(); break; + case RES_SURROUND: pImpl->RemoveSurround();break; + case RES_OPAQUE : pImpl->SetOpaque(false); break; + case FN_TEXT_RANGE : + break; + // #i26791# + case RES_FOLLOW_TEXT_FLOW: { - case RES_ANCHOR: pImpl->RemoveAnchor(); break; - case RES_HORI_ORIENT: pImpl->RemoveHOrient(); break; - case RES_VERT_ORIENT: pImpl->RemoveVOrient(); break; - case RES_LR_SPACE: pImpl->RemoveLRSpace(); break; - case RES_UL_SPACE: pImpl->RemoveULSpace(); break; - case RES_SURROUND: pImpl->RemoveSurround();break; - case RES_OPAQUE : pImpl->SetOpaque(false); break; - case FN_TEXT_RANGE : - break; - // #i26791# - case RES_FOLLOW_TEXT_FLOW: - { - pImpl->RemoveFollowTextFlow(); - } - break; - // #i28701# - case RES_WRAP_INFLUENCE_ON_OBJPOS: - { - pImpl->RemoveWrapInfluenceOnObjPos(); - } - break; + pImpl->RemoveFollowTextFlow(); } + break; + // #i28701# + case RES_WRAP_INFLUENCE_ON_OBJPOS: + { + pImpl->RemoveWrapInfluenceOnObjPos(); + } + break; } } - else - { - const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get(); - uno::Any aPState = xShapeAgg->queryAggregation(rPStateType); - auto xShapePrState = o3tl::tryAccess<uno::Reference<XPropertyState>>( - aPState); - if(!xShapePrState) - throw uno::RuntimeException(); - (*xShapePrState)->setPropertyToDefault( rPropertyName ); - } } else - throw uno::RuntimeException(); + { + const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get(); + uno::Any aPState = xShapeAgg->queryAggregation(rPStateType); + auto xShapePrState = o3tl::tryAccess<uno::Reference<XPropertyState>>( + aPState); + if(!xShapePrState) + throw uno::RuntimeException(); + (*xShapePrState)->setPropertyToDefault( rPropertyName ); + } + } uno::Any SwXShape::getPropertyDefault( const OUString& rPropertyName ) @@ -1936,33 +1932,31 @@ uno::Any SwXShape::getPropertyDefault( const OUString& rPropertyName ) SolarMutexGuard aGuard; SwFrameFormat* pFormat = GetFrameFormat(); uno::Any aRet; - if(xShapeAgg.is()) + if(!xShapeAgg.is()) + throw uno::RuntimeException(); + + const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName ); + if(pEntry) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName ); - if(pEntry) - { - if(pEntry->nWID < RES_FRMATR_END && pFormat) - { - const SfxPoolItem& rDefItem = - pFormat->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); - rDefItem.QueryValue(aRet, pEntry->nMemberId); - } - else - throw uno::RuntimeException(); - } - else - { - const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get(); - uno::Any aPState = xShapeAgg->queryAggregation(rPStateType); - auto xShapePrState = o3tl::tryAccess<uno::Reference<XPropertyState>>( - aPState); - if(!xShapePrState) - throw uno::RuntimeException(); - (*xShapePrState)->getPropertyDefault( rPropertyName ); - } + if(!(pEntry->nWID < RES_FRMATR_END && pFormat)) + throw uno::RuntimeException(); + + const SfxPoolItem& rDefItem = + pFormat->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(aRet, pEntry->nMemberId); + } else - throw uno::RuntimeException(); + { + const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get(); + uno::Any aPState = xShapeAgg->queryAggregation(rPStateType); + auto xShapePrState = o3tl::tryAccess<uno::Reference<XPropertyState>>( + aPState); + if(!xShapePrState) + throw uno::RuntimeException(); + (*xShapePrState)->getPropertyDefault( rPropertyName ); + } + return aRet; } @@ -2740,58 +2734,58 @@ void SwXGroupShape::add( const uno::Reference< XShape >& xShape ) SolarMutexGuard aGuard; SvxShape* pSvxShape = GetSvxShape(); SwFrameFormat* pFormat = GetFrameFormat(); - if(pSvxShape && pFormat) + if(!(pSvxShape && pFormat)) + throw uno::RuntimeException(); + + uno::Reference<XShapes> xShapes; + if( xShapeAgg.is() ) { - uno::Reference<XShapes> xShapes; - if( xShapeAgg.is() ) - { - const uno::Type& rType = cppu::UnoType<XShapes>::get(); - uno::Any aAgg = xShapeAgg->queryAggregation( rType ); - aAgg >>= xShapes; - } - if(xShapes.is()) - xShapes->add(xShape); - else - throw uno::RuntimeException(); + const uno::Type& rType = cppu::UnoType<XShapes>::get(); + uno::Any aAgg = xShapeAgg->queryAggregation( rType ); + aAgg >>= xShapes; + } + if(!xShapes.is()) + throw uno::RuntimeException(); - uno::Reference<lang::XUnoTunnel> xTunnel(xShape, uno::UNO_QUERY); - SwXShape* pSwShape = nullptr; - if(xShape.is()) - pSwShape = reinterpret_cast< SwXShape * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXShape::getUnoTunnelId()) )); - if(pSwShape && pSwShape->m_bDescriptor) + xShapes->add(xShape); + + + uno::Reference<lang::XUnoTunnel> xTunnel(xShape, uno::UNO_QUERY); + SwXShape* pSwShape = nullptr; + if(xShape.is()) + pSwShape = reinterpret_cast< SwXShape * >( + sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXShape::getUnoTunnelId()) )); + if(pSwShape && pSwShape->m_bDescriptor) + { + SvxShape* pAddShape = reinterpret_cast< SvxShape * >( + sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SvxShape::getUnoTunnelId()) )); + if(pAddShape) { - SvxShape* pAddShape = reinterpret_cast< SvxShape * >( - sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SvxShape::getUnoTunnelId()) )); - if(pAddShape) + SdrObject* pObj = pAddShape->GetSdrObject(); + if(pObj) { - SdrObject* pObj = pAddShape->GetSdrObject(); - if(pObj) + SwDoc* pDoc = pFormat->GetDoc(); + // set layer of new drawing + // object to corresponding invisible layer. + if( SdrInventor::FmForm != pObj->GetObjInventor()) { - SwDoc* pDoc = pFormat->GetDoc(); - // set layer of new drawing - // object to corresponding invisible layer. - if( SdrInventor::FmForm != pObj->GetObjInventor()) - { - pObj->SetLayer( pSwShape->pImpl->GetOpaque() - ? pDoc->getIDocumentDrawModelAccess().GetInvisibleHeavenId() - : pDoc->getIDocumentDrawModelAccess().GetInvisibleHellId() ); - } - else - { - pObj->SetLayer(pDoc->getIDocumentDrawModelAccess().GetInvisibleControlsId()); - } + pObj->SetLayer( pSwShape->pImpl->GetOpaque() + ? pDoc->getIDocumentDrawModelAccess().GetInvisibleHeavenId() + : pDoc->getIDocumentDrawModelAccess().GetInvisibleHellId() ); + } + else + { + pObj->SetLayer(pDoc->getIDocumentDrawModelAccess().GetInvisibleControlsId()); } } - pSwShape->m_bDescriptor = false; - //add the group member to the format of the group - SwFrameFormat* pShapeFormat = ::FindFrameFormat( pSvxShape->GetSdrObject() ); - if(pShapeFormat) - pFormat->Add(pSwShape); } + pSwShape->m_bDescriptor = false; + //add the group member to the format of the group + SwFrameFormat* pShapeFormat = ::FindFrameFormat( pSvxShape->GetSdrObject() ); + if(pShapeFormat) + pFormat->Add(pSwShape); } - else - throw uno::RuntimeException(); + } void SwXGroupShape::remove( const uno::Reference< XShape >& xShape ) diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index bee8055a0fa6..0b0d8d0859a1 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -610,21 +610,20 @@ void SAL_CALL SwXFieldMaster::setPropertyValue( // Thus the last property set will be used as Data Source. const sal_uInt16 nMemberValueId = GetFieldTypeMId( rPropertyName, *pType ); - if ( USHRT_MAX != nMemberValueId ) - { - pType->PutValue( rValue, nMemberValueId ); - if ( pType->Which() == SwFieldIds::User ) - { - // trigger update of User field in order to get depending Input Fields updated. - pType->UpdateFields(); - } - } - else + if ( USHRT_MAX == nMemberValueId ) { throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast< cppu::OWeakObject * >( this ) ); } + + pType->PutValue( rValue, nMemberValueId ); + if ( pType->Which() == SwFieldIds::User ) + { + // trigger update of User field in order to get depending Input Fields updated. + pType->UpdateFields(); + } + } } else if (!pType && m_pImpl->m_pDoc && rPropertyName == UNO_NAME_NAME) @@ -1925,26 +1924,25 @@ void SAL_CALL SwXTextField::attach( SwTextAttr* pTextAttr = aPam.GetNode().GetTextNode()->GetFieldTextAttrAt( aPam.GetPoint()->nContent.GetIndex()-1, true ); // What about updating the fields? (see fldmgr.cxx) - if (pTextAttr) - { - const SwFormatField& rField = pTextAttr->GetFormatField(); - m_pImpl->m_pFormatField = &rField; + if (!pTextAttr) + throw uno::RuntimeException("no SwTextAttr inserted?"); // could theoretically happen, if paragraph is full - if ( pTextAttr->Which() == RES_TXTATR_ANNOTATION - && *aPam.GetPoint() != *aPam.GetMark() ) + const SwFormatField& rField = pTextAttr->GetFormatField(); + m_pImpl->m_pFormatField = &rField; + + if ( pTextAttr->Which() == RES_TXTATR_ANNOTATION + && *aPam.GetPoint() != *aPam.GetMark() ) + { + // create annotation mark + const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pTextAttr->GetFormatField().GetField()); + OSL_ENSURE( pPostItField != nullptr, "<SwXTextField::attachToRange(..)> - annotation field missing!" ); + if ( pPostItField != nullptr ) { - // create annotation mark - const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pTextAttr->GetFormatField().GetField()); - OSL_ENSURE( pPostItField != nullptr, "<SwXTextField::attachToRange(..)> - annotation field missing!" ); - if ( pPostItField != nullptr ) - { - IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess(); - pMarksAccess->makeAnnotationMark( aPam, pPostItField->GetName() ); - } + IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess(); + pMarksAccess->makeAnnotationMark( aPam, pPostItField->GetName() ); } } - else // could theoretically happen, if paragraph is full - throw uno::RuntimeException("no SwTextAttr inserted?"); + } delete pField; @@ -1966,52 +1964,51 @@ void SAL_CALL SwXTextField::attach( && m_pImpl->m_nServiceId == SwServiceType::FieldTypeAnnotation ) { SwUnoInternalPaM aIntPam( *m_pImpl->m_pDoc ); - if ( ::sw::XTextRangeToSwPaM( aIntPam, xTextRange ) ) - { - // nothing to do, if the text range only covers the former annotation field - if ( aIntPam.Start()->nNode != aIntPam.End()->nNode - || aIntPam.Start()->nContent.GetIndex() != aIntPam.End()->nContent.GetIndex()-1 ) + if ( !::sw::XTextRangeToSwPaM( aIntPam, xTextRange ) ) + throw lang::IllegalArgumentException(); + + // nothing to do, if the text range only covers the former annotation field + if ( aIntPam.Start()->nNode != aIntPam.End()->nNode + || aIntPam.Start()->nContent.GetIndex() != aIntPam.End()->nContent.GetIndex()-1 ) + { + UnoActionContext aCont( m_pImpl->m_pDoc ); + // insert copy of annotation at new text range + SwPostItField* pPostItField = static_cast< SwPostItField* >(m_pImpl->m_pFormatField->GetField()->CopyField()); + SwFormatField aFormatField( *pPostItField ); + delete pPostItField; + SwPaM aEnd( *aIntPam.End(), *aIntPam.End() ); + m_pImpl->m_pDoc->getIDocumentContentOperations().InsertPoolItem( aEnd, aFormatField ); + // delete former annotation { - UnoActionContext aCont( m_pImpl->m_pDoc ); - // insert copy of annotation at new text range - SwPostItField* pPostItField = static_cast< SwPostItField* >(m_pImpl->m_pFormatField->GetField()->CopyField()); - SwFormatField aFormatField( *pPostItField ); - delete pPostItField; - SwPaM aEnd( *aIntPam.End(), *aIntPam.End() ); - m_pImpl->m_pDoc->getIDocumentContentOperations().InsertPoolItem( aEnd, aFormatField ); - // delete former annotation - { - const SwTextField* pTextField = m_pImpl->m_pFormatField->GetTextField(); - SwTextNode& rTextNode = *pTextField->GetpTextNode(); - SwPaM aPam( rTextNode, pTextField->GetStart() ); - aPam.SetMark(); - aPam.Move(); - m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam); - } - // keep inserted annotation + const SwTextField* pTextField = m_pImpl->m_pFormatField->GetTextField(); + SwTextNode& rTextNode = *pTextField->GetpTextNode(); + SwPaM aPam( rTextNode, pTextField->GetStart() ); + aPam.SetMark(); + aPam.Move(); + m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam); + } + // keep inserted annotation + { + SwTextField* pTextAttr = aEnd.GetNode().GetTextNode()->GetFieldTextAttrAt( aEnd.End()->nContent.GetIndex()-1, true ); + if ( pTextAttr != nullptr ) { - SwTextField* pTextAttr = aEnd.GetNode().GetTextNode()->GetFieldTextAttrAt( aEnd.End()->nContent.GetIndex()-1, true ); - if ( pTextAttr != nullptr ) - { - m_pImpl->m_pFormatField = &pTextAttr->GetFormatField(); + m_pImpl->m_pFormatField = &pTextAttr->GetFormatField(); - if ( *aIntPam.GetPoint() != *aIntPam.GetMark() ) + if ( *aIntPam.GetPoint() != *aIntPam.GetMark() ) + { + // create annotation mark + const SwPostItField* pField = dynamic_cast< const SwPostItField* >(pTextAttr->GetFormatField().GetField()); + OSL_ENSURE( pField != nullptr, "<SwXTextField::attach(..)> - annotation field missing!" ); + if ( pField != nullptr ) { - // create annotation mark - const SwPostItField* pField = dynamic_cast< const SwPostItField* >(pTextAttr->GetFormatField().GetField()); - OSL_ENSURE( pField != nullptr, "<SwXTextField::attach(..)> - annotation field missing!" ); - if ( pField != nullptr ) - { - IDocumentMarkAccess* pMarksAccess = aIntPam.GetDoc()->getIDocumentMarkAccess(); - pMarksAccess->makeAnnotationMark( aIntPam, pField->GetName() ); - } + IDocumentMarkAccess* pMarksAccess = aIntPam.GetDoc()->getIDocumentMarkAccess(); + pMarksAccess->makeAnnotationMark( aIntPam, pField->GetName() ); } } } } } - else - throw lang::IllegalArgumentException(); + } else throw lang::IllegalArgumentException(); @@ -2251,10 +2248,11 @@ SwXTextField::setPropertyValue( } if (pBool) { - if( auto b = o3tl::tryAccess<bool>(rValue) ) - *pBool = *b; - else + auto b = o3tl::tryAccess<bool>(rValue); + if( !b ) throw lang::IllegalArgumentException(); + *pBool = *b; + } } else diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 9b33f94a1387..87828b3eb23e 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1498,11 +1498,11 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& // is no contour, or if the contour has been set by the // API itself (or in other words, if the contour isn't // used already). - if( !pNoText->HasContour_() || - !pNoText->IsContourMapModeValid() ) - pNoText->SetPixelContour( *o3tl::doAccess<bool>(aValue) ); - else + if( pNoText->HasContour_() && pNoText->IsContourMapModeValid() ) throw lang::IllegalArgumentException(); + + pNoText->SetPixelContour( *o3tl::doAccess<bool>(aValue) ); + } else { @@ -1535,45 +1535,44 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID) { SwFrameFormat *pFrameFormat = lcl_GetFrameFormat( aValue, pFormat->GetDoc() ); - if( pFrameFormat ) - { - UnoActionContext aAction(pFormat->GetDoc()); + if( !pFrameFormat ) + throw lang::IllegalArgumentException(); - SfxItemSet* pSet = nullptr; - // #i31771#, #i25798# - No adjustment of - // anchor ( no call of method <sw_ChkAndSetNewAnchor(..)> ), - // if document is currently in reading mode. - if ( !pFormat->GetDoc()->IsInReading() ) + UnoActionContext aAction(pFormat->GetDoc()); + + SfxItemSet* pSet = nullptr; + // #i31771#, #i25798# - No adjustment of + // anchor ( no call of method <sw_ChkAndSetNewAnchor(..)> ), + // if document is currently in reading mode. + if ( !pFormat->GetDoc()->IsInReading() ) + { + // see SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Point* pDocPos ) + SwFlyFrame *pFly = nullptr; { - // see SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Point* pDocPos ) - SwFlyFrame *pFly = nullptr; - { - const SwFrameFormat* pFormatXX = pFormat; - if (dynamic_cast<const SwFlyFrameFormat*>( pFormatXX) ) - pFly = static_cast<const SwFlyFrameFormat*>(pFormatXX)->GetFrame(); - } - if ( pFly ) + const SwFrameFormat* pFormatXX = pFormat; + if (dynamic_cast<const SwFlyFrameFormat*>( pFormatXX) ) + pFly = static_cast<const SwFlyFrameFormat*>(pFormatXX)->GetFrame(); + } + if ( pFly ) + { + const ::SfxPoolItem* pItem; + if( SfxItemState::SET == pFrameFormat->GetItemState( RES_ANCHOR, false, &pItem )) { - const ::SfxPoolItem* pItem; - if( SfxItemState::SET == pFrameFormat->GetItemState( RES_ANCHOR, false, &pItem )) + pSet = new SfxItemSet( pDoc->GetAttrPool(), aFrameFormatSetRange ); + pSet->Put( *pItem ); + if ( pFormat->GetDoc()->GetEditShell() != nullptr + && !sw_ChkAndSetNewAnchor( *pFly, *pSet ) ) { - pSet = new SfxItemSet( pDoc->GetAttrPool(), aFrameFormatSetRange ); - pSet->Put( *pItem ); - if ( pFormat->GetDoc()->GetEditShell() != nullptr - && !sw_ChkAndSetNewAnchor( *pFly, *pSet ) ) - { - delete pSet; - pSet = nullptr; - } + delete pSet; + pSet = nullptr; } } } - - pFormat->GetDoc()->SetFrameFormatToFly( *pFormat, *pFrameFormat, pSet ); - delete pSet; } - else - throw lang::IllegalArgumentException(); + + pFormat->GetDoc()->SetFrameFormatToFly( *pFormat, *pFrameFormat, pSet ); + delete pSet; + } else if( FN_UNO_GRAPHIC_U_R_L == pEntry->nWID || FN_UNO_GRAPHIC_FILTER == pEntry->nWID) @@ -2569,19 +2568,18 @@ uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName ) if(pFormat) { const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName); - if(pEntry) + if(!pEntry) + throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + + if ( pEntry->nWID < RES_FRMATR_END ) { - if ( pEntry->nWID < RES_FRMATR_END ) - { - const SfxPoolItem& rDefItem = - pFormat->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); - const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); + const SfxPoolItem& rDefItem = + pFormat->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); - rDefItem.QueryValue(aRet, nMemberId); - } + rDefItem.QueryValue(aRet, nMemberId); } - else - throw beans::UnknownPropertyException( "Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + } else if(!IsDescriptor()) throw uno::RuntimeException(); @@ -2655,20 +2653,19 @@ uno::Reference< text::XTextRange > SwXFrame::getAnchor() SolarMutexGuard aGuard; uno::Reference< text::XTextRange > aRef; SwFrameFormat* pFormat = GetFrameFormat(); - if(pFormat) + if(!pFormat) + throw uno::RuntimeException(); + + const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); + // return an anchor for non-page bound frames + // and for page bound frames that have a page no == NULL and a content position + if ((rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE) || + (rAnchor.GetContentAnchor() && !rAnchor.GetPageNum())) { - const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); - // return an anchor for non-page bound frames - // and for page bound frames that have a page no == NULL and a content position - if ((rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE) || - (rAnchor.GetContentAnchor() && !rAnchor.GetPageNum())) - { - const SwPosition &rPos = *(rAnchor.GetContentAnchor()); - aRef = SwXTextRange::CreateXTextRange(*pFormat->GetDoc(), rPos, nullptr); - } + const SwPosition &rPos = *(rAnchor.GetContentAnchor()); + aRef = SwXTextRange::CreateXTextRange(*pFormat->GetDoc(), rPos, nullptr); } - else - throw uno::RuntimeException(); + return aRef; } @@ -2697,379 +2694,378 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan } SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr; - if(pDoc) + if(!pDoc) + throw lang::IllegalArgumentException(); + + SwUnoInternalPaM aIntPam(*pDoc); + // this now needs to return TRUE + ::sw::XTextRangeToSwPaM(aIntPam, xTextRange); + + SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); + SwPaM aPam(rNode); + aPam.Move( fnMoveBackward, GoInDoc ); + static sal_uInt16 const aFrameAttrRange[] = { - SwUnoInternalPaM aIntPam(*pDoc); - // this now needs to return TRUE - ::sw::XTextRangeToSwPaM(aIntPam, xTextRange); + RES_FRMATR_BEGIN, RES_FRMATR_END-1, + RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, - SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); - SwPaM aPam(rNode); - aPam.Move( fnMoveBackward, GoInDoc ); - static sal_uInt16 const aFrameAttrRange[] = - { - RES_FRMATR_BEGIN, RES_FRMATR_END-1, - RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, + // FillAttribute support + XATTR_FILL_FIRST, XATTR_FILL_LAST, - // FillAttribute support - XATTR_FILL_FIRST, XATTR_FILL_LAST, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, + 0 + }; + static sal_uInt16 const aGrAttrRange[] = + { + RES_GRFATR_BEGIN, RES_GRFATR_END-1, + 0 + }; + SfxItemSet aGrSet(pDoc->GetAttrPool(), aGrAttrRange ); - SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, - 0 - }; - static sal_uInt16 const aGrAttrRange[] = - { - RES_GRFATR_BEGIN, RES_GRFATR_END-1, - 0 - }; - SfxItemSet aGrSet(pDoc->GetAttrPool(), aGrAttrRange ); + SfxItemSet aFrameSet(pDoc->GetAttrPool(), aFrameAttrRange ); - SfxItemSet aFrameSet(pDoc->GetAttrPool(), aFrameAttrRange ); + // set correct parent to get the XFILL_NONE FillStyle as needed + aFrameSet.SetParent(&pDoc->GetDfltFrameFormat()->GetAttrSet()); - // set correct parent to get the XFILL_NONE FillStyle as needed - aFrameSet.SetParent(&pDoc->GetDfltFrameFormat()->GetAttrSet()); + // no the related items need to be added to the set + bool bSizeFound; + if(!pProps->AnyToItemSet( pDoc, aFrameSet, aGrSet, bSizeFound)) + throw lang::IllegalArgumentException(); + // a TextRange is handled separately + *aPam.GetPoint() = *aIntPam.GetPoint(); + if(aIntPam.HasMark()) + { + aPam.SetMark(); + *aPam.GetMark() = *aIntPam.GetMark(); + } - // no the related items need to be added to the set - bool bSizeFound; - if(!pProps->AnyToItemSet( pDoc, aFrameSet, aGrSet, bSizeFound)) - throw lang::IllegalArgumentException(); - // a TextRange is handled separately - *aPam.GetPoint() = *aIntPam.GetPoint(); - if(aIntPam.HasMark()) + const SfxPoolItem* pItem; + RndStdIds eAnchorId = RndStdIds::FLY_AT_PARA; + if(SfxItemState::SET == aFrameSet.GetItemState(RES_ANCHOR, false, &pItem) ) + { + eAnchorId = static_cast<const SwFormatAnchor*>(pItem)->GetAnchorId(); + if( RndStdIds::FLY_AT_FLY == eAnchorId && + !aPam.GetNode().FindFlyStartNode()) { - aPam.SetMark(); - *aPam.GetMark() = *aIntPam.GetMark(); + // framebound only where a frame exists + SwFormatAnchor aAnchor(RndStdIds::FLY_AT_PARA); + aFrameSet.Put(aAnchor); } - - const SfxPoolItem* pItem; - RndStdIds eAnchorId = RndStdIds::FLY_AT_PARA; - if(SfxItemState::SET == aFrameSet.GetItemState(RES_ANCHOR, false, &pItem) ) + else if ((RndStdIds::FLY_AT_PAGE == eAnchorId) && + 0 == static_cast<const SwFormatAnchor*>(pItem)->GetPageNum() ) { - eAnchorId = static_cast<const SwFormatAnchor*>(pItem)->GetAnchorId(); - if( RndStdIds::FLY_AT_FLY == eAnchorId && - !aPam.GetNode().FindFlyStartNode()) - { - // framebound only where a frame exists - SwFormatAnchor aAnchor(RndStdIds::FLY_AT_PARA); - aFrameSet.Put(aAnchor); - } - else if ((RndStdIds::FLY_AT_PAGE == eAnchorId) && - 0 == static_cast<const SwFormatAnchor*>(pItem)->GetPageNum() ) - { - SwFormatAnchor aAnchor( *static_cast<const SwFormatAnchor*>(pItem) ); - aAnchor.SetAnchor( aPam.GetPoint() ); - aFrameSet.Put(aAnchor); - } + SwFormatAnchor aAnchor( *static_cast<const SwFormatAnchor*>(pItem) ); + aAnchor.SetAnchor( aPam.GetPoint() ); + aFrameSet.Put(aAnchor); } + } - const ::uno::Any* pStyle; - SwFrameFormat *pParentFrameFormat = nullptr; - if(pProps->GetProperty(FN_UNO_FRAME_STYLE_NAME, 0, pStyle)) - pParentFrameFormat = lcl_GetFrameFormat( *pStyle, pDoc ); + const ::uno::Any* pStyle; + SwFrameFormat *pParentFrameFormat = nullptr; + if(pProps->GetProperty(FN_UNO_FRAME_STYLE_NAME, 0, pStyle)) + pParentFrameFormat = lcl_GetFrameFormat( *pStyle, pDoc ); - SwFlyFrameFormat* pFormat = nullptr; - if( eType == FLYCNTTYPE_FRM) + SwFlyFrameFormat* pFormat = nullptr; + if( eType == FLYCNTTYPE_FRM) + { + UnoActionContext aCont(pDoc); + if(m_pCopySource) { - UnoActionContext aCont(pDoc); - if(m_pCopySource) - { - SwFormatAnchor* pAnchorItem = nullptr; - // the frame is inserted bound to page - // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text - if (eAnchorId != RndStdIds::FLY_AT_PAGE) - { - pAnchorItem = static_cast<SwFormatAnchor*>(aFrameSet.Get(RES_ANCHOR).Clone()); - aFrameSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE, 1 )); - } - - aPam.DeleteMark(); // mark position node will be deleted! - aIntPam.DeleteMark(); // mark position node will be deleted! - pFormat = pDoc->MakeFlyAndMove( *m_pCopySource, aFrameSet, - nullptr, - pParentFrameFormat ); - if(pAnchorItem && pFormat) - { - pFormat->DelFrames(); - pAnchorItem->SetAnchor( m_pCopySource->Start() ); - SfxItemSet aAnchorSet( pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{} ); - aAnchorSet.Put( *pAnchorItem ); - pDoc->SetFlyFrameAttr( *pFormat, aAnchorSet ); - delete pAnchorItem; - } - DELETEZ( m_pCopySource ); - } - else + SwFormatAnchor* pAnchorItem = nullptr; + // the frame is inserted bound to page + // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text + if (eAnchorId != RndStdIds::FLY_AT_PAGE) { - pFormat = pDoc->MakeFlySection( RndStdIds::FLY_AT_PARA, aPam.GetPoint(), - &aFrameSet, pParentFrameFormat ); + pAnchorItem = static_cast<SwFormatAnchor*>(aFrameSet.Get(RES_ANCHOR).Clone()); + aFrameSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE, 1 )); } - if(pFormat) + + aPam.DeleteMark(); // mark position node will be deleted! + aIntPam.DeleteMark(); // mark position node will be deleted! + pFormat = pDoc->MakeFlyAndMove( *m_pCopySource, aFrameSet, + nullptr, + pParentFrameFormat ); + if(pAnchorItem && pFormat) { - pFormat->Add(this); - if(!m_sName.isEmpty()) - pDoc->SetFlyName(*pFormat, m_sName); + pFormat->DelFrames(); + pAnchorItem->SetAnchor( m_pCopySource->Start() ); + SfxItemSet aAnchorSet( pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{} ); + aAnchorSet.Put( *pAnchorItem ); + pDoc->SetFlyFrameAttr( *pFormat, aAnchorSet ); + delete pAnchorItem; } - // wake up the SwXTextFrame - static_cast<SwXTextFrame*>(this)->SetDoc( bIsDescriptor ? m_pDoc : GetFrameFormat()->GetDoc() ); + DELETEZ( m_pCopySource ); } - else if( eType == FLYCNTTYPE_GRF) + else { - UnoActionContext aCont(pDoc); - const ::uno::Any* pGraphicURL; - OUString sGraphicURL; - GraphicObject *pGrfObj = nullptr; - if(pProps->GetProperty(FN_UNO_GRAPHIC_U_R_L, 0, pGraphicURL)) - { - (*pGraphicURL) >>= sGraphicURL; - if( sGraphicURL.startsWith(sPackageProtocol) ) - { - pGrfObj = new GraphicObject; - pGrfObj->SetUserData( sGraphicURL ); - sGraphicURL.clear(); - } - else if( sGraphicURL.startsWith(sGraphicObjectProtocol) ) - { - OString sId(OUStringToOString( - sGraphicURL.copy( sizeof(sGraphicObjectProtocol)-1 ), - RTL_TEXTENCODING_ASCII_US)); - pGrfObj = new GraphicObject( sId ); - sGraphicURL.clear(); - } - } - Graphic aGraphic; - const ::uno::Any* pGraphic; - if( pProps->GetProperty( FN_UNO_GRAPHIC, 0, pGraphic )) + pFormat = pDoc->MakeFlySection( RndStdIds::FLY_AT_PARA, aPam.GetPoint(), + &aFrameSet, pParentFrameFormat ); + } + if(pFormat) + { + pFormat->Add(this); + if(!m_sName.isEmpty()) + pDoc->SetFlyName(*pFormat, m_sName); + } + // wake up the SwXTextFrame + static_cast<SwXTextFrame*>(this)->SetDoc( bIsDescriptor ? m_pDoc : GetFrameFormat()->GetDoc() ); + } + else if( eType == FLYCNTTYPE_GRF) + { + UnoActionContext aCont(pDoc); + const ::uno::Any* pGraphicURL; + OUString sGraphicURL; + GraphicObject *pGrfObj = nullptr; + if(pProps->GetProperty(FN_UNO_GRAPHIC_U_R_L, 0, pGraphicURL)) + { + (*pGraphicURL) >>= sGraphicURL; + if( sGraphicURL.startsWith(sPackageProtocol) ) { - uno::Reference< graphic::XGraphic > xGraphic; - (*pGraphic) >>= xGraphic; - aGraphic = Graphic( xGraphic ); + pGrfObj = new GraphicObject; + pGrfObj->SetUserData( sGraphicURL ); + sGraphicURL.clear(); } - - OUString sFltName; - const ::uno::Any* pFilter; - if(pProps->GetProperty(FN_UNO_GRAPHIC_FILTER, 0, pFilter)) + else if( sGraphicURL.startsWith(sGraphicObjectProtocol) ) { - (*pFilter) >>= sFltName; + OString sId(OUStringToOString( + sGraphicURL.copy( sizeof(sGraphicObjectProtocol)-1 ), + RTL_TEXTENCODING_ASCII_US)); + pGrfObj = new GraphicObject( sId ); + sGraphicURL.clear(); } - - pFormat = (pGrfObj) - ? pDoc->getIDocumentContentOperations().InsertGraphicObject( - aPam, *pGrfObj, &aFrameSet, &aGrSet, pParentFrameFormat) - : pDoc->getIDocumentContentOperations().InsertGraphic( - aPam, sGraphicURL, sFltName, &aGraphic, - &aFrameSet, &aGrSet, pParentFrameFormat); - delete pGrfObj; - if(pFormat) - { - SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFormat->GetContent().GetContentIdx() - ->GetIndex()+1 ]->GetGrfNode(); - if (pGrfNd) - pGrfNd->SetChgTwipSize( !bSizeFound ); - pFormat->Add(this); - if(!m_sName.isEmpty()) - pDoc->SetFlyName(*pFormat, m_sName); - - } - const ::uno::Any* pSurroundContour; - if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUR, pSurroundContour)) - setPropertyValue(UNO_NAME_SURROUND_CONTOUR, *pSurroundContour); - const ::uno::Any* pContourOutside; - if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUROUTSIDE, pContourOutside)) - setPropertyValue(UNO_NAME_CONTOUR_OUTSIDE, *pContourOutside); - const ::uno::Any* pContourPoly; - if(pProps->GetProperty(FN_PARAM_CONTOUR_PP, 0, pContourPoly)) - setPropertyValue(UNO_NAME_CONTOUR_POLY_POLYGON, *pContourPoly); - const ::uno::Any* pPixelContour; - if(pProps->GetProperty(FN_UNO_IS_PIXEL_CONTOUR, 0, pPixelContour)) - setPropertyValue(UNO_NAME_IS_PIXEL_CONTOUR, *pPixelContour); - const ::uno::Any* pAutoContour; - if(pProps->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR, 0, pAutoContour)) - setPropertyValue(UNO_NAME_IS_AUTOMATIC_CONTOUR, *pAutoContour); } - else + Graphic aGraphic; + const ::uno::Any* pGraphic; + if( pProps->GetProperty( FN_UNO_GRAPHIC, 0, pGraphic )) { - const ::uno::Any* pCLSID = nullptr; - const ::uno::Any* pStreamName = nullptr; - const ::uno::Any* pEmbeddedObject = nullptr; - if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID) - && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName ) - && !pProps->GetProperty( FN_EMBEDDED_OBJECT, 0, pEmbeddedObject )) - throw uno::RuntimeException(); - if(pCLSID) - { - OUString aCLSID; - SvGlobalName aClassName; - uno::Reference < embed::XEmbeddedObject > xIPObj; - std::unique_ptr < comphelper::EmbeddedObjectContainer > pCnt; - if( (*pCLSID) >>= aCLSID ) + uno::Reference< graphic::XGraphic > xGraphic; + (*pGraphic) >>= xGraphic; + aGraphic = Graphic( xGraphic ); + } + + OUString sFltName; + const ::uno::Any* pFilter; + if(pProps->GetProperty(FN_UNO_GRAPHIC_FILTER, 0, pFilter)) + { + (*pFilter) >>= sFltName; + } + + pFormat = (pGrfObj) + ? pDoc->getIDocumentContentOperations().InsertGraphicObject( + aPam, *pGrfObj, &aFrameSet, &aGrSet, pParentFrameFormat) + : pDoc->getIDocumentContentOperations().InsertGraphic( + aPam, sGraphicURL, sFltName, &aGraphic, + &aFrameSet, &aGrSet, pParentFrameFormat); + delete pGrfObj; + if(pFormat) + { + SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFormat->GetContent().GetContentIdx() + ->GetIndex()+1 ]->GetGrfNode(); + if (pGrfNd) + pGrfNd->SetChgTwipSize( !bSizeFound ); + pFormat->Add(this); + if(!m_sName.isEmpty()) + pDoc->SetFlyName(*pFormat, m_sName); + + } + const ::uno::Any* pSurroundContour; + if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUR, pSurroundContour)) + setPropertyValue(UNO_NAME_SURROUND_CONTOUR, *pSurroundContour); + const ::uno::Any* pContourOutside; + if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUROUTSIDE, pContourOutside)) + setPropertyValue(UNO_NAME_CONTOUR_OUTSIDE, *pContourOutside); + const ::uno::Any* pContourPoly; + if(pProps->GetProperty(FN_PARAM_CONTOUR_PP, 0, pContourPoly)) + setPropertyValue(UNO_NAME_CONTOUR_POLY_POLYGON, *pContourPoly); + const ::uno::Any* pPixelContour; + if(pProps->GetProperty(FN_UNO_IS_PIXEL_CONTOUR, 0, pPixelContour)) + setPropertyValue(UNO_NAME_IS_PIXEL_CONTOUR, *pPixelContour); + const ::uno::Any* pAutoContour; + if(pProps->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR, 0, pAutoContour)) + setPropertyValue(UNO_NAME_IS_AUTOMATIC_CONTOUR, *pAutoContour); + } + else + { + const ::uno::Any* pCLSID = nullptr; + const ::uno::Any* pStreamName = nullptr; + const ::uno::Any* pEmbeddedObject = nullptr; + if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID) + && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName ) + && !pProps->GetProperty( FN_EMBEDDED_OBJECT, 0, pEmbeddedObject )) + throw uno::RuntimeException(); + if(pCLSID) + { + OUString aCLSID; + SvGlobalName aClassName; + uno::Reference < embed::XEmbeddedObject > xIPObj; + std::unique_ptr < comphelper::EmbeddedObjectContainer > pCnt; + if( (*pCLSID) >>= aCLSID ) + { + if( !aClassName.MakeId( aCLSID ) ) { - if( !aClassName.MakeId( aCLSID ) ) - { - lang::IllegalArgumentException aExcept; - aExcept.Message = "CLSID invalid"; - throw aExcept; - } - - pCnt.reset( new comphelper::EmbeddedObjectContainer ); - OUString aName; - - OUString sDocumentBaseURL = pDoc->GetPersist()->getDocumentBaseURL(); - xIPObj = pCnt->CreateEmbeddedObject(aClassName.GetByteSequence(), aName, - &sDocumentBaseURL); + lang::IllegalArgumentException aExcept; + aExcept.Message = "CLSID invalid"; + throw aExcept; } - if ( xIPObj.is() ) - { - UnoActionContext aAction(pDoc); - pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr); - if(!bSizeFound) - { - //TODO/LATER: how do I transport it to the OLENode? - sal_Int64 nAspect = m_nDrawAspect; - // TODO/LEAN: VisualArea still needs running state - svt::EmbeddedObjectRef::TryRunningState( xIPObj ); + pCnt.reset( new comphelper::EmbeddedObjectContainer ); + OUString aName; - // set parent to get correct VisArea(in case of object needing parent printer) - uno::Reference < container::XChild > xChild( xIPObj, uno::UNO_QUERY ); - if ( xChild.is() ) - xChild->setParent( pDoc->GetDocShell()->GetModel() ); - - //The Size should be suggested by the OLE server if not manually set - MapUnit aRefMap = VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj->getMapUnit( nAspect ) ); - awt::Size aSize; - try - { - aSize = xIPObj->getVisualAreaSize( nAspect ); - } - catch ( embed::NoVisualAreaSizeException& ) - { - // the default size will be set later - } - - Size aSz( aSize.Width, aSize.Height ); - if ( !aSz.Width() || !aSz.Height() ) - { - aSz.Width() = aSz.Height() = 5000; - aSz = OutputDevice::LogicToLogic - ( aSz, MapMode( MapUnit::Map100thMM ), aRefMap ); - } - MapMode aMyMap( MapUnit::MapTwip ); - aSz = OutputDevice::LogicToLogic( aSz, aRefMap, aMyMap ); - SwFormatFrameSize aFrameSz; - aFrameSz.SetSize(aSz); - aFrameSet.Put(aFrameSz); - } - SwFlyFrameFormat* pFormat2 = nullptr; - - ::svt::EmbeddedObjectRef xObjRef( xIPObj, m_nDrawAspect); - pFormat2 = pDoc->getIDocumentContentOperations().InsertEmbObject( - aPam, xObjRef, &aFrameSet ); - - // store main document name to show in the title bar - uno::Reference< frame::XTitle > xModelTitle( pDoc->GetDocShell()->GetModel(), css::uno::UNO_QUERY ); - if( xModelTitle.is() ) - xIPObj->setContainerName( xModelTitle->getTitle() ); - - assert(pFormat2 && "Doc->Insert(notxt) failed."); - - pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr); - pFormat2->Add(this); - if(!m_sName.isEmpty()) - pDoc->SetFlyName(*pFormat2, m_sName); - } + OUString sDocumentBaseURL = pDoc->GetPersist()->getDocumentBaseURL(); + xIPObj = pCnt->CreateEmbeddedObject(aClassName.GetByteSequence(), aName, + &sDocumentBaseURL); } - else if( pStreamName ) + if ( xIPObj.is() ) { - OUString sStreamName; - (*pStreamName) >>= sStreamName; + UnoActionContext aAction(pDoc); pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr); + if(!bSizeFound) + { + //TODO/LATER: how do I transport it to the OLENode? + sal_Int64 nAspect = m_nDrawAspect; - SwFlyFrameFormat* pFrameFormat = nullptr; - pFrameFormat = pDoc->getIDocumentContentOperations().InsertOLE( aPam, sStreamName, m_nDrawAspect, &aFrameSet, nullptr ); + // TODO/LEAN: VisualArea still needs running state + svt::EmbeddedObjectRef::TryRunningState( xIPObj ); - // store main document name to show in the title bar - SwOLENode* pNd = nullptr; - const SwNodeIndex* pIdx = pFrameFormat->GetContent().GetContentIdx(); - if( pIdx ) - { - SwNodeIndex aIdx( *pIdx, 1 ); - SwNoTextNode* pNoText = aIdx.GetNode().GetNoTextNode(); - pNd = pNoText->GetOLENode(); - } - if( pNd ) - { - uno::Reference < embed::XEmbeddedObject > xObj = pNd->GetOLEObj().GetOleRef(); - if( xObj.is() ) + // set parent to get correct VisArea(in case of object needing parent printer) + uno::Reference < container::XChild > xChild( xIPObj, uno::UNO_QUERY ); + if ( xChild.is() ) + xChild->setParent( pDoc->GetDocShell()->GetModel() ); + + //The Size should be suggested by the OLE server if not manually set + MapUnit aRefMap = VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj->getMapUnit( nAspect ) ); + awt::Size aSize; + try { - uno::Reference< frame::XTitle > xModelTitle( pDoc->GetDocShell()->GetModel(), css::uno::UNO_QUERY ); - if( xModelTitle.is() ) - xObj->setContainerName( xModelTitle->getTitle() ); + aSize = xIPObj->getVisualAreaSize( nAspect ); } + catch ( embed::NoVisualAreaSizeException& ) + { + // the default size will be set later + } + + Size aSz( aSize.Width, aSize.Height ); + if ( !aSz.Width() || !aSz.Height() ) + { + aSz.Width() = aSz.Height() = 5000; + aSz = OutputDevice::LogicToLogic + ( aSz, MapMode( MapUnit::Map100thMM ), aRefMap ); + } + MapMode aMyMap( MapUnit::MapTwip ); + aSz = OutputDevice::LogicToLogic( aSz, aRefMap, aMyMap ); + SwFormatFrameSize aFrameSz; + aFrameSz.SetSize(aSz); + aFrameSet.Put(aFrameSz); } + SwFlyFrameFormat* pFormat2 = nullptr; - pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr); - pFrameFormat->Add(this); - if(!m_sName.isEmpty()) - pDoc->SetFlyName(*pFrameFormat, m_sName); - } - else if (pEmbeddedObject) - { - uno::Reference< embed::XEmbeddedObject > obj; - (*pEmbeddedObject) >>= obj; - svt::EmbeddedObjectRef xObj; - xObj.Assign( obj, embed::Aspects::MSOLE_CONTENT ); + ::svt::EmbeddedObjectRef xObjRef( xIPObj, m_nDrawAspect); + pFormat2 = pDoc->getIDocumentContentOperations().InsertEmbObject( + aPam, xObjRef, &aFrameSet ); - pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr); + // store main document name to show in the title bar + uno::Reference< frame::XTitle > xModelTitle( pDoc->GetDocShell()->GetModel(), css::uno::UNO_QUERY ); + if( xModelTitle.is() ) + xIPObj->setContainerName( xModelTitle->getTitle() ); + + assert(pFormat2 && "Doc->Insert(notxt) failed."); - // Not sure if these setParent() and InsertEmbeddedObject() calls are really - // needed, it seems to work without, but logic from code elsewhere suggests - // they should be done. - SfxObjectShell& rPers = *pDoc->GetPersist(); - uno::Reference < container::XChild > xChild( obj, uno::UNO_QUERY ); - if ( xChild.is() ) - xChild->setParent( rPers.GetModel() ); - OUString rName; - rPers.GetEmbeddedObjectContainer().InsertEmbeddedObject( obj, rName ); - - SwFlyFrameFormat* pFrameFormat = nullptr; - pFrameFormat = pDoc->getIDocumentContentOperations().InsertEmbObject( - aPam, xObj, &aFrameSet); pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr); - pFrameFormat->Add(this); + pFormat2->Add(this); if(!m_sName.isEmpty()) - pDoc->SetFlyName(*pFrameFormat, m_sName); + pDoc->SetFlyName(*pFormat2, m_sName); } } - if( pFormat && pDoc->getIDocumentDrawModelAccess().GetDrawModel() ) - GetOrCreateSdrObject(*pFormat); - const ::uno::Any* pOrder; - if( pProps->GetProperty(FN_UNO_Z_ORDER, 0, pOrder) ) - setPropertyValue(UNO_NAME_Z_ORDER, *pOrder); - const ::uno::Any* pReplacement; - if( pProps->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC, 0, pReplacement) ) - setPropertyValue(UNO_NAME_GRAPHIC, *pReplacement); - // new attribute Title - const ::uno::Any* pTitle; - if ( pProps->GetProperty(FN_UNO_TITLE, 0, pTitle) ) + else if( pStreamName ) { - setPropertyValue(UNO_NAME_TITLE, *pTitle); + OUString sStreamName; + (*pStreamName) >>= sStreamName; + pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr); + + SwFlyFrameFormat* pFrameFormat = nullptr; + pFrameFormat = pDoc->getIDocumentContentOperations().InsertOLE( aPam, sStreamName, m_nDrawAspect, &aFrameSet, nullptr ); + + // store main document name to show in the title bar + SwOLENode* pNd = nullptr; + const SwNodeIndex* pIdx = pFrameFormat->GetContent().GetContentIdx(); + if( pIdx ) + { + SwNodeIndex aIdx( *pIdx, 1 ); + SwNoTextNode* pNoText = aIdx.GetNode().GetNoTextNode(); + pNd = pNoText->GetOLENode(); + } + if( pNd ) + { + uno::Reference < embed::XEmbeddedObject > xObj = pNd->GetOLEObj().GetOleRef(); + if( xObj.is() ) + { + uno::Reference< frame::XTitle > xModelTitle( pDoc->GetDocShell()->GetModel(), css::uno::UNO_QUERY ); + if( xModelTitle.is() ) + xObj->setContainerName( xModelTitle->getTitle() ); + } + } + + pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr); + pFrameFormat->Add(this); + if(!m_sName.isEmpty()) + pDoc->SetFlyName(*pFrameFormat, m_sName); } - // new attribute Description - const ::uno::Any* pDescription; - if ( pProps->GetProperty(FN_UNO_DESCRIPTION, 0, pDescription) ) + else if (pEmbeddedObject) { - setPropertyValue(UNO_NAME_DESCRIPTION, *pDescription); - } + uno::Reference< embed::XEmbeddedObject > obj; + (*pEmbeddedObject) >>= obj; + svt::EmbeddedObjectRef xObj; + xObj.Assign( obj, embed::Aspects::MSOLE_CONTENT ); - // For grabbag - const uno::Any* pFrameIntropgrabbagItem; - if( pProps->GetProperty(RES_FRMATR_GRABBAG, 0, pFrameIntropgrabbagItem) ) - { - setPropertyValue(UNO_NAME_FRAME_INTEROP_GRAB_BAG, *pFrameIntropgrabbagItem); + pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr); + + // Not sure if these setParent() and InsertEmbeddedObject() calls are really + // needed, it seems to work without, but logic from code elsewhere suggests + // they should be done. + SfxObjectShell& rPers = *pDoc->GetPersist(); + uno::Reference < container::XChild > xChild( obj, uno::UNO_QUERY ); + if ( xChild.is() ) + xChild->setParent( rPers.GetModel() ); + OUString rName; + rPers.GetEmbeddedObjectContainer().InsertEmbeddedObject( obj, rName ); + + SwFlyFrameFormat* pFrameFormat = nullptr; + pFrameFormat = pDoc->getIDocumentContentOperations().InsertEmbObject( + aPam, xObj, &aFrameSet); + pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr); + pFrameFormat->Add(this); + if(!m_sName.isEmpty()) + pDoc->SetFlyName(*pFrameFormat, m_sName); } } - else - throw lang::IllegalArgumentException(); + if( pFormat && pDoc->getIDocumentDrawModelAccess().GetDrawModel() ) + GetOrCreateSdrObject(*pFormat); + const ::uno::Any* pOrder; + if( pProps->GetProperty(FN_UNO_Z_ORDER, 0, pOrder) ) + setPropertyValue(UNO_NAME_Z_ORDER, *pOrder); + const ::uno::Any* pReplacement; + if( pProps->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC, 0, pReplacement) ) + setPropertyValue(UNO_NAME_GRAPHIC, *pReplacement); + // new attribute Title + const ::uno::Any* pTitle; + if ( pProps->GetProperty(FN_UNO_TITLE, 0, pTitle) ) + { + setPropertyValue(UNO_NAME_TITLE, *pTitle); + } + // new attribute Description + const ::uno::Any* pDescription; + if ( pProps->GetProperty(FN_UNO_DESCRIPTION, 0, pDescription) ) + { + setPropertyValue(UNO_NAME_DESCRIPTION, *pDescription); + } + + // For grabbag + const uno::Any* pFrameIntropgrabbagItem; + if( pProps->GetProperty(RES_FRMATR_GRABBAG, 0, pFrameIntropgrabbagItem) ) + { + setPropertyValue(UNO_NAME_FRAME_INTEROP_GRAB_BAG, *pFrameIntropgrabbagItem); + } + // reset the flag and delete Descriptor pointer ResetDescriptor(); } @@ -3083,17 +3079,16 @@ void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) { SwDoc* pDoc = pFormat->GetDoc(); SwUnoInternalPaM aIntPam(*pDoc); - if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange)) - { - SfxItemSet aSet( pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{} ); - aSet.SetParent(&pFormat->GetAttrSet()); - SwFormatAnchor aAnchor = static_cast<const SwFormatAnchor&>(aSet.Get(RES_ANCHOR)); - aAnchor.SetAnchor( aIntPam.Start() ); - aSet.Put(aAnchor); - pDoc->SetFlyFrameAttr( *pFormat, aSet ); - } - else + if (!::sw::XTextRangeToSwPaM(aIntPam, xTextRange)) throw lang::IllegalArgumentException(); + + SfxItemSet aSet( pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{} ); + aSet.SetParent(&pFormat->GetAttrSet()); + SwFormatAnchor aAnchor = static_cast<const SwFormatAnchor&>(aSet.Get(RES_ANCHOR)); + aAnchor.SetAnchor( aIntPam.Start() ); + aSet.Put(aAnchor); + pDoc->SetFlyFrameAttr( *pFormat, aSet ); + } } @@ -3235,41 +3230,40 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor() SolarMutexGuard aGuard; uno::Reference< text::XTextCursor > aRef; SwFrameFormat* pFormat = GetFrameFormat(); - if(pFormat) - { - //save current start node to be able to check if there is content after the table - - //otherwise the cursor would be in the body text! - const SwNode& rNode = pFormat->GetContent().GetContentIdx()->GetNode(); - const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType(SwFlyStartNode); + if(!pFormat) + throw uno::RuntimeException(); - SwPaM aPam(rNode); - aPam.Move(fnMoveForward, GoInNode); - SwTableNode* pTableNode = aPam.GetNode().FindTableNode(); - SwContentNode* pCont = nullptr; - while( pTableNode ) - { - aPam.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); - pTableNode = pCont->FindTableNode(); - } - if(pCont) - aPam.GetPoint()->nContent.Assign(pCont, 0); + //save current start node to be able to check if there is content after the table - + //otherwise the cursor would be in the body text! + const SwNode& rNode = pFormat->GetContent().GetContentIdx()->GetNode(); + const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType(SwFlyStartNode); - const SwStartNode* pNewStartNode = - aPam.GetNode().FindSttNodeByType(SwFlyStartNode); - if(!pNewStartNode || pNewStartNode != pOwnStartNode) - { - uno::RuntimeException aExcept; - aExcept.Message = "no text available"; - throw aExcept; - } + SwPaM aPam(rNode); + aPam.Move(fnMoveForward, GoInNode); + SwTableNode* pTableNode = aPam.GetNode().FindTableNode(); + SwContentNode* pCont = nullptr; + while( pTableNode ) + { + aPam.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); + pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); + pTableNode = pCont->FindTableNode(); + } + if(pCont) + aPam.GetPoint()->nContent.Assign(pCont, 0); - SwXTextCursor *const pXCursor = new SwXTextCursor( - *pFormat->GetDoc(), this, CursorType::Frame, *aPam.GetPoint()); - aRef = static_cast<text::XWordCursor*>(pXCursor); + const SwStartNode* pNewStartNode = + aPam.GetNode().FindSttNodeByType(SwFlyStartNode); + if(!pNewStartNode || pNewStartNode != pOwnStartNode) + { + uno::RuntimeException aExcept; + aExcept.Message = "no text available"; + throw aExcept; } - else - throw uno::RuntimeException(); + + SwXTextCursor *const pXCursor = new SwXTextCursor( + *pFormat->GetDoc(), this, CursorType::Frame, *aPam.GetPoint()); + aRef = static_cast<text::XWordCursor*>(pXCursor); + return aRef; } @@ -3279,18 +3273,17 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextCursor > aRef; SwFrameFormat* pFormat = GetFrameFormat(); SwUnoInternalPaM aPam(*GetDoc()); - if (pFormat && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) + if (!pFormat || !::sw::XTextRangeToSwPaM(aPam, aTextPosition)) + throw uno::RuntimeException(); + + SwNode& rNode = pFormat->GetContent().GetContentIdx()->GetNode(); + if(aPam.GetNode().FindFlyStartNode() == rNode.FindFlyStartNode()) { - SwNode& rNode = pFormat->GetContent().GetContentIdx()->GetNode(); - if(aPam.GetNode().FindFlyStartNode() == rNode.FindFlyStartNode()) - { - aRef = static_cast<text::XWordCursor*>( - new SwXTextCursor(*pFormat->GetDoc(), this, CursorType::Frame, - *aPam.GetPoint(), aPam.GetMark())); - } + aRef = static_cast<text::XWordCursor*>( + new SwXTextCursor(*pFormat->GetDoc(), this, CursorType::Frame, + *aPam.GetPoint(), aPam.GetMark())); } - else - throw uno::RuntimeException(); + return aRef; } diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index 59a6b9f93041..3df28474d49d 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -2172,14 +2172,11 @@ SwXDocumentIndexMark::setPropertyValue( case WID_LEVEL: { const sal_Int16 nVal = lcl_AnyToInt16(rValue); - if(nVal >= 0 && nVal < MAXLEVEL) - { - m_pImpl->m_nLevel = nVal; - } - else + if(nVal < 0 || nVal >= MAXLEVEL) { throw lang::IllegalArgumentException(); } + m_pImpl->m_nLevel = nVal; } break; case WID_TOC_BOOKMARK : diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index d10454243088..b633cbb6a448 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -246,18 +246,16 @@ lcl_setAutoStyle(IStyleAccess & rStyleAccess, const uno::Any & rValue, std::shared_ptr<SfxItemSet> pStyle = bPara ? rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_PARA ): rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_CHAR ); - if(pStyle.get()) - { - SwFormatAutoFormat aFormat( (bPara) - ? sal::static_int_cast< sal_uInt16 >(RES_AUTO_STYLE) - : sal::static_int_cast< sal_uInt16 >(RES_TXTATR_AUTOFMT) ); - aFormat.SetStyleHandle( pStyle ); - rSet.Put(aFormat); - } - else + if(!pStyle.get()) { throw lang::IllegalArgumentException(); } + + SwFormatAutoFormat aFormat( (bPara) + ? sal::static_int_cast< sal_uInt16 >(RES_AUTO_STYLE) + : sal::static_int_cast< sal_uInt16 >(RES_TXTATR_AUTOFMT) ); + aFormat.SetStyleHandle( pStyle ); + rSet.Put(aFormat); }; void diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 5aef3386aa1c..a1e8ab795fc7 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -391,12 +391,9 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl( for(sal_Int32 nProp = 0; nProp < nLength; nProp++) { const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]); - if(pEntry) - { - GetPropertyValue( pValues[nProp], *pEntry, &rUnoCursor, pSet ); - } - else + if(!pEntry) throw beans::UnknownPropertyException( "Unknown property: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); + GetPropertyValue( pValues[nProp], *pEntry, &rUnoCursor, pSet ); } } return aValues; diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index aec2f023c4a2..0b1adbb59fcb 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -536,31 +536,30 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor() uno::Reference< text::XTextCursor > xRet; SwNodeIndex* pNodeIndex = pRedline->GetContentIdx(); - if(pNodeIndex) + if(!pNodeIndex) { - SwPosition aPos(*pNodeIndex); - SwXTextCursor *const pXCursor = - new SwXTextCursor(*pDoc, this, CursorType::Redline, aPos); - auto& rUnoCursor(pXCursor->GetCursor()); - rUnoCursor.Move(fnMoveForward, GoInNode); - - // is here a table? - SwTableNode* pTableNode = rUnoCursor.GetNode().FindTableNode(); - SwContentNode* pCont = nullptr; - while( pTableNode ) - { - rUnoCursor.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); - pTableNode = pCont->FindTableNode(); - } - if(pCont) - rUnoCursor.GetPoint()->nContent.Assign(pCont, 0); - xRet = static_cast<text::XWordCursor*>(pXCursor); + throw uno::RuntimeException(); } - else + + SwPosition aPos(*pNodeIndex); + SwXTextCursor *const pXCursor = + new SwXTextCursor(*pDoc, this, CursorType::Redline, aPos); + auto& rUnoCursor(pXCursor->GetCursor()); + rUnoCursor.Move(fnMoveForward, GoInNode); + + // is here a table? + SwTableNode* pTableNode = rUnoCursor.GetNode().FindTableNode(); + SwContentNode* pCont = nullptr; + while( pTableNode ) { - throw uno::RuntimeException(); + rUnoCursor.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); + pCont = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); + pTableNode = pCont->FindTableNode(); } + if(pCont) + rUnoCursor.GetPoint()->nContent.Assign(pCont, 0); + xRet = static_cast<text::XWordCursor*>(pXCursor); + return xRet; } diff --git a/sw/source/core/unocore/unoredlines.cxx b/sw/source/core/unocore/unoredlines.cxx index c2ef94108d06..e68a2eca865e 100644 --- a/sw/source/core/unocore/unoredlines.cxx +++ b/sw/source/core/unocore/unoredlines.cxx @@ -60,15 +60,11 @@ uno::Any SwXRedlines::getByIndex(sal_Int32 nIndex) if(!IsValid()) throw uno::RuntimeException(); const SwRedlineTable& rRedTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); - uno::Any aRet; - if ((rRedTable.size() > static_cast<size_t>(nIndex)) && (nIndex >= 0)) - { - uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nIndex], *GetDoc() ); - aRet <<= xRet; - } - else + if ((rRedTable.size() <= static_cast<size_t>(nIndex)) || (nIndex < 0)) throw lang::IndexOutOfBoundsException(); - return aRet; + + uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTable[nIndex], *GetDoc() ); + return uno::Any(xRet); } uno::Reference< container::XEnumeration > SwXRedlines::createEnumeration() diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index db3005f88d15..9616c94718f6 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -295,238 +295,235 @@ uno::Reference< beans::XPropertySetInfo > SwXFootnoteProperties::getPropertySet void SwXFootnoteProperties::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue) { SolarMutexGuard aGuard; - if(pDoc) + if(!pDoc) + throw uno::RuntimeException(); + + const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); + if(!pEntry) + throw beans::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 ) ); + SwFootnoteInfo aFootnoteInfo(pDoc->GetFootnoteInfo()); + switch(pEntry->nWID) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); - if(pEntry) + case WID_PREFIX: + { + OUString uTmp; + aValue >>= uTmp; + aFootnoteInfo.SetPrefix(uTmp); + } + break; + case WID_SUFFIX: { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - SwFootnoteInfo aFootnoteInfo(pDoc->GetFootnoteInfo()); - switch(pEntry->nWID) + OUString uTmp; + aValue >>= uTmp; + aFootnoteInfo.SetSuffix(uTmp); + } + break; + case WID_NUMBERING_TYPE: + { + sal_Int16 nTmp = 0; + aValue >>= nTmp; + if(!(nTmp >= 0 && + (nTmp <= SVX_NUM_ARABIC || + nTmp > SVX_NUM_BITMAP))) + throw lang::IllegalArgumentException(); + + aFootnoteInfo.aFormat.SetNumberingType((SvxNumType)nTmp); + + } + break; + case WID_START_AT: + { + sal_Int16 nTmp = 0; + aValue >>= nTmp; + aFootnoteInfo.nFootnoteOffset = nTmp; + } + break; + case WID_FOOTNOTE_COUNTING: + { + sal_Int16 nTmp = 0; + aValue >>= nTmp; + switch(nTmp) { - case WID_PREFIX: - { - OUString uTmp; - aValue >>= uTmp; - aFootnoteInfo.SetPrefix(uTmp); - } - break; - case WID_SUFFIX: - { - OUString uTmp; - aValue >>= uTmp; - aFootnoteInfo.SetSuffix(uTmp); - } - break; - case WID_NUMBERING_TYPE: - { - sal_Int16 nTmp = 0; - aValue >>= nTmp; - if(nTmp >= 0 && - (nTmp <= SVX_NUM_ARABIC || - nTmp > SVX_NUM_BITMAP)) - aFootnoteInfo.aFormat.SetNumberingType((SvxNumType)nTmp); - else - throw lang::IllegalArgumentException(); - } - break; - case WID_START_AT: - { - sal_Int16 nTmp = 0; - aValue >>= nTmp; - aFootnoteInfo.nFootnoteOffset = nTmp; - } - break; - case WID_FOOTNOTE_COUNTING: - { - sal_Int16 nTmp = 0; - aValue >>= nTmp; - switch(nTmp) - { - case FootnoteNumbering::PER_PAGE: - aFootnoteInfo.eNum = FTNNUM_PAGE; - break; - case FootnoteNumbering::PER_CHAPTER: - aFootnoteInfo.eNum = FTNNUM_CHAPTER; - break; - case FootnoteNumbering::PER_DOCUMENT: - aFootnoteInfo.eNum = FTNNUM_DOC; - break; - } - } - break; - case WID_PARAGRAPH_STYLE: - { - SwTextFormatColl* pColl = lcl_GetParaStyle(pDoc, aValue); - if(pColl) - aFootnoteInfo.SetFootnoteTextColl(*pColl); - } + case FootnoteNumbering::PER_PAGE: + aFootnoteInfo.eNum = FTNNUM_PAGE; break; - case WID_PAGE_STYLE: - { - SwPageDesc* pDesc = lcl_GetPageDesc(pDoc, aValue); - if(pDesc) - aFootnoteInfo.ChgPageDesc( pDesc ); - } + case FootnoteNumbering::PER_CHAPTER: + aFootnoteInfo.eNum = FTNNUM_CHAPTER; break; - case WID_ANCHOR_CHARACTER_STYLE: - case WID_CHARACTER_STYLE: - { - SwCharFormat* pFormat = lcl_getCharFormat(pDoc, aValue); - if(pFormat) - { - if(pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE) - aFootnoteInfo.SetAnchorCharFormat(pFormat); - else - aFootnoteInfo.SetCharFormat(pFormat); - } - } - break; - case WID_POSITION_END_OF_DOC: - { - bool bVal = *o3tl::doAccess<bool>(aValue); - aFootnoteInfo.ePos = bVal ? FTNPOS_CHAPTER : FTNPOS_PAGE; - } - break; - case WID_END_NOTICE: - { - OUString uTmp; - aValue >>= uTmp; - aFootnoteInfo.aQuoVadis = uTmp; - } - break; - case WID_BEGIN_NOTICE: - { - OUString uTmp; - aValue >>= uTmp; - aFootnoteInfo.aErgoSum = uTmp; - } + case FootnoteNumbering::PER_DOCUMENT: + aFootnoteInfo.eNum = FTNNUM_DOC; break; } - pDoc->SetFootnoteInfo(aFootnoteInfo); } - else - throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + break; + case WID_PARAGRAPH_STYLE: + { + SwTextFormatColl* pColl = lcl_GetParaStyle(pDoc, aValue); + if(pColl) + aFootnoteInfo.SetFootnoteTextColl(*pColl); + } + break; + case WID_PAGE_STYLE: + { + SwPageDesc* pDesc = lcl_GetPageDesc(pDoc, aValue); + if(pDesc) + aFootnoteInfo.ChgPageDesc( pDesc ); + } + break; + case WID_ANCHOR_CHARACTER_STYLE: + case WID_CHARACTER_STYLE: + { + SwCharFormat* pFormat = lcl_getCharFormat(pDoc, aValue); + if(pFormat) + { + if(pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE) + aFootnoteInfo.SetAnchorCharFormat(pFormat); + else + aFootnoteInfo.SetCharFormat(pFormat); + } + } + break; + case WID_POSITION_END_OF_DOC: + { + bool bVal = *o3tl::doAccess<bool>(aValue); + aFootnoteInfo.ePos = bVal ? FTNPOS_CHAPTER : FTNPOS_PAGE; + } + break; + case WID_END_NOTICE: + { + OUString uTmp; + aValue >>= uTmp; + aFootnoteInfo.aQuoVadis = uTmp; + } + break; + case WID_BEGIN_NOTICE: + { + OUString uTmp; + aValue >>= uTmp; + aFootnoteInfo.aErgoSum = uTmp; + } + break; } - else - throw uno::RuntimeException(); + pDoc->SetFootnoteInfo(aFootnoteInfo); + + } uno::Any SwXFootnoteProperties::getPropertyValue(const OUString& rPropertyName) { SolarMutexGuard aGuard; uno::Any aRet; - if(pDoc) + if(!pDoc) + throw uno::RuntimeException(); + + const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); + if(!pEntry) + throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + + const SwFootnoteInfo& rFootnoteInfo = pDoc->GetFootnoteInfo(); + switch(pEntry->nWID) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); - if(pEntry) + case WID_PREFIX: + { + aRet <<= rFootnoteInfo.GetPrefix(); + } + break; + case WID_SUFFIX: + { + aRet <<= rFootnoteInfo.GetSuffix(); + } + break; + case WID_NUMBERING_TYPE : { - const SwFootnoteInfo& rFootnoteInfo = pDoc->GetFootnoteInfo(); - switch(pEntry->nWID) + aRet <<= (sal_Int16)rFootnoteInfo.aFormat.GetNumberingType(); + } + break; + case WID_START_AT: + aRet <<= (sal_Int16)rFootnoteInfo.nFootnoteOffset; + break; + case WID_FOOTNOTE_COUNTING : + { + sal_Int16 nRet = 0; + switch(rFootnoteInfo.eNum) { - case WID_PREFIX: - { - aRet <<= rFootnoteInfo.GetPrefix(); - } - break; - case WID_SUFFIX: - { - aRet <<= rFootnoteInfo.GetSuffix(); - } - break; - case WID_NUMBERING_TYPE : - { - aRet <<= (sal_Int16)rFootnoteInfo.aFormat.GetNumberingType(); - } - break; - case WID_START_AT: - aRet <<= (sal_Int16)rFootnoteInfo.nFootnoteOffset; - break; - case WID_FOOTNOTE_COUNTING : - { - sal_Int16 nRet = 0; - switch(rFootnoteInfo.eNum) - { - case FTNNUM_PAGE: - nRet = FootnoteNumbering::PER_PAGE; - break; - case FTNNUM_CHAPTER: - nRet = FootnoteNumbering::PER_CHAPTER; - break; - case FTNNUM_DOC: - nRet = FootnoteNumbering::PER_DOCUMENT; - break; - } - aRet <<= nRet; - } + case FTNNUM_PAGE: + nRet = FootnoteNumbering::PER_PAGE; break; - case WID_PARAGRAPH_STYLE : - { - SwTextFormatColl* pColl = rFootnoteInfo.GetFootnoteTextColl(); - OUString aString; - if(pColl) - aString = pColl->GetName(); - SwStyleNameMapper::FillProgName(aString, aString, SwGetPoolIdFromName::TxtColl, true); - aRet <<= aString; - } + case FTNNUM_CHAPTER: + nRet = FootnoteNumbering::PER_CHAPTER; break; - case WID_PAGE_STYLE : - { - OUString aString; - if( rFootnoteInfo.KnowsPageDesc() ) - { - SwStyleNameMapper::FillProgName( - rFootnoteInfo.GetPageDesc( *pDoc )->GetName(), - aString, - SwGetPoolIdFromName::PageDesc, - true); - } - aRet <<= aString; - } - break; - case WID_ANCHOR_CHARACTER_STYLE: - case WID_CHARACTER_STYLE: - { - OUString aString; - const SwCharFormat* pCharFormat = nullptr; - if( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE ) - { - if( rFootnoteInfo.GetAnchorCharFormatDep()->GetRegisteredIn() ) - pCharFormat = rFootnoteInfo.GetAnchorCharFormat(*pDoc); - } - else - { - if( rFootnoteInfo.GetCharFormatDep()->GetRegisteredIn() ) - pCharFormat = rFootnoteInfo.GetCharFormat(*pDoc); - } - if( pCharFormat ) - { - SwStyleNameMapper::FillProgName( - pCharFormat->GetName(), - aString, - SwGetPoolIdFromName::ChrFmt, - true); - } - aRet <<= aString; - } - break; - case WID_POSITION_END_OF_DOC: - aRet <<= FTNPOS_CHAPTER == rFootnoteInfo.ePos; - break; - case WID_END_NOTICE : - aRet <<= rFootnoteInfo.aQuoVadis; - break; - case WID_BEGIN_NOTICE : - aRet <<= rFootnoteInfo.aErgoSum; + case FTNNUM_DOC: + nRet = FootnoteNumbering::PER_DOCUMENT; break; } + aRet <<= nRet; } - else - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + break; + case WID_PARAGRAPH_STYLE : + { + SwTextFormatColl* pColl = rFootnoteInfo.GetFootnoteTextColl(); + OUString aString; + if(pColl) + aString = pColl->GetName(); + SwStyleNameMapper::FillProgName(aString, aString, SwGetPoolIdFromName::TxtColl, true); + aRet <<= aString; + } + break; + case WID_PAGE_STYLE : + { + OUString aString; + if( rFootnoteInfo.KnowsPageDesc() ) + { + SwStyleNameMapper::FillProgName( + rFootnoteInfo.GetPageDesc( *pDoc )->GetName(), + aString, + SwGetPoolIdFromName::PageDesc, + true); + } + aRet <<= aString; + } + break; + case WID_ANCHOR_CHARACTER_STYLE: + case WID_CHARACTER_STYLE: + { + OUString aString; + const SwCharFormat* pCharFormat = nullptr; + if( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE ) + { + if( rFootnoteInfo.GetAnchorCharFormatDep()->GetRegisteredIn() ) + pCharFormat = rFootnoteInfo.GetAnchorCharFormat(*pDoc); + } + else + { + if( rFootnoteInfo.GetCharFormatDep()->GetRegisteredIn() ) + pCharFormat = rFootnoteInfo.GetCharFormat(*pDoc); + } + if( pCharFormat ) + { + SwStyleNameMapper::FillProgName( + pCharFormat->GetName(), + aString, + SwGetPoolIdFromName::ChrFmt, + true); + } + aRet <<= aString; + } + break; + case WID_POSITION_END_OF_DOC: + aRet <<= FTNPOS_CHAPTER == rFootnoteInfo.ePos; + break; + case WID_END_NOTICE : + aRet <<= rFootnoteInfo.aQuoVadis; + break; + case WID_BEGIN_NOTICE : + aRet <<= rFootnoteInfo.aErgoSum; + break; } - else - throw uno::RuntimeException(); + + return aRet; } @@ -592,73 +589,72 @@ void SwXEndnoteProperties::setPropertyValue(const OUString& rPropertyName, const if(pDoc) { const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); - if(pEntry) + 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 ) ); + SwEndNoteInfo aEndInfo(pDoc->GetEndNoteInfo()); + switch(pEntry->nWID) { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - SwEndNoteInfo aEndInfo(pDoc->GetEndNoteInfo()); - switch(pEntry->nWID) + case WID_PREFIX: { - case WID_PREFIX: - { - OUString uTmp; - aValue >>= uTmp; - aEndInfo.SetPrefix(uTmp); - } - break; - case WID_SUFFIX: - { - OUString uTmp; - aValue >>= uTmp; - aEndInfo.SetSuffix(uTmp); - } - break; - case WID_NUMBERING_TYPE : - { - sal_Int16 nTmp = 0; - aValue >>= nTmp; - aEndInfo.aFormat.SetNumberingType((SvxNumType)nTmp); - } - break; - case WID_START_AT: - { - sal_Int16 nTmp = 0; - aValue >>= nTmp; - aEndInfo.nFootnoteOffset = nTmp; - } - break; - case WID_PARAGRAPH_STYLE : - { - SwTextFormatColl* pColl = lcl_GetParaStyle(pDoc, aValue); - if(pColl) - aEndInfo.SetFootnoteTextColl(*pColl); - } - break; - case WID_PAGE_STYLE : - { - SwPageDesc* pDesc = lcl_GetPageDesc(pDoc, aValue); - if(pDesc) - aEndInfo.ChgPageDesc( pDesc ); - } - break; - case WID_ANCHOR_CHARACTER_STYLE: - case WID_CHARACTER_STYLE : + OUString uTmp; + aValue >>= uTmp; + aEndInfo.SetPrefix(uTmp); + } + break; + case WID_SUFFIX: + { + OUString uTmp; + aValue >>= uTmp; + aEndInfo.SetSuffix(uTmp); + } + break; + case WID_NUMBERING_TYPE : + { + sal_Int16 nTmp = 0; + aValue >>= nTmp; + aEndInfo.aFormat.SetNumberingType((SvxNumType)nTmp); + } + break; + case WID_START_AT: + { + sal_Int16 nTmp = 0; + aValue >>= nTmp; + aEndInfo.nFootnoteOffset = nTmp; + } + break; + case WID_PARAGRAPH_STYLE : + { + SwTextFormatColl* pColl = lcl_GetParaStyle(pDoc, aValue); + if(pColl) + aEndInfo.SetFootnoteTextColl(*pColl); + } + break; + case WID_PAGE_STYLE : + { + SwPageDesc* pDesc = lcl_GetPageDesc(pDoc, aValue); + if(pDesc) + aEndInfo.ChgPageDesc( pDesc ); + } + break; + case WID_ANCHOR_CHARACTER_STYLE: + case WID_CHARACTER_STYLE : + { + SwCharFormat* pFormat = lcl_getCharFormat(pDoc, aValue); + if(pFormat) { - SwCharFormat* pFormat = lcl_getCharFormat(pDoc, aValue); - if(pFormat) - { - if(pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE) - aEndInfo.SetAnchorCharFormat(pFormat); - else - aEndInfo.SetCharFormat(pFormat); - } + if(pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE) + aEndInfo.SetAnchorCharFormat(pFormat); + else + aEndInfo.SetCharFormat(pFormat); } - break; } - pDoc->SetEndNoteInfo(aEndInfo); + break; } - else - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + pDoc->SetEndNoteInfo(aEndInfo); + } } @@ -669,82 +665,81 @@ uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName) if(pDoc) { const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); - if(pEntry) + if(!pEntry) + throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + + const SwEndNoteInfo& rEndInfo = pDoc->GetEndNoteInfo(); + switch(pEntry->nWID) { - const SwEndNoteInfo& rEndInfo = pDoc->GetEndNoteInfo(); - switch(pEntry->nWID) + case WID_PREFIX: + aRet <<= rEndInfo.GetPrefix(); + break; + case WID_SUFFIX: + aRet <<= rEndInfo.GetSuffix(); + break; + case WID_NUMBERING_TYPE : + aRet <<= (sal_Int16)rEndInfo.aFormat.GetNumberingType(); + break; + case WID_START_AT: + aRet <<= (sal_Int16)rEndInfo.nFootnoteOffset; + break; + case WID_PARAGRAPH_STYLE : { - case WID_PREFIX: - aRet <<= rEndInfo.GetPrefix(); - break; - case WID_SUFFIX: - aRet <<= rEndInfo.GetSuffix(); - break; - case WID_NUMBERING_TYPE : - aRet <<= (sal_Int16)rEndInfo.aFormat.GetNumberingType(); - break; - case WID_START_AT: - aRet <<= (sal_Int16)rEndInfo.nFootnoteOffset; - break; - case WID_PARAGRAPH_STYLE : + SwTextFormatColl* pColl = rEndInfo.GetFootnoteTextColl(); + OUString aString; + if(pColl) + aString = pColl->GetName(); + SwStyleNameMapper::FillProgName( + aString, + aString, + SwGetPoolIdFromName::TxtColl, + true); + aRet <<= aString; + + } + break; + case WID_PAGE_STYLE : + { + OUString aString; + if( rEndInfo.KnowsPageDesc() ) { - SwTextFormatColl* pColl = rEndInfo.GetFootnoteTextColl(); - OUString aString; - if(pColl) - aString = pColl->GetName(); SwStyleNameMapper::FillProgName( - aString, - aString, - SwGetPoolIdFromName::TxtColl, - true); - aRet <<= aString; - + rEndInfo.GetPageDesc( *pDoc )->GetName(), + aString, + SwGetPoolIdFromName::PageDesc, + true ); } - break; - case WID_PAGE_STYLE : + aRet <<= aString; + } + break; + case WID_ANCHOR_CHARACTER_STYLE: + case WID_CHARACTER_STYLE: + { + OUString aString; + const SwCharFormat* pCharFormat = nullptr; + if( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE ) { - OUString aString; - if( rEndInfo.KnowsPageDesc() ) - { - SwStyleNameMapper::FillProgName( - rEndInfo.GetPageDesc( *pDoc )->GetName(), - aString, - SwGetPoolIdFromName::PageDesc, - true ); - } - aRet <<= aString; + if( rEndInfo.GetAnchorCharFormatDep()->GetRegisteredIn() ) + pCharFormat = rEndInfo.GetAnchorCharFormat(*pDoc); } - break; - case WID_ANCHOR_CHARACTER_STYLE: - case WID_CHARACTER_STYLE: + else { - OUString aString; - const SwCharFormat* pCharFormat = nullptr; - if( pEntry->nWID == WID_ANCHOR_CHARACTER_STYLE ) - { - if( rEndInfo.GetAnchorCharFormatDep()->GetRegisteredIn() ) - pCharFormat = rEndInfo.GetAnchorCharFormat(*pDoc); - } - else - { - if( rEndInfo.GetCharFormatDep()->GetRegisteredIn() ) - pCharFormat = rEndInfo.GetCharFormat(*pDoc); - } - if( pCharFormat ) - { - SwStyleNameMapper::FillProgName( - pCharFormat->GetName(), - aString, - SwGetPoolIdFromName::ChrFmt, - true ); - } - aRet <<= aString; + if( rEndInfo.GetCharFormatDep()->GetRegisteredIn() ) + pCharFormat = rEndInfo.GetCharFormat(*pDoc); } - break; + if( pCharFormat ) + { + SwStyleNameMapper::FillProgName( + pCharFormat->GetName(), + aString, + SwGetPoolIdFromName::ChrFmt, + true ); + } + aRet <<= aString; } + break; } - else - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + } return aRet; } @@ -808,208 +803,200 @@ void SwXLineNumberingProperties::setPropertyValue( const OUString& rPropertyName, const Any& aValue) { SolarMutexGuard aGuard; - if(pDoc) + if(!pDoc) + throw uno::RuntimeException(); + + const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->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 ) ); + SwLineNumberInfo aFontMetric(pDoc->GetLineNumberInfo()); + switch(pEntry->nWID) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); - if(pEntry) + case WID_NUM_ON: { - if ( pEntry->nFlags & PropertyAttribute::READONLY) - throw PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - SwLineNumberInfo aFontMetric(pDoc->GetLineNumberInfo()); - switch(pEntry->nWID) + bool bVal = *o3tl::doAccess<bool>(aValue); + aFontMetric.SetPaintLineNumbers(bVal); + } + break; + case WID_CHARACTER_STYLE : + { + SwCharFormat* pFormat = lcl_getCharFormat(pDoc, aValue); + if(pFormat) + aFontMetric.SetCharFormat(pFormat); + } + break; + case WID_NUMBERING_TYPE : + { + SvxNumberType aNumType(aFontMetric.GetNumType()); + sal_Int16 nTmp = 0; + aValue >>= nTmp; + aNumType.SetNumberingType((SvxNumType)nTmp); + aFontMetric.SetNumType(aNumType); + } + break; + case WID_NUMBER_POSITION : + { + sal_Int16 nTmp = 0; + aValue >>= nTmp; + switch(nTmp) { - case WID_NUM_ON: - { - bool bVal = *o3tl::doAccess<bool>(aValue); - aFontMetric.SetPaintLineNumbers(bVal); - } + case style::LineNumberPosition::LEFT: + aFontMetric.SetPos(LINENUMBER_POS_LEFT); ; break; - case WID_CHARACTER_STYLE : - { - SwCharFormat* pFormat = lcl_getCharFormat(pDoc, aValue); - if(pFormat) - aFontMetric.SetCharFormat(pFormat); - } + case style::LineNumberPosition::RIGHT : + aFontMetric.SetPos(LINENUMBER_POS_RIGHT); ; break; - case WID_NUMBERING_TYPE : - { - SvxNumberType aNumType(aFontMetric.GetNumType()); - sal_Int16 nTmp = 0; - aValue >>= nTmp; - aNumType.SetNumberingType((SvxNumType)nTmp); - aFontMetric.SetNumType(aNumType); - } + case style::LineNumberPosition::INSIDE: + aFontMetric.SetPos(LINENUMBER_POS_INSIDE); ; break; - case WID_NUMBER_POSITION : - { - sal_Int16 nTmp = 0; - aValue >>= nTmp; - switch(nTmp) - { - case style::LineNumberPosition::LEFT: - aFontMetric.SetPos(LINENUMBER_POS_LEFT); ; - break; - case style::LineNumberPosition::RIGHT : - aFontMetric.SetPos(LINENUMBER_POS_RIGHT); ; - break; - case style::LineNumberPosition::INSIDE: - aFontMetric.SetPos(LINENUMBER_POS_INSIDE); ; - break; - case style::LineNumberPosition::OUTSIDE: - aFontMetric.SetPos(LINENUMBER_POS_OUTSIDE); - break; - } - } - break; - case WID_DISTANCE : - { - sal_Int32 nVal = 0; - aValue >>= nVal; - sal_Int32 nTmp = convertMm100ToTwip(nVal); - if (nTmp > USHRT_MAX) - nTmp = USHRT_MAX; - aFontMetric.SetPosFromLeft( static_cast< sal_uInt16 >(nTmp) ); - } - break; - case WID_INTERVAL : - { - sal_Int16 nTmp = 0; - aValue >>= nTmp; - if( nTmp > 0) - aFontMetric.SetCountBy(nTmp); - } - break; - case WID_SEPARATOR_TEXT : - { - OUString uTmp; - aValue >>= uTmp; - aFontMetric.SetDivider(uTmp); - } - break; - case WID_SEPARATOR_INTERVAL: - { - sal_Int16 nTmp = 0; - aValue >>= nTmp; - if( nTmp >= 0) - aFontMetric.SetDividerCountBy(nTmp); - } - break; - case WID_COUNT_EMPTY_LINES : - { - bool bVal = *o3tl::doAccess<bool>(aValue); - aFontMetric.SetCountBlankLines(bVal); - } - break; - case WID_COUNT_LINES_IN_FRAMES : - { - bool bVal = *o3tl::doAccess<bool>(aValue); - aFontMetric.SetCountInFlys(bVal); - } - break; - case WID_RESTART_AT_EACH_PAGE : - { - bool bVal = *o3tl::doAccess<bool>(aValue); - aFontMetric.SetRestartEachPage(bVal); - } + case style::LineNumberPosition::OUTSIDE: + aFontMetric.SetPos(LINENUMBER_POS_OUTSIDE); break; } - pDoc->SetLineNumberInfo(aFontMetric); } - else - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + break; + case WID_DISTANCE : + { + sal_Int32 nVal = 0; + aValue >>= nVal; + sal_Int32 nTmp = convertMm100ToTwip(nVal); + if (nTmp > USHRT_MAX) + nTmp = USHRT_MAX; + aFontMetric.SetPosFromLeft( static_cast< sal_uInt16 >(nTmp) ); + } + break; + case WID_INTERVAL : + { + sal_Int16 nTmp = 0; + aValue >>= nTmp; + if( nTmp > 0) + aFontMetric.SetCountBy(nTmp); + } + break; + case WID_SEPARATOR_TEXT : + { + OUString uTmp; + aValue >>= uTmp; + aFontMetric.SetDivider(uTmp); + } + break; + case WID_SEPARATOR_INTERVAL: + { + sal_Int16 nTmp = 0; + aValue >>= nTmp; + if( nTmp >= 0) + aFontMetric.SetDividerCountBy(nTmp); + } + break; + case WID_COUNT_EMPTY_LINES : + { + bool bVal = *o3tl::doAccess<bool>(aValue); + aFontMetric.SetCountBlankLines(bVal); + } + break; + case WID_COUNT_LINES_IN_FRAMES : + { + bool bVal = *o3tl::doAccess<bool>(aValue); + aFontMetric.SetCountInFlys(bVal); + } + break; + case WID_RESTART_AT_EACH_PAGE : + { + bool bVal = *o3tl::doAccess<bool>(aValue); + aFontMetric.SetRestartEachPage(bVal); + } + break; } - else - throw uno::RuntimeException(); + pDoc->SetLineNumberInfo(aFontMetric); } Any SwXLineNumberingProperties::getPropertyValue(const OUString& rPropertyName) { SolarMutexGuard aGuard; Any aRet; - if(pDoc) + if(!pDoc) + throw uno::RuntimeException(); + + const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); + if(!pEntry) + throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + + const SwLineNumberInfo& rInfo = pDoc->GetLineNumberInfo(); + switch(pEntry->nWID) { - const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName ); - if(pEntry) + case WID_NUM_ON: + aRet <<= rInfo.IsPaintLineNumbers(); + break; + case WID_CHARACTER_STYLE : { - const SwLineNumberInfo& rInfo = pDoc->GetLineNumberInfo(); - switch(pEntry->nWID) + OUString aString; + // return empty string if no char format is set + // otherwise it would be created here + if(rInfo.HasCharFormat()) { - case WID_NUM_ON: - aRet <<= rInfo.IsPaintLineNumbers(); - break; - case WID_CHARACTER_STYLE : - { - OUString aString; - // return empty string if no char format is set - // otherwise it would be created here - if(rInfo.HasCharFormat()) - { - SwStyleNameMapper::FillProgName( - rInfo.GetCharFormat(pDoc->getIDocumentStylePoolAccess())->GetName(), - aString, - SwGetPoolIdFromName::ChrFmt, - true); - } - aRet <<= aString; - } - break; - case WID_NUMBERING_TYPE : - aRet <<= (sal_Int16)rInfo.GetNumType().GetNumberingType(); - break; - case WID_NUMBER_POSITION : - { - sal_Int16 nRet = 0; - switch(rInfo.GetPos()) - { - case LINENUMBER_POS_LEFT: - nRet = style::LineNumberPosition::LEFT; - break; - case LINENUMBER_POS_RIGHT : - nRet = style::LineNumberPosition::RIGHT ; - break; - case LINENUMBER_POS_INSIDE: - nRet = style::LineNumberPosition::INSIDE ; - break; - case LINENUMBER_POS_OUTSIDE : - nRet = style::LineNumberPosition::OUTSIDE ; - break; - } - aRet <<= nRet; - } - break; - case WID_DISTANCE : - { - sal_uInt32 nPos = rInfo.GetPosFromLeft(); - if(USHRT_MAX == nPos) - nPos = 0; - aRet <<= static_cast < sal_Int32 >(convertTwipToMm100(nPos)); - } - break; - case WID_INTERVAL : - aRet <<= (sal_Int16)rInfo.GetCountBy(); - break; - case WID_SEPARATOR_TEXT : - aRet <<= rInfo.GetDivider(); - break; - case WID_SEPARATOR_INTERVAL: - aRet <<= (sal_Int16)rInfo.GetDividerCountBy(); + SwStyleNameMapper::FillProgName( + rInfo.GetCharFormat(pDoc->getIDocumentStylePoolAccess())->GetName(), + aString, + SwGetPoolIdFromName::ChrFmt, + true); + } + aRet <<= aString; + } + break; + case WID_NUMBERING_TYPE : + aRet <<= (sal_Int16)rInfo.GetNumType().GetNumberingType(); + break; + case WID_NUMBER_POSITION : + { + sal_Int16 nRet = 0; + switch(rInfo.GetPos()) + { + case LINENUMBER_POS_LEFT: + nRet = style::LineNumberPosition::LEFT; break; - case WID_COUNT_EMPTY_LINES : - aRet <<= rInfo.IsCountBlankLines(); + case LINENUMBER_POS_RIGHT : + nRet = style::LineNumberPosition::RIGHT ; break; - case WID_COUNT_LINES_IN_FRAMES : - aRet <<= rInfo.IsCountInFlys(); + case LINENUMBER_POS_INSIDE: + nRet = style::LineNumberPosition::INSIDE ; break; - case WID_RESTART_AT_EACH_PAGE : - aRet <<= rInfo.IsRestartEachPage(); + case LINENUMBER_POS_OUTSIDE : + nRet = style::LineNumberPosition::OUTSIDE ; break; } + aRet <<= nRet; } - else - throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + break; + case WID_DISTANCE : + { + sal_uInt32 nPos = rInfo.GetPosFromLeft(); + if(USHRT_MAX == nPos) + nPos = 0; + aRet <<= static_cast < sal_Int32 >(convertTwipToMm100(nPos)); + } + break; + case WID_INTERVAL : + aRet <<= (sal_Int16)rInfo.GetCountBy(); + break; + case WID_SEPARATOR_TEXT : + aRet <<= rInfo.GetDivider(); + break; + case WID_SEPARATOR_INTERVAL: + aRet <<= (sal_Int16)rInfo.GetDividerCountBy(); + break; + case WID_COUNT_EMPTY_LINES : + aRet <<= rInfo.IsCountBlankLines(); + break; + case WID_COUNT_LINES_IN_FRAMES : + aRet <<= rInfo.IsCountInFlys(); + break; + case WID_RESTART_AT_EACH_PAGE : + aRet <<= rInfo.IsRestartEachPage(); + break; } - else - throw uno::RuntimeException(); return aRet; } diff --git a/sw/source/core/unocore/unosrch.cxx b/sw/source/core/unocore/unosrch.cxx index 14033515a8bf..4c6d37a6ba6d 100644 --- a/sw/source/core/unocore/unosrch.cxx +++ b/sw/source/core/unocore/unosrch.cxx @@ -545,31 +545,30 @@ void SwXTextSearch::setPropertyValue(const OUString& rPropertyName, const uno::A { SolarMutexGuard aGuard; const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName); - if(pEntry) - { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException ("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - bool bVal = false; - if(auto b = o3tl::tryAccess<bool>(aValue)) - bVal = *b; - switch(pEntry->nWID) - { - case WID_SEARCH_ALL : m_bAll = bVal; break; - case WID_WORDS: m_bWord = bVal; break; - case WID_BACKWARDS : m_bBack = bVal; break; - case WID_REGULAR_EXPRESSION : m_bExpr = bVal; break; - case WID_CASE_SENSITIVE : m_bCase = bVal; break; - //case WID_IN_SELECTION : bInSel = bVal; break; - case WID_STYLES : m_bStyles = bVal; break; - case WID_SIMILARITY : m_bSimilarity = bVal; break; - case WID_SIMILARITY_RELAX: m_bLevRelax = bVal; break; - case WID_SIMILARITY_EXCHANGE: aValue >>= m_nLevExchange; break; - case WID_SIMILARITY_ADD: aValue >>= m_nLevAdd; break; - case WID_SIMILARITY_REMOVE : aValue >>= m_nLevRemove;break; - }; - } - else + if(!pEntry) throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + + if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) + throw beans::PropertyVetoException ("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + bool bVal = false; + if(auto b = o3tl::tryAccess<bool>(aValue)) + bVal = *b; + switch(pEntry->nWID) + { + case WID_SEARCH_ALL : m_bAll = bVal; break; + case WID_WORDS: m_bWord = bVal; break; + case WID_BACKWARDS : m_bBack = bVal; break; + case WID_REGULAR_EXPRESSION : m_bExpr = bVal; break; + case WID_CASE_SENSITIVE : m_bCase = bVal; break; + //case WID_IN_SELECTION : bInSel = bVal; break; + case WID_STYLES : m_bStyles = bVal; break; + case WID_SIMILARITY : m_bSimilarity = bVal; break; + case WID_SIMILARITY_RELAX: m_bLevRelax = bVal; break; + case WID_SIMILARITY_EXCHANGE: aValue >>= m_nLevExchange; break; + case WID_SIMILARITY_ADD: aValue >>= m_nLevAdd; break; + case WID_SIMILARITY_REMOVE : aValue >>= m_nLevRemove;break; + }; + } uno::Any SwXTextSearch::getPropertyValue(const OUString& rPropertyName) @@ -579,33 +578,32 @@ uno::Any SwXTextSearch::getPropertyValue(const OUString& rPropertyName) const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName(rPropertyName); bool bSet = false; - if(pEntry) + if(!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + + sal_Int16 nSet = 0; + switch(pEntry->nWID) { - sal_Int16 nSet = 0; - switch(pEntry->nWID) - { - case WID_SEARCH_ALL : bSet = m_bAll; goto SET_BOOL; - case WID_WORDS: bSet = m_bWord; goto SET_BOOL; - case WID_BACKWARDS : bSet = m_bBack; goto SET_BOOL; - case WID_REGULAR_EXPRESSION : bSet = m_bExpr; goto SET_BOOL; - case WID_CASE_SENSITIVE : bSet = m_bCase; goto SET_BOOL; - //case WID_IN_SELECTION : bSet = bInSel; goto SET_BOOL; - case WID_STYLES : bSet = m_bStyles; goto SET_BOOL; - case WID_SIMILARITY : bSet = m_bSimilarity; goto SET_BOOL; - case WID_SIMILARITY_RELAX: bSet = m_bLevRelax; + case WID_SEARCH_ALL : bSet = m_bAll; goto SET_BOOL; + case WID_WORDS: bSet = m_bWord; goto SET_BOOL; + case WID_BACKWARDS : bSet = m_bBack; goto SET_BOOL; + case WID_REGULAR_EXPRESSION : bSet = m_bExpr; goto SET_BOOL; + case WID_CASE_SENSITIVE : bSet = m_bCase; goto SET_BOOL; + //case WID_IN_SELECTION : bSet = bInSel; goto SET_BOOL; + case WID_STYLES : bSet = m_bStyles; goto SET_BOOL; + case WID_SIMILARITY : bSet = m_bSimilarity; goto SET_BOOL; + case WID_SIMILARITY_RELAX: bSet = m_bLevRelax; SET_BOOL: - aRet <<= bSet; - break; - case WID_SIMILARITY_EXCHANGE: nSet = m_nLevExchange; goto SET_UINT16; - case WID_SIMILARITY_ADD: nSet = m_nLevAdd; goto SET_UINT16; - case WID_SIMILARITY_REMOVE : nSet = m_nLevRemove; + aRet <<= bSet; + break; + case WID_SIMILARITY_EXCHANGE: nSet = m_nLevExchange; goto SET_UINT16; + case WID_SIMILARITY_ADD: nSet = m_nLevAdd; goto SET_UINT16; + case WID_SIMILARITY_REMOVE : nSet = m_nLevRemove; SET_UINT16: - aRet <<= nSet; - break; - }; - } - else - throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + aRet <<= nSet; + break; + }; + return aRet; } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 62b9821791a0..67ad889ead63 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -3373,41 +3373,40 @@ uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex) uno::Any aRet; if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT) throw lang::IndexOutOfBoundsException(); - if(IsValid()) + if(!IsValid()) + throw uno::RuntimeException(); + + uno::Reference< style::XAutoStyleFamily > aRef; + IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex]; + switch( nType ) { - uno::Reference< style::XAutoStyleFamily > aRef; - IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex]; - switch( nType ) + case IStyleAccess::AUTO_STYLE_CHAR: { - case IStyleAccess::AUTO_STYLE_CHAR: - { - if(!m_xAutoCharStyles.is()) - m_xAutoCharStyles = new SwXAutoStyleFamily(m_pDocShell, nType); - aRef = m_xAutoCharStyles; - } - break; - case IStyleAccess::AUTO_STYLE_RUBY: - { - if(!m_xAutoRubyStyles.is()) - m_xAutoRubyStyles = new SwXAutoStyleFamily(m_pDocShell, nType ); - aRef = m_xAutoRubyStyles; - } - break; - case IStyleAccess::AUTO_STYLE_PARA: - { - if(!m_xAutoParaStyles.is()) - m_xAutoParaStyles = new SwXAutoStyleFamily(m_pDocShell, nType ); - aRef = m_xAutoParaStyles; - } - break; - - default: - ; + if(!m_xAutoCharStyles.is()) + m_xAutoCharStyles = new SwXAutoStyleFamily(m_pDocShell, nType); + aRef = m_xAutoCharStyles; } - aRet <<= aRef; + break; + case IStyleAccess::AUTO_STYLE_RUBY: + { + if(!m_xAutoRubyStyles.is()) + m_xAutoRubyStyles = new SwXAutoStyleFamily(m_pDocShell, nType ); + aRef = m_xAutoRubyStyles; + } + break; + case IStyleAccess::AUTO_STYLE_PARA: + { + if(!m_xAutoParaStyles.is()) + m_xAutoParaStyles = new SwXAutoStyleFamily(m_pDocShell, nType ); + aRef = m_xAutoParaStyles; + } + break; + + default: + ; } - else - throw uno::RuntimeException(); + aRet <<= aRef; + return aRet; } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 360cccc531ca..968b30059d6f 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1037,14 +1037,13 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV tableCellProperties = aValue.get< uno::Sequence< beans::PropertyValue > >(); comphelper::SequenceAsHashMap aPropMap(tableCellProperties); OUString sRedlineType; - if(aPropMap.getValue("RedlineType") >>= sRedlineType) - { - // Create a 'Table Cell Redline' object - SwUnoCursorHelper::makeTableCellRedline(*pBox, sRedlineType, tableCellProperties); - } - else + if(!(aPropMap.getValue("RedlineType") >>= sRedlineType)) throw beans::UnknownPropertyException("No redline type property: ", static_cast<cppu::OWeakObject*>(this)); + // Create a 'Table Cell Redline' object + SwUnoCursorHelper::makeTableCellRedline(*pBox, sRedlineType, tableCellProperties); + + } else { @@ -1308,15 +1307,14 @@ void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno: tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >(); comphelper::SequenceAsHashMap aPropMap( tableRowProperties ); OUString sRedlineType; - if( aPropMap.getValue("RedlineType") >>= sRedlineType ) - { - // Create a 'Table Row Redline' object - SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties); - } - else + if( !(aPropMap.getValue("RedlineType") >>= sRedlineType) ) { throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) ); } + + // Create a 'Table Row Redline' object + SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties); + } else { @@ -3388,115 +3386,114 @@ SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV { const SfxItemPropertySimpleEntry *const pEntry = m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName); - if(pEntry) - { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + if(!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - SwDoc *const pDoc = m_pImpl->m_pTableCursor->GetDoc(); - SwUnoTableCursor& rCursor(dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor)); + if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) + throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + + SwDoc *const pDoc = m_pImpl->m_pTableCursor->GetDoc(); + SwUnoTableCursor& rCursor(dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor)); + { + // HACK: remove pending actions for selecting old style tables + UnoActionRemoveContext aRemoveContext(rCursor); + } + rCursor.MakeBoxSels(); + switch(pEntry->nWID ) + { + case FN_UNO_TABLE_CELL_BACKGROUND: { - // HACK: remove pending actions for selecting old style tables - UnoActionRemoveContext aRemoveContext(rCursor); + SvxBrushItem aBrush( RES_BACKGROUND ); + SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush); + static_cast<SfxPoolItem&>(aBrush).PutValue(aValue, pEntry->nMemberId); + pDoc->SetBoxAttr(*m_pImpl->m_pTableCursor, aBrush); + } - rCursor.MakeBoxSels(); - switch(pEntry->nWID ) + break; + case RES_BOX : { - case FN_UNO_TABLE_CELL_BACKGROUND: + SfxItemSet aSet(pDoc->GetAttrPool(), + svl::Items<RES_BOX, RES_BOX, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{}); + SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); + aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::ALL, false); + SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::NONE; + switch(pEntry->nMemberId & ~CONVERT_TWIPS) { - SvxBrushItem aBrush( RES_BACKGROUND ); - SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush); - static_cast<SfxPoolItem&>(aBrush).PutValue(aValue, pEntry->nMemberId); - pDoc->SetBoxAttr(*m_pImpl->m_pTableCursor, aBrush); - + case LEFT_BORDER : nValid = SvxBoxInfoItemValidFlags::LEFT; break; + case RIGHT_BORDER: nValid = SvxBoxInfoItemValidFlags::RIGHT; break; + case TOP_BORDER : nValid = SvxBoxInfoItemValidFlags::TOP; break; + case BOTTOM_BORDER: nValid = SvxBoxInfoItemValidFlags::BOTTOM; break; + case LEFT_BORDER_DISTANCE : + case RIGHT_BORDER_DISTANCE: + case TOP_BORDER_DISTANCE : + case BOTTOM_BORDER_DISTANCE: + nValid = SvxBoxInfoItemValidFlags::DISTANCE; + break; } - break; - case RES_BOX : - { - SfxItemSet aSet(pDoc->GetAttrPool(), - svl::Items<RES_BOX, RES_BOX, - SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{}); - SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER ); - aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::ALL, false); - SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::NONE; - switch(pEntry->nMemberId & ~CONVERT_TWIPS) - { - case LEFT_BORDER : nValid = SvxBoxInfoItemValidFlags::LEFT; break; - case RIGHT_BORDER: nValid = SvxBoxInfoItemValidFlags::RIGHT; break; - case TOP_BORDER : nValid = SvxBoxInfoItemValidFlags::TOP; break; - case BOTTOM_BORDER: nValid = SvxBoxInfoItemValidFlags::BOTTOM; break; - case LEFT_BORDER_DISTANCE : - case RIGHT_BORDER_DISTANCE: - case TOP_BORDER_DISTANCE : - case BOTTOM_BORDER_DISTANCE: - nValid = SvxBoxInfoItemValidFlags::DISTANCE; - break; - } - aBoxInfo.SetValid(nValid); + aBoxInfo.SetValid(nValid); - aSet.Put(aBoxInfo); - SwDoc::GetTabBorders(rCursor, aSet); + aSet.Put(aBoxInfo); + SwDoc::GetTabBorders(rCursor, aSet); - aSet.Put(aBoxInfo); - SvxBoxItem aBoxItem(static_cast<const SvxBoxItem&>(aSet.Get(RES_BOX))); - static_cast<SfxPoolItem&>(aBoxItem).PutValue(aValue, pEntry->nMemberId); - aSet.Put(aBoxItem); - pDoc->SetTabBorders(*m_pImpl->m_pTableCursor, aSet); - } - break; - case RES_BOXATR_FORMAT: - { - SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT); - static_cast<SfxPoolItem&>(aNumberFormat).PutValue(aValue, 0); - pDoc->SetBoxAttr(rCursor, aNumberFormat); - } - break; - case FN_UNO_RANGE_ROW_LABEL: - { - bool bTmp = *o3tl::doAccess<bool>(aValue); - if (m_pImpl->m_bFirstRowAsLabel != bTmp) - { - lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners); - m_pImpl->m_bFirstRowAsLabel = bTmp; - } - } - break; - case FN_UNO_RANGE_COL_LABEL: + aSet.Put(aBoxInfo); + SvxBoxItem aBoxItem(static_cast<const SvxBoxItem&>(aSet.Get(RES_BOX))); + static_cast<SfxPoolItem&>(aBoxItem).PutValue(aValue, pEntry->nMemberId); + aSet.Put(aBoxItem); + pDoc->SetTabBorders(*m_pImpl->m_pTableCursor, aSet); + } + break; + case RES_BOXATR_FORMAT: + { + SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT); + static_cast<SfxPoolItem&>(aNumberFormat).PutValue(aValue, 0); + pDoc->SetBoxAttr(rCursor, aNumberFormat); + } + break; + case FN_UNO_RANGE_ROW_LABEL: + { + bool bTmp = *o3tl::doAccess<bool>(aValue); + if (m_pImpl->m_bFirstRowAsLabel != bTmp) { - bool bTmp = *o3tl::doAccess<bool>(aValue); - if (m_pImpl->m_bFirstColumnAsLabel != bTmp) - { - lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners); - m_pImpl->m_bFirstColumnAsLabel = bTmp; - } + lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners); + m_pImpl->m_bFirstRowAsLabel = bTmp; } - break; - case RES_VERT_ORIENT: + } + break; + case FN_UNO_RANGE_COL_LABEL: + { + bool bTmp = *o3tl::doAccess<bool>(aValue); + if (m_pImpl->m_bFirstColumnAsLabel != bTmp) { - sal_Int16 nAlign = -1; - aValue >>= nAlign; - if( nAlign >= text::VertOrientation::NONE && nAlign <= text::VertOrientation::BOTTOM) - pDoc->SetBoxAlign( rCursor, nAlign ); + lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners); + m_pImpl->m_bFirstColumnAsLabel = bTmp; } - break; - default: - { - SfxItemSet aItemSet( pDoc->GetAttrPool(), {{pEntry->nWID, pEntry->nWID}} ); - SwUnoCursorHelper::GetCursorAttr(rCursor.GetSelRing(), - aItemSet); + } + break; + case RES_VERT_ORIENT: + { + sal_Int16 nAlign = -1; + aValue >>= nAlign; + if( nAlign >= text::VertOrientation::NONE && nAlign <= text::VertOrientation::BOTTOM) + pDoc->SetBoxAlign( rCursor, nAlign ); + } + break; + default: + { + SfxItemSet aItemSet( pDoc->GetAttrPool(), {{pEntry->nWID, pEntry->nWID}} ); + SwUnoCursorHelper::GetCursorAttr(rCursor.GetSelRing(), + aItemSet); - if (!SwUnoCursorHelper::SetCursorPropertyValue( - *pEntry, aValue, rCursor.GetSelRing(), aItemSet)) - { - m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); - } - SwUnoCursorHelper::SetCursorAttr(rCursor.GetSelRing(), - aItemSet, SetAttrMode::DEFAULT, true); + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, aValue, rCursor.GetSelRing(), aItemSet)) + { + m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); } + SwUnoCursorHelper::SetCursorAttr(rCursor.GetSelRing(), + aItemSet, SetAttrMode::DEFAULT, true); } } - else - throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + } } @@ -3509,76 +3506,75 @@ uno::Any SAL_CALL SwXCellRange::getPropertyValue(const OUString& rPropertyName) { const SfxItemPropertySimpleEntry *const pEntry = m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName); - if(pEntry) + if(!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + + switch(pEntry->nWID ) { - switch(pEntry->nWID ) + case FN_UNO_TABLE_CELL_BACKGROUND: { - case FN_UNO_TABLE_CELL_BACKGROUND: - { - SvxBrushItem aBrush( RES_BACKGROUND ); - if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush)) - aBrush.QueryValue(aRet, pEntry->nMemberId); + SvxBrushItem aBrush( RES_BACKGROUND ); + if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush)) + aBrush.QueryValue(aRet, pEntry->nMemberId); - } - break; - case RES_BOX : - { - SwDoc *const pDoc = m_pImpl->m_pTableCursor->GetDoc(); - SfxItemSet aSet(pDoc->GetAttrPool(), - svl::Items<RES_BOX, RES_BOX, - SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{}); - aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER )); - SwDoc::GetTabBorders(*m_pImpl->m_pTableCursor, aSet); - const SvxBoxItem& rBoxItem = static_cast<const SvxBoxItem&>(aSet.Get(RES_BOX)); - rBoxItem.QueryValue(aRet, pEntry->nMemberId); - } - break; - case RES_BOXATR_FORMAT: - OSL_FAIL("not implemented"); - break; - case FN_UNO_PARA_STYLE: - { - SwFormatColl *const pTmpFormat = - SwUnoCursorHelper::GetCurTextFormatColl(*m_pImpl->m_pTableCursor, false); - OUString sRet; - if(pFormat) - sRet = pTmpFormat->GetName(); - aRet <<= sRet; - } - break; - case FN_UNO_RANGE_ROW_LABEL: - aRet <<= m_pImpl->m_bFirstRowAsLabel; - break; - case FN_UNO_RANGE_COL_LABEL: - aRet <<= m_pImpl->m_bFirstColumnAsLabel; - break; - case RES_VERT_ORIENT: - { - SwFormatVertOrient aVertOrient; - if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aVertOrient)) - { - aVertOrient.QueryValue( aRet, pEntry->nMemberId ); - } - } - break; - default: + } + break; + case RES_BOX : + { + SwDoc *const pDoc = m_pImpl->m_pTableCursor->GetDoc(); + SfxItemSet aSet(pDoc->GetAttrPool(), + svl::Items<RES_BOX, RES_BOX, + SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{}); + aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER )); + SwDoc::GetTabBorders(*m_pImpl->m_pTableCursor, aSet); + const SvxBoxItem& rBoxItem = static_cast<const SvxBoxItem&>(aSet.Get(RES_BOX)); + rBoxItem.QueryValue(aRet, pEntry->nMemberId); + } + break; + case RES_BOXATR_FORMAT: + OSL_FAIL("not implemented"); + break; + case FN_UNO_PARA_STYLE: + { + SwFormatColl *const pTmpFormat = + SwUnoCursorHelper::GetCurTextFormatColl(*m_pImpl->m_pTableCursor, false); + OUString sRet; + if(pFormat) + sRet = pTmpFormat->GetName(); + aRet <<= sRet; + } + break; + case FN_UNO_RANGE_ROW_LABEL: + aRet <<= m_pImpl->m_bFirstRowAsLabel; + break; + case FN_UNO_RANGE_COL_LABEL: + aRet <<= m_pImpl->m_bFirstColumnAsLabel; + break; + case RES_VERT_ORIENT: + { + SwFormatVertOrient aVertOrient; + if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aVertOrient)) { - SfxItemSet aSet( - m_pImpl->m_pTableCursor->GetDoc()->GetAttrPool(), - svl::Items< - RES_CHRATR_BEGIN, RES_FRMATR_END - 1, - RES_UNKNOWNATR_CONTAINER, - RES_UNKNOWNATR_CONTAINER>{}); - // first look at the attributes of the cursor - SwUnoTableCursor *const pCursor = - dynamic_cast<SwUnoTableCursor*>(&(*m_pImpl->m_pTableCursor)); - SwUnoCursorHelper::GetCursorAttr(pCursor->GetSelRing(), aSet); - m_pImpl->m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); + aVertOrient.QueryValue( aRet, pEntry->nMemberId ); } } + break; + default: + { + SfxItemSet aSet( + m_pImpl->m_pTableCursor->GetDoc()->GetAttrPool(), + svl::Items< + RES_CHRATR_BEGIN, RES_FRMATR_END - 1, + RES_UNKNOWNATR_CONTAINER, + RES_UNKNOWNATR_CONTAINER>{}); + // first look at the attributes of the cursor + SwUnoTableCursor *const pCursor = + dynamic_cast<SwUnoTableCursor*>(&(*m_pImpl->m_pTableCursor)); + SwUnoCursorHelper::GetCursorAttr(pCursor->GetSelRing(), aSet); + m_pImpl->m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); + } } - else - throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + } return aRet; } diff --git a/sw/source/core/unocore/unotextmarkup.cxx b/sw/source/core/unocore/unotextmarkup.cxx index ee0799ba5e98..941093a7a581 100644 --- a/sw/source/core/unocore/unotextmarkup.cxx +++ b/sw/source/core/unocore/unotextmarkup.cxx @@ -409,10 +409,9 @@ void SAL_CALL SwXTextMarkup::commitMultiTextMarkup( { if (pMarkups[i].nType == text::TextMarkupType::SENTENCE) { - if (nSentenceMarkUpIndex == -1) - nSentenceMarkUpIndex = i; - else // there is already one sentence markup - throw lang::IllegalArgumentException(); + if (nSentenceMarkUpIndex != -1) + throw lang::IllegalArgumentException(); // there is already one sentence markup + nSentenceMarkUpIndex = i; } else if( pMarkups[i].nType != text::TextMarkupType::PROOFREADING ) return; diff --git a/sw/source/ui/vba/vbaborders.cxx b/sw/source/ui/vba/vbaborders.cxx index 73d3fd2c6c79..ad70cf1bdf09 100644 --- a/sw/source/ui/vba/vbaborders.cxx +++ b/sw/source/ui/vba/vbaborders.cxx @@ -178,52 +178,51 @@ public: sal_Int32 nLineStyle = 0; _linestyle >>= nLineStyle; table::BorderLine aBorderLine; - if ( getBorderLine( aBorderLine ) ) + if ( !getBorderLine( aBorderLine ) ) + throw uno::RuntimeException("Method failed" ); + + switch ( nLineStyle ) { - switch ( nLineStyle ) + case word::WdLineStyle::wdLineStyleNone: + { + aBorderLine.InnerLineWidth = 0; + aBorderLine.OuterLineWidth = 0; + break; + } + case word::WdLineStyle::wdLineStyleDashDot: + case word::WdLineStyle::wdLineStyleDashDotDot: + case word::WdLineStyle::wdLineStyleDashDotStroked: + case word::WdLineStyle::wdLineStyleDashLargeGap: + case word::WdLineStyle::wdLineStyleDashSmallGap: + case word::WdLineStyle::wdLineStyleDot: + case word::WdLineStyle::wdLineStyleDouble: + case word::WdLineStyle::wdLineStyleDoubleWavy: + case word::WdLineStyle::wdLineStyleEmboss3D: + case word::WdLineStyle::wdLineStyleEngrave3D: + case word::WdLineStyle::wdLineStyleInset: + case word::WdLineStyle::wdLineStyleOutset: + case word::WdLineStyle::wdLineStyleSingle: + case word::WdLineStyle::wdLineStyleSingleWavy: + case word::WdLineStyle::wdLineStyleThickThinLargeGap: + case word::WdLineStyle::wdLineStyleThickThinMedGap: + case word::WdLineStyle::wdLineStyleThickThinSmallGap: + case word::WdLineStyle::wdLineStyleThinThickLargeGap: + case word::WdLineStyle::wdLineStyleThinThickMedGap: + case word::WdLineStyle::wdLineStyleThinThickSmallGap: + case word::WdLineStyle::wdLineStyleThinThickThinLargeGap: + case word::WdLineStyle::wdLineStyleThinThickThinMedGap: + case word::WdLineStyle::wdLineStyleThinThickThinSmallGap: + case word::WdLineStyle::wdLineStyleTriple: { - case word::WdLineStyle::wdLineStyleNone: - { - aBorderLine.InnerLineWidth = 0; - aBorderLine.OuterLineWidth = 0; - break; - } - case word::WdLineStyle::wdLineStyleDashDot: - case word::WdLineStyle::wdLineStyleDashDotDot: - case word::WdLineStyle::wdLineStyleDashDotStroked: - case word::WdLineStyle::wdLineStyleDashLargeGap: - case word::WdLineStyle::wdLineStyleDashSmallGap: - case word::WdLineStyle::wdLineStyleDot: - case word::WdLineStyle::wdLineStyleDouble: - case word::WdLineStyle::wdLineStyleDoubleWavy: - case word::WdLineStyle::wdLineStyleEmboss3D: - case word::WdLineStyle::wdLineStyleEngrave3D: - case word::WdLineStyle::wdLineStyleInset: - case word::WdLineStyle::wdLineStyleOutset: - case word::WdLineStyle::wdLineStyleSingle: - case word::WdLineStyle::wdLineStyleSingleWavy: - case word::WdLineStyle::wdLineStyleThickThinLargeGap: - case word::WdLineStyle::wdLineStyleThickThinMedGap: - case word::WdLineStyle::wdLineStyleThickThinSmallGap: - case word::WdLineStyle::wdLineStyleThinThickLargeGap: - case word::WdLineStyle::wdLineStyleThinThickMedGap: - case word::WdLineStyle::wdLineStyleThinThickSmallGap: - case word::WdLineStyle::wdLineStyleThinThickThinLargeGap: - case word::WdLineStyle::wdLineStyleThinThickThinMedGap: - case word::WdLineStyle::wdLineStyleThinThickThinSmallGap: - case word::WdLineStyle::wdLineStyleTriple: - { - aBorderLine.InnerLineWidth = 0; - aBorderLine.OuterLineWidth = OOLineHairline; - break; - } - default: - throw uno::RuntimeException("Bad param" ); + aBorderLine.InnerLineWidth = 0; + aBorderLine.OuterLineWidth = OOLineHairline; + break; } - setBorderLine( aBorderLine ); + default: + throw uno::RuntimeException("Bad param" ); } - else - throw uno::RuntimeException("Method failed" ); + setBorderLine( aBorderLine ); + } }; diff --git a/sw/source/ui/vba/vbaselection.cxx b/sw/source/ui/vba/vbaselection.cxx index df4c34706726..14bef8e35a26 100644 --- a/sw/source/ui/vba/vbaselection.cxx +++ b/sw/source/ui/vba/vbaselection.cxx @@ -82,19 +82,18 @@ uno::Reference< text::XTextRange > SwVbaSelection::GetSelectedRange() { uno::Reference< text::XTextRange > xTextRange; uno::Reference< lang::XServiceInfo > xServiceInfo( mxModel->getCurrentSelection(), uno::UNO_QUERY_THROW ); - if( xServiceInfo->supportsService("com.sun.star.text.TextRanges") ) + if( !xServiceInfo->supportsService("com.sun.star.text.TextRanges") ) { - uno::Reference< container::XIndexAccess > xTextRanges( xServiceInfo, uno::UNO_QUERY_THROW ); - if( xTextRanges->getCount() > 0 ) - { - // if there are multiple selection, just return the last selected Range. - xTextRange.set( xTextRanges->getByIndex( xTextRanges->getCount()-1 ), uno::UNO_QUERY_THROW ); - } + throw uno::RuntimeException("Not implemented" ); } - else + + uno::Reference< container::XIndexAccess > xTextRanges( xServiceInfo, uno::UNO_QUERY_THROW ); + if( xTextRanges->getCount() > 0 ) { - throw uno::RuntimeException("Not implemented" ); + // if there are multiple selection, just return the last selected Range. + xTextRange.set( xTextRanges->getByIndex( xTextRanges->getCount()-1 ), uno::UNO_QUERY_THROW ); } + return xTextRange; } @@ -646,10 +645,9 @@ uno::Reference< word::XRange > SAL_CALL SwVbaSelection::GoTo( const uno::Any& _w nPage = 0; } } - if( nPage != 0 ) - xPageCursor->jumpToPage( ( sal_Int16 )nPage ); - else + if( nPage == 0 ) throw uno::RuntimeException("Not implemented" ); + xPageCursor->jumpToPage( ( sal_Int16 )nPage ); break; } default: diff --git a/sw/source/ui/vba/vbastyle.cxx b/sw/source/ui/vba/vbastyle.cxx index 7fc026d2f3c3..1fd50b63812d 100644 --- a/sw/source/ui/vba/vbastyle.cxx +++ b/sw/source/ui/vba/vbastyle.cxx @@ -127,15 +127,13 @@ void SAL_CALL SwVbaStyle::setNameLocal( const OUString& _namelocal ) uno::Reference< word::XParagraphFormat > SAL_CALL SwVbaStyle::getParagraphFormat() { - if( word::WdStyleType::wdStyleTypeParagraph == getType() ) - { - uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW ); - return uno::Reference< word::XParagraphFormat >( new SwVbaParagraphFormat( this, mxContext, mxStyleProps ) ); - } - else + if( word::WdStyleType::wdStyleTypeParagraph != getType() ) { throw uno::RuntimeException(); } + + uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW ); + return uno::Reference< word::XParagraphFormat >( new SwVbaParagraphFormat( this, mxContext, mxStyleProps ) ); } sal_Bool SAL_CALL SwVbaStyle::getAutomaticallyUpdate() @@ -155,30 +153,26 @@ uno::Any SAL_CALL SwVbaStyle::getBaseStyle() // ParentStyle OUString sBaseStyle; mxStyleProps->getPropertyValue("ParentStyle") >>= sBaseStyle; - if( !sBaseStyle.isEmpty() ) - { - uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) ); - return xCol->Item( uno::makeAny( sBaseStyle ), uno::Any() ); - } - else + if( sBaseStyle.isEmpty() ) { throw uno::RuntimeException(); } + + uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) ); + return xCol->Item( uno::makeAny( sBaseStyle ), uno::Any() ); } void SAL_CALL SwVbaStyle::setBaseStyle( const uno::Any& _basestyle ) { uno::Reference< word::XStyle > xStyle; _basestyle >>= xStyle; - if( xStyle.is() ) - { - OUString sBaseStyle = xStyle->getName(); - mxStyleProps->setPropertyValue("ParentStyle", uno::makeAny( sBaseStyle ) ); - } - else + if( !xStyle.is() ) { throw uno::RuntimeException(); } + + OUString sBaseStyle = xStyle->getName(); + mxStyleProps->setPropertyValue("ParentStyle", uno::makeAny( sBaseStyle ) ); } uno::Any SAL_CALL SwVbaStyle::getNextParagraphStyle() @@ -186,30 +180,26 @@ uno::Any SAL_CALL SwVbaStyle::getNextParagraphStyle() //FollowStyle OUString sFollowStyle; mxStyleProps->getPropertyValue("FollowStyle") >>= sFollowStyle; - if( !sFollowStyle.isEmpty() ) - { - uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) ); - return xCol->Item( uno::makeAny( sFollowStyle ), uno::Any() ); - } - else + if( sFollowStyle.isEmpty() ) { throw uno::RuntimeException(); } + + uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) ); + return xCol->Item( uno::makeAny( sFollowStyle ), uno::Any() ); } void SAL_CALL SwVbaStyle::setNextParagraphStyle( const uno::Any& _nextparagraphstyle ) { uno::Reference< word::XStyle > xStyle; _nextparagraphstyle >>= xStyle; - if( xStyle.is() ) - { - OUString sFollowStyle = xStyle->getName(); - mxStyleProps->setPropertyValue("FollowStyle", uno::makeAny( sFollowStyle ) ); - } - else + if( !xStyle.is() ) { throw uno::RuntimeException(); } + + OUString sFollowStyle = xStyle->getName(); + mxStyleProps->setPropertyValue("FollowStyle", uno::makeAny( sFollowStyle ) ); } ::sal_Int32 SAL_CALL SwVbaStyle::getListLevelNumber() diff --git a/sw/source/ui/vba/vbatemplate.cxx b/sw/source/ui/vba/vbatemplate.cxx index 0a2452f9bb4a..27af69f99148 100644 --- a/sw/source/ui/vba/vbatemplate.cxx +++ b/sw/source/ui/vba/vbatemplate.cxx @@ -98,15 +98,13 @@ SwVbaTemplate::AutoTextEntries( const uno::Any& index ) OUString sNewGroup = lcl_CheckGroupName( sGroup ); uno::Reference< container::XIndexAccess > xGroup; - if( xAutoTextContainer->hasByName( sNewGroup ) ) - { - xGroup.set( xAutoTextContainer->getByName( sNewGroup ), uno::UNO_QUERY_THROW ); - } - else + if( !xAutoTextContainer->hasByName( sNewGroup ) ) { throw uno::RuntimeException("Auto Text Entry doesn't exist" ); } + xGroup.set( xAutoTextContainer->getByName( sNewGroup ), uno::UNO_QUERY_THROW ); + uno::Reference< XCollection > xCol( new SwVbaAutoTextEntries( this, mxContext, xGroup ) ); if( index.hasValue() ) return xCol->Item( index, uno::Any() ); diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx index 986f81bbe1fb..8790a4763986 100644 --- a/sw/source/uibase/misc/glosdoc.cxx +++ b/sw/source/uibase/misc/glosdoc.cxx @@ -613,15 +613,13 @@ Reference< text::XAutoTextEntry > SwGlossaries::GetAutoTextEntry( bool bCreate = ( rCompleteGroupName == GetDefName() ); std::unique_ptr< SwTextBlocks > pGlosGroup( GetGroupDoc( rCompleteGroupName, bCreate ) ); - if ( pGlosGroup.get() && !pGlosGroup->GetError() ) - { - sal_uInt16 nIdx = pGlosGroup->GetIndex( rEntryName ); - if ( USHRT_MAX == nIdx ) - throw container::NoSuchElementException(); - } - else + if ( !pGlosGroup.get() || pGlosGroup->GetError() ) throw lang::WrappedTargetException(); + sal_uInt16 nIdx = pGlosGroup->GetIndex( rEntryName ); + if ( USHRT_MAX == nIdx ) + throw container::NoSuchElementException(); + Reference< text::XAutoTextEntry > xReturn; UnoAutoTextEntries::iterator aSearch( m_aGlossaryEntries.begin() ); diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index 45a111c0b213..4e91560f0cc2 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -385,60 +385,58 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf { //the printer must be created OUString sPrinterName; - if( rValue >>= sPrinterName ) + if( !(rValue >>= sPrinterName) ) + throw IllegalArgumentException(); + + if( !mpPrinter && !sPrinterName.isEmpty() && mpDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) { - if( !mpPrinter && !sPrinterName.isEmpty() && mpDocSh->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) + SfxPrinter* pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( true ); + if ( pPrinter->GetName() != sPrinterName ) { - SfxPrinter* pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( true ); - if ( pPrinter->GetName() != sPrinterName ) + VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName ); + assert (! pNewPrinter->isDisposed() ); + if( pNewPrinter->IsKnown() ) + { + // set printer only once; in _postSetValues + mpPrinter = pNewPrinter; + } + else { - VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName ); - assert (! pNewPrinter->isDisposed() ); - if( pNewPrinter->IsKnown() ) - { - // set printer only once; in _postSetValues - mpPrinter = pNewPrinter; - } - else - { - pNewPrinter.disposeAndClear(); - } + pNewPrinter.disposeAndClear(); } } } - else - throw IllegalArgumentException(); + } break; case HANDLE_PRINTER_SETUP: { Sequence < sal_Int8 > aSequence; - if ( rValue >>= aSequence ) + if ( !(rValue >>= aSequence) ) + throw IllegalArgumentException(); + + sal_uInt32 nSize = aSequence.getLength(); + if( nSize > 0 ) { - sal_uInt32 nSize = aSequence.getLength(); - if( nSize > 0 ) + SvMemoryStream aStream (aSequence.getArray(), nSize, + StreamMode::READ ); + aStream.Seek ( STREAM_SEEK_TO_BEGIN ); + static sal_uInt16 const nRange[] = { - SvMemoryStream aStream (aSequence.getArray(), nSize, - StreamMode::READ ); - aStream.Seek ( STREAM_SEEK_TO_BEGIN ); - static sal_uInt16 const nRange[] = - { - FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER, - SID_HTML_MODE, SID_HTML_MODE, - SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, - SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, - 0 - }; - auto pItemSet = o3tl::make_unique<SfxItemSet>( mpDoc->GetAttrPool(), nRange ); - VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) ); - assert (! pPrinter->isDisposed() ); - // set printer only once; in _postSetValues - mpPrinter.disposeAndClear(); - mpPrinter = pPrinter; - } + FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER, + SID_HTML_MODE, SID_HTML_MODE, + SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, + SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, + 0 + }; + auto pItemSet = o3tl::make_unique<SfxItemSet>( mpDoc->GetAttrPool(), nRange ); + VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) ); + assert (! pPrinter->isDisposed() ); + // set printer only once; in _postSetValues + mpPrinter.disposeAndClear(); + mpPrinter = pPrinter; } - else - throw IllegalArgumentException(); + } break; case HANDLE_IS_KERN_ASIAN_PUNCTUATION: diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx index 5d57bb4cdc22..9091fb7208a6 100644 --- a/sw/source/uibase/uno/unoatxt.cxx +++ b/sw/source/uibase/uno/unoatxt.cxx @@ -270,27 +270,26 @@ void SwXAutoTextGroup::renameByName(const OUString& aElementName, if(aNewElementName != aElementName && hasByName(aNewElementName)) throw container::ElementExistException(); std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr); - if(pGlosGroup && !pGlosGroup->GetError()) + if(!pGlosGroup || pGlosGroup->GetError()) + throw uno::RuntimeException(); + + sal_uInt16 nIdx = pGlosGroup->GetIndex( aElementName); + if(USHRT_MAX == nIdx) + throw lang::IllegalArgumentException(); + OUString aNewShort(aNewElementName); + OUString aNewName(aNewElementTitle); + sal_uInt16 nOldLongIdx = pGlosGroup->GetLongIndex( aNewShort ); + sal_uInt16 nOldIdx = pGlosGroup->GetIndex( aNewName ); + + if( nIdx != USHRT_MAX && + (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&& + (nOldIdx == USHRT_MAX || nOldIdx == nIdx )) { - sal_uInt16 nIdx = pGlosGroup->GetIndex( aElementName); - if(USHRT_MAX == nIdx) - throw lang::IllegalArgumentException(); - OUString aNewShort(aNewElementName); - OUString aNewName(aNewElementTitle); - sal_uInt16 nOldLongIdx = pGlosGroup->GetLongIndex( aNewShort ); - sal_uInt16 nOldIdx = pGlosGroup->GetIndex( aNewName ); - - if( nIdx != USHRT_MAX && - (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&& - (nOldIdx == USHRT_MAX || nOldIdx == nIdx )) - { - pGlosGroup->Rename( nIdx, &aNewShort, &aNewName ); - if(pGlosGroup->GetError() != ERRCODE_NONE) - throw io::IOException(); - } + pGlosGroup->Rename( nIdx, &aNewShort, &aNewName ); + if(pGlosGroup->GetError() != ERRCODE_NONE) + throw io::IOException(); } - else - throw uno::RuntimeException(); + } static bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextRange* pxRange) @@ -433,14 +432,12 @@ void SwXAutoTextGroup::removeByName(const OUString& aEntryName) { SolarMutexGuard aGuard; std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr); - if(pGlosGroup && !pGlosGroup->GetError()) - { - sal_uInt16 nIdx = pGlosGroup->GetIndex(aEntryName); - if ( nIdx != USHRT_MAX ) - pGlosGroup->Delete(nIdx); - } - else + if(!pGlosGroup || pGlosGroup->GetError()) throw container::NoSuchElementException(); + + sal_uInt16 nIdx = pGlosGroup->GetIndex(aEntryName); + if ( nIdx != USHRT_MAX ) + pGlosGroup->Delete(nIdx); } OUString SwXAutoTextGroup::getName() diff --git a/sw/source/uibase/uno/unomailmerge.cxx b/sw/source/uibase/uno/unomailmerge.cxx index 4f8441d770e2..e68f614c3729 100644 --- a/sw/source/uibase/uno/unomailmerge.cxx +++ b/sw/source/uibase/uno/unomailmerge.cxx @@ -1085,10 +1085,9 @@ void SAL_CALL SwXMailMerge::addPropertyChangeListener( if (!m_bDisposing && rListener.is()) { const SfxItemPropertySimpleEntry* pCur = m_pPropSet->getPropertyMap().getByName( rPropertyName ); - if (pCur) - m_aPropListeners.addInterface( pCur->nWID, rListener ); - else + if (!pCur) throw UnknownPropertyException(); + m_aPropListeners.addInterface( pCur->nWID, rListener ); } } @@ -1100,10 +1099,9 @@ void SAL_CALL SwXMailMerge::removePropertyChangeListener( if (!m_bDisposing && rListener.is()) { const SfxItemPropertySimpleEntry* pCur = m_pPropSet->getPropertyMap().getByName( rPropertyName ); - if (pCur) - m_aPropListeners.removeInterface( pCur->nWID, rListener ); - else + if (!pCur) throw UnknownPropertyException(); + m_aPropListeners.removeInterface( pCur->nWID, rListener ); } } diff --git a/sw/source/uibase/uno/unomod.cxx b/sw/source/uibase/uno/unomod.cxx index 81f72fa9b37c..a41e1f40b1e2 100644 --- a/sw/source/uibase/uno/unomod.cxx +++ b/sw/source/uibase/uno/unomod.cxx @@ -354,10 +354,10 @@ void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, sal_Int16 nTmp = 0; rValue >>= nTmp; SwPostItMode nVal = static_cast<SwPostItMode>(nTmp); - if(nVal <= SwPostItMode::EndPage) - mpPrtOpt->SetPrintPostIts(nVal); - else + if(!(nVal <= SwPostItMode::EndPage)) throw lang::IllegalArgumentException(); + + mpPrtOpt->SetPrintPostIts(nVal); } break; case HANDLE_PRINTSET_EMPTY_PAGES: @@ -369,10 +369,10 @@ void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, case HANDLE_PRINTSET_FAX_NAME: { OUString sString; - if ( rValue >>= sString) - mpPrtOpt->SetFaxName(sString); - else + if ( !(rValue >>= sString)) throw lang::IllegalArgumentException(); + + mpPrtOpt->SetFaxName(sString); } break; case HANDLE_PRINTSET_PROSPECT_RTL: @@ -708,20 +708,18 @@ void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, c break; case HANDLE_VIEWSET_HELP_URL: { - if ( pView ) - { - OUString sHelpURL; - if ( ! ( rValue >>= sHelpURL ) ) - throw IllegalArgumentException(); - - INetURLObject aHID( sHelpURL ); - if ( aHID.GetProtocol() == INetProtocol::Hid ) - pView->GetEditWin().SetHelpId( OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 ) ); - else - throw IllegalArgumentException (); - } - else + if ( !pView ) throw UnknownPropertyException(); + + OUString sHelpURL; + if ( ! ( rValue >>= sHelpURL ) ) + throw IllegalArgumentException(); + + INetURLObject aHID( sHelpURL ); + if ( aHID.GetProtocol() != INetProtocol::Hid ) + throw IllegalArgumentException (); + + pView->GetEditWin().SetHelpId( OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 ) ); } break; case HANDLE_VIEWSET_HORI_RULER_METRIC: @@ -889,17 +887,15 @@ void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, u break; case HANDLE_VIEWSET_HELP_URL : { - if ( pView ) - { - bBool = false; - OUStringBuffer sHelpURL; - sHelpURL.append ( INET_HID_SCHEME ); - SwEditWin &rEditWin = pView->GetEditWin(); - sHelpURL.append( OUString::fromUtf8( rEditWin.GetHelpId() ) ); - rValue <<= sHelpURL.makeStringAndClear(); - } - else + if ( !pView ) throw UnknownPropertyException(); + + bBool = false; + OUStringBuffer sHelpURL; + sHelpURL.append ( INET_HID_SCHEME ); + SwEditWin &rEditWin = pView->GetEditWin(); + sHelpURL.append( OUString::fromUtf8( rEditWin.GetHelpId() ) ); + rValue <<= sHelpURL.makeStringAndClear(); } break; case HANDLE_VIEWSET_HORI_RULER_METRIC: diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 865d00e5b6ce..c1e25aadb2a7 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -527,26 +527,22 @@ void SwXTextDocument::reformat() void SwXTextDocument::lockControllers() { SolarMutexGuard aGuard; - if(IsValid()) - { - UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc()); - aActionArr.push_front(pContext); - } - else + if(!IsValid()) throw DisposedException("", static_cast< XTextDocument* >(this)); + + UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc()); + aActionArr.push_front(pContext); } void SwXTextDocument::unlockControllers() { SolarMutexGuard aGuard; - if(!aActionArr.empty()) - { - UnoActionContext* pContext = aActionArr.front(); - aActionArr.pop_front(); - delete pContext; - } - else + if(aActionArr.empty()) throw RuntimeException("Nothing to unlock"); + + UnoActionContext* pContext = aActionArr.front(); + aActionArr.pop_front(); + delete pContext; } sal_Bool SwXTextDocument::hasControllersLocked() @@ -636,15 +632,13 @@ void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties() { SolarMutexGuard aGuard; - if(IsValid()) + if(!IsValid()) + throw DisposedException("", static_cast< XTextDocument* >(this)); + + if(!mxXLineNumberingProperties.is()) { - if(!mxXLineNumberingProperties.is()) - { - mxXLineNumberingProperties = new SwXLineNumberingProperties(pDocShell->GetDoc()); - } + mxXLineNumberingProperties = new SwXLineNumberingProperties(pDocShell->GetDoc()); } - else - throw DisposedException("", static_cast< XTextDocument* >(this)); return mxXLineNumberingProperties; } @@ -1002,35 +996,34 @@ Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings() { SolarMutexGuard aGuard; Sequence< beans::PropertyValue > aSeq(9); - if(IsValid()) - { - beans::PropertyValue* pArray = aSeq.getArray(); - SwPagePreviewPrtData aData; - const SwPagePreviewPrtData* pData = pDocShell->GetDoc()->GetPreviewPrtData(); - if(pData) - aData = *pData; - Any aVal; - aVal <<= (sal_Int16)aData.GetRow(); - pArray[0] = beans::PropertyValue("PageRows", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int16)aData.GetCol(); - pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)convertTwipToMm100(aData.GetLeftSpace()); - pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)convertTwipToMm100(aData.GetRightSpace()); - pArray[3] = beans::PropertyValue("RightMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)convertTwipToMm100(aData.GetTopSpace()); - pArray[4] = beans::PropertyValue("TopMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)convertTwipToMm100(aData.GetBottomSpace()); - pArray[5] = beans::PropertyValue("BottomMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)convertTwipToMm100(aData.GetHorzSpace()); - pArray[6] = beans::PropertyValue("HoriMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)convertTwipToMm100(aData.GetVertSpace()); - pArray[7] = beans::PropertyValue("VertMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= aData.GetLandscape(); - pArray[8] = beans::PropertyValue("IsLandscape", -1, aVal, PropertyState_DIRECT_VALUE); - } - else + if(!IsValid()) throw DisposedException("", static_cast< XTextDocument* >(this)); + + beans::PropertyValue* pArray = aSeq.getArray(); + SwPagePreviewPrtData aData; + const SwPagePreviewPrtData* pData = pDocShell->GetDoc()->GetPreviewPrtData(); + if(pData) + aData = *pData; + Any aVal; + aVal <<= (sal_Int16)aData.GetRow(); + pArray[0] = beans::PropertyValue("PageRows", -1, aVal, PropertyState_DIRECT_VALUE); + aVal <<= (sal_Int16)aData.GetCol(); + pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE); + aVal <<= (sal_Int32)convertTwipToMm100(aData.GetLeftSpace()); + pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE); + aVal <<= (sal_Int32)convertTwipToMm100(aData.GetRightSpace()); + pArray[3] = beans::PropertyValue("RightMargin", -1, aVal, PropertyState_DIRECT_VALUE); + aVal <<= (sal_Int32)convertTwipToMm100(aData.GetTopSpace()); + pArray[4] = beans::PropertyValue("TopMargin", -1, aVal, PropertyState_DIRECT_VALUE); + aVal <<= (sal_Int32)convertTwipToMm100(aData.GetBottomSpace()); + pArray[5] = beans::PropertyValue("BottomMargin", -1, aVal, PropertyState_DIRECT_VALUE); + aVal <<= (sal_Int32)convertTwipToMm100(aData.GetHorzSpace()); + pArray[6] = beans::PropertyValue("HoriMargin", -1, aVal, PropertyState_DIRECT_VALUE); + aVal <<= (sal_Int32)convertTwipToMm100(aData.GetVertSpace()); + pArray[7] = beans::PropertyValue("VertMargin", -1, aVal, PropertyState_DIRECT_VALUE); + aVal <<= aData.GetLandscape(); + pArray[8] = beans::PropertyValue("IsLandscape", -1, aVal, PropertyState_DIRECT_VALUE); + return aSeq; } @@ -1078,155 +1071,154 @@ static OUString lcl_CreateOutlineString( size_t nIndex, void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings) { SolarMutexGuard aGuard; - if(IsValid()) - { - SwPagePreviewPrtData aData; - //if only a few properties are coming, then use the current settings - const SwPagePreviewPrtData* pData = pDocShell->GetDoc()->GetPreviewPrtData(); - if(pData) - aData = *pData; - const beans::PropertyValue* pProperties = aSettings.getConstArray(); - int nCount = aSettings.getLength(); - for(int i = 0; i < nCount; i++) + if(!IsValid()) + throw DisposedException("", static_cast< XTextDocument* >(this)); + + SwPagePreviewPrtData aData; + //if only a few properties are coming, then use the current settings + const SwPagePreviewPrtData* pData = pDocShell->GetDoc()->GetPreviewPrtData(); + if(pData) + aData = *pData; + const beans::PropertyValue* pProperties = aSettings.getConstArray(); + int nCount = aSettings.getLength(); + for(int i = 0; i < nCount; i++) + { + OUString sName = pProperties[i].Name; + const Any& rVal = pProperties[i].Value; + bool bException; + sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException); + if( sName == "PageRows" ) { - OUString sName = pProperties[i].Name; - const Any& rVal = pProperties[i].Value; - bool bException; - sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException); - if( sName == "PageRows" ) - { - if(!nVal || nVal > 0xff) - throw RuntimeException("Invalid value"); - aData.SetRow((sal_uInt8)nVal); - } - else if(sName == "PageColumns") - { - if(!nVal || nVal > 0xff) - throw RuntimeException("Invalid value"); - aData.SetCol((sal_uInt8)nVal); - } - else if(sName == "LeftMargin") - { - aData.SetLeftSpace(convertMm100ToTwip(nVal)); - } - else if(sName == "RightMargin") - { - aData.SetRightSpace(convertMm100ToTwip(nVal)); - } - else if(sName == "TopMargin") - { - aData.SetTopSpace(convertMm100ToTwip(nVal)); - } - else if(sName == "BottomMargin") - { - aData.SetBottomSpace(convertMm100ToTwip(nVal)); - } - else if(sName == "HoriMargin") - { - aData.SetHorzSpace(convertMm100ToTwip(nVal)); - } - else if(sName == "VertMargin") - { - aData.SetVertSpace(convertMm100ToTwip(nVal)); - } - else if(sName == "IsLandscape") + if(!nVal || nVal > 0xff) + throw RuntimeException("Invalid value"); + aData.SetRow((sal_uInt8)nVal); + } + else if(sName == "PageColumns") + { + if(!nVal || nVal > 0xff) + throw RuntimeException("Invalid value"); + aData.SetCol((sal_uInt8)nVal); + } + else if(sName == "LeftMargin") + { + aData.SetLeftSpace(convertMm100ToTwip(nVal)); + } + else if(sName == "RightMargin") + { + aData.SetRightSpace(convertMm100ToTwip(nVal)); + } + else if(sName == "TopMargin") + { + aData.SetTopSpace(convertMm100ToTwip(nVal)); + } + else if(sName == "BottomMargin") + { + aData.SetBottomSpace(convertMm100ToTwip(nVal)); + } + else if(sName == "HoriMargin") + { + aData.SetHorzSpace(convertMm100ToTwip(nVal)); + } + else if(sName == "VertMargin") + { + aData.SetVertSpace(convertMm100ToTwip(nVal)); + } + else if(sName == "IsLandscape") + { + auto b = o3tl::tryAccess<bool>(rVal); + bException = bool(b); + if (b) { - auto b = o3tl::tryAccess<bool>(rVal); - bException = bool(b); - if (b) - { - aData.SetLandscape(*b); - } + aData.SetLandscape(*b); } - else - bException = true; - if(bException) - throw RuntimeException(); } - pDocShell->GetDoc()->SetPreviewPrtData(&aData); + else + bException = true; + if(bException) + throw RuntimeException(); } - else - throw DisposedException("", static_cast< XTextDocument* >(this)); + pDocShell->GetDoc()->SetPreviewPrtData(&aData); + } void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions) { SolarMutexGuard aGuard; - if(IsValid()) + if(!IsValid()) + throw DisposedException("", static_cast< XTextDocument* >(this)); + + SfxViewFrame* pFrame = SfxViewFrame::LoadHiddenDocument( *pDocShell, SfxInterfaceId(7) ); + SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SfxCallMode::SYNCHRON, + pDocShell->GetDoc()->GetAttrPool()); + aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, true)); + + for ( int n = 0; n < xOptions.getLength(); ++n ) { - SfxViewFrame* pFrame = SfxViewFrame::LoadHiddenDocument( *pDocShell, SfxInterfaceId(7) ); - SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SfxCallMode::SYNCHRON, - pDocShell->GetDoc()->GetAttrPool()); - aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, true)); + // get Property-Value from options + const beans::PropertyValue &rProp = xOptions.getConstArray()[n]; + Any aValue( rProp.Value ); - for ( int n = 0; n < xOptions.getLength(); ++n ) + // FileName-Property? + if ( rProp.Name == UNO_NAME_FILE_NAME ) { - // get Property-Value from options - const beans::PropertyValue &rProp = xOptions.getConstArray()[n]; - Any aValue( rProp.Value ); - - // FileName-Property? - if ( rProp.Name == UNO_NAME_FILE_NAME ) + OUString sFileURL; + if ( rProp.Value >>= sFileURL ) { - OUString sFileURL; - if ( rProp.Value >>= sFileURL ) - { - // Convert the File URL into a system dependent path, as the SalPrinter expects - OUString sSystemPath; - FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath ); - aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) ); - } - else if ( rProp.Value.getValueType() != cppu::UnoType<void>::get() ) - throw IllegalArgumentException(); + // Convert the File URL into a system dependent path, as the SalPrinter expects + OUString sSystemPath; + FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath ); + aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) ); } + else if ( rProp.Value.getValueType() != cppu::UnoType<void>::get() ) + throw IllegalArgumentException(); + } - // CopyCount-Property - else if ( rProp.Name == UNO_NAME_COPY_COUNT ) - { - sal_Int32 nCopies = 0; - aValue >>= nCopies; - aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) ); - } + // CopyCount-Property + else if ( rProp.Name == UNO_NAME_COPY_COUNT ) + { + sal_Int32 nCopies = 0; + aValue >>= nCopies; + aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) ); + } - // Collate-Property - else if ( rProp.Name == UNO_NAME_COLLATE ) - { - if ( auto b = o3tl::tryAccess<bool>(rProp.Value) ) + // Collate-Property + else if ( rProp.Name == UNO_NAME_COLLATE ) + { + auto b = o3tl::tryAccess<bool>(rProp.Value); + if ( !b ) + throw IllegalArgumentException(); + aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *b ) ); - aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *b ) ); - else - throw IllegalArgumentException(); - } + } - // Sort-Property - else if ( rProp.Name == UNO_NAME_SORT ) - { - if ( auto b = o3tl::tryAccess<bool>(rProp.Value) ) - aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *b ) ); - else - throw IllegalArgumentException(); - } + // Sort-Property + else if ( rProp.Name == UNO_NAME_SORT ) + { + auto b = o3tl::tryAccess<bool>(rProp.Value); + if ( !b ) + throw IllegalArgumentException(); - // Pages-Property - else if ( rProp.Name == UNO_NAME_PAGES ) - { - OUString sTmp; - if ( rProp.Value >>= sTmp ) - aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) ); - else - throw IllegalArgumentException(); - } + aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *b ) ); } - // #i117783# - bApplyPagePrintSettingsFromXPagePrintable = true; - pFrame->GetViewShell()->ExecuteSlot(aReq); - // Frame close - pFrame->DoClose(); + // Pages-Property + else if ( rProp.Name == UNO_NAME_PAGES ) + { + OUString sTmp; + if ( !(rProp.Value >>= sTmp) ) + throw IllegalArgumentException(); + + aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) ); + } } - else - throw DisposedException("", static_cast< XTextDocument* >(this)); + + // #i117783# + bApplyPagePrintSettingsFromXPagePrintable = true; + pFrame->GetViewShell()->ExecuteSlot(aReq); + // Frame close + pFrame->DoClose(); + } Reference< XNameAccess > SwXTextDocument::getReferenceMarks() @@ -4262,12 +4254,10 @@ void SwXOutlineTarget::setPropertyValue( Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName) { - Any aRet; - if(rPropertyName == UNO_LINK_DISPLAY_NAME) - aRet <<= sOutlineText; - else - throw UnknownPropertyException(); - return aRet; + if(rPropertyName != UNO_LINK_DISPLAY_NAME) + throw UnknownPropertyException();; + + return Any(sOutlineText); } void SwXOutlineTarget::addPropertyChangeListener( diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index 8681e73c21fe..3515f1f34f5e 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -482,30 +482,27 @@ uno::Reference< text::XTextViewCursor > SwXTextView::getViewCursor() { SolarMutexGuard aGuard; comphelper::ProfileZone aZone("getViewCursor"); - if(GetView()) + if(!GetView()) + throw uno::RuntimeException(); + + if(!mxTextViewCursor.is()) { - if(!mxTextViewCursor.is()) - { - mxTextViewCursor = new SwXTextViewCursor(GetView()); - } - return mxTextViewCursor; + mxTextViewCursor = new SwXTextViewCursor(GetView()); } - else - throw uno::RuntimeException(); + return mxTextViewCursor; } uno::Reference< beans::XPropertySet > SwXTextView::getViewSettings() { SolarMutexGuard aGuard; - if(m_pView) + if(!m_pView) + throw uno::RuntimeException(); + + if(!mxViewSettings.is()) { - if(!mxViewSettings.is()) - { - mxViewSettings = new SwXViewSettings( m_pView ); - } + mxViewSettings = new SwXViewSettings( m_pView ); } - else - throw uno::RuntimeException(); + return mxViewSettings; } @@ -879,86 +876,82 @@ awt::Point SwXTextViewCursor::getPosition() { SolarMutexGuard aGuard; awt::Point aRet; - if(m_pView) - { - const SwWrtShell& rSh = m_pView->GetWrtShell(); - const SwRect& aCharRect(rSh.GetCharRect()); + if(!m_pView) + throw uno::RuntimeException(); - const SwFrameFormat& rMaster = rSh.GetPageDesc( rSh.GetCurPageDesc() ).GetMaster(); + const SwWrtShell& rSh = m_pView->GetWrtShell(); + const SwRect& aCharRect(rSh.GetCharRect()); - const SvxULSpaceItem& rUL = rMaster.GetULSpace(); - const long nY = aCharRect.Top() - (rUL.GetUpper() + DOCUMENTBORDER); - aRet.Y = convertTwipToMm100(nY); + const SwFrameFormat& rMaster = rSh.GetPageDesc( rSh.GetCurPageDesc() ).GetMaster(); + + const SvxULSpaceItem& rUL = rMaster.GetULSpace(); + const long nY = aCharRect.Top() - (rUL.GetUpper() + DOCUMENTBORDER); + aRet.Y = convertTwipToMm100(nY); + + const SvxLRSpaceItem& rLR = rMaster.GetLRSpace(); + const long nX = aCharRect.Left() - (rLR.GetLeft() + DOCUMENTBORDER); + aRet.X = convertTwipToMm100(nX); - const SvxLRSpaceItem& rLR = rMaster.GetLRSpace(); - const long nX = aCharRect.Left() - (rLR.GetLeft() + DOCUMENTBORDER); - aRet.X = convertTwipToMm100(nX); - } - else - throw uno::RuntimeException(); return aRet; } void SwXTextViewCursor::collapseToStart() { SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + if(!m_pView) + throw uno::RuntimeException(); - SwWrtShell& rSh = m_pView->GetWrtShell(); - if(rSh.HasSelection()) - { - SwPaM* pShellCursor = rSh.GetCursor(); - if(*pShellCursor->GetPoint() > *pShellCursor->GetMark()) - pShellCursor->Exchange(); - pShellCursor->DeleteMark(); - rSh.EnterStdMode(); - rSh.SetSelection(*pShellCursor); - } + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + if(rSh.HasSelection()) + { + SwPaM* pShellCursor = rSh.GetCursor(); + if(*pShellCursor->GetPoint() > *pShellCursor->GetMark()) + pShellCursor->Exchange(); + pShellCursor->DeleteMark(); + rSh.EnterStdMode(); + rSh.SetSelection(*pShellCursor); } - else - throw uno::RuntimeException(); + } void SwXTextViewCursor::collapseToEnd() { SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + if(!m_pView) + throw uno::RuntimeException(); - SwWrtShell& rSh = m_pView->GetWrtShell(); - if(rSh.HasSelection()) - { - SwPaM* pShellCursor = rSh.GetCursor(); - if(*pShellCursor->GetPoint() < *pShellCursor->GetMark()) - pShellCursor->Exchange(); - pShellCursor->DeleteMark(); - rSh.EnterStdMode(); - rSh.SetSelection(*pShellCursor); - } + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + if(rSh.HasSelection()) + { + SwPaM* pShellCursor = rSh.GetCursor(); + if(*pShellCursor->GetPoint() < *pShellCursor->GetMark()) + pShellCursor->Exchange(); + pShellCursor->DeleteMark(); + rSh.EnterStdMode(); + rSh.SetSelection(*pShellCursor); } - else - throw uno::RuntimeException(); + } sal_Bool SwXTextViewCursor::isCollapsed() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - const SwWrtShell& rSh = m_pView->GetWrtShell(); - bRet = !rSh.HasSelection(); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + const SwWrtShell& rSh = m_pView->GetWrtShell(); + bRet = !rSh.HasSelection(); + return bRet; } @@ -967,15 +960,14 @@ sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand) { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, nCount, true ); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, nCount, true ); + return bRet; } @@ -983,15 +975,14 @@ sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand) { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, nCount, true ); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, nCount, true ); + return bRet; } @@ -1001,139 +992,138 @@ void SwXTextViewCursor::gotoRange( sal_Bool bExpand) { SolarMutexGuard aGuard; - if(m_pView && xRange.is()) + if(!(m_pView && xRange.is())) + throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); + if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException(); + } - SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); - if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) - { - throw uno::RuntimeException(); - } + ShellMode eSelMode = m_pView->GetShellMode(); + SwWrtShell& rSh = m_pView->GetWrtShell(); + // call EnterStdMode in non-text selections only + if(!bExpand || + (eSelMode != ShellMode::TableText && + eSelMode != ShellMode::ListText && + eSelMode != ShellMode::TableListText && + eSelMode != ShellMode::Text )) + rSh.EnterStdMode(); + SwPaM* pShellCursor = rSh.GetCursor(); + SwPaM aOwnPaM(*pShellCursor->GetPoint()); + if(pShellCursor->HasMark()) + { + aOwnPaM.SetMark(); + *aOwnPaM.GetMark() = *pShellCursor->GetMark(); + } - ShellMode eSelMode = m_pView->GetShellMode(); - SwWrtShell& rSh = m_pView->GetWrtShell(); - // call EnterStdMode in non-text selections only - if(!bExpand || - (eSelMode != ShellMode::TableText && - eSelMode != ShellMode::ListText && - eSelMode != ShellMode::TableListText && - eSelMode != ShellMode::Text )) - rSh.EnterStdMode(); - SwPaM* pShellCursor = rSh.GetCursor(); - SwPaM aOwnPaM(*pShellCursor->GetPoint()); - if(pShellCursor->HasMark()) - { - aOwnPaM.SetMark(); - *aOwnPaM.GetMark() = *pShellCursor->GetMark(); - } + uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); + SwXTextRange* pRange = nullptr; + SwXParagraph* pPara = nullptr; + OTextCursorHelper* pCursor = nullptr; + if(xRangeTunnel.is()) + { + pRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething( + SwXTextRange::getUnoTunnelId())); + pCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId())); + pPara = reinterpret_cast<SwXParagraph*>(xRangeTunnel->getSomething( + SwXParagraph::getUnoTunnelId())); + } - uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); - SwXTextRange* pRange = nullptr; - SwXParagraph* pPara = nullptr; - OTextCursorHelper* pCursor = nullptr; - if(xRangeTunnel.is()) + const FrameTypeFlags nFrameType = rSh.GetFrameType(nullptr,true); + + SwStartNodeType eSearchNodeType = SwNormalStartNode; + if(nFrameType & FrameTypeFlags::FLY_ANY) + eSearchNodeType = SwFlyStartNode; + else if(nFrameType &FrameTypeFlags::HEADER) + eSearchNodeType = SwHeaderStartNode; + else if(nFrameType & FrameTypeFlags::FOOTER) + eSearchNodeType = SwFooterStartNode; + else if(nFrameType & FrameTypeFlags::TABLE) + eSearchNodeType = SwTableBoxStartNode; + else if(nFrameType & FrameTypeFlags::FOOTNOTE) + eSearchNodeType = SwFootnoteStartNode; + + const SwStartNode* pOwnStartNode = aOwnPaM.GetNode(). + FindSttNodeByType(eSearchNodeType); + + const SwNode* pSrcNode = nullptr; + if(pCursor && pCursor->GetPaM()) + { + pSrcNode = &pCursor->GetPaM()->GetNode(); + } + else if (pRange) + { + SwPaM aPam(pRange->GetDoc().GetNodes()); + if (pRange->GetPositions(aPam)) { - pRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething( - SwXTextRange::getUnoTunnelId())); - pCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething( - OTextCursorHelper::getUnoTunnelId())); - pPara = reinterpret_cast<SwXParagraph*>(xRangeTunnel->getSomething( - SwXParagraph::getUnoTunnelId())); + pSrcNode = &aPam.GetNode(); } + } + else if (pPara && pPara->GetTextNode()) + { + pSrcNode = pPara->GetTextNode(); + } + const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : nullptr; - const FrameTypeFlags nFrameType = rSh.GetFrameType(nullptr,true); - - SwStartNodeType eSearchNodeType = SwNormalStartNode; - if(nFrameType & FrameTypeFlags::FLY_ANY) - eSearchNodeType = SwFlyStartNode; - else if(nFrameType &FrameTypeFlags::HEADER) - eSearchNodeType = SwHeaderStartNode; - else if(nFrameType & FrameTypeFlags::FOOTER) - eSearchNodeType = SwFooterStartNode; - else if(nFrameType & FrameTypeFlags::TABLE) - eSearchNodeType = SwTableBoxStartNode; - else if(nFrameType & FrameTypeFlags::FOOTNOTE) - eSearchNodeType = SwFootnoteStartNode; - - const SwStartNode* pOwnStartNode = aOwnPaM.GetNode(). - FindSttNodeByType(eSearchNodeType); - - const SwNode* pSrcNode = nullptr; - if(pCursor && pCursor->GetPaM()) - { - pSrcNode = &pCursor->GetPaM()->GetNode(); - } - else if (pRange) - { - SwPaM aPam(pRange->GetDoc().GetNodes()); - if (pRange->GetPositions(aPam)) - { - pSrcNode = &aPam.GetNode(); - } - } - else if (pPara && pPara->GetTextNode()) - { - pSrcNode = pPara->GetTextNode(); - } - const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : nullptr; + //Skip SectionNodes + while(pTmp && pTmp->IsSectionNode()) + { + pTmp = pTmp->StartOfSectionNode(); + } + while(pOwnStartNode && pOwnStartNode->IsSectionNode()) + { + pOwnStartNode = pOwnStartNode->StartOfSectionNode(); + } + //Without Expand it is allowed to jump out with the ViewCursor everywhere, + //with Expand only in the same environment + if(bExpand && + (pOwnStartNode != pTmp || + (eSelMode != ShellMode::TableText && + eSelMode != ShellMode::ListText && + eSelMode != ShellMode::TableListText && + eSelMode != ShellMode::Text))) + throw uno::RuntimeException(); - //Skip SectionNodes - while(pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - while(pOwnStartNode && pOwnStartNode->IsSectionNode()) - { - pOwnStartNode = pOwnStartNode->StartOfSectionNode(); - } - //Without Expand it is allowed to jump out with the ViewCursor everywhere, - //with Expand only in the same environment - if(bExpand && - (pOwnStartNode != pTmp || - (eSelMode != ShellMode::TableText && - eSelMode != ShellMode::ListText && - eSelMode != ShellMode::TableListText && - eSelMode != ShellMode::Text))) - throw uno::RuntimeException(); - - //Now, the selection must be expanded. - if(bExpand) + //Now, the selection must be expanded. + if(bExpand) + { + // The cursor should include everything that has been included + // by him and the transferred Range. + SwPosition aOwnLeft(*aOwnPaM.Start()); + SwPosition aOwnRight(*aOwnPaM.End()); + SwPosition* pParamLeft = rDestPam.Start(); + SwPosition* pParamRight = rDestPam.End(); + // Now four SwPositions are there, two of them are needed, but which? + if(aOwnRight > *pParamRight) + *aOwnPaM.GetPoint() = aOwnRight; + else + *aOwnPaM.GetPoint() = *pParamRight; + aOwnPaM.SetMark(); + if(aOwnLeft < *pParamLeft) + *aOwnPaM.GetMark() = aOwnLeft; + else + *aOwnPaM.GetMark() = *pParamLeft; + } + else + { + //The cursor shall match the passed range. + *aOwnPaM.GetPoint() = *rDestPam.GetPoint(); + if(rDestPam.HasMark()) { - // The cursor should include everything that has been included - // by him and the transferred Range. - SwPosition aOwnLeft(*aOwnPaM.Start()); - SwPosition aOwnRight(*aOwnPaM.End()); - SwPosition* pParamLeft = rDestPam.Start(); - SwPosition* pParamRight = rDestPam.End(); - // Now four SwPositions are there, two of them are needed, but which? - if(aOwnRight > *pParamRight) - *aOwnPaM.GetPoint() = aOwnRight; - else - *aOwnPaM.GetPoint() = *pParamRight; aOwnPaM.SetMark(); - if(aOwnLeft < *pParamLeft) - *aOwnPaM.GetMark() = aOwnLeft; - else - *aOwnPaM.GetMark() = *pParamLeft; + *aOwnPaM.GetMark() = *rDestPam.GetMark(); } else - { - //The cursor shall match the passed range. - *aOwnPaM.GetPoint() = *rDestPam.GetPoint(); - if(rDestPam.HasMark()) - { - aOwnPaM.SetMark(); - *aOwnPaM.GetMark() = *rDestPam.GetMark(); - } - else - aOwnPaM.DeleteMark(); - } - rSh.SetSelection(aOwnPaM); + aOwnPaM.DeleteMark(); } - else - throw uno::RuntimeException(); + rSh.SetSelection(aOwnPaM); + } @@ -1141,49 +1131,46 @@ void SwXTextViewCursor::gotoStart(sal_Bool bExpand) { SolarMutexGuard aGuard; comphelper::ProfileZone aZone("SwXTextViewCursor::gotoStart"); - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - m_pView->GetWrtShell().SttDoc( bExpand ); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + m_pView->GetWrtShell().SttDoc( bExpand ); + } void SwXTextViewCursor::gotoEnd(sal_Bool bExpand) { SolarMutexGuard aGuard; comphelper::ProfileZone aZone("SwXTextViewCursor::gotoEnd"); - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - m_pView->GetWrtShell().EndDoc( bExpand ); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + m_pView->GetWrtShell().EndDoc( bExpand ); + } sal_Bool SwXTextViewCursor::jumpToFirstPage() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) + if(!m_pView) + throw uno::RuntimeException(); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + if (rSh.IsSelFrameMode()) { - SwWrtShell& rSh = m_pView->GetWrtShell(); - if (rSh.IsSelFrameMode()) - { - rSh.UnSelectFrame(); - rSh.LeaveSelFrameMode(); - } - rSh.EnterStdMode(); - bRet = rSh.SttEndDoc(true); + rSh.UnSelectFrame(); + rSh.LeaveSelFrameMode(); } - else - throw uno::RuntimeException(); + rSh.EnterStdMode(); + bRet = rSh.SttEndDoc(true); + return bRet; } @@ -1191,20 +1178,19 @@ sal_Bool SwXTextViewCursor::jumpToLastPage() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) + if(!m_pView) + throw uno::RuntimeException(); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + if (rSh.IsSelFrameMode()) { - SwWrtShell& rSh = m_pView->GetWrtShell(); - if (rSh.IsSelFrameMode()) - { - rSh.UnSelectFrame(); - rSh.LeaveSelFrameMode(); - } - rSh.EnterStdMode(); - bRet = rSh.SttEndDoc(false); - rSh.SttPg(); + rSh.UnSelectFrame(); + rSh.LeaveSelFrameMode(); } - else - throw uno::RuntimeException(); + rSh.EnterStdMode(); + bRet = rSh.SttEndDoc(false); + rSh.SttPg(); + return bRet; } @@ -1212,10 +1198,11 @@ sal_Bool SwXTextViewCursor::jumpToPage(sal_Int16 nPage) { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - bRet = m_pView->GetWrtShell().GotoPage(nPage, true); - else + if(!m_pView) throw uno::RuntimeException(); + + bRet = m_pView->GetWrtShell().GotoPage(nPage, true); + return bRet; } @@ -1223,10 +1210,11 @@ sal_Bool SwXTextViewCursor::jumpToNextPage() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - bRet = m_pView->GetWrtShell().SttNxtPg(); - else + if(!m_pView) throw uno::RuntimeException(); + + bRet = m_pView->GetWrtShell().SttNxtPg(); + return bRet; } @@ -1234,10 +1222,11 @@ sal_Bool SwXTextViewCursor::jumpToPreviousPage() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - bRet = m_pView->GetWrtShell().EndPrvPg(); - else + if(!m_pView) throw uno::RuntimeException(); + + bRet = m_pView->GetWrtShell().EndPrvPg(); + return bRet; } @@ -1245,10 +1234,11 @@ sal_Bool SwXTextViewCursor::jumpToEndOfPage() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - bRet = m_pView->GetWrtShell().EndPg(); - else + if(!m_pView) throw uno::RuntimeException(); + + bRet = m_pView->GetWrtShell().EndPg(); + return bRet; } @@ -1256,10 +1246,11 @@ sal_Bool SwXTextViewCursor::jumpToStartOfPage() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - bRet = m_pView->GetWrtShell().SttPg(); - else + if(!m_pView) throw uno::RuntimeException(); + + bRet = m_pView->GetWrtShell().SttPg(); + return bRet; } @@ -1267,14 +1258,13 @@ sal_Int16 SwXTextViewCursor::getPage() { SolarMutexGuard aGuard; sal_Int16 nRet = 0; - if(m_pView) - { - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwPaM* pShellCursor = rSh.GetCursor(); - nRet = static_cast<sal_Int16>(pShellCursor->GetPageNum()); - } - else + if(!m_pView) throw uno::RuntimeException(); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + SwPaM* pShellCursor = rSh.GetCursor(); + nRet = static_cast<sal_Int16>(pShellCursor->GetPageNum()); + return nRet; } @@ -1282,15 +1272,14 @@ sal_Bool SwXTextViewCursor::screenDown() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - { - SfxRequest aReq(FN_PAGEDOWN, SfxCallMode::SLOT, m_pView->GetPool()); - m_pView->Execute(aReq); - const SfxPoolItem* pRet = aReq.GetReturnValue(); - bRet = pRet && static_cast<const SfxBoolItem*>(pRet)->GetValue(); - } - else + if(!m_pView) throw uno::RuntimeException(); + + SfxRequest aReq(FN_PAGEDOWN, SfxCallMode::SLOT, m_pView->GetPool()); + m_pView->Execute(aReq); + const SfxPoolItem* pRet = aReq.GetReturnValue(); + bRet = pRet && static_cast<const SfxBoolItem*>(pRet)->GetValue(); + return bRet; } @@ -1298,15 +1287,14 @@ sal_Bool SwXTextViewCursor::screenUp() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - { - SfxRequest aReq(FN_PAGEUP, SfxCallMode::SLOT, m_pView->GetPool()); - m_pView->Execute(aReq); - const SfxPoolItem* pRet = aReq.GetReturnValue(); - bRet = pRet && static_cast<const SfxBoolItem*>(pRet)->GetValue(); - } - else + if(!m_pView) throw uno::RuntimeException(); + + SfxRequest aReq(FN_PAGEUP, SfxCallMode::SLOT, m_pView->GetPool()); + m_pView->Execute(aReq); + const SfxPoolItem* pRet = aReq.GetReturnValue(); + bRet = pRet && static_cast<const SfxBoolItem*>(pRet)->GetValue(); + return bRet; } @@ -1314,18 +1302,17 @@ uno::Reference< text::XText > SwXTextViewCursor::getText() { SolarMutexGuard aGuard; uno::Reference< text::XText > xRet; - if(m_pView) - { - if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwPaM* pShellCursor = rSh.GetCursor(); - SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = ::sw::CreateParentXText(*pDoc, *pShellCursor->Start()); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection( false )) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + SwPaM* pShellCursor = rSh.GetCursor(); + SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); + xRet = ::sw::CreateParentXText(*pDoc, *pShellCursor->Start()); + return xRet; } @@ -1333,18 +1320,17 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getStart() { SolarMutexGuard aGuard; uno::Reference< text::XTextRange > xRet; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwPaM* pShellCursor = rSh.GetCursor(); - SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->Start(), nullptr); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + SwPaM* pShellCursor = rSh.GetCursor(); + SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); + xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->Start(), nullptr); + return xRet; } @@ -1352,18 +1338,17 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd() { SolarMutexGuard aGuard; uno::Reference< text::XTextRange > xRet; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwPaM* pShellCursor = rSh.GetCursor(); - SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->End(), nullptr); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + SwPaM* pShellCursor = rSh.GetCursor(); + SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); + xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCursor->End(), nullptr); + return xRet; } @@ -1438,36 +1423,33 @@ uno::Reference< XPropertySetInfo > SwXTextViewCursor::getPropertySetInfo( ) void SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const Any& aValue ) { SolarMutexGuard aGuard; - if(m_pView) - { - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwPaM* pShellCursor = rSh.GetCursor(); - SwNode& rNode = pShellCursor->GetNode(); - if (rNode.IsTextNode()) - { - SwUnoCursorHelper::SetPropertyValue( - *pShellCursor, *m_pPropSet, rPropertyName, aValue ); - } - else - throw RuntimeException(); - } - else + if(!m_pView) + throw RuntimeException(); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + SwPaM* pShellCursor = rSh.GetCursor(); + SwNode& rNode = pShellCursor->GetNode(); + if (!rNode.IsTextNode()) throw RuntimeException(); + + SwUnoCursorHelper::SetPropertyValue( + *pShellCursor, *m_pPropSet, rPropertyName, aValue ); + + } Any SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName ) { SolarMutexGuard aGuard; Any aRet; - if(m_pView) - { - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwPaM* pShellCursor = rSh.GetCursor(); - aRet = SwUnoCursorHelper::GetPropertyValue( - *pShellCursor, *m_pPropSet, rPropertyName); - } - else + if(!m_pView) throw RuntimeException(); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + SwPaM* pShellCursor = rSh.GetCursor(); + aRet = SwUnoCursorHelper::GetPropertyValue( + *pShellCursor, *m_pPropSet, rPropertyName); + return aRet; } @@ -1495,15 +1477,14 @@ PropertyState SwXTextViewCursor::getPropertyState( const OUString& rPropertyNam { SolarMutexGuard aGuard; PropertyState eState; - if(m_pView) - { - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwPaM* pShellCursor = rSh.GetCursor(); - eState = SwUnoCursorHelper::GetPropertyState( - *pShellCursor, *m_pPropSet, rPropertyName); - } - else + if(!m_pView) throw RuntimeException(); + + SwWrtShell& rSh = m_pView->GetWrtShell(); + SwPaM* pShellCursor = rSh.GetCursor(); + eState = SwUnoCursorHelper::GetPropertyState( + *pShellCursor, *m_pPropSet, rPropertyName); + return eState; } @@ -1553,15 +1534,14 @@ sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand) SolarMutexGuard aGuard; comphelper::ProfileZone aZone("SwXTextViewCursor::goDown"); bool bRet = false; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - bRet = m_pView->GetWrtShell().Down( bExpand, nCount, true ); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + bRet = m_pView->GetWrtShell().Down( bExpand, nCount, true ); + return bRet; } @@ -1570,15 +1550,14 @@ sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand) SolarMutexGuard aGuard; comphelper::ProfileZone aZone("SwXTextViewCursor::goUp"); bool bRet = false; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - bRet = m_pView->GetWrtShell().Up( bExpand, nCount, true ); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection()) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + bRet = m_pView->GetWrtShell().Up( bExpand, nCount, true ); + return bRet; } @@ -1586,15 +1565,14 @@ sal_Bool SwXTextViewCursor::isAtStartOfLine() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - { - if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - bRet = m_pView->GetWrtShell().IsAtLeftMargin(); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection( false )) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + bRet = m_pView->GetWrtShell().IsAtLeftMargin(); + return bRet; } @@ -1602,44 +1580,41 @@ sal_Bool SwXTextViewCursor::isAtEndOfLine() { SolarMutexGuard aGuard; bool bRet = false; - if(m_pView) - { - if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - bRet = m_pView->GetWrtShell().IsAtRightMargin(); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection( false )) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + bRet = m_pView->GetWrtShell().IsAtRightMargin(); + return bRet; } void SwXTextViewCursor::gotoEndOfLine(sal_Bool bExpand) { SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - m_pView->GetWrtShell().RightMargin(bExpand, true); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection( false )) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + m_pView->GetWrtShell().RightMargin(bExpand, true); + } void SwXTextViewCursor::gotoStartOfLine(sal_Bool bExpand) { SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - m_pView->GetWrtShell().LeftMargin(bExpand, true); - } - else + if(!m_pView) throw uno::RuntimeException(); + + if (!IsTextSelection( false )) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + + m_pView->GetWrtShell().LeftMargin(bExpand, true); + } OUString SwXTextViewCursor::getImplementationName() |