20 #include <com/sun/star/text/HoriOrientation.hpp>
21 #include <com/sun/star/text/VertOrientation.hpp>
22 #include <rtl/uri.hxx>
32 #include <osl/diagnose.h>
45 #include <section.hxx>
58 OUString aStyle, aLang, aDir;
60 SvxAdjust eAdjust = HtmlTokenId::CENTER_ON==nToken ? SvxAdjust::Center
63 bool bHeader=
false, bFooter=
false;
65 for (
size_t i = rHTMLOptions.size();
i; )
70 case HtmlOptionId::ID:
73 case HtmlOptionId::ALIGN:
74 if( HtmlTokenId::DIVISION_ON==nToken )
77 case HtmlOptionId::STYLE:
80 case HtmlOptionId::CLASS:
83 case HtmlOptionId::LANG:
86 case HtmlOptionId::DIR:
89 case HtmlOptionId::HREF:
92 case HtmlOptionId::TITLE:
94 const OUString& rType = rOption.
GetString();
95 if( rType.equalsIgnoreAsciiCase(
"header") )
97 else if( rType.equalsIgnoreAsciiCase(
"footer") )
105 bool bAppended =
false;
115 bool bStyleParsed =
false, bPositioned =
false;
121 aItemSet, aPropInfo, &aLang, &aDir );
124 if ( aPropInfo.m_nColumnCount >= 2 )
130 bPositioned = HtmlTokenId::DIVISION_ON == nToken && !aClass.isEmpty() &&
137 const std::unique_ptr<HTMLAttrContext>& pParent
139 if (!pParent->IsVisible())
142 aPropInfo.m_bVisible =
false;
145 bPositioned =
DoPositioning(aItemSet, aPropInfo, xCntxt.get());
153 xCntxt->SetHeaderOrFooter(
true);
203 pCNd =
m_xDoc->GetNodes().MakeTextNode( aSttIdx,
207 SwPaM aDelPam( aSttIdx );
215 if (
SwSection* pOldContent =
m_xDoc->InsertSwSection(aDelPam, aSection,
nullptr,
nullptr,
false))
219 for(
size_t i=0;
i <
m_xDoc->GetPageDescCnt();
i++ )
223 m_xDoc->ChgPageDesc(
i, *pPageDesc );
232 else if( !bPositioned && aId.getLength() > 9 &&
233 (aId[0] ==
's' || aId[0] ==
'S' ) &&
234 (aId[1] ==
'd' || aId[1] ==
'D' ) )
236 bool bEndNote =
false, bFootNote =
false;
241 if( bFootNote || bEndNote )
252 aPropInfo.m_aId.clear();
258 if( (!aId.isEmpty() && !bPositioned) || !aHRef.isEmpty() )
269 if (aPrvNdIdx.GetNode().IsSectionNode())
275 std::unique_ptr<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts(bAppended ?
nullptr :
new std::deque<std::unique_ptr<HTMLAttr>>);
276 SetAttr(
true,
true, pPostIts.get() );
279 const OUString
aName(
m_xDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId : nullptr ) );
281 if( !aHRef.isEmpty() )
284 sal_Int32
nPos = aHRef.lastIndexOf( cDelim );
285 sal_Int32 nPos2 = -1;
288 nPos2 = aHRef.lastIndexOf( cDelim, nPos );
291 sal_Int32 nTmp = nPos;
307 aURL += aHRef.subView( nPos+1 );
311 aURL += aHRef.subView( nPos+1, nPos2 - (nPos+1) )
313 + rtl::Uri::decode( aHRef.copy( nPos2+1 ),
314 rtl_UriDecodeWithCharset,
315 RTL_TEXTENCODING_ISO_8859_1 );
323 if( !aHRef.isEmpty() )
335 aFrameItemSet.Put( *pItem );
340 aFrameItemSet.Put( *pItem );
344 m_xDoc->InsertSwSection( *
m_pPam, aSection,
nullptr, &aFrameItemSet,
false );
371 xCntxt->SetSpansSection(
true );
374 if( !aPropInfo.m_aId.isEmpty() && aPropInfo.m_aId==aName )
375 aPropInfo.m_aId.clear();
382 if( SvxAdjust::End != eAdjust )
389 InsertAttrs( aItemSet, aPropInfo, xCntxt.get(), true );
391 xCntxt->SetVisible(aPropInfo.m_bVisible);
399 std::unique_ptr<HTMLAttrContext> xCntxt;
405 case HtmlTokenId::CENTER_ON:
406 case HtmlTokenId::DIVISION_ON:
419 if (xCntxt->IsHeaderOrFooter())
433 OSL_ENSURE( pHdFtFormat,
"No header or footer" );
448 sal_uInt16 nSpace = 0;
476 nPrvNxtIdx = rContentStIdx.
GetIndex() + 1;
479 pTextNode =
m_xDoc->GetNodes()[nPrvNxtIdx]
525 OSL_ENSURE(
false,
"Wrong PaM position at end of section" );
532 bool bSectionClosed =
false;
539 bSectionClosed =
true;
545 return bSectionClosed;
551 OUString aStyle, aClass, aLang, aDir;
553 sal_uInt16 nCols = columnsFromCss, nGutter = 10;
554 bool bPercentWidth =
true;
557 for (
size_t i = rHTMLOptions.size();
i; )
562 case HtmlOptionId::ID:
565 case HtmlOptionId::STYLE:
568 case HtmlOptionId::CLASS:
571 case HtmlOptionId::LANG:
574 case HtmlOptionId::DIR:
577 case HtmlOptionId::COLS:
578 nCols = o3tl::narrowing<sal_uInt16>(rOption.
GetNumber());
580 case HtmlOptionId::WIDTH:
582 bPercentWidth = (rOption.
GetString().indexOf(
'%') != -1);
583 if( bPercentWidth && nWidth>100 )
586 case HtmlOptionId::GUTTER:
587 nGutter = o3tl::narrowing<sal_uInt16>(rOption.
GetNumber());
593 std::unique_ptr<HTMLAttrContext> xCntxt(
new HTMLAttrContext(HtmlTokenId::MULTICOL_ON));
597 bool bInCntnr =
false;
600 bInCntnr =
nullptr !=
m_aContexts[--
i]->GetFrameItemSet();
603 bool bStyleParsed =
false;
608 aItemSet, aPropInfo, &aLang, &aDir );
617 MapMode(MapUnit::MapTwip) ).Width();
620 if( !nPercentWidth && nTwipWidth <
MINFLY )
624 bool bPositioned =
false;
636 SetVarSize( aPropInfo, aFrameItemSet, nTwipWidth, nPercentWidth );
638 SetSpace(
Size(0,0), aItemSet, aPropInfo, aFrameItemSet );
653 aPropInfo.m_aId.clear();
658 xCntxt->SetPopStack(
true );
662 bool bAppended =
false;
685 if (aPrvNdIdx.GetNode().IsSectionNode())
691 std::unique_ptr<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts(bAppended ?
nullptr :
new std::deque<std::unique_ptr<HTMLAttr>>);
692 SetAttr(
true,
true, pPostIts.get() );
695 OUString
aName(
m_xDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId : nullptr ) );
706 MapMode(MapUnit::MapTwip) ).Width());
711 aFormatCol.
Init( nCols, nGutter, USHRT_MAX );
712 aFrameItemSet.Put( aFormatCol );
716 aFrameItemSet.Put( *pItem );
721 aFrameItemSet.Put( *pItem );
724 m_xDoc->InsertSwSection( *
m_pPam, aSection,
nullptr, &aFrameItemSet,
false );
751 xCntxt->SetSpansSection(
true );
754 if( !aPropInfo.m_aId.isEmpty() && aPropInfo.m_aId==aName )
755 aPropInfo.m_aId.clear();
760 InsertAttrs( aItemSet, aPropInfo, xCntxt.get(), true );
767 const OUString& rName )
775 if( !rName.isEmpty() )
795 m_xDoc->GetNodes()[nDestIdx]->GetContentNode();
797 OSL_ENSURE( pDestContentNd,
"Why is the target not a Content-Node?" );
805 if( pFormatPageDesc && pFormatPageDesc->
GetPageDesc() )
807 pDestContentNd->
SetAttr( *pFormatPageDesc );
813 switch( pItem->GetBreak() )
815 case SvxBreak::PageBefore:
816 case SvxBreak::PageAfter:
817 case SvxBreak::PageBoth:
819 pDestContentNd->
SetAttr( *pItem );
835 pDestContentNd->
SetAttr(*pItem);
Starts a section of nodes in the document model.
bool EndSection(bool bLFStripped=false)
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
static void SetSpace(const Size &rPixSpace, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFlyItemSet)
void SetAnchorAndAdjustment(sal_Int16 eVertOri, sal_Int16 eHoriOri, const SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFrameSet)
EnumT GetEnum(const HTMLOptionEnum< EnumT > *pOptEnums, EnumT nDflt=static_cast< EnumT >(0)) const
HtmlOptionId GetToken() const
SwNodeOffset EndOfSectionIndex() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
Marks a position in the document model.
void SetAttr(bool bChkEnd=true, bool bBeforeTable=false, std::deque< std::unique_ptr< HTMLAttr >> *pPostIts=nullptr)
bool IsSectionNode() const
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
sal_uInt16 GetLower() const
void SetHidden(bool const bFlag)
SwPageDesc * GetPageDesc()
SAL_DLLPRIVATE void SetProtectFlag(bool const bFlag)
void FixHeaderFooterDistance(bool bHeader, const SwPosition *pOldPos)
void SetLinkFileName(OUString const &rNew)
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
bool CreateContainer(std::u16string_view rClass, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, HTMLAttrContext *pContext)
const sal_Unicode cTokenSeparator
const OUString & GetString() const
constexpr sal_uInt16 RES_FRMATR_END(133)
HTMLAttrContexts m_aContexts
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
Content, content of frame (header, footer, fly).
bool m_bReadingHeaderOrFooter
SwTableFormat * GetFrameFormat()
static OutputDevice * GetDefaultDevice()
void NewDivision(HtmlTokenId nToken)
static void ResetFrameFormatAttrs(SfxItemSet &rFrameSet)
SwTableNode * GetTableNode()
void InsertAttrs(std::deque< std::unique_ptr< HTMLAttr >> rAttrs)
bool ParseStyleOptions(const OUString &rStyle, const OUString &rId, const OUString &rClass, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
const SwTable & GetTable() const
SwNodeOffset GetIndex() const
#define OOO_STRING_SVTOOLS_HTML_sdfootnote
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
void InsertAttr(const SfxPoolItem &rItem, bool bInsAtStart)
SwFormatColl & GetAnyFormatColl() const
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
static void SetFrameFormatAttrs(SfxItemSet &rItemSet, HtmlFrameFormatFlags nFlags, SfxItemSet &rFrameItemSet)
bool IsContentNode() const
PaM is Point and Mark: a selection of the document model.
SwNodeIndex * GetFootEndNoteSection(const OUString &rName)
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwStartNode * StartOfSectionNode() const
const SwPosition * GetPoint() const
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
SwContentNode * GetContentNode()
void EndContext(HTMLAttrContext *pContext)
Marks a character position inside a document model node.
bool DoPositioning(SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, HTMLAttrContext *pContext)
void SetSpansSection(bool bSet)
Marks a node in the document model.
void RegisterFlyFrame(SwFrameFormat *pFlyFrame)
void InsertFlyFrame(const SfxItemSet &rItemSet, HTMLAttrContext *pCntxt, const OUString &rId)
sal_uInt32 GetNumber() const
const SwNodeIndex * GetContentIdx() const
void NewMultiCol(sal_uInt16 columnsFromCss=0)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SwFrameFormat & GetMaster()
SwTextNode is a paragraph in the document model.
void MovePageDescAttrs(SwNode *pSrcNd, SwNodeOffset nDestIdx, bool bFormatBreak)
bool EndSections(bool bLFStripped)
virtual bool SetAttr(const SfxPoolItem &)
made virtual
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
HTMLOptionEnum< SvxAdjust > const aHTMLPAlignTable[]
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define OOO_STRING_SVTOOLS_HTML_sdendnote
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
::std::vector< HTMLOption > HTMLOptions
sal_Int32 GetIndex() const
static void SetVarSize(SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet, SwTwips nDfltWidth=MINLAY, sal_uInt8 nDefaultPercentWidth=0)
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
SwMoveFnCollection const & fnMoveBackward
Ends a section of nodes in the document model.
std::shared_ptr< HTMLAttrTable > m_xAttrTab
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
bool AppendTextNode(SwHTMLAppendMode eMode=AM_NORMAL, bool bUpdateNum=true)
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
void PushContext(std::unique_ptr< HTMLAttrContext > &rCntxt)
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
rtl::Reference< SwDoc > m_xDoc
void SaveDocContext(HTMLAttrContext *pCntxt, HtmlContextFlags nFlags, const SwPosition *pNewPos)
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
bool GetSpansSection() const
static bool MayBePositioned(const SvxCSS1PropertyInfo &rPropInfo, bool bAutoWidth=false)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
static bool HasStyleOptions(std::u16string_view rStyle, std::u16string_view rId, std::u16string_view rClass, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
sal_uInt16 GetUpper() const
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
Base class of the Writer document model elements.