LibreOffice Module sw (master)  1
htmlcss1.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <hintids.hxx>
21 #include <svl/itemiter.hxx>
22 #include <svl/urihelper.hxx>
24 #include <sfx2/docfile.hxx>
25 #include <editeng/editids.hrc>
26 #include <editeng/fhgtitem.hxx>
27 #include <editeng/brushitem.hxx>
28 #include <editeng/lrspitem.hxx>
29 #include <editeng/ulspitem.hxx>
30 #include <editeng/boxitem.hxx>
31 #include <editeng/flstitem.hxx>
33 #include <editeng/keepitem.hxx>
34 #include <editeng/fontitem.hxx>
35 #include <editeng/langitem.hxx>
36 #include <editeng/frmdiritem.hxx>
37 #include <svtools/htmltokn.h>
38 #include <svtools/htmlkywd.hxx>
39 #include <fmtpdsc.hxx>
40 #include <fmtanchr.hxx>
41 #include <fmtornt.hxx>
42 #include <fmtsrnd.hxx>
43 #include <fmtfsize.hxx>
44 #include <frmatr.hxx>
45 #include <charfmt.hxx>
46 #include <docary.hxx>
47 #include <osl/diagnose.h>
48 
49 #include <doc.hxx>
51 #include <pam.hxx>
52 #include <poolfmt.hxx>
53 #include <docsh.hxx>
54 #include <paratr.hxx>
55 #include <pagedesc.hxx>
56 #include "css1kywd.hxx"
57 #include "swcss1.hxx"
58 #include "htmlnum.hxx"
59 #include "swhtml.hxx"
60 #include <numrule.hxx>
61 #include "css1atr.hxx"
62 
63 using namespace ::com::sun::star;
64 
65 // How many rows/characters are allowed for DropCaps?
66 // (Are there maybe somewhere else corresponding values?)
67 #define MAX_DROPCAP_LINES 9
68 #define MAX_DROPCAP_CHARS 9
69 
70 static void lcl_swcss1_setEncoding( SwFormat& rFormat, rtl_TextEncoding eEnc );
71 
72 // Implementation of SwCSS1Parsers (actually swcss1.cxx)
73 static const sal_uInt16 aItemIds[] =
74 {
75  RES_BREAK,
77  RES_KEEP,
78 };
79 
80 void SwCSS1Parser::ChgPageDesc( const SwPageDesc *pPageDesc,
81  const SwPageDesc& rNewPageDesc )
82 {
83  size_t pos;
84  bool found = m_pDoc->ContainsPageDesc( pPageDesc, &pos );
85  OSL_ENSURE( found, "style not found" );
86  if (found)
87  m_pDoc->ChgPageDesc( pos, rNewPageDesc );
88 }
89 
90 SwCSS1Parser::SwCSS1Parser(SwDoc *const pDoc, SwHTMLParser const& rParser,
91  const sal_uInt32 aFHeights[7], const OUString& rBaseURL, bool const bNewDoc)
92  : SvxCSS1Parser(pDoc->GetAttrPool(), rBaseURL,
94  , m_pDoc( pDoc )
95  , m_rHTMLParser(rParser)
96  , m_nDropCapCnt( 0 ),
97  m_bIsNewDoc( bNewDoc ),
98  m_bBodyBGColorSet( false ),
99  m_bBodyBackgroundSet( false ),
100  m_bBodyTextSet( false ),
101  m_bBodyLinkSet( false ),
102  m_bBodyVLinkSet( false ),
103  m_bSetFirstPageDesc( false ),
104  m_bSetRightPageDesc( false ),
105  m_bTableHeaderTextCollSet( false ),
106  m_bTableTextCollSet( false ),
107  m_bLinkCharFormatsSet( false )
108 {
109  m_aFontHeights[0] = aFHeights[0];
110  m_aFontHeights[1] = aFHeights[1];
111  m_aFontHeights[2] = aFHeights[2];
112  m_aFontHeights[3] = aFHeights[3];
113  m_aFontHeights[4] = aFHeights[4];
114  m_aFontHeights[5] = aFHeights[5];
115  m_aFontHeights[6] = aFHeights[6];
116 }
117 
119 {
120 }
121 
122 // Feature: PrintExt
124  const SvxCSS1PropertyInfo& rPropInfo )
125 {
126  SvxBreak eBreak = SvxBreak::NONE;
127  bool bKeep = false;
128  bool bSetKeep = false, bSetBreak = false, bSetPageDesc = false;
129  const SwPageDesc *pPageDesc = nullptr;
130  switch( rPropInfo.m_ePageBreakBefore )
131  {
133  eBreak = SvxBreak::PageBefore;
134  bSetBreak = true;
135  break;
137  pPageDesc = GetLeftPageDesc( true );
138  bSetPageDesc = true;
139  break;
141  pPageDesc = GetRightPageDesc( true );
142  bSetPageDesc = true;
143  break;
145  bSetBreak = bSetPageDesc = true;
146  break;
147  default:
148  ;
149  }
150  switch( rPropInfo.m_ePageBreakAfter )
151  {
155  // LEFT/RIGHT also could be set in the previous paragraph
156  eBreak = SvxBreak::PageAfter;
157  bSetBreak = true;
158  break;
160  bSetBreak = bSetKeep = bSetPageDesc = true;
161  break;
163  bKeep = bSetKeep = true;
164  break;
165  default:
166  ;
167  }
168 
169  if( bSetBreak )
170  rItemSet.Put( SvxFormatBreakItem( eBreak, RES_BREAK ) );
171  if( bSetPageDesc )
172  rItemSet.Put( SwFormatPageDesc( pPageDesc ) );
173  if( bSetKeep )
174  rItemSet.Put( SvxFormatKeepItem( bKeep, RES_KEEP ) );
175 
176  return bSetBreak;
177 }
178 
179 static void SetCharFormatAttrs( SwCharFormat *pCharFormat, SfxItemSet& rItemSet )
180 {
181  const SfxPoolItem *pItem;
182  static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
184  for(sal_uInt16 i : aWhichIds)
185  {
186  if( SfxItemState::SET == rItemSet.GetItemState( i, false,
187  &pItem ) &&
188  static_cast<const SvxFontHeightItem *>(pItem)->GetProp() != 100)
189  {
190  // percentage values at the FontHeight item aren't supported
191  rItemSet.ClearItem( i );
192  }
193  }
194 
195  pCharFormat->SetFormatAttr( rItemSet );
196 
197  if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
198  {
199  // A Brush-Item with RES_BACKGROUND must be converted to one
200  // with RES_CHRATR_BACKGROUND
201 
202  SvxBrushItem aBrushItem( *static_cast<const SvxBrushItem *>(pItem) );
203  aBrushItem.SetWhich( RES_CHRATR_BACKGROUND );
204  pCharFormat->SetFormatAttr( aBrushItem );
205  }
206 
207  if( SfxItemState::SET == rItemSet.GetItemState( RES_BOX, false, &pItem ) )
208  {
209  SvxBoxItem aBoxItem( *static_cast<const SvxBoxItem *>(pItem) );
210  aBoxItem.SetWhich( RES_CHRATR_BOX );
211  pCharFormat->SetFormatAttr( aBoxItem );
212  }
213 }
214 
216 {
217  OSL_ENSURE( !m_bLinkCharFormatsSet, "Call SetLinkCharFormats unnecessary" );
218 
219  SvxCSS1MapEntry *pStyleEntry =
221  SwCharFormat *pUnvisited = nullptr, *pVisited = nullptr;
222  if( pStyleEntry )
223  {
224  SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
225  bool bColorSet = (SfxItemState::SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
226  false));
228  SetCharFormatAttrs( pUnvisited, rItemSet );
229  m_bBodyLinkSet |= bColorSet;
230 
232  SetCharFormatAttrs( pVisited, rItemSet );
233  m_bBodyVLinkSet |= bColorSet;
234  }
235 
236  OUString sTmp = OOO_STRING_SVTOOLS_HTML_anchor ":link";
237 
238  pStyleEntry = GetTag( sTmp );
239  if( pStyleEntry )
240  {
241  SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
242  bool bColorSet = (SfxItemState::SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
243  false));
244  if( !pUnvisited )
246  SetCharFormatAttrs( pUnvisited, rItemSet );
247  m_bBodyLinkSet |= bColorSet;
248  }
249 
250  sTmp = OOO_STRING_SVTOOLS_HTML_anchor ":visited";
251 
252  pStyleEntry = GetTag( sTmp );
253  if( pStyleEntry )
254  {
255  SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
256  bool bColorSet = (SfxItemState::SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
257  false));
258  if( !pVisited )
260  SetCharFormatAttrs( pVisited, rItemSet );
261  m_bBodyVLinkSet |= bColorSet;
262  }
263 
264  m_bLinkCharFormatsSet = true;
265 }
266 
267 static void SetTextCollAttrs( SwTextFormatColl *pColl, SfxItemSet& rItemSet,
268  SvxCSS1PropertyInfo const & rPropInfo,
269  SwCSS1Parser *pCSS1Parser )
270 {
271  const SfxItemSet& rCollItemSet = pColl->GetAttrSet();
272  const SfxPoolItem *pCollItem, *pItem;
273 
274  // left, right border and first line indentation
275  if( (rPropInfo.m_bLeftMargin || rPropInfo.m_bRightMargin ||
276  rPropInfo.m_bTextIndent) &&
277  (!rPropInfo.m_bLeftMargin || !rPropInfo.m_bRightMargin ||
278  !rPropInfo.m_bTextIndent) &&
279  SfxItemState::SET == rCollItemSet.GetItemState(RES_LR_SPACE,true,&pCollItem) &&
280  SfxItemState::SET == rItemSet.GetItemState(RES_LR_SPACE,false,&pItem) )
281  {
282  const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
283 
284  SvxLRSpaceItem aLRItem( *static_cast<const SvxLRSpaceItem *>(pCollItem) );
285  if( rPropInfo.m_bLeftMargin )
286  aLRItem.SetTextLeft( pLRItem->GetTextLeft() );
287  if( rPropInfo.m_bRightMargin )
288  aLRItem.SetRight( pLRItem->GetRight() );
289  if( rPropInfo.m_bTextIndent )
290  aLRItem.SetTextFirstLineOffset( pLRItem->GetTextFirstLineOffset() );
291 
292  rItemSet.Put( aLRItem );
293  }
294 
295  // top and bottom border
296  if( (rPropInfo.m_bTopMargin || rPropInfo.m_bBottomMargin) &&
297  (!rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin) &&
298  SfxItemState::SET == rCollItemSet.GetItemState(RES_UL_SPACE,true,
299  &pCollItem) &&
300  SfxItemState::SET == rItemSet.GetItemState(RES_UL_SPACE,false,&pItem) )
301  {
302  const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
303 
304  SvxULSpaceItem aULItem( *static_cast<const SvxULSpaceItem *>(pCollItem) );
305  if( rPropInfo.m_bTopMargin )
306  aULItem.SetUpper( pULItem->GetUpper() );
307  if( rPropInfo.m_bBottomMargin )
308  aULItem.SetLower( pULItem->GetLower() );
309 
310  rItemSet.Put( aULItem );
311  }
312 
313  static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,RES_CHRATR_CJK_FONTSIZE,
315  for(sal_uInt16 i : aWhichIds)
316  {
317  if( SfxItemState::SET == rItemSet.GetItemState( i, false,
318  &pItem ) &&
319  static_cast<const SvxFontHeightItem *>(pItem)->GetProp() != 100)
320  {
321  // percentage values at the FontHeight item aren't supported
322  rItemSet.ClearItem( i );
323  }
324  }
325 
326  pCSS1Parser->SetFormatBreak( rItemSet, rPropInfo );
327 
328  pColl->SetFormatAttr( rItemSet );
329 }
330 
331 void SwCSS1Parser::SetTableTextColl( bool bHeader )
332 {
333  OSL_ENSURE( !(bHeader ? m_bTableHeaderTextCollSet : m_bTableTextCollSet),
334  "Call SetTableTextColl unnecessary" );
335 
336  sal_uInt16 nPoolId;
337  OUString sTag;
338  if( bHeader )
339  {
340  nPoolId = RES_POOLCOLL_TABLE_HDLN;
342  }
343  else
344  {
345  nPoolId = RES_POOLCOLL_TABLE;
347  }
348 
349  SwTextFormatColl *pColl = nullptr;
350 
351  // The following entries will never be used again and may be changed.
352  SvxCSS1MapEntry *pStyleEntry = GetTag( sTag );
353  if( pStyleEntry )
354  {
355  pColl = GetTextFormatColl(nPoolId, OUString());
356  SetTextCollAttrs( pColl, pStyleEntry->GetItemSet(),
357  pStyleEntry->GetPropertyInfo(), this );
358  }
359 
360  OUString sTmp = sTag + " " OOO_STRING_SVTOOLS_HTML_parabreak;
361  pStyleEntry = GetTag( sTmp );
362  if( pStyleEntry )
363  {
364  if( !pColl )
365  pColl = GetTextFormatColl(nPoolId, OUString());
366  SetTextCollAttrs( pColl, pStyleEntry->GetItemSet(),
367  pStyleEntry->GetPropertyInfo(), this );
368  }
369 
370  if( bHeader )
372  else
373  m_bTableTextCollSet = true;
374 }
375 
377  SfxItemSet *pItemSet2 )
378 {
379  std::shared_ptr<SvxBrushItem> aBrushItem(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
380  std::shared_ptr<SvxBoxItem> aBoxItem(std::make_shared<SvxBoxItem>(RES_BOX));
381  std::shared_ptr<SvxFrameDirectionItem> aFrameDirItem(std::make_shared<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR));
382  bool bSetBrush = pBrush!=nullptr, bSetBox = false, bSetFrameDir = false;
383  if( pBrush )
384  aBrushItem.reset(pBrush->Clone());
385 
386  if( pItemSet2 )
387  {
388  const SfxPoolItem *pItem = nullptr;
389  if( SfxItemState::SET == pItemSet2->GetItemState( RES_BACKGROUND, false,
390  &pItem ) )
391  {
392  // set a background
393  aBrushItem.reset(static_cast<SvxBrushItem*>(pItem->Clone()));
394  pItemSet2->ClearItem( RES_BACKGROUND );
395  bSetBrush = true;
396  }
397 
398  if( SfxItemState::SET == pItemSet2->GetItemState( RES_BOX, false, &pItem ) )
399  {
400  // set a border
401  aBoxItem.reset(static_cast<SvxBoxItem*>(pItem->Clone()));
402  pItemSet2->ClearItem( RES_BOX );
403  bSetBox = true;
404  }
405 
406  if( SfxItemState::SET == pItemSet2->GetItemState( RES_FRAMEDIR, false, &pItem ) )
407  {
408  // set a frame
409  aFrameDirItem.reset(static_cast<SvxFrameDirectionItem*>(pItem->Clone()));
410  pItemSet2->ClearItem( RES_FRAMEDIR );
411  bSetFrameDir = true;
412  }
413  }
414 
415  if( bSetBrush || bSetBox || bSetFrameDir )
416  {
417  static sal_uInt16 aPoolIds[] = { RES_POOLPAGE_HTML, RES_POOLPAGE_FIRST,
419  for(sal_uInt16 i : aPoolIds)
420  {
421  const SwPageDesc *pPageDesc = GetPageDesc( i, false );
422  if( pPageDesc )
423  {
424  SwPageDesc aNewPageDesc( *pPageDesc );
425  SwFrameFormat &rMaster = aNewPageDesc.GetMaster();
426  if( bSetBrush )
427  rMaster.SetFormatAttr( *aBrushItem );
428  if( bSetBox )
429  rMaster.SetFormatAttr( *aBoxItem );
430  if( bSetFrameDir )
431  rMaster.SetFormatAttr( *aFrameDirItem );
432 
433  ChgPageDesc( pPageDesc, aNewPageDesc );
434  }
435  }
436  }
437 }
438 
439 // Feature: PrintExt
441  SfxItemSet& rItemSet,
442  const SvxCSS1PropertyInfo& rPropInfo )
443 {
444  if( !pPageDesc )
445  return;
446 
447  SwPageDesc aNewPageDesc( *pPageDesc );
448  SwFrameFormat &rMaster = aNewPageDesc.GetMaster();
449  const SfxItemSet& rPageItemSet = rMaster.GetAttrSet();
450  const SfxPoolItem *pPageItem, *pItem;
451  bool bChanged = false;
452 
453  // left, right border and first line indentation
454  if( (rPropInfo.m_bLeftMargin || rPropInfo.m_bRightMargin) &&
455  SfxItemState::SET == rItemSet.GetItemState(RES_LR_SPACE,false,&pItem) )
456  {
457  if( (!rPropInfo.m_bLeftMargin || !rPropInfo.m_bRightMargin) &&
458  SfxItemState::SET == rPageItemSet.GetItemState(RES_LR_SPACE,
459  true,&pPageItem) )
460  {
461  const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
462 
463  SvxLRSpaceItem aLRItem( *static_cast<const SvxLRSpaceItem *>(pPageItem) );
464  if( rPropInfo.m_bLeftMargin )
465  aLRItem.SetLeft( pLRItem->GetLeft() );
466  if( rPropInfo.m_bRightMargin )
467  aLRItem.SetRight( pLRItem->GetRight() );
468 
469  rMaster.SetFormatAttr( aLRItem );
470  }
471  else
472  {
473  rMaster.SetFormatAttr( *pItem );
474  }
475  bChanged = true;
476  }
477 
478  // top and bottom border
479  if( (rPropInfo.m_bTopMargin || rPropInfo.m_bBottomMargin) &&
480  SfxItemState::SET == rItemSet.GetItemState(RES_UL_SPACE,false,&pItem) )
481  {
482  if( (!rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin) &&
483  SfxItemState::SET == rPageItemSet.GetItemState(RES_UL_SPACE,
484  true,&pPageItem) )
485  {
486  const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
487 
488  SvxULSpaceItem aULItem( *static_cast<const SvxULSpaceItem *>(pPageItem) );
489  if( rPropInfo.m_bTopMargin )
490  aULItem.SetUpper( pULItem->GetUpper() );
491  if( rPropInfo.m_bBottomMargin )
492  aULItem.SetLower( pULItem->GetLower() );
493 
494  rMaster.SetFormatAttr( aULItem );
495  }
496  else
497  {
498  rMaster.SetFormatAttr( *pItem );
499  }
500  bChanged = true;
501  }
502 
503  // the size
504  if( rPropInfo.m_eSizeType != SVX_CSS1_STYPE_NONE )
505  {
506  if( rPropInfo.m_eSizeType == SVX_CSS1_STYPE_TWIP )
507  {
509  rPropInfo.m_nHeight ) );
510  bChanged = true;
511  }
512  else
513  {
514  // With "size: auto|portrait|landscape" the current size
515  // of the style remains. If "landscape" and "portrait" then
516  // the landscape flag will be set and maybe the width/height
517  // are swapped.
518  SwFormatFrameSize aFrameSz( rMaster.GetFrameSize() );
519  bool bLandscape = aNewPageDesc.GetLandscape();
520  if( ( bLandscape &&
521  rPropInfo.m_eSizeType == SVX_CSS1_STYPE_PORTRAIT ) ||
522  ( !bLandscape &&
523  rPropInfo.m_eSizeType == SVX_CSS1_STYPE_LANDSCAPE ) )
524  {
525  SwTwips nTmp = aFrameSz.GetHeight();
526  aFrameSz.SetHeight( aFrameSz.GetWidth() );
527  aFrameSz.SetWidth( nTmp );
528  rMaster.SetFormatAttr( aFrameSz );
529  aNewPageDesc.SetLandscape( !bLandscape );
530  bChanged = true;
531  }
532  }
533  }
534 
535  // Is that possible?
536  if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
537  {
538  // set a background
539  rMaster.SetFormatAttr( *pItem );
540  rItemSet.ClearItem( RES_BACKGROUND );
541  bChanged = true;
542  }
543 
544  if( bChanged )
545  ChgPageDesc( pPageDesc, aNewPageDesc );
546 }
547 
548 std::shared_ptr<SvxBrushItem> SwCSS1Parser::makePageDescBackground() const
549 {
552 }
553 
555  bool bSubClassOnly )
556 {
558  sal_Int32 nLen = rClass.getLength();
559  sal_Int32 nPos = nLen > 4 ? rClass.lastIndexOf( '-' ) : -1;
560 
561  if( nPos == -1 )
562  {
563  if( bSubClassOnly )
564  return nScriptFlags;
565  nPos = 0;
566  }
567  else
568  {
569  nPos++;
570  nLen = nLen - nPos;
571  }
572 
573  switch( nLen )
574  {
575  case 3:
576  if( rClass.matchIgnoreAsciiCase( "cjk", nPos ) )
577  {
578  nScriptFlags = Css1ScriptFlags::CJK;
579  }
580  else if( rClass.matchIgnoreAsciiCase( "ctl", nPos ) )
581  {
582  nScriptFlags = Css1ScriptFlags::CTL;
583  }
584  break;
585  case 7:
586  if( rClass.matchIgnoreAsciiCase( "western", nPos ) )
587  {
588  nScriptFlags = Css1ScriptFlags::Western;
589  }
590  break;
591  }
592  if( Css1ScriptFlags::AllMask != nScriptFlags )
593  {
594  if( nPos )
595  {
596  rClass = rClass.copy( 0, nPos-1 );
597  }
598  else
599  {
600  rClass.clear();
601  }
602  }
603 
604  return nScriptFlags;
605 }
606 
608  OUString& rToken, OUString& rClass,
609  Css1ScriptFlags& rScriptFlags )
610 {
611  rToken = pSelector->GetString();
612  rClass.clear();
613  rScriptFlags = Css1ScriptFlags::AllMask;
614 
615  CSS1SelectorType eType = pSelector->GetType();
616  if( CSS1_SELTYPE_ELEM_CLASS==eType )
617  {
618  sal_Int32 nPos = rToken.indexOf( '.' );
619  OSL_ENSURE( nPos >= 0, "No dot in Class-Selector???" );
620  if( nPos >= 0 )
621  {
622  rClass = rToken.copy( nPos+1 );
623  rToken = rToken.copy( 0, nPos );
624 
625  rScriptFlags = SwCSS1Parser::GetScriptFromClass( rClass, false );
626  if( rClass.isEmpty() )
627  eType = CSS1_SELTYPE_ELEMENT;
628  }
629  }
630 
631  rToken = rToken.toAsciiLowerCase();
632  return eType;
633 }
634 
635 static void RemoveScriptItems( SfxItemSet& rItemSet, Css1ScriptFlags nScript,
636  const SfxItemSet *pParentItemSet = nullptr )
637 {
638  static const sal_uInt16 aWhichIds[3][5] =
639  {
646  };
647 
648  bool aClearItems[3] = { false, false, false };
649  switch( nScript )
650  {
652  aClearItems[1] = aClearItems[2] = true;
653  break;
655  aClearItems[0] = aClearItems[2] = true;
656  break;
658  aClearItems[0] = aClearItems[1] = true;
659  break;
661  break;
662  default:
663  OSL_ENSURE( aClearItems[0], "unknown script type" );
664  break;
665  }
666 
667  for( size_t j=0; j < SAL_N_ELEMENTS(aWhichIds); ++j )
668  {
669  for( size_t i=0; i < SAL_N_ELEMENTS(aWhichIds[0]); ++i )
670  {
671  sal_uInt16 nWhich = aWhichIds[j][i];
672  const SfxPoolItem *pItem;
673  if( aClearItems[j] ||
674  (pParentItemSet &&
675  SfxItemState::SET == rItemSet.GetItemState( nWhich, false, &pItem ) &&
676  (0==i ? swhtml_css1atr_equalFontItems( *pItem, pParentItemSet->Get(nWhich ) )
677  : *pItem == pParentItemSet->Get(nWhich ) ) ) )
678  {
679  rItemSet.ClearItem( nWhich );
680  }
681  }
682  }
683 }
684 
686  SfxItemSet& rItemSet,
687  SvxCSS1PropertyInfo& rPropInfo )
688 {
689  if( !m_bIsNewDoc )
690  return;
691 
692  CSS1SelectorType eSelType = pSelector->GetType();
693  const CSS1Selector *pNext = pSelector->GetNext();
694 
695  if( CSS1_SELTYPE_ID==eSelType && !pNext )
696  {
697  InsertId( pSelector->GetString(), rItemSet, rPropInfo );
698  }
699  else if( CSS1_SELTYPE_CLASS==eSelType && !pNext )
700  {
701  OUString aClass( pSelector->GetString() );
702  Css1ScriptFlags nScript = GetScriptFromClass( aClass );
703  if( Css1ScriptFlags::AllMask != nScript )
704  {
705  SfxItemSet aScriptItemSet( rItemSet );
706  RemoveScriptItems( aScriptItemSet, nScript );
707  InsertClass( aClass, aScriptItemSet, rPropInfo );
708  }
709  else
710  {
711  InsertClass( aClass, rItemSet, rPropInfo );
712  }
713  }
714  else if( CSS1_SELTYPE_PAGE==eSelType )
715  {
716  if( !pNext ||
717  (CSS1_SELTYPE_PSEUDO == pNext->GetType() &&
718  (pNext->GetString().equalsIgnoreAsciiCase( "left" ) ||
719  pNext->GetString().equalsIgnoreAsciiCase( "right" ) ||
720  pNext->GetString().equalsIgnoreAsciiCase( "first" ) ) ) )
721  {
722  OUString aName;
723  if( pNext )
724  aName = pNext->GetString();
725  InsertPage( aName,
726  pNext != nullptr,
727  rItemSet, rPropInfo );
728  }
729  }
730 
731  if( CSS1_SELTYPE_ELEMENT != eSelType &&
732  CSS1_SELTYPE_ELEM_CLASS != eSelType)
733  return;
734 
735  // get token and class of selector
736  OUString aToken2;
737  OUString aClass;
738  Css1ScriptFlags nScript;
739  eSelType = GetTokenAndClass( pSelector, aToken2, aClass, nScript );
740  HtmlTokenId nToken2 = GetHTMLToken( aToken2 );
741 
742  // and also some information of the next element
743  CSS1SelectorType eNextType = pNext ? pNext->GetType()
745 
746  // first some special cases
747  if( CSS1_SELTYPE_ELEMENT==eSelType )
748  {
749  switch( nToken2 )
750  {
751  case HtmlTokenId::ANCHOR_ON:
752  if( !pNext )
753  {
754  InsertTag( aToken2, rItemSet, rPropInfo );
755  return;
756  }
757  else if (CSS1_SELTYPE_PSEUDO == eNextType)
758  {
759  // maybe A:visited or A:link
760 
761  OUString aPseudo( pNext->GetString() );
762  aPseudo = aPseudo.toAsciiLowerCase();
763  bool bInsert = false;
764  switch( aPseudo[0] )
765  {
766  case 'l':
767  if( aPseudo == "link" )
768  {
769  bInsert = true;
770  }
771  break;
772  case 'v':
773  if( aPseudo == "visited" )
774  {
775  bInsert = true;
776  }
777  break;
778  }
779  if( bInsert )
780  {
781  OUString sTmp = aToken2 + ":" + aPseudo;
782  if( Css1ScriptFlags::AllMask != nScript )
783  {
784  SfxItemSet aScriptItemSet( rItemSet );
785  RemoveScriptItems( aScriptItemSet, nScript );
786  InsertTag( sTmp, aScriptItemSet, rPropInfo );
787  }
788  else
789  {
790  InsertTag( sTmp, rItemSet, rPropInfo );
791  }
792  return;
793  }
794  }
795  break;
796  case HtmlTokenId::BODY_ON:
797  if( !pNext )
798  {
799  // BODY
800 
801  // We must test the background before setting, because
802  // in SetPageDescAttrs it will be deleted.
803  const SfxPoolItem *pItem;
804  if( SfxItemState::SET==rItemSet.GetItemState(RES_BACKGROUND,false,&pItem) )
805  {
806  const SvxBrushItem *pBrushItem =
807  static_cast<const SvxBrushItem *>(pItem);
808 
810  if( pBrushItem->GetColor() != COL_TRANSPARENT )
811  m_bBodyBGColorSet = true;
812  if( GPOS_NONE != pBrushItem->GetGraphicPos() )
813  m_bBodyBackgroundSet = true;
814  }
815 
816  // Border and Padding
817  rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST );
818 
819  // Some attributes must be set at the style, the ones which
820  // aren't inherited
821  SetPageDescAttrs( nullptr, &rItemSet );
822 
823  // all remaining options can be set at the default style,
824  // then they're the default
825  if( SfxItemState::SET==rItemSet.GetItemState(RES_CHRATR_COLOR,false) )
826  m_bBodyTextSet = true;
829  rItemSet, rPropInfo, this );
830 
831  return;
832  }
833  break;
834  default: break;
835  }
836  }
837  else if( CSS1_SELTYPE_ELEM_CLASS==eSelType && HtmlTokenId::ANCHOR_ON==nToken2 &&
838  !pNext && aClass.getLength() >= 9 &&
839  ('s' == aClass[0] || 'S' == aClass[0]) )
840  {
841  sal_uInt16 nPoolFormatId = 0;
842  if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdendnote_sym) )
843  nPoolFormatId = RES_POOLCHR_ENDNOTE;
844  else if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdfootnote_sym) )
845  nPoolFormatId = RES_POOLCHR_FOOTNOTE;
846  if( nPoolFormatId )
847  {
848  if( Css1ScriptFlags::AllMask == nScript )
849  {
850  SetCharFormatAttrs( GetCharFormatFromPool(nPoolFormatId), rItemSet );
851  }
852  else
853  {
854  SfxItemSet aScriptItemSet( rItemSet );
855  RemoveScriptItems( aScriptItemSet, nScript );
857  aScriptItemSet);
858  }
859  return;
860  }
861  }
862 
863  // Now the selectors are processed which belong to a paragraph style
864  sal_uInt16 nPoolCollId = 0;
865  switch( nToken2 )
866  {
867  case HtmlTokenId::HEAD1_ON:
868  nPoolCollId = RES_POOLCOLL_HEADLINE1;
869  break;
870  case HtmlTokenId::HEAD2_ON:
871  nPoolCollId = RES_POOLCOLL_HEADLINE2;
872  break;
873  case HtmlTokenId::HEAD3_ON:
874  nPoolCollId = RES_POOLCOLL_HEADLINE3;
875  break;
876  case HtmlTokenId::HEAD4_ON:
877  nPoolCollId = RES_POOLCOLL_HEADLINE4;
878  break;
879  case HtmlTokenId::HEAD5_ON:
880  nPoolCollId = RES_POOLCOLL_HEADLINE5;
881  break;
882  case HtmlTokenId::HEAD6_ON:
883  nPoolCollId = RES_POOLCOLL_HEADLINE6;
884  break;
885  case HtmlTokenId::PARABREAK_ON:
886  if( aClass.getLength() >= 9 &&
887  ('s' == aClass[0] || 'S' == aClass[0]) )
888  {
889  if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdendnote) )
890  nPoolCollId = RES_POOLCOLL_ENDNOTE;
891  else if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdfootnote) )
892  nPoolCollId = RES_POOLCOLL_FOOTNOTE;
893 
894  if( nPoolCollId )
895  aClass.clear();
896  else
897  nPoolCollId = RES_POOLCOLL_TEXT;
898  }
899  else
900  {
901  nPoolCollId = RES_POOLCOLL_TEXT;
902  }
903  break;
904  case HtmlTokenId::ADDRESS_ON:
905  nPoolCollId = RES_POOLCOLL_SENDADRESS;
906  break;
907  case HtmlTokenId::BLOCKQUOTE_ON:
908  nPoolCollId = RES_POOLCOLL_HTML_BLOCKQUOTE;
909  break;
910  case HtmlTokenId::DT_ON:
911  nPoolCollId = RES_POOLCOLL_HTML_DT;
912  break;
913  case HtmlTokenId::DD_ON:
914  nPoolCollId = RES_POOLCOLL_HTML_DD;
915  break;
916  case HtmlTokenId::PREFORMTXT_ON:
917  nPoolCollId = RES_POOLCOLL_HTML_PRE;
918  break;
919  case HtmlTokenId::TABLEHEADER_ON:
920  case HtmlTokenId::TABLEDATA_ON:
921  if( CSS1_SELTYPE_ELEMENT==eSelType && !pNext )
922  {
923  InsertTag( aToken2, rItemSet, rPropInfo );
924  return;
925  }
926  else if( CSS1_SELTYPE_ELEMENT==eSelType && pNext &&
927  (CSS1_SELTYPE_ELEMENT==eNextType ||
928  CSS1_SELTYPE_ELEM_CLASS==eNextType) )
929  {
930  // not TH and TD, but TH P and TD P
931  OUString aSubToken, aSubClass;
932  GetTokenAndClass( pNext, aSubToken, aSubClass, nScript );
933  if( HtmlTokenId::PARABREAK_ON == GetHTMLToken( aSubToken ) )
934  {
935  aClass = aSubClass;
936  pNext = pNext->GetNext();
937  eNextType = pNext ? pNext->GetType() : CSS1_SELTYPE_ELEMENT;
938 
939  if( !aClass.isEmpty() || pNext )
940  {
941  nPoolCollId = static_cast< sal_uInt16 >(
942  HtmlTokenId::TABLEHEADER_ON == nToken2 ? RES_POOLCOLL_TABLE_HDLN
943  : RES_POOLCOLL_TABLE );
944  }
945  else
946  {
947  OUString sTmp = aToken2 + " " OOO_STRING_SVTOOLS_HTML_parabreak;
948 
949  if( Css1ScriptFlags::AllMask == nScript )
950  {
951  InsertTag( sTmp, rItemSet, rPropInfo );
952  }
953  else
954  {
955  SfxItemSet aScriptItemSet( rItemSet );
956  RemoveScriptItems( aScriptItemSet, nScript );
957  InsertTag( sTmp, aScriptItemSet, rPropInfo );
958  }
959 
960  return;
961  }
962  }
963  }
964  break;
965 
966  default:
967  ;
968  }
969 
970  if( nPoolCollId )
971  {
972  if( !pNext ||
973  (CSS1_SELTYPE_PSEUDO==eNextType &&
974  pNext->GetString().equalsIgnoreAsciiCase( "first-letter" ) &&
975  SvxAdjust::Left == rPropInfo.m_eFloat) )
976  {
977  // either not a composed selector or a X:first-line { float: left; ... }
978 
979  // search resp. create the style
980  SwTextFormatColl* pColl = GetTextFormatColl(nPoolCollId, OUString());
981  SwTextFormatColl* pParentColl = nullptr;
982  if( !aClass.isEmpty() )
983  {
984  OUString aName( pColl->GetName() );
985  AddClassName( aName, aClass );
986 
987  pParentColl = pColl;
989  if( !pColl )
990  pColl = m_pDoc->MakeTextFormatColl( aName, pParentColl );
991  }
992  if( !pNext )
993  {
994  // set only the attributes at the style
995  const SfxPoolItem *pItem;
996  const SvxBoxItem *pBoxItem = nullptr;
997  if( SfxItemState::SET ==
998  pColl->GetAttrSet().GetItemState(RES_BOX,true,&pItem) )
999  pBoxItem = static_cast<const SvxBoxItem *>(pItem);
1000  rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST, pBoxItem );
1001  if( Css1ScriptFlags::AllMask == nScript && !pParentColl )
1002  {
1003  SetTextCollAttrs( pColl, rItemSet, rPropInfo, this );
1004  }
1005  else
1006  {
1007  SfxItemSet aScriptItemSet( rItemSet );
1008  RemoveScriptItems( aScriptItemSet, nScript,
1009  pParentColl ? &pParentColl->GetAttrSet() : nullptr );
1010  SetTextCollAttrs( pColl, aScriptItemSet, rPropInfo, this );
1011  }
1012  }
1013  else
1014  {
1015  // create a DropCap attribute
1016  SwFormatDrop aDrop( pColl->GetDrop() );
1017  aDrop.GetChars() = 1;
1018 
1019  // set the attributes of the DropCap attribute
1020  if( Css1ScriptFlags::AllMask == nScript )
1021  {
1022  OUString sName(pColl->GetName());
1023  FillDropCap( aDrop, rItemSet, &sName );
1024  }
1025  else
1026  {
1027  SfxItemSet aScriptItemSet( rItemSet );
1028  if( Css1ScriptFlags::Western != nScript )
1029  {
1030  aScriptItemSet.ClearItem( RES_CHRATR_FONT );
1031  aScriptItemSet.ClearItem( RES_CHRATR_LANGUAGE );
1032  aScriptItemSet.ClearItem( RES_CHRATR_POSTURE );
1033  aScriptItemSet.ClearItem( RES_CHRATR_WEIGHT );
1034  }
1035  if( Css1ScriptFlags::CJK != nScript )
1036  {
1037  aScriptItemSet.ClearItem( RES_CHRATR_CJK_FONT );
1038  aScriptItemSet.ClearItem( RES_CHRATR_CJK_LANGUAGE );
1039  aScriptItemSet.ClearItem( RES_CHRATR_CJK_POSTURE );
1040  aScriptItemSet.ClearItem( RES_CHRATR_CJK_WEIGHT );
1041  }
1042  if( Css1ScriptFlags::CTL != nScript )
1043  {
1044  aScriptItemSet.ClearItem( RES_CHRATR_CTL_FONT );
1045  aScriptItemSet.ClearItem( RES_CHRATR_CTL_LANGUAGE );
1046  aScriptItemSet.ClearItem( RES_CHRATR_CTL_POSTURE );
1047  aScriptItemSet.ClearItem( RES_CHRATR_CTL_WEIGHT );
1048  }
1049  OUString sName(pColl->GetName());
1050  FillDropCap( aDrop, aScriptItemSet, &sName );
1051  }
1052 
1053  // Only set the attribute if "float: left" is specified and
1054  // the Initial is over several lines. Otherwise the maybe
1055  // created character style will be later searched and set
1056  // via name.
1057  if( aDrop.GetLines() > 1 &&
1058  (SvxAdjust::Left == rPropInfo.m_eFloat ||
1059  Css1ScriptFlags::AllMask == nScript) )
1060  {
1061  pColl->SetFormatAttr( aDrop );
1062  }
1063  }
1064  }
1065 
1066  return;
1067  }
1068 
1069  // Now the selectors are processed which are belonging to the character
1070  // template. There are no composed ones here.
1071  if( pNext )
1072  return;
1073 
1074  SwCharFormat* pCFormat = GetChrFormat(nToken2, OUString());
1075  if( pCFormat )
1076  {
1077  SwCharFormat *pParentCFormat = nullptr;
1078  if( !aClass.isEmpty() )
1079  {
1080  OUString aName( pCFormat->GetName() );
1081  AddClassName( aName, aClass );
1082  pParentCFormat = pCFormat;
1083 
1084  pCFormat = m_pDoc->FindCharFormatByName( aName );
1085  if( !pCFormat )
1086  {
1087  pCFormat = m_pDoc->MakeCharFormat( aName, pParentCFormat );
1088  pCFormat->SetAuto(false);
1089  }
1090  }
1091 
1092  if( Css1ScriptFlags::AllMask == nScript && !pParentCFormat )
1093  {
1094  SetCharFormatAttrs( pCFormat, rItemSet );
1095  }
1096  else
1097  {
1098  SfxItemSet aScriptItemSet( rItemSet );
1099  RemoveScriptItems( aScriptItemSet, nScript,
1100  pParentCFormat ? &pParentCFormat->GetAttrSet() : nullptr );
1101  SetCharFormatAttrs( pCFormat, aScriptItemSet );
1102  }
1103  }
1104 }
1105 
1106 sal_uInt32 SwCSS1Parser::GetFontHeight( sal_uInt16 nSize ) const
1107 {
1108  return m_aFontHeights[ std::min<sal_uInt16>(nSize,6) ];
1109 }
1110 
1112 {
1113  const FontList *pFList = nullptr;
1114  SwDocShell *pDocSh = m_pDoc->GetDocShell();
1115  if( pDocSh )
1116  {
1117  const SvxFontListItem *pFListItem =
1118  static_cast<const SvxFontListItem *>(pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
1119  if( pFListItem )
1120  pFList = pFListItem->GetFontList();
1121  }
1122 
1123  return pFList;
1124 }
1125 
1126 SwCharFormat* SwCSS1Parser::GetChrFormat( HtmlTokenId nToken2, const OUString& rClass ) const
1127 {
1128  // search the corresponding style
1129  sal_uInt16 nPoolId = 0;
1130  const char* sName = nullptr;
1131  switch( nToken2 )
1132  {
1133  case HtmlTokenId::EMPHASIS_ON: nPoolId = RES_POOLCHR_HTML_EMPHASIS; break;
1134  case HtmlTokenId::CITIATION_ON: nPoolId = RES_POOLCHR_HTML_CITIATION; break;
1135  case HtmlTokenId::STRONG_ON: nPoolId = RES_POOLCHR_HTML_STRONG; break;
1136  case HtmlTokenId::CODE_ON: nPoolId = RES_POOLCHR_HTML_CODE; break;
1137  case HtmlTokenId::SAMPLE_ON: nPoolId = RES_POOLCHR_HTML_SAMPLE; break;
1138  case HtmlTokenId::KEYBOARD_ON: nPoolId = RES_POOLCHR_HTML_KEYBOARD; break;
1139  case HtmlTokenId::VARIABLE_ON: nPoolId = RES_POOLCHR_HTML_VARIABLE; break;
1140  case HtmlTokenId::DEFINSTANCE_ON: nPoolId = RES_POOLCHR_HTML_DEFINSTANCE; break;
1141  case HtmlTokenId::TELETYPE_ON: nPoolId = RES_POOLCHR_HTML_TELETYPE; break;
1142 
1143  case HtmlTokenId::SHORTQUOTE_ON: sName = OOO_STRING_SVTOOLS_HTML_shortquote; break;
1144  case HtmlTokenId::LANGUAGE_ON: sName = OOO_STRING_SVTOOLS_HTML_language; break;
1145  case HtmlTokenId::AUTHOR_ON: sName = OOO_STRING_SVTOOLS_HTML_author; break;
1146  case HtmlTokenId::PERSON_ON: sName = OOO_STRING_SVTOOLS_HTML_person; break;
1147  case HtmlTokenId::ACRONYM_ON: sName = OOO_STRING_SVTOOLS_HTML_acronym; break;
1148  case HtmlTokenId::ABBREVIATION_ON: sName = OOO_STRING_SVTOOLS_HTML_abbreviation; break;
1149  case HtmlTokenId::INSERTEDTEXT_ON: sName = OOO_STRING_SVTOOLS_HTML_insertedtext; break;
1150  case HtmlTokenId::DELETEDTEXT_ON: sName = OOO_STRING_SVTOOLS_HTML_deletedtext; break;
1151  default: break;
1152  }
1153 
1154  // search or create the style (only possible with name)
1155  if( !nPoolId && !sName )
1156  return nullptr;
1157 
1158  // search or create style (without class)
1159  SwCharFormat *pCFormat = nullptr;
1160  if( nPoolId )
1161  {
1162  pCFormat = GetCharFormatFromPool( nPoolId );
1163  }
1164  else
1165  {
1166  OUString sCName( OUString::createFromAscii(sName) );
1167  pCFormat = m_pDoc->FindCharFormatByName( sCName );
1168  if( !pCFormat )
1169  {
1170  pCFormat = m_pDoc->MakeCharFormat( sCName, m_pDoc->GetDfltCharFormat() );
1171  pCFormat->SetAuto(false);
1172  }
1173  }
1174 
1175  OSL_ENSURE( pCFormat, "No character style???" );
1176 
1177  // If a class exists, then search for the class style but don't
1178  // create one.
1179  OUString aClass( rClass );
1180  GetScriptFromClass( aClass, false );
1181  if( !aClass.isEmpty() )
1182  {
1183  OUString aTmp( pCFormat->GetName() );
1184  AddClassName( aTmp, aClass );
1185  SwCharFormat *pClassCFormat = m_pDoc->FindCharFormatByName( aTmp );
1186  if( pClassCFormat )
1187  {
1188  pCFormat = pClassCFormat;
1189  }
1190  else
1191  {
1192  const SvxCSS1MapEntry *pClass = GetClass( aClass );
1193  if( pClass )
1194  {
1195  pCFormat = m_pDoc->MakeCharFormat( aTmp, pCFormat );
1196  pCFormat->SetAuto(false);
1197  SfxItemSet aItemSet( pClass->GetItemSet() );
1198  SetCharFormatAttrs( pCFormat, aItemSet );
1199  }
1200  }
1201  }
1202 
1203  return pCFormat;
1204 }
1205 
1207 {
1209 
1211 
1212  if( m_bIsNewDoc )
1213  {
1215  for( SwTextFormatColls::size_type i=nOldArrLen; i<nArrLen; ++i )
1217  GetDfltEncoding() );
1218  }
1219 
1220  return pColl;
1221 }
1222 
1224 {
1225  const SwCharFormats::size_type nOldArrLen = m_pDoc->GetCharFormats()->size();
1226 
1228 
1229  if( m_bIsNewDoc )
1230  {
1231  const SwCharFormats::size_type nArrLen = m_pDoc->GetCharFormats()->size();
1232 
1233  for( SwCharFormats::size_type i=nOldArrLen; i<nArrLen; i++ )
1235  GetDfltEncoding() );
1236  }
1237 
1238  return pCharFormat;
1239 }
1240 
1242  const OUString& rClass )
1243 {
1244  SwTextFormatColl* pColl = nullptr;
1245 
1246  OUString aClass( rClass );
1247  GetScriptFromClass( aClass, false );
1248  if( RES_POOLCOLL_TEXT == nTextColl && aClass.getLength() >= 9 &&
1249  ('s' == aClass[0] || 'S' == aClass[0] ) )
1250  {
1251  if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdendnote) )
1252  {
1253  nTextColl = RES_POOLCOLL_ENDNOTE;
1254  aClass.clear();
1255  }
1256  else if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdfootnote) )
1257  {
1258  nTextColl = RES_POOLCOLL_FOOTNOTE;
1259  aClass.clear();
1260  }
1261  }
1262 
1263  if( USER_FMT & nTextColl ) // one created by Reader
1264  {
1265  OSL_ENSURE( false, "Where does the user style comes from?" );
1267  }
1268  else
1269  {
1270  pColl = GetTextCollFromPool( nTextColl );
1271  }
1272 
1273  OSL_ENSURE( pColl, "No paragraph style???" );
1274  if( !aClass.isEmpty() )
1275  {
1276  OUString aTmp( pColl->GetName() );
1277  AddClassName( aTmp, aClass );
1278  SwTextFormatColl* pClassColl = m_pDoc->FindTextFormatCollByName( aTmp );
1279 
1280  if( !pClassColl &&
1281  (nTextColl==RES_POOLCOLL_TABLE ||
1282  nTextColl==RES_POOLCOLL_TABLE_HDLN) )
1283  {
1284  // In this case there was a <TD><P CLASS=foo>, but no TD.foo
1285  // style was found. The we must use P.foo, if available.
1286  SwTextFormatColl* pCollText =
1288  aTmp = pCollText->GetName();
1289  AddClassName( aTmp, aClass );
1290  pClassColl = m_pDoc->FindTextFormatCollByName( aTmp );
1291  }
1292 
1293  if( pClassColl )
1294  {
1295  pColl = pClassColl;
1296  }
1297  else
1298  {
1299  const SvxCSS1MapEntry *pClass = GetClass( aClass );
1300  if( pClass )
1301  {
1302  pColl = m_pDoc->MakeTextFormatColl( aTmp, pColl );
1303  SfxItemSet aItemSet( pClass->GetItemSet() );
1304  SvxCSS1PropertyInfo aPropInfo( pClass->GetPropertyInfo() );
1305  aPropInfo.SetBoxItem( aItemSet, MIN_BORDER_DIST );
1306  bool bPositioned = MayBePositioned( pClass->GetPropertyInfo() );
1307  if( bPositioned )
1308  aItemSet.ClearItem( RES_BACKGROUND );
1309  SetTextCollAttrs( pColl, aItemSet, aPropInfo,
1310  this );
1311  }
1312  }
1313 
1314  }
1315 
1316  if( pColl )
1318 
1319  return pColl;
1320 }
1321 
1323 {
1325 }
1326 
1327 static SwPageDesc *FindPageDesc(SwDoc *pDoc, sal_uInt16 nPoolId)
1328 {
1329  size_t nPageDescs = pDoc->GetPageDescCnt();
1330  size_t nPage;
1331  for (nPage=0; nPage < nPageDescs &&
1332  pDoc->GetPageDesc(nPage).GetPoolFormatId() != nPoolId; ++nPage)
1333  ;
1334 
1335  return nPage < nPageDescs ? &pDoc->GetPageDesc(nPage) : nullptr;
1336 }
1337 
1338 const SwPageDesc *SwCSS1Parser::GetPageDesc( sal_uInt16 nPoolId, bool bCreate )
1339 {
1340  if( RES_POOLPAGE_HTML == nPoolId )
1342 
1343  const SwPageDesc *pPageDesc = FindPageDesc(m_pDoc, nPoolId);
1344  if( !pPageDesc && bCreate )
1345  {
1347  { // (there should be only one definition of header/footer in HTML)
1348  SAL_WARN("sw.html", "no creating PageDesc while reading header/footer");
1349  return nullptr;
1350  }
1351 
1352  // The first page is created from the right page, if there is one.
1353  SwPageDesc *pMasterPageDesc = nullptr;
1354  if( RES_POOLPAGE_FIRST == nPoolId )
1355  pMasterPageDesc = FindPageDesc(m_pDoc, RES_POOLPAGE_RIGHT);
1356  if( !pMasterPageDesc )
1358 
1359  // The new page style is created by copying from master
1360  SwPageDesc *pNewPageDesc = m_pDoc->
1361  getIDocumentStylePoolAccess().GetPageDescFromPool( nPoolId, false );
1362 
1363  // therefore we also need the number of the new style
1364  OSL_ENSURE(pNewPageDesc == FindPageDesc(m_pDoc, nPoolId), "page style not found");
1365 
1366  m_pDoc->CopyPageDesc( *pMasterPageDesc, *pNewPageDesc, false );
1367 
1368  // Modify the styles for their new purpose.
1369  const SwPageDesc *pFollow = nullptr;
1370  bool bSetFollowFollow = false;
1371  switch( nPoolId )
1372  {
1373  case RES_POOLPAGE_FIRST:
1374  // If there is already a left page, then is it the follow-up
1375  // style, else it is the HTML style.
1376  pFollow = GetLeftPageDesc();
1377  if( !pFollow )
1378  pFollow = pMasterPageDesc;
1379  break;
1380 
1381  case RES_POOLPAGE_RIGHT:
1382  // If the left style is already created, nothing will happen here.
1383  // Otherwise the left style is created and ensures the link with
1384  // the right style.
1385  GetLeftPageDesc( true );
1386  break;
1387 
1388  case RES_POOLPAGE_LEFT:
1389  // The right style is created if none exists. No links are created.
1390  // If there is already a first page style, then the left style becomes
1391  // follow-up style of the first page.
1392  pFollow = GetRightPageDesc( true );
1393  bSetFollowFollow = true;
1394  {
1395  const SwPageDesc *pFirstPageDesc = GetFirstPageDesc();
1396  if( pFirstPageDesc )
1397  {
1398  SwPageDesc aNewFirstPageDesc( *pFirstPageDesc );
1399  aNewFirstPageDesc.SetFollow( pNewPageDesc );
1400  ChgPageDesc( pFirstPageDesc, aNewFirstPageDesc );
1401  }
1402  }
1403  break;
1404  }
1405 
1406  if( pFollow )
1407  {
1408  SwPageDesc aNewPageDesc( *pNewPageDesc );
1409  aNewPageDesc.SetFollow( pFollow );
1410  ChgPageDesc( pNewPageDesc, aNewPageDesc );
1411 
1412  if( bSetFollowFollow )
1413  {
1414  SwPageDesc aNewFollowPageDesc( *pFollow );
1415  aNewFollowPageDesc.SetFollow( pNewPageDesc );
1416  ChgPageDesc( pFollow, aNewFollowPageDesc );
1417  }
1418  }
1419  pPageDesc = pNewPageDesc;
1420  }
1421 
1422  return pPageDesc;
1423 }
1424 
1426  bool bAutoWidth )
1427 {
1428  // abs-pos
1429  // left/top none auto twip perc
1430 
1431  // none Z Z - -
1432  // auto Z Z - -
1433  // twip Z Z S/R -
1434  // perc - - - -
1435 
1436  // - the tag will be positioned absolutely and left/top are both
1437  // present and don't contain a percentage value, or
1438  // - the tag should flow, and
1439  // - a width was specified (needed in both cases)
1440  return ( ( SVX_CSS1_POS_ABSOLUTE == rPropInfo.m_ePosition &&
1441  SVX_CSS1_LTYPE_PERCENTAGE != rPropInfo.m_eLeftType &&
1442  SVX_CSS1_LTYPE_PERCENTAGE != rPropInfo.m_eTopType &&
1443  (SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eLeftType ||
1444  SVX_CSS1_LTYPE_TWIP != rPropInfo.m_eTopType) ) ||
1445  ( SvxAdjust::End != rPropInfo.m_eFloat ) ) &&
1446  ( bAutoWidth ||
1447  SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eWidthType ||
1448  SVX_CSS1_LTYPE_PERCENTAGE == rPropInfo.m_eWidthType );
1449 }
1450 
1451 void SwCSS1Parser::AddClassName( OUString& rFormatName, const OUString& rClass )
1452 {
1453  OSL_ENSURE( !rClass.isEmpty(), "Style class without length?" );
1454 
1455  rFormatName += "." + rClass;
1456 }
1457 
1459  SfxItemSet& rItemSet,
1460  const OUString *pName )
1461 {
1462  // the number of lines matches somehow a percentage value
1463  // for the height (what happens with absolute heights???)
1464  sal_uInt8 nLines = rDrop.GetLines();
1465  const SfxPoolItem *pItem;
1466  if( SfxItemState::SET == rItemSet.GetItemState( RES_CHRATR_FONTSIZE, false, &pItem ) )
1467  {
1468  sal_uInt16 nProp = static_cast<const SvxFontHeightItem *>(pItem)->GetProp();
1469  nLines = static_cast<sal_uInt8>((nProp + 50) / 100);
1470  if( nLines < 1 )
1471  nLines = 1;
1472  else if( nLines > MAX_DROPCAP_LINES )
1473  nLines = MAX_DROPCAP_LINES;
1474 
1475  // Only when nLines>1, then the attribute also is set. Then
1476  // we don't need the font height in the character style.
1477  if( nLines > 1 )
1478  {
1479  rItemSet.ClearItem( RES_CHRATR_FONTSIZE );
1480  rItemSet.ClearItem( RES_CHRATR_CJK_FONTSIZE );
1481  rItemSet.ClearItem( RES_CHRATR_CTL_FONTSIZE );
1482  }
1483  }
1484 
1485  // In case of hard attribution (pName==0) we can stop, if the Initial is
1486  // only one line.
1487  if( nLines<=1 )
1488  return;
1489 
1490  rDrop.GetLines() = nLines;
1491 
1492  // a right border becomes the spacing to text!
1493  if( SfxItemState::SET == rItemSet.GetItemState( RES_LR_SPACE, false, &pItem ) )
1494  {
1495  rDrop.GetDistance() = static_cast< sal_uInt16 >(
1496  static_cast<const SvxLRSpaceItem *>(pItem)->GetRight() );
1497  rItemSet.ClearItem( RES_LR_SPACE );
1498  }
1499 
1500  // for every other attribute create a character style
1501  if( rItemSet.Count() )
1502  {
1503  SwCharFormat *pCFormat = nullptr;
1504  OUString aName;
1505  if( pName )
1506  {
1507  aName = *pName + ".FL"; // first letter
1508  pCFormat = m_pDoc->FindCharFormatByName( aName );
1509  }
1510  else
1511  {
1512  do
1513  {
1514  aName = "first-letter " + OUString::number( static_cast<sal_Int32>(++m_nDropCapCnt) );
1515  }
1516  while( m_pDoc->FindCharFormatByName(aName) );
1517  }
1518 
1519  if( !pCFormat )
1520  {
1521  pCFormat = m_pDoc->MakeCharFormat( aName, m_pDoc->GetDfltCharFormat() );
1522  pCFormat->SetAuto(false);
1523  }
1524  SetCharFormatAttrs( pCFormat, rItemSet );
1525 
1526  // The character style needs only be set in the attribute, when
1527  // the attribute also is set.
1528  if( nLines > 1 )
1529  rDrop.SetCharFormat( pCFormat );
1530  }
1531 }
1532 
1533 // specific CSS1 of SwHTMLParsers
1534 
1536 {
1537  // find the table entry of the item ...
1538  HTMLAttr **ppAttr = nullptr;
1539  switch( nWhich )
1540  {
1541  case RES_CHRATR_BLINK:
1542  ppAttr = &m_xAttrTab->pBlink;
1543  break;
1544  case RES_CHRATR_CASEMAP:
1545  ppAttr = &m_xAttrTab->pCaseMap;
1546  break;
1547  case RES_CHRATR_COLOR:
1548  ppAttr = &m_xAttrTab->pFontColor;
1549  break;
1550  case RES_CHRATR_CROSSEDOUT:
1551  ppAttr = &m_xAttrTab->pStrike;
1552  break;
1553  case RES_CHRATR_ESCAPEMENT:
1554  ppAttr = &m_xAttrTab->pEscapement;
1555  break;
1556  case RES_CHRATR_FONT:
1557  ppAttr = &m_xAttrTab->pFont;
1558  break;
1559  case RES_CHRATR_CJK_FONT:
1560  ppAttr = &m_xAttrTab->pFontCJK;
1561  break;
1562  case RES_CHRATR_CTL_FONT:
1563  ppAttr = &m_xAttrTab->pFontCTL;
1564  break;
1565  case RES_CHRATR_FONTSIZE:
1566  ppAttr = &m_xAttrTab->pFontHeight;
1567  break;
1569  ppAttr = &m_xAttrTab->pFontHeightCJK;
1570  break;
1572  ppAttr = &m_xAttrTab->pFontHeightCTL;
1573  break;
1574  case RES_CHRATR_KERNING:
1575  ppAttr = &m_xAttrTab->pKerning;
1576  break;
1577  case RES_CHRATR_POSTURE:
1578  ppAttr = &m_xAttrTab->pItalic;
1579  break;
1581  ppAttr = &m_xAttrTab->pItalicCJK;
1582  break;
1584  ppAttr = &m_xAttrTab->pItalicCTL;
1585  break;
1586  case RES_CHRATR_UNDERLINE:
1587  ppAttr = &m_xAttrTab->pUnderline;
1588  break;
1589  case RES_CHRATR_WEIGHT:
1590  ppAttr = &m_xAttrTab->pBold;
1591  break;
1592  case RES_CHRATR_CJK_WEIGHT:
1593  ppAttr = &m_xAttrTab->pBoldCJK;
1594  break;
1595  case RES_CHRATR_CTL_WEIGHT:
1596  ppAttr = &m_xAttrTab->pBoldCTL;
1597  break;
1598  case RES_CHRATR_BACKGROUND:
1599  ppAttr = &m_xAttrTab->pCharBrush;
1600  break;
1601  case RES_CHRATR_BOX:
1602  ppAttr = &m_xAttrTab->pCharBox;
1603  break;
1604 
1606  ppAttr = &m_xAttrTab->pLineSpacing;
1607  break;
1608  case RES_PARATR_ADJUST:
1609  ppAttr = &m_xAttrTab->pAdjust;
1610  break;
1611 
1612  case RES_LR_SPACE:
1613  ppAttr = &m_xAttrTab->pLRSpace;
1614  break;
1615  case RES_UL_SPACE:
1616  ppAttr = &m_xAttrTab->pULSpace;
1617  break;
1618  case RES_BOX:
1619  ppAttr = &m_xAttrTab->pBox;
1620  break;
1621  case RES_BACKGROUND:
1622  ppAttr = &m_xAttrTab->pBrush;
1623  break;
1624  case RES_BREAK:
1625  ppAttr = &m_xAttrTab->pBreak;
1626  break;
1627  case RES_PAGEDESC:
1628  ppAttr = &m_xAttrTab->pPageDesc;
1629  break;
1630  case RES_PARATR_SPLIT:
1631  ppAttr = &m_xAttrTab->pSplit;
1632  break;
1633  case RES_PARATR_WIDOWS:
1634  ppAttr = &m_xAttrTab->pWidows;
1635  break;
1636  case RES_PARATR_ORPHANS:
1637  ppAttr = &m_xAttrTab->pOrphans;
1638  break;
1639  case RES_KEEP:
1640  ppAttr = &m_xAttrTab->pKeep;
1641  break;
1642 
1643  case RES_CHRATR_LANGUAGE:
1644  ppAttr = &m_xAttrTab->pLanguage;
1645  break;
1647  ppAttr = &m_xAttrTab->pLanguageCJK;
1648  break;
1650  ppAttr = &m_xAttrTab->pLanguageCTL;
1651  break;
1652 
1653  case RES_FRAMEDIR:
1654  ppAttr = &m_xAttrTab->pDirection;
1655  break;
1656  }
1657 
1658  return ppAttr;
1659 }
1660 
1662 {
1663  OUString sType;
1664 
1665  const HTMLOptions& rOptions2 = GetOptions();
1666  for (size_t i = rOptions2.size(); i; )
1667  {
1668  const HTMLOption& rOption = rOptions2[--i];
1669  if( HtmlOptionId::TYPE == rOption.GetToken() )
1670  sType = rOption.GetString();
1671  }
1672 
1673  m_bIgnoreRawData = sType.getLength() &&
1674  !sType.getToken(0,';').equalsAscii(sCSS_mimetype);
1675 }
1676 
1678 {
1679  m_bIgnoreRawData = false;
1680 
1681  if( !m_aStyleSource.isEmpty() )
1682  {
1683  m_pCSS1Parser->ParseStyleSheet( m_aStyleSource );
1684  m_aStyleSource.clear();
1685  }
1686 }
1687 
1688 bool SwHTMLParser::FileDownload( const OUString& rURL,
1689  OUString& rStr )
1690 {
1691  // depose view (because of reschedule)
1692  SwViewShell *pOldVSh = CallEndAction();
1693 
1694  SfxMedium aDLMedium( rURL, StreamMode::READ | StreamMode::SHARE_DENYWRITE );
1695 
1696  SvStream* pStream = aDLMedium.GetInStream();
1697  if( pStream )
1698  {
1699  SvMemoryStream aStream;
1700  aStream.WriteStream( *pStream );
1701 
1702  rStr = OUString(static_cast<const char *>(aStream.GetData()), aStream.TellEnd(),
1703  GetSrcEncoding());
1704  }
1705 
1706  // was aborted?
1707  if( ( m_xDoc->GetDocShell() && m_xDoc->GetDocShell()->IsAbortingImport() )
1708  || 1 == m_xDoc->getReferenceCount() )
1709  {
1710  // was the import aborted from SFX?
1711  eState = SvParserState::Error;
1712  pStream = nullptr;
1713  }
1714 
1715  // recreate View
1716  SwViewShell *const pVSh = CallStartAction( pOldVSh );
1717  OSL_ENSURE( pOldVSh == pVSh, "FileDownload: SwViewShell changed on us" );
1718 
1719  return pStream!=nullptr;
1720 }
1721 
1723 {
1724  bool bFinishDownload = false;
1725  if( !m_vPendingStack.empty() )
1726  {
1727  OSL_ENSURE( ShouldFinishFileDownload(),
1728  "Pending-Stack without File-Download?" );
1729 
1730  m_vPendingStack.pop_back();
1731  assert( m_vPendingStack.empty() && "Where does the Pending-Stack come from?" );
1732 
1733  bFinishDownload = true;
1734  }
1735  else
1736  {
1737  OUString sRel, sHRef, sType;
1738 
1739  const HTMLOptions& rOptions2 = GetOptions();
1740  for (size_t i = rOptions2.size(); i; )
1741  {
1742  const HTMLOption& rOption = rOptions2[--i];
1743  switch( rOption.GetToken() )
1744  {
1745  case HtmlOptionId::REL:
1746  sRel = rOption.GetString();
1747  break;
1748  case HtmlOptionId::HREF:
1750  break;
1751  case HtmlOptionId::TYPE:
1752  sType = rOption.GetString();
1753  break;
1754  default: break;
1755  }
1756  }
1757 
1758  if( !sHRef.isEmpty() && sRel.equalsIgnoreAsciiCase( "STYLESHEET" ) &&
1759  ( sType.isEmpty() ||
1760  sType.getToken(0,';').equalsAscii(sCSS_mimetype) ) )
1761  {
1762  if( GetMedium() )
1763  {
1764  // start download of style source
1765  StartFileDownload(sHRef);
1766  if( IsParserWorking() )
1767  {
1768  // The style was loaded synchronously and we can call it directly.
1769  bFinishDownload = true;
1770  }
1771  else
1772  {
1773  // The style was load asynchronously and is only available
1774  // on the next continue call. Therefore we must create a
1775  // Pending stack, so that we will return to here.
1776  m_vPendingStack.emplace_back( HtmlTokenId::LINK );
1777  }
1778  }
1779  else
1780  {
1781  // load file synchronous
1782  OUString sSource;
1783  if( FileDownload( sHRef, sSource ) )
1784  m_pCSS1Parser->ParseStyleSheet( sSource );
1785  }
1786  }
1787  }
1788 
1789  if( bFinishDownload )
1790  {
1791  OUString sSource;
1792  if( FinishFileDownload( sSource ) && !sSource.isEmpty() )
1793  m_pCSS1Parser->ParseStyleSheet( sSource );
1794  }
1795 }
1796 
1797 bool SwCSS1Parser::ParseStyleSheet( const OUString& rIn )
1798 {
1799  if( !SvxCSS1Parser::ParseStyleSheet( rIn ) )
1800  return false;
1801 
1802  SwPageDesc *pMasterPageDesc =
1804 
1805  SvxCSS1MapEntry* pPageEntry = GetPage(OUString(), false);
1806  if( pPageEntry )
1807  {
1808  // @page (affects all already existing pages)
1809 
1810  SetPageDescAttrs( pMasterPageDesc, pPageEntry->GetItemSet(),
1811  pPageEntry->GetPropertyInfo() );
1812 
1813  // For all other already existing page styles the attributes
1814  // must also be set
1815 
1816  SetPageDescAttrs( GetFirstPageDesc(), pPageEntry->GetItemSet(),
1817  pPageEntry->GetPropertyInfo() );
1818  SetPageDescAttrs( GetLeftPageDesc(), pPageEntry->GetItemSet(),
1819  pPageEntry->GetPropertyInfo() );
1820  SetPageDescAttrs( GetRightPageDesc(), pPageEntry->GetItemSet(),
1821  pPageEntry->GetPropertyInfo() );
1822 
1823  }
1824 
1825  pPageEntry = GetPage( "first", true );
1826  if( pPageEntry )
1827  {
1828  SetPageDescAttrs( GetFirstPageDesc(true), pPageEntry->GetItemSet(),
1829  pPageEntry->GetPropertyInfo() );
1830  m_bSetFirstPageDesc = true;
1831  }
1832 
1833  pPageEntry = GetPage( "right", true );
1834  if( pPageEntry )
1835  {
1836  SetPageDescAttrs( GetRightPageDesc(true), pPageEntry->GetItemSet(),
1837  pPageEntry->GetPropertyInfo() );
1838  m_bSetRightPageDesc = true;
1839  }
1840 
1841  pPageEntry = GetPage( "left", true );
1842  if( pPageEntry )
1843  SetPageDescAttrs( GetLeftPageDesc(true), pPageEntry->GetItemSet(),
1844  pPageEntry->GetPropertyInfo() );
1845 
1846  return true;
1847 }
1848 
1849 bool SwHTMLParser::ParseStyleOptions( const OUString &rStyle,
1850  const OUString &rId,
1851  const OUString &rClass,
1852  SfxItemSet &rItemSet,
1853  SvxCSS1PropertyInfo &rPropInfo,
1854  const OUString *pLang,
1855  const OUString *pDir )
1856 {
1857  bool bRet = false;
1858 
1859  if( !rClass.isEmpty() )
1860  {
1861  OUString aClass( rClass );
1863  const SvxCSS1MapEntry *pClass = m_pCSS1Parser->GetClass( aClass );
1864  if( pClass )
1865  {
1867  pClass->GetPropertyInfo(),
1868  rItemSet, rPropInfo, false );
1869  bRet = true;
1870  }
1871  }
1872 
1873  if( !rId.isEmpty() )
1874  {
1875  const SvxCSS1MapEntry *pId = m_pCSS1Parser->GetId( rId );
1876  if( pId )
1878  pId->GetPropertyInfo(),
1879  rItemSet, rPropInfo, !rClass.isEmpty() );
1880  rPropInfo.m_aId = rId;
1881  bRet = true;
1882  }
1883 
1884  if( !rStyle.isEmpty() )
1885  {
1886  m_pCSS1Parser->ParseStyleOption( rStyle, rItemSet, rPropInfo );
1887  bRet = true;
1888  }
1889 
1890  if( bRet )
1891  rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST );
1892 
1893  if( pLang && !pLang->isEmpty() )
1894  {
1896  if( LANGUAGE_DONTKNOW != eLang )
1897  {
1898  SvxLanguageItem aLang( eLang, RES_CHRATR_LANGUAGE );
1899  rItemSet.Put( aLang );
1900  aLang.SetWhich( RES_CHRATR_CJK_LANGUAGE );
1901  rItemSet.Put( aLang );
1902  aLang.SetWhich( RES_CHRATR_CTL_LANGUAGE );
1903  rItemSet.Put( aLang );
1904 
1905  bRet = true;
1906  }
1907  }
1908  if( pDir && !pDir->isEmpty() )
1909  {
1910  OUString aValue( *pDir );
1911  SvxFrameDirection eDir = SvxFrameDirection::Environment;
1912  if (aValue.equalsIgnoreAsciiCase("LTR"))
1913  eDir = SvxFrameDirection::Horizontal_LR_TB;
1914  else if (aValue.equalsIgnoreAsciiCase("RTL"))
1915  eDir = SvxFrameDirection::Horizontal_RL_TB;
1916 
1917  if( SvxFrameDirection::Environment != eDir )
1918  {
1919  SvxFrameDirectionItem aDir( eDir, RES_FRAMEDIR );
1920  rItemSet.Put( aDir );
1921 
1922  bRet = true;
1923  }
1924  }
1925 
1926  return bRet;
1927 }
1928 
1930  SfxItemSet &rFrameItemSet )
1931 {
1932  SwFormatAnchor aAnchor;
1933 
1934  sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1935  sal_Int16 eVertOri = text::VertOrientation::NONE;
1936  sal_Int16 eHoriRel = text::RelOrientation::FRAME;
1937  sal_Int16 eVertRel = text::RelOrientation::FRAME;
1938  SwTwips nHoriPos = 0, nVertPos = 0;
1939  css::text::WrapTextMode eSurround = css::text::WrapTextMode_THROUGH;
1940  if( SVX_CSS1_POS_ABSOLUTE == rPropInfo.m_ePosition )
1941  {
1942  if( SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eLeftType &&
1943  SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eTopType )
1944  {
1945  // Absolute positioned objects are page-bound, when they
1946  // aren't in a frame and otherwise frame-bound.
1947  const SwStartNode *pFlySttNd =
1949  if( pFlySttNd )
1950  {
1951  aAnchor.SetType( RndStdIds::FLY_AT_FLY );
1952  SwPosition aPos( *pFlySttNd );
1953  aAnchor.SetAnchor( &aPos );
1954  }
1955  else
1956  {
1957  aAnchor.SetType( RndStdIds::FLY_AT_PAGE );
1958  aAnchor.SetPageNum( 1 );
1959  }
1960  nHoriPos = rPropInfo.m_nLeft;
1961  nVertPos = rPropInfo.m_nTop;
1962  }
1963  else
1964  {
1965  aAnchor.SetType( RndStdIds::FLY_AT_PARA );
1966  aAnchor.SetAnchor( m_pPam->GetPoint() );
1967  eVertOri = text::VertOrientation::TOP;
1968  eVertRel = text::RelOrientation::CHAR;
1969  if( SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eLeftType )
1970  {
1971  eHoriOri = text::HoriOrientation::NONE;
1972  eHoriRel = text::RelOrientation::PAGE_FRAME;
1973  nHoriPos = rPropInfo.m_nLeft;
1974  }
1975  else
1976  {
1977  eHoriOri = text::HoriOrientation::LEFT;
1978  eHoriRel = text::RelOrientation::FRAME; // to be changed later
1979  }
1980  }
1981  }
1982  else
1983  {
1984  // Flowing object are inserted as paragraph-bound, when the paragraph is
1985  // still empty and otherwise auto-bound.
1986  // Auto-bound frames for the time being inserted at the previous position
1987  // and later moved.
1988  const sal_Int32 nContent = m_pPam->GetPoint()->nContent.GetIndex();
1989  if( nContent )
1990  {
1991  aAnchor.SetType( RndStdIds::FLY_AT_CHAR );
1993  eVertOri = text::VertOrientation::CHAR_BOTTOM;
1994  eVertRel = text::RelOrientation::CHAR;
1995  }
1996  else
1997  {
1998  aAnchor.SetType( RndStdIds::FLY_AT_PARA );
1999  eVertOri = text::VertOrientation::TOP;
2000  eVertRel = text::RelOrientation::PRINT_AREA;
2001  }
2002 
2003  aAnchor.SetAnchor( m_pPam->GetPoint() );
2004 
2005  if( nContent )
2007 
2008  sal_uInt16 nLeftSpace = 0, nRightSpace = 0;
2009  short nIndent = 0;
2010  GetMarginsFromContextWithNumberBullet( nLeftSpace, nRightSpace, nIndent );
2011 
2012  if( SvxAdjust::Right==rPropInfo.m_eFloat )
2013  {
2014  eHoriOri = text::HoriOrientation::RIGHT;
2015  eHoriRel = nRightSpace ? text::RelOrientation::PRINT_AREA : text::RelOrientation::FRAME;
2016  eSurround = css::text::WrapTextMode_LEFT;
2017  }
2018  else
2019  {
2020  eHoriOri = text::HoriOrientation::LEFT;
2021  eHoriRel = nLeftSpace ? text::RelOrientation::PRINT_AREA : text::RelOrientation::FRAME;
2022  eSurround = css::text::WrapTextMode_RIGHT;
2023  }
2024  }
2025  rFrameItemSet.Put( aAnchor );
2026 
2027  // positioned absolutely with wrap
2028  rFrameItemSet.Put( SwFormatHoriOrient( nHoriPos, eHoriOri, eHoriRel ) );
2029  rFrameItemSet.Put( SwFormatVertOrient( nVertPos, eVertOri, eVertRel ) );
2030  rFrameItemSet.Put( SwFormatSurround( eSurround ) );
2031 }
2032 
2034  SfxItemSet &rFrameItemSet,
2035  SwTwips nDfltWidth, sal_uInt8 nDfltPrcWidth )
2036 {
2037  SwTwips nWidth = nDfltWidth, nHeight = MINFLY;
2038  sal_uInt8 nPercentWidth = nDfltPrcWidth, nPercentHeight = 0;
2039  switch( rPropInfo.m_eWidthType )
2040  {
2042  nPercentWidth = rPropInfo.m_nWidth > 0 ? static_cast<sal_uInt8>(rPropInfo.m_nWidth) : 1;
2043  nWidth = MINFLY;
2044  break;
2045  case SVX_CSS1_LTYPE_TWIP:
2046  nWidth = std::max<long>(rPropInfo.m_nWidth, MINFLY);
2047  nPercentWidth = 0;
2048  break;
2049  default:
2050  ;
2051  }
2052  switch( rPropInfo.m_eHeightType )
2053  {
2055  nPercentHeight = rPropInfo.m_nHeight > 0 ? static_cast<sal_uInt8>(rPropInfo.m_nHeight) : 1;
2056  break;
2057  case SVX_CSS1_LTYPE_TWIP:
2058  // Netscape and MS-IE interpreting the height incorrectly as minimum height,
2059  // therefore we are doing the same.
2060  nHeight = std::max<long>(rPropInfo.m_nHeight, MINFLY);
2061  break;
2062  default:
2063  ;
2064  }
2065 
2066  SwFormatFrameSize aFrameSize( SwFrameSize::Minimum, nWidth, nHeight );
2067  aFrameSize.SetWidthPercent( nPercentWidth );
2068  aFrameSize.SetHeightPercent( nPercentHeight );
2069  rFrameItemSet.Put( aFrameSize );
2070 }
2071 
2073  HtmlFrameFormatFlags nFlags,
2074  SfxItemSet &rFrameItemSet )
2075 {
2076  const SfxPoolItem *pItem;
2077  if( (nFlags & HtmlFrameFormatFlags::Box) &&
2078  SfxItemState::SET==rItemSet.GetItemState( RES_BOX, true, &pItem ) )
2079  {
2080  if( nFlags & HtmlFrameFormatFlags::Padding )
2081  {
2082  SvxBoxItem aBoxItem( *static_cast<const SvxBoxItem *>(pItem) );
2083  // reset all 4 sides to 0
2084  aBoxItem.SetAllDistances(0);
2085  rFrameItemSet.Put( aBoxItem );
2086  }
2087  else
2088  {
2089  rFrameItemSet.Put( *pItem );
2090  }
2091  rItemSet.ClearItem( RES_BOX );
2092  }
2093 
2094  if( (nFlags & HtmlFrameFormatFlags::Background) &&
2095  SfxItemState::SET==rItemSet.GetItemState( RES_BACKGROUND, true, &pItem ) )
2096  {
2097  rFrameItemSet.Put( *pItem );
2098  rItemSet.ClearItem( RES_BACKGROUND );
2099  }
2100 
2101  if( (nFlags & HtmlFrameFormatFlags::Direction) &&
2102  SfxItemState::SET==rItemSet.GetItemState( RES_FRAMEDIR, true, &pItem ) )
2103  {
2104  rFrameItemSet.Put( *pItem );
2105  rItemSet.ClearItem( RES_FRAMEDIR );
2106  }
2107 }
2108 
2109 std::unique_ptr<HTMLAttrContext> SwHTMLParser::PopContext( HtmlTokenId nToken )
2110 {
2111  std::unique_ptr<HTMLAttrContext> xCntxt;
2112 
2113  HTMLAttrContexts::size_type nPos = m_aContexts.size();
2114  if( nPos <= m_nContextStMin )
2115  return nullptr;
2116 
2117  bool bFound = HtmlTokenId::NONE == nToken;
2118  if( nToken != HtmlTokenId::NONE )
2119  {
2120  // search for stack entry of token ...
2121  while( nPos > m_nContextStMin )
2122  {
2123  HtmlTokenId nCntxtToken = m_aContexts[--nPos]->GetToken();
2124  if( nCntxtToken == nToken )
2125  {
2126  bFound = true;
2127  break;
2128  }
2129  else if( nCntxtToken == HtmlTokenId::NONE ) // zero as token doesn't occur
2130  {
2131  break;
2132  }
2133  }
2134  }
2135  else
2136  {
2137  nPos--;
2138  }
2139 
2140  if( bFound )
2141  {
2142  xCntxt = std::move(m_aContexts[nPos]);
2143  m_aContexts.erase( m_aContexts.begin() + nPos );
2144  }
2145 
2146  return xCntxt;
2147 }
2148 
2149 void SwHTMLParser::GetMarginsFromContext( sal_uInt16& nLeft,
2150  sal_uInt16& nRight,
2151  short& nIndent,
2152  bool bIgnoreTopContext ) const
2153 {
2154  HTMLAttrContexts::size_type nPos = m_aContexts.size();
2155  if( bIgnoreTopContext )
2156  {
2157  if( !nPos )
2158  return;
2159  else
2160  nPos--;
2161  }
2162 
2163  while( nPos > m_nContextStAttrMin )
2164  {
2165  const HTMLAttrContext *pCntxt = m_aContexts[--nPos].get();
2166  if( pCntxt->IsLRSpaceChanged() )
2167  {
2168  pCntxt->GetMargins( nLeft, nRight, nIndent );
2169  return;
2170  }
2171  }
2172 }
2173 
2175  sal_uInt16& nRight,
2176  short& nIndent ) const
2177 {
2178  GetMarginsFromContext( nLeft, nRight, nIndent );
2179  const SwHTMLNumRuleInfo& rInfo = const_cast<SwHTMLParser*>(this)->GetNumInfo();
2180  if( rInfo.GetDepth() )
2181  {
2182  sal_uInt8 nLevel = static_cast<sal_uInt8>( (rInfo.GetDepth() <= MAXLEVEL ? rInfo.GetDepth()
2183  : MAXLEVEL) - 1 );
2184  const SwNumFormat& rNumFormat = rInfo.GetNumRule()->Get(nLevel);
2185  nLeft = nLeft + rNumFormat.GetAbsLSpace(); //TODO: overflow
2186  nIndent = rNumFormat.GetFirstLineOffset(); //TODO: overflow
2187  }
2188 }
2189 
2190 void SwHTMLParser::GetULSpaceFromContext( sal_uInt16& nUpper,
2191  sal_uInt16& nLower ) const
2192 {
2193  sal_uInt16 nDfltColl = 0;
2194  OUString aDfltClass;
2195 
2196  HTMLAttrContexts::size_type nPos = m_aContexts.size();
2197  while( nPos > m_nContextStAttrMin )
2198  {
2199  const HTMLAttrContext *pCntxt = m_aContexts[--nPos].get();
2200  if( pCntxt->IsULSpaceChanged() )
2201  {
2202  pCntxt->GetULSpace( nUpper, nLower );
2203  return;
2204  }
2205  else if( !nDfltColl )
2206  {
2207  nDfltColl = pCntxt->GetDfltTextFormatColl();
2208  if( nDfltColl )
2209  aDfltClass = pCntxt->GetClass();
2210  }
2211  }
2212 
2213  if( !nDfltColl )
2214  nDfltColl = RES_POOLCOLL_TEXT;
2215 
2216  const SwTextFormatColl *pColl =
2217  m_pCSS1Parser->GetTextFormatColl( nDfltColl, aDfltClass );
2218  const SvxULSpaceItem& rULSpace = pColl->GetULSpace();
2219  nUpper = rULSpace.GetUpper();
2220  nLower = rULSpace.GetLower();
2221 }
2222 
2224 {
2225  HTMLAttrs &rAttrs = pContext->GetAttrs();
2226  for( auto pAttr : rAttrs )
2227  {
2228  if( RES_PARATR_DROP==pAttr->GetItem().Which() )
2229  {
2230  // Set the number of characters for DropCaps. If it's zero at the
2231  // end, the attribute is set to invalid and then isn't set from SetAttr.
2232  sal_Int32 nChars = m_pPam->GetPoint()->nContent.GetIndex();
2233  if( nChars < 1 )
2234  pAttr->Invalidate();
2235  else if( nChars > MAX_DROPCAP_CHARS )
2236  nChars = MAX_DROPCAP_CHARS;
2237  static_cast<SwFormatDrop&>(pAttr->GetItem()).GetChars() = static_cast<sal_uInt8>(nChars);
2238  }
2239 
2240  EndAttr( pAttr );
2241  }
2242 }
2243 
2245 {
2246  SfxItemIter aIter( rItemSet );
2247 
2248  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
2249  {
2250  // search for the table entry of the item...
2251  sal_uInt16 nWhich = pItem->Which();
2252  HTMLAttr **ppAttr = GetAttrTabEntry( nWhich );
2253 
2254  if( ppAttr )
2255  {
2256  NewAttr(m_xAttrTab, ppAttr, *pItem);
2257  if( RES_PARATR_BEGIN > nWhich )
2258  (*ppAttr)->SetLikePara();
2259  m_aParaAttrs.push_back( *ppAttr );
2260  bool bSuccess = EndAttr( *ppAttr, false );
2261  if (!bSuccess)
2262  m_aParaAttrs.pop_back();
2263  }
2264  }
2265 }
2266 
2267 static void lcl_swcss1_setEncoding( SwFormat& rFormat, rtl_TextEncoding eEnc )
2268 {
2269  if( RTL_TEXTENCODING_DONTKNOW == eEnc )
2270  return;
2271 
2272  const SfxItemSet& rItemSet = rFormat.GetAttrSet();
2273  static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
2275  const SfxPoolItem *pItem;
2276  for(sal_uInt16 i : aWhichIds)
2277  {
2278  if( SfxItemState::SET == rItemSet.GetItemState( i, false,&pItem ) )
2279  {
2280  const SvxFontItem& rFont = *static_cast<const SvxFontItem *>(pItem);
2281  if( RTL_TEXTENCODING_SYMBOL != rFont.GetCharSet() )
2282  {
2283  SvxFontItem aFont( rFont.GetFamily(), rFont.GetFamilyName(),
2284  rFont.GetStyleName(), rFont.GetPitch(),
2285  eEnc, i);
2286  rFormat.SetFormatAttr( aFont );
2287  }
2288  }
2289  }
2290 }
2291 
2292 void SwCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
2293 {
2294  if( eEnc != GetDfltEncoding() )
2295  {
2296  if( m_bIsNewDoc )
2297  {
2298  // Set new encoding as pool default
2299  static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
2301  for(sal_uInt16 i : aWhichIds)
2302  {
2303  const SvxFontItem& rDfltFont =
2304  static_cast<const SvxFontItem&>(m_pDoc->GetDefault( i));
2305  SvxFontItem aFont( rDfltFont.GetFamily(),
2306  rDfltFont.GetFamilyName(),
2307  rDfltFont.GetStyleName(),
2308  rDfltFont.GetPitch(),
2309  eEnc, i );
2310  m_pDoc->SetDefault( aFont );
2311  }
2312 
2313  // Change all paragraph styles that do specify a font.
2314  for( auto pTextFormatColl : *m_pDoc->GetTextFormatColls() )
2315  lcl_swcss1_setEncoding( *pTextFormatColl, eEnc );
2316 
2317  // Change all character styles that do specify a font.
2318  for( auto pCharFormat : *m_pDoc->GetCharFormats() )
2319  lcl_swcss1_setEncoding( *pCharFormat, eEnc );
2320  }
2321 
2323  }
2324 }
2325 
2326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
long GetLeft() const
std::vector< SwPending > m_vPendingStack
Definition: swhtml.hxx:373
SwTextFormatColl * MakeTextFormatColl(const OUString &rFormatName, SwTextFormatColl *pDerivedFrom, bool bBroadcast=false)
Create the FormatCollections.
Definition: docfmt.cxx:876
static void MergeStyles(const SfxItemSet &rSrcSet, const SvxCSS1PropertyInfo &rSrcInfo, SfxItemSet &rTargetSet, SvxCSS1PropertyInfo &rTargetInfo, bool bSmart)
Definition: svxcss1.cxx:928
Starts a section of nodes in the document model.
Definition: node.hxx:303
void GetULSpace(sal_uInt16 &rUpper, sal_uInt16 &rLower) const
Definition: swhtml.hxx:986
SvxBreak
const SwPageDesc * GetFirstPageDesc(bool bCreate=false)
Definition: swcss1.hxx:164
#define RES_CHRATR_WEIGHT
Definition: hintids.hxx:177
bool ContainsPageDesc(const SwPageDesc *pDesc, size_t *pPos) const
Definition: docdesc.cxx:827
SvxCSS1LengthType m_eLeftType
Definition: svxcss1.hxx:137
void SetAnchorAndAdjustment(sal_Int16 eVertOri, sal_Int16 eHoriOri, const SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFrameSet)
Definition: htmlgrin.cxx:149
Css1ScriptFlags
Definition: svxcss1.hxx:76
sal_uInt16 m_nDropCapCnt
Definition: swcss1.hxx:49
HtmlOptionId GetToken() const
SvxCSS1LengthType m_eTopType
Definition: svxcss1.hxx:137
static Css1ScriptFlags GetScriptFromClass(OUString &rClass, bool bSubClassOnly=true)
Definition: htmlcss1.cxx:554
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
SwTextFormatColl * GetTextFormatColl(sal_uInt16 nTextColl, const OUString &rClass)
Definition: htmlcss1.cxx:1241
Marks a position in the document model.
Definition: pam.hxx:35
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:186
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
sal_uInt16 GetLower() const
bool m_bIgnoreRawData
Definition: swhtml.hxx:428
SwPageDesc * GetMasterPageDesc()
Definition: htmlcss1.cxx:1322
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:170
virtual void SetDfltEncoding(rtl_TextEncoding eEnc)
Definition: svxcss1.cxx:978
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:172
virtual ~SwCSS1Parser() override
Definition: htmlcss1.cxx:118
bool ShouldFinishFileDownload() const
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:842
bool m_bSetRightPageDesc
Definition: swcss1.hxx:60
SwDocShell * GetDocShell()
Definition: doc.hxx:1350
bool FileDownload(const OUString &rURL, OUString &rStr)
Definition: htmlcss1.cxx:1688
sal_uInt16 GetDfltTextFormatColl() const
Definition: swhtml.hxx:246
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
SwNodeIndex nNode
Definition: pam.hxx:37
GPOS_NONE
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nPoolId) const
Definition: htmlcss1.cxx:1206
bool IsReadingHeaderOrFooter() const
Definition: swhtml.hxx:927
#define RES_CHRATR_CJK_POSTURE
Definition: hintids.hxx:187
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:798
#define OOO_STRING_SVTOOLS_HTML_tableheader
const SvxCSS1PropertyInfo & GetPropertyInfo() const
Definition: svxcss1.hxx:174
bool m_bBodyBGColorSet
Definition: swcss1.hxx:53
sal_uInt8 GetLines() const
Definition: paratr.hxx:86
#define MINFLY
Definition: swtypes.hxx:65
#define RES_FRAMEDIR
Definition: hintids.hxx:320
void NewAttr(const std::shared_ptr< HTMLAttrTable > &rAttrTab, HTMLAttr **ppAttr, const SfxPoolItem &rItem)
Definition: swhtml.cxx:3033
const OUString & GetString() const
void StartFileDownload(const OUString &rURL)
Definition: doc.hxx:186
SwViewShell * CallEndAction(bool bChkAction=false, bool bChkPtr=true)
Definition: swhtml.cxx:2629
const OUString & GetString() const
Definition: parcss1.hxx:105
HTMLAttrContexts m_aContexts
Definition: swhtml.hxx:362
const OUString & GetClass() const
Definition: swhtml.hxx:248
#define RES_CHRATR_CJK_WEIGHT
Definition: hintids.hxx:188
#define RES_CHRATR_FONT
Definition: hintids.hxx:169
void SetTextLeft(const long nL, const sal_uInt16 nProp=100)
bool m_bBodyVLinkSet
Definition: swcss1.hxx:57
SwNode & GetNode() const
Definition: ndindex.hxx:119
#define OOO_STRING_SVTOOLS_HTML_sdfootnote_sym
long SwTwips
Definition: swtypes.hxx:49
virtual sal_uInt32 GetFontHeight(sal_uInt16 nSize) const override
Definition: htmlcss1.cxx:1106
bool m_bTableTextCollSet
Definition: swcss1.hxx:63
SvxFrameDirection
rtl_TextEncoding GetDfltEncoding() const
Definition: svxcss1.hxx:300
#define RES_CHRATR_BLINK
Definition: hintids.hxx:180
#define RES_CHRATR_CJK_FONT
Definition: hintids.hxx:184
OUString m_sBaseURL
Definition: swhtml.hxx:340
#define OOO_STRING_SVTOOLS_HTML_insertedtext
bool m_bBodyLinkSet
Definition: swcss1.hxx:56
#define RES_CHRATR_CJK_FONTSIZE
Definition: hintids.hxx:185
void SetBoxItem(SfxItemSet &rItemSet, sal_uInt16 nMinBorderDist, const SvxBoxItem *pDflt=nullptr)
Definition: svxcss1.cxx:584
#define RES_PARATR_SPLIT
Definition: hintids.hxx:257
virtual SvxBrushItem * Clone(SfxItemPool *pPool=nullptr) const override
virtual bool SetFormatAttr(const SfxPoolItem &rAttr) override
Override to recognize changes on the and register/unregister the paragragh style at t...
Definition: fmtcol.cxx:329
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
SvxCSS1PageBreak m_ePageBreakBefore
Definition: svxcss1.hxx:142
void InsertLink()
Definition: htmlcss1.cxx:1722
FontPitch GetPitch() const
#define MIN_BORDER_DIST
Definition: swtypes.hxx:74
sal_uLong m_aFontHeights[7]
Definition: swcss1.hxx:47
Value in Var-direction gives minimum (can be exceeded but not be less).
FontFamily GetFamily() const
void SetFollow(const SwPageDesc *pNew)
Definition: pagedesc.hxx:293
HtmlFrameFormatFlags
Definition: swhtml.hxx:317
virtual sal_uInt64 TellEnd() override
SwDoc * m_pDoc
Definition: docbm.cxx:1192
#define MAX_DROPCAP_CHARS
Definition: htmlcss1.cxx:68
#define OOO_STRING_SVTOOLS_HTML_tabledata
SvxCSS1LengthType m_eHeightType
Definition: svxcss1.hxx:138
SvxCSS1SizeType m_eSizeType
Definition: svxcss1.hxx:140
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
const SfxPoolItem * NextItem()
static LanguageType convertToLanguageTypeWithFallback(const OUString &rBcp47)
SvxGraphicPosition GetGraphicPos() const
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:750
void SetLeft(const long nL, const sal_uInt16 nProp=100)
void GetMarginsFromContext(sal_uInt16 &nLeft, sal_uInt16 &nRight, short &nIndent, bool bIgnoreCurrent=false) const
Definition: htmlcss1.cxx:2149
#define RES_CHRATR_CTL_FONTSIZE
Definition: hintids.hxx:190
SwIndex nContent
Definition: pam.hxx:38
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat-Id.
Definition: pagedesc.hxx:254
size_t pos
virtual void SetDfltEncoding(rtl_TextEncoding eEnc) override
Definition: htmlcss1.cxx:2292
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:425
rtl_TextEncoding GetCharSet() const
void SetLandscape(bool bNew)
Definition: pagedesc.hxx:191
bool ParseStyleOptions(const OUString &rStyle, const OUString &rId, const OUString &rClass, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
Definition: htmlcss1.cxx:1849
const OUString & GetName() const
Definition: format.hxx:111
const HTMLAttrs & GetAttrs() const
Definition: swhtml.hxx:261
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:652
CSS1SelectorType
Definition: parcss1.hxx:70
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
bool FinishFileDownload(OUString &rStr)
#define RES_UL_SPACE
Definition: hintids.hxx:292
void EndStyle()
Definition: htmlcss1.cxx:1677
SvxCSS1PageBreak m_ePageBreakAfter
Definition: svxcss1.hxx:143
void FillDropCap(SwFormatDrop &rDrop, SfxItemSet &rItemSet, const OUString *pName=nullptr)
Definition: htmlcss1.cxx:1458
sal_uInt16 GetDistance() const
Definition: paratr.hxx:95
SvxCSS1MapEntry * GetTag(const OUString &rTag)
Definition: svxcss1.cxx:813
HtmlTokenId GetHTMLToken(const OUString &rName)
#define RES_PARATR_BEGIN
Definition: hintids.hxx:254
void SetAllDistances(sal_uInt16 nNew)
#define RES_CHRATR_CASEMAP
Definition: hintids.hxx:163
SwHTMLParser const & m_rHTMLParser
Definition: swcss1.hxx:45
void ParseStyleSheet()
Definition: parcss1.cxx:669
SwPaM * m_pPam
Definition: swhtml.hxx:376
#define OOO_STRING_SVTOOLS_HTML_sdfootnote
const char * sName
bool m_bBodyBackgroundSet
Definition: swcss1.hxx:54
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
const OUString & GetStyleName() const
#define OOO_STRING_SVTOOLS_HTML_author
Base class for various Writer styles.
Definition: format.hxx:43
#define SAL_N_ELEMENTS(arr)
DocumentType eType
void InsertPage(const OUString &rPage, bool bPseudo, const SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rProp)
Definition: svxcss1.cxx:785
#define RES_BACKGROUND
Definition: hintids.hxx:305
const Color & GetColor() const
Table of Contents - heading.
Definition: poolfmt.hxx:342
#define RES_CHRATR_COLOR
Definition: hintids.hxx:165
static void SetCharFormatAttrs(SwCharFormat *pCharFormat, SfxItemSet &rItemSet)
Definition: htmlcss1.cxx:179
bool m_bLinkCharFormatsSet
Definition: swcss1.hxx:65
static void SetFrameFormatAttrs(SfxItemSet &rItemSet, HtmlFrameFormatFlags nFlags, SfxItemSet &rFrameItemSet)
Definition: htmlcss1.cxx:2072
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:496
void SetRight(const long nR, const sal_uInt16 nProp=100)
void SetLinkCharFormats()
Definition: htmlcss1.cxx:215
sal_uInt16 char * pName
SfxMedium * GetMedium()
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:57
std::deque< HTMLAttr * > HTMLAttrs
Definition: swhtml.hxx:71
OptionalString sType
#define RES_CHRATR_BACKGROUND
Definition: hintids.hxx:183
sal_uInt16 GetDepth() const
Definition: htmlnum.hxx:73
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
OUString m_aStyleSource
Definition: swhtml.hxx:346
bool IsLRSpaceChanged() const
Definition: swhtml.hxx:252
#define RES_CHRATR_CTL_FONT
Definition: hintids.hxx:189
Internet visited.
Definition: poolfmt.hxx:122
int i
const SwFormatDrop & GetDrop(bool=true) const
Definition: paratr.hxx:216
sal_Int32 GetAbsLSpace() const
void EndContextAttrs(HTMLAttrContext *pContext)
Definition: htmlcss1.cxx:2223
const SwPosition * GetPoint() const
Definition: pam.hxx:207
First page.
Definition: poolfmt.hxx:172
#define RES_CHRATR_BOX
Definition: hintids.hxx:202
std::vector< SwTextFormatColl * >::size_type size_type
Definition: docary.hxx:63
const SwPageDesc * GetLeftPageDesc(bool bCreate=false)
Definition: swcss1.hxx:174
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:880
static void AddClassName(OUString &rFormatName, const OUString &rClass)
Definition: htmlcss1.cxx:1451
void SetAuto(bool bNew)
Definition: format.hxx:159
bool GetLandscape() const
Definition: pagedesc.hxx:190
#define OOO_STRING_SVTOOLS_HTML_language
Text body.
Definition: poolfmt.hxx:251
#define OOO_STRING_SVTOOLS_HTML_person
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
Definition: swhtml.hxx:371
FlyAnchors.
Definition: fmtanchr.hxx:34
sal_uInt16 Count() const
const SwPageDesc * GetRightPageDesc(bool bCreate=false)
Definition: swcss1.hxx:169
#define RES_PARATR_ORPHANS
Definition: hintids.hxx:258
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
SwCharFormat * GetChrFormat(HtmlTokenId nToken, const OUString &rClass) const
Definition: htmlcss1.cxx:1126
size_t GetPageDescCnt() const
Definition: doc.hxx:879
std::shared_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:782
Internet normal.
Definition: poolfmt.hxx:121
size_t size() const
Definition: docary.hxx:84
std::unique_ptr< HTMLAttrContext > PopContext(HtmlTokenId nToken=HtmlTokenId::NONE)
Definition: htmlcss1.cxx:2109
void InsertClass(const OUString &rClass, const SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rProp)
Definition: svxcss1.cxx:772
#define LANGUAGE_DONTKNOW
#define RES_CHRATR_UNDERLINE
Definition: hintids.hxx:176
void ChgPageDesc(const OUString &rName, const SwPageDesc &)
Definition: docdesc.cxx:853
SvxCSS1Position m_ePosition
Definition: svxcss1.hxx:121
short GetTextFirstLineOffset() const
#define RES_CHRATR_ESCAPEMENT
Definition: hintids.hxx:168
void SetPageDescAttrs(const SvxBrushItem *pBrush, SfxItemSet *pItemSet=nullptr)
Definition: htmlcss1.cxx:376
SwCSS1Parser(SwDoc *pDoc, SwHTMLParser const &rParser, sal_uInt32 const aFHeight[7], const OUString &rBaseURL, bool bNewDoc)
Definition: htmlcss1.cxx:90
#define OOO_STRING_SVTOOLS_HTML_shortquote
sal_uInt8 GetChars() const
Definition: paratr.hxx:89
SvxAdjust m_eFloat
Definition: svxcss1.hxx:119
static void lcl_swcss1_setEncoding(SwFormat &rFormat, rtl_TextEncoding eEnc)
Definition: htmlcss1.cxx:2267
SvStream & WriteStream(SvStream &rStream)
Left page.
Definition: poolfmt.hxx:173
void InsertParaAttrs(const SfxItemSet &rItemSet)
Definition: htmlcss1.cxx:2244
Frame cannot be moved in Var-direction.
void GetMargins(sal_uInt16 &nLeft, sal_uInt16 &nRight, short &nIndent) const
Definition: swhtml.hxx:967
#define OOO_STRING_SVTOOLS_HTML_deletedtext
SwCharFormat * GetCharFormatFromPool(sal_uInt16 nPoolId) const
Definition: htmlcss1.cxx:1223
virtual const FontList * GetFontList() const override
Definition: htmlcss1.cxx:1111
#define RES_CHRATR_KERNING
Definition: hintids.hxx:171
#define RES_LR_SPACE
Definition: hintids.hxx:291
size_t m_nContextStMin
Definition: swhtml.hxx:401
#define OOO_STRING_SVTOOLS_HTML_acronym
HtmlTokenId
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
SvxCSS1MapEntry * GetPage(const OUString &rPage, bool bPseudo)
Definition: svxcss1.cxx:796
void SetHeightPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:93
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:77
bool m_bBodyTextSet
Definition: swcss1.hxx:55
const sal_uInt16 USER_FMT
POLLCOLL-groups:
Definition: poolfmt.hxx:63
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:770
const OUString & GetFamilyName() const
void SetDefault(const SfxPoolItem &)
Set attribute as new default attribute in current document.
Definition: docfmt.cxx:526
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:217
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SvStream * GetInStream()
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:76
void CopyPageDesc(const SwPageDesc &rSrcDesc, SwPageDesc &rDstDesc, bool bCopyPoolIds=true)
Copy the complete PageDesc - beyond document and "deep"! Optionally copying of PoolFormatId, -HlpId can be prevented.
Definition: docfmt.cxx:1406
bool IsULSpaceChanged() const
Definition: swhtml.hxx:257
SvxCSS1LengthType m_eWidthType
Definition: svxcss1.hxx:138
const CSS1Selector * GetNext() const
Definition: parcss1.hxx:108
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:737
HTMLAttrs m_aParaAttrs
Definition: swhtml.hxx:360
void ChgPageDesc(const SwPageDesc *pPageDesc, const SwPageDesc &rNewPageDesc)
Definition: htmlcss1.cxx:80
const char *const sCSS_mimetype
Definition: css1kywd.cxx:22
static void RemoveScriptItems(SfxItemSet &rItemSet, Css1ScriptFlags nScript, const SfxItemSet *pParentItemSet=nullptr)
Definition: htmlcss1.cxx:635
#define OOO_STRING_SVTOOLS_HTML_sdendnote
#define OOO_STRING_SVTOOLS_HTML_sdendnote_sym
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:777
static void SetTextCollAttrs(SwTextFormatColl *pColl, SfxItemSet &rItemSet, SvxCSS1PropertyInfo const &rPropInfo, SwCSS1Parser *pCSS1Parser)
Definition: htmlcss1.cxx:267
#define RES_CHRATR_CTL_LANGUAGE
Definition: hintids.hxx:191
unsigned char sal_uInt8
#define RES_CHRATR_POSTURE
Definition: hintids.hxx:173
#define RES_CHRATR_CTL_WEIGHT
Definition: hintids.hxx:193
#define RES_CHRATR_CTL_POSTURE
Definition: hintids.hxx:192
void SetWidthPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:95
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
Right page.
Definition: poolfmt.hxx:174
SwDoc * m_pDoc
Definition: swcss1.hxx:44
::std::vector< HTMLOption > HTMLOptions
bool m_bTableHeaderTextCollSet
Definition: swcss1.hxx:62
void GetULSpaceFromContext(sal_uInt16 &rUpper, sal_uInt16 &rLower) const
Definition: htmlcss1.cxx:2190
OUString aName
sal_Int32 GetIndex() const
Definition: index.hxx:95
SwHTMLNumRuleInfo & GetNumInfo()
Definition: swhtml.hxx:538
bool m_bSetFirstPageDesc
Definition: swcss1.hxx:59
const SwPageDesc * GetPageDesc(sal_uInt16 nPoolId, bool bCreate)
Definition: htmlcss1.cxx:1338
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
bool EndAttr(HTMLAttr *pAttr, bool bChkEmpty=true)
Definition: swhtml.cxx:3049
#define RES_KEEP
Definition: hintids.hxx:310
#define MAX_DROPCAP_LINES
Definition: htmlcss1.cxx:67
#define OOO_STRING_SVTOOLS_HTML_parabreak
#define RES_PARATR_ADJUST
Definition: hintids.hxx:256
HTMLAttr ** GetAttrTabEntry(sal_uInt16 nWhich)
Definition: htmlcss1.cxx:1535
static void SetVarSize(SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet, SwTwips nDfltWidth=MINLAY, sal_uInt8 nDefaultPercentWidth=0)
Definition: htmlcss1.cxx:2033
void SetTableTextColl(bool bHeader)
Definition: htmlcss1.cxx:331
bool swhtml_css1atr_equalFontItems(const SfxPoolItem &r1, const SfxPoolItem &r2)
Definition: css1atr.cxx:1003
size_t m_nContextStAttrMin
Definition: swhtml.hxx:402
CSS1SelectorType GetType() const
Definition: parcss1.hxx:104
sal_Int32 GetFirstLineOffset() const
bool m_bIsNewDoc
Definition: swcss1.hxx:51
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
long GetRight() const
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
#define RES_PARATR_WIDOWS
Definition: hintids.hxx:259
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:198
#define RES_BOX
Definition: hintids.hxx:306
#define SAL_WARN(area, stream)
#define RES_CHRATR_CROSSEDOUT
Definition: hintids.hxx:167
static CSS1SelectorType GetTokenAndClass(const CSS1Selector *pSelector, OUString &rToken, OUString &rClass, Css1ScriptFlags &rScriptFlags)
Definition: htmlcss1.cxx:607
void GetMarginsFromContextWithNumberBullet(sal_uInt16 &nLeft, sal_uInt16 &nRight, short &nIndent) const
Definition: htmlcss1.cxx:2174
void InsertTag(const OUString &rTag, const SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rProp)
Definition: svxcss1.cxx:806
#define RES_PARATR_DROP
Definition: hintids.hxx:262
std::shared_ptr< SvxBrushItem > makePageDescBackground() const
Definition: htmlcss1.cxx:548
bool SetFormatBreak(SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rPropInfo)
Definition: htmlcss1.cxx:123
std::shared_ptr< HTMLAttrTable > m_xAttrTab
Definition: swhtml.hxx:361
void NewStyle()
Definition: htmlcss1.cxx:1661
const FontList * GetFontList() const
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:50
const SfxItemSet & GetItemSet() const
Definition: svxcss1.hxx:171
A simple selector.
Definition: parcss1.hxx:91
void InsertId(const OUString &rId, const SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rProp)
Definition: svxcss1.cxx:759
static const sal_uInt16 aItemIds[]
Definition: htmlcss1.cxx:73
Subgroup table.
Definition: poolfmt.hxx:341
#define RES_PAGEDESC
Definition: hintids.hxx:293
#define RES_BREAK
Definition: hintids.hxx:294
#define OOO_STRING_SVTOOLS_HTML_abbreviation
long GetTextLeft() const
SwViewShell * CallStartAction(SwViewShell *pVSh=nullptr, bool bChkPtr=true)
Definition: swhtml.cxx:2600
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
rtl::Reference< SwDoc > m_xDoc
Definition: swhtml.hxx:375
SwNumRule * GetNumRule()
Definition: htmlnum.hxx:69
const SvxCSS1MapEntry * GetClass(const OUString &rClass) const
Definition: svxcss1.cxx:779
#define OOO_STRING_SVTOOLS_HTML_anchor
static SwPageDesc * FindPageDesc(SwDoc *pDoc, sal_uInt16 nPoolId)
Definition: htmlcss1.cxx:1327
void SetCharFormat(SwCharFormat *pNew)
Definition: paratr.cxx:63
virtual void StyleParsed(const CSS1Selector *pSelector, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo) override
Definition: htmlcss1.cxx:685
sal_uInt16 nPos
static bool MayBePositioned(const SvxCSS1PropertyInfo &rPropInfo, bool bAutoWidth=false)
Definition: htmlcss1.cxx:1425
const SfxPoolItem * GetCurItem() const
#define RES_PARATR_LINESPACING
Definition: hintids.hxx:255
const void * GetData()
sal_uInt16 GetUpper() const
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1478
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)