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 )
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)
1426 if (leftMarginNew != leftMarginOld)
1436 OSL_ENSURE(
false,
"What is a field doing in the control stack,"
1437 "probably should have been in the endstack");
1441 OSL_ENSURE(
false,
"What is an annotation doing in the control stack,"
1442 "probably should have been in the endstack");
1446 OSL_ENSURE(
false,
"What is an input field doing in the control stack,"
1447 "probably should have been in the endstack");
1452 SwPaM aRegion(rTmpPos);
1460 if (
nullptr != pFrame)
1505 eState = pSet->GetItemState(nWhich,
false);
1536 pItem = &pNd->
GetAttr(nWhich);
1547 size_t nSize =
size();
1551 if (rEntry.
m_pAttr->Which() == nWhich)
1578 sal_uInt16 nSubType;
1599 switch (rEntry.
m_pAttr->Which())
1631 sal_uInt16 nRefNo =
static_cast<SwTextFootnote*
>(pFootnote)->GetSeqRefNo();
1651 OSL_ENSURE(
false,
"EndStck used with non field, not what we want");
1681 short nRequiredLength = 2 + 2*nDel + 2*nIns + 1*nIns;
1682 if (nRequiredLength > nLen)
1692 std::shared_ptr<SvxTabStopItem> aAttr(std::make_shared<SvxTabStopItem>(0, 0, SvxTabAdjust::Default,
RES_PARATR_TABSTOP));
1695 sal_uInt16 nTabBase;
1699 if (nTabBase <
m_vColl.size())
1700 pSty =
m_vColl[nTabBase].m_pFormat;
1710 bool bFound =
false;
1711 std::unordered_set<size_t> aLoopWatch;
1712 while (pSty && !bFound)
1716 &pTabs) == SfxItemState::SET;
1719 aAttr.reset(pTabs->
Clone());
1723 sal_uInt16 nOldTabBase = nTabBase;
1725 if (nTabBase <
m_vColl.size())
1726 nTabBase =
m_vColl[nTabBase].m_nBase;
1730 nOldTabBase != nTabBase &&
1736 aLoopWatch.insert(
reinterpret_cast<size_t>(pSty));
1737 if (nTabBase <
m_vColl.size())
1738 pSty =
m_vColl[nTabBase].m_pFormat;
1741 if (aLoopWatch.find(
reinterpret_cast<size_t>(pSty)) !=
1751 for (
short i=0;
i < nDel; ++
i)
1753 sal_uInt16
nPos = aAttr->GetPos(SVBT16ToUInt16(pDel +
i*2));
1755 aAttr->Remove(
nPos );
1758 for (
short i=0;
i < nIns; ++
i)
1760 short nPos = SVBT16ToUInt16(pIns +
i*2);
1762 switch( pTyp[
i].aBits1 & 0x7 )
1780 switch( pTyp[
i].aBits1 >> 3 & 0x7 )
1797 sal_uInt16 nPos2 = aAttr->GetPos(
nPos );
1799 aAttr->Remove(nPos2);
1800 aAttr->Insert(aTabStop);
1830 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1832 uno::Reference<document::XDocumentProperties> xDocuProps(
1833 xDPS->getDocumentProperties());
1834 OSL_ENSURE(xDocuProps.is(),
"DocumentProperties is null");
1835 if (xDocuProps.is())
1840 xDocuProps->setPrintDate(uDT);
1873 if( nDefTabSiz < 56 )
1878 const_cast<SvxTabStop&
>(aNewTab[0]).GetAdjustment() = SvxTabAdjust::Default;
1886 sal_Int16 nZoomType;
1888 case 1: nZoomType = sal_Int16(SvxZoomType::WHOLEPAGE);
break;
1889 case 2: nZoomType = sal_Int16(SvxZoomType::PAGEWIDTH);
break;
1890 case 3: nZoomType = sal_Int16(SvxZoomType::OPTIMAL);
break;
1891 default: nZoomType = sal_Int16(SvxZoomType::PERCENT);
break;
1895 {
"VisibleBottom",
uno::Any(sal_Int32(0)) },
1896 {
"ZoomType",
uno::Any(nZoomType) }
1900 xBox->insertByIndex(sal_Int32(0),
uno::Any(aViewProps));
1901 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(
m_pDocShell->
GetModel(), uno::UNO_QUERY);
1902 xViewDataSupplier->setViewData(xBox);
1949 if (
m_xWDop->fDontBreakWrappedTables)
1965 uno::Reference<beans::XPropertySetInfo> xInfo = xDocProps->getPropertySetInfo();
1968 if (xInfo->hasPropertyByName(
"ApplyFormDesignMode"))
1969 xDocProps->setPropertyValue(
"ApplyFormDesignMode", css::uno::Any(
false));
1975 {
"name",
uno::Any(OUString(
"compatibilityMode")) },
1976 {
"uri",
uno::Any(OUString(
"http://schemas.microsoft.com/office/word")) },
1977 {
"val",
uno::Any(OUString(
"11")) }
1981 {
"compatSetting",
uno::Any(aCompatSetting) }
1984 aGrabBag[
"CompatSettings"] <<= aValue;
1994 else if ( xDocProps.is() )
1997 aGrabBag[
"FormPasswordHash"] <<=
m_xWDop->lKeyProtDoc;
2017 i18n::ForbiddenCharacters aForbidden(OUString(+rTypo.
m_rgxchFPunct),
2056 mxTmpPos(pRdr->
m_rDoc.CreateUnoCursor(*pRdr->m_pPaM->GetPoint())),
2057 mxOldStck(
std::move(pRdr->m_xCtrlStck)),
2058 mxOldAnchorStck(
std::move(pRdr->m_xAnchorStck)),
2059 mxOldRedlines(
std::move(pRdr->m_xRedlineStack)),
2060 mxOldPlcxMan(pRdr->m_xPlcxMan),
2061 mpWFlyPara(
std::move(pRdr->m_xWFlyPara)),
2062 mpSFlyPara(
std::move(pRdr->m_xSFlyPara)),
2063 mpPreviousNumPaM(pRdr->m_pPreviousNumPaM),
2064 mpPrevNumRule(pRdr->m_pPrevNumRule),
2065 mxTableDesc(
std::move(pRdr->m_xTableDesc)),
2066 mnInTable(pRdr->m_nInTable),
2067 mnCurrentColl(pRdr->m_nCurrentColl),
2068 mcSymbol(pRdr->m_cSymbol),
2069 mbIgnoreText(pRdr->m_bIgnoreText),
2070 mbSymbol(pRdr->m_bSymbol),
2071 mbHdFtFootnoteEdn(pRdr->m_bHdFtFootnoteEdn),
2072 mbTxbxFlySection(pRdr->m_bTxbxFlySection),
2073 mbAnl(pRdr->m_bAnl),
2074 mbInHyperlink(pRdr->m_bInHyperlink),
2075 mbPgSecBreak(pRdr->m_bPgSecBreak),
2076 mbWasParaEnd(pRdr->m_bWasParaEnd),
2077 mbHasBorder(pRdr->m_bHasBorder),
2078 mbFirstPara(pRdr->m_bFirstPara)
2147 if (xLastAnchorCursor)
2166 if (nStartCp < 0 || nLen < 0)
2204 sAuthor = OUString(pDescri->
xstUsrInitl + 1, nLen, RTL_TEXTENCODING_MS_1252);
2211 const sal_uInt16 nLen = std::min<sal_uInt16>(SVBT16ToUInt16(pDescri->
xstUsrInitl[0]),
2213 OUStringBuffer
aBuf;
2214 aBuf.setLength(nLen);
2215 for(sal_uInt16 nIdx = 1; nIdx <= nLen; ++nIdx)
2217 sInitials =
aBuf.makeStringAndClear();
2223 sAuthor = sInitials;
2226 sal_uInt32 nDateTime = 0;
2232 nDateTime = SVBT32ToUInt32(*
reinterpret_cast<SVBT32*
>(pExtended+(
nIndex*18)));
2244 sText, sInitials, OUString(), aDate );
2261 OSL_ENSURE(pSttIdx,
"impossible");
2277 aAnch.
SetType( RndStdIds::FLY_AT_PARA );
2290 OSL_ENSURE( pFrameObj,
2291 "<SwWW8ImplReader::Read_HdFtTextAsHackedFrame(..)> - missing SdrObject instance" );
2321 return (nHeaderCP < m_xWwFib->m_ccpHdr && nHeaderCP >= 0);
2332 for(
sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
2334 if (nI & nWhichItems)
2338 bOk = (
m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nStart >= 0 && nLen >= 2 );
2341 m_xHdFt->GetTextPosExact(
static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
2368 for(
sal_uInt8 nI = 0x20; nI; nI >>= 1, nNumber-- )
2374 bOk = (
m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nLen >= 2 );
2377 m_xHdFt->GetTextPosExact(
static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
2389 bool bDisabledFirst = bUseFirst && !rSection.
HasTitlePage();
2430 bool bHackRequired =
false;
2432 bHackRequired =
true;
2434 bHackRequired =
true;
2464 OSL_ENSURE(rSection.
mpPage,
"makes no sense to call with a main page");
2484 if (pText !=
nullptr)
2509 pRule && !
m_xWDop->fDontUseHTMLAutoSpacing &&
2578 if(pULSpaceItem !=
nullptr)
2583 aUL.
SetUpper(
static_cast< sal_uInt16
>(nSpace) );
2585 aUL.
SetLower(
static_cast< sal_uInt16
>(nSpace) );
2646 bool bTableRowEnd = (
m_xPlcxMan->HasParaSprm(
m_bVer67 ? 25 : 0x2417).pSprm !=
nullptr);
2677 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(24).pSprm);
2680 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(0x2416).pSprm);
2682 nCellLevel =
int(
nullptr !=
m_xPlcxMan->HasParaSprm(0x244B).pSprm);
2694 WW8_CP nMyStartCp=nStartCp;
2698 nCellLevel = *aLevel.
pSprm;
2725 bStopTab = bStartTab =
true;
2728 if(
m_bAnl && !bTableRowEnd )
2737 || bStopTab || bStartTab )
2797 return bTableRowEnd;
2845 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2855 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2871 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2879 if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW)
2915 char const *pIn, std::size_t nInLen,
sal_Unicode *pOut, std::size_t nOutLen)
2917 const sal_uInt32 nFlags =
2918 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
2919 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
2920 RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2921 RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2923 const sal_uInt32 nFlags2 =
2924 RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE |
2925 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE |
2926 RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE |
2927 RTL_TEXTTOUNICODE_FLAGS_FLUSH;
2929 std::size_t nDestChars=0;
2930 std::size_t nConverted=0;
2934 sal_uInt32 nInfo = 0;
2935 sal_Size nThisConverted=0;
2937 nDestChars += rtl_convertTextToUnicode(hConverter,
nullptr,
2938 pIn+nConverted, nInLen-nConverted,
2939 pOut+nDestChars, nOutLen-nDestChars,
2940 nFlags, &nInfo, &nThisConverted);
2942 OSL_ENSURE(nInfo == 0,
"A character conversion failed!");
2944 nConverted += nThisConverted;
2947 nInfo & RTL_TEXTTOUNICODE_INFO_UNDEFINED ||
2948 nInfo & RTL_TEXTTOUNICODE_INFO_MBUNDEFINED
2951 sal_Size nOtherConverted;
2952 rtl_TextToUnicodeConverter hCP1252Converter =
2953 rtl_createTextToUnicodeConverter(RTL_TEXTENCODING_MS_1252);
2954 nDestChars += rtl_convertTextToUnicode(hCP1252Converter,
nullptr,
2956 pOut+nDestChars, nOutLen-nDestChars,
2957 nFlags2, &nInfo, &nOtherConverted);
2958 rtl_destroyTextToUnicodeConverter(hCP1252Converter);
2961 }
while (nConverted < nInLen);
2968 bool bResult =
false;
2970 switch (
static_cast<sal_uInt16
>(
nLang))
2999 if (nChar >= 0x0030 && nChar <= 0x0039)
3000 return nChar + 0x0630;
3007 OUString makeOUString(rtl_uString *pStr, sal_Int32 nAllocLen)
3010 if (nAllocLen < pStr->length + 256)
3011 return OUString(pStr, SAL_NO_ACQUIRE);
3013 OUString sRet(pStr->buffer, pStr->length);
3014 rtl_uString_release(pStr);
3024 sal_Int32 nRequestedStrLen = nEnd - rPos;
3026 OSL_ENSURE(nRequestedStrLen,
"String is 0");
3027 if (nRequestedStrLen <= 0)
3034 rPos+=nRequestedStrLen;
3040 OSL_ENSURE(bValidPos,
"Document claimed to have more text than available");
3044 rPos+=nRequestedStrLen;
3049 OSL_ENSURE(nAvailableStrLen,
"Document claimed to have more text than available");
3050 if (!nAvailableStrLen)
3053 rPos+=nRequestedStrLen;
3057 sal_Int32 nValidStrLen = std::min<std::size_t>(nRequestedStrLen, nAvailableStrLen);
3065 RTL_TEXTENCODING_MS_1252;
3066 if (
m_bVer67 && eSrcCharSet == RTL_TEXTENCODING_MS_932)
3105 SAL_WARN(
"sw.ww8",
"discarding word95 RTL_TEXTENCODING_MS_932 encoding");
3110 RTL_TEXTENCODING_MS_1252;
3113 auto l = [](rtl_uString*
p){rtl_uString_release(
p);};
3114 std::unique_ptr<rtl_uString,
decltype(l)> xStr(rtl_uString_alloc(nStrLen), l);
3118 std::unique_ptr<char[]> p8Bits;
3120 rtl_TextToUnicodeConverter hConverter =
nullptr;
3122 hConverter = rtl_createTextToUnicodeConverter(eSrcCharSet);
3125 p8Bits.reset(
new char[nStrLen] );
3133 if (pItem !=
nullptr)
3137 for (nL2 = 0; nL2 < nStrLen; ++nL2)
3153 if ((32 > nUCode) || (0xa0 == nUCode))
3165 if (nUCode >= 0x3000)
3168 aTest[0] =
static_cast< char >((nUCode & 0xFF00) >> 8);
3169 aTest[1] =
static_cast< char >(nUCode & 0x00FF);
3170 OUString aTemp(aTest, 2, eSrcCJKCharSet);
3171 OSL_ENSURE(aTemp.getLength() == 1,
"so much for that theory");
3172 *pWork++ = aTemp[0];
3176 char cTest =
static_cast< char >(nUCode & 0x00FF);
3182 p8Bits[nL2] = nBCode;
3193 for (sal_Int32 nI = 0; nI < nEndUsed; ++nI, ++pBuffer)
3197 xStr->buffer[nEndUsed] = 0;
3198 xStr->length = nEndUsed;
3207 rtl_destroyTextToUnicodeConverter(hConverter);
3208 return nL2 >= nStrLen;
3211#define MSASCII SAL_MAX_INT16
3216 sal_Int16 lcl_getScriptType(
3217 const uno::Reference<i18n::XBreakIterator>& rBI,
3218 const OUString &rString, sal_Int32
nPos)
3220 sal_Int16 nScript = rBI->getScriptType(rString,
nPos);
3221 if (nScript == i18n::ScriptType::WEAK && rString[
nPos] >= 0x0020 && rString[
nPos] <= 0x007F)
3228 sal_Int32 lcl_endOfScript(
3229 const uno::Reference<i18n::XBreakIterator>& rBI,
3230 const OUString &rString, sal_Int32
nPos, sal_Int16 nScript)
3232 while (
nPos < rString.getLength())
3234 sal_Int16 nNewScript = lcl_getScriptType(rBI, rString,
nPos);
3235 if (nScript != nNewScript)
3242 sal_Int32 lcl_getWriterScriptType(
3243 const uno::Reference<i18n::XBreakIterator>& rBI,
3244 const OUString &rString, sal_Int32
nPos)
3246 sal_Int16 nScript = i18n::ScriptType::WEAK;
3248 if (rString.isEmpty())
3253 nScript = rBI->getScriptType(rString,
nPos);
3254 if (nScript != i18n::ScriptType::WEAK)
3302 if (rAddString.isEmpty())
3314 sal_Int16 nScript = lcl_getScriptType(xBI, rAddString, 0);
3315 sal_Int32 nLen = rAddString.getLength();
3317 OUString sParagraphText;
3321 sParagraphText = pNd->
GetText();
3322 sal_Int32 nParaOffset = sParagraphText.getLength();
3323 sParagraphText = sParagraphText + rAddString;
3328 sal_Int32 nEnd = lcl_endOfScript(xBI, rAddString,
nPos, nScript);
3332 OUString sChunk(rAddString.copy(
nPos, nEnd-
nPos));
3334 const SvxFontItem *pOverriddenItems[] = {
nullptr,
nullptr,
nullptr};
3335 bool aForced[] = {
false,
false,
false};
3337 int nLclIdctHint = 0xFF;
3338 if (nScript == i18n::ScriptType::WEAK)
3341 nLclIdctHint = pIdctHint->
GetValue();
3346 sal_uInt16 nForceFromFontId = 0;
3347 if (nLclIdctHint != 0xFF)
3349 switch (nLclIdctHint)
3365 if (nForceFromFontId != 0)
3370 sal_Int32 nWriterScript = lcl_getWriterScriptType(xBI, sParagraphText,
3371 nPos + nParaOffset);
3373 bool bWriterWillUseSameFontAsWordAutomatically =
false;
3375 if (nWriterScript != i18n::ScriptType::WEAK)
3379 (nWriterScript == i18n::ScriptType::COMPLEX && nForceFromFontId ==
RES_CHRATR_CTL_FONT) ||
3380 (nWriterScript == i18n::ScriptType::LATIN && nForceFromFontId ==
RES_CHRATR_FONT)
3383 bWriterWillUseSameFontAsWordAutomatically =
true;
3388 sal_uInt16 nDestId = aIds[nWriterScript-1];
3390 bWriterWillUseSameFontAsWordAutomatically = sameFontIgnoringIrrelevantFields(*pSourceFont, *pDestFont);
3395 if (!bWriterWillUseSameFontAsWordAutomatically)
3402 aForced[
i] = aIds[
i] != nForceFromFontId && *pSourceFont != *pDestFont;
3405 pOverriddenItems[
i] =
3409 aForceFont.SetWhich(aIds[
i]);
3423 if (pOverriddenItems[
i])
3430 nScript = lcl_getScriptType(xBI, rAddString,
nPos);
3438 OUStringBuffer buf(aString.size());
3439 for (
size_t i = 0;
i < aString.size(); ++
i)
3448 SAL_INFO(
"sw.ww8",
"filtering control character");
3451 return buf.makeStringAndClear();
3460 if (addString.isEmpty())
3466 OSL_ENSURE(pNd,
"What the hell, where's my text node");
3474 if (addString.getLength() <= nCharsLeft)
3500 tools::Long nEnd = ( nNextAttr < nTextEnd ) ? nNextAttr : nTextEnd;
3504 WW8_CP nRequested = nEnd - rPos;
3510 SAL_WARN(
"sw.ww8",
"document claims to have more characters, " << nRequested <<
" than remaining, " << nMaxPossible);
3511 nRequested = nMaxPossible;
3517 for (
WW8_CP nCh = 0; nCh < nRequested; ++nCh)
3536 bool bStartLine =
ReadChar(rPos, nCpOfs);
3547 bool bParaEndAdded =
false;
3554 if (pTemp && pTemp->
GetText().isEmpty()
3571 bParaEndAdded =
true;
3582 return bParaEndAdded;
3587 bool bNewParaEnd =
false;
3595 sal_uInt16 nWCharVal(0);
3601 m_pStrm -> ReadUChar( nBCode );
3606 bool bParaMark =
false;
3608 if ( 0xc != nWCharVal )
3636 if (pCntNd!=
nullptr && pCntNd->
Len()>0)
3663 cInsert =
u'\x00a4';
3667 cInsert =
u'\x00b5';
3676 cInsert =
u'\x00a7';
3714 sal_uInt16 nWordCode(0);
3722 nWordCode = nByteCode;
3724 if( nWordCode == 0x1 )
3739 pResult =
ImportGraf(
nullptr, pAsCharFlyFormat);
3749 "WW8: Please report this document, it may have a "
3766 bNewParaEnd = bParaMark =
true;
3779 pTest->
Where() == nPosCp+1+nCpOfs)
3811 SAL_INFO(
"sw.ww8.level2",
"<unknownValue val=\"" << nWCharVal <<
"\">" );
3815 if(
'\x0' != cInsert )
3817 OUString sInsert(cInsert);
3826 bool* pStartAttr,
bool bCallProcessSpecial)
3844 if (nOldColl >=
m_vColl.size())
3847 bool bTabRowEnd =
false;
3893 rbStartLine =
false;
3911 else if( aRes.
nSprmId < 0x800 )
3921 WW8_CP nMaxLegalSkip = nTextEnd - rTextPos;
3923 rTextPos += std::min<WW8_CP>(nSkipChars, nMaxLegalSkip);
3924 nSkipPos = rTextPos-1;
3934 SAL_WARN_IF(!bValidPos,
"sw.ww8",
"Document claimed to have text at an invalid position, skip attributes for region");
3942 bool bDoPlcxManPlusPLus =
true;
3946 if( bDoPlcxManPlusPLus )
3948 nNext = bValidPos ?
m_xPlcxMan->Where() : nTextEnd;
3956 if( (0 <= nNext) && (nSkipPos >= nNext) )
3958 if (nDepthGuard >= 1024)
3960 SAL_WARN(
"sw.ww8",
"ReadTextAttr hit recursion limit");
3964 nNext =
ReadTextAttr(rTextPos, nTextEnd, rbStartLine, nDepthGuard + 1);
3965 bDoPlcxManPlusPLus =
false;
3975 while( nSkipPos >= nNext );
3990 if( rTextPos >= rNext )
3995 if (rTextPos == rNext && rTextPos >= nTextEnd)
3998 while( rTextPos >= rNext );
4001 else if ( rbStartLine )
4011 rbStartLine =
false;
4024 std::stack<sal_uInt16> aStack;
4027 while (!aStack.empty())
4029 sal_uInt16 nSprmId = aStack.top();
4030 if ((0 < nSprmId) && ((
eFTN > nSprmId) || (0x0800 <= nSprmId)))
4042 bool bStartLine =
true;
4044 short nDistance = 0;
4068 if (nTextLen > nMaxPossible)
4070 SAL_WARN_IF(nTextLen > nMaxPossible,
"sw.ww8",
"TextLen too long");
4071 nTextLen = nMaxPossible;
4073 WW8_CP nTextEnd = nStartCp+nTextLen;
4074 while (l < nTextEnd)
4076 ReadAttrs( l, nNext, nTextEnd, bStartLine );
4085 bStartLine =
ReadChars(l, nNext, nTextEnd, nCpOfs);
4113 SAL_WARN_IF(!pEndNd,
"sw.ww8",
"didn't find textnode for dropcap");
4116 const sal_Int32 nDropCapLen = pPreviousNode->GetText().getLength();
4120 SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1);
4131 aDrop.
GetChars() = writer_cast<sal_uInt8>(nDropCapLen);
4137 else if(pNewSwCharFormat)
4153 aDCS =
m_xPlcxMan->GetPapPLCF()->HasSprm(46);
4155 aDCS =
m_xPlcxMan->GetPapPLCF()->HasSprm(0x442C);
4158 nDropLines = (*aDCS.
pSprm) >> 3;
4164 nDistance = SVBT16ToUInt16(
aDistance.pSprm);
4173 if (pSwFormatCharFormat)
4194 m_nProgress = o3tl::narrowing<sal_uInt16>(l * 100 / nTextLen);
4196 m_nProgress = o3tl::narrowing<sal_uInt16>(l / nTextLen * 100);
4248 : m_pDocShell(rD.GetDocShell())
4251 , m_pTableStream(nullptr)
4252 , m_pDataStream(nullptr)
4255 , m_aSectionManager(*this)
4256 , m_aExtraneousParas(rD)
4257 , m_aInsertedTables(rD)
4258 , m_aSectionNameGenerator(rD,
"WW")
4259 , m_aGrfNameGenerator(bNewDoc, OUString(
'G'))
4260 , m_aParaStyleMapper(rD)
4261 , m_aCharStyleMapper(rD)
4262 , m_pFlyFormatOfJustInsertedGraphic(nullptr)
4263 , m_pPreviousNumPaM(nullptr)
4264 , m_pPrevNumRule(nullptr)
4265 , m_pCurrentColl(nullptr)
4266 , m_pDfltTextFormatColl(nullptr)
4267 , m_pStandardFormatColl(nullptr)
4268 , m_pDrawModel(nullptr)
4269 , m_pDrawPg(nullptr)
4270 , m_pNumFieldType(nullptr)
4271 , m_sBaseURL(
std::move(aBaseURL))
4275 , m_bRegardHindiDigits( false )
4276 , m_bDrawCpOValid( false )
4282 , m_eTextCharSet(RTL_TEXTENCODING_ASCII_US)
4283 , m_eStructCharSet(RTL_TEXTENCODING_ASCII_US)
4284 , m_eHardCharSet(RTL_TEXTENCODING_DONTKNOW)
4288 , m_nLFOPosition(USHRT_MAX)
4295 , m_nWantedVersion(nVersionPara)
4296 , m_nSwNumLevel(0xff)
4297 , m_nWwNumType(0xff)
4298 , m_pChosenWW8OutlineStyle(nullptr)
4300 , m_bNewDoc(bNewDoc)
4301 , m_bSkipImages(bSkipImages)
4302 , m_bReadNoTable(false)
4303 , m_bPgSecBreak(false)
4306 , m_bTxbxFlySection(false)
4307 , m_bHasBorder(false)
4309 , m_bIgnoreText(false)
4311 , m_bWasTabRowEnd(false)
4312 , m_bWasTabCellEnd(false)
4314 , m_bHdFtFootnoteEdn(false)
4315 , m_bFootnoteEdn(false)
4316 , m_bIsHeader(false)
4317 , m_bIsFooter(false)
4318 , m_bIsUnicode(false)
4319 , m_bCpxStyle(false)
4320 , m_bStyNormal(false)
4321 , m_bWWBugNormal(false)
4322 , m_bNoAttrImport(false)
4323 , m_bInHyperlink(false)
4324 , m_bWasParaEnd(false)
4329 , m_bEmbeddObj(false)
4330 , m_bCurrentAND_fNumberAcross(false)
4331 , m_bNoLnNumYet(true)
4332 , m_bFirstPara(true)
4333 , m_bFirstParaOfPage(false)
4334 , m_bParaAutoBefore(false)
4335 , m_bParaAutoAfter(false)
4339 , m_bReadTable(false)
4340 , m_bLoadingTOXCache(false)
4341 , m_nEmbeddedTOXLevel(0)
4342 , m_bLoadingTOXHyperlink(false)
4343 , m_bCareFirstParaEndInToc(false)
4344 , m_bCareLastParaEndInToc(false)
4345 , m_bNotifyMacroEventRead(false)
4346 , m_bFuzzing(
utl::ConfigManager::IsFuzzing())
4367 OSL_ENSURE(
false,
"WW stack already deleted" );
4391 if (
aData.begin()->get()->nFlags & ShapeFlag::Background)
4410 SetPage(rPage, rFormat, rSection, bIgnoreCols);
4432 OSL_ENSURE(rSection.
mpPage,
"Makes no sense to call me with no pages to set");
4454 OSL_ENSURE(pApply,
"impossible");
4469 mySegIter const &rStart,
bool bIgnoreCols)
4482 OSL_ENSURE(rIter->mpPage,
"no page!");
4488 if (rIter != rStart)
4489 pPrevious = &(*(rIter-1));
4490 SetHdFt(*rIter, std::distance(rStart, rIter), pPrevious);
4498 rIter->mpPage->SetFollow(rIter->mpPage);
4500 if (rIter->PageRestartNo())
4511 for (
mySegIter aIter = aStart; aIter != aEnd; ++aIter)
4516 if ( aIter->maSep.bkc == 1 && aIter->maSep.ccolM1 > 0 )
4524 mySegIter aPrev = (aIter == aStart) ? aIter : aIter-1;
4528 bool bThisAndPreviousAreCompatible = ((aIter->GetPageWidth() == aPrev->GetPageWidth()) &&
4529 (aIter->GetPageHeight() == aPrev->GetPageHeight()) && (aIter->IsLandScape() == aPrev->IsLandScape()));
4531 bool bInsertSection = (aIter != aStart) && aIter->IsContinuous() && bThisAndPreviousAreCompatible;
4532 bool bInsertPageDesc = !bInsertSection;
4535 if (bInsertPageDesc)
4546 bool bIgnoreCols = bInsertSection;
4547 bool bThisAndNextAreCompatible = (aNext == aEnd) ||
4548 ((aIter->GetPageWidth() == aNext->GetPageWidth()) &&
4549 (aIter->GetPageHeight() == aNext->GetPageHeight()) &&
4550 (aIter->IsLandScape() == aNext->IsLandScape()));
4552 if ((aNext != aEnd && aNext->IsContinuous() && bThisAndNextAreCompatible) || bProtected)
4555 if ((aIter->NoCols() > 1) || bProtected)
4556 bInsertSection =
true;
4568 if ( aIter->maSep.bkc == 3 || aIter->maSep.bkc == 4 )
4579 *aIter = aTmpSection;
4583 if ( aIter->maSep.bkc == 4 )
4605 aAnchor = aNext->maStart;
4626 bool bHasOwnHdFt =
false;
4633 if (!bInsertPageDesc)
4638 aIter->maSep.grpfIhdt, std::distance(aStart, aIter)
4646 bool bFailed =
true;
4652 for(; nStart <= nEnd; ++nStart)
4668 aIter->mpPage = pOrig;
4685 if (aNext == aEnd || !aNext->IsContinuous())
4693 SwPaM aTest(*pTextNd);
4703 for (
auto aI =
m_aTextNodes.rbegin(); aI != aEnd; ++aI)
4709 SwPaM aTest(*pTextNode);
4726 SAL_WARN(
"sw.ww8",
"It is unexpected to drop a para scheduled for removal");
4731 : m_pTextNode(pTextNode)
4745 if (rHint.
GetId() != SfxHintId::SwLegacyModify)
4773 if (!m_xWwFib->m_lcbCmds)
4776 bool bValidPos =
checkSeek(*m_pTableStream, m_xWwFib->m_fcCmds);
4780 uno::Reference < embed::XStorage > xRoot(m_pDocShell->GetStorage());
4787 uno::Reference < io::XStream >
xStream =
4788 xRoot->openStreamElement(
SL::aMSMacroCmds, embed::ElementModes::READWRITE );
4791 sal_uInt32 lcbCmds = std::min<sal_uInt32>(m_xWwFib->m_lcbCmds, m_pTableStream->remainingSize());
4792 std::unique_ptr<sal_uInt8[]> xBuffer(
new sal_uInt8[lcbCmds]);
4793 m_xWwFib->m_lcbCmds = m_pTableStream->ReadBytes(xBuffer.get(), lcbCmds);
4794 xOutStream->WriteBytes(xBuffer.get(), m_xWwFib->m_lcbCmds);
4803 std::vector<OUString> aDocVarStrings;
4804 std::vector<ww::bytes> aDocVarStringIds;
4805 std::vector<OUString> aDocValueStrings;
4806 WW8ReadSTTBF(!m_bVer67, *m_pTableStream, m_xWwFib->m_fcStwUser,
4807 m_xWwFib->m_lcbStwUser, m_bVer67 ? 2 : 0, m_eStructCharSet,
4808 aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
4809 if (m_bVer67)
return;
4811 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4812 m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
4813 uno::Reference<document::XDocumentProperties> xDocProps(
4814 xDPS->getDocumentProperties());
4815 OSL_ENSURE(xDocProps.is(),
"DocumentProperties is null");
4816 uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
4817 xDocProps->getUserDefinedProperties();
4818 OSL_ENSURE(xUserDefinedProps.is(),
"UserDefinedProperties is null");
4820 for(
size_t i=0;
i<aDocVarStrings.size();
i++)
4822 const OUString &rName = aDocVarStrings[
i];
4826 xUserDefinedProps->addProperty( rName,
4827 beans::PropertyAttribute::REMOVABLE,
4829 }
catch (
const uno::Exception &) {
4843 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
4844 m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
4845 uno::Reference<document::XDocumentProperties> xDocProps(
4846 xDPS->getDocumentProperties());
4847 OSL_ENSURE(xDocProps.is(),
"DocumentProperties is null");
4849 if (!xDocProps.is())
4852 if ( m_xWwFib->m_fDot )
4854 SfxMedium* pMedium = m_pDocShell->GetMedium();
4860 if ( !sTemplateURL.isEmpty() )
4861 xDocProps->setTemplateURL( sTemplateURL );
4864 else if (m_xWwFib->m_lcbSttbfAssoc)
4866 auto nCur = m_pTableStream->Tell();
4869 if (!
checkSeek(*m_pTableStream, m_xWwFib->m_fcSttbfAssoc) || !aSttb.Read(*m_pTableStream))
4870 SAL_WARN(
"sw.ww8",
"** Read of SttbAssoc data failed!!!! ");
4871 m_pTableStream->Seek( nCur );
4872 OUString sPath = aSttb.getStringAtIndex( 0x1 );
4875 if ( !sPath.isEmpty() )
4876 osl::FileBase::getFileURLFromSystemPath( sPath,
aURL );
4878 xDocProps->setTemplateURL(
aURL );
4880 xDocProps->setTemplateURL( sPath );
4886static void lcl_createTemplateToProjectEntry(
const uno::Reference< container::XNameContainer >& xPrjNameCache,
const OUString& sTemplatePathOrURL,
const OUString& sVBAProjName )
4888 if ( !xPrjNameCache.is() )
4892 aObj.
SetURL( sTemplatePathOrURL );
4893 bool bIsURL = aObj.
GetProtocol() != INetProtocol::NotValid;
4896 aURL = sTemplatePathOrURL;
4899 osl::FileBase::getFileURLFromSystemPath( sTemplatePathOrURL,
aURL );
4904 OUString templateNameWithExt = aObj.
GetLastName();
4905 sal_Int32
nIndex = templateNameWithExt.lastIndexOf(
'.' );
4908 OUString templateName = templateNameWithExt.copy( 0,
nIndex );
4909 xPrjNameCache->insertByName( templateName,
uno::Any( sVBAProjName ) );
4912 catch(
const uno::Exception& )
4919class WW8Customizations
4930WW8Customizations::WW8Customizations(
SvStream* pTableStream,
WW8Fib const & rFib ) : mpTableStream(pTableStream), mWw8Fib( rFib )
4934void WW8Customizations::Import(
SwDocShell* pShell )
4936 if ( mWw8Fib.m_lcbCmds == 0 || !
IsEightPlus(mWw8Fib.GetFIBVersion()) )
4941 sal_uInt64 nCur = mpTableStream->Tell();
4942 if (!
checkSeek(*mpTableStream, mWw8Fib.m_fcCmds))
4944 SAL_WARN(
"sw.ww8",
"** Seek to Customization data failed!!!! ");
4947 bool bReadResult = aTCG.
Read( *mpTableStream );
4948 mpTableStream->Seek( nCur );
4951 SAL_WARN(
"sw.ww8",
"** Read of Customization data failed!!!! ");
4958 SAL_WARN(
"sw.ww8",
"** Read of Customization data failed!!!! epically");
4969 uno::Sequence< OUString > sGlobalTemplates;
4972 uno::Reference<ucb::XSimpleFileAccess3> xSFA(ucb::SimpleFileAccess::create(::comphelper::getProcessComponentContext()));
4974 if( xSFA->isFolder( aAddinPath ) )
4975 sGlobalTemplates = xSFA->getFolderContents( aAddinPath,
false );
4977 for (
const auto& rGlobalTemplate : std::as_const(sGlobalTemplates) )
4980 aObj.
SetURL( rGlobalTemplate );
4981 bool bIsURL = aObj.
GetProtocol() != INetProtocol::NotValid;
4984 aURL = rGlobalTemplate;
4986 osl::FileBase::getFileURLFromSystemPath( rGlobalTemplate,
aURL );
4987 if ( !
aURL.endsWithIgnoreAsciiCase(
".dot" ) || ( !sCreatedFrom.empty() && sCreatedFrom ==
aURL ) )
4992 BasicProjImportHelper aBasicImporter( *
m_pDocShell );
4998 refMainStream->SetEndian(SvStreamEndian::LITTLE);
4999 WW8Fib aWwFib( *refMainStream, 8 );
5003 if (xTableStream.
is() &&
ERRCODE_NONE == xTableStream->GetError())
5005 xTableStream->SetEndian(SvStreamEndian::LITTLE);
5006 WW8Customizations aGblCustomisations( xTableStream.
get(), aWwFib );
5021 uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(
xModel, uno::UNO_QUERY_THROW);
5025 uno::Reference<task::XInteractionHandler> xHandler;
5026 xDocumentMetadataAccess->loadMetadataFromStorage(xStorage, xBaseURI, xHandler);
5028 catch (
const uno::Exception&)
5035 auto pFibData = std::make_shared<::ww8::WW8FibData>();
5037 if (
m_xWwFib->m_fReadOnlyRecommended)
5038 pFibData->setReadOnlyRecommended(
true);
5040 pFibData->setReadOnlyRecommended(
false);
5043 pFibData->setWriteReservation(
true);
5045 pFibData->setWriteReservation(
false);