27#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28#include <com/sun/star/table/BorderLine2.hpp>
41#include <unonames.hxx>
42#include <document.hxx>
46#define XML_LINE_LEFT 0
47#define XML_LINE_RIGHT 1
49#define XML_LINE_BOTTOM 3
51#define XML_LINE_TLBR 0
52#define XML_LINE_BLTR 1
62using com::sun::star::uno::UNO_QUERY;
65 SvXMLImport& rImportP) :
94 for (
auto& rProperty : rProperties)
129 if (pAllBorderWidthProperty)
130 pAllBorderWidthProperty->
mnIndex = -1;
131 if (pAllBorderProperty)
132 pAllBorderProperty->
mnIndex = -1;
133 if (pAllPaddingProperty)
134 pAllPaddingProperty->
mnIndex = -1;
136 for (
i = 0;
i < 4; ++
i)
138 if (pAllPaddingProperty && !pPadding[
i])
140 if (pAllBorderProperty && !pBorders[
i])
143 pBorders[
i] = pNewBorders[
i];
145 if( !pBorderWidths[
i] )
146 pBorderWidths[
i] = pAllBorderWidthProperty;
151 table::BorderLine2 aBorderLine;
152 pBorders[
i]->
maValue >>= aBorderLine;
153 if( pBorderWidths[
i] )
158 table::BorderLine2 aBorderLineWidth;
159 pBorderWidths[
i]->
maValue >>= aBorderLineWidth;
160 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
161 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
162 aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
163 pBorders[
i]->
maValue <<= aBorderLine;
167 for(
i = 0;
i < 2; ++
i )
169 if( pDiagBorders[
i] && ( pDiagBorderWidths[
i] || pOldDiagBorderWidths[
i] ) )
171 table::BorderLine2 aBorderLine;
172 pDiagBorders[
i]->
maValue >>= aBorderLine;
173 table::BorderLine2 aBorderLineWidth;
174 if (pDiagBorderWidths[
i])
175 pDiagBorderWidths[
i]->
maValue >>= aBorderLineWidth;
177 pOldDiagBorderWidths[
i]->
maValue >>= aBorderLineWidth;
178 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
179 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
180 aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
181 pDiagBorders[
i]->
maValue <<= aBorderLine;
182 if (pDiagBorderWidths[
i])
184 if (pOldDiagBorderWidths[
i])
185 pOldDiagBorderWidths[
i]->
mnIndex = -1;
189 for (
i = 0;
i < 4; ++
i)
193 rProperties.push_back(*pNewPadding[
i]);
194 delete pNewPadding[
i];
198 rProperties.push_back(*pNewBorders[
i]);
199 delete pNewBorders[
i];
206 SvXMLImport& rImportP) :
221 for (
auto& rProperty : rProperties)
237 if(!(::cppu::any2bool(pPageBreak->
maValue)))
242 if (::cppu::any2bool(pOptimalHeight->
maValue))
267 XMLTableCellPropsContext(
268 SvXMLImport& rImport, sal_Int32 nElement,
269 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
271 ::std::vector< XMLPropertyState > &rProps,
277 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
278 ::std::vector< XMLPropertyState > &rProperties,
284XMLTableCellPropsContext::XMLTableCellPropsContext(
285 SvXMLImport& rImport, sal_Int32 nElement,
286 const uno::Reference< xml::sax::XFastAttributeList >& xAttrList,
288 ::std::vector< XMLPropertyState > &rProps,
295css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTableCellPropsContext::createFastChildContext(
297 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
298 ::std::vector< XMLPropertyState > &rProperties,
304 if (nElement ==
XML_ELEMENT(STYLE, XML_HYPERLINK) ||
310 if ( aIter.getToken() ==
XML_ELEMENT(XLINK, XML_HREF) )
311 sURL = aIter.toString();
315 if ( !sURL.isEmpty() )
318 aProp.maValue <<= sURL;
319 rProperties.push_back( aProp );
329 OUString msApplyStyle;
330 OUString msCondition;
337 SvXMLImport& rImport, sal_Int32 nElement,
338 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList );
345ScXMLMapContext::ScXMLMapContext(SvXMLImport& rImport, sal_Int32 ,
346 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
351 OUString sValue = aIter.toString();
352 switch (aIter.getToken())
355 msCondition = sValue;
371 OUString aCondition, aConditionNmsp;
372 FormulaGrammar::Grammar eGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
373 GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eGrammar, msCondition );
374 bool bHasNmsp = aCondition.getLength() < msCondition.getLength();
383 FormulaGrammar::Grammar eNewGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
384 GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eNewGrammar, aCondition,
true );
385 if( eNewGrammar != FormulaGrammar::GRAM_EXTERNAL )
386 eGrammar = eNewGrammar;
390 ScDocument* pDoc = GetScImport().GetDocument();
393 OUString(), OUString(), eGrammar, eGrammar);
400 const OUString& rValue )
423 mpCondFormat(nullptr),
424 mbDeleteCondFormat(true)
436 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
438 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
444 ScXMLMapContext* pMapContext =
new ScXMLMapContext(
GetImport(), nElement, xAttrList);
445 xContext = pMapContext;
454 xContext =
new XMLTableCellPropsContext(
GetImport(), nElement,
472 for(
const table::CellRangeAddress& aAddress : xCellRanges)
474 ScRange aRange( aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet, aAddress.EndColumn, aAddress.EndRow, aAddress.Sheet );
475 aRangeList.
Join( aRange );
481 auto itr = std::find_if(pFormatList->
begin(), pFormatList->
end(),
482 [
this](
const std::unique_ptr<ScConditionalFormat>& rxFormat) { return rxFormat->EqualEntries(*mpCondFormat); });
483 if (itr != pFormatList->
end())
486 sal_uInt32 nCondId = (*itr)->GetKey();
487 size_t n = aRangeList.
size();
488 for(
size_t i = 0;
i <
n; ++
i)
490 const ScRange & rRange = aRangeList[
i];
491 rRangeList.
Join(rRange);
511 const uno::Reference< XPropertySet > & rPropSet )
515 if (
GetFamily() == XmlStyleFamily::TABLE_CELL)
526 else if (
GetFamily() == XmlStyleFamily::TABLE_TABLE)
539 uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(
GetImport().GetModel(), uno::UNO_QUERY);
540 if (xMultiServiceFactory.is())
542 uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance(
"com.sun.star.sheet.Defaults"), uno::UNO_QUERY);
543 if (xProperties.is())
553 property->mnIndex = -1;
555 OSL_ENSURE(
nIndex != -1,
"Property not found in Map");
566 OSL_ENSURE( xImpPrMap.is(),
"There is the import prop mapper" );
568 xPrMap = xImpPrMap->getPropertySetMapper();
573 return rProp.
mnIndex != -1 && xPrMap->GetEntryContextId(rProp.
mnIndex) == nContextID;
596 OSL_FAIL(
"not possible to get style");
607 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
611 if (nFamily == XmlStyleFamily::TEXT_PARAGRAPH || nFamily == XmlStyleFamily::TEXT_TEXT)
613 else if (nFamily == XmlStyleFamily::SD_GRAPHICS_ID)
617 nFamily, nElement, xAttrList );
623 case XmlStyleFamily::TABLE_CELL:
624 case XmlStyleFamily::TABLE_COLUMN:
625 case XmlStyleFamily::TABLE_ROW:
626 case XmlStyleFamily::TABLE_TABLE:
638 const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
646 case XmlStyleFamily::TABLE_CELL:
649 case XmlStyleFamily::SD_GRAPHICS_ID:
663 const bool bTempAutoStyles )
665 , nNumberFormatIndex(-1)
666 , nConditionalFormatIndex(-1)
667 , nCellStyleIndex(-1)
668 , nMasterPageNameIndex(-1)
669 , bAutoStyles(bTempAutoStyles)
680 GetImport().GetTextImport()->SetAutoStyles(
this );
695 case XmlStyleFamily::TABLE_CELL:
706 case XmlStyleFamily::TABLE_COLUMN:
714 case XmlStyleFamily::TABLE_ROW:
722 case XmlStyleFamily::TABLE_TABLE:
737uno::Reference < XNameContainer >
746 case XmlStyleFamily::TABLE_TABLE:
751 sName =
"TableStyles";
754 case XmlStyleFamily::TABLE_CELL:
759 sName =
"CellStyles";
762 case XmlStyleFamily::TABLE_COLUMN:
767 sName =
"ColumnStyles";
770 case XmlStyleFamily::TABLE_ROW:
778 case XmlStyleFamily::SD_GRAPHICS_ID:
783 sName =
"GraphicStyles";
790 uno::Reference< XStyleFamiliesSupplier > xFamiliesSupp(
792 if (xFamiliesSupp.is())
794 uno::Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
798 xStyles.set(xFamilies->getByName(
sName ), uno::UNO_QUERY);
800 catch ( uno::Exception& )
808 case XmlStyleFamily::TABLE_TABLE:
811 case XmlStyleFamily::TABLE_CELL:
814 case XmlStyleFamily::TABLE_COLUMN:
817 case XmlStyleFamily::TABLE_ROW:
820 case XmlStyleFamily::SD_GRAPHICS_ID:
839 case XmlStyleFamily::TABLE_COLUMN:
842 case XmlStyleFamily::TABLE_ROW:
845 case XmlStyleFamily::TABLE_CELL:
848 case XmlStyleFamily::TABLE_TABLE:
851 case XmlStyleFamily::SD_GRAPHICS_ID:
911 const uno::Reference< XFastAttributeList > & xAttrList )
919 !
GetImport().GetTextImport()->IsInsertMode() );
929 const uno::Reference< XFastAttributeList > & )
942 const uno::Reference< XFastAttributeList > & xAttrList,
945 bContainsRightHeader(false),
946 bContainsRightFooter(false)
956 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
974 bFooter, bLeft, bFirst );
984 uno::Reference < sheet::XHeaderFooterContent > xHeaderFooterContent(
xPropSet->getPropertyValue( rContent ), uno::UNO_QUERY);
985 if (xHeaderFooterContent.is())
987 xHeaderFooterContent->getLeftText()->setString(
"");
988 xHeaderFooterContent->getCenterText()->setString(
"");
989 xHeaderFooterContent->getRightText()->setString(
"");
1021 ScCellTextCursor* pCellImp = comphelper::getFromUnoTunnel<ScCellTextCursor>( xPropSet );
1029 ScSheetSaveData* pSheetData = comphelper::getFromUnoTunnel<ScModelObj>(
GetImport().GetModel())->GetSheetSaveData();
1037 ScDrawTextCursor* pDrawImp = comphelper::getFromUnoTunnel<ScDrawTextCursor>( xPropSet );
1042 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