[Libreoffice-commits] core.git: sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 31 09:57:19 UTC 2020
sw/source/filter/ww8/docxattributeoutput.cxx | 412 +++++-----
sw/source/filter/ww8/docxexport.cxx | 104 +-
sw/source/filter/ww8/docxsdrexport.cxx | 38 -
sw/source/filter/ww8/rtfattributeoutput.cxx | 488 ++++++------
sw/source/filter/ww8/rtfexport.cxx | 21
sw/source/filter/ww8/writerhelper.cxx | 22
sw/source/filter/ww8/wrtw8esh.cxx | 628 ++++++++--------
sw/source/filter/ww8/wrtw8nds.cxx | 56 -
sw/source/filter/ww8/wrtw8sty.cxx | 58 -
sw/source/filter/ww8/wrtww8.cxx | 405 +++++-----
sw/source/filter/ww8/wrtww8gr.cxx | 218 ++---
sw/source/filter/ww8/ww8atr.cxx | 1022 +++++++++++++--------------
sw/source/filter/ww8/ww8graf.cxx | 262 +++---
sw/source/filter/ww8/ww8par.cxx | 392 +++++-----
sw/source/filter/ww8/ww8par2.cxx | 497 ++++++-------
sw/source/filter/ww8/ww8par3.cxx | 268 +++----
sw/source/filter/ww8/ww8par5.cxx | 114 +--
sw/source/filter/ww8/ww8par6.cxx | 323 ++++----
sw/source/filter/ww8/ww8scan.cxx | 214 ++---
19 files changed, 2774 insertions(+), 2768 deletions(-)
New commits:
commit e42166098b13d1bf4f66291550ab326b750bcbed
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jul 30 10:37:55 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 31 11:56:36 2020 +0200
loplugin:flatten in sw/filter/ww8
Change-Id: Ia296fc6e6c8f78edf533dedf52996560ae62d143
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99853
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index e90a9efc2e08..6581f93f3834 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -909,75 +909,75 @@ void DocxAttributeOutput::SyncNodelessCells(ww8::WW8TableNodeInfoInner::Pointer_
void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t const & pInner, bool bForceEmptyParagraph )
{
- if ( pInner )
- {
- // Where are we in the table
- sal_uInt32 nRow = pInner->getRow();
- sal_Int32 nCell = pInner->getCell();
+ if ( !pInner )
+ return;
- InitTableHelper( pInner );
+ // Where are we in the table
+ sal_uInt32 nRow = pInner->getRow();
+ sal_Int32 nCell = pInner->getCell();
- // HACK
- // msoffice seems to have an internal limitation of 63 columns for tables
- // and refuses to load .docx with more, even though the spec seems to allow that;
- // so simply if there are more columns, don't close the last one msoffice will handle
- // and merge the contents of the remaining ones into it (since we don't close the cell
- // here, following ones will not be opened)
- const bool limitWorkaround = (nCell >= MAX_CELL_IN_WORD && !pInner->isEndOfLine());
- const bool bEndCell = pInner->isEndOfCell() && !limitWorkaround;
- const bool bEndRow = pInner->isEndOfLine();
+ InitTableHelper( pInner );
+
+ // HACK
+ // msoffice seems to have an internal limitation of 63 columns for tables
+ // and refuses to load .docx with more, even though the spec seems to allow that;
+ // so simply if there are more columns, don't close the last one msoffice will handle
+ // and merge the contents of the remaining ones into it (since we don't close the cell
+ // here, following ones will not be opened)
+ const bool limitWorkaround = (nCell >= MAX_CELL_IN_WORD && !pInner->isEndOfLine());
+ const bool bEndCell = pInner->isEndOfCell() && !limitWorkaround;
+ const bool bEndRow = pInner->isEndOfLine();
- if (bEndCell)
+ if (bEndCell)
+ {
+ while (pInner->getDepth() < m_tableReference->m_nTableDepth)
{
- while (pInner->getDepth() < m_tableReference->m_nTableDepth)
- {
- //we expect that the higher depth row was closed, and
- //we are just missing the table close
- assert(lastOpenCell.back() == -1 && lastClosedCell.back() == -1);
- EndTable();
- }
+ //we expect that the higher depth row was closed, and
+ //we are just missing the table close
+ assert(lastOpenCell.back() == -1 && lastClosedCell.back() == -1);
+ EndTable();
+ }
- SyncNodelessCells(pInner, nCell, nRow);
+ SyncNodelessCells(pInner, nCell, nRow);
- sal_Int32 nClosedCell = lastClosedCell.back();
- if (nCell == nClosedCell)
- {
- //Start missing trailing cell(s)
- ++nCell;
- StartTableCell(pInner, nCell, nRow);
+ sal_Int32 nClosedCell = lastClosedCell.back();
+ if (nCell == nClosedCell)
+ {
+ //Start missing trailing cell(s)
+ ++nCell;
+ StartTableCell(pInner, nCell, nRow);
- //Continue on missing next trailing cell(s)
- ww8::RowSpansPtr xRowSpans = pInner->getRowSpansOfRow();
- sal_Int32 nRemainingCells = xRowSpans->size() - nCell;
- for (sal_Int32 i = 1; i < nRemainingCells; ++i)
+ //Continue on missing next trailing cell(s)
+ ww8::RowSpansPtr xRowSpans = pInner->getRowSpansOfRow();
+ sal_Int32 nRemainingCells = xRowSpans->size() - nCell;
+ for (sal_Int32 i = 1; i < nRemainingCells; ++i)
+ {
+ if (bForceEmptyParagraph)
{
- if (bForceEmptyParagraph)
- {
- m_pSerializer->singleElementNS(XML_w, XML_p);
- }
-
- EndTableCell(nCell);
-
- StartTableCell(pInner, nCell, nRow);
+ m_pSerializer->singleElementNS(XML_w, XML_p);
}
- }
- if (bForceEmptyParagraph)
- {
- m_pSerializer->singleElementNS(XML_w, XML_p);
- }
+ EndTableCell(nCell);
- EndTableCell(nCell);
+ StartTableCell(pInner, nCell, nRow);
+ }
}
- // This is a line end
- if (bEndRow)
- EndTableRow();
+ if (bForceEmptyParagraph)
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_p);
+ }
- // This is the end of the table
- if (pInner->isFinalEndOfLine())
- EndTable();
+ EndTableCell(nCell);
}
+
+ // This is a line end
+ if (bEndRow)
+ EndTableRow();
+
+ // This is the end of the table
+ if (pInner->isFinalEndOfLine())
+ EndTable();
}
void DocxAttributeOutput::EmptyParagraph()
@@ -2309,32 +2309,32 @@ void DocxAttributeOutput::EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos
}
// Write the ref field if a bookmark had to be set and the field
// should be visible
- if ( rInfos.pField )
- {
- sal_uInt16 nSubType = rInfos.pField->GetSubType( );
- bool bIsSetField = rInfos.pField->GetTyp( )->Which( ) == SwFieldIds::SetExp;
- bool bShowRef = bIsSetField && ( nSubType & nsSwExtendedSubType::SUB_INVISIBLE ) == 0;
+ if ( !rInfos.pField )
+ return;
- if ( ( !m_sFieldBkm.isEmpty() ) && bShowRef )
- {
- // Write the field beginning
- m_pSerializer->startElementNS(XML_w, XML_r);
- m_pSerializer->singleElementNS( XML_w, XML_fldChar,
- FSNS( XML_w, XML_fldCharType ), "begin" );
- m_pSerializer->endElementNS( XML_w, XML_r );
+ sal_uInt16 nSubType = rInfos.pField->GetSubType( );
+ bool bIsSetField = rInfos.pField->GetTyp( )->Which( ) == SwFieldIds::SetExp;
+ bool bShowRef = bIsSetField && ( nSubType & nsSwExtendedSubType::SUB_INVISIBLE ) == 0;
- rInfos.sCmd = FieldString( ww::eREF );
- rInfos.sCmd += "\"";
- rInfos.sCmd += m_sFieldBkm;
- rInfos.sCmd += "\" ";
+ if ( !(( !m_sFieldBkm.isEmpty() ) && bShowRef) )
+ return;
- // Clean the field bookmark data to avoid infinite loop
- m_sFieldBkm = OUString( );
+ // Write the field beginning
+ m_pSerializer->startElementNS(XML_w, XML_r);
+ m_pSerializer->singleElementNS( XML_w, XML_fldChar,
+ FSNS( XML_w, XML_fldCharType ), "begin" );
+ m_pSerializer->endElementNS( XML_w, XML_r );
- // Write the end of the field
- EndField_Impl( pNode, nPos, rInfos );
- }
- }
+ rInfos.sCmd = FieldString( ww::eREF );
+ rInfos.sCmd += "\"";
+ rInfos.sCmd += m_sFieldBkm;
+ rInfos.sCmd += "\" ";
+
+ // Clean the field bookmark data to avoid infinite loop
+ m_sFieldBkm = OUString( );
+
+ // Write the end of the field
+ EndField_Impl( pNode, nPos, rInfos );
}
void DocxAttributeOutput::StartRunProperties()
@@ -2693,30 +2693,30 @@ void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
void DocxAttributeOutput::GetSdtEndBefore(const SdrObject* pSdrObj)
{
- if (pSdrObj)
- {
- uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY_THROW);
- uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
- if( xPropSet.is() )
- {
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
- uno::Sequence< beans::PropertyValue > aGrabBag;
- if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
- {
- xPropSet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
- }
- else if(xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("InteropGrabBag"))
- {
- xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
- }
+ if (!pSdrObj)
+ return;
- auto pProp = std::find_if(aGrabBag.begin(), aGrabBag.end(),
- [this](const beans::PropertyValue& rProp) {
- return "SdtEndBefore" == rProp.Name && m_bStartedCharSdt && !m_bEndCharSdt; });
- if (pProp != aGrabBag.end())
- pProp->Value >>= m_bEndCharSdt;
- }
+ uno::Reference<drawing::XShape> xShape(const_cast<SdrObject*>(pSdrObj)->getUnoShape(), uno::UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
+ if( !xPropSet.is() )
+ return;
+
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ uno::Sequence< beans::PropertyValue > aGrabBag;
+ if (xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("FrameInteropGrabBag"))
+ {
+ xPropSet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
+ }
+ else if(xPropSetInfo.is() && xPropSetInfo->hasPropertyByName("InteropGrabBag"))
+ {
+ xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
}
+
+ auto pProp = std::find_if(aGrabBag.begin(), aGrabBag.end(),
+ [this](const beans::PropertyValue& rProp) {
+ return "SdtEndBefore" == rProp.Name && m_bStartedCharSdt && !m_bEndCharSdt; });
+ if (pProp != aGrabBag.end())
+ pProp->Value >>= m_bEndCharSdt;
}
void DocxAttributeOutput::WritePostponedGraphic()
@@ -4339,23 +4339,23 @@ void DocxAttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTa
const SwFrameFormat * pLineFormat = pTabLine->GetFrameFormat();
const SwFormatFrameSize& rLSz = pLineFormat->GetFrameSize();
- if ( SwFrameSize::Variable != rLSz.GetHeightSizeType() && rLSz.GetHeight() )
- {
- sal_Int32 nHeight = rLSz.GetHeight();
- const char *pRule = nullptr;
+ if ( !(SwFrameSize::Variable != rLSz.GetHeightSizeType() && rLSz.GetHeight()) )
+ return;
- switch ( rLSz.GetHeightSizeType() )
- {
- case SwFrameSize::Fixed: pRule = "exact"; break;
- case SwFrameSize::Minimum: pRule = "atLeast"; break;
- default: break;
- }
+ sal_Int32 nHeight = rLSz.GetHeight();
+ const char *pRule = nullptr;
- if ( pRule )
- m_pSerializer->singleElementNS( XML_w, XML_trHeight,
- FSNS( XML_w, XML_val ), OString::number(nHeight),
- FSNS( XML_w, XML_hRule ), pRule );
+ switch ( rLSz.GetHeightSizeType() )
+ {
+ case SwFrameSize::Fixed: pRule = "exact"; break;
+ case SwFrameSize::Minimum: pRule = "atLeast"; break;
+ default: break;
}
+
+ if ( pRule )
+ m_pSerializer->singleElementNS( XML_w, XML_trHeight,
+ FSNS( XML_w, XML_val ), OString::number(nHeight),
+ FSNS( XML_w, XML_hRule ), pRule );
}
void DocxAttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
@@ -4398,20 +4398,20 @@ void DocxAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer
SwWriteTableRow *pRow = rRows[ pTableTextNodeInfoInner->getRow( ) ].get();
sal_uInt32 nCell = pTableTextNodeInfoInner->getCell();
const SwWriteTableCells& rTableCells = pRow->GetCells();
- if (nCell < rTableCells.size() )
+ if (nCell >= rTableCells.size() )
+ return;
+
+ const SwWriteTableCell *const pCell = pRow->GetCells()[ nCell ].get();
+ switch( pCell->GetVertOri())
{
- const SwWriteTableCell *const pCell = pRow->GetCells()[ nCell ].get();
- switch( pCell->GetVertOri())
- {
- case text::VertOrientation::TOP:
- break;
- case text::VertOrientation::CENTER:
- m_pSerializer->singleElementNS(XML_w, XML_vAlign, FSNS(XML_w, XML_val), "center");
- break;
- case text::VertOrientation::BOTTOM:
- m_pSerializer->singleElementNS(XML_w, XML_vAlign, FSNS(XML_w, XML_val), "bottom");
- break;
- }
+ case text::VertOrientation::TOP:
+ break;
+ case text::VertOrientation::CENTER:
+ m_pSerializer->singleElementNS(XML_w, XML_vAlign, FSNS(XML_w, XML_val), "center");
+ break;
+ case text::VertOrientation::BOTTOM:
+ m_pSerializer->singleElementNS(XML_w, XML_vAlign, FSNS(XML_w, XML_val), "bottom");
+ break;
}
}
@@ -4801,22 +4801,22 @@ void DocxAttributeOutput::WriteSrcRect(const SdrObject* pSdrObj, const SwFrameFo
nCropB -= rBox.GetDistance( SvxBoxItemLine::BOTTOM );
}
- if ( (0 != nCropL) || (0 != nCropT) || (0 != nCropR) || (0 != nCropB) )
- {
- double widthMultiplier = 100000.0/aOriginalSize.Width();
- double heightMultiplier = 100000.0/aOriginalSize.Height();
+ if ( !((0 != nCropL) || (0 != nCropT) || (0 != nCropR) || (0 != nCropB)) )
+ return;
- sal_Int32 left = static_cast<sal_Int32>(rtl::math::round(nCropL * widthMultiplier));
- sal_Int32 right = static_cast<sal_Int32>(rtl::math::round(nCropR * widthMultiplier));
- sal_Int32 top = static_cast<sal_Int32>(rtl::math::round(nCropT * heightMultiplier));
- sal_Int32 bottom = static_cast<sal_Int32>(rtl::math::round(nCropB * heightMultiplier));
+ double widthMultiplier = 100000.0/aOriginalSize.Width();
+ double heightMultiplier = 100000.0/aOriginalSize.Height();
- m_pSerializer->singleElementNS( XML_a, XML_srcRect,
- XML_l, OString::number(left),
- XML_t, OString::number(top),
- XML_r, OString::number(right),
- XML_b, OString::number(bottom) );
- }
+ sal_Int32 left = static_cast<sal_Int32>(rtl::math::round(nCropL * widthMultiplier));
+ sal_Int32 right = static_cast<sal_Int32>(rtl::math::round(nCropR * widthMultiplier));
+ sal_Int32 top = static_cast<sal_Int32>(rtl::math::round(nCropT * heightMultiplier));
+ sal_Int32 bottom = static_cast<sal_Int32>(rtl::math::round(nCropB * heightMultiplier));
+
+ m_pSerializer->singleElementNS( XML_a, XML_srcRect,
+ XML_l, OString::number(left),
+ XML_t, OString::number(top),
+ XML_r, OString::number(right),
+ XML_b, OString::number(bottom) );
}
void DocxAttributeOutput::PopRelIdCache()
@@ -7178,23 +7178,23 @@ void DocxAttributeOutput::CharFont( const SvxFontItem& rFont)
GetExport().GetId( rFont ); // ensure font info is written to fontTable.xml
const OUString& sFontName(rFont.GetFamilyName());
const OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8);
- if (!sFontNameUtf8.isEmpty())
- {
- if (m_pFontsAttrList &&
- ( m_pFontsAttrList->hasAttribute(FSNS( XML_w, XML_ascii )) ||
- m_pFontsAttrList->hasAttribute(FSNS( XML_w, XML_hAnsi )) )
- )
- {
- // tdf#38778: do to fields output into DOC the font could be added before and after field declaration
- // that all sub runs of the field will have correct font inside.
- // For DOCX we should do not add the same font information twice in the same node
- return;
- }
+ if (sFontNameUtf8.isEmpty())
+ return;
- AddToAttrList( m_pFontsAttrList, 2,
- FSNS( XML_w, XML_ascii ), sFontNameUtf8.getStr(),
- FSNS( XML_w, XML_hAnsi ), sFontNameUtf8.getStr() );
+ if (m_pFontsAttrList &&
+ ( m_pFontsAttrList->hasAttribute(FSNS( XML_w, XML_ascii )) ||
+ m_pFontsAttrList->hasAttribute(FSNS( XML_w, XML_hAnsi )) )
+ )
+ {
+ // tdf#38778: do to fields output into DOC the font could be added before and after field declaration
+ // that all sub runs of the field will have correct font inside.
+ // For DOCX we should do not add the same font information twice in the same node
+ return;
}
+
+ AddToAttrList( m_pFontsAttrList, 2,
+ FSNS( XML_w, XML_ascii ), sFontNameUtf8.getStr(),
+ FSNS( XML_w, XML_hAnsi ), sFontNameUtf8.getStr() );
}
void DocxAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize)
@@ -7689,22 +7689,22 @@ void DocxAttributeOutput::WriteField_Impl( const SwField* pField, ww::eField eTy
infos.bOpen = bool(FieldFlags::Start & nMode);
m_Fields.push_back( infos );
- if ( pField )
- {
- SwFieldIds nType = pField->GetTyp( )->Which( );
- sal_uInt16 nSubType = pField->GetSubType();
+ if ( !pField )
+ return;
- // TODO Any other field types here ?
- if ( ( nType == SwFieldIds::SetExp ) && ( nSubType & nsSwGetSetExpType::GSE_STRING ) )
- {
- const SwSetExpField *pSet = static_cast<const SwSetExpField*>( pField );
- m_sFieldBkm = pSet->GetPar1( );
- }
- else if ( nType == SwFieldIds::Dropdown )
- {
- const SwDropDownField* pDropDown = static_cast<const SwDropDownField*>( pField );
- m_sFieldBkm = pDropDown->GetName( );
- }
+ SwFieldIds nType = pField->GetTyp( )->Which( );
+ sal_uInt16 nSubType = pField->GetSubType();
+
+ // TODO Any other field types here ?
+ if ( ( nType == SwFieldIds::SetExp ) && ( nSubType & nsSwGetSetExpType::GSE_STRING ) )
+ {
+ const SwSetExpField *pSet = static_cast<const SwSetExpField*>( pField );
+ m_sFieldBkm = pSet->GetPar1( );
+ }
+ else if ( nType == SwFieldIds::Dropdown )
+ {
+ const SwDropDownField* pDropDown = static_cast<const SwDropDownField*>( pField );
+ m_sFieldBkm = pDropDown->GetName( );
}
}
@@ -8231,22 +8231,22 @@ void DocxAttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
void DocxAttributeOutput::ParaNumRule_Impl( const SwTextNode* pTextNd, sal_Int32 nLvl, sal_Int32 nNumId )
{
- if ( USHRT_MAX != nNumId )
- {
- const sal_Int32 nTableSize = m_rExport.m_pUsedNumTable ? m_rExport.m_pUsedNumTable->size() : 0;
- const SwNumRule* pRule = nNumId > 0 && nNumId <= nTableSize ? (*m_rExport.m_pUsedNumTable)[nNumId-1] : nullptr;
- const bool bOutlineRule = pRule && pRule->IsOutlineRule();
+ if ( USHRT_MAX == nNumId )
+ return;
- // Do not export outline rules (Chapter Numbering) as paragraph properties, only as style properties.
- if ( !pTextNd || !bOutlineRule )
- {
- m_pSerializer->startElementNS(XML_w, XML_numPr);
- m_pSerializer->singleElementNS(XML_w, XML_ilvl,
- FSNS(XML_w, XML_val), OString::number(nLvl));
- m_pSerializer->singleElementNS(XML_w, XML_numId,
- FSNS(XML_w, XML_val), OString::number(nNumId));
- m_pSerializer->endElementNS( XML_w, XML_numPr );
- }
+ const sal_Int32 nTableSize = m_rExport.m_pUsedNumTable ? m_rExport.m_pUsedNumTable->size() : 0;
+ const SwNumRule* pRule = nNumId > 0 && nNumId <= nTableSize ? (*m_rExport.m_pUsedNumTable)[nNumId-1] : nullptr;
+ const bool bOutlineRule = pRule && pRule->IsOutlineRule();
+
+ // Do not export outline rules (Chapter Numbering) as paragraph properties, only as style properties.
+ if ( !pTextNd || !bOutlineRule )
+ {
+ m_pSerializer->startElementNS(XML_w, XML_numPr);
+ m_pSerializer->singleElementNS(XML_w, XML_ilvl,
+ FSNS(XML_w, XML_val), OString::number(nLvl));
+ m_pSerializer->singleElementNS(XML_w, XML_numId,
+ FSNS(XML_w, XML_val), OString::number(nNumId));
+ m_pSerializer->endElementNS( XML_w, XML_numPr );
}
}
@@ -8920,33 +8920,33 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
aOutputBorderOptions.aShadowLocation = pShadowItem->GetLocation();
}
- if ( !m_bOpenedSectPr || GetWritingHeaderFooter())
- {
- // Not inside a section
-
- // Open the paragraph's borders tag
- m_pSerializer->startElementNS(XML_w, XML_pBdr);
+ if ( !(!m_bOpenedSectPr || GetWritingHeaderFooter()))
+ return;
- std::map<SvxBoxItemLine, css::table::BorderLine2> aStyleBorders;
- const SvxBoxItem* pInherited = nullptr;
- if ( GetExport().m_pStyAttr )
- pInherited = GetExport().m_pStyAttr->GetItem<SvxBoxItem>(RES_BOX);
- else if ( GetExport().m_pCurrentStyle && GetExport().m_pCurrentStyle->DerivedFrom() )
- pInherited = GetExport().m_pCurrentStyle->DerivedFrom()->GetAttrSet().GetItem<SvxBoxItem>(RES_BOX);
+ // Not inside a section
- if ( pInherited )
- {
- aStyleBorders[ SvxBoxItemLine::TOP ] = SvxBoxItem::SvxLineToLine(pInherited->GetTop(), /*bConvert=*/false);
- aStyleBorders[ SvxBoxItemLine::BOTTOM ] = SvxBoxItem::SvxLineToLine(pInherited->GetBottom(), false);
- aStyleBorders[ SvxBoxItemLine::LEFT ] = SvxBoxItem::SvxLineToLine(pInherited->GetLeft(), false);
- aStyleBorders[ SvxBoxItemLine::RIGHT ] = SvxBoxItem::SvxLineToLine(pInherited->GetRight(), false);
- }
+ // Open the paragraph's borders tag
+ m_pSerializer->startElementNS(XML_w, XML_pBdr);
- impl_borders( m_pSerializer, rBox, aOutputBorderOptions, aStyleBorders );
+ std::map<SvxBoxItemLine, css::table::BorderLine2> aStyleBorders;
+ const SvxBoxItem* pInherited = nullptr;
+ if ( GetExport().m_pStyAttr )
+ pInherited = GetExport().m_pStyAttr->GetItem<SvxBoxItem>(RES_BOX);
+ else if ( GetExport().m_pCurrentStyle && GetExport().m_pCurrentStyle->DerivedFrom() )
+ pInherited = GetExport().m_pCurrentStyle->DerivedFrom()->GetAttrSet().GetItem<SvxBoxItem>(RES_BOX);
- // Close the paragraph's borders tag
- m_pSerializer->endElementNS( XML_w, XML_pBdr );
+ if ( pInherited )
+ {
+ aStyleBorders[ SvxBoxItemLine::TOP ] = SvxBoxItem::SvxLineToLine(pInherited->GetTop(), /*bConvert=*/false);
+ aStyleBorders[ SvxBoxItemLine::BOTTOM ] = SvxBoxItem::SvxLineToLine(pInherited->GetBottom(), false);
+ aStyleBorders[ SvxBoxItemLine::LEFT ] = SvxBoxItem::SvxLineToLine(pInherited->GetLeft(), false);
+ aStyleBorders[ SvxBoxItemLine::RIGHT ] = SvxBoxItem::SvxLineToLine(pInherited->GetRight(), false);
}
+
+ impl_borders( m_pSerializer, rBox, aOutputBorderOptions, aStyleBorders );
+
+ // Close the paragraph's borders tag
+ m_pSerializer->endElementNS( XML_w, XML_pBdr );
}
void DocxAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCol& rCol, bool bEven, SwTwips nPageSize )
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 160cc8c385d3..e603d2deb3a2 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -693,52 +693,52 @@ void DocxExport::WriteFootnotesEndnotes()
m_pAttrOutput->SetSerializer( m_pDocumentFS );
}
- if ( m_pAttrOutput->HasEndnotes() )
- {
- // setup word/styles.xml and the relations + content type
- m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
- oox::getRelationship(Relationship::ENDNOTES),
- "endnotes.xml" );
+ if ( !m_pAttrOutput->HasEndnotes() )
+ return;
- ::sax_fastparser::FSHelperPtr pEndnotesFS =
- m_pFilter->openFragmentStreamWithSerializer( "word/endnotes.xml",
- "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" );
+ // setup word/styles.xml and the relations + content type
+ m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
+ oox::getRelationship(Relationship::ENDNOTES),
+ "endnotes.xml" );
- // switch the serializer to redirect the output to word/endnotes.xml
- m_pAttrOutput->SetSerializer( pEndnotesFS );
- // tdf#99227
- m_pSdrExport->setSerializer( pEndnotesFS );
- // tdf#107969
- m_pVMLExport->SetFS(pEndnotesFS);
+ ::sax_fastparser::FSHelperPtr pEndnotesFS =
+ m_pFilter->openFragmentStreamWithSerializer( "word/endnotes.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" );
- // do the work
- m_pAttrOutput->FootnotesEndnotes( false );
+ // switch the serializer to redirect the output to word/endnotes.xml
+ m_pAttrOutput->SetSerializer( pEndnotesFS );
+ // tdf#99227
+ m_pSdrExport->setSerializer( pEndnotesFS );
+ // tdf#107969
+ m_pVMLExport->SetFS(pEndnotesFS);
- // switch the serializer back
- m_pVMLExport->SetFS(m_pDocumentFS);
- m_pSdrExport->setSerializer( m_pDocumentFS );
- m_pAttrOutput->SetSerializer( m_pDocumentFS );
- }
+ // do the work
+ m_pAttrOutput->FootnotesEndnotes( false );
+
+ // switch the serializer back
+ m_pVMLExport->SetFS(m_pDocumentFS);
+ m_pSdrExport->setSerializer( m_pDocumentFS );
+ m_pAttrOutput->SetSerializer( m_pDocumentFS );
}
void DocxExport::WritePostitFields()
{
- if ( m_pAttrOutput->HasPostitFields() )
- {
- m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
- oox::getRelationship(Relationship::COMMENTS),
- "comments.xml" );
+ if ( !m_pAttrOutput->HasPostitFields() )
+ return;
- ::sax_fastparser::FSHelperPtr pPostitFS =
- m_pFilter->openFragmentStreamWithSerializer( "word/comments.xml",
- "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" );
+ m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
+ oox::getRelationship(Relationship::COMMENTS),
+ "comments.xml" );
- pPostitFS->startElementNS( XML_w, XML_comments, MainXmlNamespaces());
- m_pAttrOutput->SetSerializer( pPostitFS );
- m_pAttrOutput->WritePostitFields();
- m_pAttrOutput->SetSerializer( m_pDocumentFS );
- pPostitFS->endElementNS( XML_w, XML_comments );
- }
+ ::sax_fastparser::FSHelperPtr pPostitFS =
+ m_pFilter->openFragmentStreamWithSerializer( "word/comments.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" );
+
+ pPostitFS->startElementNS( XML_w, XML_comments, MainXmlNamespaces());
+ m_pAttrOutput->SetSerializer( pPostitFS );
+ m_pAttrOutput->WritePostitFields();
+ m_pAttrOutput->SetSerializer( m_pDocumentFS );
+ pPostitFS->endElementNS( XML_w, XML_comments );
}
void DocxExport::WriteNumbering()
@@ -1538,26 +1538,26 @@ void DocxExport::WriteVBA()
return;
uno::Reference<io::XStream> xDataStream = xDocumentStorage->openStreamElement(aDataName, nOpenMode);
- if (xDataStream.is())
- {
- // Then the data stream, which wants to work with an already set
- // xProjectStream.
- std::unique_ptr<SvStream> pIn(utl::UcbStreamHelper::CreateStream(xDataStream));
+ if (!xDataStream.is())
+ return;
- uno::Reference<io::XStream> xOutputStream(GetFilter().openFragmentStream("word/vbaData.xml", "application/vnd.ms-word.vbaData+xml"), uno::UNO_QUERY);
- if (!xOutputStream.is())
- return;
- std::unique_ptr<SvStream> pOut(utl::UcbStreamHelper::CreateStream(xOutputStream));
+ // Then the data stream, which wants to work with an already set
+ // xProjectStream.
+ std::unique_ptr<SvStream> pIn(utl::UcbStreamHelper::CreateStream(xDataStream));
- // Write the stream.
- pOut->WriteStream(*pIn);
+ uno::Reference<io::XStream> xOutputStream(GetFilter().openFragmentStream("word/vbaData.xml", "application/vnd.ms-word.vbaData+xml"), uno::UNO_QUERY);
+ if (!xOutputStream.is())
+ return;
+ std::unique_ptr<SvStream> pOut(utl::UcbStreamHelper::CreateStream(xOutputStream));
- // Write the relationship.
- if (!xProjectStream.is())
- return;
+ // Write the stream.
+ pOut->WriteStream(*pIn);
- m_pFilter->addRelation(xProjectStream, oox::getRelationship(Relationship::WORDVBADATA), "vbaData.xml");
- }
+ // Write the relationship.
+ if (!xProjectStream.is())
+ return;
+
+ m_pFilter->addRelation(xProjectStream, oox::getRelationship(Relationship::WORDVBADATA), "vbaData.xml");
}
void DocxExport::WriteEmbeddings()
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index bc540c232337..a70801e78773 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -796,26 +796,26 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
}
// No? Then just approximate based on what we have.
- if (isAnchor && !nWrapToken)
+ if (!(isAnchor && !nWrapToken))
+ return;
+
+ switch (pFrameFormat->GetSurround().GetValue())
{
- switch (pFrameFormat->GetSurround().GetValue())
- {
- case css::text::WrapTextMode_NONE:
- m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapTopAndBottom);
- break;
- case css::text::WrapTextMode_THROUGH:
- m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapNone);
- break;
- case css::text::WrapTextMode_PARALLEL:
- m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText,
- "bothSides");
- break;
- case css::text::WrapTextMode_DYNAMIC:
- default:
- m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText,
- "largest");
- break;
- }
+ case css::text::WrapTextMode_NONE:
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapTopAndBottom);
+ break;
+ case css::text::WrapTextMode_THROUGH:
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapNone);
+ break;
+ case css::text::WrapTextMode_PARALLEL:
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText,
+ "bothSides");
+ break;
+ case css::text::WrapTextMode_DYNAMIC:
+ default:
+ m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_wrapSquare, XML_wrapText,
+ "largest");
+ break;
}
}
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 10d38a569e92..22e468d4c65a 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -731,33 +731,33 @@ void RtfAttributeOutput::TableDefaultBorders(
= pRow->GetCells()[pTableTextNodeInfoInner->getCell()].get();
const SwFrameFormat* pCellFormat = pCell->GetBox()->GetFrameFormat();
const SfxPoolItem* pItem;
- if (pCellFormat->GetAttrSet().HasItem(RES_BOX, &pItem))
+ if (!pCellFormat->GetAttrSet().HasItem(RES_BOX, &pItem))
+ return;
+
+ auto& rBox = static_cast<const SvxBoxItem&>(*pItem);
+ static const SvxBoxItemLine aBorders[] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
+ SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT };
+ static const char* aBorderNames[]
+ = { OOO_STRING_SVTOOLS_RTF_CLBRDRT, OOO_STRING_SVTOOLS_RTF_CLBRDRL,
+ OOO_STRING_SVTOOLS_RTF_CLBRDRB, OOO_STRING_SVTOOLS_RTF_CLBRDRR };
+ //Yes left and top are swapped with each other for cell padding! Because
+ //that's what the thundering annoying rtf export/import word xp does.
+ static const char* aCellPadNames[]
+ = { OOO_STRING_SVTOOLS_RTF_CLPADL, OOO_STRING_SVTOOLS_RTF_CLPADT,
+ OOO_STRING_SVTOOLS_RTF_CLPADB, OOO_STRING_SVTOOLS_RTF_CLPADR };
+ static const char* aCellPadUnits[]
+ = { OOO_STRING_SVTOOLS_RTF_CLPADFL, OOO_STRING_SVTOOLS_RTF_CLPADFT,
+ OOO_STRING_SVTOOLS_RTF_CLPADFB, OOO_STRING_SVTOOLS_RTF_CLPADFR };
+ for (int i = 0; i < 4; ++i)
{
- auto& rBox = static_cast<const SvxBoxItem&>(*pItem);
- static const SvxBoxItemLine aBorders[] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
- SvxBoxItemLine::BOTTOM, SvxBoxItemLine::RIGHT };
- static const char* aBorderNames[]
- = { OOO_STRING_SVTOOLS_RTF_CLBRDRT, OOO_STRING_SVTOOLS_RTF_CLBRDRL,
- OOO_STRING_SVTOOLS_RTF_CLBRDRB, OOO_STRING_SVTOOLS_RTF_CLBRDRR };
- //Yes left and top are swapped with each other for cell padding! Because
- //that's what the thundering annoying rtf export/import word xp does.
- static const char* aCellPadNames[]
- = { OOO_STRING_SVTOOLS_RTF_CLPADL, OOO_STRING_SVTOOLS_RTF_CLPADT,
- OOO_STRING_SVTOOLS_RTF_CLPADB, OOO_STRING_SVTOOLS_RTF_CLPADR };
- static const char* aCellPadUnits[]
- = { OOO_STRING_SVTOOLS_RTF_CLPADFL, OOO_STRING_SVTOOLS_RTF_CLPADFT,
- OOO_STRING_SVTOOLS_RTF_CLPADFB, OOO_STRING_SVTOOLS_RTF_CLPADFR };
- for (int i = 0; i < 4; ++i)
+ if (const editeng::SvxBorderLine* pLn = rBox.GetLine(aBorders[i]))
+ m_aRowDefs.append(OutTBLBorderLine(m_rExport, pLn, aBorderNames[i]));
+ if (rBox.GetDistance(aBorders[i]))
{
- if (const editeng::SvxBorderLine* pLn = rBox.GetLine(aBorders[i]))
- m_aRowDefs.append(OutTBLBorderLine(m_rExport, pLn, aBorderNames[i]));
- if (rBox.GetDistance(aBorders[i]))
- {
- m_aRowDefs.append(aCellPadUnits[i]);
- m_aRowDefs.append(sal_Int32(3));
- m_aRowDefs.append(aCellPadNames[i]);
- m_aRowDefs.append(static_cast<sal_Int32>(rBox.GetDistance(aBorders[i])));
- }
+ m_aRowDefs.append(aCellPadUnits[i]);
+ m_aRowDefs.append(sal_Int32(3));
+ m_aRowDefs.append(aCellPadNames[i]);
+ m_aRowDefs.append(static_cast<sal_Int32>(rBox.GetDistance(aBorders[i])));
}
}
}
@@ -817,27 +817,27 @@ void RtfAttributeOutput::TableHeight(ww8::WW8TableNodeInfoInner::Pointer_t pTabl
const SwFrameFormat* pLineFormat = pTabLine->GetFrameFormat();
const SwFormatFrameSize& rLSz = pLineFormat->GetFrameSize();
- if (SwFrameSize::Variable != rLSz.GetHeightSizeType() && rLSz.GetHeight())
- {
- sal_Int32 nHeight = 0;
+ if (!(SwFrameSize::Variable != rLSz.GetHeightSizeType() && rLSz.GetHeight()))
+ return;
- switch (rLSz.GetHeightSizeType())
- {
- case SwFrameSize::Fixed:
- nHeight = -rLSz.GetHeight();
- break;
- case SwFrameSize::Minimum:
- nHeight = rLSz.GetHeight();
- break;
- default:
- break;
- }
+ sal_Int32 nHeight = 0;
- if (nHeight)
- {
- m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRRH);
- m_aRowDefs.append(nHeight);
- }
+ switch (rLSz.GetHeightSizeType())
+ {
+ case SwFrameSize::Fixed:
+ nHeight = -rLSz.GetHeight();
+ break;
+ case SwFrameSize::Minimum:
+ nHeight = rLSz.GetHeight();
+ break;
+ default:
+ break;
+ }
+
+ if (nHeight)
+ {
+ m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRRH);
+ m_aRowDefs.append(nHeight);
}
}
@@ -889,19 +889,21 @@ void RtfAttributeOutput::TableVerticalCell(
m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMRG);
// vertical alignment
- if (pCellFormat->GetAttrSet().HasItem(RES_VERT_ORIENT, &pItem))
- switch (static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient())
- {
- case text::VertOrientation::CENTER:
- m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALC);
- break;
- case text::VertOrientation::BOTTOM:
- m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALB);
- break;
- default:
- m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALT);
- break;
- }
+ if (!pCellFormat->GetAttrSet().HasItem(RES_VERT_ORIENT, &pItem))
+ return;
+
+ switch (static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient())
+ {
+ case text::VertOrientation::CENTER:
+ m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALC);
+ break;
+ case text::VertOrientation::BOTTOM:
+ m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALB);
+ break;
+ default:
+ m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALT);
+ break;
+ }
}
void RtfAttributeOutput::TableNodeInfoInner(ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner)
@@ -1089,26 +1091,26 @@ void RtfAttributeOutput::EndTable()
void RtfAttributeOutput::FinishTableRowCell(const ww8::WW8TableNodeInfoInner::Pointer_t& pInner)
{
- if (pInner)
- {
- // Where are we in the table
- sal_uInt32 nRow = pInner->getRow();
+ if (!pInner)
+ return;
- const SwTable* pTable = pInner->getTable();
- const SwTableLines& rLines = pTable->GetTabLines();
- sal_uInt16 nLinesCount = rLines.size();
+ // Where are we in the table
+ sal_uInt32 nRow = pInner->getRow();
- if (pInner->isEndOfCell())
- EndTableCell();
+ const SwTable* pTable = pInner->getTable();
+ const SwTableLines& rLines = pTable->GetTabLines();
+ sal_uInt16 nLinesCount = rLines.size();
- // This is a line end
- if (pInner->isEndOfLine())
- EndTableRow();
+ if (pInner->isEndOfCell())
+ EndTableCell();
- // This is the end of the table
- if (pInner->isEndOfLine() && (nRow + 1) == nLinesCount)
- EndTable();
- }
+ // This is a line end
+ if (pInner->isEndOfLine())
+ EndTableRow();
+
+ // This is the end of the table
+ if (pInner->isEndOfLine() && (nRow + 1) == nLinesCount)
+ EndTable();
}
void RtfAttributeOutput::StartStyles()
@@ -1858,23 +1860,23 @@ void lcl_TextFrameRelativeSize(std::vector<std::pair<OString, OString>>& rFlyPro
rFlyProperties.emplace_back(std::make_pair("sizerelh", aRelation));
}
const sal_uInt8 nHeightPercent = rSize.GetHeightPercent();
- if (nHeightPercent && nHeightPercent != SwFormatFrameSize::SYNCED)
- {
- rFlyProperties.push_back(
- std::make_pair<OString, OString>("pctVert", OString::number(nHeightPercent * 10)));
+ if (!(nHeightPercent && nHeightPercent != SwFormatFrameSize::SYNCED))
+ return;
- OString aRelation;
- switch (rSize.GetHeightPercentRelation())
- {
- case text::RelOrientation::PAGE_FRAME:
- aRelation = "1"; // page
- break;
- default:
- aRelation = "0"; // margin
- break;
- }
- rFlyProperties.emplace_back(std::make_pair("sizerelv", aRelation));
+ rFlyProperties.push_back(
+ std::make_pair<OString, OString>("pctVert", OString::number(nHeightPercent * 10)));
+
+ OString aRelation;
+ switch (rSize.GetHeightPercentRelation())
+ {
+ case text::RelOrientation::PAGE_FRAME:
+ aRelation = "1"; // page
+ break;
+ default:
+ aRelation = "0"; // margin
+ break;
}
+ rFlyProperties.emplace_back(std::make_pair("sizerelv", aRelation));
}
}
@@ -2730,26 +2732,26 @@ void RtfAttributeOutput::CharEmphasisMark(const SvxEmphasisMarkItem& rEmphasisMa
void RtfAttributeOutput::CharTwoLines(const SvxTwoLinesItem& rTwoLines)
{
- if (rTwoLines.GetValue())
- {
- sal_Unicode cStart = rTwoLines.GetStartBracket();
- sal_Unicode cEnd = rTwoLines.GetEndBracket();
-
- sal_uInt16 nType;
- if (!cStart && !cEnd)
- nType = 0;
- else if ('{' == cStart || '}' == cEnd)
- nType = 4;
- else if ('<' == cStart || '>' == cEnd)
- nType = 3;
- else if ('[' == cStart || ']' == cEnd)
- nType = 2;
- else // all other kind of brackets
- nType = 1;
-
- m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TWOINONE);
- m_aStyles.append(static_cast<sal_Int32>(nType));
- }
+ if (!rTwoLines.GetValue())
+ return;
+
+ sal_Unicode cStart = rTwoLines.GetStartBracket();
+ sal_Unicode cEnd = rTwoLines.GetEndBracket();
+
+ sal_uInt16 nType;
+ if (!cStart && !cEnd)
+ nType = 0;
+ else if ('{' == cStart || '}' == cEnd)
+ nType = 4;
+ else if ('<' == cStart || '>' == cEnd)
+ nType = 3;
+ else if ('[' == cStart || ']' == cEnd)
+ nType = 2;
+ else // all other kind of brackets
+ nType = 1;
+
+ m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TWOINONE);
+ m_aStyles.append(static_cast<sal_Int32>(nType));
}
void RtfAttributeOutput::CharScaleWidth(const SvxCharScaleWidthItem& rScaleWidth)
@@ -2804,18 +2806,18 @@ void RtfAttributeOutput::CharHighlight(const SvxBrushItem& rBrush)
void RtfAttributeOutput::TextINetFormat(const SwFormatINetFormat& rURL)
{
- if (!rURL.GetValue().isEmpty())
- {
- const SwCharFormat* pFormat;
- const SwTextINetFormat* pTextAtr = rURL.GetTextINetFormat();
+ if (rURL.GetValue().isEmpty())
+ return;
- if (pTextAtr && nullptr != (pFormat = pTextAtr->GetCharFormat()))
- {
- sal_uInt16 nStyle = m_rExport.GetId(pFormat);
- OString* pString = m_rExport.GetStyle(nStyle);
- if (pString)
- m_aStyles.append(*pString);
- }
+ const SwCharFormat* pFormat;
+ const SwTextINetFormat* pTextAtr = rURL.GetTextINetFormat();
+
+ if (pTextAtr && nullptr != (pFormat = pTextAtr->GetCharFormat()))
+ {
+ sal_uInt16 nStyle = m_rExport.GetId(pFormat);
+ OString* pString = m_rExport.GetStyle(nStyle);
+ if (pString)
+ m_aStyles.append(*pString);
}
}
@@ -3323,121 +3325,121 @@ void RtfAttributeOutput::FormatSurround(const SwFormatSurround& rSurround)
void RtfAttributeOutput::FormatVertOrientation(const SwFormatVertOrient& rFlyVert)
{
- if (m_rExport.m_bOutFlyFrameAttrs && m_rExport.GetRTFFlySyntax())
+ if (!(m_rExport.m_bOutFlyFrameAttrs && m_rExport.GetRTFFlySyntax()))
+ return;
+
+ switch (rFlyVert.GetRelationOrient())
{
- switch (rFlyVert.GetRelationOrient())
- {
- case text::RelOrientation::PAGE_FRAME:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posrelv", OString::number(1)));
- break;
- default:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posrelv", OString::number(2)));
- m_rExport.Strm()
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBYPARA)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE);
- break;
- }
+ case text::RelOrientation::PAGE_FRAME:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posrelv", OString::number(1)));
+ break;
+ default:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posrelv", OString::number(2)));
+ m_rExport.Strm()
+ .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBYPARA)
+ .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE);
+ break;
+ }
- switch (rFlyVert.GetVertOrient())
- {
- case text::VertOrientation::TOP:
- case text::VertOrientation::LINE_TOP:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posv", OString::number(1)));
- break;
- case text::VertOrientation::BOTTOM:
- case text::VertOrientation::LINE_BOTTOM:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posv", OString::number(3)));
- break;
- case text::VertOrientation::CENTER:
- case text::VertOrientation::LINE_CENTER:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posv", OString::number(2)));
- break;
- default:
- break;
- }
+ switch (rFlyVert.GetVertOrient())
+ {
+ case text::VertOrientation::TOP:
+ case text::VertOrientation::LINE_TOP:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posv", OString::number(1)));
+ break;
+ case text::VertOrientation::BOTTOM:
+ case text::VertOrientation::LINE_BOTTOM:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posv", OString::number(3)));
+ break;
+ case text::VertOrientation::CENTER:
+ case text::VertOrientation::LINE_CENTER:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posv", OString::number(2)));
+ break;
+ default:
+ break;
+ }
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPTOP);
- m_rExport.OutLong(rFlyVert.GetPos());
- if (m_pFlyFrameSize)
- {
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM);
- m_rExport.OutLong(rFlyVert.GetPos() + m_pFlyFrameSize->Height());
- }
+ m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPTOP);
+ m_rExport.OutLong(rFlyVert.GetPos());
+ if (m_pFlyFrameSize)
+ {
+ m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM);
+ m_rExport.OutLong(rFlyVert.GetPos() + m_pFlyFrameSize->Height());
}
}
void RtfAttributeOutput::FormatHorizOrientation(const SwFormatHoriOrient& rFlyHori)
{
- if (m_rExport.m_bOutFlyFrameAttrs && m_rExport.GetRTFFlySyntax())
+ if (!(m_rExport.m_bOutFlyFrameAttrs && m_rExport.GetRTFFlySyntax()))
+ return;
+
+ switch (rFlyHori.GetRelationOrient())
{
- switch (rFlyHori.GetRelationOrient())
- {
- case text::RelOrientation::PAGE_FRAME:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posrelh", OString::number(1)));
- break;
- default:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posrelh", OString::number(2)));
- m_rExport.Strm()
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBXCOLUMN)
- .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBXIGNORE);
- break;
- }
+ case text::RelOrientation::PAGE_FRAME:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posrelh", OString::number(1)));
+ break;
+ default:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posrelh", OString::number(2)));
+ m_rExport.Strm()
+ .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBXCOLUMN)
+ .WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPBXIGNORE);
+ break;
+ }
- switch (rFlyHori.GetHoriOrient())
- {
- case text::HoriOrientation::LEFT:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posh", OString::number(1)));
- break;
- case text::HoriOrientation::CENTER:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posh", OString::number(2)));
- break;
- case text::HoriOrientation::RIGHT:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("posh", OString::number(3)));
- break;
- default:
- break;
- }
+ switch (rFlyHori.GetHoriOrient())
+ {
+ case text::HoriOrientation::LEFT:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posh", OString::number(1)));
+ break;
+ case text::HoriOrientation::CENTER:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posh", OString::number(2)));
+ break;
+ case text::HoriOrientation::RIGHT:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("posh", OString::number(3)));
+ break;
+ default:
+ break;
+ }
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPLEFT);
- m_rExport.OutLong(rFlyHori.GetPos());
- if (m_pFlyFrameSize)
- {
- m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPRIGHT);
- m_rExport.OutLong(rFlyHori.GetPos() + m_pFlyFrameSize->Width());
- }
+ m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPLEFT);
+ m_rExport.OutLong(rFlyHori.GetPos());
+ if (m_pFlyFrameSize)
+ {
+ m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPRIGHT);
+ m_rExport.OutLong(rFlyHori.GetPos() + m_pFlyFrameSize->Width());
}
}
void RtfAttributeOutput::FormatAnchor(const SwFormatAnchor& rAnchor)
{
- if (!m_rExport.GetRTFFlySyntax())
+ if (m_rExport.GetRTFFlySyntax())
+ return;
+
+ RndStdIds eId = rAnchor.GetAnchorId();
+ m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYANCHOR);
+ m_aRunText->append(static_cast<sal_Int32>(eId));
+ switch (eId)
{
- RndStdIds eId = rAnchor.GetAnchorId();
- m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYANCHOR);
- m_aRunText->append(static_cast<sal_Int32>(eId));
- switch (eId)
- {
- case RndStdIds::FLY_AT_PAGE:
- m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYPAGE);
- m_aRunText->append(static_cast<sal_Int32>(rAnchor.GetPageNum()));
- break;
- case RndStdIds::FLY_AT_PARA:
- case RndStdIds::FLY_AS_CHAR:
- m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYCNTNT);
- break;
- default:
- break;
- }
+ case RndStdIds::FLY_AT_PAGE:
+ m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYPAGE);
+ m_aRunText->append(static_cast<sal_Int32>(rAnchor.GetPageNum()));
+ break;
+ case RndStdIds::FLY_AT_PARA:
+ case RndStdIds::FLY_AS_CHAR:
+ m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYCNTNT);
+ break;
+ default:
+ break;
}
}
@@ -3464,35 +3466,35 @@ void RtfAttributeOutput::FormatFillStyle(const XFillStyleItem& rFillStyle)
void RtfAttributeOutput::FormatFillGradient(const XFillGradientItem& rFillGradient)
{
- if (*m_oFillStyle == drawing::FillStyle_GRADIENT)
- {
- m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "fillType", OString::number(7))); // Shade using the fillAngle
+ if (*m_oFillStyle != drawing::FillStyle_GRADIENT)
+ return;
- const XGradient& rGradient = rFillGradient.GetGradientValue();
- const Color& rStartColor = rGradient.GetStartColor();
- m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "fillBackColor", OString::number(wwUtility::RGBToBGR(rStartColor))));
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>(
+ "fillType", OString::number(7))); // Shade using the fillAngle
- const Color& rEndColor = rGradient.GetEndColor();
- m_aFlyProperties.push_back(std::make_pair<OString, OString>(
- "fillColor", OString::number(wwUtility::RGBToBGR(rEndColor))));
+ const XGradient& rGradient = rFillGradient.GetGradientValue();
+ const Color& rStartColor = rGradient.GetStartColor();
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>(
+ "fillBackColor", OString::number(wwUtility::RGBToBGR(rStartColor))));
- switch (rGradient.GetGradientStyle())
- {
- case css::awt::GradientStyle_LINEAR:
- break;
- case css::awt::GradientStyle_AXIAL:
- m_aFlyProperties.push_back(
- std::make_pair<OString, OString>("fillFocus", OString::number(50)));
- break;
- case css::awt::GradientStyle_RADIAL:
- case css::awt::GradientStyle_ELLIPTICAL:
- case css::awt::GradientStyle_SQUARE:
- case css::awt::GradientStyle_RECT:
- default:
- break;
- }
+ const Color& rEndColor = rGradient.GetEndColor();
+ m_aFlyProperties.push_back(std::make_pair<OString, OString>(
+ "fillColor", OString::number(wwUtility::RGBToBGR(rEndColor))));
+
+ switch (rGradient.GetGradientStyle())
+ {
+ case css::awt::GradientStyle_LINEAR:
+ break;
+ case css::awt::GradientStyle_AXIAL:
+ m_aFlyProperties.push_back(
+ std::make_pair<OString, OString>("fillFocus", OString::number(50)));
+ break;
+ case css::awt::GradientStyle_RADIAL:
+ case css::awt::GradientStyle_ELLIPTICAL:
+ case css::awt::GradientStyle_SQUARE:
+ case css::awt::GradientStyle_RECT:
+ default:
+ break;
}
}
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 57ef3730a4d0..71916fd3466f 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -1079,19 +1079,18 @@ SvStream& RtfExport::OutLong(long nVal) { return Writer::OutLong(Strm(), nVal);
void RtfExport::OutUnicode(const char* pToken, const OUString& rContent, bool bUpr)
{
- if (!rContent.isEmpty())
+ if (rContent.isEmpty())
+ return;
+
+ if (!bUpr)
{
- if (!bUpr)
- {
- Strm().WriteChar('{').WriteCharPtr(pToken).WriteChar(' ');
- Strm().WriteCharPtr(
- msfilter::rtfutil::OutString(rContent, m_eCurrentEncoding).getStr());
- Strm().WriteChar('}');
- }
- else
- Strm().WriteCharPtr(
- msfilter::rtfutil::OutStringUpr(pToken, rContent, m_eCurrentEncoding).getStr());
+ Strm().WriteChar('{').WriteCharPtr(pToken).WriteChar(' ');
+ Strm().WriteCharPtr(msfilter::rtfutil::OutString(rContent, m_eCurrentEncoding).getStr());
+ Strm().WriteChar('}');
}
+ else
+ Strm().WriteCharPtr(
+ msfilter::rtfutil::OutStringUpr(pToken, rContent, m_eCurrentEncoding).getStr());
}
void RtfExport::OutDateTime(const char* pStr, const util::DateTime& rDT)
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index e52fa5412dc7..26027a22d57a 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -319,19 +319,19 @@ namespace sw
DrawingOLEAdaptor::~DrawingOLEAdaptor()
{
- if (mxIPRef.is())
- {
- OSL_ENSURE( !mrPers.GetEmbeddedObjectContainer().HasEmbeddedObject( mxIPRef ), "Object in adaptor is inserted?!" );
- try
- {
- mxIPRef->close(true);
- }
- catch ( const css::util::CloseVetoException& )
- {
- }
+ if (!mxIPRef.is())
+ return;
- mxIPRef = nullptr;
+ OSL_ENSURE( !mrPers.GetEmbeddedObjectContainer().HasEmbeddedObject( mxIPRef ), "Object in adaptor is inserted?!" );
+ try
+ {
+ mxIPRef->close(true);
}
+ catch ( const css::util::CloseVetoException& )
+ {
+ }
+
+ mxIPRef = nullptr;
}
}
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index a721682939f9..a34d80d5ffb4 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -276,29 +276,29 @@ void SwBasicEscherEx::PreWriteHyperlinkWithinFly(const SwFrameFormat& rFormat,Es
{
const SfxPoolItem* pItem;
const SwAttrSet& rAttrSet = rFormat.GetAttrSet();
- if (SfxItemState::SET == rAttrSet.GetItemState(RES_URL, true, &pItem))
+ if (SfxItemState::SET != rAttrSet.GetItemState(RES_URL, true, &pItem))
+ return;
+
+ const SwFormatURL *pINetFormat = dynamic_cast<const SwFormatURL*>(pItem);
+ if (!(pINetFormat && !pINetFormat->GetURL().isEmpty()))
+ return;
+
+ SvMemoryStream aStrm;
+ WriteHyperlinkWithinFly( aStrm, pINetFormat );
+ rPropOpt.AddOpt(ESCHER_Prop_pihlShape, true, 0, aStrm);
+ sal_uInt32 nValue;
+ OUString aNamestr = pINetFormat->GetName();
+ if (!aNamestr.isEmpty())
{
- const SwFormatURL *pINetFormat = dynamic_cast<const SwFormatURL*>(pItem);
- if (pINetFormat && !pINetFormat->GetURL().isEmpty())
- {
- SvMemoryStream aStrm;
- WriteHyperlinkWithinFly( aStrm, pINetFormat );
- rPropOpt.AddOpt(ESCHER_Prop_pihlShape, true, 0, aStrm);
- sal_uInt32 nValue;
- OUString aNamestr = pINetFormat->GetName();
- if (!aNamestr.isEmpty())
- {
- rPropOpt.AddOpt(ESCHER_Prop_wzName, aNamestr );
- }
- if(rPropOpt.GetOpt( ESCHER_Prop_fPrint, nValue))
- {
- nValue|=0x03080008;
- rPropOpt.AddOpt(ESCHER_Prop_fPrint, nValue );
- }
- else
- rPropOpt.AddOpt(ESCHER_Prop_fPrint, 0x03080008 );
- }
+ rPropOpt.AddOpt(ESCHER_Prop_wzName, aNamestr );
+ }
+ if(rPropOpt.GetOpt( ESCHER_Prop_fPrint, nValue))
+ {
+ nValue|=0x03080008;
+ rPropOpt.AddOpt(ESCHER_Prop_fPrint, nValue );
}
+ else
+ rPropOpt.AddOpt(ESCHER_Prop_fPrint, 0x03080008 );
}
namespace
@@ -620,234 +620,234 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
sal_uInt32 nFcStart = rWrt.pTableStrm->Tell();
- if (!maDrawObjs.empty())
- {
- // write CPs
- WW8Fib& rFib = *rWrt.pFib;
- WW8_CP nCpOffs = GetCpOffset(rFib);
+ if (maDrawObjs.empty())
+ return;
- for (const auto& rDrawObj : maDrawObjs)
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, rDrawObj.mnCp - nCpOffs);
+ // write CPs
+ WW8Fib& rFib = *rWrt.pFib;
+ WW8_CP nCpOffs = GetCpOffset(rFib);
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, rFib.m_ccpText + rFib.m_ccpFootnote +
- rFib.m_ccpHdr + rFib.m_ccpEdn + rFib.m_ccpTxbx + rFib.m_ccpHdrTxbx + 1);
+ for (const auto& rDrawObj : maDrawObjs)
+ SwWW8Writer::WriteLong(*rWrt.pTableStrm, rDrawObj.mnCp - nCpOffs);
- for (const auto& rDrawObj : maDrawObjs)
- {
- // write the fspa-struct
- const ww8::Frame &rFrameFormat = rDrawObj.maContent;
- const SwFrameFormat &rFormat = rFrameFormat.GetFrameFormat();
- const SdrObject* pObj = rFormat.FindRealSdrObject();
-
- tools::Rectangle aRect;
- SwFormatVertOrient rVOr = rFormat.GetVertOrient();
- SwFormatHoriOrient rHOr = rFormat.GetHoriOrient();
- // #i30669# - convert the positioning attributes.
- // Most positions are converted, if layout information exists.
- const bool bPosConverted =
- WinwordAnchoring::ConvertPosition( rHOr, rVOr, rFormat );
-
- Point aObjPos;
- bool bHasHeightWidthSwapped(false);
- if (RES_FLYFRMFMT == rFormat.Which())
- {
- SwRect aLayRect(rFormat.FindLayoutRect(false, &aObjPos));
- // the Object is not visible - so get the values from
- // the format. The Position may not be correct.
- if( aLayRect.IsEmpty() )
- aRect.SetSize( rFormat.GetFrameSize().GetSize() );
- else
- {
- // #i56090# Do not only consider the first client
- // Note that we actually would have to find the maximum size of the
- // frame format clients. However, this already should work in most cases.
- const SwRect aSizeRect(rFormat.FindLayoutRect());
- if ( aSizeRect.Width() > aLayRect.Width() )
- aLayRect.Width( aSizeRect.Width() );
-
- aRect = aLayRect.SVRect();
- }
- }
- else
- {
- OSL_ENSURE(pObj, "Where is the SDR-Object?");
- if (pObj)
- {
- aRect = pObj->GetLogicRect();
+ SwWW8Writer::WriteLong(*rWrt.pTableStrm, rFib.m_ccpText + rFib.m_ccpFootnote +
+ rFib.m_ccpHdr + rFib.m_ccpEdn + rFib.m_ccpTxbx + rFib.m_ccpHdrTxbx + 1);
- // rotating to vertical means swapping height and width as seen in SvxMSDffManager::ImportShape
- const long nAngle = NormAngle36000( pObj->GetRotateAngle() );
- const bool bAllowSwap = pObj->GetObjIdentifier() != OBJ_LINE && pObj->GetObjIdentifier() != OBJ_GRUP;
- if ( bAllowSwap && (( nAngle > 4500 && nAngle <= 13500 ) || ( nAngle > 22500 && nAngle <= 31500 )) )
- {
- const long nWidth = aRect.getWidth();
- const long nHeight = aRect.getHeight();
- aRect.setWidth( nHeight );
- aRect.setHeight( nWidth );
- bHasHeightWidthSwapped = true;
- }
- }
- }
+ for (const auto& rDrawObj : maDrawObjs)
+ {
+ // write the fspa-struct
+ const ww8::Frame &rFrameFormat = rDrawObj.maContent;
+ const SwFrameFormat &rFormat = rFrameFormat.GetFrameFormat();
+ const SdrObject* pObj = rFormat.FindRealSdrObject();
- // #i30669# - use converted position, if conversion is performed.
- // Unify position determination of Writer fly frames
- // and drawing objects.
- if ( bPosConverted )
- {
- aRect.SetPos( Point( rHOr.GetPos(), rVOr.GetPos() ) );
- }
+ tools::Rectangle aRect;
+ SwFormatVertOrient rVOr = rFormat.GetVertOrient();
+ SwFormatHoriOrient rHOr = rFormat.GetHoriOrient();
+ // #i30669# - convert the positioning attributes.
+ // Most positions are converted, if layout information exists.
+ const bool bPosConverted =
+ WinwordAnchoring::ConvertPosition( rHOr, rVOr, rFormat );
+
+ Point aObjPos;
+ bool bHasHeightWidthSwapped(false);
+ if (RES_FLYFRMFMT == rFormat.Which())
+ {
+ SwRect aLayRect(rFormat.FindLayoutRect(false, &aObjPos));
+ // the Object is not visible - so get the values from
+ // the format. The Position may not be correct.
+ if( aLayRect.IsEmpty() )
+ aRect.SetSize( rFormat.GetFrameSize().GetSize() );
else
{
- aRect -= rDrawObj.maParentPos;
- aObjPos = aRect.TopLeft();
- if (text::VertOrientation::NONE == rVOr.GetVertOrient())
- {
- // #i22673#
- sal_Int16 eOri = rVOr.GetRelationOrient();
- if (eOri == text::RelOrientation::CHAR || eOri == text::RelOrientation::TEXT_LINE)
- aObjPos.setY( -rVOr.GetPos() );
- else
- aObjPos.setY( rVOr.GetPos() );
- }
- if (text::HoriOrientation::NONE == rHOr.GetHoriOrient())
- aObjPos.setX( rHOr.GetPos() );
- aRect.SetPos( aObjPos );
+ // #i56090# Do not only consider the first client
+ // Note that we actually would have to find the maximum size of the
+ // frame format clients. However, this already should work in most cases.
+ const SwRect aSizeRect(rFormat.FindLayoutRect());
+ if ( aSizeRect.Width() > aLayRect.Width() )
+ aLayRect.Width( aSizeRect.Width() );
+
+ aRect = aLayRect.SVRect();
}
-
- sal_Int32 nThick = rDrawObj.mnThick;
-
- //If we are being exported as an inline hack, set
- //corner to 0 and forget about border thickness for positioning
- if (rFrameFormat.IsInline())
+ }
+ else
+ {
+ OSL_ENSURE(pObj, "Where is the SDR-Object?");
+ if (pObj)
{
- aRect.SetPos(Point(0,0));
- nThick = 0;
- }
+ aRect = pObj->GetLogicRect();
- // spid
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, rDrawObj.mnShapeId);
-
- SwTwips nLeft = aRect.Left() + nThick;
- SwTwips nRight = aRect.Right() - nThick;
- SwTwips nTop = aRect.Top() + nThick;
- SwTwips nBottom = aRect.Bottom() - nThick;
-
- // tdf#93675, 0 below line/paragraph and/or top line/paragraph with
- // wrap top+bottom or other wraps is affecting the line directly
- // above the anchor line, which seems odd, but a tiny adjustment
- // here to bring the top down convinces msoffice to wrap like us
- if (nTop == 0 && !rFrameFormat.IsInline() &&
- rVOr.GetVertOrient() == text::VertOrientation::NONE &&
- rVOr.GetRelationOrient() == text::RelOrientation::FRAME)
- {
- nTop = 8;
+ // rotating to vertical means swapping height and width as seen in SvxMSDffManager::ImportShape
+ const long nAngle = NormAngle36000( pObj->GetRotateAngle() );
+ const bool bAllowSwap = pObj->GetObjIdentifier() != OBJ_LINE && pObj->GetObjIdentifier() != OBJ_GRUP;
+ if ( bAllowSwap && (( nAngle > 4500 && nAngle <= 13500 ) || ( nAngle > 22500 && nAngle <= 31500 )) )
+ {
+ const long nWidth = aRect.getWidth();
+ const long nHeight = aRect.getHeight();
+ aRect.setWidth( nHeight );
+ aRect.setHeight( nWidth );
+ bHasHeightWidthSwapped = true;
+ }
}
+ }
- //Nasty swap for bidi if necessary
- rWrt.MiserableRTLFrameFormatHack(nLeft, nRight, rFrameFormat);
-
- // tdf#70838. Word relates the position to the unrotated rectangle,
- // Writer to the rotated one. Because the rotation is around center,
- // the difference counts half.
- if(pObj && pObj->GetRotateAngle())
+ // #i30669# - use converted position, if conversion is performed.
+ // Unify position determination of Writer fly frames
+ // and drawing objects.
+ if ( bPosConverted )
+ {
+ aRect.SetPos( Point( rHOr.GetPos(), rVOr.GetPos() ) );
+ }
+ else
+ {
+ aRect -= rDrawObj.maParentPos;
+ aObjPos = aRect.TopLeft();
+ if (text::VertOrientation::NONE == rVOr.GetVertOrient())
{
- SwTwips nXOff;
- SwTwips nYOff;
- SwTwips nSnapWidth = pObj->GetSnapRect().getWidth();
- SwTwips nSnapHeight = pObj->GetSnapRect().getHeight();
- SwTwips nLogicWidth = pObj->GetLogicRect().getWidth();
- SwTwips nLogicHeight = pObj->GetLogicRect().getHeight();
- // +1 for to compensate integer arithmetic rounding errors
- if(bHasHeightWidthSwapped)
- {
- nXOff = (nSnapWidth - nLogicHeight + 1) / 2;
- nYOff = (nSnapHeight - nLogicWidth + 1) / 2;
- }
+ // #i22673#
+ sal_Int16 eOri = rVOr.GetRelationOrient();
+ if (eOri == text::RelOrientation::CHAR || eOri == text::RelOrientation::TEXT_LINE)
+ aObjPos.setY( -rVOr.GetPos() );
else
- {
- nXOff = (nSnapWidth - nLogicWidth + 1) / 2;
- nYOff = (nSnapHeight - nLogicHeight + 1) / 2;
- }
- nLeft += nXOff;
- nRight += nXOff;
- nTop += nYOff;
- nBottom += nYOff;
+ aObjPos.setY( rVOr.GetPos() );
}
+ if (text::HoriOrientation::NONE == rHOr.GetHoriOrient())
+ aObjPos.setX( rHOr.GetPos() );
+ aRect.SetPos( aObjPos );
+ }
- //xaLeft/yaTop/xaRight/yaBottom - rel. to anchor
- //(most of) the border is outside the graphic is word, so
- //change dimensions to fit
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, nLeft);
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, nTop);
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, nRight);
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, nBottom);
-
- //fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock
- sal_uInt16 nFlags=0;
- //If nFlags isn't 0x14 its overridden by the escher properties
- if (RndStdIds::FLY_AT_PAGE == rFormat.GetAnchor().GetAnchorId())
- nFlags = 0x0000;
- else
- nFlags = 0x0014; // x-rel to text, y-rel to text
+ sal_Int32 nThick = rDrawObj.mnThick;
- const SwFormatSurround& rSurr = rFormat.GetSurround();
- sal_uInt16 nContour = rSurr.IsContour() ? 0x0080 : 0x0040;
- css::text::WrapTextMode eSurround = rSurr.GetSurround();
+ //If we are being exported as an inline hack, set
+ //corner to 0 and forget about border thickness for positioning
+ if (rFrameFormat.IsInline())
+ {
+ aRect.SetPos(Point(0,0));
+ nThick = 0;
+ }
- /*
- #i3958#
- The inline elements being export as anchored to character inside
- the shape field hack are required to be wrap through so as to flow
- over the following dummy 0x01 graphic
- */
- if (rFrameFormat.IsInline())
- eSurround = css::text::WrapTextMode_THROUGH;
+ // spid
+ SwWW8Writer::WriteLong(*rWrt.pTableStrm, rDrawObj.mnShapeId);
+
+ SwTwips nLeft = aRect.Left() + nThick;
+ SwTwips nRight = aRect.Right() - nThick;
+ SwTwips nTop = aRect.Top() + nThick;
+ SwTwips nBottom = aRect.Bottom() - nThick;
+
+ // tdf#93675, 0 below line/paragraph and/or top line/paragraph with
+ // wrap top+bottom or other wraps is affecting the line directly
+ // above the anchor line, which seems odd, but a tiny adjustment
+ // here to bring the top down convinces msoffice to wrap like us
+ if (nTop == 0 && !rFrameFormat.IsInline() &&
+ rVOr.GetVertOrient() == text::VertOrientation::NONE &&
+ rVOr.GetRelationOrient() == text::RelOrientation::FRAME)
+ {
+ nTop = 8;
+ }
- switch (eSurround)
+ //Nasty swap for bidi if necessary
+ rWrt.MiserableRTLFrameFormatHack(nLeft, nRight, rFrameFormat);
+
+ // tdf#70838. Word relates the position to the unrotated rectangle,
+ // Writer to the rotated one. Because the rotation is around center,
+ // the difference counts half.
+ if(pObj && pObj->GetRotateAngle())
+ {
+ SwTwips nXOff;
+ SwTwips nYOff;
+ SwTwips nSnapWidth = pObj->GetSnapRect().getWidth();
+ SwTwips nSnapHeight = pObj->GetSnapRect().getHeight();
+ SwTwips nLogicWidth = pObj->GetLogicRect().getWidth();
+ SwTwips nLogicHeight = pObj->GetLogicRect().getHeight();
+ // +1 for to compensate integer arithmetic rounding errors
+ if(bHasHeightWidthSwapped)
{
- case css::text::WrapTextMode_NONE:
- nFlags |= 0x0020;
- break;
- case css::text::WrapTextMode_THROUGH:
- nFlags |= 0x0060;
- break;
- case css::text::WrapTextMode_PARALLEL:
- nFlags |= 0x0000 | nContour;
- break;
- case css::text::WrapTextMode_DYNAMIC:
- nFlags |= 0x0600 | nContour;
- break;
- case css::text::WrapTextMode_LEFT:
- nFlags |= 0x0200 | nContour;
- break;
- case css::text::WrapTextMode_RIGHT:
- nFlags |= 0x0400 | nContour;
- break;
- default:
- OSL_ENSURE(false, "Unsupported surround type for export");
- break;
+ nXOff = (nSnapWidth - nLogicHeight + 1) / 2;
+ nYOff = (nSnapHeight - nLogicWidth + 1) / 2;
}
- if (pObj && (pObj->GetLayer() == rWrt.m_pDoc->getIDocumentDrawModelAccess().GetHellId() ||
- pObj->GetLayer() == rWrt.m_pDoc->getIDocumentDrawModelAccess().GetInvisibleHellId()))
+ else
{
- nFlags |= 0x4000;
+ nXOff = (nSnapWidth - nLogicWidth + 1) / 2;
+ nYOff = (nSnapHeight - nLogicHeight + 1) / 2;
}
+ nLeft += nXOff;
+ nRight += nXOff;
+ nTop += nYOff;
+ nBottom += nYOff;
+ }
- /*
- #i3958# Required to make this inline stuff work in WordXP, not
- needed for 2003 interestingly
- */
- if (rFrameFormat.IsInline())
- nFlags |= 0x8000;
+ //xaLeft/yaTop/xaRight/yaBottom - rel. to anchor
+ //(most of) the border is outside the graphic is word, so
+ //change dimensions to fit
+ SwWW8Writer::WriteLong(*rWrt.pTableStrm, nLeft);
+ SwWW8Writer::WriteLong(*rWrt.pTableStrm, nTop);
+ SwWW8Writer::WriteLong(*rWrt.pTableStrm, nRight);
+ SwWW8Writer::WriteLong(*rWrt.pTableStrm, nBottom);
+
+ //fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock
+ sal_uInt16 nFlags=0;
+ //If nFlags isn't 0x14 its overridden by the escher properties
+ if (RndStdIds::FLY_AT_PAGE == rFormat.GetAnchor().GetAnchorId())
+ nFlags = 0x0000;
+ else
+ nFlags = 0x0014; // x-rel to text, y-rel to text
- SwWW8Writer::WriteShort(*rWrt.pTableStrm, nFlags);
+ const SwFormatSurround& rSurr = rFormat.GetSurround();
+ sal_uInt16 nContour = rSurr.IsContour() ? 0x0080 : 0x0040;
+ css::text::WrapTextMode eSurround = rSurr.GetSurround();
- // cTxbx
- SwWW8Writer::WriteLong(*rWrt.pTableStrm, 0);
+ /*
+ #i3958#
+ The inline elements being export as anchored to character inside
+ the shape field hack are required to be wrap through so as to flow
+ over the following dummy 0x01 graphic
+ */
+ if (rFrameFormat.IsInline())
+ eSurround = css::text::WrapTextMode_THROUGH;
+
+ switch (eSurround)
+ {
+ case css::text::WrapTextMode_NONE:
+ nFlags |= 0x0020;
+ break;
+ case css::text::WrapTextMode_THROUGH:
+ nFlags |= 0x0060;
+ break;
+ case css::text::WrapTextMode_PARALLEL:
+ nFlags |= 0x0000 | nContour;
+ break;
+ case css::text::WrapTextMode_DYNAMIC:
+ nFlags |= 0x0600 | nContour;
+ break;
+ case css::text::WrapTextMode_LEFT:
+ nFlags |= 0x0200 | nContour;
+ break;
+ case css::text::WrapTextMode_RIGHT:
+ nFlags |= 0x0400 | nContour;
+ break;
+ default:
+ OSL_ENSURE(false, "Unsupported surround type for export");
+ break;
+ }
+ if (pObj && (pObj->GetLayer() == rWrt.m_pDoc->getIDocumentDrawModelAccess().GetHellId() ||
+ pObj->GetLayer() == rWrt.m_pDoc->getIDocumentDrawModelAccess().GetInvisibleHellId()))
+ {
+ nFlags |= 0x4000;
}
- RegisterWithFib(rFib, nFcStart, rWrt.pTableStrm->Tell() - nFcStart);
+ /*
+ #i3958# Required to make this inline stuff work in WordXP, not
+ needed for 2003 interestingly
+ */
+ if (rFrameFormat.IsInline())
+ nFlags |= 0x8000;
+
+ SwWW8Writer::WriteShort(*rWrt.pTableStrm, nFlags);
+
+ // cTxbx
+ SwWW8Writer::WriteLong(*rWrt.pTableStrm, 0);
}
+
+ RegisterWithFib(rFib, nFcStart, rWrt.pTableStrm->Tell() - nFcStart);
}
void MainTextPlcDrawObj::RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
@@ -1135,62 +1135,62 @@ void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos )
OutParaAttr(true, &aUsedRunWhichs);
- if (!aTextAtrArr.empty())
- {
- const SwModify* pOldMod = m_rExport.m_pOutFormatNode;
- m_rExport.m_pOutFormatNode = nullptr;
+ if (aTextAtrArr.empty())
+ return;
+
+ const SwModify* pOldMod = m_rExport.m_pOutFormatNode;
+ m_rExport.m_pOutFormatNode = nullptr;
- const SfxItemPool* pSrcPool = pEditPool;
- const SfxItemPool& rDstPool = m_rExport.m_pDoc->GetAttrPool();
+ const SfxItemPool* pSrcPool = pEditPool;
+ const SfxItemPool& rDstPool = m_rExport.m_pDoc->GetAttrPool();
- nTmpSwPos = nSwPos;
- // Did we already produce a <w:sz> element?
- m_rExport.m_bFontSizeWritten = false;
- for(const auto& rTextAtr : aTextAtrArr)
+ nTmpSwPos = nSwPos;
+ // Did we already produce a <w:sz> element?
+ m_rExport.m_bFontSizeWritten = false;
+ for(const auto& rTextAtr : aTextAtrArr)
+ {
+ if (nSwPos >= rTextAtr.nStart && nSwPos < rTextAtr.nEnd)
{
- if (nSwPos >= rTextAtr.nStart && nSwPos < rTextAtr.nEnd)
+ sal_uInt16 nWhich = rTextAtr.pAttr->Which();
+ if (nWhich == EE_FEATURE_FIELD)
{
- sal_uInt16 nWhich = rTextAtr.pAttr->Which();
- if (nWhich == EE_FEATURE_FIELD)
- {
- OutEEField(*(rTextAtr.pAttr));
- continue;
- }
- if (nWhich == EE_FEATURE_TAB)
- {
- m_rExport.WriteChar(0x9);
- continue;
- }
+ OutEEField(*(rTextAtr.pAttr));
+ continue;
+ }
+ if (nWhich == EE_FEATURE_TAB)
+ {
+ m_rExport.WriteChar(0x9);
+ continue;
+ }
- const sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
- if (nSlotId && nWhich != nSlotId)
+ const sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
+ if (nSlotId && nWhich != nSlotId)
+ {
+ nWhich = rDstPool.GetWhich(nSlotId);
+ if (nWhich && nWhich != nSlotId &&
+ nWhich < RES_UNKNOWNATR_BEGIN &&
+ m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
{
- nWhich = rDstPool.GetWhich(nSlotId);
- if (nWhich && nWhich != nSlotId &&
- nWhich < RES_UNKNOWNATR_BEGIN &&
- m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
- {
- // use always the SW-Which Id !
- std::unique_ptr<SfxPoolItem> pI(rTextAtr.pAttr->Clone());
- pI->SetWhich( nWhich );
- // Will this item produce a <w:sz> element?
- bool bFontSizeItem = nWhich == RES_CHRATR_FONTSIZE || nWhich == RES_CHRATR_CJK_FONTSIZE;
- if (!m_rExport.m_bFontSizeWritten || !bFontSizeItem)
- m_rExport.AttrOutput().OutputItem( *pI );
- if (bFontSizeItem)
- m_rExport.m_bFontSizeWritten = true;
- }
+ // use always the SW-Which Id !
+ std::unique_ptr<SfxPoolItem> pI(rTextAtr.pAttr->Clone());
+ pI->SetWhich( nWhich );
+ // Will this item produce a <w:sz> element?
+ bool bFontSizeItem = nWhich == RES_CHRATR_FONTSIZE || nWhich == RES_CHRATR_CJK_FONTSIZE;
+ if (!m_rExport.m_bFontSizeWritten || !bFontSizeItem)
+ m_rExport.AttrOutput().OutputItem( *pI );
+ if (bFontSizeItem)
+ m_rExport.m_bFontSizeWritten = true;
}
}
-
- if( nSwPos < rTextAtr.nStart )
- break;
}
- m_rExport.m_bFontSizeWritten = false;
- nTmpSwPos = 0; // HasTextItem only allowed in the above area
- m_rExport.m_pOutFormatNode = pOldMod;
+ if( nSwPos < rTextAtr.nStart )
+ break;
}
+ m_rExport.m_bFontSizeWritten = false;
+
+ nTmpSwPos = 0; // HasTextItem only allowed in the above area
+ m_rExport.m_pOutFormatNode = pOldMod;
}
bool MSWord_SdrAttrIter::IsTextAttr(sal_Int32 nSwPos)
@@ -1276,40 +1276,40 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>*
SetItemsThatDifferFromStandard(bCharAttr, aSet);
- if (aSet.Count())
- {
- const SfxItemSet* pOldSet = m_rExport.GetCurItemSet();
- m_rExport.SetCurItemSet( &aSet );
+ if (!aSet.Count())
+ return;
- SfxItemIter aIter( aSet );
- const SfxPoolItem* pItem = aIter.GetCurItem();
+ const SfxItemSet* pOldSet = m_rExport.GetCurItemSet();
+ m_rExport.SetCurItemSet( &aSet );
- const SfxItemPool* pSrcPool = pEditPool,
- * pDstPool = &m_rExport.m_pDoc->GetAttrPool();
+ SfxItemIter aIter( aSet );
+ const SfxPoolItem* pItem = aIter.GetCurItem();
- do
- {
- sal_uInt16 nWhich = pItem->Which();
- if (pWhichsToIgnore && pWhichsToIgnore->find(nWhich) != pWhichsToIgnore->end())
- continue;
+ const SfxItemPool* pSrcPool = pEditPool,
+ * pDstPool = &m_rExport.m_pDoc->GetAttrPool();
- sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
+ do
+ {
+ sal_uInt16 nWhich = pItem->Which();
+ if (pWhichsToIgnore && pWhichsToIgnore->find(nWhich) != pWhichsToIgnore->end())
+ continue;
- if ( nSlotId && nWhich != nSlotId &&
- 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) &&
- nWhich != nSlotId &&
- ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_TXTATR_END )
- : ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END ) ) )
- {
- // use always the SW-Which Id !
- std::unique_ptr<SfxPoolItem> pI(pItem->Clone());
- pI->SetWhich( nWhich );
- if (m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
- m_rExport.AttrOutput().OutputItem(*pI);
- }
- } while ((pItem = aIter.NextItem()));
- m_rExport.SetCurItemSet( pOldSet );
- }
+ sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
+
+ if ( nSlotId && nWhich != nSlotId &&
+ 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) &&
+ nWhich != nSlotId &&
+ ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_TXTATR_END )
+ : ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END ) ) )
+ {
+ // use always the SW-Which Id !
+ std::unique_ptr<SfxPoolItem> pI(pItem->Clone());
+ pI->SetWhich( nWhich );
+ if (m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
+ m_rExport.AttrOutput().OutputItem(*pI);
+ }
+ } while ((pItem = aIter.NextItem()));
+ m_rExport.SetCurItemSet( pOldSet );
}
void WW8Export::WriteSdrTextObj(const SdrTextObj& rTextObj, sal_uInt8 nTyp)
@@ -1428,27 +1428,27 @@ void WinwordAnchoring::WriteData( EscherEx& rEx ) const
{
//Toplevel groups get their winword extra data attached, and sub elements
//use the defaults
- if (rEx.GetGroupLevel() <= 1)
+ if (rEx.GetGroupLevel() > 1)
+ return;
+
+ SvStream& rSt = rEx.GetStream();
+ //The last argument denotes the number of sub properties in this atom
+ if (mbInline)
{
- SvStream& rSt = rEx.GetStream();
- //The last argument denotes the number of sub properties in this atom
- if (mbInline)
- {
- rEx.AddAtom(18, DFF_msofbtUDefProp, 3, 3); //Prop id is 0xF122
- rSt.WriteUInt16( 0x0390 ).WriteUInt32( 3 );
- rSt.WriteUInt16( 0x0392 ).WriteUInt32( 3 );
- //This sub property is required to be in the dummy inline frame as
- //well
- rSt.WriteUInt16( 0x053F ).WriteUInt32( nInlineHack );
- }
- else
- {
- rEx.AddAtom(24, DFF_msofbtUDefProp, 3, 4 ); //Prop id is 0xF122
- rSt.WriteUInt16( 0x038F ).WriteUInt32( mnXAlign );
- rSt.WriteUInt16( 0x0390 ).WriteUInt32( mnXRelTo );
- rSt.WriteUInt16( 0x0391 ).WriteUInt32( mnYAlign );
- rSt.WriteUInt16( 0x0392 ).WriteUInt32( mnYRelTo );
- }
+ rEx.AddAtom(18, DFF_msofbtUDefProp, 3, 3); //Prop id is 0xF122
+ rSt.WriteUInt16( 0x0390 ).WriteUInt32( 3 );
+ rSt.WriteUInt16( 0x0392 ).WriteUInt32( 3 );
+ //This sub property is required to be in the dummy inline frame as
+ //well
+ rSt.WriteUInt16( 0x053F ).WriteUInt32( nInlineHack );
+ }
+ else
+ {
+ rEx.AddAtom(24, DFF_msofbtUDefProp, 3, 4 ); //Prop id is 0xF122
+ rSt.WriteUInt16( 0x038F ).WriteUInt32( mnXAlign );
+ rSt.WriteUInt16( 0x0390 ).WriteUInt32( mnXRelTo );
+ rSt.WriteUInt16( 0x0391 ).WriteUInt32( mnYAlign );
+ rSt.WriteUInt16( 0x0392 ).WriteUInt32( mnYRelTo );
}
}
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 86e884fc8794..2e19f4e5bae6 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -555,45 +555,45 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bWriteCombChars)
void SwWW8AttrIter::handleToggleProperty(SfxItemSet& rExportSet, const SwFormatCharFormat* pCharFormatItem,
sal_uInt16 nWhich, const SfxPoolItem* pValue)
{
- if (!rExportSet.HasItem(nWhich) && pValue)
- {
- bool hasPropertyInCharStyle = false;
- bool hasPropertyInParaStyle = false;
+ if (!(!rExportSet.HasItem(nWhich) && pValue))
+ return;
- // get bold flag from specified character style
- if (pCharFormatItem)
+ bool hasPropertyInCharStyle = false;
+ bool hasPropertyInParaStyle = false;
+
+ // get bold flag from specified character style
+ if (pCharFormatItem)
+ {
+ if (const SwCharFormat* pCharFormat = pCharFormatItem->GetCharFormat())
{
- if (const SwCharFormat* pCharFormat = pCharFormatItem->GetCharFormat())
+ const SfxPoolItem* pItem = nullptr;
+ if (pCharFormat->GetAttrSet().HasItem(nWhich, &pItem))
{
- const SfxPoolItem* pItem = nullptr;
- if (pCharFormat->GetAttrSet().HasItem(nWhich, &pItem))
- {
- hasPropertyInCharStyle = (*pItem == *pValue);
- }
+ hasPropertyInCharStyle = (*pItem == *pValue);
}
}
+ }
- // get bold flag from specified paragraph style
+ // get bold flag from specified paragraph style
+ {
+ SwTextFormatColl& rTextColl = static_cast<SwTextFormatColl&>( rNd.GetAnyFormatColl() );
+ sal_uInt16 nStyle = m_rExport.m_pStyles->GetSlot( &rTextColl );
+ nStyle = ( nStyle != 0xfff ) ? nStyle : 0;
+ const SwFormat* pFormat = m_rExport.m_pStyles->GetSwFormat(nStyle);
+ if (pFormat)
{
- SwTextFormatColl& rTextColl = static_cast<SwTextFormatColl&>( rNd.GetAnyFormatColl() );
- sal_uInt16 nStyle = m_rExport.m_pStyles->GetSlot( &rTextColl );
- nStyle = ( nStyle != 0xfff ) ? nStyle : 0;
- const SwFormat* pFormat = m_rExport.m_pStyles->GetSwFormat(nStyle);
- if (pFormat)
+ const SfxPoolItem* pItem = nullptr;
+ if (pFormat->GetAttrSet().HasItem(nWhich, &pItem))
{
- const SfxPoolItem* pItem = nullptr;
- if (pFormat->GetAttrSet().HasItem(nWhich, &pItem))
- {
- hasPropertyInParaStyle = (*pItem == *pValue);
- }
+ hasPropertyInParaStyle = (*pItem == *pValue);
}
}
+ }
- // add inline property
- if (hasPropertyInCharStyle && hasPropertyInParaStyle)
- {
- rExportSet.Put(*pValue);
- }
+ // add inline property
+ if (hasPropertyInCharStyle && hasPropertyInParaStyle)
+ {
+ rExportSet.Put(*pValue);
}
}
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 2172f2c3e54d..fc973381db09 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -804,19 +804,19 @@ void wwFont::WriteDocx( DocxAttributeOutput* rAttrOutput ) const
{
// no font embedding, panose id, subsetting, ... implemented
- if (!msFamilyNm.isEmpty())
- {
- rAttrOutput->StartFont( msFamilyNm );
+ if (msFamilyNm.isEmpty())
+ return;
- if ( mbAlt )
- rAttrOutput->FontAlternateName( msAltNm );
- rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ), meChrSet );
- rAttrOutput->FontFamilyType( meFamily );
- rAttrOutput->FontPitchType( mePitch );
- rAttrOutput->EmbedFont( msFamilyNm, meFamily, mePitch );
+ rAttrOutput->StartFont( msFamilyNm );
- rAttrOutput->EndFont();
- }
+ if ( mbAlt )
+ rAttrOutput->FontAlternateName( msAltNm );
+ rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ), meChrSet );
+ rAttrOutput->FontFamilyType( meFamily );
+ rAttrOutput->FontPitchType( mePitch );
+ rAttrOutput->EmbedFont( msFamilyNm, meFamily, mePitch );
+
+ rAttrOutput->EndFont();
}
void wwFont::WriteRtf( const RtfAttributeOutput* rAttrOutput ) const
@@ -1478,26 +1478,26 @@ void WW8Export::SetupSectionPositions( WW8_PdAttrDesc* pA )
void WW8AttributeOutput::TextVerticalAdjustment( const drawing::TextVerticalAdjust nVA )
{
- if ( drawing::TextVerticalAdjust_TOP != nVA ) // top alignment is the default
+ if ( drawing::TextVerticalAdjust_TOP == nVA ) // top alignment is the default
+ return;
+
+ sal_uInt8 nMSVA = 0;
+ switch( nVA )
{
- sal_uInt8 nMSVA = 0;
- switch( nVA )
- {
- case drawing::TextVerticalAdjust_CENTER:
- nMSVA = 1;
- break;
- case drawing::TextVerticalAdjust_BOTTOM: //Writer = 2, Word = 3
- nMSVA = 3;
- break;
- case drawing::TextVerticalAdjust_BLOCK: //Writer = 3, Word = 2
- nMSVA = 2;
- break;
- default:
- break;
- }
- SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SVjc::val );
- m_rWW8Export.pO->push_back( nMSVA );
+ case drawing::TextVerticalAdjust_CENTER:
+ nMSVA = 1;
+ break;
+ case drawing::TextVerticalAdjust_BOTTOM: //Writer = 2, Word = 3
+ nMSVA = 3;
+ break;
+ case drawing::TextVerticalAdjust_BLOCK: //Writer = 3, Word = 2
+ nMSVA = 2;
+ break;
+ default:
+ break;
}
+ SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::SVjc::val );
+ m_rWW8Export.pO->push_back( nMSVA );
}
void WW8Export::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 23a5b2c9822c..a0df3f50e248 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -1288,43 +1288,44 @@ void WW8_WrFkp::Write( SvStream& rStrm, SwWW8WrGrf& rGrf )
void WW8_WrFkp::MergeToNew( short& rVarLen, sal_uInt8 *& rpNewSprms )
{
sal_uInt8 nStart = pOfs[ (nIMax-1) * nItemSize ];
- if( nStart )
- { // has Sprms
- sal_uInt8* p = pFkp + ( static_cast<sal_uInt16>(nStart) << 1 );
+ if( !nStart )
+ return;
- // old and new equal? Then copy only one into the new sprms
- if( nOldVarLen == rVarLen && !memcmp( p+1, rpNewSprms, nOldVarLen ))
- {
- sal_uInt8* pNew = new sal_uInt8[ nOldVarLen ];
- memcpy( pNew, p+1, nOldVarLen );
- rpNewSprms = pNew;
- }
- else
- {
- sal_uInt8* pNew = new sal_uInt8[ nOldVarLen + rVarLen ];
- memcpy( pNew, p+1, nOldVarLen );
- memcpy( pNew + nOldVarLen, rpNewSprms, rVarLen );
+// has Sprms
+ sal_uInt8* p = pFkp + ( static_cast<sal_uInt16>(nStart) << 1 );
- rpNewSprms = pNew;
- rVarLen = rVarLen + nOldVarLen;
- }
- --nIMax;
- // if this Sprms don't used from others, remove it
- bool bFnd = false;
- for (sal_uInt16 n = 0; n < nIMax; ++n)
- {
- if (nStart == pOfs[n * nItemSize])
- {
- bFnd = true;
- break;
- }
- }
- if (!bFnd)
+ // old and new equal? Then copy only one into the new sprms
+ if( nOldVarLen == rVarLen && !memcmp( p+1, rpNewSprms, nOldVarLen ))
+ {
+ sal_uInt8* pNew = new sal_uInt8[ nOldVarLen ];
+ memcpy( pNew, p+1, nOldVarLen );
+ rpNewSprms = pNew;
+ }
+ else
+ {
+ sal_uInt8* pNew = new sal_uInt8[ nOldVarLen + rVarLen ];
+ memcpy( pNew, p+1, nOldVarLen );
+ memcpy( pNew + nOldVarLen, rpNewSprms, rVarLen );
+
+ rpNewSprms = pNew;
+ rVarLen = rVarLen + nOldVarLen;
+ }
+ --nIMax;
+ // if this Sprms don't used from others, remove it
+ bool bFnd = false;
+ for (sal_uInt16 n = 0; n < nIMax; ++n)
+ {
+ if (nStart == pOfs[n * nItemSize])
{
- nStartGrp = nOldStartGrp;
- memset( p, 0, nOldVarLen+1 );
+ bFnd = true;
+ break;
}
}
+ if (!bFnd)
+ {
+ nStartGrp = nOldStartGrp;
+ memset( p, 0, nOldVarLen+1 );
+ }
}
WW8_FC WW8_WrFkp::GetStartFc() const
@@ -1438,40 +1439,40 @@ void WW8Export::AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, s
std::vector< const ::sw::mark::IMark* > aArr;
sal_uInt16 nContent;
const sal_Int32 nCurrentEnd = nCurrentPos + nLen;
- if( GetWriter().GetBookmarks( rNd, nCurrentPos, nCurrentEnd, aArr ))
+ if( !GetWriter().GetBookmarks( rNd, nCurrentPos, nCurrentEnd, aArr ))
+ return;
+
+ sal_uLong nNd = rNd.GetIndex(), nSttCP = Fc2Cp( Strm().Tell() );
+ for(const ::sw::mark::IMark* p : aArr)
{
- sal_uLong nNd = rNd.GetIndex(), nSttCP = Fc2Cp( Strm().Tell() );
- for(const ::sw::mark::IMark* p : aArr)
- {
- const ::sw::mark::IMark& rBkmk = *p;
- if(dynamic_cast< const ::sw::mark::IFieldmark *>(&rBkmk))
- continue;
+ const ::sw::mark::IMark& rBkmk = *p;
+ if(dynamic_cast< const ::sw::mark::IFieldmark *>(&rBkmk))
+ continue;
- const SwPosition* pPos = &rBkmk.GetMarkPos();
- const SwPosition* pOPos = nullptr;
- if(rBkmk.IsExpanded())
- pOPos = &rBkmk.GetOtherMarkPos();
- if( pOPos && pOPos->nNode == pPos->nNode &&
- pOPos->nContent < pPos->nContent )
- {
- pPos = pOPos;
- pOPos = &rBkmk.GetMarkPos();
- }
+ const SwPosition* pPos = &rBkmk.GetMarkPos();
+ const SwPosition* pOPos = nullptr;
+ if(rBkmk.IsExpanded())
+ pOPos = &rBkmk.GetOtherMarkPos();
+ if( pOPos && pOPos->nNode == pPos->nNode &&
+ pOPos->nContent < pPos->nContent )
+ {
+ pPos = pOPos;
+ pOPos = &rBkmk.GetMarkPos();
+ }
- if( !pOPos || ( nNd == pPos->nNode.GetIndex() &&
- ( nContent = pPos->nContent.GetIndex() ) >= nCurrentPos &&
- nContent < nCurrentEnd ) )
- {
- sal_uLong nCp = nSttCP + pPos->nContent.GetIndex() - nCurrentPos;
- m_pBkmks->Append(nCp, BookmarkToWord(rBkmk.GetName()));
- }
- if( pOPos && nNd == pOPos->nNode.GetIndex() &&
- ( nContent = pOPos->nContent.GetIndex() ) >= nCurrentPos &&
- nContent < nCurrentEnd )
- {
- sal_uLong nCp = nSttCP + pOPos->nContent.GetIndex() - nCurrentPos;
- m_pBkmks->Append(nCp, BookmarkToWord(rBkmk.GetName()));
- }
+ if( !pOPos || ( nNd == pPos->nNode.GetIndex() &&
+ ( nContent = pPos->nContent.GetIndex() ) >= nCurrentPos &&
+ nContent < nCurrentEnd ) )
+ {
+ sal_uLong nCp = nSttCP + pPos->nContent.GetIndex() - nCurrentPos;
+ m_pBkmks->Append(nCp, BookmarkToWord(rBkmk.GetName()));
+ }
+ if( pOPos && nNd == pOPos->nNode.GetIndex() &&
+ ( nContent = pOPos->nContent.GetIndex() ) >= nCurrentPos &&
+ nContent < nCurrentEnd )
+ {
+ sal_uLong nCp = nSttCP + pOPos->nContent.GetIndex() - nCurrentPos;
+ m_pBkmks->Append(nCp, BookmarkToWord(rBkmk.GetName()));
}
}
}
@@ -1688,22 +1689,22 @@ void WW8Export::WriteAsStringTable(const std::vector<OUString>& rStrings,
sal_Int32& rfcSttbf, sal_Int32& rlcbSttbf)
{
sal_uInt16 n, nCount = static_cast< sal_uInt16 >(rStrings.size());
- if( nCount )
- {
- // we have some Redlines found in the document -> the
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list