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