20 #include <com/sun/star/embed/XEmbeddedObject.hpp>
21 #include <com/sun/star/i18n/ScriptType.hpp>
22 #include <com/sun/star/drawing/XShape.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <section.hxx>
81 #include <strings.hrc>
100 #if OSL_DEBUG_LEVEL > 1
132 const char aTableHeadingName[] =
"Table Heading";
133 const char aQuotations[] =
"Quotations";
134 const char aCaption[] =
"Caption";
135 const char aHeading[] =
"Heading";
136 const char aQuotation[] =
"Quotation";
137 const char aSourceText[] =
"Source Text";
140 constexpr OUStringLiteral aDocumentString =
u"Document";
141 constexpr OUStringLiteral aDivString =
u"Div";
142 constexpr OUStringLiteral aSectString =
u"Sect";
143 constexpr OUStringLiteral aHString =
u"H";
144 constexpr OUStringLiteral aH1String =
u"H1";
145 constexpr OUStringLiteral aH2String =
u"H2";
146 constexpr OUStringLiteral aH3String =
u"H3";
147 constexpr OUStringLiteral aH4String =
u"H4";
148 constexpr OUStringLiteral aH5String =
u"H5";
149 constexpr OUStringLiteral aH6String =
u"H6";
150 constexpr OUStringLiteral aListString =
u"L";
151 constexpr OUStringLiteral aListItemString =
u"LI";
152 constexpr OUStringLiteral aListBodyString =
u"LBody";
153 constexpr OUStringLiteral aBlockQuoteString =
u"BlockQuote";
154 constexpr OUStringLiteral aCaptionString =
u"Caption";
155 constexpr OUStringLiteral aIndexString =
u"Index";
156 constexpr OUStringLiteral aTOCString =
u"TOC";
157 constexpr OUStringLiteral aTOCIString =
u"TOCI";
158 constexpr OUStringLiteral aTableString =
u"Table";
159 constexpr OUStringLiteral aTRString =
u"TR";
160 constexpr OUStringLiteral aTDString =
u"TD";
161 constexpr OUStringLiteral aTHString =
u"TH";
162 constexpr OUStringLiteral aBibEntryString =
u"BibEntry";
163 constexpr OUStringLiteral aQuoteString =
u"Quote";
164 constexpr OUStringLiteral aSpanString =
u"Span";
165 constexpr OUStringLiteral aCodeString =
u"Code";
166 constexpr OUStringLiteral aFigureString =
u"Figure";
167 constexpr OUStringLiteral aFormulaString =
u"Formula";
168 constexpr OUStringLiteral aLinkString =
u"Link";
169 constexpr OUStringLiteral aNoteString =
u"Note";
172 bool lcl_IsHeadlineCell(
const SwCellFrame& rCellFrame )
184 bRet = sStyleName == aTableHeadingName;
191 bool lcl_IsInNonStructEnv(
const SwFrame& rFrame )
203 if ( rFrame.
GetUpper() != pTabFrame &&
212 void* lcl_GetKeyFromFrame(
const SwFrame& rFrame )
214 void* pKey =
nullptr;
217 pKey = const_cast<void*>(static_cast<void const *>(&(static_cast<const SwPageFrame&>(rFrame).
GetFormat()->getIDocumentSettingAccess())));
219 pKey = const_cast<void*>(static_cast<void const *>(static_cast<const SwTextFrame&>(rFrame).GetTextNodeFirst()));
221 pKey = const_cast<void*>(static_cast<void const *>(static_cast<const SwSectionFrame&>(rFrame).GetSection()));
223 pKey = const_cast<void*>(static_cast<void const *>(static_cast<const SwTabFrame&>(rFrame).GetTable()));
225 pKey = const_cast<void*>(static_cast<void const *>(static_cast<const SwRowFrame&>(rFrame).GetTabLine()));
230 pKey =
const_cast<void*
>(
static_cast<void const *
>(&
static_cast<const SwCellFrame&
>(rFrame).GetTabBox()->FindStartOfRowSpan( *pTable )));
242 const SwNode* pNode = &rNode;
249 if (aIdx.GetNode().IsTextNode())
252 *rTextFrame.
getRootFrame(), *aIdx.GetNode().GetTextNode());
257 if ( (pPrevNumRule == pNumRule) &&
264 pNode = &aIdx.GetNode();
278 rShell.SwCursorShell::ClearMark();
290 : m_nEndStructureElement( 0 ),
291 m_nRestoreCurrentTag( -1 ),
292 mpNumInfo( pNumInfo ),
293 mpFrameInfo( pFrameInfo ),
294 mpPorInfo( pPorInfo )
302 #if OSL_DEBUG_LEVEL > 1
315 #if OSL_DEBUG_LEVEL > 1
318 (
void)nCurrentStruct;
327 #if OSL_DEBUG_LEVEL > 1
333 #if OSL_DEBUG_LEVEL > 1
336 (
void)nCurrentStruct;
343 sal_Int32 nReopenTag = -1;
344 bool bContinue =
false;
349 const SwFrame* pKeyFrame =
nullptr;
369 if ((RndStdIds::FLY_AT_PARA == rAnchor.
GetAnchorId()) ||
370 (RndStdIds::FLY_AT_CHAR == rAnchor.
GetAnchorId()) ||
373 pKeyFrame =
static_cast<const SwFlyFrame&
>(rFrame).GetAnchorFrame();
380 void* pKey = lcl_GetKeyFromFrame( *pKeyFrame );
385 const FrameTagIdMap::const_iterator aIter = rFrameTagIdMap.find( pKey );
386 if ( aIter != rFrameTagIdMap.end() )
387 nReopenTag = (*aIter).second;
392 if ( -1 != nReopenTag )
396 OSL_ENSURE( bSuccess,
"Failed to reopen tag" );
398 #if OSL_DEBUG_LEVEL > 1
405 return bRet && !bContinue;
413 OSL_ENSURE( bSuccess,
"Failed to restore reopened tag" );
415 #if OSL_DEBUG_LEVEL > 1
427 #if OSL_DEBUG_LEVEL > 1
428 aStructStack.push_back( o3tl::narrowing<sal_uInt16>(eType) );
448 rNumListIdMap[ pNodeNum ] = nId;
453 rNumListBodyIdMap[ pNodeNum ] = nId;
466 const void* pKey = lcl_GetKeyFromFrame( rFrame );
471 rFrameTagIdMap[ pKey ] = nId;
483 #if OSL_DEBUG_LEVEL > 1
502 bool bPlacement =
false;
503 bool bWritingMode =
false;
504 bool bSpaceBefore =
false;
505 bool bSpaceAfter =
false;
506 bool bStartIndent =
false;
507 bool bEndIndent =
false;
508 bool bTextIndent =
false;
509 bool bTextAlign =
false;
511 bool bHeight =
false;
513 bool bRowSpan =
false;
635 OSL_ENSURE( pFrame->
IsTextFrame(),
"Frame type <-> tag attribute mismatch" );
637 static_cast<const SwTextFrame*
>(pFrame)->GetTextNodeForParaProps()->GetSwAttrSet().GetLRSpace();
638 nVal = rSpace.GetTextFirstLineOffset();
645 OSL_ENSURE( pFrame->
IsTextFrame(),
"Frame type <-> tag attribute mismatch" );
646 const SwAttrSet& aSet =
static_cast<const SwTextFrame*
>(pFrame)->GetTextNodeForParaProps()->GetSwAttrSet();
647 const SvxAdjust nAdjust = aSet.GetAdjust().GetAdjust();
648 if ( SvxAdjust::Block == nAdjust || SvxAdjust::Center == nAdjust ||
650 (!pFrame->
IsRightToLeft() && SvxAdjust::Right == nAdjust) ) )
652 eVal = SvxAdjust::Block == nAdjust ?
654 SvxAdjust::Center == nAdjust ?
683 !
static_cast<const SwTabFrame*
>(pFrame)->IsFollow() &&
684 !
static_cast<const SwTabFrame*
>(pFrame)->HasFollow() ) )
709 const TableColumnsMapEntry::const_iterator aLeftIter = rCols.find( nLeft );
710 const TableColumnsMapEntry::const_iterator aRightIter = rCols.find( nRight );
712 OSL_ENSURE( aLeftIter != rCols.end() && aRightIter != rCols.end(),
"Colspan trouble" );
713 if ( aLeftIter != rCols.end() && aRightIter != rCols.end() )
715 nVal = std::distance( aLeftIter, aRightIter );
731 bool bActualText =
false;
732 bool bBaselineShift =
false;
733 bool bTextDecorationType =
false;
734 bool bLinkAttribute =
false;
735 bool bLanguage =
false;
750 bTextDecorationType =
756 bTextDecorationType =
768 OUString aActualText;
770 aActualText = OUString(
u'\x00ad');
776 if ( bBaselineShift )
780 if ( nVal > 0 ) nVal = 33;
781 else if ( nVal < 0 ) nVal = -33;
785 nVal = nVal * pPor->
Height() / 100;
790 if ( bTextDecorationType )
808 if ( nDefaultLang != nCurrentLanguage )
812 if ( bLinkAttribute )
818 auto aIter = std::find_if(rLinkIdMap.begin(), rLinkIdMap.end(),
819 [&aPorCenter](
const IdMapEntry& rEntry) {
return rEntry.first.Contains(aPorCenter); });
820 if (aIter != rLinkIdMap.end())
822 sal_Int32 nLinkId = (*aIter).second;
831 OSL_ENSURE(
mpNumInfo,
"List without mpNumInfo?" );
836 OSL_ENSURE( rFrame.
IsTextFrame(),
"numbered only for text frames" );
841 if ( lcl_IsInNonStructEnv( rTextFrame ) || rTextFrame.IsFollow() )
844 const SwTextNode *
const pTextNd = rTextFrame.GetTextNodeForParaProps();
846 const SwNodeNum* pNodeNum = pTextNd->
GetNum(rTextFrame.getRootFrame());
848 const bool bNumbered = !pTextNd->
IsOutline() && pNodeNum && pNodeNum->
GetParent() && pNumRule;
857 const bool bSameNumbering = lcl_HasPreviousParaSameNumRule(rTextFrame, *pTextNd);
860 if ( bSameNumbering )
862 sal_Int32 nReopenTag = -1;
872 if ( bNewSubListStart || bNoLabel )
877 if ( bNewSubListStart )
881 NumListBodyIdMap::const_iterator aIter;
884 aIter = rNumListBodyIdMap.find( pParent );
885 while ( aIter == rNumListBodyIdMap.end() &&
nullptr != ( pParent = pParent->
GetParent() ) );
887 if ( aIter != rNumListBodyIdMap.end() )
888 nReopenTag = (*aIter).second;
899 const NumListBodyIdMap::const_iterator aIter = rNumListBodyIdMap.find( pPrevious );
900 if ( aIter != rNumListBodyIdMap.end() )
902 nReopenTag = (*aIter).second;
906 pPrevious = pPrevious->
GetPred(
true);
922 const NumListIdMap::const_iterator aIter = rNumListIdMap.find( pPrevious );
923 if ( aIter != rNumListIdMap.end() )
925 nReopenTag = (*aIter).second;
929 pPrevious = pPrevious->
GetPred(
true);
933 if ( -1 != nReopenTag )
938 #if OSL_DEBUG_LEVEL > 1
947 rNumListIdMap.clear();
949 rNumListBodyIdMap.clear();
972 if ( lcl_IsInNonStructEnv( *pFrame ) )
980 sal_uInt16 nPDFType = USHRT_MAX;
994 aPDFType = aDocumentString;
1010 aPDFType = aDivString;
1020 aPDFType = aNoteString;
1038 aPDFType = aIndexString;
1043 aPDFType = aTOCString;
1050 aPDFType = aSectString;
1062 static_cast<const SwTextFrame*
>(pFrame)->GetTextNodeForParaProps();
1067 OUString sStyleName;
1068 OUString sParentStyleName;
1072 if ( pParentTextFormat)
1079 aPDFType = sStyleName;
1083 if (sStyleName == aQuotations)
1086 aPDFType = aBlockQuoteString;
1091 else if (sStyleName == aCaption)
1094 aPDFType = aCaptionString;
1099 else if (sParentStyleName == aCaption)
1102 aPDFType = sStyleName + aCaptionString;
1107 else if (sStyleName == aHeading)
1110 aPDFType = aHString;
1119 nRealLevel =
std::min(nRealLevel, 5);
1125 aPDFType = aH1String;
1128 aPDFType = aH2String;
1131 aPDFType = aH3String;
1134 aPDFType = aH4String;
1137 aPDFType = aH5String;
1140 aPDFType = aH6String;
1170 aPDFType = aTableString;
1178 const TableColumnsMap::const_iterator aIter = rTableColumnsMap.find( pTable );
1180 if ( aIter == rTableColumnsMap.end() )
1187 while ( pMasterFrame )
1196 rCols.insert( nLeft );
1198 while ( pCellFrame )
1201 rCols.insert( nRight );
1202 pCellFrame = pCellFrame->
GetNext();
1206 pMasterFrame = pMasterFrame->
GetFollow();
1221 if ( !static_cast<const SwRowFrame*>(pFrame)->IsRepeatedHeadline() )
1224 aPDFType = aTRString;
1238 if ( pTable->
IsInHeadline( *pFrame ) || lcl_IsHeadlineCell( *static_cast<const SwCellFrame*>(pFrame) ) )
1241 aPDFType = aTHString;
1246 aPDFType = aTDString;
1263 bool bFormula =
false;
1270 uno::Reference< embed::XEmbeddedObject > aRef = aOLEObj.
GetOleRef();
1279 aPDFType = aFormulaString;
1284 aPDFType = aFigureString;
1290 aPDFType = aDivString;
1298 if ( USHRT_MAX != nPDFType )
1300 BeginTag( static_cast<vcl::PDFWriter::StructElement>(nPDFType), aPDFType );
1323 if ( lcl_IsInNonStructEnv( *pFrame ) )
1326 sal_uInt16 nPDFType = USHRT_MAX;
1337 aPDFType = aSpanString;
1344 std::pair<SwTextNode const*, sal_Int32>
const pos(
1349 OUString sStyleName;
1350 if ( !pInetFormatAttr )
1352 std::vector<SwTextAttr *>
const charAttrs(
1356 ? (*charAttrs.begin())->GetCharFormat().GetCharFormat() :
nullptr;
1362 if( pInetFormatAttr )
1365 aPDFType = aLinkString;
1368 else if (sStyleName == aQuotation)
1371 aPDFType = aQuoteString;
1373 else if (sStyleName == aSourceText)
1376 aPDFType = aCodeString;
1390 nCurrentLanguage != nDefaultLang ||
1391 !sStyleName.isEmpty())
1394 if (!sStyleName.isEmpty())
1395 aPDFType = sStyleName;
1397 aPDFType = aSpanString;
1405 aPDFType = aLinkString;
1421 aPDFType = aLinkString;
1426 aPDFType = aBibEntryString;
1441 if ( USHRT_MAX != nPDFType )
1443 BeginTag( static_cast<vcl::PDFWriter::StructElement>(nPDFType), aPDFType );
1455 const OUString& rPageRange,
1456 bool bSkipEmptyPages,
1457 bool bEditEngineOnly,
1461 mbSkipEmptyPages( bSkipEmptyPages ),
1462 mbEditEngineOnly( bEditEngineOnly ),
1463 mrPrintData( rPrintData )
1465 if ( !rPageRange.isEmpty() )
1473 sal_Int32 nPageNumber = 0;
1476 if ( pCurrPage->IsEmptyPage() )
1481 pCurrPage =
static_cast<const SwPageFrame*
>( pCurrPage->GetNext() );
1491 #if OSL_DEBUG_LEVEL > 1
1498 if ( i18n::ScriptType::ASIAN == nScript )
1500 else if ( i18n::ScriptType::COMPLEX == nScript )
1522 double fScale = 0.75;
1523 aRectSize.
setWidth( aRectSize.Width() * fScale );
1524 aRectSize.setHeight( aRectSize.Height() * fScale );
1530 aRect.
Move(0, nShiftY);
1540 if ( !pPDFExtOutDevData )
1552 aMapMode.SetMapUnit( MapUnit::MapTwip );
1558 mrSh.SwCursorShell::Push();
1559 mrSh.SwCursorShell::ClearMark();
1570 std::vector<SwFormatField*> vpFields;
1572 for(
auto pFormatField : vpFields)
1574 const SwTextNode* pTNd = pFormatField->GetTextField()->GetpTextNode();
1575 OSL_ENSURE(
nullptr != pTNd,
"Enhanced pdf export - text node is missing");
1576 if(!lcl_TryMoveToNonHiddenField(
mrSh, *pTNd, *pFormatField))
1584 for (sal_Int32 aNotePageNum : aNotePageNums)
1593 const Color* pColor;
1594 pNumFormatter->
GetOutputString(aDateDiff.GetDate(), nFormat, sDate, &pColor);
1604 pPDFExtOutDevData->
CreateNote(aRect, aNote, aNotePageNum);
1606 mrSh.SwCursorShell::ClearMark();
1614 for(
auto &rAttr : aArr )
1617 OSL_ENSURE(
nullptr != p,
"Enhanced pdf export - SwGetINetAttr is missing" );
1620 OSL_ENSURE(
nullptr != pTNd,
"Enhanced pdf export - text node is missing" );
1640 const bool bIntern =
'#' == aURL[0];
1648 aTmp.insert( aTmp.begin(),
mrSh.SwCursorShell::GetCursor_()->begin(),
mrSh.SwCursorShell::GetCursor_()->end() );
1649 OSL_ENSURE( !aTmp.empty(),
"Enhanced pdf export - rectangles are missing" );
1655 sal_Int32 nDestId = -1;
1658 aURL = aURL.copy( 1 );
1659 mrSh.SwCursorShell::ClearMark();
1675 if ( -1 != nDestPageNum )
1678 nDestId = pPDFExtOutDevData->
CreateDest(aRect, nDestPageNum);
1682 if ( !bIntern || -1 != nDestId )
1689 const size_t nNumOfRects = aTmp.size();
1690 for (
size_t i = 0;
i < nNumOfRects; ++
i )
1693 const SwRect& rLinkRect( aTmp[
i ] );
1698 for (sal_Int32 aLinkPageNum : aLinkPageNums)
1702 const sal_Int32 nLinkId =
1703 pPDFExtOutDevData->
CreateLink(aRect, aLinkPageNum);
1706 const IdMapEntry aLinkEntry( rLinkRect, nLinkId );
1711 pPDFExtOutDevData->
SetLinkDest( nLinkId, nDestId );
1713 pPDFExtOutDevData->
SetLinkURL( nLinkId, aURL );
1716 if ( bHeaderFooter )
1723 mrSh.SwCursorShell::ClearMark();
1729 const size_t nSpzFrameFormatsCount = pTable->
size();
1730 for(
size_t n = 0;
n < nSpzFrameFormatsCount; ++
n )
1744 const bool bIntern =
'#' ==
aURL[0];
1747 sal_Int32 nDestId = -1;
1751 mrSh.SwCursorShell::ClearMark();
1766 if ( -1 != nDestPageNum )
1769 nDestId = pPDFExtOutDevData->
CreateDest(aRect, nDestPageNum);
1773 if ( !bIntern || -1 != nDestId )
1782 for (sal_Int32 aLinkPageNum : aLinkPageNums)
1785 const sal_Int32 nLinkId =
1786 pPDFExtOutDevData->
CreateLink(aRect, aLinkPageNum);
1790 pPDFExtOutDevData->
SetLinkDest( nLinkId, nDestId );
1796 if (RndStdIds::FLY_AT_PAGE != rAnch.
GetAnchorId())
1816 if (aScreenPageNums.empty())
1819 uno::Reference<drawing::XShape> xShape(
pObject->getUnoShape(), uno::UNO_QUERY);
1820 if (xShape->getShapeType() ==
"com.sun.star.drawing.MediaShape")
1822 uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY);
1824 xShapePropSet->getPropertyValue(
"MediaURL") >>= aMediaURL;
1825 if (!aMediaURL.isEmpty())
1829 for (sal_Int32 nScreenPageNum : aScreenPageNums)
1831 sal_Int32 nScreenId = pPDFExtOutDevData->
CreateScreen(aPDFRect, nScreenPageNum);
1832 if (aMediaURL.startsWith(
"vnd.sun.star.Package:"))
1835 OUString aTempFileURL;
1836 xShapePropSet->getPropertyValue(
"PrivateTempFileURL") >>= aTempFileURL;
1847 mrSh.SwCursorShell::ClearMark();
1852 std::vector<SwFormatField*> vpFields;
1854 for(
auto pFormatField : vpFields )
1856 if( pFormatField->GetTextField() && pFormatField->IsFieldInDoc() )
1858 const SwTextNode* pTNd = pFormatField->GetTextField()->GetpTextNode();
1859 OSL_ENSURE(
nullptr != pTNd,
"Enhanced pdf export - text node is missing" );
1860 if(!lcl_TryMoveToNonHiddenField(
mrSh, *pTNd, *pFormatField))
1863 mrSh.SwCursorShell::SetMark();
1868 aTmp.insert( aTmp.begin(),
mrSh.SwCursorShell::GetCursor_()->begin(),
mrSh.SwCursorShell::GetCursor_()->end() );
1869 OSL_ENSURE( !aTmp.empty(),
"Enhanced pdf export - rectangles are missing" );
1871 mrSh.SwCursorShell::ClearMark();
1884 if ( -1 != nDestPageNum )
1888 const sal_Int32 nDestId = pPDFExtOutDevData->
CreateDest(aRect, nDestPageNum);
1895 const size_t nNumOfRects = aTmp.size();
1896 for (
size_t i = 0;
i < nNumOfRects; ++
i )
1899 const SwRect& rLinkRect( aTmp[
i ] );
1904 for (sal_Int32 aLinkPageNum : aLinkPageNums)
1908 const sal_Int32 nLinkId =
1909 pPDFExtOutDevData->
CreateLink(aRect, aLinkPageNum);
1912 const IdMapEntry aLinkEntry( rLinkRect, nLinkId );
1916 pPDFExtOutDevData->
SetLinkDest( nLinkId, nDestId );
1919 if ( bHeaderFooter )
1927 mrSh.SwCursorShell::ClearMark();
1935 for (
size_t nIdx = 0; nIdx < nFootnoteCount; ++nIdx )
1956 mrSh.SwCursorShell::SetMark();
1961 aTmp.insert( aTmp.begin(),
mrSh.SwCursorShell::GetCursor_()->begin(),
mrSh.SwCursorShell::GetCursor_()->end() );
1962 OSL_ENSURE( !aTmp.empty(),
"Enhanced pdf export - rectangles are missing" );
1965 mrSh.SwCursorShell::ClearMark();
1970 const SwRect aLinkRect( aTmp[ 0 ] );
1978 if ( -1 != nDestPageNum )
1986 if (fnBodyPage->IsVertical()){
1987 tools::Long fnSymbolTop = fnBodyPage->GetTopMargin() + fnBodyPage->getFrameArea().
Top();
1989 fnSymbolRect =
SwRect(rDestRect.
Pos().X(),fnSymbolTop,rDestRect.
Width(),symbolHeight);
1991 if (fnBodyPage->IsRightToLeft()){
1992 tools::Long fnSymbolRight = fnBodyPage->getFrameArea().
Right() - fnBodyPage->GetRightMargin();
1994 fnSymbolRect =
SwRect(rDestRect.
Pos().X(),rDestRect.
Pos().Y(),symbolWidth,rDestRect.
Height());
1996 tools::Long fnSymbolLeft = fnBodyPage->GetLeftMargin() + fnBodyPage->getFrameArea().
Left();
1998 fnSymbolRect =
SwRect(fnSymbolLeft,rDestRect.
Pos().Y(),symbolWidth,rDestRect.
Height());
2004 const sal_Int32 nBackLinkId = pPDFExtOutDevData->
CreateLink(aFootnoteSymbolRect, nDestPageNum);
2006 const sal_Int32 nDestId = pPDFExtOutDevData->
CreateDest(aRect, nDestPageNum);
2013 const sal_Int32 nLinkId = pPDFExtOutDevData->
CreateLink(aRect, aLinkPageNum);
2015 const sal_Int32 nBackDestId = pPDFExtOutDevData->
CreateDest(aRect, aLinkPageNum);
2017 const IdMapEntry aLinkEntry( aLinkRect, nLinkId );
2021 const IdMapEntry aBackLinkEntry( aFootnoteSymbolRect, nBackLinkId );
2024 pPDFExtOutDevData->
SetLinkDest( nLinkId, nDestId );
2025 pPDFExtOutDevData->
SetLinkDest( nBackLinkId, nBackDestId );
2034 typedef std::pair< sal_Int8, sal_Int32 > StackEntry;
2035 std::stack< StackEntry > aOutlineStack;
2036 aOutlineStack.push( StackEntry( -1, -1 ) );
2044 OSL_ENSURE(
nullptr != pTNd,
"Enhanced pdf export - text node is missing" );
2054 sal_Int8 nLevelOnTopOfStack = aOutlineStack.top().first;
2055 while ( nLevelOnTopOfStack >= nLevel &&
2056 nLevelOnTopOfStack != -1 )
2058 aOutlineStack.pop();
2059 nLevelOnTopOfStack = aOutlineStack.top().first;
2061 const sal_Int32 nParent = aOutlineStack.top().second;
2073 if ( -1 != nDestPageNum )
2077 const sal_Int32 nDestId =
2078 pPDFExtOutDevData->
CreateDest(aRect, nDestPageNum);
2085 const sal_Int32 nOutlineId =
2089 aOutlineStack.push( StackEntry( nLevel, nOutlineId ) );
2107 const ::sw::mark::IMark* pBkmk = *ppMark;
2108 mrSh.SwCursorShell::ClearMark();
2109 const OUString& sBkName = pBkmk->GetName();
2127 if ( -1 != nDestPageNum )
2133 mrSh.SwCursorShell::ClearMark();
2142 std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->
GetBookmarks();
2143 for (
const auto& rBookmark : rBookmarks )
2145 OUString aBookmarkName( rBookmark.aBookmark );
2146 const bool bIntern =
'#' == aBookmarkName[0];
2149 aBookmarkName = aBookmarkName.copy( 1 );
2161 if ( -1 != nDestPageNum )
2164 if ( rBookmark.nLinkId != -1 )
2167 const sal_Int32 nDestId = pPDFExtOutDevData->
CreateDest(aRect, nDestPageNum);
2170 pPDFExtOutDevData->
SetLinkDest( rBookmark.nLinkId, nDestId );
2179 pPDFExtOutDevData->
SetLinkURL( rBookmark.nLinkId, aBookmarkName );
2193 if (!pPDFExtOutDevData)
2198 std::vector<SwFormatField*> aFields;
2207 for (
const auto pFormatField : aFields)
2209 if (!pFormatField->GetTextField() || !pFormatField->IsFieldInDoc())
2214 const auto& rAuthorityField
2216 if (!rAuthorityField.HasURL())
2223 if (!lcl_TryMoveToNonHiddenField(
mrSh, rTextNode, *pFormatField))
2229 mrSh.SwCursorShell::SetMark();
2233 for (
const auto& rLinkRect : *
mrSh.SwCursorShell::GetCursor_())
2238 sal_Int32 nLinkId = pPDFExtOutDevData->CreateLink(aRect, rLinkPageNum);
2241 pPDFExtOutDevData->SetLinkURL(nLinkId, rURL);
2245 mrSh.SwCursorShell::ClearMark();
2254 if ( !aPageNums.empty() )
2255 return aPageNums[0];
2263 const SwRect& rRect )
const
2265 std::vector< sal_Int32 > aPageNums;
2269 if ( nPageNumOfRect < 0 )
2281 sal_Int32 nOutputPageNum = 0;
2284 for ( ; aIter != aEnd; ++aIter )
2286 if ( *aIter == nPageNumOfRect )
2287 aPageNums.push_back( nOutputPageNum );
2296 sal_Int32 nOutputPageNum = 0;
2301 if (
i == static_cast<size_t>( nPageNumOfRect ) )
2303 aPageNums.push_back( nOutputPageNum );
2311 aPageNums.push_back( nPageNumOfRect );
2321 const OUString& rURL,
2322 bool bIntern )
const
2333 SwRect aHFLinkRect( rLinkRect );
2339 if ( aHFLinkRect.
Pos() != rLinkRect.
Pos() )
2344 for (sal_Int32 aHFLinkPageNum : aHFLinkPageNums)
2348 const sal_Int32 nHFLinkId =
2349 rPDFExtOutDevData.
CreateLink(aRect, aHFLinkPageNum);
2353 rPDFExtOutDevData.
SetLinkDest( nHFLinkId, nDestId );
2355 rPDFExtOutDevData.
SetLinkURL( nHFLinkId, rURL );
SwFieldType * GetFieldType(size_t nField, SwFieldIds nResId=SwFieldIds::Unknown) const
get field types with a ResId, if 0 get all
Instances of SwFields and those derived from it occur 0 to n times.
SwFrame * FindFooterOrHeader()
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
OUString const & GetAuthorField(ToxAuthorityField ePos) const
Base class of the Writer layout elements.
Represents the visualization of a paragraph.
tools::Long GetRight(const SwRect &rRect) const
const Por_Info * mpPorInfo
static LanguageType GetDefaultLanguage()
sal_uInt8 m_nEndStructureElement
void Right(const tools::Long nRight)
void GetINetAttrs(SwGetINetAttrs &rArr, bool bIncludeInToxContent=true)
const SwSortedObjs * GetDrawObjs() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
Marks a position in the document model.
void EndStructureElements()
const SwNodes & GetNodes() const
const SwPageFrame * GetPageAtPos(const Point &rPt, const Size *pSize=nullptr, bool bExtend=false) const
Point rPt: The point that should be used to find the page Size pSize: If given, we return the (first)...
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr) const
LanguageType GetLanguage() const
Language at field position.
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
A tree of numbered nodes.
void setWidth(tools::Long nWidth)
SwPostItMode GetPrintPostIts() const
const SwOLEObj & GetOLEObj() const
const OUString & GetText() const
bool IsOutline() const
Returns if this text node is an outline.
SwTextAttr * GetAttr(TextFrameIndex nPos) const
Returns the attribute for a position.
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
virtual OUString getOutlineText(const tSortedOutlineNodeList::size_type nIdx, SwRootFrame const *pLayout, const bool bWithNumber=true, const bool bWithSpacesForLevel=false, const bool bWithFootnote=true) const =0
vcl::PDFExtOutDevData * mpPDFExtOutDevData
tools::Long GetLeftMargin(const SwFrame &rFrame) const
void CheckRestoreTag() const
const SwTable * GetTable() const
void Left(const tools::Long nLeft)
bool SetCurrentStructureElement(sal_Int32 nElement)
static TableColumnsMap s_aTableColumnsMap
std::unique_ptr< StringRangeEnumerator > mpRangeEnum
const IDocumentOutlineNodes * getIDocumentOutlineNodesAccess() const
SwFrameType GetType() const
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
SwNumberTreeNode * GetPred(bool bSibling=false) const
Returns the greatest descendant of the root that is smaller than this node, aka the predecessor of th...
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
void SetScreenURL(sal_Int32 nScreenId, const OUString &rURL)
void BeginTag(vcl::PDFWriter::StructElement aTagRole, const OUString &rTagName)
Base class of all fields.
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
SwNumberTreeNode * GetParent() const
Returns the parent of this node.
SwTabFrame is one table in the document layout, containing rows (which contain cells).
static LinkIdMap s_aLinkIdMap
static LanguageType s_eLanguageDefault
SwNode * DocumentSectionStartNode(SwNode *pNode) const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
static FrameTagIdMap s_aFrameTagIdMap
Provides access to the marks of a document.
void SetStructureAttribute(PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal)
virtual OUString GetPar1() const override
Author.
void MakeHeaderFooterLinks(vcl::PDFExtOutDevData &rPDFExtOutDevData, const SwTextNode &rTNd, const SwRect &rLinkRect, sal_Int32 nDestId, const OUString &rURL, bool bIntern) const
const MapMode & GetMapMode() const
bool IsFootnoteDeleted(IDocumentRedlineAccess const &rIDRA, SwTextFootnote const &rTextFootnote)
bool GotoFootnoteAnchor()
jump from footnote to anchor
bool IsFirst(const SwNumberTreeNode *pNode) const
Return if a node is first non-phantom child of this node.
void Pos(const Point &rNew)
FontStrikeout GetStrikeout() const
IDocumentMarkAccess * getIDocumentMarkAccess()
std::vector< IdMapEntry > LinkIdMap
sal_Int32 m_nRestoreCurrentTag
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
Of course Writer needs its own rectangles.
tools::Long GetWidth(const SwRect &rRect) const
const SwPrintData & mrPrintData
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
bool IsListRestart() const
EmbeddedObjectRef * pObject
const SwFrameFormats * GetSpzFrameFormats() const
bool JumpToSwMark(SwViewShell const *pVwSh, std::u16string_view rMark)
bool IsInHeaderFooter(const SwNodeIndex &rIdx) const
int GetAttrOutlineLevel() const
Returns outline level of this text node.
void GatherFields(std::vector< SwFormatField * > &rvFormatFields, bool bCollectOnlyInDocNodes=true) const
sal_Int32 getRowSpan() const
void SetAttributes(vcl::PDFWriter::StructElement eType)
OUString SwResId(TranslateId aId)
bool SelectHiddenRange()
If the current cursor position is inside a hidden range, the hidden range is selected.
bool GetIsExportNamedDestinations() const
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
const SwLinePortion & mrPor
const SwTableBox * GetTabBox() const
invariant for SwAuthorityField is that it is always registered at its SwAuthorityFieldType via AddFie...
const SwRect & getFrameArea() const
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
bool GotoFootnoteText()
jump from content to footnote
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
std::vector< SwGetINetAttr > SwGetINetAttrs
const OUString & GetText() const
const SwRowFrame * IsInSplitTableRow() const
SwTextPaintInfo & GetInfo()
sal_Int32 GetStart() const
void Width(tools::Long nNew)
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
void SetLinkDest(sal_Int32 nLinkId, sal_Int32 nDestId)
const SwFormatField & GetFormatField() const
FontEmphasisMark GetEmphasisMark() const
tools::Long GetLeft(const SwRect &rRect) const
static sal_uInt16 IsMath(const SvGlobalName &rName)
static FrameTagIdMap & GetFrameTagIdMap()
void ExportAuthorityEntryLinks()
Exports bibliography entry links.
sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
SwPageFrame * GetPageByPageNum(sal_uInt16 _nPageNum) const
Get page frame by physical page number looping through the lowers, which are page frame...
sal_Int32 GetCurrentStructureElement() const
static NumListIdMap s_aNumListIdMap
SwFontScript GetActual() const
SwAuthEntry * GetAuthEntry() const
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
SwShellCursor * GetCursor_()
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
SwTextNode const * GetTextNodeForParaProps() const
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
A helper class to save cursor state (position).
SwTabFrame * FindMaster(bool bFirstMaster=false) const
void BeginNumberedListStructureElements()
sal_uInt16 GetPageCount() const
std::map< const SwTable *, TableColumnsMapEntry > TableColumnsMap
const Num_Info * mpNumInfo
const SwPosition * GetPoint() const
bool GetIsExportTaggedPDF() const
SwIndex & Assign(SwIndexReg *, sal_Int32)
const SwTOXBase * GetTOXBase() const
void SetStructureAttributeNumerical(PDFWriter::StructAttribute eAttr, sal_Int32 nValue)
SwPageFrame * FindPageFrame()
const SwTextINetFormat & rINetAttr
constexpr TypedWhichId< SwFormatURL > RES_URL(111)
const SwTextPainter & mrTextPainter
const SwFrame * Lower() const
tools::Long GetHeight(const SwRect &rRect) const
FontLineStyle GetOverline() const
SwTaggedPDFHelper(const Num_Info *pNumInfo, const Frame_Info *pFrameInfo, const Por_Info *pPorInfo, OutputDevice const &rOut)
bool GotoINetAttr(const SwTextINetFormat &rAttr)
std::pair< SwRect, sal_Int32 > IdMapEntry
virtual int getOutlineLevel(const tSortedOutlineNodeList::size_type nIdx) const =0
SwLayoutFrame * GetUpper()
std::set< tools::Long, lt_TableColumn > TableColumnsMapEntry
sal_Int32 CreateDest(const tools::Rectangle &rRect, sal_Int32 nPageNr=-1, PDFWriter::DestAreaType eType=PDFWriter::DestAreaType::XYZ)
void CalcRect(const SwLinePortion &rPor, SwRect *pRect, SwRect *pIntersect=nullptr, const bool bInsideBox=false) const
Calculate the rectangular area where the portion takes place.
virtual tSortedOutlineNodeList::size_type getOutlineNodesCount() const =0
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
sal_Int32 CalcOutputPageNum(const SwRect &rRect) const
static bool IsExportTaggedPDF(const OutputDevice &rOut)
bool GetIsExportNotes() const
const SwRowFrame * IsInFollowFlowRow() const
tools::Long GetTopMargin(const SwFrame &rFrame) const
TextFrameIndex GetIdx() const
Marks a node in the document model.
std::vector< sal_Int32 > maPageNumberMap
The problem is that numbers in StringRangeEnumerator aren't accordant to real page numbers if mbSkipE...
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
~SwEnhancedPDFExportHelper()
tools::Long GetRightMargin(const SwFrame &rFrame) const
const SwTextNode * GetpTextNode() const
TextFrameIndex GetLen() const
A page of the document layout.
void BeginInlineStructureElements()
SwTextFrame * GetTextFrame()
sal_Int32 BeginStructureElement(PDFWriter::StructElement eType, const OUString &rAlias=OUString())
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
SwPostItMode
this must match the definitions in css::text::NotePrintMode
sal_Int32 CreateScreen(const tools::Rectangle &rRect, sal_Int32 nPageNr)
SwTable is one table in the document model, containing rows (which contain cells).
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
const OUString & GetText() const
SwTextNode * GetParaPropsNode(SwRootFrame const &rLayout, SwNodeIndex const &rNode)
SwSectionFrame * FindSctFrame()
FontLineStyle GetUnderline() const
const LanguageTag & getLocale()
void DescribeRegisteredDest(sal_Int32 nDestId, const tools::Rectangle &rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType=PDFWriter::DestAreaType::XYZ)
Base class for anything that can be part of a line in the Writer layout.
void SetLinkURL(sal_Int32 nLinkId, const OUString &rURL)
std::map< const SwNumberTreeNode *, sal_Int32 > NumListBodyIdMap
SwTextNode is a paragraph in the document model.
void CreateNote(const tools::Rectangle &rRect, const PDFNote &rNote, sal_Int32 nPageNr=-1)
For querying the INet-attributes for Navigator.
const Frame_Info * mpFrameInfo
LanguageType GetLanguage() const
std::vector< SwRect > SwRects
const SwContentNode * GetNode() const
std::map< const SwNumberTreeNode *, sal_Int32 > NumListIdMap
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
sal_uInt16 GetSeqNo() const
Get/set SequenceNo (of interest only for REF_SEQUENCEFLD).
SwFieldIds Which() const
ResId.
tools::Rectangle SVRect() const
tools::Long GetBottomMargin(const SwFrame &rFrame) const
general base class for all free-flowing frames
static std::vector< sal_uInt16 > aStructStack
static TableColumnsMap & GetTableColumnsMap()
PortionType GetWhichPor() const
sal_Int32 GetPageNumAndSetOffsetForPDF(OutputDevice &rOut, const SwRect &rRect) const
std::vector< PDFExtOutDevBookmarkEntry > & GetBookmarks()
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
bool IsCountedInList() const
bool IsNoTextFrame() const
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
LanguageType GetAppLanguage()
sal_Int32 CreateNamedDest(const OUString &sDestName, const tools::Rectangle &rRect, sal_Int32 nPageNr=-1)
bool IsRightToLeft() const
sal_Int32 CreateLink(const tools::Rectangle &rRect, sal_Int32 nPageNr=-1)
void Top(const tools::Long nTop)
const SwRect & GetCharRect() const
std::map< const void *, sal_Int32 > FrameTagIdMap
const OUString & GetSetRefName() const
bool IsParaPropsNode(SwRootFrame const &rLayout, SwTextNode const &rNode)
const Point & GetOrigin() const
std::vector< sal_Int32 > CalcOutputPageNums(const SwRect &rRect) const
void SetDocumentLocale(const css::lang::Locale &rLoc)
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
sal_Int32 CreateOutlineItem(sal_Int32 nParent, const OUString &rText, sal_Int32 nDestID)
static NumListIdMap & GetNumListIdMap()
void GotoPrevLayoutTextFrame(SwNodeIndex &rIndex, SwRootFrame const *const pLayout)
void BeginBlockStructureElements()
const SwTabFrame * GetFollow() const
static NumListBodyIdMap s_aNumListBodyIdMap
void SetActualText(const OUString &rText)
const sal_uInt16 CRSR_SKIP_CHARS
bool GetIsExportBookmarks() const
SwFootnoteIdxs & GetFootnoteIdxs()
vcl::ExtOutDevData * GetExtOutDevData() const
SwFormatColl * GetFormatColl() const
static LinkIdMap & GetLinkIdMap()
virtual bool IsCounted() const
Return if this node is counted.
void SetScreenStream(sal_Int32 nScreenId, const OUString &rURL)
SectionType GetType() const
SwEnhancedPDFExportHelper(SwEditShell &rSh, OutputDevice &rOut, const OUString &rPageRange, bool bSkipEmptyPages, bool bEditEngineOnly, const SwPrintData &rPrintData)
std::vector< SwNode * >::size_type size_type
const SwContentFrame * ContainsContent() const
Checks if the frame contains one or more ContentFrame's anywhere in his subsidiary structure; if so t...
static NumListBodyIdMap & GetNumListBodyIdMap()
SwRootFrame * GetLayout() const
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
short GetEscapement() const
void SetStructureBoundingBox(const tools::Rectangle &rRect)
bool GotoOutline(const OUString &rName)
void Height(tools::Long nNew)
tools::Rectangle SwRectToPDFRect(const SwPageFrame *pCurrPage, const tools::Rectangle &rRectangle) const
void EndStructureElement()
virtual sal_uInt16 GetSubType() const override
Get/set sub type.
bool GotoFormatField(const SwFormatField &rField)
bool IsFooterFrame() const
SwRootFrame * getRootFrame()
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
bool IsViewLocked() const
SwCellFrame is one table cell in the document layout.
bool GotoRefMark(const OUString &rRefMark, sal_uInt16 nSubType, sal_uInt16 nSeqNo)
jump to reference marker
void RestoreSavePos()
Restore cursor state to the one saved by SwCursorSaveState.
const SwFormatINetFormat & GetINetFormat() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwRowFrame is one table row in the document layout.
bool IsHeaderFrame() const
bool IsInHeadline(const SwFrame &rFrame) const
bool m_bDetectedRangeSegmentation false
SwTabFrame * FindTabFrame()
Base class of the Writer document model elements.