20#include <config_features.h>
25#include <com/sun/star/embed/Aspects.hpp>
26#include <com/sun/star/embed/ElementModes.hpp>
27#include <com/sun/star/frame/XModel.hpp>
28#include <com/sun/star/packages/XPackageEncryption.hpp>
29#include <com/sun/star/lang/XMultiServiceFactory.hpp>
36#include <rtl/random.h>
37#include <rtl/ustring.hxx>
38#include <rtl/ustrbuf.hxx>
59#include <editeng/editeng.hxx>
96#include <../../core/inc/DocumentRedlineManager.hxx>
113#include <editeng/editids.hrc>
119#include <com/sun/star/beans/PropertyAttribute.hpp>
120#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
121#include <com/sun/star/document/XViewDataSupplier.hpp>
134#include <osl/file.hxx>
142#include <unordered_set>
150#include <com/sun/star/i18n/XBreakIterator.hpp>
151#include <com/sun/star/i18n/ScriptType.hpp>
153#include <com/sun/star/ucb/SimpleFileAccess.hpp>
155#include <com/sun/star/script/vba/XVBACompatibility.hpp>
171 if(
pData &&
pData->GetInventor() == SdrInventor::ScOrSwDraw
187 OUStringBuffer aTmpStr;
190 aTmpStr.append(
"../");
193 if (!aTmpStr.isEmpty())
194 aTmpStr.append(rPath);
198 if (!aTmpStr.isEmpty())
200 bool bWasAbs =
false;
208 void lclIgnoreUString32(
SvStream& rStrm)
210 sal_uInt32 nChars(0);
221 constexpr sal_uInt32 WW8_HLINK_BODY = 0x00000001;
222 constexpr sal_uInt32 WW8_HLINK_ABS = 0x00000002;
223 constexpr sal_uInt32 WW8_HLINK_DESCR = 0x00000014;
224 constexpr sal_uInt32 WW8_HLINK_MARK = 0x00000008;
225 constexpr sal_uInt32 WW8_HLINK_FRAME = 0x00000080;
226 constexpr sal_uInt32 WW8_HLINK_UNC = 0x00000100;
231 sal_uInt8 const aGuidUrlMoniker[ 16 ] = {
232 0xE0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B };
234 sal_uInt8 const aGuidFileMoniker[ 16 ] = {
235 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 };
238 sal_uInt32 nFlags(0);
244 std::unique_ptr< OUString > xLongName;
245 std::unique_ptr< OUString > xShortName;
246 std::unique_ptr< OUString > xTextMark;
250 lclIgnoreUString32(
rStrm );
263 sal_uInt32 nStrLen(0);
273 else if(
::get_flag( nFlags, WW8_HLINK_BODY ) )
277 if( memcmp(aGuid, aGuidFileMoniker, 16) == 0 )
279 sal_uInt16 nLevel = 0;
283 sal_uInt32 nUnits = 0;
286 xShortName.reset(
new OUString);
295 sal_uInt32 nStrLen(0);
310 else if( memcmp(aGuid, aGuidUrlMoniker, 16) == 0 )
316 sal_uInt32 nStrLen(0);
320 xLongName.reset(
new OUString);
331 SAL_INFO(
"sw.ww8",
"WW8Hyperlink::ReadEmbeddedData - unknown content GUID");
341 if (!xLongName && xShortName)
342 xLongName.reset(
new OUString(*xShortName));
343 else if (!xLongName && xTextMark)
344 xLongName.reset(
new OUString );
350 if (xLongName->isEmpty())
351 *xTextMark = xTextMark->replace(
'!',
'.');
352 *xLongName +=
"#" + *xTextMark;
360class BasicProjImportHelper
363 uno::Reference< uno::XComponentContext >
mxCtx;
365 explicit BasicProjImportHelper(
SwDocShell& rShell ) : mrDocShell( rShell ),
369 bool import(
const uno::Reference< io::XInputStream >& rxIn );
370 OUString getProjectName()
const;
375bool BasicProjImportHelper::import(
const uno::Reference< io::XInputStream >& rxIn )
385 bRet = aVbaPrj.importVbaProject( *vbaStg );
388 catch(
const uno::Exception& )
395OUString BasicProjImportHelper::getProjectName()
const
397 OUString sProjName(
"Standard" );
398 uno::Reference< beans::XPropertySet > xProps( mrDocShell.GetModel(), uno::UNO_QUERY );
403 uno::Reference< script::vba::XVBACompatibility > xVBA( xProps->getPropertyValue(
"BasicLibraries" ), uno::UNO_QUERY_THROW );
404 sProjName = xVBA->getProjectName();
407 catch(
const uno::Exception& )
422 SBBItem() : cchData(0){}
424 sal_uInt16 m_fExtend;
426 sal_uInt16 m_cbExtra;
428 std::vector< SBBItem > m_dataItems;
430 Sttb(Sttb
const&) =
delete;
437 OUString getStringAtIndex( sal_uInt32 );
457 const size_t nMaxPossibleRecords = rS.
remainingSize() /
sizeof(sal_uInt16);
458 if (m_cData > nMaxPossibleRecords)
460 for ( sal_Int32 index = 0;
index < m_cData; ++
index )
465 m_dataItems.push_back( aItem );
472Sttb::getStringAtIndex( sal_uInt32 index )
475 if ( index < m_dataItems.size() )
476 aRet = m_dataItems[
index ].data;
482 :
SvxMSDffManager(*rRdr.m_pTableStream, rRdr.GetBaseURL(), rRdr.m_xWwFib->m_fcDggInfo,
483 rRdr.m_pDataStream, nullptr, 0,
COL_WHITE, rRdr.m_pStrm, bSkipImages),
484 m_rReader(rRdr), m_pFallbackStream(nullptr)
492 sal_uInt32 nFlags(0);
515 const int _nCalledByGroup )
const
520 if ( _nCalledByGroup > 0 )
526 OUString sStorageName;
528 uno::Reference < embed::XStorage > xDstStg;
533 css::uno::Reference< css::drawing::XShape > xShape;
553 css::embed::Aspects::MSOLE_CONTENT,
563 "if you're recursive, you're broken");
614 pImpRec->nShapeId = rObjData.
nShapeId;
623 pImpRec->pClientAnchorBuffer, pImpRec->nClientAnchorLen );
631 pImpRec->pClientDataBuffer, pImpRec->nClientDataLen );
633 pImpRec->nGroupShapeBooleanProperties = 0;
642 if (nBytesLeft > nAvailableBytes)
644 SAL_WARN(
"sw.ww8",
"Document claimed to have shape record of " << nBytesLeft <<
" bytes, but only " << nAvailableBytes <<
" available");
645 nBytesLeft = nAvailableBytes;
647 while( 5 < nBytesLeft )
651 sal_uInt32 nUDData(0);
657 case 0x038F: pImpRec->nXAlign = nUDData;
break;
659 pImpRec->nXRelTo = nUDData;
661 case 0x0391: pImpRec->nYAlign = nUDData;
break;
663 pImpRec->nYRelTo = nUDData;
665 case 0x03BF: pImpRec->nGroupShapeBooleanProperties = nUDData;
break;
670 pImpRec->relativeHorizontalWidth = nUDData;
676 pImpRec->isHorizontalRule =
true;
693 bool bIsSimpleDrawingTextBox = (pImpRec->eShapeType ==
mso_sptTextBox);
694 if (!bIsSimpleDrawingTextBox)
699 bIsSimpleDrawingTextBox =
721 bool bVerticalText =
false;
729 nTextRotationAngle = 9000_deg100;
733 nTextRotationAngle = 27000_deg100;
736 bVerticalText =
true;
739 bVerticalText =
true;
740 nTextRotationAngle = 9000_deg100;
748 if (nTextRotationAngle)
750 if (nTextRotationAngle == 9000_deg100)
756 sal_Int32 nOldTextLeft = nTextLeft;
757 sal_Int32 nOldTextRight = nTextRight;
758 sal_Int32 nOldTextTop = nTextTop;
759 sal_Int32 nOldTextBottom = nTextBottom;
761 nTextLeft = nOldTextBottom;
762 nTextRight = nOldTextTop;
763 nTextTop = nOldTextLeft;
764 nTextBottom = nOldTextRight;
766 else if (nTextRotationAngle == 27000_deg100)
772 sal_Int32 nOldTextLeft = nTextLeft;
773 sal_Int32 nOldTextRight = nTextRight;
774 sal_Int32 nOldTextTop = nTextTop;
775 sal_Int32 nOldTextBottom = nTextBottom;
777 nTextLeft = nOldTextTop;
778 nTextRight = nOldTextBottom;
779 nTextTop = nOldTextRight;
780 nTextBottom = nOldTextLeft;
784 if (bIsSimpleDrawingTextBox)
800 if( bIsSimpleDrawingTextBox )
802 std::shared_ptr<SvxMSDffShapeInfo>
const xTmpRec =
803 std::make_shared<SvxMSDffShapeInfo>(0, pImpRec->nShapeId);
805 SvxMSDffShapeInfos_ById::const_iterator
const it =
834 pImpRec->bAutoWidth =
true;
848 pImpRec->nDxTextLeft = nTextLeft;
849 pImpRec->nDyTextTop = nTextTop;
850 pImpRec->nDxTextRight = nTextRight;
851 pImpRec->nDyTextBottom = nTextBottom;
854 sal_uInt32 eTextAnchor =
864 switch( eTextAnchor )
911 pObj->SetMergedItemSet(aSet);
920 if ( bIsSimpleDrawingTextBox )
922 if ( nTextRotationAngle )
928 aPivot.AdjustX(nMinWH );
929 aPivot.AdjustY(nMinWH );
930 pObj->NbcRotate(aPivot, nTextRotationAngle);
939 double fExtraTextRotation = 0.0;
944 if ( rObjData.
nSpFlags & ShapeFlag::FlipV )
946 fExtraTextRotation += 18000.0;
948 fExtraTextRotation += nTextRotationAngle.
get();
949 if ( !::basegfx::fTools::equalZero( fExtraTextRotation ) )
951 fExtraTextRotation /= 100.0;
953 css::beans::PropertyValue aPropVal;
954 aPropVal.Name =
"TextRotateAngle";
955 aPropVal.Value <<= fExtraTextRotation;
981 if( SfxItemState::DEFAULT == eState )
983 pObj->SetMergedItemSet(aSet);
988 pImpRec->bDrawHell =
true;
990 pImpRec->bDrawHell =
false;
992 pImpRec->bHidden =
true;
997 pImpRec->aTextId.nTxBxS = o3tl::narrowing<sal_uInt16>( nTextId >> 16 );
998 pImpRec->aTextId.nSequence = o3tl::narrowing<sal_uInt16>(nTextId);
1005 pImpRec->nDxWrapDistRight
1014 pImpRec->pWrapPolygon.reset();
1016 sal_uInt16 nNumElemVert(0), nNumElemMemVert(0), nElemSizeVert(0);
1019 if (nNumElemVert && (nElemSizeVert == 8 || nElemSizeVert == 4))
1029 for (sal_uInt16
i = 0;
i < nNumElemVert; ++
i)
1031 sal_Int32 nX(0), nY(0);
1032 if (nElemSizeVert == 8)
1036 sal_Int16 nSmallX(0), nSmallY(0);
1041 (*(pImpRec->pWrapPolygon))[
i].setX( nX );
1042 (*(pImpRec->pWrapPolygon))[
i].setY( nY );
1061 nLineFlags &= ~0x08;
1064 pImpRec->eLineStyle = (nLineFlags & 8)
1072 pImpRec->nFlags = rObjData.
nSpFlags;
1074 if( pImpRec->nShapeId )
1076 auto nShapeId = pImpRec->nShapeId;
1077 auto nShapeOrder = (
static_cast<sal_uLong>(pImpRec->aTextId.nTxBxS) << 16)
1078 + pImpRec->aTextId.nSequence;
1080 pImpRec->pObj = pObj;
1081 rImportData.
insert(std::move(pImpRec));
1087 ( (rObjData.
nSpFlags & ShapeFlag::Group)
1106 std::vector< sal_uInt8 >
aBuffer( nBufferSize );
1110 sal_uInt64 nStreamSize = aMemStream.
TellEnd();
1112 bool bRet = 4 <= nStreamSize;
1113 sal_uInt16 nRawRecId,nRawRecSize;
1133 if (!aNameStr.isEmpty())
1152 sal_uInt16 nColl = 0;
1156 nColl = SVBT16ToUInt16(
pData);
1178 "fields into the control stack");
1180 "input fields into the control stack");
1182 "annotations into the control stack");
1184 "redlines into the control stack");
1197 size_t nCnt =
size();
1198 for (
size_t i=0;
i < nCnt; ++
i)
1201 if (nAttrId == rEntry.
m_pAttr->Which())
1216 "<GetListFirstLineIndent> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
1220 if (eAdj == SvxAdjust::Right)
1222 else if (eAdj == SvxAdjust::Center)
1226 return nReverseListIndented;
1233 "<lcl_GetTrueMargin> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
1237 rFirstLinePos = nBodyIndent + nFirstLineDiff;
1239 const auto nPseudoListBodyIndent = rFormat.
GetAbsLSpace();
1241 tools::Long nExtraListIndent = nPseudoListBodyIndent + nReverseListIndented;
1243 return std::max<tools::Long>(nExtraListIndent, 0);
1250 const bool bFirstLineOfstSet,
1251 const bool bLeftIndentSet )
1257 rLR.
SetTextLeft(nWantedFirstLinePos - nExtraListIndent);
1262 if ( !bFirstLineOfstSet && bLeftIndentSet &&
1267 else if ( bFirstLineOfstSet && !bLeftIndentSet &&
1272 else if (!bFirstLineOfstSet && !bLeftIndentSet )
1307 switch( rEntry.
m_pAttr->Which() )
1313 bool bInsertBookmarkIntoDoc =
true;
1316 if ( pFltBookmark !=
nullptr && pFltBookmark->
IsTOCBookmark() )
1318 const OUString& rName = pFltBookmark->
GetName();
1322 bInsertBookmarkIntoDoc =
false;
1325 if ( bInsertBookmarkIntoDoc )
1341 switch (rEntry.
m_pAttr->Which())
1352 SwPaM aRegion(rTmpPos);
1358 for(; nStart <= nEnd; ++nStart)
1379 const bool bFirstLineIndentSet =
1383 const bool bLeftIndentSet =
1387 bFirstLineIndentSet,
1391 if (aNewLR == aOldLR)
1402 OSL_ENSURE(
false,
"What is a field doing in the control stack,"
1403 "probably should have been in the endstack");
1407 OSL_ENSURE(
false,
"What is an annotation doing in the control stack,"
1408 "probably should have been in the endstack");
1412 OSL_ENSURE(
false,
"What is an input field doing in the control stack,"
1413 "probably should have been in the endstack");
1418 SwPaM aRegion(rTmpPos);
1426 if (
nullptr != pFrame)
1487 pItem = &pNd->
GetAttr(nWhich);
1498 size_t nSize =
size();
1502 if (rEntry.
m_pAttr->Which() == nWhich)
1529 sal_uInt16 nSubType;
1550 switch (rEntry.
m_pAttr->Which())
1582 sal_uInt16 nRefNo =
static_cast<SwTextFootnote*
>(pFootnote)->GetSeqRefNo();
1602 OSL_ENSURE(
false,
"EndStck used with non field, not what we want");
1632 short nRequiredLength = 2 + 2*nDel + 2*nIns + 1*nIns;
1633 if (nRequiredLength > nLen)
1643 std::shared_ptr<SvxTabStopItem> aAttr(std::make_shared<SvxTabStopItem>(0, 0, SvxTabAdjust::Default,
RES_PARATR_TABSTOP));
1646 sal_uInt16 nTabBase;
1650 if (nTabBase <
m_vColl.size())
1651 pSty =
m_vColl[nTabBase].m_pFormat;
1661 bool bFound =
false;
1662 std::unordered_set<size_t> aLoopWatch;
1663 while (pSty && !bFound)
1667 &pTabs) == SfxItemState::SET;
1670 aAttr.reset(pTabs->
Clone());
1674 sal_uInt16 nOldTabBase = nTabBase;
1676 if (nTabBase <
m_vColl.size())
1677 nTabBase =
m_vColl[nTabBase].m_nBase;
1681 nOldTabBase != nTabBase &&
1687 aLoopWatch.insert(
reinterpret_cast<size_t>(pSty));
1688 if (nTabBase <
m_vColl.size())
1689 pSty =
m_vColl[nTabBase].m_pFormat;
1692 if (aLoopWatch.find(
reinterpret_cast<size_t>(pSty)) !=
1702 for (
short i=0;
i < nDel; ++
i)
1704 sal_uInt16
nPos = aAttr->GetPos(SVBT16ToUInt16(pDel +
i*2));
1706 aAttr->Remove(
nPos );
1709 for (
short i=0;
i < nIns; ++
i)
1711 short nPos = SVBT16ToUInt16(pIns +
i*2);
1713 switch( pTyp[
i].aBits1 & 0x7 )
1731 switch( pTyp[
i].aBits1 >> 3 & 0x7 )
1748 sal_uInt16 nPos2 = aAttr->GetPos(
nPos );
1750 aAttr->Remove(nPos2);
1751 aAttr->Insert(aTabStop);
1781 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1783 uno::Reference<document::XDocumentProperties> xDocuProps(
1784 xDPS->getDocumentProperties());
1785 OSL_ENSURE(xDocuProps.is(),
"DocumentProperties is null");
1786 if (xDocuProps.is())
1791 xDocuProps->setPrintDate(uDT);
1824 if( nDefTabSiz < 56 )
1829 const_cast<SvxTabStop&
>(aNewTab[0]).GetAdjustment() = SvxTabAdjust::Default;
1837 sal_Int16 nZoomType;
1839 case 1: nZoomType = sal_Int16(SvxZoomType::WHOLEPAGE);
break;
1840 case 2: nZoomType = sal_Int16(SvxZoomType::PAGEWIDTH);
break;
1841 case 3: nZoomType = sal_Int16(SvxZoomType::OPTIMAL);
break;
1842 default: nZoomType = sal_Int16(SvxZoomType::PERCENT);
break;
1846 {
"VisibleBottom",
uno::Any(sal_Int32(0)) },
1847 {
"ZoomType",
uno::Any(nZoomType) }
1851 xBox->insertByIndex(sal_Int32(0),
uno::Any(aViewProps));
1852 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(
m_pDocShell->
GetModel(), uno::UNO_QUERY);
1853 xViewDataSupplier->setViewData(xBox);
1907 uno::Reference<beans::XPropertySetInfo> xInfo = xDocProps->getPropertySetInfo();
1910 if (xInfo->hasPropertyByName(
"ApplyFormDesignMode"))
1911 xDocProps->setPropertyValue(
"ApplyFormDesignMode", css::uno::Any(
false));
1917 {
"name",
uno::Any(OUString(
"compatibilityMode")) },
1918 {
"uri",
uno::Any(OUString(
"http://schemas.microsoft.com/office/word")) },
1919 {
"val",
uno::Any(OUString(
"11")) }
1923 {
"compatSetting",
uno::Any(aCompatSetting) }
1926 aGrabBag[
"CompatSettings"] <<= aValue;
1936 else if ( xDocProps.is() )
1939 aGrabBag[
"FormPasswordHash"] <<=
m_xWDop->lKeyProtDoc;
1959 i18n::ForbiddenCharacters aForbidden(OUString(+rTypo.
m_rgxchFPunct),
1998 mxTmpPos(pRdr->
m_rDoc.CreateUnoCursor(*pRdr->m_pPaM->GetPoint())),
1999 mxOldStck(
std::move(pRdr->m_xCtrlStck)),
2000 mxOldAnchorStck(
std::move(pRdr->m_xAnchorStck)),
2001 mxOldRedlines(
std::move(pRdr->m_xRedlineStack)),
2002 mxOldPlcxMan(pRdr->m_xPlcxMan),
2003 mpWFlyPara(
std::move(pRdr->m_xWFlyPara)),
2004 mpSFlyPara(
std::move(pRdr->m_xSFlyPara)),
2005 mpPreviousNumPaM(pRdr->m_pPreviousNumPaM),
2006 mpPrevNumRule(pRdr->m_pPrevNumRule),
2007 mxTableDesc(
std::move(pRdr->m_xTableDesc)),
2008 mnInTable(pRdr->m_nInTable),
2009 mnCurrentColl(pRdr->m_nCurrentColl),
2010 mcSymbol(pRdr->m_cSymbol),
2011 mbIgnoreText(pRdr->m_bIgnoreText),
2012 mbSymbol(pRdr->m_bSymbol),
2013 mbHdFtFootnoteEdn(pRdr->m_bHdFtFootnoteEdn),
2014 mbTxbxFlySection(pRdr->m_bTxbxFlySection),
2015 mbAnl(pRdr->m_bAnl),
2016 mbInHyperlink(pRdr->m_bInHyperlink),
2017 mbPgSecBreak(pRdr->m_bPgSecBreak),
2018 mbWasParaEnd(pRdr->m_bWasParaEnd),
2019 mbHasBorder(pRdr->m_bHasBorder),
2020 mbFirstPara(pRdr->m_bFirstPara)
2089 if (xLastAnchorCursor)
2108 if (nStartCp < 0 || nLen < 0)
2146 sAuthor = OUString(pDescri->
xstUsrInitl + 1, nLen, RTL_TEXTENCODING_MS_1252);
2153 const sal_uInt16 nLen = std::min<sal_uInt16>(SVBT16ToUInt16(pDescri->
xstUsrInitl[0]),
2155 OUStringBuffer
aBuf;
2156 aBuf.setLength(nLen);
2157 for(sal_uInt16 nIdx = 1; nIdx <= nLen; ++nIdx)
2159 sInitials =
aBuf.makeStringAndClear();
2165 sAuthor = sInitials;
2168 sal_uInt32 nDateTime = 0;
2174 nDateTime = SVBT32ToUInt32(*
reinterpret_cast<SVBT32*
>(pExtended+(
nIndex*18)));
2186 sText, sInitials, OUString(), aDate );
2203 OSL_ENSURE(pSttIdx,
"impossible");
2219 aAnch.
SetType( RndStdIds::FLY_AT_PARA );
2232 OSL_ENSURE( pFrameObj,
2233 "<SwWW8ImplReader::Read_HdFtTextAsHackedFrame(..)> - missing SdrObject instance" );
2263 return (nHeaderCP < m_xWwFib->m_ccpHdr && nHeaderCP >= 0);
2274 for(
sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
2276 if (nI & nWhichItems)
2280 bOk = (
m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nStart >= 0 && nLen >= 2 );
2283 m_xHdFt->GetTextPosExact(
static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
2310 for(
sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
2316 bOk = (
m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nLen >= 2 );
2319 m_xHdFt->GetTextPosExact(
static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
2331 bool bDisabledFirst = bUseFirst && !rSection.
HasTitlePage();
2372 bool bHackRequired =
false;
2374 bHackRequired =
true;
2376 bHackRequired =
true;
2406 OSL_ENSURE(rSection.
mpPage,
"makes no sense to call with a main page");
2426 if (pText !=
nullptr)
2451 pRule && !
m_xWDop->fDontUseHTMLAutoSpacing &&
2520 if(pULSpaceItem !=
nullptr)
2525 aUL.
SetUpper(
static_cast< sal_uInt16
>(nSpace) );
2527 aUL.
SetLower(
static_cast< sal_uInt16
>(nSpace) );
2597 bool bResult =
true;
2600 if (
nullptr != aRes.
pSprm)
2612 const int nMagicNumber = 469;
2617 if ((nTableWidth + nMagicNumber) < nTextAreaWidth)
2638 sal_uInt16 nUChar = 0;
2672 bool bTableRowEnd = (
m_xPlcxMan->HasParaSprm(
m_bVer67 ? 25 : 0x2417).pSprm !=
nullptr);
2703 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(24).pSprm);
2706 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(0x2416).pSprm);
2708 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(0x244B).pSprm);
2720 WW8_CP nMyStartCp=nStartCp;
2724 nCellLevel = *aLevel.
pSprm;
2751 bStopTab = bStartTab =
true;
2754 if(
m_bAnl && !bTableRowEnd )
2763 || bStopTab || bStartTab )
2823 return bTableRowEnd;
2871 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2881 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2897 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2905 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2941 char const *pIn, std::size_t nInLen,
sal_Unicode *pOut, std::size_t nOutLen)
2943 const sal_uInt32 nFlags =
2944 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
2945 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
2946 RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2947 RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2949 const sal_uInt32 nFlags2 =
2950 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE |
2951 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE |
2952 RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2953 RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2955 std::size_t nDestChars=0;
2956 std::size_t nConverted=0;
2960 sal_uInt32 nInfo = 0;
2961 sal_Size nThisConverted=0;
2963 nDestChars += rtl_convertTextToUnicode(hConverter,
nullptr,
2964 pIn+nConverted, nInLen-nConverted,
2965 pOut+nDestChars, nOutLen-nDestChars,
2966 nFlags, &nInfo, &nThisConverted);
2968 OSL_ENSURE(nInfo == 0,
"A character conversion failed!");
2970 nConverted += nThisConverted;
2973 nInfo & RTL_TEXTTOUNICODE_INFO_UNDEFINED ||
2974 nInfo & RTL_TEXTTOUNICODE_INFO_MBUNDEFINED
2977 sal_Size nOtherConverted;
2978 rtl_TextToUnicodeConverter hCP1252Converter =
2979 rtl_createTextToUnicodeConverter(RTL_TEXTENCODING_MS_1252);
2980 nDestChars += rtl_convertTextToUnicode(hCP1252Converter,
nullptr,
2982 pOut+nDestChars, nOutLen-nDestChars,
2983 nFlags2, &nInfo, &nOtherConverted);
2984 rtl_destroyTextToUnicodeConverter(hCP1252Converter);
2987 }
while (nConverted < nInLen);
2994 bool bResult =
false;
2996 switch (
static_cast<sal_uInt16
>(
nLang))
3025 if (nChar >= 0x0030 && nChar <= 0x0039)
3026 return nChar + 0x0630;
3033 OUString makeOUString(rtl_uString *pStr, sal_Int32 nAllocLen)
3036 if (nAllocLen < pStr->length + 256)
3037 return OUString(pStr, SAL_NO_ACQUIRE);
3039 OUString sRet(pStr->buffer, pStr->length);
3040 rtl_uString_release(pStr);
3050 sal_Int32 nRequestedStrLen = nEnd - rPos;
3052 OSL_ENSURE(nRequestedStrLen,
"String is 0");
3053 if (nRequestedStrLen <= 0)
3060 rPos+=nRequestedStrLen;
3066 OSL_ENSURE(bValidPos,
"Document claimed to have more text than available");
3070 rPos+=nRequestedStrLen;
3075 OSL_ENSURE(nAvailableStrLen,
"Document claimed to have more text than available");
3076 if (!nAvailableStrLen)
3079 rPos+=nRequestedStrLen;
3083 sal_Int32 nValidStrLen = std::min<std::size_t>(nRequestedStrLen, nAvailableStrLen);
3091 RTL_TEXTENCODING_MS_1252;
3092 if (
m_bVer67 && eSrcCharSet == RTL_TEXTENCODING_MS_932)
3131 SAL_WARN(
"sw.ww8",
"discarding word95 RTL_TEXTENCODING_MS_932 encoding");
3136 RTL_TEXTENCODING_MS_1252;
3139 auto l = [](rtl_uString*
p){rtl_uString_release(
p);};
3140 std::unique_ptr<rtl_uString,
decltype(l)> xStr(rtl_uString_alloc(nStrLen), l);
3144 std::unique_ptr<char[]> p8Bits;
3146 rtl_TextToUnicodeConverter hConverter =
nullptr;
3148 hConverter = rtl_createTextToUnicodeConverter(eSrcCharSet);
3151 p8Bits.reset(
new char[nStrLen] );
3159 if (pItem !=
nullptr)
3163 for (nL2 = 0; nL2 < nStrLen; ++nL2)
3179 if ((32 > nUCode) || (0xa0 == nUCode))
3191 if (nUCode >= 0x3000)
3194 aTest[0] =
static_cast< char >((nUCode & 0xFF00) >> 8);
3195 aTest[1] =
static_cast< char >(nUCode & 0x00FF);
3196 OUString aTemp(aTest, 2, eSrcCJKCharSet);
3197 OSL_ENSURE(aTemp.getLength() == 1,
"so much for that theory");
3198 *pWork++ = aTemp[0];
3202 char cTest =
static_cast< char >(nUCode & 0x00FF);
3208 p8Bits[nL2] = nBCode;
3219 for (sal_Int32 nI = 0; nI < nEndUsed; ++nI, ++pBuffer)
3223 xStr->buffer[nEndUsed] = 0;
3224 xStr->length = nEndUsed;
3233 rtl_destroyTextToUnicodeConverter(hConverter);
3234 return nL2 >= nStrLen;
3237#define MSASCII SAL_MAX_INT16
3242 sal_Int16 lcl_getScriptType(
3243 const uno::Reference<i18n::XBreakIterator>& rBI,
3244 const OUString &rString, sal_Int32
nPos)
3246 sal_Int16 nScript = rBI->getScriptType(rString,
nPos);
3247 if (nScript == i18n::ScriptType::WEAK && rString[
nPos] >= 0x0020 && rString[
nPos] <= 0x007F)
3254 sal_Int32 lcl_endOfScript(
3255 const uno::Reference<i18n::XBreakIterator>& rBI,
3256 const OUString &rString, sal_Int32
nPos, sal_Int16 nScript)
3258 while (
nPos < rString.getLength())
3260 sal_Int16 nNewScript = lcl_getScriptType(rBI, rString,
nPos);
3261 if (nScript != nNewScript)
3268 sal_Int32 lcl_getWriterScriptType(
3269 const uno::Reference<i18n::XBreakIterator>& rBI,
3270 const OUString &rString, sal_Int32
nPos)
3272 sal_Int16 nScript = i18n::ScriptType::WEAK;
3274 if (rString.isEmpty())
3279 nScript = rBI->getScriptType(rString,
nPos);
3280 if (nScript != i18n::ScriptType::WEAK)
3328 if (rAddString.isEmpty())
3340 sal_Int16 nScript = lcl_getScriptType(xBI, rAddString, 0);
3341 sal_Int32 nLen = rAddString.getLength();
3343 OUString sParagraphText;
3347 sParagraphText = pNd->
GetText();
3348 sal_Int32 nParaOffset = sParagraphText.getLength();
3349 sParagraphText = sParagraphText + rAddString;
3354 sal_Int32 nEnd = lcl_endOfScript(xBI, rAddString,
nPos, nScript);
3358 OUString sChunk(rAddString.copy(
nPos, nEnd-
nPos));
3360 const SvxFontItem *pOverriddenItems[] = {
nullptr,
nullptr,
nullptr};
3361 bool aForced[] = {
false,
false,
false};
3363 int nLclIdctHint = 0xFF;
3364 if (nScript == i18n::ScriptType::WEAK)
3367 nLclIdctHint = pIdctHint->
GetValue();
3372 sal_uInt16 nForceFromFontId = 0;
3373 if (nLclIdctHint != 0xFF)
3375 switch (nLclIdctHint)
3391 if (nForceFromFontId != 0)
3396 sal_Int32 nWriterScript = lcl_getWriterScriptType(xBI, sParagraphText,
3397 nPos + nParaOffset);
3399 bool bWriterWillUseSameFontAsWordAutomatically =
false;
3401 if (nWriterScript != i18n::ScriptType::WEAK)
3405 (nWriterScript == i18n::ScriptType::COMPLEX && nForceFromFontId ==
RES_CHRATR_CTL_FONT) ||
3406 (nWriterScript == i18n::ScriptType::LATIN && nForceFromFontId ==
RES_CHRATR_FONT)
3409 bWriterWillUseSameFontAsWordAutomatically =
true;
3414 sal_uInt16 nDestId = aIds[nWriterScript-1];
3416 bWriterWillUseSameFontAsWordAutomatically = sameFontIgnoringIrrelevantFields(*pSourceFont, *pDestFont);
3421 if (!bWriterWillUseSameFontAsWordAutomatically)
3428 aForced[
i] = aIds[
i] != nForceFromFontId && *pSourceFont != *pDestFont;
3431 pOverriddenItems[
i] =
3435 aForceFont.SetWhich(aIds[
i]);
3449 if (pOverriddenItems[
i])
3456 nScript = lcl_getScriptType(xBI, rAddString,
nPos);
3464 OUStringBuffer buf(aString.size());
3465 for (
size_t i = 0;
i < aString.size(); ++
i)
3474 SAL_INFO(
"sw.ww8",
"filtering control character");
3477 return buf.makeStringAndClear();
3486 if (addString.isEmpty())
3492 OSL_ENSURE(pNd,
"What the hell, where's my text node");
3500 if (addString.getLength() <= nCharsLeft)
3526 tools::Long nEnd = ( nNextAttr < nTextEnd ) ? nNextAttr : nTextEnd;
3530 WW8_CP nRequested = nEnd - rPos;
3536 SAL_WARN(
"sw.ww8",
"document claims to have more characters, " << nRequested <<
" than remaining, " << nMaxPossible);
3537 nRequested = nMaxPossible;
3543 for (
WW8_CP nCh = 0; nCh < nRequested; ++nCh)
3562 bool bStartLine =
ReadChar(rPos, nCpOfs);
3573 bool bParaEndAdded =
false;
3580 if (pTemp && pTemp->
GetText().isEmpty()
3597 bParaEndAdded =
true;
3608 return bParaEndAdded;
3613 bool bNewParaEnd =
false;
3621 sal_uInt16 nWCharVal(0);
3627 m_pStrm -> ReadUChar( nBCode );
3632 bool bParaMark =
false;
3634 if ( 0xc != nWCharVal )
3662 if (pCntNd!=
nullptr && pCntNd->
Len()>0)
3689 cInsert =
u'\x00a4';
3693 cInsert =
u'\x00b5';
3702 cInsert =
u'\x00a7';
3740 sal_uInt16 nWordCode(0);
3748 nWordCode = nByteCode;
3750 if( nWordCode == 0x1 )
3765 pResult =
ImportGraf(
nullptr, pAsCharFlyFormat);
3775 "WW8: Please report this document, it may have a "
3792 bNewParaEnd = bParaMark =
true;
3805 pTest->
Where() == nPosCp+1+nCpOfs)
3837 SAL_INFO(
"sw.ww8.level2",
"<unknownValue val=\"" << nWCharVal <<
"\">" );
3841 if(
'\x0' != cInsert )
3843 OUString sInsert(cInsert);
3852 bool* pStartAttr,
bool bCallProcessSpecial)
3870 if (nOldColl >=
m_vColl.size())
3873 bool bTabRowEnd =
false;
3919 rbStartLine =
false;
3937 else if( aRes.
nSprmId < 0x800 )
3947 WW8_CP nMaxLegalSkip = nTextEnd - rTextPos;
3949 rTextPos += std::min<WW8_CP>(nSkipChars, nMaxLegalSkip);
3950 nSkipPos = rTextPos-1;
3960 SAL_WARN_IF(!bValidPos,
"sw.ww8",
"Document claimed to have text at an invalid position, skip attributes for region");
3968 bool bDoPlcxManPlusPLus =
true;
3972 if( bDoPlcxManPlusPLus )
3974 nNext = bValidPos ?
m_xPlcxMan->Where() : nTextEnd;
3982 if( (0 <= nNext) && (nSkipPos >= nNext) )
3984 if (nDepthGuard >= 1024)
3986 SAL_WARN(
"sw.ww8",
"ReadTextAttr hit recursion limit");
3990 nNext =
ReadTextAttr(rTextPos, nTextEnd, rbStartLine, nDepthGuard + 1);
3991 bDoPlcxManPlusPLus =
false;
4001 while( nSkipPos >= nNext );
4016 if( rTextPos >= rNext )
4021 if (rTextPos == rNext && rTextPos >= nTextEnd)
4024 while( rTextPos >= rNext );
4027 else if ( rbStartLine )
4037 rbStartLine =
false;
4050 std::stack<sal_uInt16> aStack;
4053 while (!aStack.empty())
4055 sal_uInt16 nSprmId = aStack.top();
4056 if ((0 < nSprmId) && ((
eFTN > nSprmId) || (0x0800 <= nSprmId)))
4068 bool bStartLine =
true;
4070 short nDistance = 0;
4094 if (nTextLen > nMaxPossible)
4096 SAL_WARN_IF(nTextLen > nMaxPossible,
"sw.ww8",
"TextLen too long");
4097 nTextLen = nMaxPossible;
4099 WW8_CP nTextEnd = nStartCp+nTextLen;
4100 while (l < nTextEnd)
4102 ReadAttrs( l, nNext, nTextEnd, bStartLine );
4111 bStartLine =
ReadChars(l, nNext, nTextEnd, nCpOfs);
4139 SAL_WARN_IF(!pEndNd,
"sw.ww8",
"didn't find textnode for dropcap");
4142 const sal_Int32 nDropCapLen = pPreviousNode->GetText().getLength();
4146 SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1);
4157 aDrop.
GetChars() = writer_cast<sal_uInt8>(nDropCapLen);
4163 else if(pNewSwCharFormat)
4179 aDCS =
m_xPlcxMan->GetPapPLCF()->HasSprm(46);
4181 aDCS =
m_xPlcxMan->GetPapPLCF()->HasSprm(0x442C);
4184 nDropLines = (*aDCS.
pSprm) >> 3;
4190 nDistance = SVBT16ToUInt16(
aDistance.pSprm);
4199 if (pSwFormatCharFormat)
4220 m_nProgress = o3tl::narrowing<sal_uInt16>(l * 100 / nTextLen);
4222 m_nProgress = o3tl::narrowing<sal_uInt16>(l / nTextLen * 100);
4274 : m_pDocShell(rD.GetDocShell())
4277 , m_pTableStream(nullptr)
4278 , m_pDataStream(nullptr)
4281 , m_aSectionManager(*this)
4282 , m_aExtraneousParas(rD)
4283 , m_aInsertedTables(rD)
4284 , m_aSectionNameGenerator(rD,
"WW")
4285 , m_aGrfNameGenerator(bNewDoc, OUString(
'G'))
4286 , m_aParaStyleMapper(rD)
4287 , m_aCharStyleMapper(rD)
4288 , m_pFlyFormatOfJustInsertedGraphic(nullptr)
4289 , m_pPreviousNumPaM(nullptr)
4290 , m_pPrevNumRule(nullptr)
4291 , m_pCurrentColl(nullptr)
4292 , m_pDfltTextFormatColl(nullptr)
4293 , m_pStandardFormatColl(nullptr)
4294 , m_pDrawModel(nullptr)
4295 , m_pDrawPg(nullptr)
4296 , m_pNumFieldType(nullptr)
4297 , m_sBaseURL(
std::move(aBaseURL))
4301 , m_bRegardHindiDigits( false )
4302 , m_bDrawCpOValid( false )
4308 , m_eTextCharSet(RTL_TEXTENCODING_ASCII_US)
4309 , m_eStructCharSet(RTL_TEXTENCODING_ASCII_US)
4310 , m_eHardCharSet(RTL_TEXTENCODING_DONTKNOW)
4314 , m_nLFOPosition(USHRT_MAX)
4321 , m_nWantedVersion(nVersionPara)
4322 , m_nSwNumLevel(0xff)
4323 , m_nWwNumType(0xff)
4324 , m_pChosenWW8OutlineStyle(nullptr)
4326 , m_bNewDoc(bNewDoc)
4327 , m_bSkipImages(bSkipImages)
4328 , m_bReadNoTable(false)
4329 , m_bPgSecBreak(false)
4332 , m_bTxbxFlySection(false)
4333 , m_bHasBorder(false)
4335 , m_bIgnoreText(false)
4337 , m_bWasTabRowEnd(false)
4338 , m_bWasTabCellEnd(false)
4340 , m_bHdFtFootnoteEdn(false)
4341 , m_bFootnoteEdn(false)
4342 , m_bIsHeader(false)
4343 , m_bIsFooter(false)
4344 , m_bIsUnicode(false)
4345 , m_bCpxStyle(false)
4346 , m_bStyNormal(false)
4347 , m_bWWBugNormal(false)
4348 , m_bNoAttrImport(false)
4349 , m_bInHyperlink(false)
4350 , m_bWasParaEnd(false)
4355 , m_bEmbeddObj(false)
4356 , m_bCurrentAND_fNumberAcross(false)
4357 , m_bNoLnNumYet(true)
4358 , m_bFirstPara(true)
4359 , m_bFirstParaOfPage(false)
4360 , m_bParaAutoBefore(false)
4361 , m_bParaAutoAfter(false)
4365 , m_bReadTable(false)
4366 , m_bLoadingTOXCache(false)
4367 , m_nEmbeddedTOXLevel(0)
4368 , m_bLoadingTOXHyperlink(false)
4369 , m_bCareFirstParaEndInToc(false)
4370 , m_bCareLastParaEndInToc(false)
4371 , m_bNotifyMacroEventRead(false)
4372 , m_bFuzzing(
utl::ConfigManager::IsFuzzing())
4393 OSL_ENSURE(
false,
"WW stack already deleted" );
4417 if (
aData.begin()->get()->nFlags & ShapeFlag::Background)
4436 SetPage(rPage, rFormat, rSection, bIgnoreCols);
4458 OSL_ENSURE(rSection.
mpPage,
"Makes no sense to call me with no pages to set");
4480 OSL_ENSURE(pApply,
"impossible");
4495 mySegIter const &rStart,
bool bIgnoreCols)
4508 OSL_ENSURE(rIter->mpPage,
"no page!");
4514 if (rIter != rStart)
4515 pPrevious = &(*(rIter-1));
4516 SetHdFt(*rIter, std::distance(rStart, rIter), pPrevious);
4524 rIter->mpPage->SetFollow(rIter->mpPage);
4526 if (rIter->PageRestartNo())
4537 for (
mySegIter aIter = aStart; aIter != aEnd; ++aIter)
4542 if ( aIter->maSep.bkc == 1 && aIter->maSep.ccolM1 > 0 )
4550 mySegIter aPrev = (aIter == aStart) ? aIter : aIter-1;
4554 bool bThisAndPreviousAreCompatible = ((aIter->GetPageWidth() == aPrev->GetPageWidth()) &&
4555 (aIter->GetPageHeight() == aPrev->GetPageHeight()) && (aIter->IsLandScape() == aPrev->IsLandScape()));
4557 bool bInsertSection = (aIter != aStart) && aIter->IsContinuous() && bThisAndPreviousAreCompatible;
4558 bool bInsertPageDesc = !bInsertSection;
4560 if( aIter->maSep.dxaLeft != aPrev->maSep.dxaLeft || aIter->maSep.dxaRight != aPrev->maSep.dxaRight )
4561 bInsertPageDesc =
true;
4564 if (bInsertPageDesc)
4575 bool bIgnoreCols = bInsertSection;
4576 bool bThisAndNextAreCompatible = (aNext == aEnd) ||
4577 ((aIter->GetPageWidth() == aNext->GetPageWidth()) &&
4578 (aIter->GetPageHeight() == aNext->GetPageHeight()) &&
4579 (aIter->IsLandScape() == aNext->IsLandScape()));
4581 if ((aNext != aEnd && aNext->IsContinuous() && bThisAndNextAreCompatible) || bProtected)
4584 if ((aIter->NoCols() > 1) || bProtected)
4585 bInsertSection =
true;
4597 if ( aIter->maSep.bkc == 3 || aIter->maSep.bkc == 4 )
4608 *aIter = aTmpSection;
4612 if ( aIter->maSep.bkc == 4 )
4634 aAnchor = aNext->maStart;
4655 bool bHasOwnHdFt =
false;
4662 if (!bInsertPageDesc)
4667 aIter->maSep.grpfIhdt, std::distance(aStart, aIter)
4675 bool bFailed =
true;
4681 for(; nStart <= nEnd; ++nStart)
4697 aIter->mpPage = pOrig;
4714 if (aNext == aEnd || !aNext->IsContinuous())
4722 SwPaM aTest(*pTextNd);
4732 for (
auto aI =
m_aTextNodes.rbegin(); aI != aEnd; ++aI)
4738 SwPaM aTest(*pTextNode);
4755 SAL_WARN(
"sw.ww8",
"It is unexpected to drop a para scheduled for removal");
4760 : m_pTextNode(pTextNode)
4774 if (rHint.
GetId() != SfxHintId::SwLegacyModify)
4802 if (!m_xWwFib->m_lcbCmds)
4805 bool bValidPos =
checkSeek(*m_pTableStream, m_xWwFib->m_fcCmds);
4809 uno::Reference < embed::XStorage > xRoot(m_pDocShell->GetStorage());
4816 uno::Reference < io::XStream >
xStream =
4817 xRoot->openStreamElement(
SL::aMSMacroCmds, embed::ElementModes::READWRITE );
4820 sal_uInt32 lcbCmds = std::min<sal_uInt32>(m_xWwFib->m_lcbCmds, m_pTableStream->remainingSize());
4821 std::unique_ptr<sal_uInt8[]> xBuffer(
new sal_uInt8[lcbCmds]);
4822 m_xWwFib->m_lcbCmds = m_pTableStream->ReadBytes(xBuffer.get(), lcbCmds);
4823 xOutStream->WriteBytes(xBuffer.get(), m_xWwFib->m_lcbCmds);
4832 std::vector<OUString> aDocVarStrings;
4833 std::vector<ww::bytes> aDocVarStringIds;
4834 std::vector<OUString> aDocValueStrings;
4835 WW8ReadSTTBF(!m_bVer67, *m_pTableStream, m_xWwFib->m_fcStwUser,
4836 m_xWwFib->m_lcbStwUser, m_bVer67 ? 2 : 0, m_eStructCharSet,
4837 aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
4838 if (m_bVer67)
return;
4840 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4841 m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
4842 uno::Reference<document::XDocumentProperties> xDocProps(
4843 xDPS->getDocumentProperties());
4844 OSL_ENSURE(xDocProps.is(),
"DocumentProperties is null");
4845 uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
4846 xDocProps->getUserDefinedProperties();
4847 OSL_ENSURE(xUserDefinedProps.is(),
"UserDefinedProperties is null");
4849 for(
size_t i=0;
i<aDocVarStrings.size();
i++)
4851 const OUString &rName = aDocVarStrings[
i];
4855 xUserDefinedProps->addProperty( rName,
4856 beans::PropertyAttribute::REMOVABLE,
4858 }
catch (
const uno::Exception &) {
4872 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4873 m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
4874 uno::Reference<document::XDocumentProperties> xDocProps(
4875 xDPS->getDocumentProperties());
4876 OSL_ENSURE(xDocProps.is(),
"DocumentProperties is null");
4878 if (!xDocProps.is())
4881 if ( m_xWwFib->m_fDot )
4883 SfxMedium* pMedium = m_pDocShell->GetMedium();
4889 if ( !sTemplateURL.isEmpty() )
4890 xDocProps->setTemplateURL( sTemplateURL );
4893 else if (m_xWwFib->m_lcbSttbfAssoc)
4895 auto nCur = m_pTableStream->Tell();
4898 if (!
checkSeek(*m_pTableStream, m_xWwFib->m_fcSttbfAssoc) || !aSttb.Read(*m_pTableStream))
4899 SAL_WARN(
"sw.ww8",
"** Read of SttbAssoc data failed!!!! ");
4900 m_pTableStream->Seek( nCur );
4901 OUString sPath = aSttb.getStringAtIndex( 0x1 );
4904 if ( !sPath.isEmpty() )
4905 osl::FileBase::getFileURLFromSystemPath( sPath,
aURL );
4907 xDocProps->setTemplateURL(
aURL );
4909 xDocProps->setTemplateURL( sPath );
4915static void lcl_createTemplateToProjectEntry(
const uno::Reference< container::XNameContainer >& xPrjNameCache,
const OUString& sTemplatePathOrURL,
const OUString& sVBAProjName )
4917 if ( !xPrjNameCache.is() )
4921 aObj.
SetURL( sTemplatePathOrURL );
4922 bool bIsURL = aObj.
GetProtocol() != INetProtocol::NotValid;
4925 aURL = sTemplatePathOrURL;
4928 osl::FileBase::getFileURLFromSystemPath( sTemplatePathOrURL,
aURL );
4933 OUString templateNameWithExt = aObj.
GetLastName();
4934 sal_Int32
nIndex = templateNameWithExt.lastIndexOf(
'.' );
4937 OUString templateName = templateNameWithExt.copy( 0,
nIndex );
4938 xPrjNameCache->insertByName( templateName,
uno::Any( sVBAProjName ) );
4941 catch(
const uno::Exception& )
4948class WW8Customizations
4959WW8Customizations::WW8Customizations(
SvStream* pTableStream,
WW8Fib const & rFib ) : mpTableStream(pTableStream), mWw8Fib( rFib )
4963void WW8Customizations::Import(
SwDocShell* pShell )
4965 if ( mWw8Fib.m_lcbCmds == 0 || !
IsEightPlus(mWw8Fib.GetFIBVersion()) )
4970 sal_uInt64 nCur = mpTableStream->Tell();
4971 if (!
checkSeek(*mpTableStream, mWw8Fib.m_fcCmds))
4973 SAL_WARN(
"sw.ww8",
"** Seek to Customization data failed!!!! ");
4976 bool bReadResult = aTCG.
Read( *mpTableStream );
4977 mpTableStream->Seek( nCur );
4980 SAL_WARN(
"sw.ww8",
"** Read of Customization data failed!!!! ");
4987 SAL_WARN(
"sw.ww8",
"** Read of Customization data failed!!!! epically");
4998 uno::Sequence< OUString > sGlobalTemplates;
5001 uno::Reference<ucb::XSimpleFileAccess3> xSFA(ucb::SimpleFileAccess::create(::comphelper::getProcessComponentContext()));
5003 if( xSFA->isFolder( aAddinPath ) )
5004 sGlobalTemplates = xSFA->getFolderContents( aAddinPath,
false );
5006 for (
const auto& rGlobalTemplate : std::as_const(sGlobalTemplates) )
5009 aObj.
SetURL( rGlobalTemplate );
5010 bool bIsURL = aObj.
GetProtocol() != INetProtocol::NotValid;
5013 aURL = rGlobalTemplate;
5015 osl::FileBase::getFileURLFromSystemPath( rGlobalTemplate,
aURL );
5016 if ( !
aURL.endsWithIgnoreAsciiCase(
".dot" ) || ( !sCreatedFrom.empty() && sCreatedFrom ==
aURL ) )
5021 BasicProjImportHelper aBasicImporter( *
m_pDocShell );
5027 refMainStream->SetEndian(SvStreamEndian::LITTLE);
5028 WW8Fib aWwFib( *refMainStream, 8 );
5032 if (xTableStream.
is() &&
ERRCODE_NONE == xTableStream->GetError())
5034 xTableStream->SetEndian(SvStreamEndian::LITTLE);
5035 WW8Customizations aGblCustomisations( xTableStream.
get(), aWwFib );
5050 uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(
xModel, uno::UNO_QUERY_THROW);
5054 uno::Reference<task::XInteractionHandler> xHandler;
5055 xDocumentMetadataAccess->loadMetadataFromStorage(xStorage, xBaseURI, xHandler);
5057 catch (
const uno::Exception&)
5064 auto pFibData = std::make_shared<::ww8::WW8FibData>();
5066 if (
m_xWwFib->m_fReadOnlyRecommended)
5067 pFibData->setReadOnlyRecommended(
true);
5069 pFibData->setReadOnlyRecommended(
false);
5072 pFibData->setWriteReservation(
true);
5074 pFibData->setWriteReservation(
false);