summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-30 10:36:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-31 11:00:25 +0200
commit2bfd51eab364c6b00603e2fa1e9c354eec90dc7f (patch)
tree232912bf3b41ebb6b8fbb91a541eb496a1e661a0 /sw
parent3ac9c33a93a04d3e3192a6a31c0c07d76c02b311 (diff)
loplugin:flatten in sw/core/unocore
Change-Id: If96b2484426f0d09119ca89943729c149675156f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99851 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/unocore/unobkm.cxx22
-rw-r--r--sw/source/core/unocore/unochart.cxx324
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx55
-rw-r--r--sw/source/core/unocore/unodraw.cxx763
-rw-r--r--sw/source/core/unocore/unoflatpara.cxx28
-rw-r--r--sw/source/core/unocore/unoframe.cxx76
-rw-r--r--sw/source/core/unocore/unoobj.cxx164
-rw-r--r--sw/source/core/unocore/unoobj2.cxx74
-rw-r--r--sw/source/core/unocore/unoparagraph.cxx90
-rw-r--r--sw/source/core/unocore/unoportenum.cxx76
-rw-r--r--sw/source/core/unocore/unorefmk.cxx24
-rw-r--r--sw/source/core/unocore/unosect.cxx42
-rw-r--r--sw/source/core/unocore/unosett.cxx127
-rw-r--r--sw/source/core/unocore/unostyle.cxx385
-rw-r--r--sw/source/core/unocore/unotbl.cxx363
-rw-r--r--sw/source/core/unocore/unotext.cxx50
16 files changed, 1331 insertions, 1332 deletions
diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx
index c8fa27faa896..97550fec41da 100644
--- a/sw/source/core/unocore/unobkm.cxx
+++ b/sw/source/core/unocore/unobkm.cxx
@@ -619,21 +619,21 @@ void SwXFieldmark::setFieldType(const OUString & fieldType)
IFieldmark *pBkm = dynamic_cast<IFieldmark*>(GetBookmark());
if(!pBkm)
throw uno::RuntimeException();
- if(fieldType != getFieldType())
+ if(fieldType == getFieldType())
+ return;
+
+ if(fieldType == ODF_FORMDROPDOWN || fieldType == ODF_FORMCHECKBOX || fieldType == ODF_FORMDATE)
{
- if(fieldType == ODF_FORMDROPDOWN || fieldType == ODF_FORMCHECKBOX || fieldType == ODF_FORMDATE)
+ ::sw::mark::IFieldmark* pNewFieldmark = GetIDocumentMarkAccess()->changeFormFieldmarkType(pBkm, fieldType);
+ if (pNewFieldmark)
{
- ::sw::mark::IFieldmark* pNewFieldmark = GetIDocumentMarkAccess()->changeFormFieldmarkType(pBkm, fieldType);
- if (pNewFieldmark)
- {
- registerInMark(*this, pNewFieldmark);
- return;
- }
+ registerInMark(*this, pNewFieldmark);
+ return;
}
-
- // We did not generate a new fieldmark, so set the type ID
- pBkm->SetFieldname(fieldType);
}
+
+ // We did not generate a new fieldmark, so set the type ID
+ pBkm->SetFieldname(fieldType);
}
uno::Reference<container::XNameContainer> SwXFieldmark::getParameters()
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index c2f9c915d43b..42c4b9876c53 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1365,20 +1365,20 @@ void SAL_CALL SwChartDataProvider::dispose( )
if (!m_bDisposed)
m_bDisposed = true;
}
- if (bMustDispose)
- {
- // dispose all data-sequences
- for (const auto& rEntry : m_aDataSequences)
- {
- DisposeAllDataSequences( rEntry.first );
- }
- // release all references to data-sequences
- m_aDataSequences.clear();
+ if (!bMustDispose)
+ return;
- // require listeners to release references to this object
- lang::EventObject aEvtObj( dynamic_cast< chart2::data::XDataProvider * >(this) );
- m_aEventListeners.disposeAndClear( aEvtObj );
+ // dispose all data-sequences
+ for (const auto& rEntry : m_aDataSequences)
+ {
+ DisposeAllDataSequences( rEntry.first );
}
+ // release all references to data-sequences
+ m_aDataSequences.clear();
+
+ // require listeners to release references to this object
+ lang::EventObject aEvtObj( dynamic_cast< chart2::data::XDataProvider * >(this) );
+ m_aEventListeners.disposeAndClear( aEvtObj );
}
void SAL_CALL SwChartDataProvider::addEventListener(
@@ -1425,21 +1425,21 @@ void SwChartDataProvider::RemoveDataSequence( const SwTable &rTable, uno::Refere
void SwChartDataProvider::InvalidateTable( const SwTable *pTable )
{
OSL_ENSURE( pTable, "table pointer is NULL" );
- if (pTable)
- {
- if (!m_bDisposed)
- pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking();
+ if (!pTable)
+ return;
- const Set_DataSequenceRef_t &rSet = m_aDataSequences[ pTable ];
- for (const auto& rItem : rSet)
+ if (!m_bDisposed)
+ pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking();
+
+ const Set_DataSequenceRef_t &rSet = m_aDataSequences[ pTable ];
+ for (const auto& rItem : rSet)
+ {
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
+ uno::Reference< util::XModifiable > xRef( xTemp, uno::UNO_QUERY );
+ if (xRef.is())
{
- uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
- uno::Reference< util::XModifiable > xRef( xTemp, uno::UNO_QUERY );
- if (xRef.is())
- {
- // mark the sequence as 'dirty' and notify listeners
- xRef->setModified( true );
- }
+ // mark the sequence as 'dirty' and notify listeners
+ xRef->setModified( true );
}
}
}
@@ -1447,79 +1447,79 @@ void SwChartDataProvider::InvalidateTable( const SwTable *pTable )
void SwChartDataProvider::DeleteBox( const SwTable *pTable, const SwTableBox &rBox )
{
OSL_ENSURE( pTable, "table pointer is NULL" );
- if (pTable)
- {
- if (!m_bDisposed)
- pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking();
+ if (!pTable)
+ return;
- Set_DataSequenceRef_t &rSet = m_aDataSequences[ pTable ];
+ if (!m_bDisposed)
+ pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking();
- // iterate over all data-sequences for that table...
- Set_DataSequenceRef_t::iterator aIt( rSet.begin() );
- Set_DataSequenceRef_t::iterator aEndIt( rSet.end() );
- Set_DataSequenceRef_t::iterator aDelIt; // iterator used for deletion when appropriate
- while (aIt != aEndIt)
- {
- SwChartDataSequence *pDataSeq = nullptr;
- bool bNowEmpty = false;
- bool bSeqDisposed = false;
+ Set_DataSequenceRef_t &rSet = m_aDataSequences[ pTable ];
+
+ // iterate over all data-sequences for that table...
+ Set_DataSequenceRef_t::iterator aIt( rSet.begin() );
+ Set_DataSequenceRef_t::iterator aEndIt( rSet.end() );
+ Set_DataSequenceRef_t::iterator aDelIt; // iterator used for deletion when appropriate
+ while (aIt != aEndIt)
+ {
+ SwChartDataSequence *pDataSeq = nullptr;
+ bool bNowEmpty = false;
+ bool bSeqDisposed = false;
- // check if weak reference is still valid...
- uno::Reference< chart2::data::XDataSequence > xTemp(*aIt);
- if (xTemp.is())
+ // check if weak reference is still valid...
+ uno::Reference< chart2::data::XDataSequence > xTemp(*aIt);
+ if (xTemp.is())
+ {
+ // then delete that table box (check if implementation cursor needs to be adjusted)
+ pDataSeq = static_cast< SwChartDataSequence * >( xTemp.get() );
+ if (pDataSeq)
{
- // then delete that table box (check if implementation cursor needs to be adjusted)
- pDataSeq = static_cast< SwChartDataSequence * >( xTemp.get() );
- if (pDataSeq)
+ try
{
- try
- {
- bNowEmpty = pDataSeq->DeleteBox( rBox );
- }
- catch (const lang::DisposedException&)
- {
- bNowEmpty = true;
- bSeqDisposed = true;
- }
-
- if (bNowEmpty)
- aDelIt = aIt;
+ bNowEmpty = pDataSeq->DeleteBox( rBox );
+ }
+ catch (const lang::DisposedException&)
+ {
+ bNowEmpty = true;
+ bSeqDisposed = true;
}
- }
- ++aIt;
- if (bNowEmpty)
- {
- rSet.erase( aDelIt );
- if (pDataSeq && !bSeqDisposed)
- pDataSeq->dispose(); // the current way to tell chart that sth. got removed
+ if (bNowEmpty)
+ aDelIt = aIt;
}
}
+ ++aIt;
+
+ if (bNowEmpty)
+ {
+ rSet.erase( aDelIt );
+ if (pDataSeq && !bSeqDisposed)
+ pDataSeq->dispose(); // the current way to tell chart that sth. got removed
+ }
}
}
void SwChartDataProvider::DisposeAllDataSequences( const SwTable *pTable )
{
OSL_ENSURE( pTable, "table pointer is NULL" );
- if (pTable)
- {
- if (!m_bDisposed)
- pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking();
+ if (!pTable)
+ return;
- //! make a copy of the STL container!
- //! This is necessary since calling 'dispose' will implicitly remove an element
- //! of the original container, and thus any iterator in the original container
- //! would become invalid.
- const Set_DataSequenceRef_t aSet( m_aDataSequences[ pTable ] );
+ if (!m_bDisposed)
+ pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking();
- for (const auto& rItem : aSet)
+ //! make a copy of the STL container!
+ //! This is necessary since calling 'dispose' will implicitly remove an element
+ //! of the original container, and thus any iterator in the original container
+ //! would become invalid.
+ const Set_DataSequenceRef_t aSet( m_aDataSequences[ pTable ] );
+
+ for (const auto& rItem : aSet)
+ {
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
+ uno::Reference< lang::XComponent > xRef( xTemp, uno::UNO_QUERY );
+ if (xRef.is())
{
- uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
- uno::Reference< lang::XComponent > xRef( xTemp, uno::UNO_QUERY );
- if (xRef.is())
- {
- xRef->dispose();
- }
+ xRef->dispose();
}
}
}
@@ -1560,59 +1560,59 @@ void SwChartDataProvider::AddRowCols(
SwTableBox* pFirstBox = rBoxes[0];
SwTableBox* pLastBox = rBoxes.back();
- if (pFirstBox && pLastBox)
+ if (!(pFirstBox && pLastBox))
+ return;
+
+ sal_Int32 nFirstCol = -1, nFirstRow = -1, nLastCol = -1, nLastRow = -1;
+ SwXTextTable::GetCellPosition( pFirstBox->GetName(), nFirstCol, nFirstRow );
+ SwXTextTable::GetCellPosition( pLastBox->GetName(), nLastCol, nLastRow );
+
+ bool bAddCols = false; // default; also to be used if nBoxes == 1 :-/
+ if (nFirstCol == nLastCol && nFirstRow != nLastRow)
+ bAddCols = true;
+ if (nFirstCol != nLastCol && nFirstRow != nLastRow)
+ return;
+
+ //get range of indices in col/rows for new cells
+ sal_Int32 nFirstNewCol = nFirstCol;
+ sal_Int32 nFirstNewRow = bBehind ? nFirstRow + 1 : nFirstRow - nLines;
+ if (bAddCols)
{
- sal_Int32 nFirstCol = -1, nFirstRow = -1, nLastCol = -1, nLastRow = -1;
- SwXTextTable::GetCellPosition( pFirstBox->GetName(), nFirstCol, nFirstRow );
- SwXTextTable::GetCellPosition( pLastBox->GetName(), nLastCol, nLastRow );
+ OSL_ENSURE( nFirstCol == nLastCol, "column indices seem broken" );
+ nFirstNewCol = bBehind ? nFirstCol + 1 : nFirstCol - nLines;
+ nFirstNewRow = nFirstRow;
+ }
- bool bAddCols = false; // default; also to be used if nBoxes == 1 :-/
- if (nFirstCol == nLastCol && nFirstRow != nLastRow)
- bAddCols = true;
- if (nFirstCol == nLastCol || nFirstRow == nLastRow)
+ // iterate over all data-sequences for the table
+ const Set_DataSequenceRef_t &rSet = m_aDataSequences[ &rTable ];
+ for (const auto& rItem : rSet)
+ {
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
+ uno::Reference< chart2::data::XTextualDataSequence > xRef( xTemp, uno::UNO_QUERY );
+ if (xRef.is())
{
- //get range of indices in col/rows for new cells
- sal_Int32 nFirstNewCol = nFirstCol;
- sal_Int32 nFirstNewRow = bBehind ? nFirstRow + 1 : nFirstRow - nLines;
- if (bAddCols)
- {
- OSL_ENSURE( nFirstCol == nLastCol, "column indices seem broken" );
- nFirstNewCol = bBehind ? nFirstCol + 1 : nFirstCol - nLines;
- nFirstNewRow = nFirstRow;
- }
-
- // iterate over all data-sequences for the table
- const Set_DataSequenceRef_t &rSet = m_aDataSequences[ &rTable ];
- for (const auto& rItem : rSet)
+ const sal_Int32 nLen = xRef->getTextualData().getLength();
+ if (nLen > 1) // value data-sequence ?
{
- uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
- uno::Reference< chart2::data::XTextualDataSequence > xRef( xTemp, uno::UNO_QUERY );
- if (xRef.is())
+ auto pDataSeq = comphelper::getUnoTunnelImplementation<SwChartDataSequence>(xRef);
+ if (pDataSeq)
{
- const sal_Int32 nLen = xRef->getTextualData().getLength();
- if (nLen > 1) // value data-sequence ?
- {
- auto pDataSeq = comphelper::getUnoTunnelImplementation<SwChartDataSequence>(xRef);
- if (pDataSeq)
- {
- SwRangeDescriptor aDesc;
- pDataSeq->FillRangeDesc( aDesc );
+ SwRangeDescriptor aDesc;
+ pDataSeq->FillRangeDesc( aDesc );
- chart::ChartDataRowSource eDRSource = chart::ChartDataRowSource_COLUMNS;
- if (aDesc.nTop == aDesc.nBottom && aDesc.nLeft != aDesc.nRight)
- eDRSource = chart::ChartDataRowSource_ROWS;
+ chart::ChartDataRowSource eDRSource = chart::ChartDataRowSource_COLUMNS;
+ if (aDesc.nTop == aDesc.nBottom && aDesc.nLeft != aDesc.nRight)
+ eDRSource = chart::ChartDataRowSource_ROWS;
- if (!bAddCols && eDRSource == chart::ChartDataRowSource_COLUMNS)
- {
- // add rows: extend affected columns by newly added row cells
- pDataSeq->ExtendTo( true, nFirstNewRow, nLines );
- }
- else if (bAddCols && eDRSource == chart::ChartDataRowSource_ROWS)
- {
- // add cols: extend affected rows by newly added column cells
- pDataSeq->ExtendTo( false, nFirstNewCol, nLines );
- }
- }
+ if (!bAddCols && eDRSource == chart::ChartDataRowSource_COLUMNS)
+ {
+ // add rows: extend affected columns by newly added row cells
+ pDataSeq->ExtendTo( true, nFirstNewRow, nLines );
+ }
+ else if (bAddCols && eDRSource == chart::ChartDataRowSource_ROWS)
+ {
+ // add cols: extend affected rows by newly added column cells
+ pDataSeq->ExtendTo( false, nFirstNewCol, nLines );
}
}
}
@@ -2236,50 +2236,50 @@ void SAL_CALL SwChartDataSequence::dispose( )
if (!m_bDisposed)
m_bDisposed = true;
}
- if (bMustDispose)
+ if (!bMustDispose)
+ return;
+
+ m_bDisposed = true;
+ if (m_xDataProvider.is())
{
- m_bDisposed = true;
- if (m_xDataProvider.is())
+ const SwTable* pTable = SwTable::FindTable( GetFrameFormat() );
+ if (pTable)
{
- const SwTable* pTable = SwTable::FindTable( GetFrameFormat() );
- if (pTable)
- {
- uno::Reference< chart2::data::XDataSequence > xRef( dynamic_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY );
- m_xDataProvider->RemoveDataSequence( *pTable, xRef );
- }
- else {
- OSL_FAIL( "table missing" );
- }
+ uno::Reference< chart2::data::XDataSequence > xRef( dynamic_cast< chart2::data::XDataSequence * >(this), uno::UNO_QUERY );
+ m_xDataProvider->RemoveDataSequence( *pTable, xRef );
+ }
+ else {
+ OSL_FAIL( "table missing" );
+ }
- //#i119653# The bug is crashed for an exception thrown by
- //SwCharDataSequence::setModified() because
- //the SwCharDataSequence object has been disposed.
+ //#i119653# The bug is crashed for an exception thrown by
+ //SwCharDataSequence::setModified() because
+ //the SwCharDataSequence object has been disposed.
- //Actually, the former design of SwClient will disconnect itself
- //from the notification list in its destructor.
+ //Actually, the former design of SwClient will disconnect itself
+ //from the notification list in its destructor.
- //But the SwCharDataSequence won't be destructed but disposed in code
- //(the data member SwChartDataSequence::bDisposed will be set to
- //TRUE), the relationship between client and modification is not
- //released.
+ //But the SwCharDataSequence won't be destructed but disposed in code
+ //(the data member SwChartDataSequence::bDisposed will be set to
+ //TRUE), the relationship between client and modification is not
+ //released.
- //So any notification from modify object will lead to said
- //exception threw out. Recorrect the logic of code in
- //SwChartDataSequence::Dispose(), release the relationship
- //here...
- if (m_pFormat && m_pFormat->HasWriterListeners())
- {
- EndListeningAll();
- m_pFormat = nullptr;
- m_pTableCursor.reset(nullptr);
- }
+ //So any notification from modify object will lead to said
+ //exception threw out. Recorrect the logic of code in
+ //SwChartDataSequence::Dispose(), release the relationship
+ //here...
+ if (m_pFormat && m_pFormat->HasWriterListeners())
+ {
+ EndListeningAll();
+ m_pFormat = nullptr;
+ m_pTableCursor.reset(nullptr);
}
-
- // require listeners to release references to this object
- lang::EventObject aEvtObj( dynamic_cast< chart2::data::XDataSequence * >(this) );
- m_aModifyListeners.disposeAndClear( aEvtObj );
- m_aEvtListeners.disposeAndClear( aEvtObj );
}
+
+ // require listeners to release references to this object
+ lang::EventObject aEvtObj( dynamic_cast< chart2::data::XDataSequence * >(this) );
+ m_aModifyListeners.disposeAndClear( aEvtObj );
+ m_aEvtListeners.disposeAndClear( aEvtObj );
}
void SAL_CALL SwChartDataSequence::addEventListener(
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index a82e7a1c2308..451c9cce7fa4 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1116,39 +1116,38 @@ void InsertFile(SwUnoCursor* pUnoCursor, const OUString& rURL,
SfxObjectShellRef aRef( pDocSh );
pMed->Download(); // if necessary: start the download
- if( aRef.is() && 1 < aRef->GetRefCount() ) // Ref still valid?
- {
- SwReaderPtr pRdr;
- SfxItemSet* pSet = pMed->GetItemSet();
- pSet->Put(SfxBoolItem(FN_API_CALL, true));
- if(!sPassword.isEmpty())
- pSet->Put(SfxStringItem(SID_PASSWORD, sPassword));
- Reader *pRead = pDocSh->StartConvertFrom( *pMed, pRdr, nullptr, pUnoCursor);
- if( pRead )
- {
+ if( !(aRef.is() && 1 < aRef->GetRefCount()) ) // Ref still valid?
+ return;
- UnoActionContext aContext(pDoc);
+ SwReaderPtr pRdr;
+ SfxItemSet* pSet = pMed->GetItemSet();
+ pSet->Put(SfxBoolItem(FN_API_CALL, true));
+ if(!sPassword.isEmpty())
+ pSet->Put(SfxStringItem(SID_PASSWORD, sPassword));
+ Reader *pRead = pDocSh->StartConvertFrom( *pMed, pRdr, nullptr, pUnoCursor);
+ if( !pRead )
+ return;
- if(pUnoCursor->HasMark())
- pDoc->getIDocumentContentOperations().DeleteAndJoin(*pUnoCursor);
+ UnoActionContext aContext(pDoc);
- SwNodeIndex aSave( pUnoCursor->GetPoint()->nNode, -1 );
- sal_Int32 nContent = pUnoCursor->GetPoint()->nContent.GetIndex();
+ if(pUnoCursor->HasMark())
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(*pUnoCursor);
- ErrCode nErrno = pRdr->Read( *pRead ); // and paste the document
+ SwNodeIndex aSave( pUnoCursor->GetPoint()->nNode, -1 );
+ sal_Int32 nContent = pUnoCursor->GetPoint()->nContent.GetIndex();
- if(!nErrno)
- {
- ++aSave;
- pUnoCursor->SetMark();
- pUnoCursor->GetMark()->nNode = aSave;
-
- SwContentNode* pCntNode = aSave.GetNode().GetContentNode();
- if( !pCntNode )
- nContent = 0;
- pUnoCursor->GetMark()->nContent.Assign( pCntNode, nContent );
- }
- }
+ ErrCode nErrno = pRdr->Read( *pRead ); // and paste the document
+
+ if(!nErrno)
+ {
+ ++aSave;
+ pUnoCursor->SetMark();
+ pUnoCursor->GetMark()->nNode = aSave;
+
+ SwContentNode* pCntNode = aSave.GetNode().GetContentNode();
+ if( !pCntNode )
+ nContent = 0;
+ pUnoCursor->GetMark()->nContent.Assign( pCntNode, nContent );
}
}
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index d21756c65720..43fed7b070ef 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -789,23 +789,23 @@ void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & rShapeG
SolarMutexGuard aGuard;
if(!pDoc)
throw uno::RuntimeException();
- if(xPageAgg.is())
- {
- SwFmDrawPage* pPage = GetSvxPage();
- if(pPage) //TODO: can this be Null?
- {
- pPage->PreUnGroup(rShapeGroup);
- UnoActionContext aContext(pDoc);
- pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
+ if(!xPageAgg.is())
+ return;
- pDoc->UnGroupSelection( *pPage->GetDrawView() );
- pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(),
- RndStdIds::FLY_AT_PARA,
- true, false );
- pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
- pPage->RemovePageView();
- }
- }
+ SwFmDrawPage* pPage = GetSvxPage();
+ if(!pPage) //TODO: can this be Null?
+ return;
+
+ pPage->PreUnGroup(rShapeGroup);
+ UnoActionContext aContext(pDoc);
+ pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
+
+ pDoc->UnGroupSelection( *pPage->GetDrawView() );
+ pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(),
+ RndStdIds::FLY_AT_PARA,
+ true, false );
+ pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
+ pPage->RemovePageView();
}
SwFmDrawPage* SwXDrawPage::GetSvxPage()
@@ -1038,390 +1038,390 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a
SolarMutexGuard aGuard;
SwFrameFormat* pFormat = GetFrameFormat();
const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
- if(xShapeAgg.is())
+ if(!xShapeAgg.is())
+ return;
+
+ if(pEntry)
{
- if(pEntry)
+ if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
+ throw beans::PropertyVetoException ("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
+ // with the layout it is possible to move the anchor without changing the position
+ if(pFormat)
{
- if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
- throw beans::PropertyVetoException ("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
- // with the layout it is possible to move the anchor without changing the position
- if(pFormat)
+ SwAttrSet aSet(pFormat->GetAttrSet());
+ SwDoc* pDoc = pFormat->GetDoc();
+ if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == pEntry->nMemberId)
{
- SwAttrSet aSet(pFormat->GetAttrSet());
- SwDoc* pDoc = pFormat->GetDoc();
- if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == pEntry->nMemberId)
+ bool bDone = false;
+ uno::Reference<text::XTextFrame> xFrame;
+ if(aValue >>= xFrame)
{
- bool bDone = false;
- uno::Reference<text::XTextFrame> xFrame;
- if(aValue >>= xFrame)
+ SwXFrame* pFrame = comphelper::getUnoTunnelImplementation<SwXFrame>(xFrame);
+ if(pFrame && pFrame->GetFrameFormat() &&
+ pFrame->GetFrameFormat()->GetDoc() == pDoc)
{
- SwXFrame* pFrame = comphelper::getUnoTunnelImplementation<SwXFrame>(xFrame);
- if(pFrame && pFrame->GetFrameFormat() &&
- pFrame->GetFrameFormat()->GetDoc() == pDoc)
- {
- UnoActionContext aCtx(pDoc);
- SfxItemSet aItemSet( pDoc->GetAttrPool(),
- svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{} );
- aItemSet.SetParent(&pFormat->GetAttrSet());
- SwFormatAnchor aAnchor = static_cast<const SwFormatAnchor&>(aItemSet.Get(pEntry->nWID));
- SwPosition aPos(*pFrame->GetFrameFormat()->GetContent().GetContentIdx());
- aAnchor.SetAnchor(&aPos);
- aAnchor.SetType(RndStdIds::FLY_AT_FLY);
- aItemSet.Put(aAnchor);
- pFormat->SetFormatAttr(aItemSet);
- bDone = true;
- }
+ UnoActionContext aCtx(pDoc);
+ SfxItemSet aItemSet( pDoc->GetAttrPool(),
+ svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{} );
+ aItemSet.SetParent(&pFormat->GetAttrSet());
+ SwFormatAnchor aAnchor = static_cast<const SwFormatAnchor&>(aItemSet.Get(pEntry->nWID));
+ SwPosition aPos(*pFrame->GetFrameFormat()->GetContent().GetContentIdx());
+ aAnchor.SetAnchor(&aPos);
+ aAnchor.SetType(RndStdIds::FLY_AT_FLY);
+ aItemSet.Put(aAnchor);
+ pFormat->SetFormatAttr(aItemSet);
+ bDone = true;
}
- if(!bDone)
- throw lang::IllegalArgumentException();
}
- else if(RES_OPAQUE == pEntry->nWID)
+ if(!bDone)
+ throw lang::IllegalArgumentException();
+ }
+ else if(RES_OPAQUE == pEntry->nWID)
+ {
+ SvxShape* pSvxShape = GetSvxShape();
+ SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
+ if(pSvxShape)
{
- SvxShape* pSvxShape = GetSvxShape();
- SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
- if(pSvxShape)
+ SdrObject* pObj = pSvxShape->GetSdrObject();
+ // set layer of new drawing
+ // object to corresponding invisible layer.
+ bool bIsVisible = pDoc->getIDocumentDrawModelAccess().IsVisibleLayerId( pObj->GetLayer() );
+ if(SdrInventor::FmForm != pObj->GetObjInventor())
{
- SdrObject* pObj = pSvxShape->GetSdrObject();
- // set layer of new drawing
- // object to corresponding invisible layer.
- bool bIsVisible = pDoc->getIDocumentDrawModelAccess().IsVisibleLayerId( pObj->GetLayer() );
- if(SdrInventor::FmForm != pObj->GetObjInventor())
- {
- pObj->SetLayer( *o3tl::doAccess<bool>(aValue)
- ? ( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetHeavenId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleHeavenId() )
- : ( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetHellId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleHellId() ));
- }
- else
- {
- pObj->SetLayer( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetControlsId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleControlsId());
- }
-
+ pObj->SetLayer( *o3tl::doAccess<bool>(aValue)
+ ? ( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetHeavenId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleHeavenId() )
+ : ( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetHellId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleHellId() ));
+ }
+ else
+ {
+ pObj->SetLayer( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetControlsId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleControlsId());
}
}
- // #i26791# - special handling for property FN_TEXT_RANGE
- else if ( FN_TEXT_RANGE == pEntry->nWID )
+
+ }
+ // #i26791# - special handling for property FN_TEXT_RANGE
+ else if ( FN_TEXT_RANGE == pEntry->nWID )
+ {
+ SwFormatAnchor aAnchor( aSet.Get( RES_ANCHOR ) );
+ if (aAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
{
- SwFormatAnchor aAnchor( aSet.Get( RES_ANCHOR ) );
- if (aAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
- {
- // set property <TextRange> not valid for to-page anchored shapes
- throw lang::IllegalArgumentException();
- }
+ // set property <TextRange> not valid for to-page anchored shapes
+ throw lang::IllegalArgumentException();
+ }
+
+ std::unique_ptr<SwUnoInternalPaM> pInternalPam(
+ new SwUnoInternalPaM( *(pFormat->GetDoc()) ));
+ uno::Reference< text::XTextRange > xRg;
+ aValue >>= xRg;
+ if (!::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
+ {
+ 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
+ {
+ aAnchor.SetAnchor( pInternalPam->GetPoint() );
+ aSet.Put(aAnchor);
+ pFormat->SetFormatAttr(aSet);
+ }
+ }
+ else if (pEntry->nWID == FN_TEXT_BOX)
+ {
+ bool bValue(false);
+ aValue >>= bValue;
+ if (bValue)
+ SwTextBoxHelper::create(pFormat);
+ else
+ SwTextBoxHelper::destroy(pFormat);
- std::unique_ptr<SwUnoInternalPaM> pInternalPam(
- new SwUnoInternalPaM( *(pFormat->GetDoc()) ));
- uno::Reference< text::XTextRange > xRg;
- aValue >>= xRg;
- if (!::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
+ }
+ else if (pEntry->nWID == RES_CHAIN)
+ {
+ if (pEntry->nMemberId == MID_CHAIN_NEXTNAME || pEntry->nMemberId == MID_CHAIN_PREVNAME)
+ SwTextBoxHelper::syncProperty(pFormat, pEntry->nWID, pEntry->nMemberId, aValue);
+ }
+ // #i28749#
+ else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
+ {
+ sal_Int16 nPositionLayoutDir = 0;
+ aValue >>= nPositionLayoutDir;
+ pFormat->SetPositionLayoutDir( nPositionLayoutDir );
+ }
+ else if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout())
+ {
+ UnoActionContext aCtx(pDoc);
+ if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
+ {
+ SdrObject* pObj = pFormat->FindSdrObject();
+ SdrMarkList aList;
+ SdrMark aMark(pObj);
+ aList.InsertEntry(aMark);
+ sal_Int32 nAnchor = 0;
+ cppu::enum2int( nAnchor, aValue );
+ pDoc->ChgAnchor( aList, static_cast<RndStdIds>(nAnchor),
+ false, true );
+ }
+ else
+ {
+ m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
+ pFormat->SetFormatAttr(aSet);
+ }
+ }
+ else if( RES_FRM_SIZE == pEntry->nWID &&
+ ( pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH
+ || pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT_RELATION
+ || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION ) )
+ {
+ SvxShape* pSvxShape = GetSvxShape();
+ SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
+ if(pSvxShape)
+ {
+ SdrObject* pObj = pSvxShape->GetSdrObject();
+ sal_Int16 nPercent(100);
+ aValue >>= nPercent;
+ switch (pEntry->nMemberId)
{
- throw uno::RuntimeException();
+ case MID_FRMSIZE_REL_WIDTH:
+ pObj->SetRelativeWidth( nPercent / 100.0 );
+ break;
+ case MID_FRMSIZE_REL_HEIGHT:
+ pObj->SetRelativeHeight( nPercent / 100.0 );
+ break;
+ case MID_FRMSIZE_REL_WIDTH_RELATION:
+ pObj->SetRelativeWidthRelation(nPercent);
+ break;
+ case MID_FRMSIZE_REL_HEIGHT_RELATION:
+ pObj->SetRelativeHeightRelation(nPercent);
+ break;
}
+ }
+ }
+ else
+ {
+ m_pPropSet->setPropertyValue( *pEntry, aValue, aSet );
- if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+ if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
+ {
+ bool bSetAttr = true;
+ text::TextContentAnchorType eNewAnchor = static_cast<text::TextContentAnchorType>(SWUnoHelper::GetEnumAsInt32( aValue ));
+
+ //if old anchor was in_cntnt the related text attribute has to be removed
+ const SwFormatAnchor& rOldAnchor = pFormat->GetAnchor();
+ RndStdIds eOldAnchorId = rOldAnchor.GetAnchorId();
+ SdrObject* pObj = pFormat->FindSdrObject();
+ SwFrameFormat *pFlyFormat = FindFrameFormat( pObj );
+ pFlyFormat->DelFrames();
+ if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor &&
+ (RndStdIds::FLY_AS_CHAR == eOldAnchorId))
{
- //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();
+ const SwPosition *pPos = rOldAnchor.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(
+ 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,
+ SAL_WARN_IF( pHint->GetFlyCnt().GetFrameFormat() != pFlyFormat,
"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);
+ pTextNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx);
}
- }
- else if (pEntry->nWID == FN_TEXT_BOX)
- {
- bool bValue(false);
- aValue >>= bValue;
- if (bValue)
- SwTextBoxHelper::create(pFormat);
- else
- SwTextBoxHelper::destroy(pFormat);
-
- }
- else if (pEntry->nWID == RES_CHAIN)
- {
- if (pEntry->nMemberId == MID_CHAIN_NEXTNAME || pEntry->nMemberId == MID_CHAIN_PREVNAME)
- SwTextBoxHelper::syncProperty(pFormat, pEntry->nWID, pEntry->nMemberId, aValue);
- }
- // #i28749#
- else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
- {
- sal_Int16 nPositionLayoutDir = 0;
- aValue >>= nPositionLayoutDir;
- pFormat->SetPositionLayoutDir( nPositionLayoutDir );
- }
- else if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout())
- {
- UnoActionContext aCtx(pDoc);
- if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
- {
- SdrObject* pObj = pFormat->FindSdrObject();
- SdrMarkList aList;
- SdrMark aMark(pObj);
- aList.InsertEntry(aMark);
- sal_Int32 nAnchor = 0;
- cppu::enum2int( nAnchor, aValue );
- pDoc->ChgAnchor( aList, static_cast<RndStdIds>(nAnchor),
- false, true );
- }
- else
- {
- m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
- pFormat->SetFormatAttr(aSet);
- }
- }
- else if( RES_FRM_SIZE == pEntry->nWID &&
- ( pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH
- || pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT_RELATION
- || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION ) )
- {
- SvxShape* pSvxShape = GetSvxShape();
- SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
- if(pSvxShape)
+ else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
+ (RndStdIds::FLY_AT_PAGE == eOldAnchorId))
{
- SdrObject* pObj = pSvxShape->GetSdrObject();
- sal_Int16 nPercent(100);
- aValue >>= nPercent;
- switch (pEntry->nMemberId)
+ SwFormatAnchor aNewAnchor( dynamic_cast< const SwFormatAnchor& >( aSet.Get( RES_ANCHOR ) ) );
+ //if the fly has been anchored at page then it needs to be connected
+ //to the content position
+ SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
+ if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout() )
{
- case MID_FRMSIZE_REL_WIDTH:
- pObj->SetRelativeWidth( nPercent / 100.0 );
- break;
- case MID_FRMSIZE_REL_HEIGHT:
- pObj->SetRelativeHeight( nPercent / 100.0 );
- break;
- case MID_FRMSIZE_REL_WIDTH_RELATION:
- pObj->SetRelativeWidthRelation(nPercent);
- break;
- case MID_FRMSIZE_REL_HEIGHT_RELATION:
- pObj->SetRelativeHeightRelation(nPercent);
- break;
+ SwCursorMoveState aState( CursorMoveState::SetOnlyText );
+ Point aTmp( pObj->GetSnapRect().TopLeft() );
+ pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aTmp, &aState );
}
- }
- }
- else
- {
- m_pPropSet->setPropertyValue( *pEntry, aValue, aSet );
-
- if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
- {
- bool bSetAttr = true;
- text::TextContentAnchorType eNewAnchor = static_cast<text::TextContentAnchorType>(SWUnoHelper::GetEnumAsInt32( aValue ));
-
- //if old anchor was in_cntnt the related text attribute has to be removed
- const SwFormatAnchor& rOldAnchor = pFormat->GetAnchor();
- RndStdIds eOldAnchorId = rOldAnchor.GetAnchorId();
- SdrObject* pObj = pFormat->FindSdrObject();
- SwFrameFormat *pFlyFormat = FindFrameFormat( pObj );
- pFlyFormat->DelFrames();
- if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor &&
- (RndStdIds::FLY_AS_CHAR == eOldAnchorId))
+ else
{
- //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 = rOldAnchor.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() != pFlyFormat,
- "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);
+ //without access to the layout the last node of the body will be used as anchor position
+ aPam.Move( fnMoveBackward, GoInDoc );
}
- else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
- (RndStdIds::FLY_AT_PAGE == eOldAnchorId))
+ //anchor position has to be inserted after the text attribute has been inserted
+ aNewAnchor.SetAnchor( aPam.GetPoint() );
+ aSet.Put( aNewAnchor );
+ pFormat->SetFormatAttr(aSet);
+ bSetAttr = false;
+ }
+ if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
+ (RndStdIds::FLY_AS_CHAR != eOldAnchorId))
+ {
+ SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
+ if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout() )
{
- SwFormatAnchor aNewAnchor( dynamic_cast< const SwFormatAnchor& >( aSet.Get( RES_ANCHOR ) ) );
- //if the fly has been anchored at page then it needs to be connected
- //to the content position
- SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
- if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout() )
- {
- SwCursorMoveState aState( CursorMoveState::SetOnlyText );
- Point aTmp( pObj->GetSnapRect().TopLeft() );
- pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aTmp, &aState );
- }
- else
- {
- //without access to the layout the last node of the body will be used as anchor position
- aPam.Move( fnMoveBackward, GoInDoc );
- }
- //anchor position has to be inserted after the text attribute has been inserted
- aNewAnchor.SetAnchor( aPam.GetPoint() );
- aSet.Put( aNewAnchor );
- pFormat->SetFormatAttr(aSet);
- bSetAttr = false;
+ SwCursorMoveState aState( CursorMoveState::SetOnlyText );
+ Point aTmp( pObj->GetSnapRect().TopLeft() );
+ pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aTmp, &aState );
}
- if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
- (RndStdIds::FLY_AS_CHAR != eOldAnchorId))
+ else
{
- SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
- if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout() )
- {
- SwCursorMoveState aState( CursorMoveState::SetOnlyText );
- Point aTmp( pObj->GetSnapRect().TopLeft() );
- pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aTmp, &aState );
- }
- else
- {
- //without access to the layout the last node of the body will be used as anchor position
- aPam.Move( fnMoveBackward, GoInDoc );
- }
- //the RES_TXTATR_FLYCNT needs to be added now
- SwTextNode *pNd = aPam.GetNode().GetTextNode();
- SAL_WARN_IF( !pNd, "sw.uno", "Cursor is not in a TextNode." );
- SwFormatFlyCnt aFormat( pFlyFormat );
- pNd->InsertItem(aFormat,
- aPam.GetPoint()->nContent.GetIndex(), 0 );
- --aPam.GetPoint()->nContent; // InsertItem moved it
- SwFormatAnchor aNewAnchor(
- dynamic_cast<const SwFormatAnchor&>(
- aSet.Get(RES_ANCHOR)));
- aNewAnchor.SetAnchor( aPam.GetPoint() );
- aSet.Put( aNewAnchor );
+ //without access to the layout the last node of the body will be used as anchor position
+ aPam.Move( fnMoveBackward, GoInDoc );
}
- if( bSetAttr )
- pFormat->SetFormatAttr(aSet);
+ //the RES_TXTATR_FLYCNT needs to be added now
+ SwTextNode *pNd = aPam.GetNode().GetTextNode();
+ SAL_WARN_IF( !pNd, "sw.uno", "Cursor is not in a TextNode." );
+ SwFormatFlyCnt aFormat( pFlyFormat );
+ pNd->InsertItem(aFormat,
+ aPam.GetPoint()->nContent.GetIndex(), 0 );
+ --aPam.GetPoint()->nContent; // InsertItem moved it
+ SwFormatAnchor aNewAnchor(
+ dynamic_cast<const SwFormatAnchor&>(
+ aSet.Get(RES_ANCHOR)));
+ aNewAnchor.SetAnchor( aPam.GetPoint() );
+ aSet.Put( aNewAnchor );
}
- else
+ if( bSetAttr )
pFormat->SetFormatAttr(aSet);
}
- // We have a pFormat and a pEntry as well: try to sync TextBox property.
- SwTextBoxHelper::syncProperty(pFormat, pEntry->nWID, pEntry->nMemberId, aValue);
+ else
+ pFormat->SetFormatAttr(aSet);
}
- else
+ // We have a pFormat and a pEntry as well: try to sync TextBox property.
+ SwTextBoxHelper::syncProperty(pFormat, pEntry->nWID, pEntry->nMemberId, aValue);
+ }
+ else
+ {
+ SfxPoolItem* pItem = nullptr;
+ switch(pEntry->nWID)
{
- SfxPoolItem* pItem = nullptr;
- switch(pEntry->nWID)
- {
- case RES_ANCHOR:
- pItem = pImpl->GetAnchor(true);
- break;
- case RES_HORI_ORIENT:
- pItem = pImpl->GetHOrient(true);
- break;
- case RES_VERT_ORIENT:
- pItem = pImpl->GetVOrient(true);
- break;
- case RES_LR_SPACE:
- pItem = pImpl->GetLRSpace(true);
- break;
- case RES_UL_SPACE:
- pItem = pImpl->GetULSpace(true);
- break;
- case RES_SURROUND:
- pItem = pImpl->GetSurround(true);
- break;
- case FN_TEXT_RANGE:
- if(auto tr = o3tl::tryAccess<
- uno::Reference<text::XTextRange>>(aValue))
- {
- uno::Reference< text::XTextRange > & rRange = pImpl->GetTextRange();
- rRange = *tr;
- }
- break;
- case RES_OPAQUE :
- pImpl->SetOpaque(*o3tl::doAccess<bool>(aValue));
- break;
- // #i26791#
- case RES_FOLLOW_TEXT_FLOW:
- {
- pItem = pImpl->GetFollowTextFlow( true );
- }
- break;
- // #i28701#
- case RES_WRAP_INFLUENCE_ON_OBJPOS:
- {
- pItem = pImpl->GetWrapInfluenceOnObjPos( true );
- }
- break;
- // #i28749#
- case FN_SHAPE_POSITION_LAYOUT_DIR :
+ case RES_ANCHOR:
+ pItem = pImpl->GetAnchor(true);
+ break;
+ case RES_HORI_ORIENT:
+ pItem = pImpl->GetHOrient(true);
+ break;
+ case RES_VERT_ORIENT:
+ pItem = pImpl->GetVOrient(true);
+ break;
+ case RES_LR_SPACE:
+ pItem = pImpl->GetLRSpace(true);
+ break;
+ case RES_UL_SPACE:
+ pItem = pImpl->GetULSpace(true);
+ break;
+ case RES_SURROUND:
+ pItem = pImpl->GetSurround(true);
+ break;
+ case FN_TEXT_RANGE:
+ if(auto tr = o3tl::tryAccess<
+ uno::Reference<text::XTextRange>>(aValue))
{
- sal_Int16 nPositionLayoutDir = 0;
- aValue >>= nPositionLayoutDir;
- pImpl->SetPositionLayoutDir( nPositionLayoutDir );
+ uno::Reference< text::XTextRange > & rRange = pImpl->GetTextRange();
+ rRange = *tr;
}
- break;
+ break;
+ case RES_OPAQUE :
+ pImpl->SetOpaque(*o3tl::doAccess<bool>(aValue));
+ break;
+ // #i26791#
+ case RES_FOLLOW_TEXT_FLOW:
+ {
+ pItem = pImpl->GetFollowTextFlow( true );
}
- if(pItem)
- pItem->PutValue(aValue, pEntry->nMemberId);
+ break;
+ // #i28701#
+ case RES_WRAP_INFLUENCE_ON_OBJPOS:
+ {
+ pItem = pImpl->GetWrapInfluenceOnObjPos( true );
+ }
+ break;
+ // #i28749#
+ case FN_SHAPE_POSITION_LAYOUT_DIR :
+ {
+ sal_Int16 nPositionLayoutDir = 0;
+ aValue >>= nPositionLayoutDir;
+ pImpl->SetPositionLayoutDir( nPositionLayoutDir );
+ }
+ break;
}
+ if(pItem)
+ pItem->PutValue(aValue, pEntry->nMemberId);
}
- else
+ }
+ else
+ {
+ const uno::Type& rPSetType =
+ cppu::UnoType<beans::XPropertySet>::get();
+ uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
+ auto xPrSet = o3tl::tryAccess<uno::Reference<beans::XPropertySet>>(
+ aPSet);
+ if(!xPrSet)
+ throw uno::RuntimeException();
+ // #i31698# - setting the caption point of a
+ // caption object doesn't have to change the object position.
+ // Thus, keep the position, before the caption point is set and
+ // restore it afterwards.
+ awt::Point aKeepedPosition( 0, 0 );
+ if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
{
- const uno::Type& rPSetType =
- cppu::UnoType<beans::XPropertySet>::get();
- uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
- auto xPrSet = o3tl::tryAccess<uno::Reference<beans::XPropertySet>>(
- aPSet);
- if(!xPrSet)
- throw uno::RuntimeException();
- // #i31698# - setting the caption point of a
- // caption object doesn't have to change the object position.
- // Thus, keep the position, before the caption point is set and
- // restore it afterwards.
- awt::Point aKeepedPosition( 0, 0 );
- if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
- {
- aKeepedPosition = getPosition();
- }
- if( pFormat && pFormat->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() )
- {
- UnoActionContext aCtx(pFormat->GetDoc());
- (*xPrSet)->setPropertyValue(rPropertyName, aValue);
- }
- else
- (*xPrSet)->setPropertyValue(rPropertyName, aValue);
+ aKeepedPosition = getPosition();
+ }
+ if( pFormat && pFormat->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() )
+ {
+ UnoActionContext aCtx(pFormat->GetDoc());
+ (*xPrSet)->setPropertyValue(rPropertyName, aValue);
+ }
+ else
+ (*xPrSet)->setPropertyValue(rPropertyName, aValue);
- if (pFormat)
- {
- // We have a pFormat (but no pEntry): try to sync TextBox property.
- SwTextBoxHelper::syncProperty(pFormat, rPropertyName, aValue);
- }
+ if (pFormat)
+ {
+ // We have a pFormat (but no pEntry): try to sync TextBox property.
+ SwTextBoxHelper::syncProperty(pFormat, rPropertyName, aValue);
+ }
- // #i31698# - restore object position, if caption point is set.
- if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
- {
- setPosition( aKeepedPosition );
- }
+ // #i31698# - restore object position, if caption point is set.
+ if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
+ {
+ setPosition( aKeepedPosition );
}
}
}
@@ -2035,21 +2035,22 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
if(!pDoc)
throw uno::RuntimeException();
- if (const SwDocShell* pDocSh = pDoc->GetDocShell())
+ const SwDocShell* pDocSh = pDoc->GetDocShell();
+ if (!pDocSh)
+ return;
+
+ uno::Reference<frame::XModel> xModel = pDocSh->GetModel();
+ uno::Reference< drawing::XDrawPageSupplier > xDPS(xModel, uno::UNO_QUERY);
+ if (xDPS.is())
{
- uno::Reference<frame::XModel> xModel = pDocSh->GetModel();
- uno::Reference< drawing::XDrawPageSupplier > xDPS(xModel, uno::UNO_QUERY);
- if (xDPS.is())
+ uno::Reference< drawing::XDrawPage > xDP( xDPS->getDrawPage() );
+ if (xDP.is())
{
- uno::Reference< drawing::XDrawPage > xDP( xDPS->getDrawPage() );
- if (xDP.is())
- {
- uno::Any aPos;
- aPos <<= xTextRange;
- setPropertyValue("TextRange", aPos);
- uno::Reference< drawing::XShape > xTemp( static_cast<cppu::OWeakObject*>(this), uno::UNO_QUERY );
- xDP->add( xTemp );
- }
+ uno::Any aPos;
+ aPos <<= xTextRange;
+ setPropertyValue("TextRange", aPos);
+ uno::Reference< drawing::XShape > xTemp( static_cast<cppu::OWeakObject*>(this), uno::UNO_QUERY );
+ xDP->add( xTemp );
}
}
}
@@ -2727,37 +2728,37 @@ void SwXGroupShape::add( const uno::Reference< XShape >& xShape )
if(xShape.is())
pSwShape = reinterpret_cast< SwXShape * >(
sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
- if(pSwShape && pSwShape->m_bDescriptor)
+ if(!(pSwShape && pSwShape->m_bDescriptor))
+ return;
+
+ 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)
- pSwShape->SetFrameFormat(pShapeFormat);
}
+ pSwShape->m_bDescriptor = false;
+ //add the group member to the format of the group
+ SwFrameFormat* pShapeFormat = ::FindFrameFormat( pSvxShape->GetSdrObject() );
+
+ if(pShapeFormat)
+ pSwShape->SetFrameFormat(pShapeFormat);
}
diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx
index 15ffb4441aa7..ea3ae869c62d 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -176,21 +176,21 @@ void SAL_CALL SwXFlatParagraph::setChecked( ::sal_Int32 nType, sal_Bool bVal )
{
SolarMutexGuard aGuard;
- if (GetTextNode())
+ if (!GetTextNode())
+ return;
+
+ if ( text::TextMarkupType::SPELLCHECK == nType )
{
- if ( text::TextMarkupType::SPELLCHECK == nType )
- {
- GetTextNode()->SetWrongDirty(
- bVal ? SwTextNode::WrongState::DONE : SwTextNode::WrongState::TODO);
- }
- else if ( text::TextMarkupType::SMARTTAG == nType )
- GetTextNode()->SetSmartTagDirty( !bVal );
- else if( text::TextMarkupType::PROOFREADING == nType )
- {
- GetTextNode()->SetGrammarCheckDirty( !bVal );
- if( bVal )
- ::finishGrammarCheck( *GetTextNode() );
- }
+ GetTextNode()->SetWrongDirty(
+ bVal ? SwTextNode::WrongState::DONE : SwTextNode::WrongState::TODO);
+ }
+ else if ( text::TextMarkupType::SMARTTAG == nType )
+ GetTextNode()->SetSmartTagDirty( !bVal );
+ else if( text::TextMarkupType::PROOFREADING == nType )
+ {
+ GetTextNode()->SetGrammarCheckDirty( !bVal );
+ if( bVal )
+ ::finishGrammarCheck( *GetTextNode() );
}
}
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index c277d1179789..1c1e23094474 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -2600,28 +2600,28 @@ void SwXFrame::dispose()
{
SolarMutexGuard aGuard;
SwFrameFormat* pFormat = GetFrameFormat();
- if (pFormat)
+ if (!pFormat)
+ return;
+
+ DisposeInternal();
+ SdrObject* pObj = pFormat->FindSdrObject();
+ // OD 11.09.2003 #112039# - add condition to perform delete of
+ // format/anchor sign, not only if the object is inserted, but also
+ // if a contact object is registered, which isn't in the destruction.
+ if ( pObj &&
+ ( pObj->IsInserted() ||
+ ( pObj->GetUserCall() &&
+ !static_cast<SwContact*>(pObj->GetUserCall())->IsInDTOR() ) ) )
{
- DisposeInternal();
- SdrObject* pObj = pFormat->FindSdrObject();
- // OD 11.09.2003 #112039# - add condition to perform delete of
- // format/anchor sign, not only if the object is inserted, but also
- // if a contact object is registered, which isn't in the destruction.
- if ( pObj &&
- ( pObj->IsInserted() ||
- ( pObj->GetUserCall() &&
- !static_cast<SwContact*>(pObj->GetUserCall())->IsInDTOR() ) ) )
- {
- if (pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR)
- {
- const SwPosition &rPos = *(pFormat->GetAnchor().GetContentAnchor());
- SwTextNode *pTextNode = rPos.nNode.GetNode().GetTextNode();
- const sal_Int32 nIdx = rPos.nContent.GetIndex();
- pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
- }
- else
- pFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat(pFormat);
+ if (pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+ {
+ const SwPosition &rPos = *(pFormat->GetAnchor().GetContentAnchor());
+ SwTextNode *pTextNode = rPos.nNode.GetNode().GetTextNode();
+ const sal_Int32 nIdx = rPos.nContent.GetIndex();
+ pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx );
}
+ else
+ pFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat(pFormat);
}
}
@@ -3081,28 +3081,28 @@ void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange)
}
SwFrameFormat* pFormat = GetFrameFormat();
- if( pFormat )
- {
- SwDoc* pDoc = pFormat->GetDoc();
- SwUnoInternalPaM aIntPam(*pDoc);
- if (!::sw::XTextRangeToSwPaM(aIntPam, xTextRange))
- throw lang::IllegalArgumentException();
+ if( !pFormat )
+ return;
- SfxItemSet aSet( pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{} );
- aSet.SetParent(&pFormat->GetAttrSet());
- SwFormatAnchor aAnchor = aSet.Get(RES_ANCHOR);
+ SwDoc* pDoc = pFormat->GetDoc();
+ SwUnoInternalPaM aIntPam(*pDoc);
+ if (!::sw::XTextRangeToSwPaM(aIntPam, xTextRange))
+ throw lang::IllegalArgumentException();
- if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR)
- {
- throw lang::IllegalArgumentException(
- "SwXFrame::attach(): re-anchoring AS_CHAR not supported",
- *this, 0);
- }
+ SfxItemSet aSet( pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{} );
+ aSet.SetParent(&pFormat->GetAttrSet());
+ SwFormatAnchor aAnchor = aSet.Get(RES_ANCHOR);
- aAnchor.SetAnchor( aIntPam.Start() );
- aSet.Put(aAnchor);
- pDoc->SetFlyFrameAttr( *pFormat, aSet );
+ if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR)
+ {
+ throw lang::IllegalArgumentException(
+ "SwXFrame::attach(): re-anchoring AS_CHAR not supported",
+ *this, 0);
}
+
+ aAnchor.SetAnchor( aIntPam.Start() );
+ aSet.Put(aAnchor);
+ pDoc->SetFlyFrameAttr( *pFormat, aSet );
}
awt::Point SwXFrame::getPosition()
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index aa3fd65fc2f4..5ef447324dae 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -179,25 +179,25 @@ static void
lcl_setCharStyle(SwDoc *const pDoc, const uno::Any & rValue, SfxItemSet & rSet)
{
SwDocShell *const pDocSh = pDoc->GetDocShell();
- if(pDocSh)
+ if(!pDocSh)
+ return;
+
+ OUString uStyle;
+ if (!(rValue >>= uStyle))
{
- OUString uStyle;
- if (!(rValue >>= uStyle))
- {
- throw lang::IllegalArgumentException();
- }
- OUString sStyle;
- SwStyleNameMapper::FillUIName(uStyle, sStyle,
- SwGetPoolIdFromName::ChrFmt);
- SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
- pDocSh->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char));
- if (!pStyle)
- {
- throw lang::IllegalArgumentException();
- }
- const SwFormatCharFormat aFormat(pStyle->GetCharFormat());
- rSet.Put(aFormat);
+ throw lang::IllegalArgumentException();
+ }
+ OUString sStyle;
+ SwStyleNameMapper::FillUIName(uStyle, sStyle,
+ SwGetPoolIdFromName::ChrFmt);
+ SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
+ pDocSh->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char));
+ if (!pStyle)
+ {
+ throw lang::IllegalArgumentException();
}
+ const SwFormatCharFormat aFormat(pStyle->GetCharFormat());
+ rSet.Put(aFormat);
};
/// @throws lang::IllegalArgumentException
@@ -719,34 +719,34 @@ void SwXTextCursor::DeleteAndInsert(const OUString& rText,
const bool bForceExpandHints)
{
auto pUnoCursor = static_cast<SwCursor*>(m_pImpl->m_pUnoCursor.get());
- if (pUnoCursor)
+ if (!pUnoCursor)
+ return;
+
+ // Start/EndAction
+ SwDoc* pDoc = pUnoCursor->GetDoc();
+ UnoActionContext aAction(pDoc);
+ const sal_Int32 nTextLen = rText.getLength();
+ pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
+ auto pCurrent = pUnoCursor;
+ do
{
- // Start/EndAction
- SwDoc* pDoc = pUnoCursor->GetDoc();
- UnoActionContext aAction(pDoc);
- const sal_Int32 nTextLen = rText.getLength();
- pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
- auto pCurrent = pUnoCursor;
- do
+ if (pCurrent->HasMark())
{
- if (pCurrent->HasMark())
- {
- pDoc->getIDocumentContentOperations().DeleteAndJoin(*pCurrent);
- }
- if(nTextLen)
- {
- const bool bSuccess(
- SwUnoCursorHelper::DocInsertStringSplitCR(
- *pDoc, *pCurrent, rText, bForceExpandHints ) );
- OSL_ENSURE( bSuccess, "Doc->Insert(Str) failed." );
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(*pCurrent);
+ }
+ if(nTextLen)
+ {
+ const bool bSuccess(
+ SwUnoCursorHelper::DocInsertStringSplitCR(
+ *pDoc, *pCurrent, rText, bForceExpandHints ) );
+ OSL_ENSURE( bSuccess, "Doc->Insert(Str) failed." );
- SwUnoCursorHelper::SelectPam(*pUnoCursor, true);
- pCurrent->Left(rText.getLength());
- }
- pCurrent = pCurrent->GetNext();
- } while (pCurrent != pUnoCursor);
- pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
- }
+ SwUnoCursorHelper::SelectPam(*pUnoCursor, true);
+ pCurrent->Left(rText.getLength());
+ }
+ pCurrent = pCurrent->GetNext();
+ } while (pCurrent != pUnoCursor);
+ pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
}
namespace {
@@ -2344,59 +2344,59 @@ SwXTextCursor::setPropertiesToDefault(
SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
- if ( rPropertyNames.hasElements() )
+ if ( !rPropertyNames.hasElements() )
+ return;
+
+ SwDoc & rDoc = *rUnoCursor.GetDoc();
+ std::set<sal_uInt16> aWhichIds;
+ std::set<sal_uInt16> aParaWhichIds;
+ for (const OUString& rName : rPropertyNames)
{
- SwDoc & rDoc = *rUnoCursor.GetDoc();
- std::set<sal_uInt16> aWhichIds;
- std::set<sal_uInt16> aParaWhichIds;
- for (const OUString& rName : rPropertyNames)
+ SfxItemPropertySimpleEntry const*const pEntry =
+ m_pImpl->m_rPropSet.getPropertyMap().getByName( rName );
+ if (!pEntry)
{
- SfxItemPropertySimpleEntry const*const pEntry =
- m_pImpl->m_rPropSet.getPropertyMap().getByName( rName );
- if (!pEntry)
- {
- if (rName == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
- rName == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
- {
- continue;
- }
- throw beans::UnknownPropertyException(
- "Unknown property: " + rName,
- static_cast<cppu::OWeakObject *>(this));
- }
- if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
+ if (rName == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
+ rName == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
{
- throw uno::RuntimeException(
- "setPropertiesToDefault: property is read-only: " + rName,
- static_cast<cppu::OWeakObject *>(this));
+ continue;
}
+ throw beans::UnknownPropertyException(
+ "Unknown property: " + rName,
+ static_cast<cppu::OWeakObject *>(this));
+ }
+ if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
+ {
+ throw uno::RuntimeException(
+ "setPropertiesToDefault: property is read-only: " + rName,
+ static_cast<cppu::OWeakObject *>(this));
+ }
- if (pEntry->nWID < RES_FRMATR_END)
+ if (pEntry->nWID < RES_FRMATR_END)
+ {
+ if (pEntry->nWID < RES_PARATR_BEGIN)
{
- if (pEntry->nWID < RES_PARATR_BEGIN)
- {
- aWhichIds.insert( pEntry->nWID );
- }
- else
- {
- aParaWhichIds.insert( pEntry->nWID );
- }
+ aWhichIds.insert( pEntry->nWID );
}
- else if (pEntry->nWID == FN_UNO_NUM_START_VALUE)
+ else
{
- SwUnoCursorHelper::resetCursorPropertyValue(*pEntry, rUnoCursor);
+ aParaWhichIds.insert( pEntry->nWID );
}
}
-
- if (!aParaWhichIds.empty())
+ else if (pEntry->nWID == FN_UNO_NUM_START_VALUE)
{
- lcl_SelectParaAndReset(rUnoCursor, rDoc, aParaWhichIds);
- }
- if (!aWhichIds.empty())
- {
- rDoc.ResetAttrs(rUnoCursor, true, aWhichIds);
+ SwUnoCursorHelper::resetCursorPropertyValue(*pEntry, rUnoCursor);
}
}
+
+ if (!aParaWhichIds.empty())
+ {
+ lcl_SelectParaAndReset(rUnoCursor, rDoc, aParaWhichIds);
+ }
+ if (!aWhichIds.empty())
+ {
+ rDoc.ResetAttrs(rUnoCursor, true, aWhichIds);
+ }
}
uno::Sequence< uno::Any > SAL_CALL
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 9f0dc5d8eb9e..4f280beb94cc 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -80,19 +80,19 @@ void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget)
{
rTarget = rSource;
- if (rSource.GetNext() != &rSource)
+ if (rSource.GetNext() == &rSource)
+ return;
+
+ SwPaM *pPam = const_cast<SwPaM*>(rSource.GetNext());
+ do
{
- SwPaM *pPam = const_cast<SwPaM*>(rSource.GetNext());
- do
- {
- // create new PaM
- SwPaM *const pNew = new SwPaM(*pPam, nullptr);
- // insert into ring
- pNew->MoveTo(&rTarget);
- pPam = pPam->GetNext();
- }
- while (pPam != &rSource);
+ // create new PaM
+ SwPaM *const pNew = new SwPaM(*pPam, nullptr);
+ // insert into ring
+ pNew->MoveTo(&rTarget);
+ pPam = pPam->GetNext();
}
+ while (pPam != &rSource);
}
} // namespace sw
@@ -764,26 +764,26 @@ void SwXTextRange::DeleteAndInsert(
const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
SwCursor aCursor(aPos, nullptr);
- if (GetPositions(aCursor))
+ if (!GetPositions(aCursor))
+ return;
+
+ UnoActionContext aAction(& m_pImpl->m_rDoc);
+ m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
+ if (aCursor.HasMark())
{
- UnoActionContext aAction(& m_pImpl->m_rDoc);
- m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
- if (aCursor.HasMark())
- {
- m_pImpl->m_rDoc.getIDocumentContentOperations().DeleteAndJoin(aCursor);
- }
+ m_pImpl->m_rDoc.getIDocumentContentOperations().DeleteAndJoin(aCursor);
+ }
- if (!rText.isEmpty())
- {
- SwUnoCursorHelper::DocInsertStringSplitCR(
- m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints);
+ if (!rText.isEmpty())
+ {
+ SwUnoCursorHelper::DocInsertStringSplitCR(
+ m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints);
- SwUnoCursorHelper::SelectPam(aCursor, true);
- aCursor.Left(rText.getLength());
- }
- SetPositions(aCursor);
- m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
+ SwUnoCursorHelper::SelectPam(aCursor, true);
+ aCursor.Left(rText.getLength());
}
+ SetPositions(aCursor);
+ m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
}
namespace
@@ -1441,18 +1441,18 @@ struct SwXTextRangesImpl final : public SwXTextRanges
void SwXTextRangesImpl::MakeRanges()
{
- if (GetCursor())
+ if (!GetCursor())
+ return;
+
+ for(SwPaM& rTmpCursor : GetCursor()->GetRingContainer())
{
- for(SwPaM& rTmpCursor : GetCursor()->GetRingContainer())
+ const uno::Reference< text::XTextRange > xRange(
+ SwXTextRange::CreateXTextRange(
+ *rTmpCursor.GetDoc(),
+ *rTmpCursor.GetPoint(), rTmpCursor.GetMark()));
+ if (xRange.is())
{
- const uno::Reference< text::XTextRange > xRange(
- SwXTextRange::CreateXTextRange(
- *rTmpCursor.GetDoc(),
- *rTmpCursor.GetPoint(), rTmpCursor.GetMark()));
- if (xRange.is())
- {
- m_Ranges.push_back(xRange);
- }
+ m_Ranges.push_back(xRange);
}
}
}
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index 3fef41218cad..d62ed4ab5710 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -331,19 +331,19 @@ void
SwXParagraph::attachToText(SwXText & rParent, SwTextNode & rTextNode)
{
OSL_ENSURE(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
- if (m_pImpl->m_bIsDescriptor)
+ if (!m_pImpl->m_bIsDescriptor)
+ return;
+
+ m_pImpl->m_bIsDescriptor = false;
+ m_pImpl->EndListeningAll();
+ m_pImpl->StartListening(rTextNode.GetNotifier());
+ rTextNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
+ m_pImpl->m_xParentText = &rParent;
+ if (!m_pImpl->m_sText.isEmpty())
{
- m_pImpl->m_bIsDescriptor = false;
- m_pImpl->EndListeningAll();
- m_pImpl->StartListening(rTextNode.GetNotifier());
- rTextNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
- m_pImpl->m_xParentText = &rParent;
- if (!m_pImpl->m_sText.isEmpty())
- {
- try { setString(m_pImpl->m_sText); }
- catch(...){}
- m_pImpl->m_sText.clear();
- }
+ try { setString(m_pImpl->m_sText); }
+ catch(...){}
+ m_pImpl->m_sText.clear();
}
}
@@ -478,48 +478,48 @@ void SwXParagraph::Impl::GetSinglePropertyValue_Impl(
default: break;
}
- if(!bDone)
+ if(bDone)
+ return;
+
+ // fallback to standard get value implementation used before this helper was created
+ m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
+
+ if(rEntry.aType == cppu::UnoType<sal_Int16>::get() && rEntry.aType != rAny.getValueType())
{
- // fallback to standard get value implementation used before this helper was created
- m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
+ // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
+ sal_Int32 nValue(0);
- if(rEntry.aType == cppu::UnoType<sal_Int16>::get() && rEntry.aType != rAny.getValueType())
+ if (rAny >>= nValue)
{
- // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
- sal_Int32 nValue(0);
-
- if (rAny >>= nValue)
- {
- rAny <<= static_cast<sal_Int16>(nValue);
- }
+ rAny <<= static_cast<sal_Int16>(nValue);
}
+ }
- // check for needed metric translation
- if(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
- {
- bool bDoIt(true);
+ // check for needed metric translation
+ if(!(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM))
+ return;
- if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
- {
- // exception: If these ItemTypes are used, do not convert when these are negative
- // since this means they are intended as percent values
- sal_Int32 nValue = 0;
+ bool bDoIt(true);
- if(rAny >>= nValue)
- {
- bDoIt = nValue > 0;
- }
- }
+ if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
+ {
+ // exception: If these ItemTypes are used, do not convert when these are negative
+ // since this means they are intended as percent values
+ sal_Int32 nValue = 0;
- if(bDoIt)
- {
- const MapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID));
+ if(rAny >>= nValue)
+ {
+ bDoIt = nValue > 0;
+ }
+ }
- if(eMapUnit != MapUnit::Map100thMM)
- {
- SvxUnoConvertToMM(eMapUnit, rAny);
- }
- }
+ if(bDoIt)
+ {
+ const MapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID));
+
+ if(eMapUnit != MapUnit::Map100thMM)
+ {
+ SvxUnoConvertToMM(eMapUnit, rAny);
}
}
}
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 8b968bb82d40..17688f1a3351 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -144,28 +144,28 @@ namespace
}
const SwPosition& rEndPos = pBkmk->GetMarkEnd();
- if(rEndPos.nNode == nOwnNode)
+ if(rEndPos.nNode != nOwnNode)
+ return;
+
+ unique_ptr<SwPosition> pCrossRefEndPos;
+ const SwPosition* pEndPos = nullptr;
+ ::sw::mark::CrossRefBookmark *const pCrossRefMark(dynamic_cast< ::sw::mark::CrossRefBookmark*>(pBkmk));
+ if(hasOther)
{
- unique_ptr<SwPosition> pCrossRefEndPos;
- const SwPosition* pEndPos = nullptr;
- ::sw::mark::CrossRefBookmark *const pCrossRefMark(dynamic_cast< ::sw::mark::CrossRefBookmark*>(pBkmk));
- if(hasOther)
- {
- pEndPos = &rEndPos;
- }
- else if (pCrossRefMark)
- {
- // Crossrefbookmarks only remember the start position but have to span the whole paragraph
- pCrossRefEndPos = std::make_unique<SwPosition>(rEndPos);
- pCrossRefEndPos->nContent = pCrossRefEndPos->nNode.GetNode().GetTextNode()->Len();
- pEndPos = pCrossRefEndPos.get();
- }
- if(pEndPos)
- {
- rBkmArr.insert(std::make_shared<SwXBookmarkPortion_Impl>(
- SwXBookmark::CreateXBookmark(rDoc, pBkmk),
- BkmType::End, *pEndPos));
- }
+ pEndPos = &rEndPos;
+ }
+ else if (pCrossRefMark)
+ {
+ // Crossrefbookmarks only remember the start position but have to span the whole paragraph
+ pCrossRefEndPos = std::make_unique<SwPosition>(rEndPos);
+ pCrossRefEndPos->nContent = pCrossRefEndPos->nNode.GetNode().GetTextNode()->Len();
+ pEndPos = pCrossRefEndPos.get();
+ }
+ if(pEndPos)
+ {
+ rBkmArr.insert(std::make_shared<SwXBookmarkPortion_Impl>(
+ SwXBookmark::CreateXBookmark(rDoc, pBkmk),
+ BkmType::End, *pEndPos));
}
}
@@ -1080,24 +1080,24 @@ static void lcl_FillRedlineArray(
const SwRedlineTable& rRedTable = rDoc.getIDocumentRedlineAccess().GetRedlineTable();
const size_t nRedTableCount = rRedTable.size();
- if ( nRedTableCount > 0 )
- {
- const SwPosition* pStart = rUnoCursor.GetPoint();
- const SwNodeIndex nOwnNode = pStart->nNode;
+ if ( nRedTableCount <= 0 )
+ return;
- for(size_t nRed = 0; nRed < nRedTableCount; ++nRed)
- {
- const SwRangeRedline* pRedline = rRedTable[nRed];
- const SwPosition* pRedStart = pRedline->Start();
- const SwNodeIndex nRedNode = pRedStart->nNode;
- if ( nOwnNode == nRedNode )
- rRedArr.insert( std::make_shared<SwXRedlinePortion_Impl>(
- pRedline, true ) );
- if( pRedline->HasMark() && pRedline->End()->nNode == nOwnNode )
- rRedArr.insert( std::make_shared<SwXRedlinePortion_Impl>(
- pRedline, false ) );
- }
- }
+ const SwPosition* pStart = rUnoCursor.GetPoint();
+ const SwNodeIndex nOwnNode = pStart->nNode;
+
+ for(size_t nRed = 0; nRed < nRedTableCount; ++nRed)
+ {
+ const SwRangeRedline* pRedline = rRedTable[nRed];
+ const SwPosition* pRedStart = pRedline->Start();
+ const SwNodeIndex nRedNode = pRedStart->nNode;
+ if ( nOwnNode == nRedNode )
+ rRedArr.insert( std::make_shared<SwXRedlinePortion_Impl>(
+ pRedline, true ) );
+ if( pRedline->HasMark() && pRedline->End()->nNode == nOwnNode )
+ rRedArr.insert( std::make_shared<SwXRedlinePortion_Impl>(
+ pRedline, false ) );
+ }
}
static void lcl_FillSoftPageBreakArray(
diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx
index a69fd2cab70c..581e8c7656c1 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -656,19 +656,19 @@ inline const ::sw::Meta* SwXMeta::Impl::GetMeta() const
void SwXMeta::Impl::Notify(const SfxHint& rHint)
{
m_pTextPortions.reset(); // throw away cache (SwTextNode changed)
- if(rHint.GetId() == SfxHintId::Dying || rHint.GetId() == SfxHintId::Deinitializing)
- {
- m_bIsDisposed = true;
- m_pMeta = nullptr;
- m_xText->Invalidate();
- uno::Reference<uno::XInterface> const xThis(m_wThis);
- if (!xThis.is())
- { // fdo#72695: if UNO object is already dead, don't revive it with event
- return;
- }
- lang::EventObject const ev(xThis);
- m_EventListeners.disposeAndClear(ev);
+ if(rHint.GetId() != SfxHintId::Dying && rHint.GetId() != SfxHintId::Deinitializing)
+ return;
+
+ m_bIsDisposed = true;
+ m_pMeta = nullptr;
+ m_xText->Invalidate();
+ uno::Reference<uno::XInterface> const xThis(m_wThis);
+ if (!xThis.is())
+ { // fdo#72695: if UNO object is already dead, don't revive it with event
+ return;
}
+ lang::EventObject const ev(xThis);
+ m_EventListeners.disposeAndClear(ev);
}
uno::Reference<text::XText> const & SwXMeta::GetParentText() const
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index 831f0bda3e7c..3c0eb298b079 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -523,32 +523,32 @@ lcl_UpdateSection(SwSectionFormat *const pFormat,
std::unique_ptr<SfxItemSet> const& pItemSet,
bool const bLinkModeChanged, bool const bLinkUpdateAlways = true)
{
- if (pFormat)
+ if (!pFormat)
+ return;
+
+ SwSection & rSection = *pFormat->GetSection();
+ SwDoc *const pDoc = pFormat->GetDoc();
+ SwSectionFormats const& rFormats = pDoc->GetSections();
+ UnoActionContext aContext(pDoc);
+ for (size_t i = 0; i < rFormats.size(); ++i)
{
- SwSection & rSection = *pFormat->GetSection();
- SwDoc *const pDoc = pFormat->GetDoc();
- SwSectionFormats const& rFormats = pDoc->GetSections();
- UnoActionContext aContext(pDoc);
- for (size_t i = 0; i < rFormats.size(); ++i)
+ if (rFormats[i]->GetSection()->GetSectionName()
+ == rSection.GetSectionName())
{
- if (rFormats[i]->GetSection()->GetSectionName()
- == rSection.GetSectionName())
+ pDoc->UpdateSection(i, *pSectionData, pItemSet.get(),
+ pDoc->IsInReading());
{
- pDoc->UpdateSection(i, *pSectionData, pItemSet.get(),
- pDoc->IsInReading());
- {
- // temporarily remove actions to allow cursor update
- // TODO: why? no table cursor here!
- UnoActionRemoveContext aRemoveContext( pDoc );
- }
+ // temporarily remove actions to allow cursor update
+ // TODO: why? no table cursor here!
+ UnoActionRemoveContext aRemoveContext( pDoc );
+ }
- if (bLinkModeChanged)
- {
- lcl_UpdateLinkType(rSection, bLinkUpdateAlways);
- }
- // section found and processed: break from loop
- break;
+ if (bLinkModeChanged)
+ {
+ lcl_UpdateLinkType(rSection, bLinkUpdateAlways);
}
+ // section found and processed: break from loop
+ break;
}
}
}
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index b392c42f1b88..0fbf86e1e17d 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -583,76 +583,75 @@ uno::Reference< beans::XPropertySetInfo > SwXEndnoteProperties::getPropertySetI
void SwXEndnoteProperties::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
{
SolarMutexGuard aGuard;
- if(m_pDoc)
- {
- const SfxItemPropertySimpleEntry* pEntry = m_pPropertySet->getPropertyMap().getByName( rPropertyName );
- if(!pEntry)
- throw UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
+ if(!m_pDoc)
+ return;
- if ( pEntry->nFlags & PropertyAttribute::READONLY)
- throw PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
- SwEndNoteInfo aEndInfo(m_pDoc->GetEndNoteInfo());
- switch(pEntry->nWID)
+ 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 ) );
+ SwEndNoteInfo aEndInfo(m_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.m_aFormat.SetNumberingType(static_cast<SvxNumType>(nTmp));
- }
- break;
- case WID_START_AT:
- {
- sal_Int16 nTmp = 0;
- aValue >>= nTmp;
- aEndInfo.m_nFootnoteOffset = nTmp;
- }
- break;
- case WID_PARAGRAPH_STYLE :
- {
- SwTextFormatColl* pColl = lcl_GetParaStyle(m_pDoc, aValue);
- if(pColl)
- aEndInfo.SetFootnoteTextColl(*pColl);
- }
- break;
- case WID_PAGE_STYLE :
- {
- SwPageDesc* pDesc = lcl_GetPageDesc(m_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.m_aFormat.SetNumberingType(static_cast<SvxNumType>(nTmp));
+ }
+ break;
+ case WID_START_AT:
+ {
+ sal_Int16 nTmp = 0;
+ aValue >>= nTmp;
+ aEndInfo.m_nFootnoteOffset = nTmp;
+ }
+ break;
+ case WID_PARAGRAPH_STYLE :
+ {
+ SwTextFormatColl* pColl = lcl_GetParaStyle(m_pDoc, aValue);
+ if(pColl)
+ aEndInfo.SetFootnoteTextColl(*pColl);
+ }
+ break;
+ case WID_PAGE_STYLE :
+ {
+ SwPageDesc* pDesc = lcl_GetPageDesc(m_pDoc, aValue);
+ if(pDesc)
+ aEndInfo.ChgPageDesc( pDesc );
+ }
+ break;
+ case WID_ANCHOR_CHARACTER_STYLE:
+ case WID_CHARACTER_STYLE :
+ {
+ SwCharFormat* pFormat = lcl_getCharFormat(m_pDoc, aValue);
+ if(pFormat)
{
- SwCharFormat* pFormat = lcl_getCharFormat(m_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;
}
- m_pDoc->SetEndNoteInfo(aEndInfo);
-
+ break;
}
+ m_pDoc->SetEndNoteInfo(aEndInfo);
}
uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName)
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index f3feb9973d8a..e5ce047fa6e1 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -580,12 +580,13 @@ void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL,
else if(rProperty.Name == "InputStream")
{
Reference<XInputStream> xInputStream;
- if (rProperty.Value >>= xInputStream)
- aOpt.SetInputStream(xInputStream);
- else
+ if (!(rProperty.Value >>= xInputStream))
throw IllegalArgumentException("Parameter 'InputStream' could not be converted to "
"type 'com::sun::star::io::XInputStream'",
nullptr, 0);
+
+ aOpt.SetInputStream(xInputStream);
+
}
}
const ErrCode nErr = m_pDocShell->LoadStylesFromFile( rURL, aOpt, true );
@@ -5375,198 +5376,198 @@ void SAL_CALL SwXTextCellStyle::setPropertyToDefault(const OUString& rPropertyNa
const SwBoxAutoFormat& rDefaultBoxFormat = SwTableAutoFormat::GetDefaultBoxFormat();
const SfxItemPropertyMap& rMap = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CELL_STYLE)->getPropertyMap();
const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropertyName);
- if(pEntry)
+ if(!pEntry)
+ return;
+
+ uno::Any aAny;
+ switch(pEntry->nWID)
{
- uno::Any aAny;
- switch(pEntry->nWID)
+ case RES_BACKGROUND:
{
- case RES_BACKGROUND:
- {
- SvxBrushItem rBrush = m_pBoxAutoFormat->GetBackground();
- rDefaultBoxFormat.GetBackground().QueryValue(aAny, pEntry->nMemberId);
- rBrush.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetBackground(rBrush);
- break;
- }
- case RES_BOX:
- {
- SvxBoxItem rBox = m_pBoxAutoFormat->GetBox();
- rDefaultBoxFormat.GetBox().QueryValue(aAny, pEntry->nMemberId);
- rBox.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetBox(rBox);
- break;
- }
- case RES_VERT_ORIENT:
- {
- SwFormatVertOrient rVertOrient = m_pBoxAutoFormat->GetVerticalAlignment();
- rDefaultBoxFormat.GetVerticalAlignment().QueryValue(aAny, pEntry->nMemberId);
- rVertOrient.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetVerticalAlignment(rVertOrient);
- break;
- }
- case RES_FRAMEDIR:
- {
- SvxFrameDirectionItem rFrameDirectionItem = m_pBoxAutoFormat->GetTextOrientation();
- rDefaultBoxFormat.GetTextOrientation().QueryValue(aAny, pEntry->nMemberId);
- rFrameDirectionItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetTextOrientation(rFrameDirectionItem);
- break;
- }
- case RES_BOXATR_FORMAT:
- {
- OUString sFormat;
- LanguageType eLng, eSys;
- rDefaultBoxFormat.GetValueFormat(sFormat, eLng, eSys);
- m_pBoxAutoFormat->SetValueFormat(sFormat, eLng, eSys);
- break;
- }
- case RES_PARATR_ADJUST:
- {
- SvxAdjustItem rAdjustItem = m_pBoxAutoFormat->GetAdjust();
- rDefaultBoxFormat.GetAdjust().QueryValue(aAny, pEntry->nMemberId);
- rAdjustItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetAdjust(rAdjustItem);
- break;
- }
- case RES_CHRATR_COLOR:
- {
- SvxColorItem rColorItem = m_pBoxAutoFormat->GetColor();
- rDefaultBoxFormat.GetColor().QueryValue(aAny, pEntry->nMemberId);
- rColorItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetColor(rColorItem);
- break;
- }
- case RES_CHRATR_SHADOWED:
- {
- SvxShadowedItem rShadowedItem = m_pBoxAutoFormat->GetShadowed();
- rDefaultBoxFormat.GetShadowed().QueryValue(aAny, pEntry->nMemberId);
- rShadowedItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetShadowed(rShadowedItem);
- break;
- }
- case RES_CHRATR_CONTOUR:
- {
- SvxContourItem rContourItem = m_pBoxAutoFormat->GetContour();
- rDefaultBoxFormat.GetContour().QueryValue(aAny, pEntry->nMemberId);
- rContourItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetContour(rContourItem);
- break;
- }
- case RES_CHRATR_CROSSEDOUT:
- {
- SvxCrossedOutItem rCrossedOutItem = m_pBoxAutoFormat->GetCrossedOut();
- rDefaultBoxFormat.GetCrossedOut().QueryValue(aAny, pEntry->nMemberId);
- rCrossedOutItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCrossedOut(rCrossedOutItem);
- break;
- }
- case RES_CHRATR_UNDERLINE:
- {
- SvxUnderlineItem rUnderlineItem = m_pBoxAutoFormat->GetUnderline();
- rDefaultBoxFormat.GetUnderline().QueryValue(aAny, pEntry->nMemberId);
- rUnderlineItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetUnderline(rUnderlineItem);
- break;
- }
- case RES_CHRATR_FONTSIZE:
- {
- SvxFontHeightItem rFontHeightItem = m_pBoxAutoFormat->GetHeight();
- rDefaultBoxFormat.GetHeight().QueryValue(aAny, pEntry->nMemberId);
- rFontHeightItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetHeight(rFontHeightItem);
- break;
- }
- case RES_CHRATR_WEIGHT:
- {
- SvxWeightItem rWeightItem = m_pBoxAutoFormat->GetWeight();
- rDefaultBoxFormat.GetWeight().QueryValue(aAny, pEntry->nMemberId);
- rWeightItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetWeight(rWeightItem);
- break;
- }
- case RES_CHRATR_POSTURE:
- {
- SvxPostureItem rPostureItem = m_pBoxAutoFormat->GetPosture();
- rDefaultBoxFormat.GetPosture().QueryValue(aAny, pEntry->nMemberId);
- rPostureItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetPosture(rPostureItem);
- break;
- }
- case RES_CHRATR_FONT:
- {
- SvxFontItem rFontItem = m_pBoxAutoFormat->GetFont();
- rDefaultBoxFormat.GetFont().QueryValue(aAny, pEntry->nMemberId);
- rFontItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetFont(rFontItem);
- break;
- }
- case RES_CHRATR_CJK_FONTSIZE:
- {
- SvxFontHeightItem rFontHeightItem = m_pBoxAutoFormat->GetCJKHeight();
- rDefaultBoxFormat.GetCJKHeight().QueryValue(aAny, pEntry->nMemberId);
- rFontHeightItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCJKHeight(rFontHeightItem);
- break;
- }
- case RES_CHRATR_CJK_WEIGHT:
- {
- SvxWeightItem rWeightItem = m_pBoxAutoFormat->GetCJKWeight();
- rDefaultBoxFormat.GetCJKWeight().QueryValue(aAny, pEntry->nMemberId);
- rWeightItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCJKWeight(rWeightItem);
- break;
- }
- case RES_CHRATR_CJK_POSTURE:
- {
- SvxPostureItem rPostureItem = m_pBoxAutoFormat->GetCJKPosture();
- rDefaultBoxFormat.GetCJKPosture().QueryValue(aAny, pEntry->nMemberId);
- rPostureItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCJKPosture(rPostureItem);
- break;
- }
- case RES_CHRATR_CJK_FONT:
- {
- SvxFontItem rFontItem = m_pBoxAutoFormat->GetCJKFont();
- rDefaultBoxFormat.GetCJKFont().QueryValue(aAny, pEntry->nMemberId);
- rFontItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCJKFont(rFontItem);
- break;
- }
- case RES_CHRATR_CTL_FONTSIZE:
- {
- SvxFontHeightItem rFontHeightItem = m_pBoxAutoFormat->GetCTLHeight();
- rDefaultBoxFormat.GetCTLHeight().QueryValue(aAny, pEntry->nMemberId);
- rFontHeightItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCTLHeight(rFontHeightItem);
- break;
- }
- case RES_CHRATR_CTL_WEIGHT:
- {
- SvxWeightItem rWeightItem = m_pBoxAutoFormat->GetCTLWeight();
- rDefaultBoxFormat.GetCTLWeight().QueryValue(aAny, pEntry->nMemberId);
- rWeightItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCTLWeight(rWeightItem);
- break;
- }
- case RES_CHRATR_CTL_POSTURE:
- {
- SvxPostureItem rPostureItem = m_pBoxAutoFormat->GetCTLPosture();
- rDefaultBoxFormat.GetCTLPosture().QueryValue(aAny, pEntry->nMemberId);
- rPostureItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCTLPosture(rPostureItem);
- break;
- }
- case RES_CHRATR_CTL_FONT:
- {
- SvxFontItem rFontItem = m_pBoxAutoFormat->GetCTLFont();
- rDefaultBoxFormat.GetCTLFont().QueryValue(aAny, pEntry->nMemberId);
- rFontItem.PutValue(aAny, pEntry->nMemberId);
- m_pBoxAutoFormat->SetCTLFont(rFontItem);
- break;
- }
- default:
- SAL_WARN("sw.uno", "SwXTextCellStyle setPropertyToDefault unknown nWID");
+ SvxBrushItem rBrush = m_pBoxAutoFormat->GetBackground();
+ rDefaultBoxFormat.GetBackground().QueryValue(aAny, pEntry->nMemberId);
+ rBrush.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetBackground(rBrush);
+ break;
+ }
+ case RES_BOX:
+ {
+ SvxBoxItem rBox = m_pBoxAutoFormat->GetBox();
+ rDefaultBoxFormat.GetBox().QueryValue(aAny, pEntry->nMemberId);
+ rBox.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetBox(rBox);
+ break;
+ }
+ case RES_VERT_ORIENT:
+ {
+ SwFormatVertOrient rVertOrient = m_pBoxAutoFormat->GetVerticalAlignment();
+ rDefaultBoxFormat.GetVerticalAlignment().QueryValue(aAny, pEntry->nMemberId);
+ rVertOrient.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetVerticalAlignment(rVertOrient);
+ break;
+ }
+ case RES_FRAMEDIR:
+ {
+ SvxFrameDirectionItem rFrameDirectionItem = m_pBoxAutoFormat->GetTextOrientation();
+ rDefaultBoxFormat.GetTextOrientation().QueryValue(aAny, pEntry->nMemberId);
+ rFrameDirectionItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetTextOrientation(rFrameDirectionItem);
+ break;
+ }
+ case RES_BOXATR_FORMAT:
+ {
+ OUString sFormat;
+ LanguageType eLng, eSys;
+ rDefaultBoxFormat.GetValueFormat(sFormat, eLng, eSys);
+ m_pBoxAutoFormat->SetValueFormat(sFormat, eLng, eSys);
+ break;
+ }
+ case RES_PARATR_ADJUST:
+ {
+ SvxAdjustItem rAdjustItem = m_pBoxAutoFormat->GetAdjust();
+ rDefaultBoxFormat.GetAdjust().QueryValue(aAny, pEntry->nMemberId);
+ rAdjustItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetAdjust(rAdjustItem);
+ break;
+ }
+ case RES_CHRATR_COLOR:
+ {
+ SvxColorItem rColorItem = m_pBoxAutoFormat->GetColor();
+ rDefaultBoxFormat.GetColor().QueryValue(aAny, pEntry->nMemberId);
+ rColorItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetColor(rColorItem);
+ break;
+ }
+ case RES_CHRATR_SHADOWED:
+ {
+ SvxShadowedItem rShadowedItem = m_pBoxAutoFormat->GetShadowed();
+ rDefaultBoxFormat.GetShadowed().QueryValue(aAny, pEntry->nMemberId);
+ rShadowedItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetShadowed(rShadowedItem);
+ break;
}
+ case RES_CHRATR_CONTOUR:
+ {
+ SvxContourItem rContourItem = m_pBoxAutoFormat->GetContour();
+ rDefaultBoxFormat.GetContour().QueryValue(aAny, pEntry->nMemberId);
+ rContourItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetContour(rContourItem);
+ break;
+ }
+ case RES_CHRATR_CROSSEDOUT:
+ {
+ SvxCrossedOutItem rCrossedOutItem = m_pBoxAutoFormat->GetCrossedOut();
+ rDefaultBoxFormat.GetCrossedOut().QueryValue(aAny, pEntry->nMemberId);
+ rCrossedOutItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCrossedOut(rCrossedOutItem);
+ break;
+ }
+ case RES_CHRATR_UNDERLINE:
+ {
+ SvxUnderlineItem rUnderlineItem = m_pBoxAutoFormat->GetUnderline();
+ rDefaultBoxFormat.GetUnderline().QueryValue(aAny, pEntry->nMemberId);
+ rUnderlineItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetUnderline(rUnderlineItem);
+ break;
+ }
+ case RES_CHRATR_FONTSIZE:
+ {
+ SvxFontHeightItem rFontHeightItem = m_pBoxAutoFormat->GetHeight();
+ rDefaultBoxFormat.GetHeight().QueryValue(aAny, pEntry->nMemberId);
+ rFontHeightItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetHeight(rFontHeightItem);
+ break;
+ }
+ case RES_CHRATR_WEIGHT:
+ {
+ SvxWeightItem rWeightItem = m_pBoxAutoFormat->GetWeight();
+ rDefaultBoxFormat.GetWeight().QueryValue(aAny, pEntry->nMemberId);
+ rWeightItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetWeight(rWeightItem);
+ break;
+ }
+ case RES_CHRATR_POSTURE:
+ {
+ SvxPostureItem rPostureItem = m_pBoxAutoFormat->GetPosture();
+ rDefaultBoxFormat.GetPosture().QueryValue(aAny, pEntry->nMemberId);
+ rPostureItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetPosture(rPostureItem);
+ break;
+ }
+ case RES_CHRATR_FONT:
+ {
+ SvxFontItem rFontItem = m_pBoxAutoFormat->GetFont();
+ rDefaultBoxFormat.GetFont().QueryValue(aAny, pEntry->nMemberId);
+ rFontItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetFont(rFontItem);
+ break;
+ }
+ case RES_CHRATR_CJK_FONTSIZE:
+ {
+ SvxFontHeightItem rFontHeightItem = m_pBoxAutoFormat->GetCJKHeight();
+ rDefaultBoxFormat.GetCJKHeight().QueryValue(aAny, pEntry->nMemberId);
+ rFontHeightItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCJKHeight(rFontHeightItem);
+ break;
+ }
+ case RES_CHRATR_CJK_WEIGHT:
+ {
+ SvxWeightItem rWeightItem = m_pBoxAutoFormat->GetCJKWeight();
+ rDefaultBoxFormat.GetCJKWeight().QueryValue(aAny, pEntry->nMemberId);
+ rWeightItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCJKWeight(rWeightItem);
+ break;
+ }
+ case RES_CHRATR_CJK_POSTURE:
+ {
+ SvxPostureItem rPostureItem = m_pBoxAutoFormat->GetCJKPosture();
+ rDefaultBoxFormat.GetCJKPosture().QueryValue(aAny, pEntry->nMemberId);
+ rPostureItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCJKPosture(rPostureItem);
+ break;
+ }
+ case RES_CHRATR_CJK_FONT:
+ {
+ SvxFontItem rFontItem = m_pBoxAutoFormat->GetCJKFont();
+ rDefaultBoxFormat.GetCJKFont().QueryValue(aAny, pEntry->nMemberId);
+ rFontItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCJKFont(rFontItem);
+ break;
+ }
+ case RES_CHRATR_CTL_FONTSIZE:
+ {
+ SvxFontHeightItem rFontHeightItem = m_pBoxAutoFormat->GetCTLHeight();
+ rDefaultBoxFormat.GetCTLHeight().QueryValue(aAny, pEntry->nMemberId);
+ rFontHeightItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCTLHeight(rFontHeightItem);
+ break;
+ }
+ case RES_CHRATR_CTL_WEIGHT:
+ {
+ SvxWeightItem rWeightItem = m_pBoxAutoFormat->GetCTLWeight();
+ rDefaultBoxFormat.GetCTLWeight().QueryValue(aAny, pEntry->nMemberId);
+ rWeightItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCTLWeight(rWeightItem);
+ break;
+ }
+ case RES_CHRATR_CTL_POSTURE:
+ {
+ SvxPostureItem rPostureItem = m_pBoxAutoFormat->GetCTLPosture();
+ rDefaultBoxFormat.GetCTLPosture().QueryValue(aAny, pEntry->nMemberId);
+ rPostureItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCTLPosture(rPostureItem);
+ break;
+ }
+ case RES_CHRATR_CTL_FONT:
+ {
+ SvxFontItem rFontItem = m_pBoxAutoFormat->GetCTLFont();
+ rDefaultBoxFormat.GetCTLFont().QueryValue(aAny, pEntry->nMemberId);
+ rFontItem.PutValue(aAny, pEntry->nMemberId);
+ m_pBoxAutoFormat->SetCTLFont(rFontItem);
+ break;
+ }
+ default:
+ SAL_WARN("sw.uno", "SwXTextCellStyle setPropertyToDefault unknown nWID");
}
}
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index cc90ec288046..22ea0bf07d4f 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -377,29 +377,29 @@ void SwXTextTable::GetCellPosition(const OUString& rCellName, sal_Int32& o_rColu
}
++nRowPos;
}
- if (nRowPos>0 && nRowPos<nLen)
+ if (nRowPos<=0 || nRowPos>=nLen)
+ return;
+
+ sal_Int32 nColIdx = 0;
+ for (sal_Int32 i = 0; i < nRowPos; ++i)
{
- sal_Int32 nColIdx = 0;
- for (sal_Int32 i = 0; i < nRowPos; ++i)
+ nColIdx *= 52;
+ if (i < nRowPos - 1)
+ ++nColIdx;
+ const sal_Unicode cChar = rCellName[i];
+ if ('A' <= cChar && cChar <= 'Z')
+ nColIdx += cChar - 'A';
+ else if ('a' <= cChar && cChar <= 'z')
+ nColIdx += 26 + cChar - 'a';
+ else
{
- nColIdx *= 52;
- if (i < nRowPos - 1)
- ++nColIdx;
- const sal_Unicode cChar = rCellName[i];
- if ('A' <= cChar && cChar <= 'Z')
- nColIdx += cChar - 'A';
- else if ('a' <= cChar && cChar <= 'z')
- nColIdx += 26 + cChar - 'a';
- else
- {
- nColIdx = -1; // sth failed
- break;
- }
+ nColIdx = -1; // sth failed
+ break;
}
-
- o_rColumn = nColIdx;
- o_rRow = rCellName.copy(nRowPos).toInt32() - 1; // - 1 because indices ought to be 0 based
}
+
+ o_rColumn = nColIdx;
+ o_rRow = rCellName.copy(nRowPos).toInt32() - 1; // - 1 because indices ought to be 0 based
}
/** compare position of two cells (check rows first)
@@ -1282,72 +1282,72 @@ void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno:
SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
SwTable* pTable = SwTable::FindTable( pFormat );
SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine);
- if(pLn)
+ if(!pLn)
+ return;
+
+ // Check for a specific property
+ if ( rPropertyName == "TableRedlineParams" )
{
- // Check for a specific property
- if ( rPropertyName == "TableRedlineParams" )
+ // Get the table row properties
+ uno::Sequence< beans::PropertyValue > tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
+ comphelper::SequenceAsHashMap aPropMap( tableRowProperties );
+ OUString sRedlineType;
+ if( !(aPropMap.getValue("RedlineType") >>= sRedlineType) )
{
- // Get the table row properties
- uno::Sequence< beans::PropertyValue > tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
- comphelper::SequenceAsHashMap aPropMap( tableRowProperties );
- OUString sRedlineType;
- if( !(aPropMap.getValue("RedlineType") >>= sRedlineType) )
- {
- throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) );
- }
+ throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) );
+ }
- // Create a 'Table Row Redline' object
- SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties);
+ // Create a 'Table Row Redline' object
+ SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties);
- }
- else
- {
- const SfxItemPropertySimpleEntry* pEntry =
- m_pPropSet->getPropertyMap().getByName(rPropertyName);
- SwDoc* pDoc = pFormat->GetDoc();
- 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 ) );
+ }
+ else
+ {
+ const SfxItemPropertySimpleEntry* pEntry =
+ m_pPropSet->getPropertyMap().getByName(rPropertyName);
+ SwDoc* pDoc = pFormat->GetDoc();
+ 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 ) );
- switch(pEntry->nWID)
+ switch(pEntry->nWID)
+ {
+ case FN_UNO_ROW_HEIGHT:
+ case FN_UNO_ROW_AUTO_HEIGHT:
{
- case FN_UNO_ROW_HEIGHT:
- case FN_UNO_ROW_AUTO_HEIGHT:
+ SwFormatFrameSize aFrameSize(pLn->GetFrameFormat()->GetFrameSize());
+ if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
{
- SwFormatFrameSize aFrameSize(pLn->GetFrameFormat()->GetFrameSize());
- if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
- {
- bool bSet = *o3tl::doAccess<bool>(aValue);
- aFrameSize.SetHeightSizeType(bSet ? SwFrameSize::Variable : SwFrameSize::Fixed);
- }
- else
- {
- sal_Int32 nHeight = 0;
- aValue >>= nHeight;
- Size aSz(aFrameSize.GetSize());
- aSz.setHeight( convertMm100ToTwip(nHeight) );
- aFrameSize.SetSize(aSz);
- }
- pDoc->SetAttr(aFrameSize, *pLn->ClaimFrameFormat());
+ bool bSet = *o3tl::doAccess<bool>(aValue);
+ aFrameSize.SetHeightSizeType(bSet ? SwFrameSize::Variable : SwFrameSize::Fixed);
}
- break;
-
- case FN_UNO_TABLE_COLUMN_SEPARATORS:
+ else
{
- UnoActionContext aContext(pDoc);
- SwTable* pTable2 = SwTable::FindTable( pFormat );
- lcl_SetTableSeparators(aValue, pTable2, pLine->GetTabBoxes()[0], true, pDoc);
+ sal_Int32 nHeight = 0;
+ aValue >>= nHeight;
+ Size aSz(aFrameSize.GetSize());
+ aSz.setHeight( convertMm100ToTwip(nHeight) );
+ aFrameSize.SetSize(aSz);
}
- break;
+ pDoc->SetAttr(aFrameSize, *pLn->ClaimFrameFormat());
+ }
+ break;
- default:
- {
- SwFrameFormat* pLnFormat = pLn->ClaimFrameFormat();
- SwAttrSet aSet(pLnFormat->GetAttrSet());
- m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
- pDoc->SetAttr(aSet, *pLnFormat);
- }
+ case FN_UNO_TABLE_COLUMN_SEPARATORS:
+ {
+ UnoActionContext aContext(pDoc);
+ SwTable* pTable2 = SwTable::FindTable( pFormat );
+ lcl_SetTableSeparators(aValue, pTable2, pLine->GetTabBoxes()[0], true, pDoc);
+ }
+ break;
+
+ default:
+ {
+ SwFrameFormat* pLnFormat = pLn->ClaimFrameFormat();
+ SwAttrSet aSet(pLnFormat->GetAttrSet());
+ m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
+ pDoc->SetAttr(aSet, *pLnFormat);
}
}
}
@@ -2444,20 +2444,20 @@ void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor
SolarMutexGuard aGuard;
SwSortOptions aSortOpt;
SwFrameFormat* pFormat = GetFrameFormat();
- if(pFormat &&
- SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
+ if(!(pFormat &&
+ SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)))
+ return;
+
+ SwTable* pTable = SwTable::FindTable( pFormat );
+ SwSelBoxes aBoxes;
+ const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
+ for (size_t n = 0; n < rTBoxes.size(); ++n)
{
- SwTable* pTable = SwTable::FindTable( pFormat );
- SwSelBoxes aBoxes;
- const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
- for (size_t n = 0; n < rTBoxes.size(); ++n)
- {
- SwTableBox* pBox = rTBoxes[ n ];
- aBoxes.insert( pBox );
- }
- UnoActionContext aContext( pFormat->GetDoc() );
- pFormat->GetDoc()->SortTable(aBoxes, aSortOpt);
+ SwTableBox* pBox = rTBoxes[ n ];
+ aBoxes.insert( pBox );
}
+ UnoActionContext aContext( pFormat->GetDoc() );
+ pFormat->GetDoc()->SortTable(aBoxes, aSortOpt);
}
void SwXTextTable::autoFormat(const OUString& sAutoFormatName)
@@ -3372,118 +3372,117 @@ SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV
{
SolarMutexGuard aGuard;
SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
- if(pFormat)
- {
- const SfxItemPropertySimpleEntry *const pEntry =
- m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
- if(!pEntry)
- throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
+ if(!pFormat)
+ return;
- if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
- throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
+ const SfxItemPropertySimpleEntry *const pEntry =
+ m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
+ 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);
+ std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
+ SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
+ 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)
{
- std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
- SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
- 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(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(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);
}
-
}
}
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 394e8ae7de56..614afccfd459 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -460,36 +460,36 @@ SwXText::insertControlCharacter(
aPam, OUString(cIns), nInsertFlags);
}
- if (bAbsorb)
+ if (!bAbsorb)
+ return;
+
+ const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
+ xTextRange, uno::UNO_QUERY);
+ SwXTextRange *const pRange =
+ ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
+ OTextCursorHelper *const pCursor =
+ ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
+
+ SwCursor aCursor(*aPam.GetPoint(), nullptr);
+ SwUnoCursorHelper::SelectPam(aCursor, true);
+ aCursor.Left(1);
+ // here, the PaM needs to be moved:
+ if (pRange)
{
- const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
- xTextRange, uno::UNO_QUERY);
- SwXTextRange *const pRange =
- ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
- OTextCursorHelper *const pCursor =
- ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
-
- SwCursor aCursor(*aPam.GetPoint(), nullptr);
- SwUnoCursorHelper::SelectPam(aCursor, true);
- aCursor.Left(1);
- // here, the PaM needs to be moved:
- if (pRange)
+ pRange->SetPositions(aCursor);
+ }
+ else
+ {
+ SwPaM *const pUnoCursor = pCursor->GetPaM();
+ *pUnoCursor->GetPoint() = *aCursor.GetPoint();
+ if (aCursor.HasMark())
{
- pRange->SetPositions(aCursor);
+ pUnoCursor->SetMark();
+ *pUnoCursor->GetMark() = *aCursor.GetMark();
}
else
{
- SwPaM *const pUnoCursor = pCursor->GetPaM();
- *pUnoCursor->GetPoint() = *aCursor.GetPoint();
- if (aCursor.HasMark())
- {
- pUnoCursor->SetMark();
- *pUnoCursor->GetMark() = *aCursor.GetMark();
- }
- else
- {
- pUnoCursor->DeleteMark();
- }
+ pUnoCursor->DeleteMark();
}
}
}