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;
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;
1234 "<lcl_GetTrueMargin> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION" );
1238 rFirstLinePos = nBodyIndent + nFirstLineDiff;
1240 const auto nPseudoListBodyIndent = rFormat.
GetAbsLSpace();
1242 tools::Long nExtraListIndent = nPseudoListBodyIndent + nReverseListIndented;
1244 return std::max<tools::Long>(nExtraListIndent, 0);
1252 const bool bFirstLineOfstSet,
1253 const bool bLeftIndentSet )
1259 rLeftMargin.
SetTextLeft(nWantedFirstLinePos - nExtraListIndent);
1264 if ( !bFirstLineOfstSet && bLeftIndentSet &&
1269 else if ( bFirstLineOfstSet && !bLeftIndentSet &&
1274 else if (!bFirstLineOfstSet && !bLeftIndentSet )
1309 switch( rEntry.
m_pAttr->Which() )
1315 bool bInsertBookmarkIntoDoc =
true;
1318 if ( pFltBookmark !=
nullptr && pFltBookmark->
IsTOCBookmark() )
1320 const OUString& rName = pFltBookmark->
GetName();
1324 bInsertBookmarkIntoDoc =
false;
1327 if ( bInsertBookmarkIntoDoc )
1343 switch (rEntry.
m_pAttr->Which())
1358 SwPaM aRegion(rTmpPos);
1376 for(; nStart <= nEnd; ++nStart)
1407 const bool bFirstLineIndentSet =
1411 const bool bLeftIndentSet =
1415 bFirstLineIndentSet,
1419 if (firstLineNew != firstLineOld)
1423 if (leftMarginNew != leftMarginOld)
1433 OSL_ENSURE(
false,
"What is a field doing in the control stack,"
1434 "probably should have been in the endstack");
1438 OSL_ENSURE(
false,
"What is an annotation doing in the control stack,"
1439 "probably should have been in the endstack");
1443 OSL_ENSURE(
false,
"What is an input field doing in the control stack,"
1444 "probably should have been in the endstack");
1449 SwPaM aRegion(rTmpPos);
1457 if (
nullptr != pFrame)
1502 eState = pSet->GetItemState(nWhich,
false);
1533 pItem = &pNd->
GetAttr(nWhich);
1544 size_t nSize =
size();
1548 if (rEntry.
m_pAttr->Which() == nWhich)
1575 sal_uInt16 nSubType;
1596 switch (rEntry.
m_pAttr->Which())
1628 sal_uInt16 nRefNo =
static_cast<SwTextFootnote*
>(pFootnote)->GetSeqRefNo();
1648 OSL_ENSURE(
false,
"EndStck used with non field, not what we want");
1678 short nRequiredLength = 2 + 2*nDel + 2*nIns + 1*nIns;
1679 if (nRequiredLength > nLen)
1689 std::shared_ptr<SvxTabStopItem> aAttr(std::make_shared<SvxTabStopItem>(0, 0, SvxTabAdjust::Default,
RES_PARATR_TABSTOP));
1692 sal_uInt16 nTabBase;
1696 if (nTabBase <
m_vColl.size())
1697 pSty =
m_vColl[nTabBase].m_pFormat;
1707 bool bFound =
false;
1708 std::unordered_set<size_t> aLoopWatch;
1709 while (pSty && !bFound)
1713 &pTabs) == SfxItemState::SET;
1716 aAttr.reset(pTabs->
Clone());
1720 sal_uInt16 nOldTabBase = nTabBase;
1722 if (nTabBase <
m_vColl.size())
1723 nTabBase =
m_vColl[nTabBase].m_nBase;
1727 nOldTabBase != nTabBase &&
1733 aLoopWatch.insert(
reinterpret_cast<size_t>(pSty));
1734 if (nTabBase <
m_vColl.size())
1735 pSty =
m_vColl[nTabBase].m_pFormat;
1738 if (aLoopWatch.find(
reinterpret_cast<size_t>(pSty)) !=
1748 for (
short i=0;
i < nDel; ++
i)
1750 sal_uInt16
nPos = aAttr->GetPos(SVBT16ToUInt16(pDel +
i*2));
1752 aAttr->Remove(
nPos );
1755 for (
short i=0;
i < nIns; ++
i)
1757 short nPos = SVBT16ToUInt16(pIns +
i*2);
1759 switch( pTyp[
i].aBits1 & 0x7 )
1777 switch( pTyp[
i].aBits1 >> 3 & 0x7 )
1794 sal_uInt16 nPos2 = aAttr->GetPos(
nPos );
1796 aAttr->Remove(nPos2);
1797 aAttr->Insert(aTabStop);
1827 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1829 uno::Reference<document::XDocumentProperties> xDocuProps(
1830 xDPS->getDocumentProperties());
1831 OSL_ENSURE(xDocuProps.is(),
"DocumentProperties is null");
1832 if (xDocuProps.is())
1837 xDocuProps->setPrintDate(uDT);
1870 if( nDefTabSiz < 56 )
1875 const_cast<SvxTabStop&
>(aNewTab[0]).GetAdjustment() = SvxTabAdjust::Default;
1883 sal_Int16 nZoomType;
1885 case 1: nZoomType = sal_Int16(SvxZoomType::WHOLEPAGE);
break;
1886 case 2: nZoomType = sal_Int16(SvxZoomType::PAGEWIDTH);
break;
1887 case 3: nZoomType = sal_Int16(SvxZoomType::OPTIMAL);
break;
1888 default: nZoomType = sal_Int16(SvxZoomType::PERCENT);
break;
1892 {
"VisibleBottom",
uno::Any(sal_Int32(0)) },
1893 {
"ZoomType",
uno::Any(nZoomType) }
1897 xBox->insertByIndex(sal_Int32(0),
uno::Any(aViewProps));
1898 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(
m_pDocShell->
GetModel(), uno::UNO_QUERY);
1899 xViewDataSupplier->setViewData(xBox);
1942 if (
m_xWDop->fDontBreakWrappedTables)
1958 uno::Reference<beans::XPropertySetInfo> xInfo = xDocProps->getPropertySetInfo();
1961 if (xInfo->hasPropertyByName(
"ApplyFormDesignMode"))
1962 xDocProps->setPropertyValue(
"ApplyFormDesignMode", css::uno::Any(
false));
1968 {
"name",
uno::Any(OUString(
"compatibilityMode")) },
1969 {
"uri",
uno::Any(OUString(
"http://schemas.microsoft.com/office/word")) },
1970 {
"val",
uno::Any(OUString(
"11")) }
1974 {
"compatSetting",
uno::Any(aCompatSetting) }
1977 aGrabBag[
"CompatSettings"] <<= aValue;
1987 else if ( xDocProps.is() )
1990 aGrabBag[
"FormPasswordHash"] <<=
m_xWDop->lKeyProtDoc;
2010 i18n::ForbiddenCharacters aForbidden(OUString(+rTypo.
m_rgxchFPunct),
2049 mxTmpPos(pRdr->
m_rDoc.CreateUnoCursor(*pRdr->m_pPaM->GetPoint())),
2050 mxOldStck(
std::move(pRdr->m_xCtrlStck)),
2051 mxOldAnchorStck(
std::move(pRdr->m_xAnchorStck)),
2052 mxOldRedlines(
std::move(pRdr->m_xRedlineStack)),
2053 mxOldPlcxMan(pRdr->m_xPlcxMan),
2054 mpWFlyPara(
std::move(pRdr->m_xWFlyPara)),
2055 mpSFlyPara(
std::move(pRdr->m_xSFlyPara)),
2056 mpPreviousNumPaM(pRdr->m_pPreviousNumPaM),
2057 mpPrevNumRule(pRdr->m_pPrevNumRule),
2058 mxTableDesc(
std::move(pRdr->m_xTableDesc)),
2059 mnInTable(pRdr->m_nInTable),
2060 mnCurrentColl(pRdr->m_nCurrentColl),
2061 mcSymbol(pRdr->m_cSymbol),
2062 mbIgnoreText(pRdr->m_bIgnoreText),
2063 mbSymbol(pRdr->m_bSymbol),
2064 mbHdFtFootnoteEdn(pRdr->m_bHdFtFootnoteEdn),
2065 mbTxbxFlySection(pRdr->m_bTxbxFlySection),
2066 mbAnl(pRdr->m_bAnl),
2067 mbInHyperlink(pRdr->m_bInHyperlink),
2068 mbPgSecBreak(pRdr->m_bPgSecBreak),
2069 mbWasParaEnd(pRdr->m_bWasParaEnd),
2070 mbHasBorder(pRdr->m_bHasBorder),
2071 mbFirstPara(pRdr->m_bFirstPara)
2140 if (xLastAnchorCursor)
2159 if (nStartCp < 0 || nLen < 0)
2197 sAuthor = OUString(pDescri->
xstUsrInitl + 1, nLen, RTL_TEXTENCODING_MS_1252);
2204 const sal_uInt16 nLen = std::min<sal_uInt16>(SVBT16ToUInt16(pDescri->
xstUsrInitl[0]),
2206 OUStringBuffer
aBuf;
2207 aBuf.setLength(nLen);
2208 for(sal_uInt16 nIdx = 1; nIdx <= nLen; ++nIdx)
2210 sInitials =
aBuf.makeStringAndClear();
2216 sAuthor = sInitials;
2219 sal_uInt32 nDateTime = 0;
2225 nDateTime = SVBT32ToUInt32(*
reinterpret_cast<SVBT32*
>(pExtended+(
nIndex*18)));
2237 sText, sInitials, OUString(), aDate );
2254 OSL_ENSURE(pSttIdx,
"impossible");
2270 aAnch.
SetType( RndStdIds::FLY_AT_PARA );
2283 OSL_ENSURE( pFrameObj,
2284 "<SwWW8ImplReader::Read_HdFtTextAsHackedFrame(..)> - missing SdrObject instance" );
2314 return (nHeaderCP < m_xWwFib->m_ccpHdr && nHeaderCP >= 0);
2325 for(
sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
2327 if (nI & nWhichItems)
2331 bOk = (
m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nStart >= 0 && nLen >= 2 );
2334 m_xHdFt->GetTextPosExact(
static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
2361 for(
sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
2367 bOk = (
m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nLen >= 2 );
2370 m_xHdFt->GetTextPosExact(
static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
2382 bool bDisabledFirst = bUseFirst && !rSection.
HasTitlePage();
2423 bool bHackRequired =
false;
2425 bHackRequired =
true;
2427 bHackRequired =
true;
2457 OSL_ENSURE(rSection.
mpPage,
"makes no sense to call with a main page");
2477 if (pText !=
nullptr)
2502 pRule && !
m_xWDop->fDontUseHTMLAutoSpacing &&
2571 if(pULSpaceItem !=
nullptr)
2576 aUL.
SetUpper(
static_cast< sal_uInt16
>(nSpace) );
2578 aUL.
SetLower(
static_cast< sal_uInt16
>(nSpace) );
2639 bool bTableRowEnd = (
m_xPlcxMan->HasParaSprm(
m_bVer67 ? 25 : 0x2417).pSprm !=
nullptr);
2670 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(24).pSprm);
2673 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(0x2416).pSprm);
2675 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(0x244B).pSprm);
2687 WW8_CP nMyStartCp=nStartCp;
2691 nCellLevel = *aLevel.
pSprm;
2718 bStopTab = bStartTab =
true;
2721 if(
m_bAnl && !bTableRowEnd )
2730 || bStopTab || bStartTab )
2790 return bTableRowEnd;
2838 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2848 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2864 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2872 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2908 char const *pIn, std::size_t nInLen,
sal_Unicode *pOut, std::size_t nOutLen)
2910 const sal_uInt32 nFlags =
2911 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
2912 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
2913 RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2914 RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2916 const sal_uInt32 nFlags2 =
2917 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE |
2918 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE |
2919 RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2920 RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2922 std::size_t nDestChars=0;
2923 std::size_t nConverted=0;
2927 sal_uInt32 nInfo = 0;
2928 sal_Size nThisConverted=0;
2930 nDestChars += rtl_convertTextToUnicode(hConverter,
nullptr,
2931 pIn+nConverted, nInLen-nConverted,
2932 pOut+nDestChars, nOutLen-nDestChars,
2933 nFlags, &nInfo, &nThisConverted);
2935 OSL_ENSURE(nInfo == 0,
"A character conversion failed!");
2937 nConverted += nThisConverted;
2940 nInfo & RTL_TEXTTOUNICODE_INFO_UNDEFINED ||
2941 nInfo & RTL_TEXTTOUNICODE_INFO_MBUNDEFINED
2944 sal_Size nOtherConverted;
2945 rtl_TextToUnicodeConverter hCP1252Converter =
2946 rtl_createTextToUnicodeConverter(RTL_TEXTENCODING_MS_1252);
2947 nDestChars += rtl_convertTextToUnicode(hCP1252Converter,
nullptr,
2949 pOut+nDestChars, nOutLen-nDestChars,
2950 nFlags2, &nInfo, &nOtherConverted);
2951 rtl_destroyTextToUnicodeConverter(hCP1252Converter);
2954 }
while (nConverted < nInLen);
2961 bool bResult =
false;
2963 switch (
static_cast<sal_uInt16
>(
nLang))
2992 if (nChar >= 0x0030 && nChar <= 0x0039)
2993 return nChar + 0x0630;
3000 OUString makeOUString(rtl_uString *pStr, sal_Int32 nAllocLen)
3003 if (nAllocLen < pStr->length + 256)
3004 return OUString(pStr, SAL_NO_ACQUIRE);
3006 OUString sRet(pStr->buffer, pStr->length);
3007 rtl_uString_release(pStr);
3017 sal_Int32 nRequestedStrLen = nEnd - rPos;
3019 OSL_ENSURE(nRequestedStrLen,
"String is 0");
3020 if (nRequestedStrLen <= 0)
3027 rPos+=nRequestedStrLen;
3033 OSL_ENSURE(bValidPos,
"Document claimed to have more text than available");
3037 rPos+=nRequestedStrLen;
3042 OSL_ENSURE(nAvailableStrLen,
"Document claimed to have more text than available");
3043 if (!nAvailableStrLen)
3046 rPos+=nRequestedStrLen;
3050 sal_Int32 nValidStrLen = std::min<std::size_t>(nRequestedStrLen, nAvailableStrLen);
3058 RTL_TEXTENCODING_MS_1252;
3059 if (
m_bVer67 && eSrcCharSet == RTL_TEXTENCODING_MS_932)
3098 SAL_WARN(
"sw.ww8",
"discarding word95 RTL_TEXTENCODING_MS_932 encoding");
3103 RTL_TEXTENCODING_MS_1252;
3106 auto l = [](rtl_uString*
p){rtl_uString_release(
p);};
3107 std::unique_ptr<rtl_uString,
decltype(l)> xStr(rtl_uString_alloc(nStrLen), l);
3111 std::unique_ptr<char[]> p8Bits;
3113 rtl_TextToUnicodeConverter hConverter =
nullptr;
3115 hConverter = rtl_createTextToUnicodeConverter(eSrcCharSet);
3118 p8Bits.reset(
new char[nStrLen] );
3126 if (pItem !=
nullptr)
3130 for (nL2 = 0; nL2 < nStrLen; ++nL2)
3146 if ((32 > nUCode) || (0xa0 == nUCode))
3158 if (nUCode >= 0x3000)
3161 aTest[0] =
static_cast< char >((nUCode & 0xFF00) >> 8);
3162 aTest[1] =
static_cast< char >(nUCode & 0x00FF);
3163 OUString aTemp(aTest, 2, eSrcCJKCharSet);
3164 OSL_ENSURE(aTemp.getLength() == 1,
"so much for that theory");
3165 *pWork++ = aTemp[0];
3169 char cTest =
static_cast< char >(nUCode & 0x00FF);
3175 p8Bits[nL2] = nBCode;
3186 for (sal_Int32 nI = 0; nI < nEndUsed; ++nI, ++pBuffer)
3190 xStr->buffer[nEndUsed] = 0;
3191 xStr->length = nEndUsed;
3200 rtl_destroyTextToUnicodeConverter(hConverter);
3201 return nL2 >= nStrLen;
3204#define MSASCII SAL_MAX_INT16
3209 sal_Int16 lcl_getScriptType(
3210 const uno::Reference<i18n::XBreakIterator>& rBI,
3211 const OUString &rString, sal_Int32
nPos)
3213 sal_Int16 nScript = rBI->getScriptType(rString,
nPos);
3214 if (nScript == i18n::ScriptType::WEAK && rString[
nPos] >= 0x0020 && rString[
nPos] <= 0x007F)
3221 sal_Int32 lcl_endOfScript(
3222 const uno::Reference<i18n::XBreakIterator>& rBI,
3223 const OUString &rString, sal_Int32
nPos, sal_Int16 nScript)
3225 while (
nPos < rString.getLength())
3227 sal_Int16 nNewScript = lcl_getScriptType(rBI, rString,
nPos);
3228 if (nScript != nNewScript)
3235 sal_Int32 lcl_getWriterScriptType(
3236 const uno::Reference<i18n::XBreakIterator>& rBI,
3237 const OUString &rString, sal_Int32
nPos)
3239 sal_Int16 nScript = i18n::ScriptType::WEAK;
3241 if (rString.isEmpty())
3246 nScript = rBI->getScriptType(rString,
nPos);
3247 if (nScript != i18n::ScriptType::WEAK)
3295 if (rAddString.isEmpty())
3307 sal_Int16 nScript = lcl_getScriptType(xBI, rAddString, 0);
3308 sal_Int32 nLen = rAddString.getLength();
3310 OUString sParagraphText;
3314 sParagraphText = pNd->
GetText();
3315 sal_Int32 nParaOffset = sParagraphText.getLength();
3316 sParagraphText = sParagraphText + rAddString;
3321 sal_Int32 nEnd = lcl_endOfScript(xBI, rAddString,
nPos, nScript);
3325 OUString sChunk(rAddString.copy(
nPos, nEnd-
nPos));
3327 const SvxFontItem *pOverriddenItems[] = {
nullptr,
nullptr,
nullptr};
3328 bool aForced[] = {
false,
false,
false};
3330 int nLclIdctHint = 0xFF;
3331 if (nScript == i18n::ScriptType::WEAK)
3334 nLclIdctHint = pIdctHint->
GetValue();
3339 sal_uInt16 nForceFromFontId = 0;
3340 if (nLclIdctHint != 0xFF)
3342 switch (nLclIdctHint)
3358 if (nForceFromFontId != 0)
3363 sal_Int32 nWriterScript = lcl_getWriterScriptType(xBI, sParagraphText,
3364 nPos + nParaOffset);
3366 bool bWriterWillUseSameFontAsWordAutomatically =
false;
3368 if (nWriterScript != i18n::ScriptType::WEAK)
3372 (nWriterScript == i18n::ScriptType::COMPLEX && nForceFromFontId ==
RES_CHRATR_CTL_FONT) ||
3373 (nWriterScript == i18n::ScriptType::LATIN && nForceFromFontId ==
RES_CHRATR_FONT)
3376 bWriterWillUseSameFontAsWordAutomatically =
true;
3381 sal_uInt16 nDestId = aIds[nWriterScript-1];
3383 bWriterWillUseSameFontAsWordAutomatically = sameFontIgnoringIrrelevantFields(*pSourceFont, *pDestFont);
3388 if (!bWriterWillUseSameFontAsWordAutomatically)
3395 aForced[
i] = aIds[
i] != nForceFromFontId && *pSourceFont != *pDestFont;
3398 pOverriddenItems[
i] =
3402 aForceFont.SetWhich(aIds[
i]);
3416 if (pOverriddenItems[
i])
3423 nScript = lcl_getScriptType(xBI, rAddString,
nPos);
3431 OUStringBuffer buf(aString.size());
3432 for (
size_t i = 0;
i < aString.size(); ++
i)
3441 SAL_INFO(
"sw.ww8",
"filtering control character");
3444 return buf.makeStringAndClear();
3453 if (addString.isEmpty())
3459 OSL_ENSURE(pNd,
"What the hell, where's my text node");
3467 if (addString.getLength() <= nCharsLeft)
3493 tools::Long nEnd = ( nNextAttr < nTextEnd ) ? nNextAttr : nTextEnd;
3497 WW8_CP nRequested = nEnd - rPos;
3503 SAL_WARN(
"sw.ww8",
"document claims to have more characters, " << nRequested <<
" than remaining, " << nMaxPossible);
3504 nRequested = nMaxPossible;
3510 for (
WW8_CP nCh = 0; nCh < nRequested; ++nCh)
3529 bool bStartLine =
ReadChar(rPos, nCpOfs);
3540 bool bParaEndAdded =
false;
3547 if (pTemp && pTemp->
GetText().isEmpty()
3564 bParaEndAdded =
true;
3575 return bParaEndAdded;
3580 bool bNewParaEnd =
false;
3588 sal_uInt16 nWCharVal(0);
3594 m_pStrm -> ReadUChar( nBCode );
3599 bool bParaMark =
false;
3601 if ( 0xc != nWCharVal )
3629 if (pCntNd!=
nullptr && pCntNd->
Len()>0)
3656 cInsert =
u'\x00a4';
3660 cInsert =
u'\x00b5';
3669 cInsert =
u'\x00a7';
3707 sal_uInt16 nWordCode(0);
3715 nWordCode = nByteCode;
3717 if( nWordCode == 0x1 )
3732 pResult =
ImportGraf(
nullptr, pAsCharFlyFormat);
3742 "WW8: Please report this document, it may have a "
3759 bNewParaEnd = bParaMark =
true;
3772 pTest->
Where() == nPosCp+1+nCpOfs)
3804 SAL_INFO(
"sw.ww8.level2",
"<unknownValue val=\"" << nWCharVal <<
"\">" );
3808 if(
'\x0' != cInsert )
3810 OUString sInsert(cInsert);
3819 bool* pStartAttr,
bool bCallProcessSpecial)
3837 if (nOldColl >=
m_vColl.size())
3840 bool bTabRowEnd =
false;
3886 rbStartLine =
false;
3904 else if( aRes.
nSprmId < 0x800 )
3914 WW8_CP nMaxLegalSkip = nTextEnd - rTextPos;
3916 rTextPos += std::min<WW8_CP>(nSkipChars, nMaxLegalSkip);
3917 nSkipPos = rTextPos-1;
3927 SAL_WARN_IF(!bValidPos,
"sw.ww8",
"Document claimed to have text at an invalid position, skip attributes for region");
3935 bool bDoPlcxManPlusPLus =
true;
3939 if( bDoPlcxManPlusPLus )
3941 nNext = bValidPos ?
m_xPlcxMan->Where() : nTextEnd;
3949 if( (0 <= nNext) && (nSkipPos >= nNext) )
3951 if (nDepthGuard >= 1024)
3953 SAL_WARN(
"sw.ww8",
"ReadTextAttr hit recursion limit");
3957 nNext =
ReadTextAttr(rTextPos, nTextEnd, rbStartLine, nDepthGuard + 1);
3958 bDoPlcxManPlusPLus =
false;
3968 while( nSkipPos >= nNext );
3983 if( rTextPos >= rNext )
3988 if (rTextPos == rNext && rTextPos >= nTextEnd)
3991 while( rTextPos >= rNext );
3994 else if ( rbStartLine )
4004 rbStartLine =
false;
4017 std::stack<sal_uInt16> aStack;
4020 while (!aStack.empty())
4022 sal_uInt16 nSprmId = aStack.top();
4023 if ((0 < nSprmId) && ((
eFTN > nSprmId) || (0x0800 <= nSprmId)))
4035 bool bStartLine =
true;
4037 short nDistance = 0;
4061 if (nTextLen > nMaxPossible)
4063 SAL_WARN_IF(nTextLen > nMaxPossible,
"sw.ww8",
"TextLen too long");
4064 nTextLen = nMaxPossible;
4066 WW8_CP nTextEnd = nStartCp+nTextLen;
4067 while (l < nTextEnd)
4069 ReadAttrs( l, nNext, nTextEnd, bStartLine );
4078 bStartLine =
ReadChars(l, nNext, nTextEnd, nCpOfs);
4106 SAL_WARN_IF(!pEndNd,
"sw.ww8",
"didn't find textnode for dropcap");
4109 const sal_Int32 nDropCapLen = pPreviousNode->GetText().getLength();
4113 SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1);
4124 aDrop.
GetChars() = writer_cast<sal_uInt8>(nDropCapLen);
4130 else if(pNewSwCharFormat)
4146 aDCS =
m_xPlcxMan->GetPapPLCF()->HasSprm(46);
4148 aDCS =
m_xPlcxMan->GetPapPLCF()->HasSprm(0x442C);
4151 nDropLines = (*aDCS.
pSprm) >> 3;
4157 nDistance = SVBT16ToUInt16(
aDistance.pSprm);
4166 if (pSwFormatCharFormat)
4187 m_nProgress = o3tl::narrowing<sal_uInt16>(l * 100 / nTextLen);
4189 m_nProgress = o3tl::narrowing<sal_uInt16>(l / nTextLen * 100);
4241 : m_pDocShell(rD.GetDocShell())
4244 , m_pTableStream(nullptr)
4245 , m_pDataStream(nullptr)
4248 , m_aSectionManager(*this)
4249 , m_aExtraneousParas(rD)
4250 , m_aInsertedTables(rD)
4251 , m_aSectionNameGenerator(rD,
"WW")
4252 , m_aGrfNameGenerator(bNewDoc, OUString(
'G'))
4253 , m_aParaStyleMapper(rD)
4254 , m_aCharStyleMapper(rD)
4255 , m_pFlyFormatOfJustInsertedGraphic(nullptr)
4256 , m_pPreviousNumPaM(nullptr)
4257 , m_pPrevNumRule(nullptr)
4258 , m_pCurrentColl(nullptr)
4259 , m_pDfltTextFormatColl(nullptr)
4260 , m_pStandardFormatColl(nullptr)
4261 , m_pDrawModel(nullptr)
4262 , m_pDrawPg(nullptr)
4263 , m_pNumFieldType(nullptr)
4264 , m_sBaseURL(
std::move(aBaseURL))
4268 , m_bRegardHindiDigits( false )
4269 , m_bDrawCpOValid( false )
4275 , m_eTextCharSet(RTL_TEXTENCODING_ASCII_US)
4276 , m_eStructCharSet(RTL_TEXTENCODING_ASCII_US)
4277 , m_eHardCharSet(RTL_TEXTENCODING_DONTKNOW)
4281 , m_nLFOPosition(USHRT_MAX)
4288 , m_nWantedVersion(nVersionPara)
4289 , m_nSwNumLevel(0xff)
4290 , m_nWwNumType(0xff)
4291 , m_pChosenWW8OutlineStyle(nullptr)
4293 , m_bNewDoc(bNewDoc)
4294 , m_bSkipImages(bSkipImages)
4295 , m_bReadNoTable(false)
4296 , m_bPgSecBreak(false)
4299 , m_bTxbxFlySection(false)
4300 , m_bHasBorder(false)
4302 , m_bIgnoreText(false)
4304 , m_bWasTabRowEnd(false)
4305 , m_bWasTabCellEnd(false)
4307 , m_bHdFtFootnoteEdn(false)
4308 , m_bFootnoteEdn(false)
4309 , m_bIsHeader(false)
4310 , m_bIsFooter(false)
4311 , m_bIsUnicode(false)
4312 , m_bCpxStyle(false)
4313 , m_bStyNormal(false)
4314 , m_bWWBugNormal(false)
4315 , m_bNoAttrImport(false)
4316 , m_bInHyperlink(false)
4317 , m_bWasParaEnd(false)
4322 , m_bEmbeddObj(false)
4323 , m_bCurrentAND_fNumberAcross(false)
4324 , m_bNoLnNumYet(true)
4325 , m_bFirstPara(true)
4326 , m_bFirstParaOfPage(false)
4327 , m_bParaAutoBefore(false)
4328 , m_bParaAutoAfter(false)
4332 , m_bReadTable(false)
4333 , m_bLoadingTOXCache(false)
4334 , m_nEmbeddedTOXLevel(0)
4335 , m_bLoadingTOXHyperlink(false)
4336 , m_bCareFirstParaEndInToc(false)
4337 , m_bCareLastParaEndInToc(false)
4338 , m_bNotifyMacroEventRead(false)
4339 , m_bFuzzing(
utl::ConfigManager::IsFuzzing())
4360 OSL_ENSURE(
false,
"WW stack already deleted" );
4384 if (
aData.begin()->get()->nFlags & ShapeFlag::Background)
4403 SetPage(rPage, rFormat, rSection, bIgnoreCols);
4425 OSL_ENSURE(rSection.
mpPage,
"Makes no sense to call me with no pages to set");
4447 OSL_ENSURE(pApply,
"impossible");
4462 mySegIter const &rStart,
bool bIgnoreCols)
4475 OSL_ENSURE(rIter->mpPage,
"no page!");
4481 if (rIter != rStart)
4482 pPrevious = &(*(rIter-1));
4483 SetHdFt(*rIter, std::distance(rStart, rIter), pPrevious);
4491 rIter->mpPage->SetFollow(rIter->mpPage);
4493 if (rIter->PageRestartNo())
4504 for (
mySegIter aIter = aStart; aIter != aEnd; ++aIter)
4509 if ( aIter->maSep.bkc == 1 && aIter->maSep.ccolM1 > 0 )
4517 mySegIter aPrev = (aIter == aStart) ? aIter : aIter-1;
4521 bool bThisAndPreviousAreCompatible = ((aIter->GetPageWidth() == aPrev->GetPageWidth()) &&
4522 (aIter->GetPageHeight() == aPrev->GetPageHeight()) && (aIter->IsLandScape() == aPrev->IsLandScape()));
4524 bool bInsertSection = (aIter != aStart) && aIter->IsContinuous() && bThisAndPreviousAreCompatible;
4525 bool bInsertPageDesc = !bInsertSection;
4527 if( aIter->maSep.dxaLeft != aPrev->maSep.dxaLeft || aIter->maSep.dxaRight != aPrev->maSep.dxaRight )
4528 bInsertPageDesc =
true;
4531 if (bInsertPageDesc)
4542 bool bIgnoreCols = bInsertSection;
4543 bool bThisAndNextAreCompatible = (aNext == aEnd) ||
4544 ((aIter->GetPageWidth() == aNext->GetPageWidth()) &&
4545 (aIter->GetPageHeight() == aNext->GetPageHeight()) &&
4546 (aIter->IsLandScape() == aNext->IsLandScape()));
4548 if ((aNext != aEnd && aNext->IsContinuous() && bThisAndNextAreCompatible) || bProtected)
4551 if ((aIter->NoCols() > 1) || bProtected)
4552 bInsertSection =
true;
4564 if ( aIter->maSep.bkc == 3 || aIter->maSep.bkc == 4 )
4575 *aIter = aTmpSection;
4579 if ( aIter->maSep.bkc == 4 )
4601 aAnchor = aNext->maStart;
4622 bool bHasOwnHdFt =
false;
4629 if (!bInsertPageDesc)
4634 aIter->maSep.grpfIhdt, std::distance(aStart, aIter)
4642 bool bFailed =
true;
4648 for(; nStart <= nEnd; ++nStart)
4664 aIter->mpPage = pOrig;
4681 if (aNext == aEnd || !aNext->IsContinuous())
4689 SwPaM aTest(*pTextNd);
4699 for (
auto aI =
m_aTextNodes.rbegin(); aI != aEnd; ++aI)
4705 SwPaM aTest(*pTextNode);
4722 SAL_WARN(
"sw.ww8",
"It is unexpected to drop a para scheduled for removal");
4727 : m_pTextNode(pTextNode)
4741 if (rHint.
GetId() != SfxHintId::SwLegacyModify)
4769 if (!m_xWwFib->m_lcbCmds)
4772 bool bValidPos =
checkSeek(*m_pTableStream, m_xWwFib->m_fcCmds);
4776 uno::Reference < embed::XStorage > xRoot(m_pDocShell->GetStorage());
4783 uno::Reference < io::XStream >
xStream =
4784 xRoot->openStreamElement(
SL::aMSMacroCmds, embed::ElementModes::READWRITE );
4787 sal_uInt32 lcbCmds = std::min<sal_uInt32>(m_xWwFib->m_lcbCmds, m_pTableStream->remainingSize());
4788 std::unique_ptr<sal_uInt8[]> xBuffer(
new sal_uInt8[lcbCmds]);
4789 m_xWwFib->m_lcbCmds = m_pTableStream->ReadBytes(xBuffer.get(), lcbCmds);
4790 xOutStream->WriteBytes(xBuffer.get(), m_xWwFib->m_lcbCmds);
4799 std::vector<OUString> aDocVarStrings;
4800 std::vector<ww::bytes> aDocVarStringIds;
4801 std::vector<OUString> aDocValueStrings;
4802 WW8ReadSTTBF(!m_bVer67, *m_pTableStream, m_xWwFib->m_fcStwUser,
4803 m_xWwFib->m_lcbStwUser, m_bVer67 ? 2 : 0, m_eStructCharSet,
4804 aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
4805 if (m_bVer67)
return;
4807 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4808 m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
4809 uno::Reference<document::XDocumentProperties> xDocProps(
4810 xDPS->getDocumentProperties());
4811 OSL_ENSURE(xDocProps.is(),
"DocumentProperties is null");
4812 uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
4813 xDocProps->getUserDefinedProperties();
4814 OSL_ENSURE(xUserDefinedProps.is(),
"UserDefinedProperties is null");
4816 for(
size_t i=0;
i<aDocVarStrings.size();
i++)
4818 const OUString &rName = aDocVarStrings[
i];
4822 xUserDefinedProps->addProperty( rName,
4823 beans::PropertyAttribute::REMOVABLE,
4825 }
catch (
const uno::Exception &) {
4839 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4840 m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
4841 uno::Reference<document::XDocumentProperties> xDocProps(
4842 xDPS->getDocumentProperties());
4843 OSL_ENSURE(xDocProps.is(),
"DocumentProperties is null");
4845 if (!xDocProps.is())
4848 if ( m_xWwFib->m_fDot )
4850 SfxMedium* pMedium = m_pDocShell->GetMedium();
4856 if ( !sTemplateURL.isEmpty() )
4857 xDocProps->setTemplateURL( sTemplateURL );
4860 else if (m_xWwFib->m_lcbSttbfAssoc)
4862 auto nCur = m_pTableStream->Tell();
4865 if (!
checkSeek(*m_pTableStream, m_xWwFib->m_fcSttbfAssoc) || !aSttb.Read(*m_pTableStream))
4866 SAL_WARN(
"sw.ww8",
"** Read of SttbAssoc data failed!!!! ");
4867 m_pTableStream->Seek( nCur );
4868 OUString sPath = aSttb.getStringAtIndex( 0x1 );
4871 if ( !sPath.isEmpty() )
4872 osl::FileBase::getFileURLFromSystemPath( sPath,
aURL );
4874 xDocProps->setTemplateURL(
aURL );
4876 xDocProps->setTemplateURL( sPath );
4882static void lcl_createTemplateToProjectEntry(
const uno::Reference< container::XNameContainer >& xPrjNameCache,
const OUString& sTemplatePathOrURL,
const OUString& sVBAProjName )
4884 if ( !xPrjNameCache.is() )
4888 aObj.
SetURL( sTemplatePathOrURL );
4889 bool bIsURL = aObj.
GetProtocol() != INetProtocol::NotValid;
4892 aURL = sTemplatePathOrURL;
4895 osl::FileBase::getFileURLFromSystemPath( sTemplatePathOrURL,
aURL );
4900 OUString templateNameWithExt = aObj.
GetLastName();
4901 sal_Int32
nIndex = templateNameWithExt.lastIndexOf(
'.' );
4904 OUString templateName = templateNameWithExt.copy( 0,
nIndex );
4905 xPrjNameCache->insertByName( templateName,
uno::Any( sVBAProjName ) );
4908 catch(
const uno::Exception& )
4915class WW8Customizations
4926WW8Customizations::WW8Customizations(
SvStream* pTableStream,
WW8Fib const & rFib ) : mpTableStream(pTableStream), mWw8Fib( rFib )
4930void WW8Customizations::Import(
SwDocShell* pShell )
4932 if ( mWw8Fib.m_lcbCmds == 0 || !
IsEightPlus(mWw8Fib.GetFIBVersion()) )
4937 sal_uInt64 nCur = mpTableStream->Tell();
4938 if (!
checkSeek(*mpTableStream, mWw8Fib.m_fcCmds))
4940 SAL_WARN(
"sw.ww8",
"** Seek to Customization data failed!!!! ");
4943 bool bReadResult = aTCG.
Read( *mpTableStream );
4944 mpTableStream->Seek( nCur );
4947 SAL_WARN(
"sw.ww8",
"** Read of Customization data failed!!!! ");
4954 SAL_WARN(
"sw.ww8",
"** Read of Customization data failed!!!! epically");
4965 uno::Sequence< OUString > sGlobalTemplates;
4968 uno::Reference<ucb::XSimpleFileAccess3> xSFA(ucb::SimpleFileAccess::create(::comphelper::getProcessComponentContext()));
4970 if( xSFA->isFolder( aAddinPath ) )
4971 sGlobalTemplates = xSFA->getFolderContents( aAddinPath,
false );
4973 for (
const auto& rGlobalTemplate : std::as_const(sGlobalTemplates) )
4976 aObj.
SetURL( rGlobalTemplate );
4977 bool bIsURL = aObj.
GetProtocol() != INetProtocol::NotValid;
4980 aURL = rGlobalTemplate;
4982 osl::FileBase::getFileURLFromSystemPath( rGlobalTemplate,
aURL );
4983 if ( !
aURL.endsWithIgnoreAsciiCase(
".dot" ) || ( !sCreatedFrom.empty() && sCreatedFrom ==
aURL ) )
4988 BasicProjImportHelper aBasicImporter( *
m_pDocShell );
4994 refMainStream->SetEndian(SvStreamEndian::LITTLE);
4995 WW8Fib aWwFib( *refMainStream, 8 );
4999 if (xTableStream.
is() &&
ERRCODE_NONE == xTableStream->GetError())
5001 xTableStream->SetEndian(SvStreamEndian::LITTLE);
5002 WW8Customizations aGblCustomisations( xTableStream.
get(), aWwFib );
5017 uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(
xModel, uno::UNO_QUERY_THROW);
5021 uno::Reference<task::XInteractionHandler> xHandler;
5022 xDocumentMetadataAccess->loadMetadataFromStorage(xStorage, xBaseURI, xHandler);
5024 catch (
const uno::Exception&)
5031 auto pFibData = std::make_shared<::ww8::WW8FibData>();
5033 if (
m_xWwFib->m_fReadOnlyRecommended)
5034 pFibData->setReadOnlyRecommended(
true);
5036 pFibData->setReadOnlyRecommended(
false);
5039 pFibData->setWriteReservation(
true);
5041 pFibData->setWriteReservation(
false);