summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-30 10:37:55 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-31 11:56:36 +0200
commite42166098b13d1bf4f66291550ab326b750bcbed (patch)
treeeba3259fbc143867cf342ad5579619733b861b94 /sw
parent0024c48b4822062995effed7db4f1281196384bb (diff)
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@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx412
-rw-r--r--sw/source/filter/ww8/docxexport.cxx104
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx38
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx488
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx21
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx22
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx628
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx56
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx58
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx405
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx218
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx1022
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx262
-rw-r--r--sw/source/filter/ww8/ww8par.cxx392
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx497
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx268
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx114
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx323
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx214
19 files changed, 2774 insertions, 2768 deletions
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
- // Author Name Stringtable
- SvStream& rStrm = *pTableStrm;
- rfcSttbf = rStrm.Tell();
- SwWW8Writer::WriteShort( rStrm, -1 );
- SwWW8Writer::WriteLong( rStrm, nCount );
- for( n = 0; n < nCount; ++n )
- {
- const OUString& rNm = rStrings[n];
- SwWW8Writer::WriteShort( rStrm, rNm.getLength() );
- SwWW8Writer::WriteString16(rStrm, rNm, false);
- }
- rlcbSttbf = rStrm.Tell() - rfcSttbf;
+ if( !nCount )
+ return;
+
+ // we have some Redlines found in the document -> the
+ // Author Name Stringtable
+ SvStream& rStrm = *pTableStrm;
+ rfcSttbf = rStrm.Tell();
+ SwWW8Writer::WriteShort( rStrm, -1 );
+ SwWW8Writer::WriteLong( rStrm, nCount );
+ for( n = 0; n < nCount; ++n )
+ {
+ const OUString& rNm = rStrings[n];
+ SwWW8Writer::WriteShort( rStrm, rNm.getLength() );
+ SwWW8Writer::WriteString16(rStrm, rNm, false);
}
+ rlcbSttbf = rStrm.Tell() - rfcSttbf;
}
// WriteShort() sets at FilePos nPos the value nVal and seeks to the old
@@ -2002,19 +2003,19 @@ void WW8AttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pT
{
sal_uInt32 nDepth = pTableTextNodeInfoInner->getDepth();
- if ( nDepth > 0 )
+ if ( nDepth <= 0 )
+ return;
+
+ /* Cell */
+ m_rWW8Export.InsUInt16( NS_sprm::PFInTable::val );
+ m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ m_rWW8Export.InsUInt16( NS_sprm::PItap::val );
+ m_rWW8Export.InsUInt32( nDepth );
+
+ if ( nDepth > 1 && pTableTextNodeInfoInner->isEndOfCell() )
{
- /* Cell */
- m_rWW8Export.InsUInt16( NS_sprm::PFInTable::val );
+ m_rWW8Export.InsUInt16( NS_sprm::PFInnerTableCell::val );
m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
- m_rWW8Export.InsUInt16( NS_sprm::PItap::val );
- m_rWW8Export.InsUInt32( nDepth );
-
- if ( nDepth > 1 && pTableTextNodeInfoInner->isEndOfCell() )
- {
- m_rWW8Export.InsUInt16( NS_sprm::PFInnerTableCell::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
- }
}
}
@@ -2022,47 +2023,47 @@ void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTa
{
sal_uInt32 nDepth = pTableTextNodeInfoInner->getDepth();
- if ( nDepth > 0 )
- {
- /* Row */
- if ( pTableTextNodeInfoInner->isEndOfLine() )
- {
- m_rWW8Export.InsUInt16( NS_sprm::PFInTable::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ if ( nDepth <= 0 )
+ return;
- if ( nDepth == 1 )
- {
- m_rWW8Export.InsUInt16( NS_sprm::PFTtp::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
- }
+ /* Row */
+ if ( !pTableTextNodeInfoInner->isEndOfLine() )
+ return;
- m_rWW8Export.InsUInt16( NS_sprm::PItap::val );
- m_rWW8Export.InsUInt32( nDepth );
+ m_rWW8Export.InsUInt16( NS_sprm::PFInTable::val );
+ m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
- if ( nDepth > 1 )
- {
- m_rWW8Export.InsUInt16( NS_sprm::PFInnerTableCell::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
- m_rWW8Export.InsUInt16( NS_sprm::PFInnerTtp::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
- }
+ if ( nDepth == 1 )
+ {
+ m_rWW8Export.InsUInt16( NS_sprm::PFTtp::val );
+ m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ }
- // Most of these are per-row definitions, not per-table.
- // WW8 has no explicit table start/end markup,
- // simply rows with the same table properties that are grouped together as a table.
- TableBidi( pTableTextNodeInfoInner );
- TableOrientation( pTableTextNodeInfoInner );
- TableSpacing( pTableTextNodeInfoInner );
- TableDefinition( pTableTextNodeInfoInner ); //per row definitions
- TableHeight( pTableTextNodeInfoInner ); //per row definitions
- TableBackgrounds( pTableTextNodeInfoInner ); //per row definitions
- // Since this isEndOfLine, cell margin defaults for each row come from last column.
- TableDefaultBorders( pTableTextNodeInfoInner ); //per row definitions
- TableCanSplit( pTableTextNodeInfoInner ); //per row definitions
- TableVerticalCell( pTableTextNodeInfoInner ); //per row definitions
- TableCellBorders( pTableTextNodeInfoInner ); //per row definitions
- }
+ m_rWW8Export.InsUInt16( NS_sprm::PItap::val );
+ m_rWW8Export.InsUInt32( nDepth );
+
+ if ( nDepth > 1 )
+ {
+ m_rWW8Export.InsUInt16( NS_sprm::PFInnerTableCell::val );
+ m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
+ m_rWW8Export.InsUInt16( NS_sprm::PFInnerTtp::val );
+ m_rWW8Export.pO->push_back( sal_uInt8(0x1) );
}
+
+ // Most of these are per-row definitions, not per-table.
+ // WW8 has no explicit table start/end markup,
+ // simply rows with the same table properties that are grouped together as a table.
+ TableBidi( pTableTextNodeInfoInner );
+ TableOrientation( pTableTextNodeInfoInner );
+ TableSpacing( pTableTextNodeInfoInner );
+ TableDefinition( pTableTextNodeInfoInner ); //per row definitions
+ TableHeight( pTableTextNodeInfoInner ); //per row definitions
+ TableBackgrounds( pTableTextNodeInfoInner ); //per row definitions
+ // Since this isEndOfLine, cell margin defaults for each row come from last column.
+ TableDefaultBorders( pTableTextNodeInfoInner ); //per row definitions
+ TableCanSplit( pTableTextNodeInfoInner ); //per row definitions
+ TableVerticalCell( pTableTextNodeInfoInner ); //per row definitions
+ TableCellBorders( pTableTextNodeInfoInner ); //per row definitions
}
static sal_uInt16 lcl_TCFlags(SwDoc &rDoc, const SwTableBox * pBox, sal_Int32 nRowSpan)
@@ -2234,50 +2235,50 @@ void WW8AttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t
const SwFormatVertOrient &rVert = pFormat->GetVertOrient();
if (
- (text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() ||
+ !((text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() ||
text::RelOrientation::FRAME == rHori.GetRelationOrient())
&&
(text::RelOrientation::PRINT_AREA == rVert.GetRelationOrient() ||
- text::RelOrientation::FRAME == rVert.GetRelationOrient())
+ text::RelOrientation::FRAME == rVert.GetRelationOrient()))
)
+ return;
+
+ const bool bIsRTL = m_rWW8Export.TrueFrameDirection(*pFormat) == SvxFrameDirection::Horizontal_RL_TB;
+ sal_Int16 eHOri = rHori.GetHoriOrient();
+ switch (eHOri)
{
- const bool bIsRTL = m_rWW8Export.TrueFrameDirection(*pFormat) == SvxFrameDirection::Horizontal_RL_TB;
- sal_Int16 eHOri = rHori.GetHoriOrient();
- switch (eHOri)
- {
- case text::HoriOrientation::CENTER:
- m_rWW8Export.InsUInt16( NS_sprm::TJc::val ); //logical orientation required for MSO
- m_rWW8Export.InsUInt16( 1 );
- m_rWW8Export.InsUInt16( NS_sprm::TJc90::val ); //physical orientation required for LO
- m_rWW8Export.InsUInt16( 1 );
- break;
- case text::HoriOrientation::RIGHT:
+ case text::HoriOrientation::CENTER:
+ m_rWW8Export.InsUInt16( NS_sprm::TJc::val ); //logical orientation required for MSO
+ m_rWW8Export.InsUInt16( 1 );
+ m_rWW8Export.InsUInt16( NS_sprm::TJc90::val ); //physical orientation required for LO
+ m_rWW8Export.InsUInt16( 1 );
+ break;
+ case text::HoriOrientation::RIGHT:
+ m_rWW8Export.InsUInt16( NS_sprm::TJc90::val ); //required for LO
+ m_rWW8Export.InsUInt16( 2 );
+ if ( !bIsRTL )
+ {
+ m_rWW8Export.InsUInt16( NS_sprm::TJc::val ); //required for MSO
+ m_rWW8Export.InsUInt16( 2 );
+ }
+ break;
+ case text::HoriOrientation::LEFT:
+ if ( bIsRTL )
+ {
+ m_rWW8Export.InsUInt16( NS_sprm::TJc::val ); //required for MSO
+ m_rWW8Export.InsUInt16( 2 );
+ }
+ break;
+ case text::HoriOrientation::LEFT_AND_WIDTH:
+ // Width can only be specified for the LOGICAL left, so in RTL, that is always PHYSICAL right
+ if ( bIsRTL )
+ {
m_rWW8Export.InsUInt16( NS_sprm::TJc90::val ); //required for LO
m_rWW8Export.InsUInt16( 2 );
- if ( !bIsRTL )
- {
- m_rWW8Export.InsUInt16( NS_sprm::TJc::val ); //required for MSO
- m_rWW8Export.InsUInt16( 2 );
- }
- break;
- case text::HoriOrientation::LEFT:
- if ( bIsRTL )
- {
- m_rWW8Export.InsUInt16( NS_sprm::TJc::val ); //required for MSO
- m_rWW8Export.InsUInt16( 2 );
- }
- break;
- case text::HoriOrientation::LEFT_AND_WIDTH:
- // Width can only be specified for the LOGICAL left, so in RTL, that is always PHYSICAL right
- if ( bIsRTL )
- {
- m_rWW8Export.InsUInt16( NS_sprm::TJc90::val ); //required for LO
- m_rWW8Export.InsUInt16( 2 );
- }
- break;
- default:
- break;
- }
+ }
+ break;
+ default:
+ break;
}
}
@@ -2289,33 +2290,33 @@ void WW8AttributeOutput::TableSpacing(ww8::WW8TableNodeInfoInner::Pointer_t pTab
// Writing these SPRM's will make the table a floating one, so only write
// them in case the table is already inside a frame.
- if (pTableFormat != nullptr && pTable->GetTableNode()->GetFlyFormat())
- {
- const SvxULSpaceItem & rUL = pTableFormat->GetULSpace();
+ if (!(pTableFormat != nullptr && pTable->GetTableNode()->GetFlyFormat()))
+ return;
- if (rUL.GetUpper() > 0)
- {
- sal_uInt8 const nPadding = 2;
- sal_uInt8 const nPcVert = 0;
- sal_uInt8 const nPcHorz = 0;
+ const SvxULSpaceItem & rUL = pTableFormat->GetULSpace();
- sal_uInt8 const nTPc = (nPadding << 4) | (nPcVert << 2) | nPcHorz;
+ if (rUL.GetUpper() > 0)
+ {
+ sal_uInt8 const nPadding = 2;
+ sal_uInt8 const nPcVert = 0;
+ sal_uInt8 const nPcHorz = 0;
- m_rWW8Export.InsUInt16(NS_sprm::TPc::val);
- m_rWW8Export.pO->push_back( nTPc );
+ sal_uInt8 const nTPc = (nPadding << 4) | (nPcVert << 2) | nPcHorz;
- m_rWW8Export.InsUInt16(NS_sprm::TDyaAbs::val);
- m_rWW8Export.InsUInt16(rUL.GetUpper());
+ m_rWW8Export.InsUInt16(NS_sprm::TPc::val);
+ m_rWW8Export.pO->push_back( nTPc );
- m_rWW8Export.InsUInt16(NS_sprm::TDyaFromText::val);
- m_rWW8Export.InsUInt16(rUL.GetUpper());
- }
+ m_rWW8Export.InsUInt16(NS_sprm::TDyaAbs::val);
+ m_rWW8Export.InsUInt16(rUL.GetUpper());
- if (rUL.GetLower() > 0)
- {
- m_rWW8Export.InsUInt16(NS_sprm::TDyaFromTextBottom::val);
- m_rWW8Export.InsUInt16(rUL.GetLower());
- }
+ m_rWW8Export.InsUInt16(NS_sprm::TDyaFromText::val);
+ m_rWW8Export.InsUInt16(rUL.GetUpper());
+ }
+
+ if (rUL.GetLower() > 0)
+ {
+ m_rWW8Export.InsUInt16(NS_sprm::TDyaFromTextBottom::val);
+ m_rWW8Export.InsUInt16(rUL.GetLower());
}
}
@@ -3675,27 +3676,27 @@ void WW8Export::PrepareStorage()
SwDocShell* pDocShell = m_pDoc->GetDocShell ();
OSL_ENSURE(pDocShell, "no SwDocShell");
- if (pDocShell) {
- uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
- pDocShell->GetModel(), uno::UNO_QUERY_THROW);
- uno::Reference<document::XDocumentProperties> xDocProps(
- xDPS->getDocumentProperties());
- OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
+ if (!pDocShell) return;
- if (xDocProps.is())
- {
- if ( SvtFilterOptions::Get().IsEnableWordPreview() )
- {
- std::shared_ptr<GDIMetaFile> xMetaFile =
- pDocShell->GetPreviewMetaFile();
- uno::Sequence<sal_Int8> metaFile(
- sfx2::convertMetaFile(xMetaFile.get()));
- sfx2::SaveOlePropertySet(xDocProps, &GetWriter().GetStorage(), &metaFile);
- }
- else
- sfx2::SaveOlePropertySet( xDocProps, &GetWriter().GetStorage() );
- }
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ pDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps(
+ xDPS->getDocumentProperties());
+ OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
+
+ if (!xDocProps.is())
+ return;
+
+ if ( SvtFilterOptions::Get().IsEnableWordPreview() )
+ {
+ std::shared_ptr<GDIMetaFile> xMetaFile =
+ pDocShell->GetPreviewMetaFile();
+ uno::Sequence<sal_Int8> metaFile(
+ sfx2::convertMetaFile(xMetaFile.get()));
+ sfx2::SaveOlePropertySet(xDocProps, &GetWriter().GetStorage(), &metaFile);
}
+ else
+ sfx2::SaveOlePropertySet( xDocProps, &GetWriter().GetStorage() );
}
ErrCode SwWW8Writer::WriteStorage()
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index 1795ee0ce9ea..3f94e4eb579e 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -211,109 +211,109 @@ void WW8Export::OutputOLENode( const SwOLENode& rOLENode )
tools::SvRef<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
- if( xObjStg.is() )
+ if( !xObjStg.is() )
+ return;
+
+ uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
+ if( !xObj.is() )
+ return;
+
+ const embed::XEmbeddedObject *pObj = xObj.get();
+ //Don't want to use pointer ids, as is traditional, because we need
+ //to put this into a 32bit value, and on 64bit the bottom bits
+ //might collide and two unrelated ole objects end up considered the
+ //same. Don't want to simply start at 0 which is a special value
+ sal_Int32 nPictureId = SAL_MAX_INT32 - m_aOleMap.size();
+ WW8OleMap::value_type entry = std::make_pair(pObj, nPictureId);
+ std::pair<WW8OleMap::iterator, bool> aRes = m_aOleMap.insert(entry);
+ bool bIsNotDuplicate = aRes.second; //.second is false when element already existed
+ nPictureId = aRes.first->second;
+ Set_UInt32(pDataAdr, nPictureId);
+ OUString sStorageName = "_" + OUString::number( nPictureId );
+ tools::SvRef<SotStorage> xOleStg = xObjStg->OpenSotStorage( sStorageName );
+ if( !xOleStg.is() )
+ return;
+
+ /*
+ If this object storage has been written already don't
+ waste time rewriting it
+ */
+ if (bIsNotDuplicate)
{
- uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
- if( xObj.is() )
+ sal_Int64 nAspect = rOLENode.GetAspect();
+ svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
+ m_pOLEExp->ExportOLEObject( aObjRef, *xOleStg );
+ if ( nAspect == embed::Aspects::MSOLE_ICON )
{
- const embed::XEmbeddedObject *pObj = xObj.get();
- //Don't want to use pointer ids, as is traditional, because we need
- //to put this into a 32bit value, and on 64bit the bottom bits
- //might collide and two unrelated ole objects end up considered the
- //same. Don't want to simply start at 0 which is a special value
- sal_Int32 nPictureId = SAL_MAX_INT32 - m_aOleMap.size();
- WW8OleMap::value_type entry = std::make_pair(pObj, nPictureId);
- std::pair<WW8OleMap::iterator, bool> aRes = m_aOleMap.insert(entry);
- bool bIsNotDuplicate = aRes.second; //.second is false when element already existed
- nPictureId = aRes.first->second;
- Set_UInt32(pDataAdr, nPictureId);
- OUString sStorageName = "_" + OUString::number( nPictureId );
- tools::SvRef<SotStorage> xOleStg = xObjStg->OpenSotStorage( sStorageName );
- if( xOleStg.is() )
+ OUString aObjInfo( "\3ObjInfo" );
+ if ( !xOleStg->IsStream( aObjInfo ) )
{
- /*
- If this object storage has been written already don't
- waste time rewriting it
- */
- if (bIsNotDuplicate)
+ const sal_uInt8 pObjInfoData[] = { 0x40, 0x00, 0x03, 0x00 };
+ tools::SvRef<SotStorageStream> rObjInfoStream = xOleStg->OpenSotStream( aObjInfo );
+ if ( rObjInfoStream.is() && !rObjInfoStream->GetError() )
{
- sal_Int64 nAspect = rOLENode.GetAspect();
- svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
- m_pOLEExp->ExportOLEObject( aObjRef, *xOleStg );
- if ( nAspect == embed::Aspects::MSOLE_ICON )
- {
- OUString aObjInfo( "\3ObjInfo" );
- if ( !xOleStg->IsStream( aObjInfo ) )
- {
- const sal_uInt8 pObjInfoData[] = { 0x40, 0x00, 0x03, 0x00 };
- tools::SvRef<SotStorageStream> rObjInfoStream = xOleStg->OpenSotStream( aObjInfo );
- if ( rObjInfoStream.is() && !rObjInfoStream->GetError() )
- {
- rObjInfoStream->WriteBytes(pObjInfoData, sizeof(pObjInfoData));
- xOleStg->Commit();
- }
- }
- }
+ rObjInfoStream->WriteBytes(pObjInfoData, sizeof(pObjInfoData));
+ xOleStg->Commit();
}
+ }
+ }
+ }
- // write as embedded field - the other things will be done
- // in the escher export
- OUString sServer = FieldString(ww::eEMBED) + xOleStg->GetUserName() + " ";
+ // write as embedded field - the other things will be done
+ // in the escher export
+ OUString sServer = FieldString(ww::eEMBED) + xOleStg->GetUserName() + " ";
- OutputField(nullptr, ww::eEMBED, sServer, FieldFlags::Start |
- FieldFlags::CmdStart | FieldFlags::CmdEnd);
+ OutputField(nullptr, ww::eEMBED, sServer, FieldFlags::Start |
+ FieldFlags::CmdStart | FieldFlags::CmdEnd);
- m_pChpPlc->AppendFkpEntry( Strm().Tell(),
- nSize, pSpecOLE );
+ m_pChpPlc->AppendFkpEntry( Strm().Tell(),
+ nSize, pSpecOLE );
- bool bEndCR = true;
- /*
- In the word filter we only need a preview image for
- floating images, and then only (the usual case) if the
- object doesn't contain enough information to reconstruct
- what we need.
+ bool bEndCR = true;
+ /*
+ In the word filter we only need a preview image for
+ floating images, and then only (the usual case) if the
+ object doesn't contain enough information to reconstruct
+ what we need.
- We don't need a graphic for inline objects, so we don't
- even need the overhead of a graphic in that case.
- */
- bool bGraphicNeeded = false;
+ We don't need a graphic for inline objects, so we don't
+ even need the overhead of a graphic in that case.
+ */
+ bool bGraphicNeeded = false;
- if (m_pParentFrame)
- {
- bGraphicNeeded = true;
+ if (m_pParentFrame)
+ {
+ bGraphicNeeded = true;
- if (m_pParentFrame->IsInline())
- {
- const SwAttrSet& rSet =
- m_pParentFrame->GetFrameFormat().GetAttrSet();
- bEndCR = false;
- bGraphicNeeded = TestOleNeedsGraphic(rSet,
- xOleStg, xObjStg, sStorageName, const_cast<SwOLENode*>(&rOLENode));
- }
- }
+ if (m_pParentFrame->IsInline())
+ {
+ const SwAttrSet& rSet =
+ m_pParentFrame->GetFrameFormat().GetAttrSet();
+ bEndCR = false;
+ bGraphicNeeded = TestOleNeedsGraphic(rSet,
+ xOleStg, xObjStg, sStorageName, const_cast<SwOLENode*>(&rOLENode));
+ }
+ }
- if (!bGraphicNeeded)
- WriteChar(0x1);
- else
- {
- /*
- ##897##
- We need to insert the graphic representation of
- this object for the inline case, otherwise word
- has no place to find the dimensions of the ole
- object, and will not be able to draw it
- */
- OutGrf(*m_pParentFrame);
- }
+ if (!bGraphicNeeded)
+ WriteChar(0x1);
+ else
+ {
+ /*
+ ##897##
+ We need to insert the graphic representation of
+ this object for the inline case, otherwise word
+ has no place to find the dimensions of the ole
+ object, and will not be able to draw it
+ */
+ OutGrf(*m_pParentFrame);
+ }
- OutputField(nullptr, ww::eEMBED, OUString(),
- FieldFlags::End | FieldFlags::Close);
+ OutputField(nullptr, ww::eEMBED, OUString(),
+ FieldFlags::End | FieldFlags::Close);
- if (bEndCR) //No newline in inline case
- WriteCR();
- }
- }
- }
+ if (bEndCR) //No newline in inline case
+ WriteCR();
}
void WW8Export::OutputLinkedOLE( const OUString& rOleId )
@@ -324,33 +324,33 @@ void WW8Export::OutputLinkedOLE( const OUString& rOleId )
tools::SvRef<SotStorage> xObjStg = GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool);
- if( xObjStg.is() && xObjSrc.is() )
- {
- tools::SvRef<SotStorage> xOleDst = xObjStg->OpenSotStorage( rOleId );
- if ( xOleDst.is() )
- xObjSrc->CopyTo( xOleDst.get() );
+ if( !(xObjStg.is() && xObjSrc.is()) )
+ return;
- if ( !xOleDst->GetError( ) )
- {
- xOleDst->Commit();
+ tools::SvRef<SotStorage> xOleDst = xObjStg->OpenSotStorage( rOleId );
+ if ( xOleDst.is() )
+ xObjSrc->CopyTo( xOleDst.get() );
- // Output the cPicLocation attribute
- std::unique_ptr<ww::bytes> pBuf( new ww::bytes );
- SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CPicLocation::val );
- SwWW8Writer::InsUInt32( *pBuf, rOleId.copy( 1 ).toInt32() );
+ if ( xOleDst->GetError( ) )
+ return;
- SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CFOle2::val );
- pBuf->push_back( 1 );
+ xOleDst->Commit();
- SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CFSpec::val );
- pBuf->push_back( 1 );
+ // Output the cPicLocation attribute
+ std::unique_ptr<ww::bytes> pBuf( new ww::bytes );
+ SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CPicLocation::val );
+ SwWW8Writer::InsUInt32( *pBuf, rOleId.copy( 1 ).toInt32() );
- SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CFObj::val );
- pBuf->push_back( 1 );
+ SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CFOle2::val );
+ pBuf->push_back( 1 );
- m_pChpPlc->AppendFkpEntry( Strm().Tell(), pBuf->size(), pBuf->data() );
- }
- }
+ SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CFSpec::val );
+ pBuf->push_back( 1 );
+
+ SwWW8Writer::InsUInt16( *pBuf, NS_sprm::CFObj::val );
+ pBuf->push_back( 1 );
+
+ m_pChpPlc->AppendFkpEntry( Strm().Tell(), pBuf->size(), pBuf->data() );
}
void WW8Export::OutGrf(const ww8::Frame &rFrame)
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index b71ec21f0bce..2fa8d29d8807 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -291,67 +291,67 @@ void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16
void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, bool bChpFormat, sal_uInt16 nScript,
bool bExportParentItemSet )
{
- if( bExportParentItemSet || rSet.Count() )
- {
- const SfxPoolItem* pItem;
- m_pISet = &rSet; // for double attributes
+ if( !(bExportParentItemSet || rSet.Count()) )
+ return;
- // If frame dir is set, but not adjust, then force adjust as well
- if ( bPapFormat && SfxItemState::SET == rSet.GetItemState( RES_FRAMEDIR, bExportParentItemSet ) )
+ const SfxPoolItem* pItem;
+ m_pISet = &rSet; // for double attributes
+
+ // If frame dir is set, but not adjust, then force adjust as well
+ if ( bPapFormat && SfxItemState::SET == rSet.GetItemState( RES_FRAMEDIR, bExportParentItemSet ) )
+ {
+ // No explicit adjust set ?
+ if ( SfxItemState::SET != rSet.GetItemState( RES_PARATR_ADJUST, bExportParentItemSet ) )
{
- // No explicit adjust set ?
- if ( SfxItemState::SET != rSet.GetItemState( RES_PARATR_ADJUST, bExportParentItemSet ) )
+ pItem = rSet.GetItem( RES_PARATR_ADJUST, bExportParentItemSet );
+ if ( nullptr != pItem )
{
- pItem = rSet.GetItem( RES_PARATR_ADJUST, bExportParentItemSet );
- if ( nullptr != pItem )
- {
- // then set the adjust used by the parent format
- AttrOutput().OutputItem( *pItem );
- }
+ // then set the adjust used by the parent format
+ AttrOutput().OutputItem( *pItem );
}
}
+ }
+
+ if ( bPapFormat && SfxItemState::SET == rSet.GetItemState( RES_PARATR_NUMRULE, bExportParentItemSet, &pItem ) )
+ {
+ AttrOutput().OutputItem( *pItem );
- if ( bPapFormat && SfxItemState::SET == rSet.GetItemState( RES_PARATR_NUMRULE, bExportParentItemSet, &pItem ) )
+ // switch off the numbering?
+ if ( static_cast<const SwNumRuleItem*>(pItem)->GetValue().isEmpty() &&
+ SfxItemState::SET != rSet.GetItemState( RES_LR_SPACE, false) &&
+ SfxItemState::SET == rSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
{
+ // the set the LR-Space of the parentformat!
AttrOutput().OutputItem( *pItem );
+ }
+ }
- // switch off the numbering?
- if ( static_cast<const SwNumRuleItem*>(pItem)->GetValue().isEmpty() &&
- SfxItemState::SET != rSet.GetItemState( RES_LR_SPACE, false) &&
- SfxItemState::SET == rSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
- {
- // the set the LR-Space of the parentformat!
+ ww8::PoolItems aItems;
+ GetPoolItems( rSet, aItems, bExportParentItemSet );
+ if ( bChpFormat )
+ ExportPoolItemsToCHP(aItems, nScript, nullptr);
+ if ( bPapFormat )
+ {
+ for ( const auto& rItem : aItems )
+ {
+ pItem = rItem.second;
+ sal_uInt16 nWhich = pItem->Which();
+ // Handle fill attributes just like frame attributes for now.
+ if ( (nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END && nWhich != RES_PARATR_NUMRULE ) ||
+ (nWhich >= XATTR_FILL_FIRST && nWhich < XATTR_FILL_LAST))
AttrOutput().OutputItem( *pItem );
- }
}
- ww8::PoolItems aItems;
- GetPoolItems( rSet, aItems, bExportParentItemSet );
- if ( bChpFormat )
- ExportPoolItemsToCHP(aItems, nScript, nullptr);
- if ( bPapFormat )
+ // Has to be called after RES_PARATR_GRABBAG is processed.
+ const XFillStyleItem* pXFillStyleItem(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE));
+ if (pXFillStyleItem && pXFillStyleItem->GetValue() == drawing::FillStyle_SOLID && !rSet.HasItem(RES_BACKGROUND))
{
- for ( const auto& rItem : aItems )
- {
- pItem = rItem.second;
- sal_uInt16 nWhich = pItem->Which();
- // Handle fill attributes just like frame attributes for now.
- if ( (nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END && nWhich != RES_PARATR_NUMRULE ) ||
- (nWhich >= XATTR_FILL_FIRST && nWhich < XATTR_FILL_LAST))
- AttrOutput().OutputItem( *pItem );
- }
-
- // Has to be called after RES_PARATR_GRABBAG is processed.
- const XFillStyleItem* pXFillStyleItem(rSet.GetItem<XFillStyleItem>(XATTR_FILLSTYLE));
- if (pXFillStyleItem && pXFillStyleItem->GetValue() == drawing::FillStyle_SOLID && !rSet.HasItem(RES_BACKGROUND))
- {
- // Construct an SvxBrushItem, as expected by the exporters.
- std::unique_ptr<SvxBrushItem> aBrush(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
- AttrOutput().OutputItem(*aBrush);
- }
+ // Construct an SvxBrushItem, as expected by the exporters.
+ std::unique_ptr<SvxBrushItem> aBrush(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
+ AttrOutput().OutputItem(*aBrush);
}
- m_pISet = nullptr; // for double attributes
}
+ m_pISet = nullptr; // for double attributes
}
void MSWordExportBase::GatherChapterFields()
@@ -649,26 +649,27 @@ void WW8Export::PrepareNewPageDesc( const SfxItemSet*pSet,
void MSWordExportBase::CorrectTabStopInSet( SfxItemSet& rSet, sal_Int32 nAbsLeft )
{
- if (const SvxTabStopItem *pItem = rSet.GetItem<SvxTabStopItem>(RES_PARATR_TABSTOP))
+ const SvxTabStopItem *pItem = rSet.GetItem<SvxTabStopItem>(RES_PARATR_TABSTOP);
+ if (!pItem)
+ return;
+
+ // then it must be corrected for the output
+ SvxTabStopItem aTStop(*pItem);
+ for ( sal_uInt16 nCnt = 0; nCnt < aTStop.Count(); ++nCnt )
{
- // then it must be corrected for the output
- SvxTabStopItem aTStop(*pItem);
- for ( sal_uInt16 nCnt = 0; nCnt < aTStop.Count(); ++nCnt )
+ SvxTabStop& rTab = const_cast<SvxTabStop&>(aTStop[ nCnt ]);
+ if ( SvxTabAdjust::Default != rTab.GetAdjustment() &&
+ rTab.GetTabPos() >= nAbsLeft )
{
- SvxTabStop& rTab = const_cast<SvxTabStop&>(aTStop[ nCnt ]);
- if ( SvxTabAdjust::Default != rTab.GetAdjustment() &&
- rTab.GetTabPos() >= nAbsLeft )
- {
- rTab.GetTabPos() -= nAbsLeft;
- }
- else
- {
- aTStop.Remove( nCnt );
- --nCnt;
- }
+ rTab.GetTabPos() -= nAbsLeft;
+ }
+ else
+ {
+ aTStop.Remove( nCnt );
+ --nCnt;
}
- rSet.Put( aTStop );
}
+ rSet.Put( aTStop );
}
sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
@@ -1331,24 +1332,24 @@ void WW8AttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
break;
}
- if ( nId )
+ if ( !nId )
+ return;
+
+ // use sprmCRgLid0_80 rather than sprmCLid
+ m_rWW8Export.InsUInt16( nId );
+ m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(rLanguage.GetLanguage()) );
+
+ // Word 2000 and above apparently require both old and new versions of
+ // these sprms to be set, without it spellchecking doesn't work
+ if ( nId == NS_sprm::CRgLid0_80::val )
{
- // use sprmCRgLid0_80 rather than sprmCLid
- m_rWW8Export.InsUInt16( nId );
+ m_rWW8Export.InsUInt16( NS_sprm::CRgLid0::val );
+ m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(rLanguage.GetLanguage()) );
+ }
+ else if ( nId == NS_sprm::CRgLid1_80::val )
+ {
+ m_rWW8Export.InsUInt16( NS_sprm::CRgLid1::val );
m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(rLanguage.GetLanguage()) );
-
- // Word 2000 and above apparently require both old and new versions of
- // these sprms to be set, without it spellchecking doesn't work
- if ( nId == NS_sprm::CRgLid0_80::val )
- {
- m_rWW8Export.InsUInt16( NS_sprm::CRgLid0::val );
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(rLanguage.GetLanguage()) );
- }
- else if ( nId == NS_sprm::CRgLid1_80::val )
- {
- m_rWW8Export.InsUInt16( NS_sprm::CRgLid1::val );
- m_rWW8Export.InsUInt16( static_cast<sal_uInt16>(rLanguage.GetLanguage()) );
- }
}
}
@@ -1391,18 +1392,18 @@ void WW8AttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
m_rWW8Export.pO->push_back( b );
}
- if ( 0 == b || 0xFF == b )
- {
- double fHeight = m_rWW8Export.GetItem( RES_CHRATR_FONTSIZE ).GetHeight();
- m_rWW8Export.InsUInt16( NS_sprm::CHpsPos::val );
+ if ( 0 != b && 0xFF != b )
+ return;
- m_rWW8Export.InsUInt16(static_cast<short>( round(fHeight * nEsc / 1000) ));
+ double fHeight = m_rWW8Export.GetItem( RES_CHRATR_FONTSIZE ).GetHeight();
+ m_rWW8Export.InsUInt16( NS_sprm::CHpsPos::val );
- if( 100 != nProp || !b )
- {
- m_rWW8Export.InsUInt16( NS_sprm::CHps::val );
- m_rWW8Export.InsUInt16(msword_cast<sal_uInt16>( round(fHeight * nProp / 1000) ));
- }
+ m_rWW8Export.InsUInt16(static_cast<short>( round(fHeight * nEsc / 1000) ));
+
+ if( 100 != nProp || !b )
+ {
+ m_rWW8Export.InsUInt16( NS_sprm::CHps::val );
+ m_rWW8Export.InsUInt16(msword_cast<sal_uInt16>( round(fHeight * nProp / 1000) ));
}
}
@@ -1482,20 +1483,20 @@ void WW8AttributeOutput::CharRotate( const SvxCharRotateItem& rRotate )
if ( !rRotate.GetValue() )
return;
- if (!m_rWW8Export.IsInTable())
- {
- // #i36867 In word the text in a table is rotated via the TC or NS_sprm::TTextFlow::val
- // This means you can only rotate all or none of the text adding NS_sprm::CFELayout::val
- // here corrupts the table, hence !m_rWW8Export.bIsInTable
+ if (m_rWW8Export.IsInTable())
+ return;
- m_rWW8Export.InsUInt16( NS_sprm::CFELayout::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x06) ); //len 6
- m_rWW8Export.pO->push_back( sal_uInt8(0x01) );
+ // #i36867 In word the text in a table is rotated via the TC or NS_sprm::TTextFlow::val
+ // This means you can only rotate all or none of the text adding NS_sprm::CFELayout::val
+ // here corrupts the table, hence !m_rWW8Export.bIsInTable
- m_rWW8Export.InsUInt16( rRotate.IsFitToLine() ? 1 : 0 );
- static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
- }
+ m_rWW8Export.InsUInt16( NS_sprm::CFELayout::val );
+ m_rWW8Export.pO->push_back( sal_uInt8(0x06) ); //len 6
+ m_rWW8Export.pO->push_back( sal_uInt8(0x01) );
+
+ m_rWW8Export.InsUInt16( rRotate.IsFitToLine() ? 1 : 0 );
+ static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
+ m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
}
void WW8AttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
@@ -1580,23 +1581,23 @@ void WW8AttributeOutput::CharBackground( const SvxBrushItem& rBrush )
void WW8AttributeOutput::TextINetFormat( const SwFormatINetFormat& rINet )
{
- if ( !rINet.GetValue().isEmpty() )
+ if ( rINet.GetValue().isEmpty() )
+ return;
+
+ const sal_uInt16 nId = rINet.GetINetFormatId();
+ const OUString& rStr = rINet.GetINetFormat();
+ if (rStr.isEmpty())
{
- const sal_uInt16 nId = rINet.GetINetFormatId();
- const OUString& rStr = rINet.GetINetFormat();
- if (rStr.isEmpty())
- {
- OSL_ENSURE( false, "WW8AttributeOutput::TextINetFormat(..) - missing unvisited character format at hyperlink attribute" );
- }
+ OSL_ENSURE( false, "WW8AttributeOutput::TextINetFormat(..) - missing unvisited character format at hyperlink attribute" );
+ }
- const SwCharFormat* pFormat = IsPoolUserFormat( nId )
- ? m_rWW8Export.m_pDoc->FindCharFormatByName( rStr )
- : m_rWW8Export.m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
+ const SwCharFormat* pFormat = IsPoolUserFormat( nId )
+ ? m_rWW8Export.m_pDoc->FindCharFormatByName( rStr )
+ : m_rWW8Export.m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
- m_rWW8Export.InsUInt16( NS_sprm::CIstd::val );
+ m_rWW8Export.InsUInt16( NS_sprm::CIstd::val );
- m_rWW8Export.InsUInt16( m_rWW8Export.GetId( pFormat ) );
- }
+ m_rWW8Export.InsUInt16( m_rWW8Export.GetId( pFormat ) );
}
// #i43956# - add optional parameter <pLinkStr>
@@ -1835,25 +1836,25 @@ void WW8Export::OutputField( const SwField* pField, ww::eField eFieldType,
}
}
}
- if (FieldFlags::Close & nMode)
- {
- sal_uInt8 aField15[2] = { 0x15, 0x80 };
+ if (!(FieldFlags::Close & nMode))
+ return;
- if (pField)
+ sal_uInt8 aField15[2] = { 0x15, 0x80 };
+
+ if (pField)
+ {
+ if (pField->GetTyp()->Which() == SwFieldIds::Input &&
+ eFieldType == ww::eFORMTEXT)
{
- if (pField->GetTyp()->Which() == SwFieldIds::Input &&
- eFieldType == ww::eFORMTEXT)
- {
- sal_uInt16 nSubType = pField->GetSubType();
+ sal_uInt16 nSubType = pField->GetSubType();
- if (nSubType == REF_SEQUENCEFLD)
- aField15[0] |= (0x4 << 5);
- }
+ if (nSubType == REF_SEQUENCEFLD)
+ aField15[0] |= (0x4 << 5);
}
-
- pFieldP->Append( Fc2Cp( Strm().Tell() ), aField15 );
- InsertSpecialChar( *this, 0x15, nullptr, bIncludeEmptyPicLocation );
}
+
+ pFieldP->Append( Fc2Cp( Strm().Tell() ), aField15 );
+ InsertSpecialChar( *this, 0x15, nullptr, bIncludeEmptyPicLocation );
}
void WW8Export::StartCommentOutput(const OUString& rName)
@@ -1976,165 +1977,166 @@ void AttributeOutputBase::GenerateBookmarksForSequenceField(const SwTextNode& rN
if(GetExport().GetExportFormat() == MSWordExportBase::ExportFormat::RTF) // Not implemented for RTF
return;
- if (const SwpHints* pTextAttrs = rNode.GetpSwpHints())
+ const SwpHints* pTextAttrs = rNode.GetpSwpHints();
+ if (!pTextAttrs)
+ return;
+
+ for( size_t i = 0; i < pTextAttrs->Count(); ++i )
{
- for( size_t i = 0; i < pTextAttrs->Count(); ++i )
+ const SwTextAttr* pHt = pTextAttrs->Get(i);
+ if (pHt->GetAttr().Which() == RES_TXTATR_FIELD)
{
- const SwTextAttr* pHt = pTextAttrs->Get(i);
- if (pHt->GetAttr().Which() == RES_TXTATR_FIELD)
+ const SwFormatField& rField = static_cast<const SwFormatField&>(pHt->GetAttr());
+ const SwField* pField = rField.GetField();
+ // Need to have bookmarks only for sequence fields
+ if (pField && pField->GetTyp()->Which() == SwFieldIds::SetExp && pField->GetSubType() == nsSwGetSetExpType::GSE_SEQ)
{
- const SwFormatField& rField = static_cast<const SwFormatField&>(pHt->GetAttr());
- const SwField* pField = rField.GetField();
- // Need to have bookmarks only for sequence fields
- if (pField && pField->GetTyp()->Which() == SwFieldIds::SetExp && pField->GetSubType() == nsSwGetSetExpType::GSE_SEQ)
+ const sal_uInt16 nSeqFieldNumber = static_cast<const SwSetExpField*>(pField)->GetSeqNumber();
+ const OUString sObjectName = static_cast<const SwSetExpFieldType*>(pField->GetTyp())->GetName();
+ const SwFieldTypes* pFieldTypes = GetExport().m_pDoc->getIDocumentFieldsAccess().GetFieldTypes();
+ bool bHaveFullBkm = false;
+ bool bHaveLabelAndNumberBkm = false;
+ bool bHaveCaptionOnlyBkm = false;
+ bool bHaveNumberOnlyBkm = false;
+ bool bRunSplittedAtSep = false;
+ for( auto const & pFieldType : *pFieldTypes )
{
- const sal_uInt16 nSeqFieldNumber = static_cast<const SwSetExpField*>(pField)->GetSeqNumber();
- const OUString sObjectName = static_cast<const SwSetExpFieldType*>(pField->GetTyp())->GetName();
- const SwFieldTypes* pFieldTypes = GetExport().m_pDoc->getIDocumentFieldsAccess().GetFieldTypes();
- bool bHaveFullBkm = false;
- bool bHaveLabelAndNumberBkm = false;
- bool bHaveCaptionOnlyBkm = false;
- bool bHaveNumberOnlyBkm = false;
- bool bRunSplittedAtSep = false;
- for( auto const & pFieldType : *pFieldTypes )
+ if( SwFieldIds::GetRef == pFieldType->Which() )
{
- if( SwFieldIds::GetRef == pFieldType->Which() )
+ SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
+ for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
{
- SwIterator<SwFormatField,SwFieldType> aIter( *pFieldType );
- for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
+ SwGetRefField* pRefField = static_cast<SwGetRefField*>(pFormatField->GetField());
+ // If we have a reference to the current sequence field
+ if(pRefField->GetSeqNo() == nSeqFieldNumber && pRefField->GetSetRefName() == sObjectName)
{
- SwGetRefField* pRefField = static_cast<SwGetRefField*>(pFormatField->GetField());
- // If we have a reference to the current sequence field
- if(pRefField->GetSeqNo() == nSeqFieldNumber && pRefField->GetSetRefName() == sObjectName)
+ // Need to create a separate run for separator character
+ SwWW8AttrIter aLocalAttrIter( GetExport(), rNode ); // We need a local iterator having the right number of runs
+ const OUString& aText = rNode.GetText();
+ const sal_Int32 nCategoryStart = aText.indexOf(pRefField->GetSetRefName());
+ const sal_Int32 nPosBeforeSeparator = std::max(nCategoryStart, pHt->GetStart());
+ bool bCategoryFirst = nCategoryStart < pHt->GetStart();
+ sal_Int32 nSeparatorPos = 0;
+ if (bCategoryFirst)
{
- // Need to create a separate run for separator character
- SwWW8AttrIter aLocalAttrIter( GetExport(), rNode ); // We need a local iterator having the right number of runs
- const OUString& aText = rNode.GetText();
- const sal_Int32 nCategoryStart = aText.indexOf(pRefField->GetSetRefName());
- const sal_Int32 nPosBeforeSeparator = std::max(nCategoryStart, pHt->GetStart());
- bool bCategoryFirst = nCategoryStart < pHt->GetStart();
- sal_Int32 nSeparatorPos = 0;
- if (bCategoryFirst)
+ nSeparatorPos = aLocalAttrIter.WhereNext();
+ while (nSeparatorPos <= nPosBeforeSeparator)
{
+ aLocalAttrIter.NextPos();
nSeparatorPos = aLocalAttrIter.WhereNext();
- while (nSeparatorPos <= nPosBeforeSeparator)
- {
- aLocalAttrIter.NextPos();
- nSeparatorPos = aLocalAttrIter.WhereNext();
- }
}
- else
+ }
+ else
+ {
+ nSeparatorPos = nCategoryStart + pRefField->GetSetRefName().getLength();
+ }
+ sal_Int32 nRefTextPos = 0;
+ if(nSeparatorPos < aText.getLength())
+ {
+ nRefTextPos = SwGetExpField::GetReferenceTextPos(pHt->GetFormatField(), *GetExport().m_pDoc, nSeparatorPos);
+ if(nRefTextPos != nSeparatorPos)
{
- nSeparatorPos = nCategoryStart + pRefField->GetSetRefName().getLength();
+ if(!bRunSplittedAtSep)
+ {
+ if(!bCategoryFirst)
+ rAttrIter.SplitRun(nSeparatorPos);
+ rAttrIter.SplitRun(nRefTextPos);
+ bRunSplittedAtSep = true;
+ }
+ if(!bCategoryFirst)
+ aLocalAttrIter.SplitRun(nSeparatorPos);
+ aLocalAttrIter.SplitRun(nRefTextPos);
}
- sal_Int32 nRefTextPos = 0;
- if(nSeparatorPos < aText.getLength())
+ else if (bCategoryFirst)
{
- nRefTextPos = SwGetExpField::GetReferenceTextPos(pHt->GetFormatField(), *GetExport().m_pDoc, nSeparatorPos);
- if(nRefTextPos != nSeparatorPos)
+ if(!bRunSplittedAtSep)
{
- if(!bRunSplittedAtSep)
- {
- if(!bCategoryFirst)
- rAttrIter.SplitRun(nSeparatorPos);
- rAttrIter.SplitRun(nRefTextPos);
- bRunSplittedAtSep = true;
- }
- if(!bCategoryFirst)
- aLocalAttrIter.SplitRun(nSeparatorPos);
- aLocalAttrIter.SplitRun(nRefTextPos);
+ rAttrIter.SplitRun(nSeparatorPos);
+ bRunSplittedAtSep = true;
}
- else if (bCategoryFirst)
+ aLocalAttrIter.SplitRun(nSeparatorPos);
+ }
+ }
+ // Generate bookmarks on the right position
+ OUString sName("Ref_" + pRefField->GetSetRefName() + OUString::number(pRefField->GetSeqNo()));
+ switch (pRefField->GetFormat())
+ {
+ case REF_PAGE:
+ case REF_PAGE_PGDESC:
+ case REF_CONTENT:
+ case REF_UPDOWN:
+ if(!bHaveFullBkm)
{
- if(!bRunSplittedAtSep)
+ sal_Int32 nLastAttrStart = 0;
+ sal_Int32 nActAttr = aLocalAttrIter.WhereNext();
+ while (nActAttr < rNode.GetText().getLength())
{
- rAttrIter.SplitRun(nSeparatorPos);
- bRunSplittedAtSep = true;
+ nLastAttrStart = nActAttr;
+ aLocalAttrIter.NextPos();
+ nActAttr = aLocalAttrIter.WhereNext();
}
- aLocalAttrIter.SplitRun(nSeparatorPos);
+ WriteBookmarkInActParagraph( sName + "_full", std::min(nCategoryStart, pHt->GetStart()), nLastAttrStart );
+ bHaveFullBkm = true;
}
- }
- // Generate bookmarks on the right position
- OUString sName("Ref_" + pRefField->GetSetRefName() + OUString::number(pRefField->GetSeqNo()));
- switch (pRefField->GetFormat())
+ break;
+ case REF_ONLYNUMBER:
{
- case REF_PAGE:
- case REF_PAGE_PGDESC:
- case REF_CONTENT:
- case REF_UPDOWN:
- if(!bHaveFullBkm)
- {
- sal_Int32 nLastAttrStart = 0;
- sal_Int32 nActAttr = aLocalAttrIter.WhereNext();
- while (nActAttr < rNode.GetText().getLength())
- {
- nLastAttrStart = nActAttr;
- aLocalAttrIter.NextPos();
- nActAttr = aLocalAttrIter.WhereNext();
- }
- WriteBookmarkInActParagraph( sName + "_full", std::min(nCategoryStart, pHt->GetStart()), nLastAttrStart );
- bHaveFullBkm = true;
- }
- break;
- case REF_ONLYNUMBER:
+ if(!bHaveLabelAndNumberBkm)
{
- if(!bHaveLabelAndNumberBkm)
+ sName += "_label_and_number";
+ if(bCategoryFirst)
+ WriteBookmarkInActParagraph( sName, std::min(nCategoryStart, pHt->GetStart()), std::max(nCategoryStart, pHt->GetStart()) );
+ else
{
- sName += "_label_and_number";
- if(bCategoryFirst)
- WriteBookmarkInActParagraph( sName, std::min(nCategoryStart, pHt->GetStart()), std::max(nCategoryStart, pHt->GetStart()) );
- else
+ // Find the last run which contains category text
+ SwWW8AttrIter aLocalAttrIter2( GetExport(), rNode );
+ sal_Int32 nCatLastRun = 0;
+ sal_Int32 nNextAttr = aLocalAttrIter2.WhereNext();
+ while (nNextAttr < nSeparatorPos)
{
- // Find the last run which contains category text
- SwWW8AttrIter aLocalAttrIter2( GetExport(), rNode );
- sal_Int32 nCatLastRun = 0;
- sal_Int32 nNextAttr = aLocalAttrIter2.WhereNext();
- while (nNextAttr < nSeparatorPos)
- {
- nCatLastRun = nNextAttr;
- aLocalAttrIter2.NextPos();
- nNextAttr = aLocalAttrIter2.WhereNext();
- }
- WriteBookmarkInActParagraph( sName, pHt->GetStart(), nCatLastRun );
+ nCatLastRun = nNextAttr;
+ aLocalAttrIter2.NextPos();
+ nNextAttr = aLocalAttrIter2.WhereNext();
}
- bHaveLabelAndNumberBkm = true;
+ WriteBookmarkInActParagraph( sName, pHt->GetStart(), nCatLastRun );
}
- break;
+ bHaveLabelAndNumberBkm = true;
}
- case REF_ONLYCAPTION:
+ break;
+ }
+ case REF_ONLYCAPTION:
+ {
+ if(!bHaveCaptionOnlyBkm)
{
- if(!bHaveCaptionOnlyBkm)
+ // Find last run
+ sal_Int32 nLastAttrStart = 0;
+ sal_Int32 nActAttr = aLocalAttrIter.WhereNext();
+ while (nActAttr < rNode.GetText().getLength())
{
- // Find last run
- sal_Int32 nLastAttrStart = 0;
- sal_Int32 nActAttr = aLocalAttrIter.WhereNext();
- while (nActAttr < rNode.GetText().getLength())
- {
- nLastAttrStart = nActAttr;
- aLocalAttrIter.NextPos();
- nActAttr = aLocalAttrIter.WhereNext();
- }
- WriteBookmarkInActParagraph( sName + "_caption_only", nRefTextPos, nLastAttrStart );
- bHaveCaptionOnlyBkm = true;
+ nLastAttrStart = nActAttr;
+ aLocalAttrIter.NextPos();
+ nActAttr = aLocalAttrIter.WhereNext();
}
- break;
+ WriteBookmarkInActParagraph( sName + "_caption_only", nRefTextPos, nLastAttrStart );
+ bHaveCaptionOnlyBkm = true;
}
- case REF_ONLYSEQNO:
+ break;
+ }
+ case REF_ONLYSEQNO:
+ {
+ if(!bHaveNumberOnlyBkm)
{
- if(!bHaveNumberOnlyBkm)
- {
- WriteBookmarkInActParagraph( sName + "_number_only", pHt->GetStart(), pHt->GetStart() );
- bHaveNumberOnlyBkm = true;
- }
- break;
+ WriteBookmarkInActParagraph( sName + "_number_only", pHt->GetStart(), pHt->GetStart() );
+ bHaveNumberOnlyBkm = true;
}
+ break;
}
}
}
}
}
- return;
}
+ return;
}
}
}
@@ -3478,44 +3480,44 @@ void WW8AttributeOutput::TextCharFormat( const SwFormatCharFormat& rCharFormat )
void WW8AttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
{
// #i28331# - check that bOn is set
- if ( rTwoLines.GetValue() )
- {
- m_rWW8Export.InsUInt16( NS_sprm::CFELayout::val );
- m_rWW8Export.pO->push_back( sal_uInt8(0x06) ); //len 6
- m_rWW8Export.pO->push_back( sal_uInt8(0x02) );
+ if ( !rTwoLines.GetValue() )
+ return;
- sal_Unicode cStart = rTwoLines.GetStartBracket();
- sal_Unicode cEnd = rTwoLines.GetEndBracket();
+ m_rWW8Export.InsUInt16( NS_sprm::CFELayout::val );
+ m_rWW8Export.pO->push_back( sal_uInt8(0x06) ); //len 6
+ m_rWW8Export.pO->push_back( sal_uInt8(0x02) );
- /*
- As per usual we have problems. We can have separate left and right brackets
- in OOo, it doesn't appear that you can in word. Also in word there appear
- to only be a limited number of possibilities, we can use pretty much
- anything.
+ sal_Unicode cStart = rTwoLines.GetStartBracket();
+ sal_Unicode cEnd = rTwoLines.GetEndBracket();
- So if we have none, we export none, if either bracket is set to a known
- word type we export both as that type (with the bracket winning out in
- the case of a conflict simply being the order of test here.
+ /*
+ As per usual we have problems. We can have separate left and right brackets
+ in OOo, it doesn't appear that you can in word. Also in word there appear
+ to only be a limited number of possibilities, we can use pretty much
+ anything.
- Upshot being a documented created in word will be reexported with no
- ill effects.
- */
+ So if we have none, we export none, if either bracket is set to a known
+ word type we export both as that type (with the bracket winning out in
+ the case of a conflict simply being the order of test here.
- 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
- nType = 1;
- m_rWW8Export.InsUInt16( nType );
- static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
- m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
- }
+ Upshot being a documented created in word will be reexported with no
+ ill effects.
+ */
+
+ 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
+ nType = 1;
+ m_rWW8Export.InsUInt16( nType );
+ static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
+ m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
}
void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
@@ -3920,59 +3922,59 @@ sal_uInt32 AttributeOutputBase::GridCharacterPitch( const SwTextGridItem& rGrid
void WW8AttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
{
- if (m_rWW8Export.m_bOutPageDescs)
+ if (!m_rWW8Export.m_bOutPageDescs)
+ return;
+
+ sal_uInt16 nGridType = 0;
+ switch ( rGrid.GetGridType() )
{
- sal_uInt16 nGridType = 0;
- switch ( rGrid.GetGridType() )
- {
- default:
- OSL_FAIL("Unknown grid type");
- [[fallthrough]];
- case GRID_NONE:
- nGridType = 0;
- break;
- case GRID_LINES_ONLY:
- nGridType = 2;
- break;
- case GRID_LINES_CHARS:
- if ( rGrid.IsSnapToChars() )
- nGridType = 3;
- else
- nGridType = 1;
- break;
- }
- m_rWW8Export.InsUInt16( NS_sprm::SClm::val );
- m_rWW8Export.InsUInt16( nGridType );
+ default:
+ OSL_FAIL("Unknown grid type");
+ [[fallthrough]];
+ case GRID_NONE:
+ nGridType = 0;
+ break;
+ case GRID_LINES_ONLY:
+ nGridType = 2;
+ break;
+ case GRID_LINES_CHARS:
+ if ( rGrid.IsSnapToChars() )
+ nGridType = 3;
+ else
+ nGridType = 1;
+ break;
+ }
+ m_rWW8Export.InsUInt16( NS_sprm::SClm::val );
+ m_rWW8Export.InsUInt16( nGridType );
- sal_uInt16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight();
- m_rWW8Export.InsUInt16( NS_sprm::SDyaLinePitch::val );
- m_rWW8Export.InsUInt16( nHeight );
+ sal_uInt16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight();
+ m_rWW8Export.InsUInt16( NS_sprm::SDyaLinePitch::val );
+ m_rWW8Export.InsUInt16( nHeight );
- m_rWW8Export.InsUInt16( NS_sprm::SDxtCharSpace::val );
- m_rWW8Export.InsUInt32( GridCharacterPitch( rGrid ) );
- }
+ m_rWW8Export.InsUInt16( NS_sprm::SDxtCharSpace::val );
+ m_rWW8Export.InsUInt32( GridCharacterPitch( rGrid ) );
}
void WW8AttributeOutput::FormatPaperBin( const SvxPaperBinItem& rPaperBin )
{
- if ( m_rWW8Export.m_bOutPageDescs )
+ if ( !m_rWW8Export.m_bOutPageDescs )
+ return;
+
+ sal_uInt16 nVal;
+ switch ( rPaperBin.GetValue() )
{
- sal_uInt16 nVal;
- switch ( rPaperBin.GetValue() )
- {
- case 0: nVal = 15; break; // Automatically select
- case 1: nVal = 1; break; // Upper paper tray
- case 2: nVal = 4; break; // Manual paper feed
- default: nVal = 0; break;
- }
+ case 0: nVal = 15; break; // Automatically select
+ case 1: nVal = 1; break; // Upper paper tray
+ case 2: nVal = 4; break; // Manual paper feed
+ default: nVal = 0; break;
+ }
- if ( nVal )
- {
- m_rWW8Export.InsUInt16( m_rWW8Export.m_bOutFirstPage
- ? NS_sprm::SDmBinFirst::val : NS_sprm::SDmBinOther::val );
+ if ( nVal )
+ {
+ m_rWW8Export.InsUInt16( m_rWW8Export.m_bOutFirstPage
+ ? NS_sprm::SDmBinFirst::val : NS_sprm::SDmBinOther::val );
- m_rWW8Export.InsUInt16( nVal );
- }
+ m_rWW8Export.InsUInt16( nVal );
}
}
@@ -4102,33 +4104,33 @@ void WW8AttributeOutput::FormatVertOrientation( const SwFormatVertOrient& rFlyVe
{
//!!!! anchor type and corresponding borders are still missing
- if ( m_rWW8Export.m_bOutFlyFrameAttrs )
- {
- short nPos;
- switch( rFlyVert.GetVertOrient() )
- {
- case text::VertOrientation::NONE:
- nPos = static_cast<short>(rFlyVert.GetPos());
- break;
- case text::VertOrientation::CENTER:
- case text::VertOrientation::LINE_CENTER:
- nPos = -8;
- break;
- case text::VertOrientation::BOTTOM:
- case text::VertOrientation::LINE_BOTTOM:
- nPos = -12;
- break;
- case text::VertOrientation::TOP:
- case text::VertOrientation::LINE_TOP:
- default:
- nPos = -4;
- break;
- }
+ if ( !m_rWW8Export.m_bOutFlyFrameAttrs )
+ return;
- // sprmPDyaAbs
- m_rWW8Export.InsUInt16( NS_sprm::PDyaAbs::val );
- m_rWW8Export.InsUInt16( nPos );
+ short nPos;
+ switch( rFlyVert.GetVertOrient() )
+ {
+ case text::VertOrientation::NONE:
+ nPos = static_cast<short>(rFlyVert.GetPos());
+ break;
+ case text::VertOrientation::CENTER:
+ case text::VertOrientation::LINE_CENTER:
+ nPos = -8;
+ break;
+ case text::VertOrientation::BOTTOM:
+ case text::VertOrientation::LINE_BOTTOM:
+ nPos = -12;
+ break;
+ case text::VertOrientation::TOP:
+ case text::VertOrientation::LINE_TOP:
+ default:
+ nPos = -4;
+ break;
}
+
+ // sprmPDyaAbs
+ m_rWW8Export.InsUInt16( NS_sprm::PDyaAbs::val );
+ m_rWW8Export.InsUInt16( nPos );
}
void WW8AttributeOutput::FormatHorizOrientation( const SwFormatHoriOrient& rFlyHori )
@@ -4140,105 +4142,105 @@ void WW8AttributeOutput::FormatHorizOrientation( const SwFormatHoriOrient& rFlyH
}
//!!!! anchor type and corresponding borders are still missing
- if ( m_rWW8Export.m_bOutFlyFrameAttrs )
- {
- short nPos;
- switch( rFlyHori.GetHoriOrient() )
- {
- case text::HoriOrientation::NONE:
- nPos = static_cast<short>(rFlyHori.GetPos());
- if( !nPos )
- nPos = 1; // WW: 0 is reserved
- break;
- case text::HoriOrientation::LEFT:
- nPos = rFlyHori.IsPosToggle() ? -12 : 0;
- break;
- case text::HoriOrientation::RIGHT:
- nPos = rFlyHori.IsPosToggle() ? -16 : -8;
- break;
- case text::HoriOrientation::CENTER:
- case text::HoriOrientation::FULL: // FULL only for tables
- default:
- nPos = -4;
- break;
- }
+ if ( !m_rWW8Export.m_bOutFlyFrameAttrs )
+ return;
- // sprmPDxaAbs
- m_rWW8Export.InsUInt16( NS_sprm::PDxaAbs::val );
- m_rWW8Export.InsUInt16( nPos );
+ short nPos;
+ switch( rFlyHori.GetHoriOrient() )
+ {
+ case text::HoriOrientation::NONE:
+ nPos = static_cast<short>(rFlyHori.GetPos());
+ if( !nPos )
+ nPos = 1; // WW: 0 is reserved
+ break;
+ case text::HoriOrientation::LEFT:
+ nPos = rFlyHori.IsPosToggle() ? -12 : 0;
+ break;
+ case text::HoriOrientation::RIGHT:
+ nPos = rFlyHori.IsPosToggle() ? -16 : -8;
+ break;
+ case text::HoriOrientation::CENTER:
+ case text::HoriOrientation::FULL: // FULL only for tables
+ default:
+ nPos = -4;
+ break;
}
+
+ // sprmPDxaAbs
+ m_rWW8Export.InsUInt16( NS_sprm::PDxaAbs::val );
+ m_rWW8Export.InsUInt16( nPos );
}
void WW8AttributeOutput::FormatAnchor( const SwFormatAnchor& rAnchor )
{
OSL_ENSURE( m_rWW8Export.m_pParentFrame, "Anchor without mpParentFrame !!" );
- if ( m_rWW8Export.m_bOutFlyFrameAttrs )
- {
- sal_uInt8 nP = 0;
- switch ( rAnchor.GetAnchorId() )
- {
- case RndStdIds::FLY_AT_PAGE:
- // vertical: page | horizontal: page
- nP |= (1 << 4) | (2 << 6);
- break;
- // in case of Fly as characters: set paragraph-bound!!!
- case RndStdIds::FLY_AT_FLY:
- case RndStdIds::FLY_AT_CHAR:
- case RndStdIds::FLY_AT_PARA:
- case RndStdIds::FLY_AS_CHAR:
- // vertical: page | horizontal: page
- nP |= (2 << 4) | (0 << 6);
- break;
- default:
- break;
- }
+ if ( !m_rWW8Export.m_bOutFlyFrameAttrs )
+ return;
- // sprmPPc
- m_rWW8Export.InsUInt16( NS_sprm::PPc::val );
- m_rWW8Export.pO->push_back( nP );
+ sal_uInt8 nP = 0;
+ switch ( rAnchor.GetAnchorId() )
+ {
+ case RndStdIds::FLY_AT_PAGE:
+ // vertical: page | horizontal: page
+ nP |= (1 << 4) | (2 << 6);
+ break;
+ // in case of Fly as characters: set paragraph-bound!!!
+ case RndStdIds::FLY_AT_FLY:
+ case RndStdIds::FLY_AT_CHAR:
+ case RndStdIds::FLY_AT_PARA:
+ case RndStdIds::FLY_AS_CHAR:
+ // vertical: page | horizontal: page
+ nP |= (2 << 4) | (0 << 6);
+ break;
+ default:
+ break;
}
+
+ // sprmPPc
+ m_rWW8Export.InsUInt16( NS_sprm::PPc::val );
+ m_rWW8Export.pO->push_back( nP );
}
void WW8AttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
{
// WW cannot have background in a section
- if ( !m_rWW8Export.m_bOutPageDescs )
- {
- WW8_SHD aSHD;
- WW8Export::TransBrush( rBrush.GetColor(), aSHD );
+ if ( m_rWW8Export.m_bOutPageDescs )
+ return;
- m_rWW8Export.InsUInt16( NS_sprm::PShd80::val );
- m_rWW8Export.InsUInt16( aSHD.GetValue() );
+ WW8_SHD aSHD;
+ WW8Export::TransBrush( rBrush.GetColor(), aSHD );
- m_rWW8Export.InsUInt16( NS_sprm::PShd::val );
- m_rWW8Export.pO->push_back( 10 ); //size of operand: MUST be 10
- m_rWW8Export.InsUInt32( 0xFF000000 ); //cvFore: Foreground BGR = cvAuto
- m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor() ) ); //cvBack
- m_rWW8Export.InsUInt16( 0x0000 ); //iPat: specifies the pattern used for shading = clear/100% background
- }
+ m_rWW8Export.InsUInt16( NS_sprm::PShd80::val );
+ m_rWW8Export.InsUInt16( aSHD.GetValue() );
+
+ m_rWW8Export.InsUInt16( NS_sprm::PShd::val );
+ m_rWW8Export.pO->push_back( 10 ); //size of operand: MUST be 10
+ m_rWW8Export.InsUInt32( 0xFF000000 ); //cvFore: Foreground BGR = cvAuto
+ m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor() ) ); //cvBack
+ m_rWW8Export.InsUInt16( 0x0000 ); //iPat: specifies the pattern used for shading = clear/100% background
}
void WW8AttributeOutput::FormatFillStyle( const XFillStyleItem& rFillStyle )
{
// WW cannot have background in a section
- if ( !m_rWW8Export.m_bOutPageDescs )
- {
- // see MSWordExportBase::OutputItemSet for how _SOLID is handled
- if ( rFillStyle.GetValue() == drawing::FillStyle_NONE )
- {
- //Shd80Nil
- m_rWW8Export.InsUInt16( NS_sprm::PShd80::val );
- m_rWW8Export.InsUInt16( 0xffff );
-
- //cvAuto
- m_rWW8Export.InsUInt16( NS_sprm::PShd::val );
- m_rWW8Export.pO->push_back( 10 );
- m_rWW8Export.InsUInt32( 0xFF000000 );
- m_rWW8Export.InsUInt32( 0xFF000000 );
- m_rWW8Export.InsUInt16( 0x0000 );
- }
- }
+ if ( m_rWW8Export.m_bOutPageDescs )
+ return;
+
+ // see MSWordExportBase::OutputItemSet for how _SOLID is handled
+ if ( rFillStyle.GetValue() != drawing::FillStyle_NONE )
+ return;
+
+ //Shd80Nil
+ m_rWW8Export.InsUInt16( NS_sprm::PShd80::val );
+ m_rWW8Export.InsUInt16( 0xffff );
+
+ //cvAuto
+ m_rWW8Export.InsUInt16( NS_sprm::PShd::val );
+ m_rWW8Export.pO->push_back( 10 );
+ m_rWW8Export.InsUInt32( 0xFF000000 );
+ m_rWW8Export.InsUInt32( 0xFF000000 );
+ m_rWW8Export.InsUInt16( 0x0000 );
}
void WW8AttributeOutput::FormatFillGradient( const XFillGradientItem& /*rFillGradient*/ )
@@ -4499,33 +4501,33 @@ void WW8AttributeOutput::FormatBox( const SvxBoxItem& rBox )
{
// Fly around graphic -> here no border, because the
// graphics header already has the border
- if ( !m_rWW8Export.m_bOutGrf )
- {
- bool bShadow = false;
- const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_SHADOW );
- if ( pItem )
- {
- const SvxShadowItem* p = static_cast<const SvxShadowItem*>(pItem);
- bShadow = ( p->GetLocation() != SvxShadowLocation::NONE )
- && ( p->GetWidth() != 0 );
- }
+ if ( m_rWW8Export.m_bOutGrf )
+ return;
- SvxBoxItem aBox(rBox);
- if (m_rWW8Export.m_bOutPageDescs)
- {
- editeng::WordBorderDistances aDistances;
- editeng::BorderDistancesToWord(aBox, m_pageMargins, aDistances);
+ bool bShadow = false;
+ const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_SHADOW );
+ if ( pItem )
+ {
+ const SvxShadowItem* p = static_cast<const SvxShadowItem*>(pItem);
+ bShadow = ( p->GetLocation() != SvxShadowLocation::NONE )
+ && ( p->GetWidth() != 0 );
+ }
- aBox.SetDistance(aDistances.nTop, SvxBoxItemLine::TOP);
- aBox.SetDistance(aDistances.nLeft, SvxBoxItemLine::LEFT);
- aBox.SetDistance(aDistances.nBottom, SvxBoxItemLine::BOTTOM);
- aBox.SetDistance(aDistances.nRight, SvxBoxItemLine::RIGHT);
+ SvxBoxItem aBox(rBox);
+ if (m_rWW8Export.m_bOutPageDescs)
+ {
+ editeng::WordBorderDistances aDistances;
+ editeng::BorderDistancesToWord(aBox, m_pageMargins, aDistances);
- m_bFromEdge = aDistances.bFromEdge;
- }
+ aBox.SetDistance(aDistances.nTop, SvxBoxItemLine::TOP);
+ aBox.SetDistance(aDistances.nLeft, SvxBoxItemLine::LEFT);
+ aBox.SetDistance(aDistances.nBottom, SvxBoxItemLine::BOTTOM);
+ aBox.SetDistance(aDistances.nRight, SvxBoxItemLine::RIGHT);
- m_rWW8Export.Out_SwFormatBox( aBox, bShadow );
+ m_bFromEdge = aDistances.bFromEdge;
}
+
+ m_rWW8Export.Out_SwFormatBox( aBox, bShadow );
}
SwTwips WW8Export::CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const
@@ -4560,25 +4562,25 @@ void WW8AttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFormatCol
m_rWW8Export.InsUInt16( NS_sprm::SFEvenlySpaced::val );
m_rWW8Export.pO->push_back( bEven ? 1 : 0 );
- if ( !bEven )
+ if ( bEven )
+ return;
+
+ for ( sal_uInt16 n = 0; n < nCols; ++n )
{
- for ( sal_uInt16 n = 0; n < nCols; ++n )
+ //sprmSDxaColWidth
+ m_rWW8Export.InsUInt16( NS_sprm::SDxaColWidth::val );
+ m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
+ m_rWW8Export.InsUInt16( rCol.
+ CalcPrtColWidth( n,
+ static_cast<sal_uInt16>(nPageSize) ) );
+
+ if ( n + 1 != nCols )
{
- //sprmSDxaColWidth
- m_rWW8Export.InsUInt16( NS_sprm::SDxaColWidth::val );
+ //sprmSDxaColSpacing
+ m_rWW8Export.InsUInt16( NS_sprm::SDxaColSpacing::val );
m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
- m_rWW8Export.InsUInt16( rCol.
- CalcPrtColWidth( n,
- static_cast<sal_uInt16>(nPageSize) ) );
-
- if ( n + 1 != nCols )
- {
- //sprmSDxaColSpacing
- m_rWW8Export.InsUInt16( NS_sprm::SDxaColSpacing::val );
- m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
- m_rWW8Export.InsUInt16( rColumns[n].GetRight( ) +
- rColumns[n + 1].GetLeft( ) );
- }
+ m_rWW8Export.InsUInt16( rColumns[n].GetRight( ) +
+ rColumns[n + 1].GetLeft( ) );
}
}
}
@@ -4588,66 +4590,66 @@ void AttributeOutputBase::FormatColumns( const SwFormatCol& rCol )
const SwColumns& rColumns = rCol.GetColumns();
sal_uInt16 nCols = rColumns.size();
- if ( 1 < nCols && !GetExport( ).m_bOutFlyFrameAttrs )
+ if (1 >= nCols || GetExport( ).m_bOutFlyFrameAttrs)
+ return;
+
+ // get the page width without borders !!
+
+ const SwFrameFormat* pFormat = GetExport( ).m_pCurrentPageDesc ? &GetExport( ).m_pCurrentPageDesc->GetMaster() : &const_cast<const SwDoc *>(GetExport( ).m_pDoc)->GetPageDesc(0).GetMaster();
+ const SvxFrameDirectionItem &frameDirection = pFormat->GetFrameDir();
+ SwTwips nPageSize;
+ if ( frameDirection.GetValue() == SvxFrameDirection::Vertical_RL_TB || frameDirection.GetValue() == SvxFrameDirection::Vertical_LR_TB )
{
- // get the page width without borders !!
+ const SvxULSpaceItem &rUL = pFormat->GetULSpace();
+ nPageSize = pFormat->GetFrameSize().GetHeight();
+ nPageSize -= rUL.GetUpper() + rUL.GetLower();
- const SwFrameFormat* pFormat = GetExport( ).m_pCurrentPageDesc ? &GetExport( ).m_pCurrentPageDesc->GetMaster() : &const_cast<const SwDoc *>(GetExport( ).m_pDoc)->GetPageDesc(0).GetMaster();
- const SvxFrameDirectionItem &frameDirection = pFormat->GetFrameDir();
- SwTwips nPageSize;
- if ( frameDirection.GetValue() == SvxFrameDirection::Vertical_RL_TB || frameDirection.GetValue() == SvxFrameDirection::Vertical_LR_TB )
+ const SwFormatHeader *header = pFormat->GetAttrSet().GetItem(RES_HEADER);
+ if ( header )
{
- const SvxULSpaceItem &rUL = pFormat->GetULSpace();
- nPageSize = pFormat->GetFrameSize().GetHeight();
- nPageSize -= rUL.GetUpper() + rUL.GetLower();
-
- const SwFormatHeader *header = pFormat->GetAttrSet().GetItem(RES_HEADER);
- if ( header )
+ const SwFrameFormat *headerFormat = header->GetHeaderFormat();
+ if (headerFormat)
{
- const SwFrameFormat *headerFormat = header->GetHeaderFormat();
- if (headerFormat)
- {
- nPageSize -= headerFormat->GetFrameSize().GetHeight();
- }
+ nPageSize -= headerFormat->GetFrameSize().GetHeight();
}
- const SwFormatFooter *footer = pFormat->GetAttrSet().GetItem(RES_FOOTER);
- if ( footer )
+ }
+ const SwFormatFooter *footer = pFormat->GetAttrSet().GetItem(RES_FOOTER);
+ if ( footer )
+ {
+ const SwFrameFormat *footerFormat = footer->GetFooterFormat();
+ if ( footerFormat )
{
- const SwFrameFormat *footerFormat = footer->GetFooterFormat();
- if ( footerFormat )
- {
- nPageSize -= footerFormat->GetFrameSize().GetHeight();
- }
+ nPageSize -= footerFormat->GetFrameSize().GetHeight();
}
}
- else
- {
- const SvxLRSpaceItem &rLR = pFormat->GetLRSpace();
- nPageSize = pFormat->GetFrameSize().GetWidth();
- nPageSize -= rLR.GetLeft() + rLR.GetRight();
- //i120133: The Section width should consider page indent value.
- nPageSize -= rCol.GetAdjustValue();
+ }
+ else
+ {
+ const SvxLRSpaceItem &rLR = pFormat->GetLRSpace();
+ nPageSize = pFormat->GetFrameSize().GetWidth();
+ nPageSize -= rLR.GetLeft() + rLR.GetRight();
+ //i120133: The Section width should consider page indent value.
+ nPageSize -= rCol.GetAdjustValue();
- }
+ }
- // look if all columns are equal
- bool bEven = true;
- sal_uInt16 n;
- sal_uInt16 nColWidth = rCol.CalcPrtColWidth( 0, static_cast<sal_uInt16>(nPageSize) );
- for ( n = 1; n < nCols; n++ )
- {
- short nDiff = nColWidth -
- rCol.CalcPrtColWidth( n, static_cast<sal_uInt16>(nPageSize) );
+ // look if all columns are equal
+ bool bEven = true;
+ sal_uInt16 n;
+ sal_uInt16 nColWidth = rCol.CalcPrtColWidth( 0, static_cast<sal_uInt16>(nPageSize) );
+ for ( n = 1; n < nCols; n++ )
+ {
+ short nDiff = nColWidth -
+ rCol.CalcPrtColWidth( n, static_cast<sal_uInt16>(nPageSize) );
- if ( nDiff > 10 || nDiff < -10 ) // Tolerance: 10 tw
- {
- bEven = false;
- break;
- }
+ if ( nDiff > 10 || nDiff < -10 ) // Tolerance: 10 tw
+ {
+ bEven = false;
+ break;
}
-
- FormatColumns_Impl( nCols, rCol, bEven, nPageSize );
}
+
+ FormatColumns_Impl( nCols, rCol, bEven, nPageSize );
}
// "Paragraphs together"
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 3c3961695ade..f7a048a7b35c 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -289,19 +289,19 @@ static void SetLineEndAttr( SfxItemSet& rSet, WW8_DP_LINEEND const & rLe,
}
sal_uInt16 aEB = SVBT16ToUInt16( rLe.aEndBits );
- if( aEB & 0x3 ){
- ::basegfx::B2DPolygon aPolygon;
- aPolygon.append(::basegfx::B2DPoint(0.0, 330.0));
- aPolygon.append(::basegfx::B2DPoint(100.0, 0.0));
- aPolygon.append(::basegfx::B2DPoint(200.0, 330.0));
- aPolygon.setClosed(true);
- rSet.Put( XLineStartItem( OUString(), ::basegfx::B2DPolyPolygon(aPolygon) ) );
- sal_uInt16 nSiz = SVBT16ToUInt16( rLt.lnpw )
- * ( ( aEB >> 2 & 0x3 ) + ( aEB >> 4 & 0x3 ) );
- if( nSiz < 220 ) nSiz = 220;
- rSet.Put(XLineStartWidthItem(nSiz));
- rSet.Put(XLineStartCenterItem(false));
- }
+ if( !(aEB & 0x3) ) return;
+
+ ::basegfx::B2DPolygon aPolygon;
+ aPolygon.append(::basegfx::B2DPoint(0.0, 330.0));
+ aPolygon.append(::basegfx::B2DPoint(100.0, 0.0));
+ aPolygon.append(::basegfx::B2DPoint(200.0, 330.0));
+ aPolygon.setClosed(true);
+ rSet.Put( XLineStartItem( OUString(), ::basegfx::B2DPolyPolygon(aPolygon) ) );
+ sal_uInt16 nSiz = SVBT16ToUInt16( rLt.lnpw )
+ * ( ( aEB >> 2 & 0x3 ) + ( aEB >> 4 & 0x3 ) );
+ if( nSiz < 220 ) nSiz = 220;
+ rSet.Put(XLineStartWidthItem(nSiz));
+ rSet.Put(XLineStartCenterItem(false));
}
// start of routines for the different objects
@@ -494,28 +494,28 @@ static ESelection GetESelection(EditEngine const &rDrawEditEngine, long nCpStart
void SwWW8ImplReader::InsertTxbxStyAttrs( SfxItemSet& rS, sal_uInt16 nColl )
{
SwWW8StyInf * pStyInf = GetStyle(nColl);
- if( pStyInf != nullptr && pStyInf->m_pFormat && pStyInf->m_bColl )
+ if( !(pStyInf != nullptr && pStyInf->m_pFormat && pStyInf->m_bColl) )
+ return;
+
+ const SfxPoolItem* pItem;
+ for( sal_uInt16 i = POOLATTR_BEGIN; i < POOLATTR_END; i++ )
{
- const SfxPoolItem* pItem;
- for( sal_uInt16 i = POOLATTR_BEGIN; i < POOLATTR_END; i++ )
+ // If we are set in the source and not set in the destination
+ // then add it in.
+ if ( SfxItemState::SET == pStyInf->m_pFormat->GetItemState(
+ i, true, &pItem ) )
{
- // If we are set in the source and not set in the destination
- // then add it in.
- if ( SfxItemState::SET == pStyInf->m_pFormat->GetItemState(
- i, true, &pItem ) )
+ SfxItemPool *pEditPool = rS.GetPool();
+ sal_uInt16 nWhich = i;
+ sal_uInt16 nSlotId = m_rDoc.GetAttrPool().GetSlotId(nWhich);
+ if (
+ nSlotId && nWhich != nSlotId &&
+ 0 != (nWhich = pEditPool->GetWhich(nSlotId)) &&
+ nWhich != nSlotId &&
+ ( SfxItemState::SET != rS.GetItemState(nWhich, false) )
+ )
{
- SfxItemPool *pEditPool = rS.GetPool();
- sal_uInt16 nWhich = i;
- sal_uInt16 nSlotId = m_rDoc.GetAttrPool().GetSlotId(nWhich);
- if (
- nSlotId && nWhich != nSlotId &&
- 0 != (nWhich = pEditPool->GetWhich(nSlotId)) &&
- nWhich != nSlotId &&
- ( SfxItemState::SET != rS.GetItemState(nWhich, false) )
- )
- {
- rS.Put( pItem->CloneSetWhich(nWhich) );
- }
+ rS.Put( pItem->CloneSetWhich(nWhich) );
}
}
}
@@ -2100,98 +2100,98 @@ SwWW8ImplReader::SetAttributesAtGrfNode(SvxMSDffImportRec const*const pRecord,
const SwNodeIndex* pIdx = pFlyFormat->GetContent(false).GetContentIdx();
SwGrfNode *const pGrfNd(
pIdx ? m_rDoc.GetNodes()[pIdx->GetIndex() + 1]->GetGrfNode() : nullptr);
- if (pGrfNd)
- {
- Size aSz(pGrfNd->GetTwipSize());
- // use type <sal_uInt64> instead of sal_uLong to get correct results
- // in the following calculations.
- sal_uInt64 nHeight = aSz.Height();
- sal_uInt64 nWidth = aSz.Width();
- if (!nWidth && pF)
- nWidth = o3tl::saturating_sub(pF->nXaRight, pF->nXaLeft);
- else if (!nHeight && pF)
- nHeight = o3tl::saturating_sub(pF->nYaBottom, pF->nYaTop);
-
- if( pRecord->nCropFromTop || pRecord->nCropFromBottom ||
- pRecord->nCropFromLeft || pRecord->nCropFromRight )
- {
- SwCropGrf aCrop; // Cropping is stored in 'fixed floats'
- // 16.16 (fraction times total
- if( pRecord->nCropFromTop ) // image width or height resp.)
- {
- aCrop.SetTop(lcl_ConvertCrop(pRecord->nCropFromTop, nHeight));
- }
- if( pRecord->nCropFromBottom )
- {
- aCrop.SetBottom(lcl_ConvertCrop(pRecord->nCropFromBottom, nHeight));
- }
- if( pRecord->nCropFromLeft )
- {
- aCrop.SetLeft(lcl_ConvertCrop(pRecord->nCropFromLeft, nWidth));
- }
- if( pRecord->nCropFromRight )
- {
- aCrop.SetRight(lcl_ConvertCrop(pRecord->nCropFromRight, nWidth));
- }
+ if (!pGrfNd)
+ return;
- pGrfNd->SetAttr( aCrop );
+ Size aSz(pGrfNd->GetTwipSize());
+ // use type <sal_uInt64> instead of sal_uLong to get correct results
+ // in the following calculations.
+ sal_uInt64 nHeight = aSz.Height();
+ sal_uInt64 nWidth = aSz.Width();
+ if (!nWidth && pF)
+ nWidth = o3tl::saturating_sub(pF->nXaRight, pF->nXaLeft);
+ else if (!nHeight && pF)
+ nHeight = o3tl::saturating_sub(pF->nYaBottom, pF->nYaTop);
+
+ if( pRecord->nCropFromTop || pRecord->nCropFromBottom ||
+ pRecord->nCropFromLeft || pRecord->nCropFromRight )
+ {
+ SwCropGrf aCrop; // Cropping is stored in 'fixed floats'
+ // 16.16 (fraction times total
+ if( pRecord->nCropFromTop ) // image width or height resp.)
+ {
+ aCrop.SetTop(lcl_ConvertCrop(pRecord->nCropFromTop, nHeight));
}
+ if( pRecord->nCropFromBottom )
+ {
+ aCrop.SetBottom(lcl_ConvertCrop(pRecord->nCropFromBottom, nHeight));
+ }
+ if( pRecord->nCropFromLeft )
+ {
+ aCrop.SetLeft(lcl_ConvertCrop(pRecord->nCropFromLeft, nWidth));
+ }
+ if( pRecord->nCropFromRight )
+ {
+ aCrop.SetRight(lcl_ConvertCrop(pRecord->nCropFromRight, nWidth));
+ }
+
+ pGrfNd->SetAttr( aCrop );
+ }
- bool bFlipH(pRecord->nFlags & ShapeFlag::FlipH);
- bool bFlipV(pRecord->nFlags & ShapeFlag::FlipV);
- if ( bFlipH || bFlipV )
+ bool bFlipH(pRecord->nFlags & ShapeFlag::FlipH);
+ bool bFlipV(pRecord->nFlags & ShapeFlag::FlipV);
+ if ( bFlipH || bFlipV )
+ {
+ SwMirrorGrf aMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
+ if( bFlipH )
{
- SwMirrorGrf aMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
- if( bFlipH )
- {
- if( bFlipV )
- aMirror.SetValue(MirrorGraph::Both);
- else
- aMirror.SetValue(MirrorGraph::Vertical);
- }
+ if( bFlipV )
+ aMirror.SetValue(MirrorGraph::Both);
else
- aMirror.SetValue(MirrorGraph::Horizontal);
-
- pGrfNd->SetAttr( aMirror );
+ aMirror.SetValue(MirrorGraph::Vertical);
}
+ else
+ aMirror.SetValue(MirrorGraph::Horizontal);
- if (pRecord->pObj)
- {
- const SfxItemSet& rOldSet = pRecord->pObj->GetMergedItemSet();
- // contrast
- if (WW8ITEMVALUE(rOldSet, SDRATTR_GRAFCONTRAST,
- SdrGrafContrastItem))
- {
- SwContrastGrf aContrast(
- WW8ITEMVALUE(rOldSet,
- SDRATTR_GRAFCONTRAST, SdrGrafContrastItem));
- pGrfNd->SetAttr( aContrast );
- }
+ pGrfNd->SetAttr( aMirror );
+ }
- // luminance
- if (WW8ITEMVALUE(rOldSet, SDRATTR_GRAFLUMINANCE,
- SdrGrafLuminanceItem))
- {
- SwLuminanceGrf aLuminance(WW8ITEMVALUE(rOldSet,
- SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem));
- pGrfNd->SetAttr( aLuminance );
- }
- // gamma
- if (WW8ITEMVALUE(rOldSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item))
- {
- double fVal = WW8ITEMVALUE(rOldSet, SDRATTR_GRAFGAMMA,
- SdrGrafGamma100Item);
- pGrfNd->SetAttr(SwGammaGrf(fVal/100.));
- }
+ if (!pRecord->pObj)
+ return;
- // drawmode
- auto nGrafMode = rOldSet.GetItem<SdrGrafModeItem>(SDRATTR_GRAFMODE)->GetValue();
- if ( nGrafMode != GraphicDrawMode::Standard)
- {
- SwDrawModeGrf aDrawMode( nGrafMode );
- pGrfNd->SetAttr( aDrawMode );
- }
- }
+ const SfxItemSet& rOldSet = pRecord->pObj->GetMergedItemSet();
+ // contrast
+ if (WW8ITEMVALUE(rOldSet, SDRATTR_GRAFCONTRAST,
+ SdrGrafContrastItem))
+ {
+ SwContrastGrf aContrast(
+ WW8ITEMVALUE(rOldSet,
+ SDRATTR_GRAFCONTRAST, SdrGrafContrastItem));
+ pGrfNd->SetAttr( aContrast );
+ }
+
+ // luminance
+ if (WW8ITEMVALUE(rOldSet, SDRATTR_GRAFLUMINANCE,
+ SdrGrafLuminanceItem))
+ {
+ SwLuminanceGrf aLuminance(WW8ITEMVALUE(rOldSet,
+ SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem));
+ pGrfNd->SetAttr( aLuminance );
+ }
+ // gamma
+ if (WW8ITEMVALUE(rOldSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item))
+ {
+ double fVal = WW8ITEMVALUE(rOldSet, SDRATTR_GRAFGAMMA,
+ SdrGrafGamma100Item);
+ pGrfNd->SetAttr(SwGammaGrf(fVal/100.));
+ }
+
+ // drawmode
+ auto nGrafMode = rOldSet.GetItem<SdrGrafModeItem>(SDRATTR_GRAFMODE)->GetValue();
+ if ( nGrafMode != GraphicDrawMode::Standard)
+ {
+ SwDrawModeGrf aDrawMode( nGrafMode );
+ pGrfNd->SetAttr( aDrawMode );
}
}
@@ -3171,24 +3171,24 @@ SwFlyFrameFormat* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObj
void SwWW8ImplReader::GrafikCtor() // For SVDraw and VCControls and Escher
{
- if (!m_pDrawModel)
- {
- m_rDoc.getIDocumentDrawModelAccess().GetOrCreateDrawModel(); // #i52858# - method name changed
- m_pDrawModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
- OSL_ENSURE(m_pDrawModel, "Cannot create DrawModel");
- m_pDrawPg = m_pDrawModel->GetPage(0);
+ if (m_pDrawModel)
+ return;
- m_xMSDffManager.reset(new SwMSDffManager(*this, m_bSkipImages));
- m_xMSDffManager->SetModel(m_pDrawModel, 1440);
- /*
- Now the dff manager always needs a controls converter as well, but a
- control converter may still exist without a dffmanager.
- */
- m_xFormImpl.reset(new SwMSConvertControls(m_pDocShell, m_pPaM));
+ m_rDoc.getIDocumentDrawModelAccess().GetOrCreateDrawModel(); // #i52858# - method name changed
+ m_pDrawModel = m_rDoc.getIDocumentDrawModelAccess().GetDrawModel();
+ OSL_ENSURE(m_pDrawModel, "Cannot create DrawModel");
+ m_pDrawPg = m_pDrawModel->GetPage(0);
- m_xWWZOrder.reset(new wwZOrderer(sw::util::SetLayer(m_rDoc), m_pDrawPg,
- m_xMSDffManager->GetShapeOrders()));
- }
+ m_xMSDffManager.reset(new SwMSDffManager(*this, m_bSkipImages));
+ m_xMSDffManager->SetModel(m_pDrawModel, 1440);
+ /*
+ Now the dff manager always needs a controls converter as well, but a
+ control converter may still exist without a dffmanager.
+ */
+ m_xFormImpl.reset(new SwMSConvertControls(m_pDocShell, m_pPaM));
+
+ m_xWWZOrder.reset(new wwZOrderer(sw::util::SetLayer(m_rDoc), m_pDrawPg,
+ m_xMSDffManager->GetShapeOrders()));
}
void SwWW8ImplReader::GrafikDtor()
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 7e9f7f271655..9e8429a06768 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2297,95 +2297,95 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
sal_uInt8 grpfIhdt = rSection.maSep.grpfIhdt;
SwPageDesc *pPD = rSection.mpPage;
- if( m_xHdFt )
- {
- WW8_CP nStart, nLen;
- sal_uInt8 nNumber = 5;
+ if( !m_xHdFt )
+ return;
- // This loops through the 6 flags WW8_{FOOTER,HEADER}_{ODD,EVEN,FIRST}
- // corresponding to bit fields in grpfIhdt indicating which
- // header/footer(s) are present in this section
- for( sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
+ WW8_CP nStart, nLen;
+ sal_uInt8 nNumber = 5;
+
+ // This loops through the 6 flags WW8_{FOOTER,HEADER}_{ODD,EVEN,FIRST}
+ // corresponding to bit fields in grpfIhdt indicating which
+ // header/footer(s) are present in this section
+ for( sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
+ {
+ if (nI & grpfIhdt)
{
- if (nI & grpfIhdt)
+ bool bOk = true;
+ if( m_bVer67 )
+ bOk = ( m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nLen >= 2 );
+ else
{
- bool bOk = true;
- if( m_bVer67 )
- bOk = ( m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nLen >= 2 );
- else
- {
- m_xHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
- bOk = ( 2 <= nLen ) && isValid_HdFt_CP(nStart);
- }
+ m_xHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
+ bOk = ( 2 <= nLen ) && isValid_HdFt_CP(nStart);
+ }
- bool bUseLeft
- = (nI & ( WW8_HEADER_EVEN | WW8_FOOTER_EVEN )) != 0;
- bool bUseFirst
- = (nI & ( WW8_HEADER_FIRST | WW8_FOOTER_FIRST )) != 0;
+ bool bUseLeft
+ = (nI & ( WW8_HEADER_EVEN | WW8_FOOTER_EVEN )) != 0;
+ bool bUseFirst
+ = (nI & ( WW8_HEADER_FIRST | WW8_FOOTER_FIRST )) != 0;
- // If we are loading a first-page header/footer which is not
- // actually enabled in this section (it still needs to be
- // loaded as it may be inherited by a later section)
- bool bDisabledFirst = bUseFirst && !rSection.HasTitlePage();
+ // If we are loading a first-page header/footer which is not
+ // actually enabled in this section (it still needs to be
+ // loaded as it may be inherited by a later section)
+ bool bDisabledFirst = bUseFirst && !rSection.HasTitlePage();
- bool bFooter
- = (nI & ( WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST )) != 0;
+ bool bFooter
+ = (nI & ( WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST )) != 0;
- SwFrameFormat& rFormat = bUseLeft ? pPD->GetLeft()
- : bUseFirst ? pPD->GetFirstMaster()
- : pPD->GetMaster();
+ SwFrameFormat& rFormat = bUseLeft ? pPD->GetLeft()
+ : bUseFirst ? pPD->GetFirstMaster()
+ : pPD->GetMaster();
- SwFrameFormat* pHdFtFormat;
- // If we have empty first page header and footer.
- bool bNoFirst = !(grpfIhdt & WW8_HEADER_FIRST) && !(grpfIhdt & WW8_FOOTER_FIRST);
- if (bFooter)
- {
- m_bIsFooter = true;
- //#i17196# Cannot have left without right
- if (!bDisabledFirst
- && !pPD->GetMaster().GetFooter().GetFooterFormat())
- pPD->GetMaster().SetFormatAttr(SwFormatFooter(true));
- if (bUseLeft)
- pPD->GetLeft().SetFormatAttr(SwFormatFooter(true));
- if (bUseFirst || (rSection.maSep.fTitlePage && bNoFirst))
- pPD->GetFirstMaster().SetFormatAttr(SwFormatFooter(true));
- pHdFtFormat = const_cast<SwFrameFormat*>(rFormat.GetFooter().GetFooterFormat());
- }
- else
- {
- m_bIsHeader = true;
- //#i17196# Cannot have left without right
- if (!bDisabledFirst
- && !pPD->GetMaster().GetHeader().GetHeaderFormat())
- pPD->GetMaster().SetFormatAttr(SwFormatHeader(true));
- if (bUseLeft)
- pPD->GetLeft().SetFormatAttr(SwFormatHeader(true));
- if (bUseFirst || (rSection.maSep.fTitlePage && bNoFirst))
- pPD->GetFirstMaster().SetFormatAttr(SwFormatHeader(true));
- pHdFtFormat = const_cast<SwFrameFormat*>(rFormat.GetHeader().GetHeaderFormat());
- }
+ SwFrameFormat* pHdFtFormat;
+ // If we have empty first page header and footer.
+ bool bNoFirst = !(grpfIhdt & WW8_HEADER_FIRST) && !(grpfIhdt & WW8_FOOTER_FIRST);
+ if (bFooter)
+ {
+ m_bIsFooter = true;
+ //#i17196# Cannot have left without right
+ if (!bDisabledFirst
+ && !pPD->GetMaster().GetFooter().GetFooterFormat())
+ pPD->GetMaster().SetFormatAttr(SwFormatFooter(true));
+ if (bUseLeft)
+ pPD->GetLeft().SetFormatAttr(SwFormatFooter(true));
+ if (bUseFirst || (rSection.maSep.fTitlePage && bNoFirst))
+ pPD->GetFirstMaster().SetFormatAttr(SwFormatFooter(true));
+ pHdFtFormat = const_cast<SwFrameFormat*>(rFormat.GetFooter().GetFooterFormat());
+ }
+ else
+ {
+ m_bIsHeader = true;
+ //#i17196# Cannot have left without right
+ if (!bDisabledFirst
+ && !pPD->GetMaster().GetHeader().GetHeaderFormat())
+ pPD->GetMaster().SetFormatAttr(SwFormatHeader(true));
+ if (bUseLeft)
+ pPD->GetLeft().SetFormatAttr(SwFormatHeader(true));
+ if (bUseFirst || (rSection.maSep.fTitlePage && bNoFirst))
+ pPD->GetFirstMaster().SetFormatAttr(SwFormatHeader(true));
+ pHdFtFormat = const_cast<SwFrameFormat*>(rFormat.GetHeader().GetHeaderFormat());
+ }
- if (bOk)
- {
- bool bHackRequired = false;
- if (m_bIsHeader && rSection.IsFixedHeightHeader())
- bHackRequired = true;
- else if (m_bIsFooter && rSection.IsFixedHeightFooter())
- bHackRequired = true;
+ if (bOk)
+ {
+ bool bHackRequired = false;
+ if (m_bIsHeader && rSection.IsFixedHeightHeader())
+ bHackRequired = true;
+ else if (m_bIsFooter && rSection.IsFixedHeightFooter())
+ bHackRequired = true;
- if (bHackRequired)
- {
- Read_HdFtTextAsHackedFrame(nStart, nLen, *pHdFtFormat,
- static_cast< sal_uInt16 >(rSection.GetTextAreaWidth()) );
- }
- else
- Read_HdFtText(nStart, nLen, pHdFtFormat);
+ if (bHackRequired)
+ {
+ Read_HdFtTextAsHackedFrame(nStart, nLen, *pHdFtFormat,
+ static_cast< sal_uInt16 >(rSection.GetTextAreaWidth()) );
}
- else if (pPrev)
- CopyPageDescHdFt(pPrev, pPD, nI);
-
- m_bIsHeader = m_bIsFooter = false;
+ else
+ Read_HdFtText(nStart, nLen, pHdFtFormat);
}
+ else if (pPrev)
+ CopyPageDescHdFt(pPrev, pPD, nI);
+
+ m_bIsHeader = m_bIsFooter = false;
}
}
}
@@ -2888,20 +2888,20 @@ rtl_TextEncoding SwWW8ImplReader::GetCurrentCJKCharSet()
void SwWW8ImplReader::PostProcessAttrs()
{
- if (m_pPostProcessAttrsInfo != nullptr)
- {
- SfxItemIter aIter(m_pPostProcessAttrsInfo->mItemSet);
+ if (m_pPostProcessAttrsInfo == nullptr)
+ return;
- for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
- {
- m_xCtrlStck->NewAttr(*m_pPostProcessAttrsInfo->mPaM.GetPoint(),
- *pItem);
- m_xCtrlStck->SetAttr(*m_pPostProcessAttrsInfo->mPaM.GetMark(),
- pItem->Which());
- }
+ SfxItemIter aIter(m_pPostProcessAttrsInfo->mItemSet);
- m_pPostProcessAttrsInfo.reset();
+ for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
+ {
+ m_xCtrlStck->NewAttr(*m_pPostProcessAttrsInfo->mPaM.GetPoint(),
+ *pItem);
+ m_xCtrlStck->SetAttr(*m_pPostProcessAttrsInfo->mPaM.GetMark(),
+ pItem->Which());
}
+
+ m_pPostProcessAttrsInfo.reset();
}
/*
@@ -4737,31 +4737,31 @@ void wwExtraneousParas::delete_all_from_doc()
void SwWW8ImplReader::StoreMacroCmds()
{
- if (m_xWwFib->m_lcbCmds)
- {
- bool bValidPos = checkSeek(*m_pTableStream, m_xWwFib->m_fcCmds);
- if (!bValidPos)
- return;
+ if (!m_xWwFib->m_lcbCmds)
+ return;
- uno::Reference < embed::XStorage > xRoot(m_pDocShell->GetStorage());
+ bool bValidPos = checkSeek(*m_pTableStream, m_xWwFib->m_fcCmds);
+ if (!bValidPos)
+ return;
- if (!xRoot.is())
- return;
+ uno::Reference < embed::XStorage > xRoot(m_pDocShell->GetStorage());
- try
- {
- uno::Reference < io::XStream > xStream =
- xRoot->openStreamElement( SL::aMSMacroCmds, embed::ElementModes::READWRITE );
- std::unique_ptr<SvStream> xOutStream(::utl::UcbStreamHelper::CreateStream(xStream));
+ if (!xRoot.is())
+ return;
- sal_uInt32 lcbCmds = std::min<sal_uInt32>(m_xWwFib->m_lcbCmds, m_pTableStream->remainingSize());
- std::unique_ptr<sal_uInt8[]> xBuffer(new sal_uInt8[lcbCmds]);
- m_xWwFib->m_lcbCmds = m_pTableStream->ReadBytes(xBuffer.get(), lcbCmds);
- xOutStream->WriteBytes(xBuffer.get(), m_xWwFib->m_lcbCmds);
- }
- catch (...)
- {
- }
+ try
+ {
+ uno::Reference < io::XStream > xStream =
+ xRoot->openStreamElement( SL::aMSMacroCmds, embed::ElementModes::READWRITE );
+ std::unique_ptr<SvStream> xOutStream(::utl::UcbStreamHelper::CreateStream(xStream));
+
+ sal_uInt32 lcbCmds = std::min<sal_uInt32>(m_xWwFib->m_lcbCmds, m_pTableStream->remainingSize());
+ std::unique_ptr<sal_uInt8[]> xBuffer(new sal_uInt8[lcbCmds]);
+ m_xWwFib->m_lcbCmds = m_pTableStream->ReadBytes(xBuffer.get(), lcbCmds);
+ xOutStream->WriteBytes(xBuffer.get(), m_xWwFib->m_lcbCmds);
+ }
+ catch (...)
+ {
}
}
@@ -4773,28 +4773,28 @@ void SwWW8ImplReader::ReadDocVars()
WW8ReadSTTBF(!m_bVer67, *m_pTableStream, m_xWwFib->m_fcStwUser,
m_xWwFib->m_lcbStwUser, m_bVer67 ? 2 : 0, m_eStructCharSet,
aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
- if (!m_bVer67) {
- uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
- m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
- uno::Reference<document::XDocumentProperties> xDocProps(
- xDPS->getDocumentProperties());
- OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
- uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
- xDocProps->getUserDefinedProperties();
- OSL_ENSURE(xUserDefinedProps.is(), "UserDefinedProperties is null");
-
- for(size_t i=0; i<aDocVarStrings.size(); i++)
- {
- const OUString &rName = aDocVarStrings[i];
- uno::Any aValue;
- aValue <<= rName;
- try {
- xUserDefinedProps->addProperty( rName,
- beans::PropertyAttribute::REMOVABLE,
- aValue );
- } catch (const uno::Exception &) {
- // ignore
- }
+ if (m_bVer67) return;
+
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps(
+ xDPS->getDocumentProperties());
+ OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
+ uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
+ xDocProps->getUserDefinedProperties();
+ OSL_ENSURE(xUserDefinedProps.is(), "UserDefinedProperties is null");
+
+ for(size_t i=0; i<aDocVarStrings.size(); i++)
+ {
+ const OUString &rName = aDocVarStrings[i];
+ uno::Any aValue;
+ aValue <<= rName;
+ try {
+ xUserDefinedProps->addProperty( rName,
+ beans::PropertyAttribute::REMOVABLE,
+ aValue );
+ } catch (const uno::Exception &) {
+ // ignore
}
}
}
@@ -4804,83 +4804,83 @@ void SwWW8ImplReader::ReadDocVars()
*/
void SwWW8ImplReader::ReadDocInfo()
{
- if( m_pStg )
- {
- uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
- m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
- uno::Reference<document::XDocumentProperties> xDocProps(
- xDPS->getDocumentProperties());
- OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
+ if( !m_pStg )
+ return;
- if (xDocProps.is())
- {
- if ( m_xWwFib->m_fDot )
- {
- OUString sTemplateURL;
- SfxMedium* pMedium = m_pDocShell->GetMedium();
- if ( pMedium )
- {
- const OUString& aName = pMedium->GetName();
- INetURLObject aURL( aName );
- sTemplateURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
- if ( !sTemplateURL.isEmpty() )
- xDocProps->setTemplateURL( sTemplateURL );
- }
- }
- else if (m_xWwFib->m_lcbSttbfAssoc) // not a template, and has a SttbfAssoc
- {
- auto nCur = m_pTableStream->Tell();
- Sttb aSttb;
- // point at tgc record
- if (!checkSeek(*m_pTableStream, m_xWwFib->m_fcSttbfAssoc) || !aSttb.Read(*m_pTableStream))
- SAL_WARN("sw.ww8", "** Read of SttbAssoc data failed!!!! ");
- m_pTableStream->Seek( nCur ); // return to previous position, is that necessary?
- OUString sPath = aSttb.getStringAtIndex( 0x1 );
- OUString aURL;
- // attempt to convert to url (won't work for obvious reasons on linux)
- if ( !sPath.isEmpty() )
- osl::FileBase::getFileURLFromSystemPath( sPath, aURL );
- if (aURL.isEmpty())
- xDocProps->setTemplateURL( aURL );
- else
- xDocProps->setTemplateURL( sPath );
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps(
+ xDPS->getDocumentProperties());
+ OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
- }
- sfx2::LoadOlePropertySet(xDocProps, m_pStg);
+ if (!xDocProps.is())
+ return;
+
+ if ( m_xWwFib->m_fDot )
+ {
+ OUString sTemplateURL;
+ SfxMedium* pMedium = m_pDocShell->GetMedium();
+ if ( pMedium )
+ {
+ const OUString& aName = pMedium->GetName();
+ INetURLObject aURL( aName );
+ sTemplateURL = aURL.GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
+ if ( !sTemplateURL.isEmpty() )
+ xDocProps->setTemplateURL( sTemplateURL );
}
}
+ else if (m_xWwFib->m_lcbSttbfAssoc) // not a template, and has a SttbfAssoc
+ {
+ auto nCur = m_pTableStream->Tell();
+ Sttb aSttb;
+ // point at tgc record
+ if (!checkSeek(*m_pTableStream, m_xWwFib->m_fcSttbfAssoc) || !aSttb.Read(*m_pTableStream))
+ SAL_WARN("sw.ww8", "** Read of SttbAssoc data failed!!!! ");
+ m_pTableStream->Seek( nCur ); // return to previous position, is that necessary?
+ OUString sPath = aSttb.getStringAtIndex( 0x1 );
+ OUString aURL;
+ // attempt to convert to url (won't work for obvious reasons on linux)
+ if ( !sPath.isEmpty() )
+ osl::FileBase::getFileURLFromSystemPath( sPath, aURL );
+ if (aURL.isEmpty())
+ xDocProps->setTemplateURL( aURL );
+ else
+ xDocProps->setTemplateURL( sPath );
+
+ }
+ sfx2::LoadOlePropertySet(xDocProps, m_pStg);
}
static void lcl_createTemplateToProjectEntry( const uno::Reference< container::XNameContainer >& xPrjNameCache, const OUString& sTemplatePathOrURL, const OUString& sVBAProjName )
{
- if ( xPrjNameCache.is() )
+ if ( !xPrjNameCache.is() )
+ return;
+
+ INetURLObject aObj;
+ aObj.SetURL( sTemplatePathOrURL );
+ bool bIsURL = aObj.GetProtocol() != INetProtocol::NotValid;
+ OUString aURL;
+ if ( bIsURL )
+ aURL = sTemplatePathOrURL;
+ else
{
- INetURLObject aObj;
- aObj.SetURL( sTemplatePathOrURL );
- bool bIsURL = aObj.GetProtocol() != INetProtocol::NotValid;
- OUString aURL;
- if ( bIsURL )
- aURL = sTemplatePathOrURL;
- else
- {
- osl::FileBase::getFileURLFromSystemPath( sTemplatePathOrURL, aURL );
- aObj.SetURL( aURL );
- }
- try
- {
- OUString templateNameWithExt = aObj.GetLastName();
- OUString templateName;
- sal_Int32 nIndex = templateNameWithExt.lastIndexOf( '.' );
- if ( nIndex != -1 )
- {
- templateName = templateNameWithExt.copy( 0, nIndex );
- xPrjNameCache->insertByName( templateName, uno::makeAny( sVBAProjName ) );
- }
- }
- catch( const uno::Exception& )
+ osl::FileBase::getFileURLFromSystemPath( sTemplatePathOrURL, aURL );
+ aObj.SetURL( aURL );
+ }
+ try
+ {
+ OUString templateNameWithExt = aObj.GetLastName();
+ OUString templateName;
+ sal_Int32 nIndex = templateNameWithExt.lastIndexOf( '.' );
+ if ( nIndex != -1 )
{
+ templateName = templateNameWithExt.copy( 0, nIndex );
+ xPrjNameCache->insertByName( templateName, uno::makeAny( sVBAProjName ) );
}
}
+ catch( const uno::Exception& )
+ {
+ }
}
namespace {
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index bda2cb26c1df..e58455a253e3 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -675,23 +675,23 @@ void SwWW8ImplReader::SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV,
}
}
}
- if( bInsert )
+ if( !bInsert )
+ return;
+
+ if (rAV.cbTextBefore)
{
- if (rAV.cbTextBefore)
- {
- OUString sP( sText.copy( 0, rAV.cbTextBefore ).makeStringAndClear() );
- rNum.SetPrefix( sP );
- }
- if( rAV.cbTextAfter )
- {
- OUString sP( rNum.GetSuffix() );
- sP += sText.copy( rAV.cbTextBefore, rAV.cbTextAfter).makeStringAndClear();
- rNum.SetSuffix( sP );
- }
+ OUString sP( sText.copy( 0, rAV.cbTextBefore ).makeStringAndClear() );
+ rNum.SetPrefix( sP );
+ }
+ if( rAV.cbTextAfter )
+ {
+ OUString sP( rNum.GetSuffix() );
+ sP += sText.copy( rAV.cbTextBefore, rAV.cbTextAfter).makeStringAndClear();
+ rNum.SetSuffix( sP );
+ }
// The characters before and after multiple digits do not apply because
// those are handled differently by the writer and the result is in most
// cases worse than without.
- }
}
// SetAnld gets a WW-ANLD-Descriptor and a Level and modifies the NumRules
@@ -1144,87 +1144,87 @@ void WW8TabBandDesc::ReadDef(bool bVer67, const sal_uInt8* pS, short nLen)
short nColsToRead = std::min<short>(nFileCols, nCols);
- if (nColsToRead > 0)
- {
- // read TCs
+ if (nColsToRead <= 0)
+ return;
- /*
- Attention: Beginning with Ver8 there is an extra ushort per TC
- added and the size of the border code is doubled.
- Because of this a simple copy (pTCs[i] = *pTc;)
- is not possible.
- ---
- Advantage: The work structure suits better.
- */
- WW8_TCell* pCurrentTC = pTCs;
- if( bVer67 )
+ // read TCs
+
+ /*
+ Attention: Beginning with Ver8 there is an extra ushort per TC
+ added and the size of the border code is doubled.
+ Because of this a simple copy (pTCs[i] = *pTc;)
+ is not possible.
+ ---
+ Advantage: The work structure suits better.
+ */
+ WW8_TCell* pCurrentTC = pTCs;
+ if( bVer67 )
+ {
+ WW8_TCellVer6 const * pTc = reinterpret_cast<WW8_TCellVer6 const *>(pT);
+ for (int i = 0; i < nColsToRead; i++, ++pCurrentTC,++pTc)
{
- WW8_TCellVer6 const * pTc = reinterpret_cast<WW8_TCellVer6 const *>(pT);
- for (int i = 0; i < nColsToRead; i++, ++pCurrentTC,++pTc)
+ // TC from file ?
+ sal_uInt8 aBits1 = pTc->aBits1Ver6;
+ pCurrentTC->bFirstMerged = sal_uInt8( ( aBits1 & 0x01 ) != 0 );
+ pCurrentTC->bMerged = sal_uInt8( ( aBits1 & 0x02 ) != 0 );
+ pCurrentTC->rgbrc[ WW8_TOP ]
+ = WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_TOP ] ));
+ pCurrentTC->rgbrc[ WW8_LEFT ]
+ = WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_LEFT ] ));
+ pCurrentTC->rgbrc[ WW8_BOT ]
+ = WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_BOT ] ));
+ pCurrentTC->rgbrc[ WW8_RIGHT ]
+ = WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_RIGHT ] ));
+ if( ( pCurrentTC->bMerged )
+ && ( i > 0 ) )
{
- // TC from file ?
- sal_uInt8 aBits1 = pTc->aBits1Ver6;
- pCurrentTC->bFirstMerged = sal_uInt8( ( aBits1 & 0x01 ) != 0 );
- pCurrentTC->bMerged = sal_uInt8( ( aBits1 & 0x02 ) != 0 );
- pCurrentTC->rgbrc[ WW8_TOP ]
- = WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_TOP ] ));
- pCurrentTC->rgbrc[ WW8_LEFT ]
- = WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_LEFT ] ));
- pCurrentTC->rgbrc[ WW8_BOT ]
- = WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_BOT ] ));
- pCurrentTC->rgbrc[ WW8_RIGHT ]
+ // Cell merged -> remember
+ //bWWMergedVer6[i] = true;
+ pTCs[i-1].rgbrc[ WW8_RIGHT ]
= WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_RIGHT ] ));
- if( ( pCurrentTC->bMerged )
- && ( i > 0 ) )
- {
- // Cell merged -> remember
- //bWWMergedVer6[i] = true;
- pTCs[i-1].rgbrc[ WW8_RIGHT ]
- = WW8_BRCVer9(WW8_BRC( pTc->rgbrcVer6[ WW8_RIGHT ] ));
- // apply right border to previous cell
- // bExist must not be set to false, because WW
- // does not count this cells in text boxes...
- }
+ // apply right border to previous cell
+ // bExist must not be set to false, because WW
+ // does not count this cells in text boxes...
}
}
- else
+ }
+ else
+ {
+ WW8_TCellVer8 const * pTc = reinterpret_cast<WW8_TCellVer8 const *>(pT);
+ for (int k = 0; k < nColsToRead; ++k, ++pCurrentTC, ++pTc )
{
- WW8_TCellVer8 const * pTc = reinterpret_cast<WW8_TCellVer8 const *>(pT);
- for (int k = 0; k < nColsToRead; ++k, ++pCurrentTC, ++pTc )
- {
- sal_uInt16 aBits1 = SVBT16ToUInt16( pTc->aBits1Ver8 );
- pCurrentTC->bFirstMerged = sal_uInt8( ( aBits1 & 0x0001 ) != 0 );
- pCurrentTC->bMerged = sal_uInt8( ( aBits1 & 0x0002 ) != 0 );
- pCurrentTC->bVertical = sal_uInt8( ( aBits1 & 0x0004 ) != 0 );
- pCurrentTC->bBackward = sal_uInt8( ( aBits1 & 0x0008 ) != 0 );
- pCurrentTC->bRotateFont = sal_uInt8( ( aBits1 & 0x0010 ) != 0 );
- pCurrentTC->bVertMerge = sal_uInt8( ( aBits1 & 0x0020 ) != 0 );
- pCurrentTC->bVertRestart = sal_uInt8( ( aBits1 & 0x0040 ) != 0 );
- pCurrentTC->nVertAlign = ( ( aBits1 & 0x0180 ) >> 7 );
- // note: in aBits1 there are 7 bits unused,
- // followed by another 16 unused bits
-
- pCurrentTC->rgbrc[ WW8_TOP ] = WW8_BRCVer9(pTc->rgbrcVer8[ WW8_TOP ]);
- pCurrentTC->rgbrc[ WW8_LEFT ] = WW8_BRCVer9(pTc->rgbrcVer8[ WW8_LEFT ]);
- pCurrentTC->rgbrc[ WW8_BOT ] = WW8_BRCVer9(pTc->rgbrcVer8[ WW8_BOT ]);
- pCurrentTC->rgbrc[ WW8_RIGHT ] = WW8_BRCVer9(pTc->rgbrcVer8[ WW8_RIGHT ]);
- }
+ sal_uInt16 aBits1 = SVBT16ToUInt16( pTc->aBits1Ver8 );
+ pCurrentTC->bFirstMerged = sal_uInt8( ( aBits1 & 0x0001 ) != 0 );
+ pCurrentTC->bMerged = sal_uInt8( ( aBits1 & 0x0002 ) != 0 );
+ pCurrentTC->bVertical = sal_uInt8( ( aBits1 & 0x0004 ) != 0 );
+ pCurrentTC->bBackward = sal_uInt8( ( aBits1 & 0x0008 ) != 0 );
+ pCurrentTC->bRotateFont = sal_uInt8( ( aBits1 & 0x0010 ) != 0 );
+ pCurrentTC->bVertMerge = sal_uInt8( ( aBits1 & 0x0020 ) != 0 );
+ pCurrentTC->bVertRestart = sal_uInt8( ( aBits1 & 0x0040 ) != 0 );
+ pCurrentTC->nVertAlign = ( ( aBits1 & 0x0180 ) >> 7 );
+ // note: in aBits1 there are 7 bits unused,
+ // followed by another 16 unused bits
+
+ pCurrentTC->rgbrc[ WW8_TOP ] = WW8_BRCVer9(pTc->rgbrcVer8[ WW8_TOP ]);
+ pCurrentTC->rgbrc[ WW8_LEFT ] = WW8_BRCVer9(pTc->rgbrcVer8[ WW8_LEFT ]);
+ pCurrentTC->rgbrc[ WW8_BOT ] = WW8_BRCVer9(pTc->rgbrcVer8[ WW8_BOT ]);
+ pCurrentTC->rgbrc[ WW8_RIGHT ] = WW8_BRCVer9(pTc->rgbrcVer8[ WW8_RIGHT ]);
}
+ }
- // #i25071 In '97 text direction appears to be only set using TC properties
- // not with sprmTTextFlow so we need to cycle through the maDirections and
- // double check any non-default directions
- for (int k = 0; k < nCols; ++k)
+ // #i25071 In '97 text direction appears to be only set using TC properties
+ // not with sprmTTextFlow so we need to cycle through the maDirections and
+ // double check any non-default directions
+ for (int k = 0; k < nCols; ++k)
+ {
+ if(maDirections[k] == 4)
{
- if(maDirections[k] == 4)
+ if(pTCs[k].bVertical)
{
- if(pTCs[k].bVertical)
- {
- if(pTCs[k].bBackward)
- maDirections[k] = 3;
- else
- maDirections[k] = 1;
- }
+ if(pTCs[k].bBackward)
+ maDirections[k] = 3;
+ else
+ maDirections[k] = 1;
}
}
}
@@ -1341,20 +1341,20 @@ void WW8TabBandDesc::ProcessSprmTDxaCol(const sal_uInt8* pParamsTDxaCol)
// sprmTDxaCol (opcode 0x7623) changes the width of cells
// whose index is within a certain range to be a certain value.
- if( nWwCols && pParamsTDxaCol ) // set one or more cell length(s)
- {
- sal_uInt8 nitcFirst= pParamsTDxaCol[0]; // first col to be changed
- sal_uInt8 nitcLim = pParamsTDxaCol[1]; // (last col to be changed)+1
- short nDxaCol = static_cast<sal_Int16>(SVBT16ToUInt16( pParamsTDxaCol + 2 ));
+ if( !(nWwCols && pParamsTDxaCol) ) // set one or more cell length(s)
+ return;
+
+ sal_uInt8 nitcFirst= pParamsTDxaCol[0]; // first col to be changed
+ sal_uInt8 nitcLim = pParamsTDxaCol[1]; // (last col to be changed)+1
+ short nDxaCol = static_cast<sal_Int16>(SVBT16ToUInt16( pParamsTDxaCol + 2 ));
- for( int i = nitcFirst; (i < nitcLim) && (i < nWwCols); i++ )
+ for( int i = nitcFirst; (i < nitcLim) && (i < nWwCols); i++ )
+ {
+ const short nOrgWidth = nCenter[i+1] - nCenter[i];
+ const short nDelta = nDxaCol - nOrgWidth;
+ for( int j = i+1; j <= nWwCols; j++ )
{
- const short nOrgWidth = nCenter[i+1] - nCenter[i];
- const short nDelta = nDxaCol - nOrgWidth;
- for( int j = i+1; j <= nWwCols; j++ )
- {
- nCenter[j] = nCenter[j] + nDelta;
- }
+ nCenter[j] = nCenter[j] + nDelta;
}
}
}
@@ -1528,46 +1528,46 @@ void WW8TabBandDesc::ProcessSpecificSpacing(const sal_uInt8* pParams)
void WW8TabBandDesc::ProcessSprmTDelete(const sal_uInt8* pParamsTDelete)
{
- if( nWwCols && pParamsTDelete ) // set one or more cell length(s)
- {
- sal_uInt8 nitcFirst= pParamsTDelete[0]; // first col to be deleted
- if (nitcFirst >= nWwCols) // first index to delete from doesn't exist
- return;
- sal_uInt8 nitcLim = pParamsTDelete[1]; // (last col to be deleted)+1
- if (nitcLim <= nitcFirst) // second index to delete to is not greater than first index
- return;
+ if( !(nWwCols && pParamsTDelete) ) // set one or more cell length(s)
+ return;
- /*
- * sprmTDelete causes any rgdxaCenter and rgtc entries whose index is
- * greater than or equal to itcLim to be moved
- */
- int nShlCnt = nWwCols - nitcLim; // count of cells to be shifted
+ sal_uInt8 nitcFirst= pParamsTDelete[0]; // first col to be deleted
+ if (nitcFirst >= nWwCols) // first index to delete from doesn't exist
+ return;
+ sal_uInt8 nitcLim = pParamsTDelete[1]; // (last col to be deleted)+1
+ if (nitcLim <= nitcFirst) // second index to delete to is not greater than first index
+ return;
+
+ /*
+ * sprmTDelete causes any rgdxaCenter and rgtc entries whose index is
+ * greater than or equal to itcLim to be moved
+ */
+ int nShlCnt = nWwCols - nitcLim; // count of cells to be shifted
- if (nShlCnt >= 0) //There exist entries whose index is greater than or equal to itcLim
+ if (nShlCnt >= 0) //There exist entries whose index is greater than or equal to itcLim
+ {
+ WW8_TCell* pCurrentTC = pTCs + nitcFirst;
+ int i = 0;
+ while( i < nShlCnt )
{
- WW8_TCell* pCurrentTC = pTCs + nitcFirst;
- int i = 0;
- while( i < nShlCnt )
- {
- // adjust the left x-position
- nCenter[nitcFirst + i] = nCenter[nitcLim + i];
+ // adjust the left x-position
+ nCenter[nitcFirst + i] = nCenter[nitcLim + i];
- // adjust the cell's borders
- *pCurrentTC = pTCs[ nitcLim + i];
+ // adjust the cell's borders
+ *pCurrentTC = pTCs[ nitcLim + i];
- ++i;
- ++pCurrentTC;
- }
- // adjust the left x-position of the dummy at the very end
- nCenter[nitcFirst + i] = nCenter[nitcLim + i];
+ ++i;
+ ++pCurrentTC;
}
-
- short nCellsDeleted = nitcLim - nitcFirst;
- //clip delete request to available number of cells
- if (nCellsDeleted > nWwCols)
- nCellsDeleted = nWwCols;
- nWwCols -= nCellsDeleted;
+ // adjust the left x-position of the dummy at the very end
+ nCenter[nitcFirst + i] = nCenter[nitcLim + i];
}
+
+ short nCellsDeleted = nitcLim - nitcFirst;
+ //clip delete request to available number of cells
+ if (nCellsDeleted > nWwCols)
+ nCellsDeleted = nWwCols;
+ nWwCols -= nCellsDeleted;
}
// ReadShd reads the background color of a cell
@@ -2806,41 +2806,41 @@ void WW8TabDesc::FinishSwTable()
MergeCells();
// if needed group cells together that should be merged
- if (!m_MergeGroups.empty())
+ if (m_MergeGroups.empty())
+ return;
+
+ // process all merge groups one by one
+ for (auto const& groupIt : m_MergeGroups)
{
- // process all merge groups one by one
- for (auto const& groupIt : m_MergeGroups)
+ if((1 < groupIt->size()) && groupIt->row(0)[0])
{
- if((1 < groupIt->size()) && groupIt->row(0)[0])
+ SwFrameFormat* pNewFormat = groupIt->row(0)[0]->ClaimFrameFormat();
+ pNewFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Variable, groupIt->nGroupWidth, 0));
+ const sal_uInt16 nRowSpan = groupIt->rowsCount();
+ for (sal_uInt16 n = 0; n < nRowSpan; ++n)
{
- SwFrameFormat* pNewFormat = groupIt->row(0)[0]->ClaimFrameFormat();
- pNewFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Variable, groupIt->nGroupWidth, 0));
- const sal_uInt16 nRowSpan = groupIt->rowsCount();
- for (sal_uInt16 n = 0; n < nRowSpan; ++n)
+ auto& rRow = groupIt->row(n);
+ for (size_t i = 0; i<rRow.size(); ++i)
{
- auto& rRow = groupIt->row(n);
- for (size_t i = 0; i<rRow.size(); ++i)
+ const long nRowSpanSet = (n == 0) && (i == 0) ?
+ nRowSpan :
+ (-1 * (nRowSpan - n));
+ SwTableBox* pCurrentBox = rRow[i];
+ pCurrentBox->setRowSpan(nRowSpanSet);
+
+ if (i == 0)
+ pCurrentBox->ChgFrameFormat(static_cast<SwTableBoxFormat*>(pNewFormat));
+ else
{
- const long nRowSpanSet = (n == 0) && (i == 0) ?
- nRowSpan :
- (-1 * (nRowSpan - n));
- SwTableBox* pCurrentBox = rRow[i];
- pCurrentBox->setRowSpan(nRowSpanSet);
-
- if (i == 0)
- pCurrentBox->ChgFrameFormat(static_cast<SwTableBoxFormat*>(pNewFormat));
- else
- {
- SwFrameFormat* pFormat = pCurrentBox->ClaimFrameFormat();
- pFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Variable, 0, 0));
- }
+ SwFrameFormat* pFormat = pCurrentBox->ClaimFrameFormat();
+ pFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Variable, 0, 0));
}
}
}
}
- m_pIo->m_pFormatOfJustInsertedApo = nullptr;
- m_MergeGroups.clear();
}
+ m_pIo->m_pFormatOfJustInsertedApo = nullptr;
+ m_MergeGroups.clear();
}
// browse m_MergeGroups, detect the index of the first fitting group or -1 otherwise
@@ -2975,60 +2975,61 @@ void WW8TabDesc::SetPamInCell(short nWwCol, bool bPam)
MoveOutsideTable();
return;
}
- if (bPam)
- {
- m_pCurrentWWCell = &m_pActBand->pTCs[ nWwCol ];
+ if (!bPam)
+ return;
+
+ m_pCurrentWWCell = &m_pActBand->pTCs[ nWwCol ];
- // The first paragraph in a cell with upper autospacing has upper spacing set to 0
- if(m_pIo->m_bParaAutoBefore && m_pIo->m_bFirstPara && !m_pIo->m_xWDop->fDontUseHTMLAutoSpacing)
- m_pIo->SetUpperSpacing(*m_pIo->m_pPaM, 0);
+ // The first paragraph in a cell with upper autospacing has upper spacing set to 0
+ if(m_pIo->m_bParaAutoBefore && m_pIo->m_bFirstPara && !m_pIo->m_xWDop->fDontUseHTMLAutoSpacing)
+ m_pIo->SetUpperSpacing(*m_pIo->m_pPaM, 0);
- // The last paragraph in a cell with lower autospacing has lower spacing set to 0
- if(m_pIo->m_bParaAutoAfter && !m_pIo->m_xWDop->fDontUseHTMLAutoSpacing)
- m_pIo->SetLowerSpacing(*m_pIo->m_pPaM, 0);
+ // The last paragraph in a cell with lower autospacing has lower spacing set to 0
+ if(m_pIo->m_bParaAutoAfter && !m_pIo->m_xWDop->fDontUseHTMLAutoSpacing)
+ m_pIo->SetLowerSpacing(*m_pIo->m_pPaM, 0);
- //We need to set the pPaM on the first cell, invalid
- //or not so that we can collect paragraph properties over
- //all the cells, but in that case on the valid cell we do not
- //want to reset the fmt properties
- sal_uLong nSttNd = m_pTabBox->GetSttIdx() + 1,
- nEndNd = m_pTabBox->GetSttNd()->EndOfSectionIndex();
- if (m_pIo->m_pPaM->GetPoint()->nNode != nSttNd)
+ //We need to set the pPaM on the first cell, invalid
+ //or not so that we can collect paragraph properties over
+ //all the cells, but in that case on the valid cell we do not
+ //want to reset the fmt properties
+ sal_uLong nSttNd = m_pTabBox->GetSttIdx() + 1,
+ nEndNd = m_pTabBox->GetSttNd()->EndOfSectionIndex();
+ if (m_pIo->m_pPaM->GetPoint()->nNode != nSttNd)
+ {
+ do
{
- do
- {
- m_pIo->m_pPaM->GetPoint()->nNode = nSttNd;
- }
- while (m_pIo->m_pPaM->GetNode().GetNodeType() != SwNodeType::Text && ++nSttNd < nEndNd);
- m_pIo->m_pPaM->GetPoint()->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), 0);
- // Precautionally set now, otherwise the style is not set for cells
- // that are inserted for margin balancing.
- m_pIo->m_rDoc.SetTextFormatColl(*m_pIo->m_pPaM, const_cast<SwTextFormatColl*>(m_pIo->m_pDfltTextFormatColl));
- // because this cells are invisible helper constructions only to simulate
- // the frayed view of WW-tables we do NOT need SetTextFormatCollAndListLevel()
+ m_pIo->m_pPaM->GetPoint()->nNode = nSttNd;
}
+ while (m_pIo->m_pPaM->GetNode().GetNodeType() != SwNodeType::Text && ++nSttNd < nEndNd);
+ m_pIo->m_pPaM->GetPoint()->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), 0);
+ // Precautionally set now, otherwise the style is not set for cells
+ // that are inserted for margin balancing.
+ m_pIo->m_rDoc.SetTextFormatColl(*m_pIo->m_pPaM, const_cast<SwTextFormatColl*>(m_pIo->m_pDfltTextFormatColl));
+ // because this cells are invisible helper constructions only to simulate
+ // the frayed view of WW-tables we do NOT need SetTextFormatCollAndListLevel()
+ }
- // Better to turn Snap to Grid off for all paragraphs in tables
- if(SwTextNode *pNd = m_pIo->m_pPaM->GetNode().GetTextNode())
- {
- const SfxPoolItem &rItm = pNd->SwContentNode::GetAttr(RES_PARATR_SNAPTOGRID);
- const SvxParaGridItem &rSnapToGrid = static_cast<const SvxParaGridItem&>(rItm);
+ // Better to turn Snap to Grid off for all paragraphs in tables
+ SwTextNode *pNd = m_pIo->m_pPaM->GetNode().GetTextNode();
+ if(!pNd)
+ return;
- if(rSnapToGrid.GetValue())
- {
- SvxParaGridItem aGridItem( rSnapToGrid );
- aGridItem.SetValue(false);
+ const SfxPoolItem &rItm = pNd->SwContentNode::GetAttr(RES_PARATR_SNAPTOGRID);
+ const SvxParaGridItem &rSnapToGrid = static_cast<const SvxParaGridItem&>(rItm);
- SwPosition* pGridPos = m_pIo->m_pPaM->GetPoint();
+ if(!rSnapToGrid.GetValue())
+ return;
- const sal_Int32 nEnd = pGridPos->nContent.GetIndex();
- pGridPos->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), 0);
- m_pIo->m_xCtrlStck->NewAttr(*pGridPos, aGridItem);
- pGridPos->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), nEnd);
- m_pIo->m_xCtrlStck->SetAttr(*pGridPos, RES_PARATR_SNAPTOGRID);
- }
- }
- }
+ SvxParaGridItem aGridItem( rSnapToGrid );
+ aGridItem.SetValue(false);
+
+ SwPosition* pGridPos = m_pIo->m_pPaM->GetPoint();
+
+ const sal_Int32 nEnd = pGridPos->nContent.GetIndex();
+ pGridPos->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), 0);
+ m_pIo->m_xCtrlStck->NewAttr(*pGridPos, aGridItem);
+ pGridPos->nContent.Assign(m_pIo->m_pPaM->GetContentNode(), nEnd);
+ m_pIo->m_xCtrlStck->SetAttr(*pGridPos, RES_PARATR_SNAPTOGRID);
}
void WW8TabDesc::InsertCells( short nIns )
@@ -3342,28 +3343,28 @@ void WW8TabDesc::UpdateTableMergeGroup( WW8_TCell const & rCell,
// E.g., it could be that a cell is the first one to be merged, but no
// new merge group is provided, because the potential other cell to be merged
// doesn't exist - see method <WW8TabDesc::MergeCells>.
- if ( m_pActBand->bExist[ nCol ] &&
+ if ( !(m_pActBand->bExist[ nCol ] &&
( ( rCell.bFirstMerged && pActGroup ) ||
rCell.bMerged ||
rCell.bVertMerge ||
- rCell.bVertRestart ) )
+ rCell.bVertRestart )) )
+ return;
+
+ // detect appropriate merge group
+ WW8SelBoxInfo* pTheMergeGroup = nullptr;
+ if( pActGroup )
+ // assign group
+ pTheMergeGroup = pActGroup;
+ else
{
- // detect appropriate merge group
- WW8SelBoxInfo* pTheMergeGroup = nullptr;
- if( pActGroup )
- // assign group
- pTheMergeGroup = pActGroup;
- else
- {
- // find group
- pTheMergeGroup = FindMergeGroup(
- m_pActBand->nCenter[ nCol ], m_pActBand->nWidth[ nCol ], true );
- }
- if( pTheMergeGroup )
- {
- // add current box to merge group
- pTheMergeGroup->push_back(pActBox);
- }
+ // find group
+ pTheMergeGroup = FindMergeGroup(
+ m_pActBand->nCenter[ nCol ], m_pActBand->nWidth[ nCol ], true );
+ }
+ if( pTheMergeGroup )
+ {
+ // add current box to merge group
+ pTheMergeGroup->push_back(pActBox);
}
}
@@ -3777,42 +3778,42 @@ void WW8RStyle::Set1StyleDefaults()
if (!mbFontChanged) // Style has no Font? set the default,
mpIo->SetNewFontAttr(m_ftcAsci, true, RES_CHRATR_FONT);
- if( !mpIo->m_bNoAttrImport )
- {
- // Style has no text color set, winword default is auto
- if ( !mbTextColChanged )
- mpIo->m_pCurrentColl->SetFormatAttr(SvxColorItem(COL_AUTO, RES_CHRATR_COLOR));
+ if( mpIo->m_bNoAttrImport )
+ return;
- // Style has no FontSize ? WinWord Default is 10pt for western and asian
- if( !mbFSizeChanged )
- {
- SvxFontHeightItem aAttr(200, 100, RES_CHRATR_FONTSIZE);
- mpIo->m_pCurrentColl->SetFormatAttr(aAttr);
- aAttr.SetWhich(RES_CHRATR_CJK_FONTSIZE);
- mpIo->m_pCurrentColl->SetFormatAttr(aAttr);
- }
+ // Style has no text color set, winword default is auto
+ if ( !mbTextColChanged )
+ mpIo->m_pCurrentColl->SetFormatAttr(SvxColorItem(COL_AUTO, RES_CHRATR_COLOR));
- // Style has no FontSize ? WinWord Default is 10pt for western and asian
- if( !mbFCTLSizeChanged )
- {
- SvxFontHeightItem aAttr(200, 100, RES_CHRATR_FONTSIZE);
- aAttr.SetWhich(RES_CHRATR_CTL_FONTSIZE);
- mpIo->m_pCurrentColl->SetFormatAttr(aAttr);
- }
+ // Style has no FontSize ? WinWord Default is 10pt for western and asian
+ if( !mbFSizeChanged )
+ {
+ SvxFontHeightItem aAttr(200, 100, RES_CHRATR_FONTSIZE);
+ mpIo->m_pCurrentColl->SetFormatAttr(aAttr);
+ aAttr.SetWhich(RES_CHRATR_CJK_FONTSIZE);
+ mpIo->m_pCurrentColl->SetFormatAttr(aAttr);
+ }
- if( !mbWidowsChanged ) // Widows ?
- {
- mpIo->m_pCurrentColl->SetFormatAttr( SvxWidowsItem( 2, RES_PARATR_WIDOWS ) );
- mpIo->m_pCurrentColl->SetFormatAttr( SvxOrphansItem( 2, RES_PARATR_ORPHANS ) );
- }
+ // Style has no FontSize ? WinWord Default is 10pt for western and asian
+ if( !mbFCTLSizeChanged )
+ {
+ SvxFontHeightItem aAttr(200, 100, RES_CHRATR_FONTSIZE);
+ aAttr.SetWhich(RES_CHRATR_CTL_FONTSIZE);
+ mpIo->m_pCurrentColl->SetFormatAttr(aAttr);
+ }
- // Word defaults to ltr, not inheriting from the environment like Writer. Regardless of
- // the page/sections rtl setting, the standard/no-inherit styles lack of rtl still means ltr
- if( !mbBidiChanged ) // likely, since no UI to change LTR except in default style
- {
- mpIo->m_pCurrentColl->SetFormatAttr(
- SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR));
- }
+ if( !mbWidowsChanged ) // Widows ?
+ {
+ mpIo->m_pCurrentColl->SetFormatAttr( SvxWidowsItem( 2, RES_PARATR_WIDOWS ) );
+ mpIo->m_pCurrentColl->SetFormatAttr( SvxOrphansItem( 2, RES_PARATR_ORPHANS ) );
+ }
+
+ // Word defaults to ltr, not inheriting from the environment like Writer. Regardless of
+ // the page/sections rtl setting, the standard/no-inherit styles lack of rtl still means ltr
+ if( !mbBidiChanged ) // likely, since no UI to change LTR except in default style
+ {
+ mpIo->m_pCurrentColl->SetFormatAttr(
+ SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR));
}
}
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index caaec595d45e..a1f8611b9a4f 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1664,21 +1664,21 @@ void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat)
void SetStyleIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat)
{
- if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) // #i86652#
+ if ( rFormat.GetPositionAndSpaceMode() != SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) // #i86652#
+ return;
+
+ SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*rStyle.m_pFormat, RES_LR_SPACE));
+ if (rStyle.m_bListReleventIndentSet)
{
- SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*rStyle.m_pFormat, RES_LR_SPACE));
- if (rStyle.m_bListReleventIndentSet)
- {
- SyncIndentWithList( aLR, rFormat, false, false ); // #i103711#, #i105414#
- }
- else
- {
- aLR.SetTextLeft(0);
- aLR.SetTextFirstLineOffset(0);
- }
- rStyle.m_pFormat->SetFormatAttr(aLR);
+ SyncIndentWithList( aLR, rFormat, false, false ); // #i103711#, #i105414#
}
+ else
+ {
+ aLR.SetTextLeft(0);
+ aLR.SetTextFirstLineOffset(0);
+ }
+ rStyle.m_pFormat->SetFormatAttr(aLR);
}
void SwWW8ImplReader::SetStylesList(sal_uInt16 nStyle, sal_uInt16 nCurrentLFO,
@@ -1688,29 +1688,29 @@ void SwWW8ImplReader::SetStylesList(sal_uInt16 nStyle, sal_uInt16 nCurrentLFO,
return;
SwWW8StyInf &rStyleInf = m_vColl[nStyle];
- if (rStyleInf.m_bValid)
+ if (!rStyleInf.m_bValid)
+ return;
+
+ OSL_ENSURE(m_pCurrentColl, "Cannot be called outside of style import");
+ // Phase 1: Numbering attributes when reading a StyleDef
+ if( !m_pCurrentColl )
+ return;
+
+ // only save the Parameters for now. The actual List will be appended
+ // at a later point, when the Listdefinitions is read...
+ if (
+ (USHRT_MAX > nCurrentLFO) &&
+ (WW8ListManager::nMaxLevel > nCurrentLevel)
+ )
{
- OSL_ENSURE(m_pCurrentColl, "Cannot be called outside of style import");
- // Phase 1: Numbering attributes when reading a StyleDef
- if( m_pCurrentColl )
- {
- // only save the Parameters for now. The actual List will be appended
- // at a later point, when the Listdefinitions is read...
- if (
- (USHRT_MAX > nCurrentLFO) &&
- (WW8ListManager::nMaxLevel > nCurrentLevel)
- )
- {
- rStyleInf.m_nLFOIndex = nCurrentLFO;
- rStyleInf.m_nListLevel = nCurrentLevel;
-
- std::vector<sal_uInt8> aParaSprms;
- SwNumRule* pNmRule = m_xLstManager->GetNumRuleForActivation(
- nCurrentLFO, nCurrentLevel, aParaSprms);
- if (pNmRule)
- UseListIndent(rStyleInf, pNmRule->Get(nCurrentLevel));
- }
- }
+ rStyleInf.m_nLFOIndex = nCurrentLFO;
+ rStyleInf.m_nListLevel = nCurrentLevel;
+
+ std::vector<sal_uInt8> aParaSprms;
+ SwNumRule* pNmRule = m_xLstManager->GetNumRuleForActivation(
+ nCurrentLFO, nCurrentLevel, aParaSprms);
+ if (pNmRule)
+ UseListIndent(rStyleInf, pNmRule->Get(nCurrentLevel));
}
}
@@ -1721,43 +1721,43 @@ void SwWW8ImplReader::RegisterNumFormatOnStyle(sal_uInt16 nStyle)
return;
SwWW8StyInf &rStyleInf = m_vColl[nStyle];
- if (rStyleInf.m_bValid && rStyleInf.m_pFormat)
- {
- //Save old pre-list modified indent, which are the word indent values
- rStyleInf.maWordLR.reset(ItemGet<SvxLRSpaceItem>(*rStyleInf.m_pFormat, RES_LR_SPACE).Clone());
-
- // Phase 2: refresh StyleDef after reading all Lists
- SwNumRule* pNmRule = nullptr;
- const sal_uInt16 nLFO = rStyleInf.m_nLFOIndex;
- const sal_uInt8 nLevel = rStyleInf.m_nListLevel;
- if (
- (USHRT_MAX > nLFO) &&
- (WW8ListManager::nMaxLevel > nLevel)
- )
- {
- std::vector<sal_uInt8> aParaSprms;
- pNmRule = m_xLstManager->GetNumRuleForActivation(nLFO, nLevel,
- aParaSprms);
+ if (!(rStyleInf.m_bValid && rStyleInf.m_pFormat))
+ return;
- if (pNmRule != nullptr)
+ //Save old pre-list modified indent, which are the word indent values
+ rStyleInf.maWordLR.reset(ItemGet<SvxLRSpaceItem>(*rStyleInf.m_pFormat, RES_LR_SPACE).Clone());
+
+ // Phase 2: refresh StyleDef after reading all Lists
+ SwNumRule* pNmRule = nullptr;
+ const sal_uInt16 nLFO = rStyleInf.m_nLFOIndex;
+ const sal_uInt8 nLevel = rStyleInf.m_nListLevel;
+ if (
+ (USHRT_MAX > nLFO) &&
+ (WW8ListManager::nMaxLevel > nLevel)
+ )
+ {
+ std::vector<sal_uInt8> aParaSprms;
+ pNmRule = m_xLstManager->GetNumRuleForActivation(nLFO, nLevel,
+ aParaSprms);
+
+ if (pNmRule != nullptr)
+ {
+ if (rStyleInf.IsWW8BuiltInHeadingStyle()
+ && rStyleInf.HasWW8OutlineLevel())
{
- if (rStyleInf.IsWW8BuiltInHeadingStyle()
- && rStyleInf.HasWW8OutlineLevel())
- {
- rStyleInf.m_pOutlineNumrule = pNmRule;
- }
- else
- {
- rStyleInf.m_pFormat->SetFormatAttr(
- SwNumRuleItem(pNmRule->GetName()));
- rStyleInf.m_bHasStyNumRule = true;
- }
+ rStyleInf.m_pOutlineNumrule = pNmRule;
+ }
+ else
+ {
+ rStyleInf.m_pFormat->SetFormatAttr(
+ SwNumRuleItem(pNmRule->GetName()));
+ rStyleInf.m_bHasStyNumRule = true;
}
}
-
- if (pNmRule)
- SetStyleIndent(rStyleInf, pNmRule->Get(nLevel));
}
+
+ if (pNmRule)
+ SetStyleIndent(rStyleInf, pNmRule->Get(nLevel));
}
void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
@@ -1769,86 +1769,86 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO,
// and only sets the Level. It does not check if there is a NumRule
// attached to the STYLE !!!
- if (m_xLstManager) // are all list declarations read?
+ if (!m_xLstManager) // are all list declarations read?
+ return;
+
+ SwTextNode* pTextNd = m_pPaM->GetNode().GetTextNode();
+ OSL_ENSURE(pTextNd, "No Text-Node at PaM-Position");
+ if (!pTextNd)
+ return;
+
+ std::vector<sal_uInt8> aParaSprms;
+ const SwNumRule* pRule = bSetAttr ?
+ m_xLstManager->GetNumRuleForActivation( nCurrentLFO, nCurrentLevel,
+ aParaSprms, pTextNd) : nullptr;
+
+ if (pRule == nullptr && bSetAttr)
+ return;
+
+ if (bSetAttr && pTextNd->GetNumRule() != pRule
+ && pTextNd->GetNumRule() != m_rDoc.GetOutlineNumRule())
{
- SwTextNode* pTextNd = m_pPaM->GetNode().GetTextNode();
- OSL_ENSURE(pTextNd, "No Text-Node at PaM-Position");
- if (!pTextNd)
- return;
+ pTextNd->SetAttr(SwNumRuleItem(pRule->GetName()));
+ }
+ pTextNd->SetAttrListLevel(nCurrentLevel);
- std::vector<sal_uInt8> aParaSprms;
- const SwNumRule* pRule = bSetAttr ?
- m_xLstManager->GetNumRuleForActivation( nCurrentLFO, nCurrentLevel,
- aParaSprms, pTextNd) : nullptr;
+ // <IsCounted()> state of text node has to be adjusted accordingly.
+ if ( /*nCurrentLevel >= 0 &&*/ nCurrentLevel < MAXLEVEL )
+ {
+ pTextNd->SetCountedInList( true );
+ }
- if (pRule != nullptr || !bSetAttr)
+ // #i99822#
+ // Direct application of the list level formatting no longer
+ // needed for list levels of mode LABEL_ALIGNMENT
+ bool bApplyListLevelIndentDirectlyAtPara(true);
+ {
+ if (pTextNd->GetNumRule() && nCurrentLevel < MAXLEVEL)
{
- if (bSetAttr && pTextNd->GetNumRule() != pRule
- && pTextNd->GetNumRule() != m_rDoc.GetOutlineNumRule())
+ const SwNumFormat& rFormat = pTextNd->GetNumRule()->Get(nCurrentLevel);
+ if (rFormat.GetPositionAndSpaceMode()
+ == SvxNumberFormat::LABEL_ALIGNMENT)
{
- pTextNd->SetAttr(SwNumRuleItem(pRule->GetName()));
- }
- pTextNd->SetAttrListLevel(nCurrentLevel);
-
- // <IsCounted()> state of text node has to be adjusted accordingly.
- if ( /*nCurrentLevel >= 0 &&*/ nCurrentLevel < MAXLEVEL )
- {
- pTextNd->SetCountedInList( true );
+ bApplyListLevelIndentDirectlyAtPara = false;
}
+ }
+ }
- // #i99822#
- // Direct application of the list level formatting no longer
- // needed for list levels of mode LABEL_ALIGNMENT
- bool bApplyListLevelIndentDirectlyAtPara(true);
- {
- if (pTextNd->GetNumRule() && nCurrentLevel < MAXLEVEL)
- {
- const SwNumFormat& rFormat = pTextNd->GetNumRule()->Get(nCurrentLevel);
- if (rFormat.GetPositionAndSpaceMode()
- == SvxNumberFormat::LABEL_ALIGNMENT)
- {
- bApplyListLevelIndentDirectlyAtPara = false;
- }
- }
- }
+ if (!bApplyListLevelIndentDirectlyAtPara)
+ return;
- if (bApplyListLevelIndentDirectlyAtPara)
- {
- std::unique_ptr<SfxItemSet> xListIndent(new SfxItemSet(m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE,
- RES_LR_SPACE>{}));
- const SvxLRSpaceItem *pItem = static_cast<const SvxLRSpaceItem*>(
- GetFormatAttr(RES_LR_SPACE));
- OSL_ENSURE(pItem, "impossible");
- if (pItem)
- xListIndent->Put(*pItem);
+ std::unique_ptr<SfxItemSet> xListIndent(new SfxItemSet(m_rDoc.GetAttrPool(), svl::Items<RES_LR_SPACE,
+ RES_LR_SPACE>{}));
+ const SvxLRSpaceItem *pItem = static_cast<const SvxLRSpaceItem*>(
+ GetFormatAttr(RES_LR_SPACE));
+ OSL_ENSURE(pItem, "impossible");
+ if (pItem)
+ xListIndent->Put(*pItem);
- /*
- Take the original paragraph sprms attached to this list level
- formatting and apply them to the paragraph. I'm convinced that
- this is exactly what word does.
- */
- if (short nLen = static_cast< short >(aParaSprms.size()))
- {
- std::unique_ptr<SfxItemSet> xOldCurrentItemSet(SetCurrentItemSet(std::move(xListIndent)));
+ /*
+ Take the original paragraph sprms attached to this list level
+ formatting and apply them to the paragraph. I'm convinced that
+ this is exactly what word does.
+ */
+ if (short nLen = static_cast< short >(aParaSprms.size()))
+ {
+ std::unique_ptr<SfxItemSet> xOldCurrentItemSet(SetCurrentItemSet(std::move(xListIndent)));
- sal_uInt8* pSprms1 = aParaSprms.data();
- while (0 < nLen)
- {
- sal_uInt16 nL1 = ImportSprm(pSprms1, nLen);
- nLen = nLen - nL1;
- pSprms1 += nL1;
- }
+ sal_uInt8* pSprms1 = aParaSprms.data();
+ while (0 < nLen)
+ {
+ sal_uInt16 nL1 = ImportSprm(pSprms1, nLen);
+ nLen = nLen - nL1;
+ pSprms1 += nL1;
+ }
- xListIndent = SetCurrentItemSet(std::move(xOldCurrentItemSet));
- }
+ xListIndent = SetCurrentItemSet(std::move(xOldCurrentItemSet));
+ }
- if (const SvxLRSpaceItem *pLR = xListIndent->GetItem<SvxLRSpaceItem>(RES_LR_SPACE))
- {
- m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pLR);
- m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE);
- }
- }
- }
+ if (const SvxLRSpaceItem *pLR = xListIndent->GetItem<SvxLRSpaceItem>(RES_LR_SPACE))
+ {
+ m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pLR);
+ m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE);
}
}
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 2836ca22dc29..1cc60c27a8af 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -2844,66 +2844,66 @@ static void EnsureMaxLevelForTemplates(SwTOXBase& rBase)
static void lcl_toxMatchTSwitch(SwWW8ImplReader const & rReader, SwTOXBase& rBase,
WW8ReadFieldParams& rParam)
{
- if ( rParam.GoToTokenParam() )
- {
- OUString sParams( rParam.GetResult() );
- if( !sParams.isEmpty() )
- {
- sal_Int32 nIndex = 0;
+ if ( !rParam.GoToTokenParam() )
+ return;
- // Delimiters between styles and style levels appears to allow both ; and ,
+ OUString sParams( rParam.GetResult() );
+ if( sParams.isEmpty() )
+ return;
- OUString sTemplate( sParams.getToken(0, ';', nIndex) );
- if( -1 == nIndex )
- {
- nIndex=0;
- sTemplate = sParams.getToken(0, ',', nIndex);
- }
- if( -1 == nIndex )
- {
- const SwFormat* pStyle = rReader.GetStyleWithOrgWWName(sTemplate);
- if( pStyle )
- sTemplate = pStyle->GetName();
- // Store Style for Level 0 into TOXBase
- rBase.SetStyleNames( sTemplate, 0 );
- }
- else while( -1 != nIndex )
- {
- sal_Int32 nOldIndex=nIndex;
- sal_uInt16 nLevel = static_cast<sal_uInt16>(
- sParams.getToken(0, ';', nIndex).toInt32());
- if( -1 == nIndex )
- {
- nIndex = nOldIndex;
- nLevel = static_cast<sal_uInt16>(
- sParams.getToken(0, ',', nIndex).toInt32());
- }
+ sal_Int32 nIndex = 0;
- if( (0 < nLevel) && (MAXLEVEL >= nLevel) )
- {
- nLevel--;
- // Store Style and Level into TOXBase
- const SwFormat* pStyle
- = rReader.GetStyleWithOrgWWName( sTemplate );
-
- if( pStyle )
- sTemplate = pStyle->GetName();
-
- OUString sStyles( rBase.GetStyleNames( nLevel ) );
- if( !sStyles.isEmpty() )
- sStyles += OUStringChar(TOX_STYLE_DELIMITER);
- sStyles += sTemplate;
- rBase.SetStyleNames( sStyles, nLevel );
- }
- // read next style name...
- nOldIndex = nIndex;
- sTemplate = sParams.getToken(0, ';', nIndex);
- if( -1 == nIndex )
- {
- nIndex=nOldIndex;
- sTemplate = sParams.getToken(0, ',', nIndex);
- }
- }
+ // Delimiters between styles and style levels appears to allow both ; and ,
+
+ OUString sTemplate( sParams.getToken(0, ';', nIndex) );
+ if( -1 == nIndex )
+ {
+ nIndex=0;
+ sTemplate = sParams.getToken(0, ',', nIndex);
+ }
+ if( -1 == nIndex )
+ {
+ const SwFormat* pStyle = rReader.GetStyleWithOrgWWName(sTemplate);
+ if( pStyle )
+ sTemplate = pStyle->GetName();
+ // Store Style for Level 0 into TOXBase
+ rBase.SetStyleNames( sTemplate, 0 );
+ }
+ else while( -1 != nIndex )
+ {
+ sal_Int32 nOldIndex=nIndex;
+ sal_uInt16 nLevel = static_cast<sal_uInt16>(
+ sParams.getToken(0, ';', nIndex).toInt32());
+ if( -1 == nIndex )
+ {
+ nIndex = nOldIndex;
+ nLevel = static_cast<sal_uInt16>(
+ sParams.getToken(0, ',', nIndex).toInt32());
+ }
+
+ if( (0 < nLevel) && (MAXLEVEL >= nLevel) )
+ {
+ nLevel--;
+ // Store Style and Level into TOXBase
+ const SwFormat* pStyle
+ = rReader.GetStyleWithOrgWWName( sTemplate );
+
+ if( pStyle )
+ sTemplate = pStyle->GetName();
+
+ OUString sStyles( rBase.GetStyleNames( nLevel ) );
+ if( !sStyles.isEmpty() )
+ sStyles += OUStringChar(TOX_STYLE_DELIMITER);
+ sStyles += sTemplate;
+ rBase.SetStyleNames( sStyles, nLevel );
+ }
+ // read next style name...
+ nOldIndex = nIndex;
+ sTemplate = sParams.getToken(0, ';', nIndex);
+ if( -1 == nIndex )
+ {
+ nIndex=nOldIndex;
+ sTemplate = sParams.getToken(0, ',', nIndex);
}
}
}
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 7469ba9e8c8d..a5ab4e083db2 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -754,49 +754,49 @@ SwSectionFormat *wwSectionManager::InsertSection(
void SwWW8ImplReader::HandleLineNumbering(const wwSection &rSection)
{
// check if Line Numbering must be activated or reset
- if (m_bNewDoc && rSection.maSep.nLnnMod)
- {
- // restart-numbering-mode: 0 per page, 1 per section, 2 never restart
- bool bRestartLnNumPerSection = (1 == rSection.maSep.lnc);
+ if (!(m_bNewDoc && rSection.maSep.nLnnMod))
+ return;
- if (m_bNoLnNumYet)
- {
- SwLineNumberInfo aInfo( m_rDoc.GetLineNumberInfo() );
+ // restart-numbering-mode: 0 per page, 1 per section, 2 never restart
+ bool bRestartLnNumPerSection = (1 == rSection.maSep.lnc);
- aInfo.SetPaintLineNumbers(true);
+ if (m_bNoLnNumYet)
+ {
+ SwLineNumberInfo aInfo( m_rDoc.GetLineNumberInfo() );
- aInfo.SetRestartEachPage(rSection.maSep.lnc == 0);
+ aInfo.SetPaintLineNumbers(true);
- // A value of 0 (auto) indicates that the application MUST automatically determine positioning.
- if ( rSection.maSep.dxaLnn )
- aInfo.SetPosFromLeft(writer_cast<sal_uInt16>(rSection.maSep.dxaLnn));
+ aInfo.SetRestartEachPage(rSection.maSep.lnc == 0);
- //Paint only for every n line
- aInfo.SetCountBy(rSection.maSep.nLnnMod);
+ // A value of 0 (auto) indicates that the application MUST automatically determine positioning.
+ if ( rSection.maSep.dxaLnn )
+ aInfo.SetPosFromLeft(writer_cast<sal_uInt16>(rSection.maSep.dxaLnn));
- // to be defaulted features ( HARDCODED in MS Word 6,7,8,9 )
- aInfo.SetCountBlankLines(true);
- aInfo.SetCountInFlys(false);
- aInfo.SetPos( LINENUMBER_POS_LEFT );
- SvxNumberType aNumType; // this sets SVX_NUM_ARABIC per default
- aInfo.SetNumType( aNumType );
+ //Paint only for every n line
+ aInfo.SetCountBy(rSection.maSep.nLnnMod);
- m_rDoc.SetLineNumberInfo( aInfo );
- m_bNoLnNumYet = false;
- }
+ // to be defaulted features ( HARDCODED in MS Word 6,7,8,9 )
+ aInfo.SetCountBlankLines(true);
+ aInfo.SetCountInFlys(false);
+ aInfo.SetPos( LINENUMBER_POS_LEFT );
+ SvxNumberType aNumType; // this sets SVX_NUM_ARABIC per default
+ aInfo.SetNumType( aNumType );
+
+ m_rDoc.SetLineNumberInfo( aInfo );
+ m_bNoLnNumYet = false;
+ }
- if ((0 < rSection.maSep.lnnMin) || bRestartLnNumPerSection)
+ if ((0 < rSection.maSep.lnnMin) || bRestartLnNumPerSection)
+ {
+ SwFormatLineNumber aLN;
+ if (const SwFormatLineNumber* pLN
+ = static_cast<const SwFormatLineNumber*>(GetFormatAttr(RES_LINENUMBER)))
{
- SwFormatLineNumber aLN;
- if (const SwFormatLineNumber* pLN
- = static_cast<const SwFormatLineNumber*>(GetFormatAttr(RES_LINENUMBER)))
- {
- aLN.SetCountLines( pLN->IsCount() );
- }
- aLN.SetStartValue(1 + rSection.maSep.lnnMin);
- NewAttr(aLN);
- m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LINENUMBER);
+ aLN.SetCountLines( pLN->IsCount() );
}
+ aLN.SetStartValue(1 + rSection.maSep.lnnMin);
+ NewAttr(aLN);
+ m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LINENUMBER);
}
}
@@ -2156,20 +2156,20 @@ WW8FlySet::WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
Put( SwFormatWrapInfluenceOnObjPos(
text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ) );
- if( !bGraf )
- {
- Put( SwFormatAnchor(WW8SwFlyPara::eAnchor) );
- // adjust size
+ if( bGraf )
+ return;
- //Ordinarily with frames, the border width and spacing is
- //placed outside the frame, making it larger. With these
- //types of frames, the left right thickness and space makes
- //it wider, but the top bottom spacing and border thickness
- //is placed inside.
- Put( SwFormatFrameSize( pFS->eHeightFix, pFS->nWidth +
- aSizeArray[WW8_LEFT] + aSizeArray[WW8_RIGHT],
- pFS->nHeight));
- }
+ Put( SwFormatAnchor(WW8SwFlyPara::eAnchor) );
+ // adjust size
+
+ //Ordinarily with frames, the border width and spacing is
+ //placed outside the frame, making it larger. With these
+ //types of frames, the left right thickness and space makes
+ //it wider, but the top bottom spacing and border thickness
+ //is placed inside.
+ Put( SwFormatFrameSize( pFS->eHeightFix, pFS->nWidth +
+ aSizeArray[WW8_LEFT] + aSizeArray[WW8_RIGHT],
+ pFS->nHeight));
}
// WW8FlySet-ctor for character bound graphics
@@ -2748,41 +2748,41 @@ void SwWW8ImplReader::NewAttr( const SfxPoolItem& rAttr,
const bool bFirstLineOfStSet,
const bool bLeftIndentSet )
{
- if( !m_bNoAttrImport ) // for ignoring styles during doc inserts
+ if( m_bNoAttrImport ) // for ignoring styles during doc inserts
+ return;
+
+ if (m_pCurrentColl)
{
- if (m_pCurrentColl)
- {
- OSL_ENSURE(rAttr.Which() != RES_FLTR_REDLINE, "redline in style!");
- m_pCurrentColl->SetFormatAttr(rAttr);
- }
- else if (m_xCurrentItemSet)
- {
- m_xCurrentItemSet->Put(rAttr);
- }
- else if (rAttr.Which() == RES_FLTR_REDLINE)
+ OSL_ENSURE(rAttr.Which() != RES_FLTR_REDLINE, "redline in style!");
+ m_pCurrentColl->SetFormatAttr(rAttr);
+ }
+ else if (m_xCurrentItemSet)
+ {
+ m_xCurrentItemSet->Put(rAttr);
+ }
+ else if (rAttr.Which() == RES_FLTR_REDLINE)
+ {
+ m_xRedlineStack->open(*m_pPaM->GetPoint(), rAttr);
+ }
+ else
+ {
+ m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), rAttr);
+ // #i103711#
+ if ( bFirstLineOfStSet )
{
- m_xRedlineStack->open(*m_pPaM->GetPoint(), rAttr);
+ const SwNode* pNd = &(m_pPaM->GetPoint()->nNode.GetNode());
+ m_aTextNodesHavingFirstLineOfstSet.insert( pNd );
}
- else
+ // #i105414#
+ if ( bLeftIndentSet )
{
- m_xCtrlStck->NewAttr(*m_pPaM->GetPoint(), rAttr);
- // #i103711#
- if ( bFirstLineOfStSet )
- {
- const SwNode* pNd = &(m_pPaM->GetPoint()->nNode.GetNode());
- m_aTextNodesHavingFirstLineOfstSet.insert( pNd );
- }
- // #i105414#
- if ( bLeftIndentSet )
- {
- const SwNode* pNd = &(m_pPaM->GetPoint()->nNode.GetNode());
- m_aTextNodesHavingLeftIndentSet.insert( pNd );
- }
+ const SwNode* pNd = &(m_pPaM->GetPoint()->nNode.GetNode());
+ m_aTextNodesHavingLeftIndentSet.insert( pNd );
}
-
- if (m_pPostProcessAttrsInfo && m_pPostProcessAttrsInfo->mbCopy)
- m_pPostProcessAttrsInfo->mItemSet.Put(rAttr);
}
+
+ if (m_pPostProcessAttrsInfo && m_pPostProcessAttrsInfo->mbCopy)
+ m_pPostProcessAttrsInfo->mItemSet.Put(rAttr);
}
// fetches attribute from FormatColl / Stack / Doc
@@ -2908,42 +2908,42 @@ void SwWW8ImplReader::Read_POutLvl(sal_uInt16, const sal_uInt8* pData, short nLe
void SwWW8ImplReader::Read_Symbol(sal_uInt16, const sal_uInt8* pData, short nLen )
{
- if( !m_bIgnoreText )
+ if( m_bIgnoreText )
+ return;
+
+ if (nLen < (m_bVer67 ? 3 : 4))
{
- if (nLen < (m_bVer67 ? 3 : 4))
- {
- //otherwise disable after we print the char
- if (m_xPlcxMan && m_xPlcxMan->GetDoingDrawTextBox())
- m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_FONT );
- m_bSymbol = false;
- }
- else
+ //otherwise disable after we print the char
+ if (m_xPlcxMan && m_xPlcxMan->GetDoingDrawTextBox())
+ m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_FONT );
+ m_bSymbol = false;
+ }
+ else
+ {
+ // Make new Font-Attribut
+ // (will be closed in SwWW8ImplReader::ReadChars() )
+
+ //Will not be added to the charencoding stack, for styles the real
+ //font setting will be put in as the styles charset, and for plain
+ //text encoding for symbols is moot. Drawing boxes will check bSymbol
+ //themselves so they don't need to add it to the stack either.
+ if (SetNewFontAttr(SVBT16ToUInt16( pData ), false, RES_CHRATR_FONT))
{
- // Make new Font-Attribut
- // (will be closed in SwWW8ImplReader::ReadChars() )
-
- //Will not be added to the charencoding stack, for styles the real
- //font setting will be put in as the styles charset, and for plain
- //text encoding for symbols is moot. Drawing boxes will check bSymbol
- //themselves so they don't need to add it to the stack either.
- if (SetNewFontAttr(SVBT16ToUInt16( pData ), false, RES_CHRATR_FONT))
+ SetNewFontAttr(SVBT16ToUInt16( pData ), false, RES_CHRATR_CJK_FONT);
+ SetNewFontAttr(SVBT16ToUInt16( pData ), false, RES_CHRATR_CTL_FONT);
+ if( m_bVer67 )
{
- SetNewFontAttr(SVBT16ToUInt16( pData ), false, RES_CHRATR_CJK_FONT);
- SetNewFontAttr(SVBT16ToUInt16( pData ), false, RES_CHRATR_CTL_FONT);
- if( m_bVer67 )
- {
- //convert single byte from MS1252 to Unicode
- m_cSymbol = OUString(
- reinterpret_cast<const char*>(pData+2), 1,
- RTL_TEXTENCODING_MS_1252).toChar();
- }
- else
- {
- //already is Unicode
- m_cSymbol = SVBT16ToUInt16( pData+2 );
- }
- m_bSymbol = true;
+ //convert single byte from MS1252 to Unicode
+ m_cSymbol = OUString(
+ reinterpret_cast<const char*>(pData+2), 1,
+ RTL_TEXTENCODING_MS_1252).toChar();
}
+ else
+ {
+ //already is Unicode
+ m_cSymbol = SVBT16ToUInt16( pData+2 );
+ }
+ m_bSymbol = true;
}
}
}
@@ -3849,48 +3849,49 @@ void SwWW8ImplReader::Read_FontCode( sal_uInt16 nId, const sal_uInt8* pData, sho
//Note: this function needs to be able to run multiple times on the same data.
//It is called by Read_SubSuperProp to ensure that the current fontsize is known.
- if (!m_bSymbol) // if bSymbol, the symbol's font
- { // (see sprmCSymbol) is valid!
- switch( nId )
- {
- case 113: //WW7
- case NS_sprm::CRgFtc2::val: //"Other" font, override with BiDi if it exists
- case NS_sprm::CFtcBi::val: //BiDi Font
- nId = RES_CHRATR_CTL_FONT;
- break;
- case NS_sprm::v6::sprmCFtc: //WW6
- case 111: //WW7
- case NS_sprm::CRgFtc0::val:
- nId = RES_CHRATR_FONT;
- break;
- case 112: //WW7
- case NS_sprm::CRgFtc1::val:
- nId = RES_CHRATR_CJK_FONT;
- break;
- default:
- return ;
- }
+ if (m_bSymbol) // if bSymbol, the symbol's font
+ return;
+
+// (see sprmCSymbol) is valid!
+ switch( nId )
+ {
+ case 113: //WW7
+ case NS_sprm::CRgFtc2::val: //"Other" font, override with BiDi if it exists
+ case NS_sprm::CFtcBi::val: //BiDi Font
+ nId = RES_CHRATR_CTL_FONT;
+ break;
+ case NS_sprm::v6::sprmCFtc: //WW6
+ case 111: //WW7
+ case NS_sprm::CRgFtc0::val:
+ nId = RES_CHRATR_FONT;
+ break;
+ case 112: //WW7
+ case NS_sprm::CRgFtc1::val:
+ nId = RES_CHRATR_CJK_FONT;
+ break;
+ default:
+ return ;
+ }
- ww::WordVersion eVersion = m_xWwFib->GetFIBVersion();
+ ww::WordVersion eVersion = m_xWwFib->GetFIBVersion();
- if (nLen < 2) // end of attribute
+ if (nLen < 2) // end of attribute
+ {
+ if (eVersion <= ww::eWW6)
{
- if (eVersion <= ww::eWW6)
- {
- closeFont(RES_CHRATR_CTL_FONT);
- closeFont(RES_CHRATR_CJK_FONT);
- }
- closeFont(nId);
+ closeFont(RES_CHRATR_CTL_FONT);
+ closeFont(RES_CHRATR_CJK_FONT);
}
- else
+ closeFont(nId);
+ }
+ else
+ {
+ sal_uInt16 nFCode = SVBT16ToUInt16( pData ); // font number
+ openFont(nFCode, nId);
+ if (eVersion <= ww::eWW6)
{
- sal_uInt16 nFCode = SVBT16ToUInt16( pData ); // font number
- openFont(nFCode, nId);
- if (eVersion <= ww::eWW6)
- {
- openFont(nFCode, RES_CHRATR_CJK_FONT);
- openFont(nFCode, RES_CHRATR_CTL_FONT);
- }
+ openFont(nFCode, RES_CHRATR_CJK_FONT);
+ openFont(nFCode, RES_CHRATR_CTL_FONT);
}
}
}
@@ -4951,25 +4952,25 @@ Color SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67)
void SwWW8ImplReader::Read_TextVerticalAdjustment( sal_uInt16, const sal_uInt8* pData, short nLen )
{
- if( nLen > 0 )
+ if( nLen <= 0 )
+ return;
+
+ drawing::TextVerticalAdjust nVA = drawing::TextVerticalAdjust_TOP;
+ switch( *pData )
{
- drawing::TextVerticalAdjust nVA = drawing::TextVerticalAdjust_TOP;
- switch( *pData )
- {
- case 1:
- nVA = drawing::TextVerticalAdjust_CENTER;
- break;
- case 2: //justify
- nVA = drawing::TextVerticalAdjust_BLOCK;
- break;
- case 3:
- nVA = drawing::TextVerticalAdjust_BOTTOM;
- break;
- default:
- break;
- }
- m_aSectionManager.SetCurrentSectionVerticalAdjustment( nVA );
+ case 1:
+ nVA = drawing::TextVerticalAdjust_CENTER;
+ break;
+ case 2: //justify
+ nVA = drawing::TextVerticalAdjust_BLOCK;
+ break;
+ case 3:
+ nVA = drawing::TextVerticalAdjust_BOTTOM;
+ break;
+ default:
+ break;
}
+ m_aSectionManager.SetCurrentSectionVerticalAdjustment( nVA );
}
void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8*, short nLen)
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index d985001f1b85..7b379c6d1f3e 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -3305,21 +3305,21 @@ void WW8PLCFx_Fc_FKP::HasSprm(sal_uInt16 nId, std::vector<SprmResult> &rResult)
WW8PLCFxDesc aDesc;
GetPCDSprms( aDesc );
- if (aDesc.pMemPos)
+ if (!aDesc.pMemPos)
+ return;
+
+ const wwSprmParser &rSprmParser = pFkp->GetSprmParser();
+ WW8SprmIter aIter(aDesc.pMemPos, aDesc.nSprmsLen, rSprmParser);
+ while(aIter.GetSprms())
{
- const wwSprmParser &rSprmParser = pFkp->GetSprmParser();
- WW8SprmIter aIter(aDesc.pMemPos, aDesc.nSprmsLen, rSprmParser);
- while(aIter.GetSprms())
+ if (aIter.GetCurrentId() == nId)
{
- if (aIter.GetCurrentId() == nId)
- {
- sal_uInt16 nFixedLen = rSprmParser.DistanceToData(nId);
- sal_uInt16 nL = rSprmParser.GetSprmSize(nId, aIter.GetSprms(), aIter.GetRemLen());
- rResult.emplace_back(aIter.GetCurrentParams(), nL - nFixedLen);
- }
- aIter.advance();
- };
- }
+ sal_uInt16 nFixedLen = rSprmParser.DistanceToData(nId);
+ sal_uInt16 nL = rSprmParser.GetSprmSize(nId, aIter.GetSprms(), aIter.GetRemLen());
+ rResult.emplace_back(aIter.GetCurrentParams(), nL - nFixedLen);
+ }
+ aIter.advance();
+ };
}
WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt,
@@ -4362,25 +4362,25 @@ long WW8PLCFx_Book::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& rLen )
void WW8PLCFx_Book::advance()
{
- if( pBook[0] && pBook[1] && nIMax )
- {
- (*pBook[nIsEnd]).advance();
+ if( !(pBook[0] && pBook[1] && nIMax) )
+ return;
+
+ (*pBook[nIsEnd]).advance();
- sal_uLong l0 = pBook[0]->Where();
- sal_uLong l1 = pBook[1]->Where();
- if( l0 < l1 )
+ sal_uLong l0 = pBook[0]->Where();
+ sal_uLong l1 = pBook[1]->Where();
+ if( l0 < l1 )
+ nIsEnd = 0;
+ else if( l1 < l0 )
+ nIsEnd = 1;
+ else
+ {
+ const void * p = pBook[0]->GetData(pBook[0]->GetIdx());
+ long nPairFor = (p == nullptr) ? 0 : SVBT16ToUInt16(*static_cast<SVBT16 const *>(p));
+ if (nPairFor == pBook[1]->GetIdx())
nIsEnd = 0;
- else if( l1 < l0 )
- nIsEnd = 1;
else
- {
- const void * p = pBook[0]->GetData(pBook[0]->GetIdx());
- long nPairFor = (p == nullptr) ? 0 : SVBT16ToUInt16(*static_cast<SVBT16 const *>(p));
- if (nPairFor == pBook[1]->GetIdx())
- nIsEnd = 0;
- else
- nIsEnd = nIsEnd ? 0 : 1;
- }
+ nIsEnd = nIsEnd ? 0 : 1;
}
}
@@ -4602,25 +4602,25 @@ long WW8PLCFx_AtnBook::GetNoSprms( WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& rLen
void WW8PLCFx_AtnBook::advance()
{
- if( m_pBook[0] && m_pBook[1] && nIMax )
- {
- (*m_pBook[static_cast<int>(m_bIsEnd)]).advance();
+ if( !(m_pBook[0] && m_pBook[1] && nIMax) )
+ return;
+
+ (*m_pBook[static_cast<int>(m_bIsEnd)]).advance();
- sal_uLong l0 = m_pBook[0]->Where();
- sal_uLong l1 = m_pBook[1]->Where();
- if( l0 < l1 )
+ sal_uLong l0 = m_pBook[0]->Where();
+ sal_uLong l1 = m_pBook[1]->Where();
+ if( l0 < l1 )
+ m_bIsEnd = false;
+ else if( l1 < l0 )
+ m_bIsEnd = true;
+ else
+ {
+ const void * p = m_pBook[0]->GetData(m_pBook[0]->GetIdx());
+ long nPairFor = (p == nullptr) ? 0 : SVBT16ToUInt16(*static_cast<SVBT16 const *>(p));
+ if (nPairFor == m_pBook[1]->GetIdx())
m_bIsEnd = false;
- else if( l1 < l0 )
- m_bIsEnd = true;
else
- {
- const void * p = m_pBook[0]->GetData(m_pBook[0]->GetIdx());
- long nPairFor = (p == nullptr) ? 0 : SVBT16ToUInt16(*static_cast<SVBT16 const *>(p));
- if (nPairFor == m_pBook[1]->GetIdx())
- m_bIsEnd = false;
- else
- m_bIsEnd = !m_bIsEnd;
- }
+ m_bIsEnd = !m_bIsEnd;
}
}
@@ -4731,25 +4731,25 @@ long WW8PLCFx_FactoidBook::GetNoSprms(WW8_CP& rStart, WW8_CP& rEnd, sal_Int32& r
void WW8PLCFx_FactoidBook::advance()
{
- if (m_pBook[0] && m_pBook[1] && m_nIMax)
- {
- (*m_pBook[static_cast<int>(m_bIsEnd)]).advance();
+ if (!(m_pBook[0] && m_pBook[1] && m_nIMax))
+ return;
+
+ (*m_pBook[static_cast<int>(m_bIsEnd)]).advance();
- sal_uLong l0 = m_pBook[0]->Where();
- sal_uLong l1 = m_pBook[1]->Where();
- if (l0 < l1)
+ sal_uLong l0 = m_pBook[0]->Where();
+ sal_uLong l1 = m_pBook[1]->Where();
+ if (l0 < l1)
+ m_bIsEnd = false;
+ else if (l1 < l0)
+ m_bIsEnd = true;
+ else
+ {
+ const void * p = m_pBook[0]->GetData(m_pBook[0]->GetIdx());
+ long nPairFor = (p == nullptr) ? 0 : SVBT16ToUInt16(*static_cast<SVBT16 const *>(p));
+ if (nPairFor == m_pBook[1]->GetIdx())
m_bIsEnd = false;
- else if (l1 < l0)
- m_bIsEnd = true;
else
- {
- const void * p = m_pBook[0]->GetData(m_pBook[0]->GetIdx());
- long nPairFor = (p == nullptr) ? 0 : SVBT16ToUInt16(*static_cast<SVBT16 const *>(p));
- if (nPairFor == m_pBook[1]->GetIdx())
- m_bIsEnd = false;
- else
- m_bIsEnd = !m_bIsEnd;
- }
+ m_bIsEnd = !m_bIsEnd;
}
}
@@ -5596,60 +5596,60 @@ void WW8PLCFx_Cp_FKP::Restore( const WW8PLCFxSave1& rSave )
void WW8PLCFxDesc::Save( WW8PLCFxSave1& rSave ) const
{
- if( pPLCFx )
+ if( !pPLCFx )
+ return;
+
+ pPLCFx->Save( rSave );
+ if( !pPLCFx->IsSprm() )
+ return;
+
+ WW8PLCFxDesc aD;
+ aD.nStartPos = nOrigStartPos+nCpOfs;
+ aD.nCpOfs = rSave.nCpOfs = nCpOfs;
+ if (!(pPLCFx->SeekPos(aD.nStartPos)))
{
- pPLCFx->Save( rSave );
- if( pPLCFx->IsSprm() )
- {
- WW8PLCFxDesc aD;
- aD.nStartPos = nOrigStartPos+nCpOfs;
- aD.nCpOfs = rSave.nCpOfs = nCpOfs;
- if (!(pPLCFx->SeekPos(aD.nStartPos)))
- {
- aD.nEndPos = WW8_CP_MAX;
- pPLCFx->SetDirty(true);
- }
- pPLCFx->GetSprms(&aD);
- pPLCFx->SetDirty(false);
- aD.ReduceByOffset();
- rSave.nStartCp = aD.nStartPos;
- rSave.nPLCFxMemOfs = nOrigSprmsLen - nSprmsLen;
- }
+ aD.nEndPos = WW8_CP_MAX;
+ pPLCFx->SetDirty(true);
}
+ pPLCFx->GetSprms(&aD);
+ pPLCFx->SetDirty(false);
+ aD.ReduceByOffset();
+ rSave.nStartCp = aD.nStartPos;
+ rSave.nPLCFxMemOfs = nOrigSprmsLen - nSprmsLen;
}
void WW8PLCFxDesc::Restore( const WW8PLCFxSave1& rSave )
{
- if( pPLCFx )
+ if( !pPLCFx )
+ return;
+
+ pPLCFx->Restore( rSave );
+ if( !pPLCFx->IsSprm() )
+ return;
+
+ WW8PLCFxDesc aD;
+ aD.nStartPos = rSave.nStartCp+rSave.nCpOfs;
+ nCpOfs = aD.nCpOfs = rSave.nCpOfs;
+ if (!(pPLCFx->SeekPos(aD.nStartPos)))
{
- pPLCFx->Restore( rSave );
- if( pPLCFx->IsSprm() )
- {
- WW8PLCFxDesc aD;
- aD.nStartPos = rSave.nStartCp+rSave.nCpOfs;
- nCpOfs = aD.nCpOfs = rSave.nCpOfs;
- if (!(pPLCFx->SeekPos(aD.nStartPos)))
- {
- aD.nEndPos = WW8_CP_MAX;
- pPLCFx->SetDirty(true);
- }
- pPLCFx->GetSprms(&aD);
- pPLCFx->SetDirty(false);
- aD.ReduceByOffset();
+ aD.nEndPos = WW8_CP_MAX;
+ pPLCFx->SetDirty(true);
+ }
+ pPLCFx->GetSprms(&aD);
+ pPLCFx->SetDirty(false);
+ aD.ReduceByOffset();
- if (nOrigSprmsLen > aD.nSprmsLen)
- {
- //two entries exist for the same offset, cut and run
- SAL_WARN("sw.ww8", "restored properties don't match saved properties, bailing out");
- nSprmsLen = 0;
- pMemPos = nullptr;
- }
- else
- {
- nSprmsLen = nOrigSprmsLen - rSave.nPLCFxMemOfs;
- pMemPos = aD.pMemPos == nullptr ? nullptr : aD.pMemPos + rSave.nPLCFxMemOfs;
- }
- }
+ if (nOrigSprmsLen > aD.nSprmsLen)
+ {
+ //two entries exist for the same offset, cut and run
+ SAL_WARN("sw.ww8", "restored properties don't match saved properties, bailing out");
+ nSprmsLen = 0;
+ pMemPos = nullptr;
+ }
+ else
+ {
+ nSprmsLen = nOrigSprmsLen - rSave.nPLCFxMemOfs;
+ pMemPos = aD.pMemPos == nullptr ? nullptr : aD.pMemPos + rSave.nPLCFxMemOfs;
}
}