27#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28#include <com/sun/star/table/BorderLine2.hpp>
42#include <unonames.hxx>
43#include <document.hxx>
51#define XML_LINE_LEFT 0
52#define XML_LINE_RIGHT 1
54#define XML_LINE_BOTTOM 3
56#define XML_LINE_TLBR 0
57#define XML_LINE_BLTR 1
67using com::sun::star::uno::UNO_QUERY;
70 SvXMLImport& rImportP) :
99 for (
auto& rProperty : rProperties)
134 if (pAllBorderWidthProperty)
135 pAllBorderWidthProperty->
mnIndex = -1;
136 if (pAllBorderProperty)
137 pAllBorderProperty->
mnIndex = -1;
138 if (pAllPaddingProperty)
139 pAllPaddingProperty->
mnIndex = -1;
141 for (
i = 0;
i < 4; ++
i)
143 if (pAllPaddingProperty && !pPadding[
i])
145 if (pAllBorderProperty && !pBorders[
i])
148 pBorders[
i] = pNewBorders[
i];
150 if( !pBorderWidths[
i] )
151 pBorderWidths[
i] = pAllBorderWidthProperty;
156 table::BorderLine2 aBorderLine;
157 pBorders[
i]->
maValue >>= aBorderLine;
158 if( pBorderWidths[
i] )
163 table::BorderLine2 aBorderLineWidth;
164 pBorderWidths[
i]->
maValue >>= aBorderLineWidth;
165 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
166 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
167 aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
168 pBorders[
i]->
maValue <<= aBorderLine;
172 for(
i = 0;
i < 2; ++
i )
174 if( pDiagBorders[
i] && ( pDiagBorderWidths[
i] || pOldDiagBorderWidths[
i] ) )
176 table::BorderLine2 aBorderLine;
177 pDiagBorders[
i]->
maValue >>= aBorderLine;
178 table::BorderLine2 aBorderLineWidth;
179 if (pDiagBorderWidths[
i])
180 pDiagBorderWidths[
i]->
maValue >>= aBorderLineWidth;
182 pOldDiagBorderWidths[
i]->
maValue >>= aBorderLineWidth;
183 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
184 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
185 aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
186 pDiagBorders[
i]->
maValue <<= aBorderLine;
187 if (pDiagBorderWidths[
i])
189 if (pOldDiagBorderWidths[
i])
190 pOldDiagBorderWidths[
i]->
mnIndex = -1;
194 for (
i = 0;
i < 4; ++
i)
198 rProperties.push_back(*pNewPadding[
i]);
199 delete pNewPadding[
i];
203 rProperties.push_back(*pNewBorders[
i]);
204 delete pNewBorders[
i];
211 SvXMLImport& rImportP) :
226 for (
auto& rProperty : rProperties)
242 if(!(::cppu::any2bool(pPageBreak->
maValue)))
247 if (::cppu::any2bool(pOptimalHeight->
maValue))
272 XMLTableCellPropsContext(
273 SvXMLImport& rImport, sal_Int32 nElement,
274 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
276 ::std::vector< XMLPropertyState > &rProps,
282 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
283 ::std::vector< XMLPropertyState > &rProperties,
289XMLTableCellPropsContext::XMLTableCellPropsContext(
290 SvXMLImport& rImport, sal_Int32 nElement,
291 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
293 ::std::vector< XMLPropertyState > &rProps,
300css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTableCellPropsContext::createFastChildContext(
302 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
303 ::std::vector< XMLPropertyState > &rProperties,
309 if (nElement ==
XML_ELEMENT(STYLE, XML_HYPERLINK) ||
315 if ( aIter.getToken() ==
XML_ELEMENT(XLINK, XML_HREF) )
316 sURL = aIter.toString();
320 if ( !sURL.isEmpty() )
323 aProp.maValue <<= sURL;
324 rProperties.push_back( aProp );
327 else if (nElement ==
XML_ELEMENT(LO_EXT, XML_BACKGROUND_COMPLEX_COLOR))
338 OUString msApplyStyle;
339 OUString msCondition;
346 SvXMLImport& rImport, sal_Int32 nElement,
347 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList );
354ScXMLMapContext::ScXMLMapContext(SvXMLImport& rImport, sal_Int32 ,
355 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
360 OUString sValue = aIter.toString();
361 switch (aIter.getToken())
364 msCondition = sValue;
380 OUString aCondition, aConditionNmsp;
381 FormulaGrammar::Grammar eGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
382 GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eGrammar, msCondition );
383 bool bHasNmsp = aCondition.getLength() < msCondition.getLength();
392 FormulaGrammar::Grammar eNewGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
393 GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eNewGrammar, aCondition,
true );
394 if( eNewGrammar != FormulaGrammar::GRAM_EXTERNAL )
395 eGrammar = eNewGrammar;
399 ScDocument* pDoc = GetScImport().GetDocument();
402 OUString(), OUString(), eGrammar, eGrammar);
409 const OUString& rValue )
432 mpCondFormat(nullptr),
433 mbDeleteCondFormat(true)
445 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
447 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
453 ScXMLMapContext* pMapContext =
new ScXMLMapContext(
GetImport(), nElement, xAttrList);
454 xContext = pMapContext;
463 xContext =
new XMLTableCellPropsContext(
GetImport(), nElement,
481 for(
const table::CellRangeAddress& aAddress : xCellRanges)
483 ScRange aRange( aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet, aAddress.EndColumn, aAddress.EndRow, aAddress.Sheet );
484 aRangeList.
Join( aRange );
490 auto itr = std::find_if(pFormatList->
begin(), pFormatList->
end(),
491 [
this](
const std::unique_ptr<ScConditionalFormat>& rxFormat) { return rxFormat->EqualEntries(*mpCondFormat); });
492 if (itr != pFormatList->
end())
495 sal_uInt32 nCondId = (*itr)->GetKey();
496 size_t n = aRangeList.
size();
497 for(
size_t i = 0;
i <
n; ++
i)
499 const ScRange & rRange = aRangeList[
i];
500 rRangeList.
Join(rRange);
520 const uno::Reference< XPropertySet > & rPropSet )
524 if (
GetFamily() == XmlStyleFamily::TABLE_CELL)
535 else if (
GetFamily() == XmlStyleFamily::TABLE_TABLE)
548 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(
GetImport().GetModel(), uno::UNO_QUERY);
549 if (xMultiServiceFactory.is())
551 uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance(
"com.sun.star.sheet.Defaults"), uno::UNO_QUERY);
552 if (xProperties.is())
562 property->mnIndex = -1;
564 OSL_ENSURE(
nIndex != -1,
"Property not found in Map");
575 OSL_ENSURE( xImpPrMap.is(),
"There is the import prop mapper" );
577 xPrMap = xImpPrMap->getPropertySetMapper();
582 return rProp.
mnIndex != -1 && xPrMap->GetEntryContextId(rProp.
mnIndex) == nContextID;
605 OSL_FAIL(
"not possible to get style");
616 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
620 if (nFamily == XmlStyleFamily::TEXT_PARAGRAPH || nFamily == XmlStyleFamily::TEXT_TEXT)
622 else if (nFamily == XmlStyleFamily::SD_GRAPHICS_ID)
626 nFamily, nElement, xAttrList );
632 case XmlStyleFamily::TABLE_CELL:
633 case XmlStyleFamily::TABLE_COLUMN:
634 case XmlStyleFamily::TABLE_ROW:
635 case XmlStyleFamily::TABLE_TABLE:
647 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
655 case XmlStyleFamily::TABLE_CELL:
658 case XmlStyleFamily::SD_GRAPHICS_ID:
672 const bool bTempAutoStyles )
674 , nNumberFormatIndex(-1)
675 , nConditionalFormatIndex(-1)
676 , nCellStyleIndex(-1)
677 , nMasterPageNameIndex(-1)
678 , bAutoStyles(bTempAutoStyles)
689 GetImport().GetTextImport()->SetAutoStyles(
this );
704 case XmlStyleFamily::TABLE_CELL:
715 case XmlStyleFamily::TABLE_COLUMN:
723 case XmlStyleFamily::TABLE_ROW:
731 case XmlStyleFamily::TABLE_TABLE:
746uno::Reference < XNameContainer >
755 case XmlStyleFamily::TABLE_TABLE:
760 sName =
"TableStyles";
763 case XmlStyleFamily::TABLE_CELL:
768 sName =
"CellStyles";
771 case XmlStyleFamily::TABLE_COLUMN:
776 sName =
"ColumnStyles";
779 case XmlStyleFamily::TABLE_ROW:
787 case XmlStyleFamily::SD_GRAPHICS_ID:
792 sName =
"GraphicStyles";
799 uno::Reference< XStyleFamiliesSupplier > xFamiliesSupp(
801 if (xFamiliesSupp.is())
803 uno::Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
807 xStyles.set(xFamilies->getByName(
sName ), uno::UNO_QUERY);
809 catch ( uno::Exception& )
817 case XmlStyleFamily::TABLE_TABLE:
820 case XmlStyleFamily::TABLE_CELL:
823 case XmlStyleFamily::TABLE_COLUMN:
826 case XmlStyleFamily::TABLE_ROW:
829 case XmlStyleFamily::SD_GRAPHICS_ID:
848 case XmlStyleFamily::TABLE_COLUMN:
851 case XmlStyleFamily::TABLE_ROW:
854 case XmlStyleFamily::TABLE_CELL:
857 case XmlStyleFamily::TABLE_TABLE:
860 case XmlStyleFamily::SD_GRAPHICS_ID:
920 const uno::Reference< XFastAttributeList > & xAttrList )
928 !
GetImport().GetTextImport()->IsInsertMode() );
938 const uno::Reference< XFastAttributeList > & )
951 const uno::Reference< XFastAttributeList > & xAttrList,
954 bContainsRightHeader(false),
955 bContainsRightFooter(false)
965 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
983 bFooter, bLeft, bFirst );
993 uno::Reference < sheet::XHeaderFooterContent > xHeaderFooterContent(
xPropSet->getPropertyValue( rContent ), uno::UNO_QUERY);
994 if (xHeaderFooterContent.is())
996 xHeaderFooterContent->getLeftText()->setString(
"");
997 xHeaderFooterContent->getCenterText()->setString(
"");
998 xHeaderFooterContent->getRightText()->setString(
"");
1030 ScCellTextCursor* pCellImp = comphelper::getFromUnoTunnel<ScCellTextCursor>( xPropSet );
1038 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(
GetImport().GetModel())->GetSheetSaveData();
1046 ScDrawTextCursor* pDrawImp = comphelper::getFromUnoTunnel<ScDrawTextCursor>( xPropSet );
1051 if (pAnnotationContext)
constexpr OUStringLiteral sServiceName
const ScAddress & GetPosition() const
uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?)
ScCellObj & GetCellObj() const
const ScXMLImport & GetScImport() const
ScCellTextStyleContext(SvXMLImport &rImport, SvXMLStylesContext &rStyles, XmlStyleFamily nFamily)
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
virtual ~ScCellTextStyleContext() override
static ScConditionMode GetModeFromApi(css::sheet::ConditionOperator nOperator)
void SetSrcString(const OUString &rNew)
SC_DLLPUBLIC void AddCondFormatData(const ScRangeList &rRange, SCTAB nTab, sal_uInt32 nIndex)
SC_DLLPUBLIC ScConditionalFormatList * GetCondFormList(SCTAB nTab) const
SC_DLLPUBLIC sal_uLong AddCondFormat(std::unique_ptr< ScConditionalFormat > pNew, SCTAB nTab)
virtual SvXMLImportContext * CreateHeaderFooterContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, const bool bFooter, const bool bLeft, const bool bFirst) override
void ClearContent(const OUString &rContent)
ScMasterPageContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, bool bOverwrite)
bool bContainsRightFooter
virtual ~ScMasterPageContext() override
css::uno::Reference< css::beans::XPropertySet > xPropSet
bool bContainsRightHeader
virtual void Finish(bool bOverwrite) override
SCTAB GetCurrentSheet() const
void Join(const ScRange &, bool bIsInList=false)
void Finish(bool bOverwrite) override
void AddTextStyle(const OUString &rName, const ScAddress &rCellPos, const ESelection &rSelection)
void AddContentStyle(XmlStyleFamily nFamily, const OUString &rName, const ESelection &rSelection)
ScXMLCellImportPropertyMapper(const rtl::Reference< XMLPropertySetMapper > &rMapper, SvXMLImport &rImport)
virtual ~ScXMLCellImportPropertyMapper() override
virtual void finished(::std::vector< XMLPropertyState > &rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex) const override
This method is called when all attributes have been processed.
const rtl::Reference< XMLPropertySetMapper > & GetRowStylesPropertySetMapper() const
const rtl::Reference< XMLPropertySetMapper > & GetCellStylesPropertySetMapper() const
ScDocument * GetDocument()
virtual SvXMLStyleContext * CreateStyleChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
ScXMLMasterStylesContext(SvXMLImport &rImport)
virtual SvXMLStyleContext * CreateStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
virtual bool InsertStyleFamily(XmlStyleFamily nFamily) const override
virtual ~ScXMLMasterStylesContext() override
virtual void finished(::std::vector< XMLPropertyState > &rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex) const override
This method is called when all attributes have been processed.
ScXMLRowImportPropertyMapper(const rtl::Reference< XMLPropertySetMapper > &rMapper, SvXMLImport &rImport)
virtual ~ScXMLRowImportPropertyMapper() override
SvXMLImport & GetImport()
friend friend class SvXMLImport
const rtl::Reference< XMLPropertySetMapper > & getPropertySetMapper() const
virtual void finished(::std::vector< XMLPropertyState > &rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex) const
SvXMLImport & GetImport() const
rtl::Reference< XMLPropertySetMapper > maPropMapper
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
const OUString & GetName() const
XmlStyleFamily GetFamily() const
const OUString & GetParentName() const
bool IsDefaultStyle() const
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
virtual css::uno::Reference< css::container::XNameContainer > GetStylesContainer(XmlStyleFamily nFamily) const
virtual SvXMLStyleContext * CreateDefaultStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
virtual rtl::Reference< SvXMLImportPropertyMapper > GetImportPropertyMapper(XmlStyleFamily nFamily) const
virtual SvXMLStyleContext * CreateStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
void FinishStyles(bool bOverwrite)
virtual OUString GetServiceName(XmlStyleFamily nFamily) const
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
const SvXMLStylesContext * GetStyles() const
const ::std::vector< XMLPropertyState > & GetProperties() const
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue) override
virtual void Finish(bool bOverwrite) override
ScXMLAnnotationContext * GetAnnotationContext() const
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
void ApplyCondFormat(const css::uno::Sequence< css::table::CellRangeAddress > &xCellRanges)
void AddProperty(sal_Int16 nContextID, const css::uno::Any &aValue)
XMLPropertyState * FindProperty(const sal_Int16 nContextID)
virtual void SetDefaults() override
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
ScConditionalFormat * mpCondFormat
SvXMLStylesContext * pStyles
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue) override
const ScXMLImport & GetScImport() const
XMLTableStyleContext(ScXMLImport &rImport, SvXMLStylesContext &rStyles, XmlStyleFamily nFamily, bool bDefaultStyle=false)
sal_Int32 GetNumberFormat()
virtual ~XMLTableStyleContext() override
sal_Int32 nMasterPageNameIndex
css::uno::Reference< css::container::XNameContainer > xRowStyles
sal_Int32 nConditionalFormatIndex
sal_Int32 nCellStyleIndex
sal_Int32 nNumberFormatIndex
virtual css::uno::Reference< css::container::XNameContainer > GetStylesContainer(XmlStyleFamily nFamily) const override
rtl::Reference< SvXMLImportPropertyMapper > xTableImpPropMapper
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
rtl::Reference< SvXMLImportPropertyMapper > xRowImpPropMapper
virtual ~XMLTableStylesContext() override
XMLTableStylesContext(SvXMLImport &rImport, bool bAutoStyles)
css::uno::Reference< css::container::XNameContainer > xColumnStyles
virtual OUString GetServiceName(XmlStyleFamily nFamily) const override
css::uno::Reference< css::container::XNameContainer > xCellStyles
virtual SvXMLStyleContext * CreateDefaultStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
css::uno::Reference< css::container::XNameContainer > xTableStyles
virtual rtl::Reference< SvXMLImportPropertyMapper > GetImportPropertyMapper(XmlStyleFamily nFamily) const override
virtual SvXMLStyleContext * CreateStyleStyleChildContext(XmlStyleFamily nFamily, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
sal_Int32 GetIndex(const sal_Int16 nContextID)
css::uno::Reference< css::container::XNameContainer > xGraphicStyles
const ScXMLImport & GetScImport() const
rtl::Reference< SvXMLImportPropertyMapper > xCellImpPropMapper
rtl::Reference< SvXMLImportPropertyMapper > xColumnImpPropMapper
static SvXMLImportPropertyMapper * CreateParaExtPropMapper(SvXMLImport &)
virtual void Finish(bool bOverwrite) override
const css::uno::Reference< css::style::XStyle > & GetStyle() const
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet) override
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME
constexpr OUStringLiteral XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME
void parseCondition(ScXMLConditionParseResult &rParseResult, const OUString &rAttribute, sal_Int32 nStartIndex)
Parses the next condition in a 'condition' attribute value of e.g.
enumrange< T >::Iterator begin(enumrange< T >)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_TABLE_CELL_PROPERTIES
Result of an attempt to parse a single condition in a 'condition' attribute value of e....
OUString maOperand2
First operand of the token or comparison value.
OUString maOperand1
A comparison operator if existing.
css::sheet::ConditionOperator meOperator
A data validation type if existing.
constexpr OUStringLiteral SC_UNO_PAGE_RIGHTFTRCON
constexpr OUStringLiteral SC_UNO_PAGE_RIGHTHDRCON
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)
constexpr sal_Int32 TOKEN_MASK
#define CTF_SC_ALLPADDING
#define CTF_SC_DIAGONALTLBRWIDTHS
#define CTF_SC_LEFTBORDERWIDTH
#define CTF_SC_TOPPADDING
#define CTF_SC_NUMBERFORMAT
#define CTF_SC_ROWOPTIMALHEIGHT
#define CTF_SC_TOPBORDERWIDTH
#define CTF_SC_DIAGONALBLTRWIDTH
#define CTF_SC_ALLBORDERWIDTH
#define CTF_SC_DIAGONALTLBRWIDTH
#define CTF_SC_BOTTOMPADDING
#define CTF_SC_MASTERPAGENAME
#define CTF_SC_DIAGONALBLTRWIDTHS
#define CTF_SC_RIGHTBORDER
#define CTF_SC_IMPORT_MAP
#define CTF_SC_BOTTOMBORDERWIDTH
#define CTF_SC_RIGHTBORDERWIDTH
#define CTF_SC_DIAGONALTLBR
#define CTF_SC_DIAGONALBLTR
#define CTF_SC_RIGHTPADDING
#define CTF_SC_BOTTOMBORDER
#define CTF_SC_ROWBREAKBEFORE
#define CTF_SC_LEFTPADDING
#define CTF_SC_LEFTBORDER
constexpr OUStringLiteral gsCellStyleServiceName(u"com.sun.star.style.CellStyle")
constexpr OUStringLiteral gsGraphicStyleServiceName(u"com.sun.star.style.GraphicStyle")
#define XML_TYPE_PROP_TABLE_CELL