26#include <ooxml/resourceids.hxx>
31#include <osl/diagnose.h>
32#include <rtl/ustring.hxx>
34#include <com/sun/star/beans/PropertyAttribute.hpp>
35#include <com/sun/star/beans/PropertyValue.hpp>
36#include <com/sun/star/beans/XMultiPropertySet.hpp>
37#include <com/sun/star/lang/XMultiServiceFactory.hpp>
38#include <com/sun/star/table/BorderLine2.hpp>
39#include <com/sun/star/container/XEnumeration.hpp>
40#include <com/sun/star/container/XEnumerationAccess.hpp>
41#include <com/sun/star/container/XNameContainer.hpp>
42#include <com/sun/star/style/BreakType.hpp>
43#include <com/sun/star/style/PageStyleLayout.hpp>
44#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
45#include <com/sun/star/table/ShadowFormat.hpp>
46#include <com/sun/star/text/RelOrientation.hpp>
47#include <com/sun/star/text/HoriOrientation.hpp>
48#include <com/sun/star/text/HorizontalAdjust.hpp>
49#include <com/sun/star/text/SizeType.hpp>
50#include <com/sun/star/text/VertOrientation.hpp>
51#include <com/sun/star/text/WritingMode.hpp>
52#include <com/sun/star/text/WritingMode2.hpp>
53#include <com/sun/star/text/XRedline.hpp>
54#include <com/sun/star/text/XTextColumns.hpp>
55#include <com/sun/star/text/XText.hpp>
56#include <com/sun/star/text/XTextFrame.hpp>
57#include <com/sun/star/text/XTextTablesSupplier.hpp>
58#include <com/sun/star/text/TextGridMode.hpp>
59#include <com/sun/star/text/XTextCopy.hpp>
60#include <com/sun/star/style/VerticalAlignment.hpp>
77 if ( !
m_aValues.empty() || m_vMap.empty() )
80 size_t nCharGrabBag = 0;
81 size_t nParaGrabBag = 0;
82 size_t nCellGrabBag = 0;
83 size_t nRowGrabBag = 0;
85 const PropValue* pParaStyleProp =
nullptr;
86 const PropValue* pCharStyleProp =
nullptr;
90 for (
const auto& rPropPair : m_vMap )
94 else if ( rPropPair.second.getGrabBagType() ==
PARA_GRAB_BAG )
96 else if ( rPropPair.second.getGrabBagType() ==
CELL_GRAB_BAG )
101 rPropPair.second.getValue() >>=
aSeq;
102 nCellGrabBag +=
aSeq.getLength();
104 else if ( rPropPair.second.getGrabBagType() ==
ROW_GRAB_BAG )
114 if ( pParaStyleProp !=
nullptr )
116 if ( pCharStyleProp !=
nullptr )
118 if ( pNumRuleProp !=
nullptr )
126 beans::PropertyValue* pCharGrabBagValues = aCharGrabBagValues.getArray();
127 beans::PropertyValue* pParaGrabBagValues = aParaGrabBagValues.getArray();
128 beans::PropertyValue* pCellGrabBagValues = aCellGrabBagValues.getArray();
129 beans::PropertyValue* pRowGrabBagValues = aRowGrabBagValues.getArray();
131 sal_Int32 nRowGrabBagValue = 0;
132 sal_Int32 nCellGrabBagValue = 0;
133 sal_Int32 nParaGrabBagValue = 0;
134 sal_Int32 nCharGrabBagValue = 0;
136 for (
const auto& rPropPair : m_vMap )
146 pCharGrabBagValues[nCharGrabBagValue].Name =
getPropertyName( rPropPair.first );
147 pCharGrabBagValues[nCharGrabBagValue].Value = rPropPair.second.getValue();
151 else if ( rPropPair.second.getGrabBagType() ==
PARA_GRAB_BAG )
153 pParaGrabBagValues[nParaGrabBagValue].Name =
getPropertyName( rPropPair.first );
154 pParaGrabBagValues[nParaGrabBagValue].Value = rPropPair.second.getValue();
157 else if ( rPropPair.second.getGrabBagType() ==
CELL_GRAB_BAG )
159 pCellGrabBagValues[nCellGrabBagValue].Name =
getPropertyName( rPropPair.first );
160 pCellGrabBagValues[nCellGrabBagValue].Value = rPropPair.second.getValue();
163 else if ( rPropPair.second.getGrabBagType() ==
ROW_GRAB_BAG )
165 pRowGrabBagValues[nRowGrabBagValue].Name =
getPropertyName( rPropPair.first );
166 pRowGrabBagValues[nRowGrabBagValue].Value = rPropPair.second.getValue();
172 rPropPair.second.getValue() >>=
aSeq;
173 std::copy(std::cbegin(
aSeq), std::cend(
aSeq), pCellGrabBagValues + nCellGrabBagValue);
174 nCellGrabBagValue +=
aSeq.getLength();
183 if ( nCharGrabBag && bCharGrabBag )
198std::vector< PropertyIds > PropertyMap::GetPropertyIds()
200 std::vector< PropertyIds > aRet;
201 for (
const auto& rPropPair : m_vMap )
202 aRet.push_back( rPropPair.first );
213 TagLogger::getInstance().attribute(
"value", rAny );
217 TagLogger::getInstance().attribute(
"unsignedValue", 0 );
220 sal_uInt32 auInt = 0;
222 TagLogger::getInstance().attribute(
"unsignedValue", auInt );
225 if ( rAny >>= aFloat )
227 TagLogger::getInstance().attribute(
"floatValue", rAny );
231 TagLogger::getInstance().attribute(
"unsignedValue", 0 );
236 TagLogger::getInstance().attribute(
"stringValue",
aStr );
249 TagLogger::getInstance().startElement(
"propertyMap.insert");
250 TagLogger::getInstance().attribute(
"name", rInsert);
252 TagLogger::getInstance().endElement();
256 m_vMap.insert(std::make_pair(eId,
PropValue(rAny, i_GrabBagType, bDocDefault)));
258 m_vMap[eId] =
PropValue(rAny, i_GrabBagType);
273 std::map< PropertyIds, PropValue >::const_iterator aIter = m_vMap.find( eId );
274 if ( aIter == m_vMap.end() )
275 return std::optional<Property>();
277 return std::make_pair( eId, aIter->second.getValue() );
282 return m_vMap.find( eId ) != m_vMap.end();
287 std::map< PropertyIds, PropValue >::const_iterator aIter = m_vMap.find( eId );
288 if ( aIter == m_vMap.end() )
291 return aIter->second.getIsDocDefault();
295void PropertyMap::dumpXml()
const
297 TagLogger::getInstance().startElement(
"PropertyMap" );
299 for (
const auto& rPropPair : m_vMap )
301 TagLogger::getInstance().startElement(
"property" );
303 TagLogger::getInstance().attribute(
"name",
getPropertyName( rPropPair.first ) );
305 switch ( rPropPair.first )
315 rPropPair.second.getValue() >>= aInt;
316 TagLogger::getInstance().attribute(
"value", aInt );
318 sal_uInt32 auInt = 0;
319 rPropPair.second.getValue() >>= auInt;
320 TagLogger::getInstance().attribute(
"unsignedValue", auInt );
323 rPropPair.second.getValue() >>= aFloat;
324 TagLogger::getInstance().attribute(
"floatValue", aFloat );
326 rPropPair.second.getValue() >>= auInt;
327 TagLogger::getInstance().attribute(
"stringValue", std::u16string_view() );
336 TagLogger::getInstance().endElement();
339 TagLogger::getInstance().endElement();
343void PropertyMap::InsertProps(
const PropertyMapPtr& rMap,
const bool bOverwrite )
348 for (
const auto& rPropPair : rMap->m_vMap )
350 if ( bOverwrite || !m_vMap.count(rPropPair.first) )
352 if ( !bOverwrite && !rPropPair.second.getIsDocDefault() )
353 m_vMap.insert(std::make_pair(rPropPair.first,
PropValue(rPropPair.second.getValue(), rPropPair.second.getGrabBagType(),
true)));
355 m_vMap[rPropPair.first] = rPropPair.second;
359 insertTableProperties( rMap.
get(), bOverwrite );
364void PropertyMap::insertTableProperties(
const PropertyMap*,
const bool )
367 TagLogger::getInstance().element(
"PropertyMap.insertTableProperties" );
371void PropertyMap::printProperties()
374 TagLogger::getInstance().startElement(
"properties" );
376 for (
const auto& rPropPair : m_vMap )
380 table::BorderLine2 aLine;
382 if ( rPropPair.second.getValue() >>= aLine )
384 TagLogger::getInstance().startElement(
"borderline" );
385 TagLogger::getInstance().attribute(
"color", aLine.Color );
386 TagLogger::getInstance().attribute(
"inner", aLine.InnerLineWidth );
387 TagLogger::getInstance().attribute(
"outer", aLine.OuterLineWidth );
388 TagLogger::getInstance().endElement();
390 else if ( rPropPair.second.getValue() >>= nColor )
392 TagLogger::getInstance().startElement(
"color" );
393 TagLogger::getInstance().attribute(
"number", nColor );
394 TagLogger::getInstance().endElement();
398 TagLogger::getInstance().endElement();
404SectionPropertyMap::SectionPropertyMap(
bool bIsFirstSection )
405 : m_bIsFirstSection( bIsFirstSection )
408 , m_bTitlePage( false )
409 , m_nColumnCount( 0 )
410 , m_nColumnDistance( 1249 )
411 , m_bSeparatorLineIsOn( false )
412 , m_bEvenlySpaced( false )
413 , m_nPageNumber( -1 )
414 , m_nPageNumberType( -1 )
424 , m_nGridLinePitch( 1 )
425 , m_nDxtCharSpace( 0 )
426 , m_bGridSnapToChars( true )
428 , m_nLnc(NS_ooxml::LN_Value_ST_LineNumberRestart_newPage)
431 , m_bDynamicHeightTop( true )
432 , m_bDynamicHeightBottom( true )
433 , m_bDefaultHeaderLinkToPrevious( true )
434 , m_bEvenPageHeaderLinkToPrevious( true )
435 , m_bFirstPageHeaderLinkToPrevious( true )
436 , m_bDefaultFooterLinkToPrevious( true )
437 , m_bEvenPageFooterLinkToPrevious( true )
438 , m_bFirstPageFooterLinkToPrevious( true )
441 static sal_Int32 nNumber = 0;
493 m_aFirstPageStyle.set( xTextFactory->createInstance(
"com.sun.star.style.PageStyle" ),
499 if ( xPageStyles.is() )
520 m_aFollowPageStyle.set( xTextFactory->createInstance(
"com.sun.star.style.PageStyle" ),
532 catch (
const uno::Exception& )
566 switch ( eBorderApply )
645table::ShadowFormat PropertyMap::getShadowFromBorder(
const table::BorderLine2& rBorder )
651 table::ShadowFormat aFormat;
653 aFormat.Location = table::ShadowLocation_BOTTOM_RIGHT;
654 aFormat.ShadowWidth = rBorder.LineWidth;
670 uno::Any aMargin = xStyle->getPropertyValue( sMarginName );
671 sal_Int32 nMargin = 0;
676 if (eOffsetFrom == BorderOffsetFrom::Edge)
678 uno::Any aGutterMargin = xStyle->getPropertyValue(
"GutterMargin" );
679 sal_Int32 nGutterMargin = 0;
680 aGutterMargin >>= nGutterMargin;
684 nMargin -= nGutterMargin;
685 nDistance += nGutterMargin;
690 nMargin -= nGutterMargin;
691 nDistance += nGutterMargin;
699 xMultiSet->setPropertyValues(
aProperties, aValues );
702void SectionPropertyMap::DontBalanceTextColumns()
706 if ( m_xColumnContainer.is() )
707 m_xColumnContainer->setPropertyValue(
"DontBalanceTextColumns",
uno::Any(
true ) );
709 catch (
const uno::Exception& )
723 xSection->setPropertyValue(
"WritingMode", pProp->second );
726 catch ( uno::Exception& )
744 if ( !xSection.is() )
750 catch ( uno::Exception& )
760 assert( m_nColumnCount > 1 &&
"ApplyColumnProperties called without any columns" );
764 if ( xColumnContainer.is() )
765 xColumnContainer->getPropertyValue( sTextColumns ) >>= xColumns;
767 if ( !m_bEvenlySpaced &&
768 ( sal_Int32(m_aColWidth.size()) == m_nColumnCount ) &&
769 ( (sal_Int32(m_aColDistance.size()) == m_nColumnCount - 1) || (sal_Int32(m_aColDistance.size()) == m_nColumnCount) ) )
773 sal_Int32 nColSum = 0;
774 for ( sal_Int32 nCol = 0; nCol < m_nColumnCount; ++nCol )
776 nColSum += m_aColWidth[nCol];
778 nColSum += m_aColDistance[nCol - 1];
781 sal_Int32 nRefValue = xColumns->getReferenceValue();
782 double fRel = nColSum ? double( nRefValue ) / double( nColSum ) : 0.0;
784 text::TextColumn* pColumn = aColumns.getArray();
787 for ( sal_Int32 nCol = 0; nCol < m_nColumnCount; ++nCol )
789 const double fLeft = nCol ? m_aColDistance[nCol - 1] / 2 : 0;
790 pColumn[nCol].LeftMargin = fLeft;
791 const double fRight = (nCol == m_nColumnCount - 1) ? 0 : m_aColDistance[nCol] / 2;
792 pColumn[nCol].RightMargin = fRight;
793 const double fWidth = m_aColWidth[nCol];
794 pColumn[nCol].Width = (fWidth + fLeft + fRight) * fRel;
795 nColSum += pColumn[nCol].Width;
797 if ( nColSum != nRefValue )
798 pColumn[m_nColumnCount - 1].Width += (nRefValue - nColSum);
799 assert( pColumn[m_nColumnCount - 1].
Width >= 0 );
801 xColumns->setColumns( aColumns );
805 xColumns->setColumnCount( m_nColumnCount );
809 if ( m_bSeparatorLineIsOn )
811 xColumnPropSet->setPropertyValue(
"SeparatorLineIsOn",
uno::Any(
true ) );
812 xColumnPropSet->setPropertyValue(
"SeparatorLineVerticalAlignment",
uno::Any( style::VerticalAlignment_TOP ) );
813 xColumnPropSet->setPropertyValue(
"SeparatorLineRelativeHeight",
uno::Any(
static_cast<sal_Int8>(100) ) );
814 xColumnPropSet->setPropertyValue(
"SeparatorLineColor",
uno::Any(
static_cast<sal_Int32
>(
COL_BLACK) ) );
816 xColumnPropSet->setPropertyValue(
"SeparatorLineWidth",
uno::Any(
static_cast<sal_Int32
>(2) ) );
818 xColumnContainer->setPropertyValue( sTextColumns,
uno::Any( xColumns ) );
820 m_xColumnContainer = xColumnContainer;
822 DontBalanceTextColumns();
824 catch (
const uno::Exception& )
831bool SectionPropertyMap::HasHeader(
bool bFirstPage )
const
834 if ( (bFirstPage && m_aFirstPageStyle.is()) || (!bFirstPage && m_aFollowPageStyle.is()) )
837 m_aFirstPageStyle->getPropertyValue(
840 m_aFollowPageStyle->getPropertyValue(
846bool SectionPropertyMap::HasFooter(
bool bFirstPage )
const
849 if ( (bFirstPage && m_aFirstPageStyle.is()) || (!bFirstPage && m_aFollowPageStyle.is()) )
859#define MIN_HEAD_FOOT_HEIGHT 100
871 xTxt.set( xStyle->getPropertyValue(
sName ), uno::UNO_QUERY_THROW );
874 if ( xPrevStyle.is() )
875 xPrevTxt.set( xPrevStyle->getPropertyValue(
sName ), uno::UNO_QUERY_THROW );
877 xTxt->copyText( xPrevTxt );
879 catch (
const uno::Exception& )
881 TOOLS_INFO_EXCEPTION(
"writerfilter",
"An exception occurred in SectionPropertyMap::CopyHeaderFooterTextProperty( )" );
889 bool bOmitRightHeader,
890 bool bOmitLeftHeader,
891 bool bOmitRightFooter,
892 bool bOmitLeftFooter )
898 bool bHasPrevHeader =
false;
899 bool bHeaderIsShared =
true;
902 if ( xPrevStyle.is() )
904 xPrevStyle->getPropertyValue( sHeaderIsOn ) >>= bHasPrevHeader;
905 xPrevStyle->getPropertyValue( sHeaderIsShared ) >>= bHeaderIsShared;
908 if ( bHasPrevHeader )
913 xMultiSet->setPropertyValues(
aProperties, aValues );
914 if ( !bOmitRightHeader )
916 CopyHeaderFooterTextProperty( xPrevStyle, xStyle,
919 if ( !bHeaderIsShared && !bOmitLeftHeader )
921 CopyHeaderFooterTextProperty( xPrevStyle, xStyle,
926 bool bHasPrevFooter =
false;
927 bool bFooterIsShared =
true;
930 if ( xPrevStyle.is() )
932 xPrevStyle->getPropertyValue( sFooterIsOn ) >>= bHasPrevFooter;
933 xPrevStyle->getPropertyValue( sFooterIsShared ) >>= bFooterIsShared;
936 if ( !bHasPrevFooter )
942 xMultiSet->setPropertyValues(
aProperties, aValues );
943 if ( !bOmitRightFooter )
945 CopyHeaderFooterTextProperty( xPrevStyle, xStyle,
948 if ( !bFooterIsShared && !bOmitLeftFooter )
950 CopyHeaderFooterTextProperty( xPrevStyle, xStyle,
963 SAL_INFO(
"writerfilter",
"START>>> SectionPropertyMap::CopyLastHeaderFooter()" );
967 const bool bUseEvenPages = rDM_Impl.
GetSettingsTable()->GetEvenAndOddHeaders();
975 CopyHeaderFooter(rDM_Impl, xPrevStyle, xStyle,
976 !m_bFirstPageHeaderLinkToPrevious,
true,
977 !m_bFirstPageFooterLinkToPrevious,
true );
981 CopyHeaderFooter(rDM_Impl, xPrevStyle, xStyle,
982 !m_bDefaultHeaderLinkToPrevious,
983 !(m_bEvenPageHeaderLinkToPrevious && bUseEvenPages),
984 !m_bDefaultFooterLinkToPrevious,
985 !(m_bEvenPageFooterLinkToPrevious && bUseEvenPages));
988 SAL_INFO(
"writerfilter",
"END>>> SectionPropertyMap::CopyLastHeaderFooter()" );
991void SectionPropertyMap::PrepareHeaderFooterProperties(
bool bFirstPage )
993 bool bCopyFirstToFollow = bFirstPage && m_bTitlePage && m_aFollowPageStyle.is();
996 sal_Int32 nHeaderHeight = m_nHeaderTop;
997 if ( HasHeader( bFirstPage ) )
1000 nHeaderHeight = m_nTopMargin - m_nHeaderTop;
1013 if ( m_bDynamicHeightTop )
1015 if (bCopyFirstToFollow && HasHeader(
true))
1017 m_aFollowPageStyle->setPropertyValue(
"HeaderDynamicSpacing",
1019 m_aFollowPageStyle->setPropertyValue(
"HeaderHeight",
1025 sal_Int32 nFooterHeight = m_nHeaderBottom;
1026 if ( HasFooter( bFirstPage ) )
1029 nFooterHeight = m_nBottomMargin - m_nHeaderBottom;
1040 if (m_bDynamicHeightBottom)
1042 if (bCopyFirstToFollow && HasFooter(
true))
1044 m_aFollowPageStyle->setPropertyValue(
"FooterDynamicSpacing",
1046 m_aFollowPageStyle->setPropertyValue(
"FooterHeight",
1061 if ( bIsFirstSection && rDM_Impl.
GetBodyText().is() )
1065 xRangeProperties.set( xEnum->nextElement(), uno::UNO_QUERY_THROW );
1067 xRangeProperties.set( xEnum->nextElement(), uno::UNO_QUERY_THROW );
1069 else if ( xStartingRange.is() )
1070 xRangeProperties.set( xStartingRange, uno::UNO_QUERY_THROW );
1071 return xRangeProperties;
1097 if ( xStylesSupplier.is() )
1101 if ( xStyleFamilies.is() )
1102 xStyleFamilies->getByName(
"ParagraphStyles") >>= xParagraphStyles;
1104 if ( xParagraphStyles.is() )
1105 xParagraphStyles->getByName(
"Standard") >>= xStandard;
1106 if ( xStandard.is() )
1108 sal_Int16 aWritingMode(0);
1110 if( aWritingMode == text::WritingMode2::RL_TB )
1117 catch (
const uno::Exception& ) {}
1123 CopyLastHeaderFooter( bFirstPage, rDM_Impl );
1124 PrepareHeaderFooterProperties( bFirstPage );
1141 if ( pLastContext && m_sFollowPageStyleName.isEmpty() )
1145 HandleMarginsHeaderFooter(
false, rDM_Impl );
1146 GetPageStyle( rDM_Impl,
false );
1147 if ( rDM_Impl.
IsNewDoc() && m_aFollowPageStyle.is() )
1148 ApplyProperties_( m_aFollowPageStyle );
1152 if ( !m_bTitlePage && pLastContext && m_sFirstPageStyleName.isEmpty() )
1156 HandleMarginsHeaderFooter(
true, rDM_Impl );
1157 GetPageStyle( rDM_Impl,
true );
1158 if ( rDM_Impl.
IsNewDoc() && m_aFirstPageStyle.is() )
1159 ApplyProperties_( m_aFirstPageStyle );
1162 m_aFirstPageStyle->setPropertyValue(
"FollowStyle",
uno::Any( m_sFollowPageStyleName ) );
1172 sal_Int32 nPageWidth = GetPageWidth();
1173 sal_Int32 nTextAreaWidth = nPageWidth - GetLeftMargin() - GetRightMargin();
1176 for (
const auto& rAnchor : rAnchoredObjectAnchors)
1180 if (rAnchor.m_aAnchoredObjects.size() < 4)
1184 sal_Int32 nOpaqueCount = 0;
1185 for (
const auto& rAnchored : rAnchor.m_aAnchoredObjects)
1188 if (rAnchored.m_xRedlineForInline)
1197 bool bOpaque =
true;
1198 xShape->getPropertyValue(
"Opaque") >>= bOpaque;
1204 if (nOpaqueCount < 1)
1211 sal_Int32 nShapesWidth = 0;
1212 for (
const auto& rAnchored : rAnchor.m_aAnchoredObjects)
1219 if (!xPropertySet.is())
1223 text::WrapTextMode eWrap = text::WrapTextMode_THROUGH;
1224 xPropertySet->getPropertyValue(
"Surround") >>= eWrap;
1225 if (eWrap == text::WrapTextMode_THROUGH)
1232 xPropertySet->getPropertyValue(
"RightMargin") >>=
nRightMargin;
1237 if (nTextAreaWidth > nShapesWidth)
1240 sal_Int32 nHeight = 0;
1241 for (
const auto& rAnchored : rAnchor.m_aAnchoredObjects)
1247 nHeight += xShape->getSize().Height;
1251 if (xParagraph.is())
1254 xParagraph->getPropertyValue(
"ParaTopMargin") >>=
nTopMargin;
1261 rAnchoredObjectAnchors.clear();
1264void BeforeConvertToTextFrame(std::deque<css::uno::Any>& rFramedRedlines, std::vector<sal_Int32>& redPos, std::vector<sal_Int32>& redLen, std::vector<OUString>& redCell, std::vector<OUString>& redTable)
1267 for(
size_t i = 0;
i < rFramedRedlines.size();
i+=3)
1271 rFramedRedlines[
i] >>= xRange;
1275 OUString sTableName;
1277 xRangeProperties.set( xRange, uno::UNO_QUERY_THROW );
1278 if (xRangeProperties->getPropertySetInfo()->hasPropertyByName(
"TextTable"))
1280 uno::Any aTable = xRangeProperties->getPropertyValue(
"TextTable");
1286 xTableProperties->getPropertyValue(
"TableName") >>= sTableName;
1288 if (xRangeProperties->getPropertySetInfo()->hasPropertyByName(
"Cell"))
1290 uno::Any aCell = xRangeProperties->getPropertyValue(
"Cell");
1295 xCellProperties->getPropertyValue(
"CellName") >>= sCellName;
1299 redTable.push_back(sTableName);
1300 redCell.push_back(sCellName);
1302 if (!sTableName.isEmpty() && !sCellName.isEmpty())
1305 if ( xRangeCursor.is() )
1308 sal_Int32 nLen = xRange->getString().getLength();
1309 redLen.push_back(nLen);
1310 xRangeCursor->gotoStart(
true);
1311 redPos.push_back(xRangeCursor->getString().getLength() - nLen);
1317 redLen.push_back(-1);
1318 redPos.push_back(-1);
1324void AfterConvertToTextFrame(
DomainMapper_Impl& rDM_Impl, std::deque<css::uno::Any>& aFramedRedlines, std::vector<sal_Int32>& redPos, std::vector<sal_Int32>& redLen, std::vector<OUString>& redCell, std::vector<OUString>& redTable)
1328 for(
size_t i = 0;
i < aFramedRedlines.size();
i+=3)
1331 beans::PropertyValues aRedlineProperties( 3 );
1333 if (redPos[
i/3] == -1)
1335 aFramedRedlines[
i+1] >>=
sType;
1336 aFramedRedlines[
i+2] >>= aRedlineProperties;
1340 xCrsr->goRight(redPos[
i/3],
false);
1341 xCrsr->goRight(redLen[
i/3],
true);
1345 xRedline->makeRedline(
sType, aRedlineProperties );
1347 catch (
const uno::Exception&)
1359 if ( m_nBreakType == -1 )
1360 m_nBreakType = NS_ooxml::LN_Value_ST_SectionMark_nextPage;
1361 else if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextColumn )
1368 || m_nColumnCount < 2
1372 m_nBreakType = NS_ooxml::LN_Value_ST_SectionMark_nextPage;
1375 else if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_continuous )
1380 bool bIsLandscape =
false;
1383 pProp->second >>= bIsLandscape;
1385 bool bPrevIsLandscape =
false;
1388 pProp->second >>= bPrevIsLandscape;
1390 if ( bIsLandscape != bPrevIsLandscape )
1391 m_nBreakType = NS_ooxml::LN_Value_ST_SectionMark_nextPage;
1397 HandleIncreasedAnchoredObjectSpacing(rDM_Impl);
1399 catch (
const uno::Exception&)
1408 if ( m_nLnnMin > 0 || (bFirst && m_nLnc == NS_ooxml::LN_Value_ST_LineNumberRestart_newSection) )
1414 if ( m_xStartingRange.is() )
1416 xRangeProperties.set( m_xStartingRange, uno::UNO_QUERY_THROW );
1421 xRangeProperties.set( rDM_Impl.
GetTextDocument()->getText()->getStart(), uno::UNO_QUERY_THROW );
1424 xRangeProperties->setPropertyValue(
1428 catch (
const uno::Exception& )
1435 if (m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_continuous
1441 if ( xSection.is() )
1443 if ( m_nColumnCount > 1 )
1444 ApplyColumnProperties( xSection, rDM_Impl );
1446 ApplyProtectionProperties( xSection, rDM_Impl );
1451 InheritOrFinalizePageStyles( rDM_Impl );
1452 ApplySectionProperties( xSection, rDM_Impl );
1453 OUString
aName = m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName;
1455 if ( m_bIsFirstSection && !
aName.isEmpty() && xRangeProperties.is() )
1459 else if ((!m_bFirstPageHeaderLinkToPrevious ||
1460 !m_bFirstPageFooterLinkToPrevious ||
1461 !m_bDefaultHeaderLinkToPrevious ||
1462 !m_bDefaultFooterLinkToPrevious ||
1463 !m_bEvenPageHeaderLinkToPrevious ||
1464 !m_bEvenPageFooterLinkToPrevious)
1471 xTextAppend->createTextCursorByRange(
1473 uno::UNO_QUERY_THROW);
1475 xCursor->createEnumeration());
1476 bool isFound =
false;
1477 while (xEnum->hasMoreElements())
1480 xEnum->nextElement() >>= xElem;
1481 if (xElem->getPropertySetInfo()->hasPropertyByName(
"BreakType"))
1484 if ((xElem->getPropertyValue(
"BreakType") >>= bt)
1485 && bt == style::BreakType_PAGE_BEFORE)
1496 uno::UNO_QUERY_THROW);
1497 float fCharHeight = 0;
1500 xPCursor->gotoPreviousParagraph(
false);
1503 if ((xPSCursor->getPropertyValue(
"BreakType") >>= bt)
1504 && bt == style::BreakType_PAGE_BEFORE)
1512 xPSCursor->getPropertyValue(
"CharHeight") >>= fCharHeight;
1515 if (!isFound && fCharHeight <= 1.0)
1519 xPCursor->gotoPreviousParagraph(
false);
1521 OUString aPageDescName;
1522 if ((xPropertySet->getPropertyValue(
"PageDescName") >>= aPageDescName)
1523 && !aPageDescName.isEmpty())
1526 rDM_Impl.
GetPageStyles()->getByName(aPageDescName), uno::UNO_QUERY);
1527 xPageStyle->setPropertyValue(
"FollowStyle",
1533 catch (
const uno::Exception& )
1535 SAL_WARN(
"writerfilter",
"failed to set PageDescName!" );
1541 else if (m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_nextColumn
1546 InheritOrFinalizePageStyles( rDM_Impl );
1552 if ( m_xStartingRange.is() )
1554 xRangeProperties.set( m_xStartingRange, uno::UNO_QUERY_THROW );
1559 xRangeProperties.set( rDM_Impl.
GetTextDocument()->getText()->getStart(), uno::UNO_QUERY_THROW );
1563 catch (
const uno::Exception& ) {}
1568 ApplyProtectionProperties( xSection, rDM_Impl );
1575 xFollowPageStyle.set( GetPageStyle( rDM_Impl,
false ) );
1577 HandleMarginsHeaderFooter(
false, rDM_Impl );
1585 if ( m_nColumnCount > 1 )
1588 if ( !xSection.is() )
1590 if ( xSection.is() )
1591 ApplyColumnProperties( xSection, rDM_Impl );
1592 else if ( xFollowPageStyle.is() )
1593 xColumns = ApplyColumnProperties( xFollowPageStyle, rDM_Impl );
1597 if ( pPrevSection && pPrevSection->
ColumnCount() )
1601 sal_Int32 nHeight = 1;
1604 pProp->second >>= nHeight;
1606 sal_Int32 nWidth = 1;
1609 pProp->second >>= nWidth;
1611 sal_Int16 nWritingMode = text::WritingMode2::LR_TB;
1614 pProp->second >>= nWritingMode;
1616 sal_Int32 nTextAreaHeight = nWritingMode == text::WritingMode2::LR_TB ?
1617 nHeight - m_nTopMargin - m_nBottomMargin :
1618 nWidth - m_nLeftMargin - m_nRightMargin;
1620 sal_Int32 nGridLinePitch = m_nGridLinePitch;
1622 if ( nGridLinePitch < 1 || nGridLinePitch > 31680 )
1624 SAL_WARN(
"writerfilter",
"sep.dyaLinePitch outside legal range: " << nGridLinePitch );
1628 const sal_Int32 nGridLines = nTextAreaHeight / nGridLinePitch;
1629 sal_Int16 nGridType = m_nGridType;
1636 if ( nGridType == text::TextGridMode::LINES_AND_CHARS )
1638 if (!m_nDxtCharSpace)
1639 nGridType = text::TextGridMode::LINES;
1646 sal_Int32 nCharWidth = 423;
1650 std::optional< PropertyMap::Property > pPropHeight = pEntry->m_pProperties->getProperty(
PROP_CHAR_HEIGHT_ASIAN );
1654 if ( pPropHeight->second >>= fHeight )
1660 if ( m_nDxtCharSpace )
1662 sal_Int32 nCharSpace = m_nDxtCharSpace;
1664 sal_Int32 nMain = (nCharSpace & 0xFFFFF000);
1668 sal_Int32 nFraction = (nCharSpace & 0x00000FFF);
1669 nFraction = (nFraction * 20) / 0xFFF;
1673 if ( m_nPageNumberType >= 0 )
1681 xDocProperties.set( rDM_Impl.
GetTextDocument(), uno::UNO_QUERY_THROW );
1683 xDocProperties->setPropertyValue(
"DefaultPageMode",
uno::Any(
false));
1685 catch (
const uno::Exception& )
1694 if ( rDM_Impl.
IsNewDoc() && xFollowPageStyle.is() )
1695 ApplyProperties_( xFollowPageStyle );
1700 CopyLastHeaderFooter(
true, rDM_Impl );
1701 PrepareHeaderFooterProperties(
true );
1705 ApplyProperties_( xFirstPageStyle );
1707 if ( xColumns.is() )
1708 xFirstPageStyle->setPropertyValue(
1712 ApplyBorderToPageStyles( rDM_Impl, m_eBorderApply, m_eBorderOffsetFrom );
1722 if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_evenPage || m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_oddPage )
1724 OUString* pageStyle = m_bTitlePage ? &m_sFirstPageStyleName : &m_sFollowPageStyleName;
1727 rDM_Impl.
GetTextFactory()->createInstance(
"com.sun.star.style.PageStyle" ),
1735 = {
"FooterBackGraphicURL",
"BackGraphicURL",
"HeaderBackGraphicURL" };
1736 for (
const auto& rProperty : propertyList )
1738 if ( (rProperty.Attributes & beans::PropertyAttribute::READONLY) == 0 )
1740 if (aDenylist.
find(rProperty.Name) == aDenylist.
end())
1741 evenOddStyle->setPropertyValue(
1743 pageProperties->getPropertyValue(rProperty.Name));
1746 evenOddStyle->setPropertyValue(
"FollowStyle",
uno::Any( *pageStyle ) );
1748 evenOddStyle->setPropertyValue(
"HeaderIsOn",
uno::Any(
false ) );
1749 evenOddStyle->setPropertyValue(
"FooterIsOn",
uno::Any(
false ) );
1750 CopyHeaderFooter(rDM_Impl, pageProperties, evenOddStyle);
1751 *pageStyle = evenOddStyleName;
1752 if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_evenPage )
1754 else if ( m_nBreakType == NS_ooxml::LN_Value_ST_SectionMark_oddPage )
1767 const OUString sPageStyle = m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName;
1773 xRangeProperties->setPropertyValue(
1778 if (0 <= m_nPageNumber)
1780 sal_Int16 nPageNumber =
static_cast< sal_Int16
>(m_nPageNumber);
1786 catch (
const uno::Exception& )
1793 sal_Int32 nParagraphWidth = GetPageWidth() - m_nLeftMargin - m_nRightMargin;
1794 if ( m_nColumnCount > 1 )
1797 if ( !m_aColWidth.empty() )
1798 nParagraphWidth = 0;
1800 nParagraphWidth = (nParagraphWidth - (m_nColumnDistance * (m_nColumnCount - 1))) / m_nColumnCount;
1802 if ( nParagraphWidth > 0 )
1805 for (
const auto& xShape : m_xRelativeWidthShapes )
1808 if ( xShapePropertySet->getPropertySetInfo()->hasPropertyByName(sPropRelativeWidth) )
1810 sal_uInt16 nPercent = 0;
1813 xShapePropertySet->getPropertyValue(sPropRelativeWidth) >>= nPercent;
1815 catch (
const css::uno::RuntimeException& e)
1819 SAL_WARN(
"writerfilter",
"Getting relative width failed. " << e.Message);
1823 const sal_Int32 nWidth = nParagraphWidth * nPercent / 100;
1824 xShape->setSize( awt::Size( nWidth, xShape->getSize().Height ) );
1829 m_xRelativeWidthShapes.clear();
1844void SectionPropertyMap::ClearHeaderFooterLinkToPrevious(
bool bHeader,
PageType eType )
1850 case PAGE_FIRST: m_bFirstPageHeaderLinkToPrevious =
false;
break;
1851 case PAGE_LEFT: m_bEvenPageHeaderLinkToPrevious =
false;
break;
1852 case PAGE_RIGHT: m_bDefaultHeaderLinkToPrevious =
false;
break;
1860 case PAGE_FIRST: m_bFirstPageFooterLinkToPrevious =
false;
break;
1861 case PAGE_LEFT: m_bEvenPageFooterLinkToPrevious =
false;
break;
1862 case PAGE_RIGHT: m_bDefaultFooterLinkToPrevious =
false;
break;
1869class NamedPropertyValue
1875 explicit NamedPropertyValue( OUString i_aStr )
1880 bool operator() ( beans::PropertyValue
const & aVal )
1892 std::vector< OUString > vNames;
1893 std::vector< uno::Any > vValues;
1901 const beans::PropertyValue* pCharGrabBag = std::find_if( vPropVals.begin(), vPropVals.end(), NamedPropertyValue(
"CharInteropGrabBag" ) );
1902 if ( pCharGrabBag != vPropVals.end() )
1903 (pCharGrabBag->Value) >>= vCharVals;
1904 const beans::PropertyValue* pParaGrabBag = std::find_if( vPropVals.begin(), vPropVals.end(), NamedPropertyValue(
"ParaInteropGrabBag" ) );
1905 if ( pParaGrabBag != vPropVals.end() )
1906 (pParaGrabBag->Value) >>= vParaVals;
1908 for (
const beans::PropertyValue* pIter = vPropVals.begin(); pIter != vPropVals.end(); ++pIter )
1910 if ( pIter != pCharGrabBag && pIter != pParaGrabBag
1911 && pIter->Name !=
"IsProtected"
1914 vNames.push_back( pIter->Name );
1915 vValues.push_back( pIter->Value );
1918 for (
const beans::PropertyValue &
v : std::as_const(vCharVals) )
1920 vNames.push_back(
v.Name );
1921 vValues.push_back(
v.Value );
1923 for (
const beans::PropertyValue &
v : std::as_const(vParaVals) )
1925 vNames.push_back(
v.Name );
1926 vValues.push_back(
v.Value );
1929 if ( xMultiSet.is() )
1936 catch (
const uno::Exception& )
1941 for (
size_t i = 0;
i < vNames.size(); ++
i )
1946 xStyle->setPropertyValue( vNames[
i], vValues[
i] );
1948 catch (
const uno::Exception& )
1955sal_Int32 SectionPropertyMap::GetPageWidth()
const
1960StyleSheetPropertyMap::StyleSheetPropertyMap()
1962 , mnOutlineLevel( -1 )
1967 : m_bFrameMode( false )
1968 , m_nDropCap( NS_ooxml::LN_Value_doc_ST_DropCap_none )
1972 , m_nWrap(
text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE )
1976 , m_bxValid( false )
1978 , m_byValid( false )
1984 , m_nDropCapLength( 0 )
1991 m_nDropCap = NS_ooxml::LN_Value_doc_ST_DropCap_none;
1995 m_nWrap = text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE;
2020 OSL_FAIL(
"invalid TablePropertyMapTarget" );
2033 OSL_FAIL(
"invalid TablePropertyMapTarget" );
css::chart::ChartAxisLabelPosition ePos
#define MIN_HEAD_FOOT_HEIGHT
std::vector< beans::PropertyValue > m_aValues
PropertiesInfo aProperties
tools::Long getWidth() const
tools::Long getHeight() const
const_iterator find(const Value &x) const
const_iterator end() const
css::uno::Any getProperty(sal_Int32 nPropId)
static const OUString & getPropertyName(sal_Int32 nPropId)
static TagLogger & getInstance()
void startElement(const std::string &name)
css::uno::Reference< css::text::XTextAppend > GetCurrentXText()
void SetLineNumbering(sal_Int32 nLnnMod, sal_uInt32 nLnc, sal_Int32 ndxaLnn)
bool GetIsDummyParaAddedForTableInSection() const
const css::uno::Reference< css::text::XTextDocument > & GetTextDocument() const
bool IsInComments() const
const css::uno::Reference< css::lang::XMultiServiceFactory > & GetTextFactory() const
bool m_bHasFtnSep
If the current section has a footnote separator.
void ConvertHeaderFooterToTextFrame(bool, bool)
OUString GetUnusedPageStyleName()
bool IsLineNumberingSet() const
SettingsTablePtr const & GetSettingsTable()
std::optional< sal_Int32 > m_oBackgroundColor
Document background color, applied to every page style.
css::uno::Reference< css::beans::XPropertySet > appendTextSectionAfter(css::uno::Reference< css::text::XTextRange > const &xBefore)
void SetIsFirstParagraphInSection(bool bIsFirst)
bool IsNewDoc() const
If we're importing into a new document, or just pasting to an existing one.
bool IsInFootOrEndnote() const
css::uno::Reference< css::text::XText > const & GetBodyText()
SectionPropertyMap * GetLastSectionContext()
std::vector< AnchoredObjectsInfo > m_aAnchoredObjectAnchors
Paragraphs with anchored objects in the current section.
void SetIsLastSectionGroup(bool bIsLast)
css::uno::Reference< css::container::XNameContainer > const & GetPageStyles()
bool m_bHasFtn
If the current section has footnotes.
bool GetIsLastSectionGroup() const
StyleSheetTablePtr const & GetStyleSheetTable()
css::uno::Reference< css::text::XTextRange > m_xAltChunkStartingRange
bool IsReadGlossaries() const
If we're importing autotext.
void ResetFrameProperties()
sal_Int8 m_nDropCapLength
css::text::WrapTextMode m_nWrap
const css::uno::Any & getValue() const
OUString m_sFirstPageStyleName
sal_Int32 m_nBorderDistances[4]
css::uno::Reference< css::beans::XPropertySet > m_aFollowPageStyle
void ApplyBorderToPageStyles(DomainMapper_Impl &rDM_Impl, BorderApply eBorderApply, BorderOffsetFrom eOffsetFrom)
OUString m_sFollowPageStyleName
static void SetBorderDistance(const css::uno::Reference< css::beans::XPropertySet > &xStyle, PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, BorderOffsetFrom eOffsetFrom, sal_uInt32 nLineWidth, DomainMapper_Impl &rDM_Impl)
void SetBorder(BorderPosition ePos, sal_Int32 nLineDistance, const css::table::BorderLine2 &rBorderLine, bool bShadow)
sal_Int16 ColumnCount() const
void DontBalanceTextColumns()
css::uno::Reference< css::beans::XPropertySet > m_aFirstPageStyle
const OUString & GetPageStyleName(bool bFirstPage=false)
css::uno::Reference< css::beans::XPropertySet > GetPageStyle(DomainMapper_Impl &rDM_Impl, bool bFirst)
sal_Int32 m_nDebugSectionNumber
std::optional< css::table::BorderLine2 > m_oBorderLines[4]
@ TablePropertyMapTarget_MAX
@ TablePropertyMapTarget_START
virtual void insertTableProperties(const PropertyMap *, const bool bOverwrite=true) override
bool getValue(TablePropertyMapTarget eWhich, sal_Int32 &nFill)
void setValue(TablePropertyMapTarget eWhich, sal_Int32 nSet)
ValidValue m_aValidValues[TablePropertyMapTarget_MAX]
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
virtual void Insert(SotClipboardFormatId nFormat, const OUString &rFormatName) override
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
tools::Long const nRightMargin
tools::Long const nBottomMargin
tools::Long const nTopMargin
tools::Long const nBorder
tools::Long const nLeftMargin
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
void BorderDistanceFromWord(bool bFromEdge, sal_Int32 &nMargin, sal_Int32 &nBorderDistance, sal_Int32 nBorderWidth)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
SVX_DLLPUBLIC OUString getProperty(css::uno::Reference< css::beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)
sal_Int32 convertTwipToMM100(sal_Int32 _t)
OUString getPropertyName(PropertyIds eId)
void lcl_DumpTableColumnSeparators(const uno::Any &rTableColumnSeparators)
void BeforeConvertToTextFrame(std::deque< css::uno::Any > &rFramedRedlines, std::vector< sal_Int32 > &redPos, std::vector< sal_Int32 > &redLen, std::vector< OUString > &redCell, std::vector< OUString > &redTable)
@ PROP_TOP_BORDER_DISTANCE
@ PROP_AUTOMATIC_DISTANCE
@ PROP_GRID_SNAP_TO_CHARS
@ PROP_PAGE_NUMBER_OFFSET
@ PROP_RIGHT_BORDER_DISTANCE
@ PROP_HEADER_BODY_DISTANCE
@ PROP_FOOTER_BODY_DISTANCE
@ PROP_FOOTNOTE_LINE_RELATIVE_WIDTH
@ PROP_FOOTER_DYNAMIC_SPACING
@ PROP_FOOTNOTE_LINE_ADJUST
@ PROP_HEADER_DYNAMIC_SPACING
@ PROP_GRID_STANDARD_MODE
@ PROP_TABLE_COLUMN_SEPARATORS
@ PROP_CELL_INTEROP_GRAB_BAG
@ PROP_LEFT_BORDER_DISTANCE
@ PROP_FOOTER_IS_DYNAMIC_HEIGHT
@ PROP_HEADER_IS_DYNAMIC_HEIGHT
@ PROP_BOTTOM_BORDER_DISTANCE
@ PROP_PARA_LINE_NUMBER_START_VALUE
void AfterConvertToTextFrame(DomainMapper_Impl &rDM_Impl, std::deque< css::uno::Any > &aFramedRedlines, std::vector< sal_Int32 > &redPos, std::vector< sal_Int32 > &redLen, std::vector< OUString > &redCell, std::vector< OUString > &redTable)
static void lcl_AnyToTag(const uno::Any &rAny)
static uno::Reference< beans::XPropertySet > lcl_GetRangeProperties(bool bIsFirstSection, DomainMapper_Impl &rDM_Impl, const uno::Reference< text::XTextRange > &xStartingRange)