Line data Source code
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 "xmlstyli.hxx"
21 : #include <xmloff/nmspmap.hxx>
22 : #include <xmloff/xmlnmspe.hxx>
23 : #include <xmloff/xmlimppr.hxx>
24 : #include <xmloff/families.hxx>
25 : #include <xmloff/xmlnumfi.hxx>
26 : #include <xmloff/XMLGraphicsDefaultStyle.hxx>
27 : #include <xmloff/xmltoken.hxx>
28 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
29 : #include <com/sun/star/container/XNameContainer.hpp>
30 : #include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
31 : #include <com/sun/star/table/BorderLine2.hpp>
32 : #include <comphelper/extract.hxx>
33 : #include <xmloff/xmlprcon.hxx>
34 : #include <xmloff/xmluconv.hxx>
35 : #include "XMLTableHeaderFooterContext.hxx"
36 : #include "XMLConverter.hxx"
37 : #include "XMLTableShapeImportHelper.hxx"
38 : #include "sheetdata.hxx"
39 : #include "xmlannoi.hxx"
40 : #include "textuno.hxx"
41 : #include "cellsuno.hxx"
42 :
43 : #include "docuno.hxx"
44 : #include "unonames.hxx"
45 : #include "document.hxx"
46 : #include "conditio.hxx"
47 : #include "svl/intitem.hxx"
48 : #include "rangelst.hxx"
49 : #include "rangeutl.hxx"
50 : #include "docfunc.hxx"
51 : #include "markdata.hxx"
52 : #include "docpool.hxx"
53 : #include "scitems.hxx"
54 : #include "patattr.hxx"
55 :
56 : #define XML_LINE_LEFT 0
57 : #define XML_LINE_RIGHT 1
58 : #define XML_LINE_TOP 2
59 : #define XML_LINE_BOTTOM 3
60 :
61 : #define XML_LINE_TLBR 0
62 : #define XML_LINE_BLTR 1
63 :
64 : using namespace ::com::sun::star;
65 : using namespace ::com::sun::star::xml::sax;
66 : using namespace ::com::sun::star::style;
67 : using namespace ::com::sun::star::frame;
68 : using namespace ::com::sun::star::beans;
69 : using namespace ::com::sun::star::container;
70 : using namespace xmloff::token;
71 : using namespace ::formula;
72 :
73 : using com::sun::star::uno::Reference;
74 : using com::sun::star::uno::UNO_QUERY;
75 :
76 32 : ScXMLCellImportPropertyMapper::ScXMLCellImportPropertyMapper(
77 : const UniReference< XMLPropertySetMapper >& rMapper,
78 : SvXMLImport& rImportP) :
79 32 : SvXMLImportPropertyMapper( rMapper, rImportP )
80 : {
81 32 : }
82 :
83 64 : ScXMLCellImportPropertyMapper::~ScXMLCellImportPropertyMapper()
84 : {
85 64 : }
86 :
87 276 : void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const
88 : {
89 : static const sal_Int16 aPaddingCTF[4] = { CTF_SC_LEFTPADDING, CTF_SC_RIGHTPADDING,
90 : CTF_SC_TOPPADDING, CTF_SC_BOTTOMPADDING };
91 : static const sal_Int16 aBorderCTF[4] = { CTF_SC_LEFTBORDER, CTF_SC_RIGHTBORDER,
92 : CTF_SC_TOPBORDER, CTF_SC_BOTTOMBORDER };
93 :
94 276 : SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex);
95 276 : XMLPropertyState* pAllPaddingProperty(NULL);
96 276 : XMLPropertyState* pPadding[4] = { NULL, NULL, NULL, NULL };
97 276 : XMLPropertyState* pNewPadding[4] = { NULL, NULL, NULL, NULL };
98 276 : XMLPropertyState* pAllBorderProperty = NULL;
99 276 : XMLPropertyState* pBorders[4] = { NULL, NULL, NULL, NULL };
100 276 : XMLPropertyState* pNewBorders[4] = { NULL, NULL, NULL, NULL };
101 276 : XMLPropertyState* pAllBorderWidthProperty = NULL;
102 276 : XMLPropertyState* pBorderWidths[4] = { NULL, NULL, NULL, NULL };
103 276 : XMLPropertyState* pDiagBorders[2] = { 0 };
104 276 : XMLPropertyState* pOldDiagBorderWidths[2] = { 0 }; // old attribute names without "s"
105 276 : XMLPropertyState* pDiagBorderWidths[2] = { 0 };
106 :
107 276 : ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end());
108 1513 : for (::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
109 : aIter != endproperty; ++aIter)
110 : {
111 1237 : XMLPropertyState*property = &(*aIter);
112 1237 : if (property->mnIndex != -1)
113 : {
114 1237 : sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex);
115 1237 : switch (nContextID)
116 : {
117 0 : case CTF_SC_ALLPADDING : pAllPaddingProperty = &*property; break;
118 19 : case CTF_SC_LEFTPADDING : pPadding[XML_LINE_LEFT] = &*property; break;
119 19 : case CTF_SC_RIGHTPADDING : pPadding[XML_LINE_RIGHT] = &*property; break;
120 19 : case CTF_SC_TOPPADDING : pPadding[XML_LINE_TOP] = &*property; break;
121 19 : case CTF_SC_BOTTOMPADDING : pPadding[XML_LINE_BOTTOM] = &*property; break;
122 24 : case CTF_SC_ALLBORDER : pAllBorderProperty = &*property; break;
123 38 : case CTF_SC_LEFTBORDER : pBorders[XML_LINE_LEFT] = &*property; break;
124 38 : case CTF_SC_RIGHTBORDER : pBorders[XML_LINE_RIGHT] = &*property; break;
125 38 : case CTF_SC_TOPBORDER : pBorders[XML_LINE_TOP] = &*property; break;
126 38 : case CTF_SC_BOTTOMBORDER : pBorders[XML_LINE_BOTTOM] = &*property; break;
127 12 : case CTF_SC_ALLBORDERWIDTH : pAllBorderWidthProperty = &*property; break;
128 0 : case CTF_SC_LEFTBORDERWIDTH : pBorderWidths[XML_LINE_LEFT] = &*property; break;
129 0 : case CTF_SC_RIGHTBORDERWIDTH : pBorderWidths[XML_LINE_RIGHT] = &*property; break;
130 0 : case CTF_SC_TOPBORDERWIDTH : pBorderWidths[XML_LINE_TOP] = &*property; break;
131 0 : case CTF_SC_BOTTOMBORDERWIDTH : pBorderWidths[XML_LINE_BOTTOM] = &*property; break;
132 0 : case CTF_SC_DIAGONALTLBR : pDiagBorders[XML_LINE_TLBR] = &*property; break;
133 0 : case CTF_SC_DIAGONALBLTR : pDiagBorders[XML_LINE_BLTR] = &*property; break;
134 0 : case CTF_SC_DIAGONALTLBRWIDTH : pOldDiagBorderWidths[XML_LINE_TLBR] = &*property; break;
135 0 : case CTF_SC_DIAGONALTLBRWIDTHS : pDiagBorderWidths[XML_LINE_TLBR] = &*property; break;
136 0 : case CTF_SC_DIAGONALBLTRWIDTH : pOldDiagBorderWidths[XML_LINE_BLTR] = &*property; break;
137 0 : case CTF_SC_DIAGONALBLTRWIDTHS : pDiagBorderWidths[XML_LINE_BLTR] = &*property; break;
138 : }
139 : }
140 : }
141 : sal_uInt16 i;
142 :
143 : // #i27594#; copy Value, but don't insert
144 276 : if (pAllBorderWidthProperty)
145 12 : pAllBorderWidthProperty->mnIndex = -1;
146 276 : if (pAllBorderProperty)
147 24 : pAllBorderProperty->mnIndex = -1;
148 276 : if (pAllPaddingProperty)
149 0 : pAllPaddingProperty->mnIndex = -1;
150 :
151 1380 : for (i = 0; i < 4; ++i)
152 : {
153 1104 : if (pAllPaddingProperty && !pPadding[i])
154 0 : pNewPadding[i] = new XMLPropertyState(maPropMapper->FindEntryIndex(aPaddingCTF[i]), pAllPaddingProperty->maValue);
155 1104 : if (pAllBorderProperty && !pBorders[i])
156 : {
157 96 : pNewBorders[i] = new XMLPropertyState(maPropMapper->FindEntryIndex(aBorderCTF[i]), pAllBorderProperty->maValue);
158 96 : pBorders[i] = pNewBorders[i];
159 : }
160 1104 : if( !pBorderWidths[i] )
161 1104 : pBorderWidths[i] = pAllBorderWidthProperty;
162 : else
163 0 : pBorderWidths[i]->mnIndex = -1;
164 1104 : if( pBorders[i] )
165 : {
166 248 : table::BorderLine2 aBorderLine;
167 248 : pBorders[i]->maValue >>= aBorderLine;
168 248 : if( pBorderWidths[i] )
169 : {
170 : // Merge style:border-line-width values to fo:border values. Do
171 : // not override fo:border line width or line style with an
172 : // empty value!
173 48 : table::BorderLine2 aBorderLineWidth;
174 48 : pBorderWidths[i]->maValue >>= aBorderLineWidth;
175 48 : aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
176 48 : aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
177 48 : aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
178 48 : pBorders[i]->maValue <<= aBorderLine;
179 : }
180 : }
181 : }
182 828 : for( i = 0; i < 2; ++i )
183 : {
184 552 : if( pDiagBorders[i] && ( pDiagBorderWidths[i] || pOldDiagBorderWidths[i] ) )
185 : {
186 0 : table::BorderLine2 aBorderLine;
187 0 : pDiagBorders[i]->maValue >>= aBorderLine;
188 0 : table::BorderLine2 aBorderLineWidth;
189 0 : if (pDiagBorderWidths[i])
190 0 : pDiagBorderWidths[i]->maValue >>= aBorderLineWidth; // prefer new attribute
191 : else
192 0 : pOldDiagBorderWidths[i]->maValue >>= aBorderLineWidth;
193 0 : aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
194 0 : aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
195 0 : aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
196 0 : pDiagBorders[i]->maValue <<= aBorderLine;
197 0 : if (pDiagBorderWidths[i])
198 0 : pDiagBorderWidths[i]->mnIndex = -1;
199 0 : if (pOldDiagBorderWidths[i])
200 0 : pOldDiagBorderWidths[i]->mnIndex = -1; // reset mnIndex for old and new attribute if both are present
201 : }
202 : }
203 :
204 1380 : for (i = 0; i < 4; ++i)
205 : {
206 1104 : if (pNewPadding[i])
207 : {
208 0 : rProperties.push_back(*pNewPadding[i]);
209 0 : delete pNewPadding[i];
210 : }
211 1104 : if (pNewBorders[i])
212 : {
213 96 : rProperties.push_back(*pNewBorders[i]);
214 96 : delete pNewBorders[i];
215 : }
216 : }
217 276 : }
218 :
219 22 : ScXMLRowImportPropertyMapper::ScXMLRowImportPropertyMapper(
220 : const UniReference< XMLPropertySetMapper >& rMapper,
221 : SvXMLImport& rImportP) :
222 22 : SvXMLImportPropertyMapper( rMapper, rImportP )
223 : {
224 22 : }
225 :
226 44 : ScXMLRowImportPropertyMapper::~ScXMLRowImportPropertyMapper()
227 : {
228 44 : }
229 :
230 37 : void ScXMLRowImportPropertyMapper::finished(::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const
231 : {
232 37 : SvXMLImportPropertyMapper::finished(rProperties, nStartIndex, nEndIndex);
233 37 : XMLPropertyState* pHeight(NULL);
234 37 : XMLPropertyState* pOptimalHeight(NULL);
235 37 : XMLPropertyState* pPageBreak(NULL);
236 37 : ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end());
237 148 : for (::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
238 : aIter != endproperty; ++aIter)
239 : {
240 111 : XMLPropertyState* property = &(*aIter);
241 111 : if (property->mnIndex != -1)
242 : {
243 111 : sal_Int16 nContextID = getPropertySetMapper()->GetEntryContextId(property->mnIndex);
244 111 : switch (nContextID)
245 : {
246 37 : case CTF_SC_ROWHEIGHT : pHeight = property; break;
247 37 : case CTF_SC_ROWOPTIMALHEIGHT : pOptimalHeight = property; break;
248 37 : case CTF_SC_ROWBREAKBEFORE : pPageBreak = property; break;
249 : }
250 : }
251 : }
252 37 : if (pPageBreak)
253 : {
254 37 : if(!(::cppu::any2bool(pPageBreak->maValue)))
255 37 : pPageBreak->mnIndex = -1;
256 : }
257 37 : if (pOptimalHeight)
258 : {
259 37 : if (::cppu::any2bool(pOptimalHeight->maValue))
260 : {
261 35 : if (pHeight)
262 : {
263 : // set the stored height, but keep "optimal" flag:
264 : // pass the height value as OptimalHeight property (only allowed while loading!)
265 35 : pOptimalHeight->maValue = pHeight->maValue;
266 35 : pHeight->mnIndex = -1;
267 : }
268 : else
269 0 : pOptimalHeight->mnIndex = -1;
270 : }
271 : }
272 0 : else if (pHeight)
273 : {
274 0 : rProperties.push_back(XMLPropertyState(maPropMapper->FindEntryIndex(CTF_SC_ROWOPTIMALHEIGHT), ::cppu::bool2any( false )));
275 : }
276 : // don't access pointers to rProperties elements after push_back!
277 37 : }
278 :
279 : class ScXMLMapContext : public SvXMLImportContext
280 : {
281 : rtl::OUString msApplyStyle;
282 : rtl::OUString msCondition;
283 : rtl::OUString msBaseCell;
284 :
285 : const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
286 33 : ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
287 : public:
288 :
289 : ScXMLMapContext(
290 : SvXMLImport& rImport, sal_uInt16 nPrfx,
291 : const rtl::OUString& rLName,
292 : const uno::Reference< xml::sax::XAttributeList > & xAttrList );
293 : virtual ~ScXMLMapContext();
294 :
295 : ScCondFormatEntry* CreateConditionEntry();
296 : };
297 :
298 11 : ScXMLMapContext::ScXMLMapContext(SvXMLImport& rImport, sal_uInt16 nPrfx,
299 : const OUString& rLName, const uno::Reference< xml::sax::XAttributeList > & xAttrList )
300 11 : : SvXMLImportContext( rImport, nPrfx, rLName )
301 : {
302 11 : sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
303 44 : for( sal_Int16 i=0; i < nAttrCount; ++i )
304 : {
305 33 : const OUString& rAttrName(xAttrList->getNameByIndex( i ));
306 33 : OUString aLocalName;
307 33 : sal_uInt16 nPrefix(GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ));
308 33 : const OUString& rValue(xAttrList->getValueByIndex( i ));
309 :
310 : // TODO: use a map here
311 33 : if( XML_NAMESPACE_STYLE == nPrefix )
312 : {
313 33 : if( IsXMLToken(aLocalName, XML_CONDITION ) )
314 11 : msCondition = rValue;
315 22 : else if( IsXMLToken(aLocalName, XML_APPLY_STYLE_NAME ) )
316 11 : msApplyStyle = GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TABLE_CELL, rValue);
317 11 : else if ( IsXMLToken(aLocalName, XML_BASE_CELL_ADDRESS ) )
318 11 : msBaseCell = rValue;
319 : }
320 33 : }
321 11 : }
322 :
323 11 : ScCondFormatEntry* ScXMLMapContext::CreateConditionEntry()
324 : {
325 11 : OUString aCondition, aConditionNmsp;
326 11 : FormulaGrammar::Grammar eGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
327 11 : GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eGrammar, msCondition );
328 11 : bool bHasNmsp = aCondition.getLength() < msCondition.getLength();
329 :
330 : // parse a condition from the attribute string
331 11 : ScXMLConditionParseResult aParseResult;
332 11 : ScXMLConditionHelper::parseCondition( aParseResult, aCondition, 0 );
333 :
334 11 : if( !bHasNmsp )
335 : {
336 : // the attribute does not contain a namespace: try to find a namespace of an external grammar
337 11 : FormulaGrammar::Grammar eNewGrammar = FormulaGrammar::GRAM_UNSPECIFIED;
338 11 : GetScImport().ExtractFormulaNamespaceGrammar( aCondition, aConditionNmsp, eNewGrammar, aCondition, true );
339 11 : if( eNewGrammar != FormulaGrammar::GRAM_EXTERNAL )
340 11 : eGrammar = eNewGrammar;
341 : }
342 :
343 11 : ScConditionMode eMode = ScConditionEntry::GetModeFromApi(aParseResult.meOperator);
344 11 : rtl::OUString aExpr1, aExpr2, aNmsp1, aNmsp2;
345 11 : ScDocument* pDoc = GetScImport().GetDocument();
346 :
347 : ScCondFormatEntry* pEntry = new ScCondFormatEntry(eMode, aParseResult.maOperand1, aParseResult.maOperand2, pDoc, ScAddress(), msApplyStyle,
348 11 : aNmsp1, aNmsp2, eGrammar, eGrammar);
349 :
350 11 : pEntry->SetSrcString(msBaseCell);
351 11 : return pEntry;
352 : }
353 :
354 22 : ScXMLMapContext::~ScXMLMapContext()
355 : {
356 22 : }
357 :
358 927 : void XMLTableStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
359 : const OUString& rLocalName,
360 : const OUString& rValue )
361 : {
362 : // TODO: use a map here
363 927 : if( IsXMLToken(rLocalName, XML_DATA_STYLE_NAME ) )
364 44 : sDataStyleName = rValue;
365 883 : else if ( IsXMLToken(rLocalName, XML_MASTER_PAGE_NAME ) )
366 22 : sPageStyle = rValue;
367 : else
368 861 : XMLPropStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
369 927 : }
370 :
371 0 : TYPEINIT1( XMLTableStyleContext, XMLPropStyleContext );
372 :
373 341 : XMLTableStyleContext::XMLTableStyleContext( ScXMLImport& rImport,
374 : sal_uInt16 nPrfx, const OUString& rLName,
375 : const uno::Reference< XAttributeList > & xAttrList,
376 : SvXMLStylesContext& rStyles, sal_uInt16 nFamily, bool bDefaultStyle ) :
377 : XMLPropStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle ),
378 : sDataStyleName(),
379 : pStyles(&rStyles),
380 : nNumberFormat(-1),
381 : nLastSheet(-1),
382 : bParentSet(false),
383 : mpCondFormat(NULL),
384 341 : mbDeleteCondFormat(true)
385 : {
386 341 : }
387 :
388 1023 : XMLTableStyleContext::~XMLTableStyleContext()
389 : {
390 341 : if(mbDeleteCondFormat)
391 338 : delete mpCondFormat;
392 682 : }
393 :
394 389 : SvXMLImportContext *XMLTableStyleContext::CreateChildContext(
395 : sal_uInt16 nPrefix,
396 : const OUString& rLocalName,
397 : const uno::Reference< XAttributeList > & xAttrList )
398 : {
399 389 : SvXMLImportContext *pContext(NULL);
400 :
401 778 : if( (XML_NAMESPACE_STYLE == nPrefix) &&
402 389 : IsXMLToken(rLocalName, XML_MAP ) )
403 : {
404 11 : if(!mpCondFormat)
405 3 : mpCondFormat = new ScConditionalFormat( 0, GetScImport().GetDocument() );
406 11 : ScXMLMapContext* pMapContext = new ScXMLMapContext(GetImport(), nPrefix, rLocalName, xAttrList);
407 11 : pContext = pMapContext;
408 11 : mpCondFormat->AddEntry(pMapContext->CreateConditionEntry());
409 : }
410 389 : if (!pContext)
411 : pContext = XMLPropStyleContext::CreateChildContext( nPrefix, rLocalName,
412 378 : xAttrList );
413 389 : return pContext;
414 : }
415 :
416 96 : void XMLTableStyleContext::ApplyCondFormat( uno::Sequence<table::CellRangeAddress> xCellRanges )
417 : {
418 96 : if(!mpCondFormat || GetScImport().HasNewCondFormatData())
419 : return;
420 :
421 3 : ScRangeList aRangeList;
422 3 : sal_Int32 nRanges = xCellRanges.getLength();
423 6 : for(sal_Int32 i = 0; i < nRanges; ++i)
424 : {
425 3 : table::CellRangeAddress aAddress = xCellRanges[i];
426 3 : ScRange aRange( aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet, aAddress.EndColumn, aAddress.EndRow, aAddress.Sheet );
427 3 : aRangeList.Join( aRange, false );
428 : }
429 :
430 3 : ScDocument* pDoc = GetScImport().GetDocument();
431 3 : SCTAB nTab = GetScImport().GetTables().GetCurrentSheet();
432 3 : ScConditionalFormatList* pFormatList = pDoc->GetCondFormList(nTab);
433 6 : for(ScConditionalFormatList::iterator itr = pFormatList->begin(), itrEnd = pFormatList->end();
434 : itr != itrEnd; ++itr)
435 : {
436 3 : if(itr->EqualEntries(*mpCondFormat))
437 : {
438 0 : ScRangeList& rRangeList = itr->GetRangeList();
439 0 : sal_uInt32 nCondId = itr->GetKey();
440 0 : size_t n = aRangeList.size();
441 0 : for(size_t i = 0; i < n; ++i)
442 : {
443 0 : const ScRange* pRange = aRangeList[i];
444 0 : rRangeList.Join(*pRange);
445 : }
446 :
447 0 : pDoc->AddCondFormatData( aRangeList, nTab, nCondId );
448 : return;
449 : }
450 : }
451 :
452 3 : if(mpCondFormat && mbDeleteCondFormat)
453 : {
454 3 : sal_uLong nIndex = pDoc->AddCondFormat(mpCondFormat, nTab );
455 3 : mpCondFormat->SetKey(nIndex);
456 3 : mpCondFormat->AddRange(aRangeList);
457 :
458 3 : pDoc->AddCondFormatData( aRangeList, nTab, nIndex );
459 3 : mbDeleteCondFormat = false;
460 3 : }
461 :
462 :
463 : }
464 :
465 1722 : void XMLTableStyleContext::FillPropertySet(
466 : const uno::Reference< XPropertySet > & rPropSet )
467 : {
468 1722 : if (!IsDefaultStyle())
469 : {
470 1700 : if (GetFamily() == XML_STYLE_FAMILY_TABLE_CELL)
471 : {
472 221 : if (!bParentSet)
473 : {
474 217 : AddProperty(CTF_SC_CELLSTYLE, uno::makeAny(GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TABLE_CELL, GetParentName() )));
475 217 : bParentSet = true;
476 : }
477 221 : sal_Int32 nNumFmt = GetNumberFormat();
478 221 : if (nNumFmt >= 0)
479 44 : AddProperty(CTF_SC_NUMBERFORMAT, uno::makeAny(nNumFmt));
480 : }
481 1479 : else if (GetFamily() == XML_STYLE_FAMILY_TABLE_TABLE)
482 : {
483 50 : if (!sPageStyle.isEmpty())
484 50 : AddProperty(CTF_SC_MASTERPAGENAME, uno::makeAny(GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_MASTER_PAGE, sPageStyle )));
485 : }
486 : }
487 1722 : XMLPropStyleContext::FillPropertySet(rPropSet);
488 1722 : }
489 :
490 22 : void XMLTableStyleContext::SetDefaults()
491 : {
492 22 : if ((GetFamily() == XML_STYLE_FAMILY_TABLE_CELL) && GetImport().GetModel().is())
493 : {
494 22 : uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetImport().GetModel(), uno::UNO_QUERY);
495 22 : if (xMultiServiceFactory.is())
496 : {
497 22 : uno::Reference <beans::XPropertySet> xProperties(xMultiServiceFactory->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.Defaults"))), uno::UNO_QUERY);
498 22 : if (xProperties.is())
499 22 : FillPropertySet(xProperties);
500 22 : }
501 : }
502 22 : }
503 :
504 311 : void XMLTableStyleContext::AddProperty(const sal_Int16 nContextID, const uno::Any& rValue)
505 : {
506 311 : XMLPropertyState* property = FindProperty(nContextID);
507 311 : if (property)
508 28 : property->mnIndex = -1; // #i46996# remove old property, so it isn't double
509 311 : sal_Int32 nIndex(static_cast<XMLTableStylesContext *>(pStyles)->GetIndex(nContextID));
510 : OSL_ENSURE(nIndex != -1, "Property not found in Map");
511 311 : XMLPropertyState aPropState(nIndex, rValue);
512 311 : GetProperties().push_back(aPropState); // has to be insertes in a sort order later
513 311 : }
514 :
515 311 : XMLPropertyState* XMLTableStyleContext::FindProperty(const sal_Int16 nContextID)
516 : {
517 311 : XMLPropertyState* pRet = NULL;
518 311 : UniReference < XMLPropertySetMapper > xPrMap;
519 : UniReference < SvXMLImportPropertyMapper > xImpPrMap =
520 311 : pStyles->GetImportPropertyMapper( GetFamily() );
521 : OSL_ENSURE( xImpPrMap.is(), "There is the import prop mapper" );
522 311 : if( xImpPrMap.is() )
523 311 : xPrMap = xImpPrMap->getPropertySetMapper();
524 311 : if( xPrMap.is() )
525 : {
526 311 : ::std::vector< XMLPropertyState >::iterator endproperty(GetProperties().end());
527 311 : ::std::vector< XMLPropertyState >::iterator aIter(GetProperties().begin());
528 1653 : while(!pRet && aIter != endproperty)
529 : {
530 1031 : XMLPropertyState* property = &(*aIter);
531 1031 : if (property->mnIndex != -1 && xPrMap->GetEntryContextId(property->mnIndex) == nContextID)
532 : {
533 28 : pRet = property;
534 : }
535 : else
536 1003 : ++aIter;
537 : }
538 : }
539 311 : return pRet;
540 : }
541 :
542 317 : sal_Int32 XMLTableStyleContext::GetNumberFormat()
543 : {
544 317 : if (nNumberFormat < 0 && !sDataStyleName.isEmpty())
545 : {
546 : const SvXMLNumFormatContext* pStyle = static_cast<const SvXMLNumFormatContext*>(
547 44 : pStyles->FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True));
548 :
549 44 : if (!pStyle)
550 : {
551 0 : XMLTableStylesContext* pMyStyles = static_cast<XMLTableStylesContext*>(GetScImport().GetStyles());
552 0 : if (pMyStyles)
553 : pStyle = static_cast<const SvXMLNumFormatContext*>(
554 0 : pMyStyles->FindStyleChildContext(XML_STYLE_FAMILY_DATA_STYLE, sDataStyleName, sal_True));
555 : else
556 : {
557 : OSL_FAIL("not possible to get style");
558 : }
559 : }
560 44 : if (pStyle)
561 44 : nNumberFormat = const_cast<SvXMLNumFormatContext*>(pStyle)->GetKey();
562 : }
563 317 : return nNumberFormat;
564 : }
565 :
566 : // ----------------------------------------------------------------------------
567 :
568 325 : SvXMLStyleContext *XMLTableStylesContext::CreateStyleStyleChildContext(
569 : sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
570 : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
571 : {
572 : SvXMLStyleContext *pStyle;
573 : // use own wrapper for text and paragraph, to record style usage
574 325 : if (nFamily == XML_STYLE_FAMILY_TEXT_PARAGRAPH || nFamily == XML_STYLE_FAMILY_TEXT_TEXT)
575 3 : pStyle = new ScCellTextStyleContext( GetImport(), nPrefix, rLocalName,
576 3 : xAttrList, *this, nFamily );
577 : else
578 : pStyle = SvXMLStylesContext::CreateStyleStyleChildContext(
579 322 : nFamily, nPrefix, rLocalName, xAttrList );
580 :
581 325 : if (!pStyle)
582 : {
583 319 : switch( nFamily )
584 : {
585 : case XML_STYLE_FAMILY_TABLE_CELL:
586 : case XML_STYLE_FAMILY_TABLE_COLUMN:
587 : case XML_STYLE_FAMILY_TABLE_ROW:
588 : case XML_STYLE_FAMILY_TABLE_TABLE:
589 : pStyle = new XMLTableStyleContext( GetScImport(), nPrefix, rLocalName,
590 319 : xAttrList, *this, nFamily );
591 319 : break;
592 : }
593 : }
594 :
595 325 : return pStyle;
596 : }
597 :
598 23 : SvXMLStyleContext *XMLTableStylesContext::CreateDefaultStyleStyleChildContext(
599 : sal_uInt16 nFamily, sal_uInt16 nPrefix, const OUString& rLocalName,
600 : const uno::Reference< xml::sax::XAttributeList > & xAttrList )
601 : {
602 : SvXMLStyleContext *pStyle(SvXMLStylesContext::CreateDefaultStyleStyleChildContext( nFamily, nPrefix,
603 : rLocalName,
604 23 : xAttrList ));
605 23 : if (!pStyle)
606 : {
607 23 : switch( nFamily )
608 : {
609 : case XML_STYLE_FAMILY_TABLE_CELL:
610 : pStyle = new XMLTableStyleContext( GetScImport(), nPrefix, rLocalName,
611 22 : xAttrList, *this, nFamily, sal_True);
612 22 : break;
613 : case XML_STYLE_FAMILY_SD_GRAPHICS_ID:
614 1 : pStyle = new XMLGraphicsDefaultStyle( GetScImport(), nPrefix, rLocalName,
615 1 : xAttrList, *this);
616 1 : break;
617 : }
618 : }
619 :
620 23 : return pStyle;
621 : }
622 :
623 66 : XMLTableStylesContext::XMLTableStylesContext( SvXMLImport& rImport,
624 : sal_uInt16 nPrfx ,
625 : const OUString& rLName ,
626 : const uno::Reference< XAttributeList > & xAttrList,
627 : const bool bTempAutoStyles ) :
628 : SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList ),
629 : sCellStyleServiceName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.CellStyle" ) )),
630 : sColumnStyleServiceName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_COLUMN_STYLES_NAME ))),
631 : sRowStyleServiceName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_ROW_STYLES_NAME ))),
632 : sTableStyleServiceName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( XML_STYLE_FAMILY_TABLE_TABLE_STYLES_NAME ))),
633 : nNumberFormatIndex(-1),
634 : nConditionalFormatIndex(-1),
635 : nCellStyleIndex(-1),
636 : nMasterPageNameIndex(-1),
637 66 : bAutoStyles(bTempAutoStyles)
638 : {
639 66 : }
640 :
641 132 : XMLTableStylesContext::~XMLTableStylesContext()
642 : {
643 132 : }
644 :
645 66 : void XMLTableStylesContext::EndElement()
646 : {
647 66 : SvXMLStylesContext::EndElement();
648 66 : if (bAutoStyles)
649 44 : GetImport().GetTextImport()->SetAutoStyles( this );
650 : else
651 22 : ((ScXMLImport&)GetImport()).InsertStyles();
652 66 : }
653 :
654 : UniReference < SvXMLImportPropertyMapper >
655 2814 : XMLTableStylesContext::GetImportPropertyMapper(
656 : sal_uInt16 nFamily ) const
657 : {
658 2814 : UniReference < SvXMLImportPropertyMapper > xMapper(SvXMLStylesContext::GetImportPropertyMapper(nFamily));
659 :
660 2814 : if (!xMapper.is())
661 : {
662 2616 : switch( nFamily )
663 : {
664 : case XML_STYLE_FAMILY_TABLE_CELL:
665 : {
666 963 : if( !xCellImpPropMapper.is() )
667 : {
668 : ((XMLTableStylesContext *)this)->xCellImpPropMapper =
669 32 : new ScXMLCellImportPropertyMapper( GetScImport().GetCellStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
670 32 : xCellImpPropMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(const_cast<SvXMLImport&>(GetImport()), const_cast<XMLFontStylesContext*>(GetScImport().GetFontDecls())));
671 : }
672 963 : xMapper = xCellImpPropMapper;
673 : }
674 963 : break;
675 : case XML_STYLE_FAMILY_TABLE_COLUMN:
676 : {
677 124 : if( !xColumnImpPropMapper.is() )
678 : ((XMLTableStylesContext *)this)->xColumnImpPropMapper =
679 22 : new SvXMLImportPropertyMapper( GetScImport().GetColumnStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
680 124 : xMapper = xColumnImpPropMapper;
681 : }
682 124 : break;
683 : case XML_STYLE_FAMILY_TABLE_ROW:
684 : {
685 1385 : if( !xRowImpPropMapper.is() )
686 : ((XMLTableStylesContext *)this)->xRowImpPropMapper =
687 22 : new ScXMLRowImportPropertyMapper( GetScImport().GetRowStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
688 1385 : xMapper = xRowImpPropMapper;
689 : }
690 1385 : break;
691 : case XML_STYLE_FAMILY_TABLE_TABLE:
692 : {
693 144 : if( !xTableImpPropMapper.is() )
694 : ((XMLTableStylesContext *)this)->xTableImpPropMapper =
695 22 : new SvXMLImportPropertyMapper( GetScImport().GetTableStylesPropertySetMapper(), const_cast<SvXMLImport&>(GetImport()) );
696 144 : xMapper = xTableImpPropMapper;
697 : }
698 144 : break;
699 : }
700 : }
701 :
702 2814 : return xMapper;
703 : }
704 :
705 : uno::Reference < XNameContainer >
706 250 : XMLTableStylesContext::GetStylesContainer( sal_uInt16 nFamily ) const
707 : {
708 250 : uno::Reference < XNameContainer > xStyles(SvXMLStylesContext::GetStylesContainer(nFamily));
709 250 : if (!xStyles.is())
710 : {
711 250 : OUString sName;
712 250 : switch( nFamily )
713 : {
714 : case XML_STYLE_FAMILY_TABLE_TABLE:
715 : {
716 0 : if( xTableStyles.is() )
717 0 : xStyles.set(xTableStyles);
718 : else
719 : sName =
720 0 : OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "TableStyles" ) ));
721 : }
722 0 : break;
723 : case XML_STYLE_FAMILY_TABLE_CELL:
724 : {
725 250 : if( xCellStyles.is() )
726 228 : xStyles.set(xCellStyles);
727 : else
728 : sName =
729 22 : OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) ));
730 : }
731 250 : break;
732 : case XML_STYLE_FAMILY_TABLE_COLUMN:
733 : {
734 0 : if( xColumnStyles.is() )
735 0 : xStyles.set(xColumnStyles);
736 : else
737 : sName =
738 0 : OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColumnStyles" ) ));
739 : }
740 0 : break;
741 : case XML_STYLE_FAMILY_TABLE_ROW:
742 : {
743 0 : if( xRowStyles.is() )
744 0 : xStyles.set(xRowStyles);
745 : else
746 : sName =
747 0 : OUString( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "RowStyles" ) ));
748 : }
749 0 : break;
750 : }
751 250 : if( !xStyles.is() && !sName.isEmpty() && GetScImport().GetModel().is() )
752 : {
753 : uno::Reference< XStyleFamiliesSupplier > xFamiliesSupp(
754 22 : GetScImport().GetModel(), UNO_QUERY );
755 22 : if (xFamiliesSupp.is())
756 : {
757 22 : uno::Reference< XNameAccess > xFamilies(xFamiliesSupp->getStyleFamilies());
758 :
759 : try
760 : {
761 22 : xStyles.set(xFamilies->getByName( sName ), uno::UNO_QUERY);
762 : }
763 0 : catch ( uno::Exception& )
764 : {
765 : // #i97680# Named table/column/row styles aren't supported, getByName will throw an exception.
766 : // For better interoperability, these styles should then be handled as automatic styles.
767 : // For now, NULL is returned (and the style is ignored).
768 : }
769 22 : switch( nFamily )
770 : {
771 : case XML_STYLE_FAMILY_TABLE_TABLE:
772 0 : ((XMLTableStylesContext *)this)->xTableStyles.set(xStyles);
773 0 : break;
774 : case XML_STYLE_FAMILY_TABLE_CELL:
775 22 : ((XMLTableStylesContext *)this)->xCellStyles.set(xStyles);
776 22 : break;
777 : case XML_STYLE_FAMILY_TABLE_COLUMN:
778 0 : ((XMLTableStylesContext *)this)->xColumnStyles.set(xStyles);
779 0 : break;
780 : case XML_STYLE_FAMILY_TABLE_ROW:
781 0 : ((XMLTableStylesContext *)this)->xRowStyles.set(xStyles);
782 0 : break;
783 22 : }
784 22 : }
785 250 : }
786 : }
787 :
788 250 : return xStyles;
789 : }
790 :
791 15 : OUString XMLTableStylesContext::GetServiceName( sal_uInt16 nFamily ) const
792 : {
793 15 : rtl::OUString sServiceName(SvXMLStylesContext::GetServiceName(nFamily));
794 15 : if (sServiceName.isEmpty())
795 : {
796 15 : switch( nFamily )
797 : {
798 : case XML_STYLE_FAMILY_TABLE_COLUMN:
799 0 : sServiceName = sColumnStyleServiceName;
800 0 : break;
801 : case XML_STYLE_FAMILY_TABLE_ROW:
802 0 : sServiceName = sRowStyleServiceName;
803 0 : break;
804 : case XML_STYLE_FAMILY_TABLE_CELL:
805 15 : sServiceName = sCellStyleServiceName;
806 15 : break;
807 : case XML_STYLE_FAMILY_TABLE_TABLE:
808 0 : sServiceName = sTableStyleServiceName;
809 0 : break;
810 : }
811 : }
812 15 : return sServiceName;
813 : }
814 :
815 311 : sal_Int32 XMLTableStylesContext::GetIndex(const sal_Int16 nContextID)
816 : {
817 311 : if (nContextID == CTF_SC_CELLSTYLE)
818 : {
819 217 : if (nCellStyleIndex == -1)
820 : nCellStyleIndex =
821 32 : GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
822 217 : return nCellStyleIndex;
823 : }
824 94 : else if (nContextID == CTF_SC_NUMBERFORMAT)
825 : {
826 44 : if (nNumberFormatIndex == -1)
827 : nNumberFormatIndex =
828 26 : GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
829 44 : return nNumberFormatIndex;
830 : }
831 50 : else if (nContextID == CTF_SC_IMPORT_MAP)
832 : {
833 0 : if (nConditionalFormatIndex == -1)
834 : nConditionalFormatIndex =
835 0 : GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_CELL)->getPropertySetMapper()->FindEntryIndex(nContextID);
836 0 : return nConditionalFormatIndex;
837 : }
838 50 : else if (nContextID == CTF_SC_MASTERPAGENAME)
839 : {
840 50 : if (nMasterPageNameIndex == -1)
841 : nMasterPageNameIndex =
842 22 : GetImportPropertyMapper(XML_STYLE_FAMILY_TABLE_TABLE)->getPropertySetMapper()->FindEntryIndex(nContextID);
843 50 : return nMasterPageNameIndex;
844 : }
845 : else
846 0 : return -1;
847 : }
848 :
849 : // ---------------------------------------------------------------------------
850 0 : TYPEINIT1( ScXMLMasterStylesContext, SvXMLStylesContext );
851 :
852 88 : sal_Bool ScXMLMasterStylesContext::InsertStyleFamily( sal_uInt16 ) const
853 : {
854 88 : return sal_True;
855 : }
856 :
857 22 : ScXMLMasterStylesContext::ScXMLMasterStylesContext(
858 : SvXMLImport& rImport,
859 : sal_uInt16 nPrfx, const OUString& rLName,
860 : const uno::Reference< XAttributeList > & xAttrList ) :
861 22 : SvXMLStylesContext( rImport, nPrfx, rLName, xAttrList )
862 : {
863 22 : }
864 :
865 44 : ScXMLMasterStylesContext::~ScXMLMasterStylesContext()
866 : {
867 44 : }
868 :
869 44 : SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleChildContext(
870 : sal_uInt16 nPrefix,
871 : const OUString& rLocalName,
872 : const uno::Reference< XAttributeList > & xAttrList )
873 : {
874 44 : SvXMLStyleContext *pContext(0);
875 :
876 132 : if( (XML_NAMESPACE_STYLE == nPrefix) &&
877 44 : IsXMLToken(rLocalName, XML_MASTER_PAGE) &&
878 44 : InsertStyleFamily( XML_STYLE_FAMILY_MASTER_PAGE ) )
879 : pContext = new ScMasterPageContext(
880 44 : GetImport(), nPrefix, rLocalName, xAttrList,
881 44 : !GetImport().GetTextImport()->IsInsertMode() );
882 :
883 : // any other style will be ignored here!
884 :
885 44 : return pContext;
886 : }
887 :
888 0 : SvXMLStyleContext *ScXMLMasterStylesContext::CreateStyleStyleChildContext(
889 : sal_uInt16 /* nFamily */,
890 : sal_uInt16 /* nPrefix */,
891 : const OUString& /* rLocalName */,
892 : const uno::Reference< XAttributeList > & /* xAttrList */ )
893 : {
894 0 : return 0;
895 : }
896 :
897 22 : void ScXMLMasterStylesContext::EndElement()
898 : {
899 22 : FinishStyles(sal_True);
900 22 : }
901 :
902 0 : TYPEINIT1( ScMasterPageContext, XMLTextMasterPageContext );
903 :
904 44 : ScMasterPageContext::ScMasterPageContext( SvXMLImport& rImport,
905 : sal_uInt16 nPrfx, const OUString& rLName,
906 : const uno::Reference< XAttributeList > & xAttrList,
907 : bool bOverwrite ) :
908 : XMLTextMasterPageContext( rImport, nPrfx, rLName, xAttrList, bOverwrite ),
909 : bContainsRightHeader(false),
910 44 : bContainsRightFooter(false)
911 : {
912 44 : }
913 :
914 88 : ScMasterPageContext::~ScMasterPageContext()
915 : {
916 88 : }
917 :
918 176 : SvXMLImportContext *ScMasterPageContext::CreateChildContext(
919 : sal_uInt16 nPrefix,
920 : const OUString& rLocalName,
921 : const uno::Reference< XAttributeList > & xAttrList )
922 : {
923 176 : return XMLTextMasterPageContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
924 : }
925 :
926 176 : SvXMLImportContext *ScMasterPageContext::CreateHeaderFooterContext(
927 : sal_uInt16 nPrefix,
928 : const ::rtl::OUString& rLocalName,
929 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
930 : const sal_Bool bFooter,
931 : const sal_Bool bLeft,
932 : const sal_Bool /*bFirst*/ )
933 : {
934 176 : if (!bLeft)
935 : {
936 88 : if (bFooter)
937 44 : bContainsRightFooter = sal_True;
938 : else
939 44 : bContainsRightHeader = sal_True;
940 : }
941 176 : if (!xPropSet.is())
942 44 : xPropSet.set(GetStyle(), UNO_QUERY );
943 176 : return new XMLTableHeaderFooterContext( GetImport(),
944 : nPrefix, rLocalName,
945 : xAttrList,
946 : xPropSet,
947 176 : bFooter, bLeft );
948 : }
949 :
950 0 : void ScMasterPageContext::ClearContent(const rtl::OUString& rContent)
951 : {
952 0 : if (!xPropSet.is())
953 0 : xPropSet.set(GetStyle(), UNO_QUERY );
954 :
955 0 : if (xPropSet.is())
956 : {
957 0 : uno::Reference < sheet::XHeaderFooterContent > xHeaderFooterContent(xPropSet->getPropertyValue( rContent ), uno::UNO_QUERY);
958 0 : if (xHeaderFooterContent.is())
959 : {
960 0 : xHeaderFooterContent->getLeftText()->setString(sEmpty);
961 0 : xHeaderFooterContent->getCenterText()->setString(sEmpty);
962 0 : xHeaderFooterContent->getRightText()->setString(sEmpty);
963 0 : xPropSet->setPropertyValue( rContent, uno::makeAny(xHeaderFooterContent) );
964 0 : }
965 : }
966 0 : }
967 :
968 44 : void ScMasterPageContext::Finish( sal_Bool bOverwrite )
969 : {
970 44 : XMLTextMasterPageContext::Finish(bOverwrite);
971 44 : if (!bContainsRightFooter)
972 0 : ClearContent(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_PAGE_RIGHTFTRCON)));
973 44 : if (!bContainsRightHeader)
974 0 : ClearContent(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_PAGE_RIGHTHDRCON)));
975 44 : }
976 :
977 : // ---------------------------------------------------------------------------
978 :
979 3 : ScCellTextStyleContext::ScCellTextStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
980 : const rtl::OUString& rLName, const uno::Reference<xml::sax::XAttributeList> & xAttrList,
981 : SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle ) :
982 : XMLTextStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily, bDefaultStyle ),
983 3 : nLastSheet(-1)
984 : {
985 3 : }
986 :
987 6 : ScCellTextStyleContext::~ScCellTextStyleContext()
988 : {
989 6 : }
990 :
991 5 : void ScCellTextStyleContext::FillPropertySet( const uno::Reference<beans::XPropertySet>& xPropSet )
992 : {
993 5 : XMLTextStyleContext::FillPropertySet( xPropSet );
994 :
995 5 : ScXMLImport& rXMLImport = GetScImport();
996 :
997 5 : ScCellTextCursor* pCellImp = ScCellTextCursor::getImplementation( xPropSet );
998 5 : if (pCellImp)
999 : {
1000 1 : ScAddress aPos = pCellImp->GetCellObj().GetPosition();
1001 1 : if ( aPos.Tab() != nLastSheet )
1002 : {
1003 1 : ESelection aSel = pCellImp->GetSelection();
1004 :
1005 1 : ScSheetSaveData* pSheetData = ScModelObj::getImplementation(GetImport().GetModel())->GetSheetSaveData();
1006 1 : pSheetData->AddTextStyle( GetName(), aPos, aSel );
1007 :
1008 1 : nLastSheet = aPos.Tab();
1009 : }
1010 : }
1011 4 : else if ( rXMLImport.GetTables().GetCurrentSheet() != nLastSheet )
1012 : {
1013 4 : ScDrawTextCursor* pDrawImp = ScDrawTextCursor::getImplementation( xPropSet );
1014 4 : if (pDrawImp)
1015 : {
1016 1 : XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)GetScImport().GetShapeImport().get();
1017 1 : ScXMLAnnotationContext* pAnnotationContext = pTableShapeImport->GetAnnotationContext();
1018 1 : if (pAnnotationContext)
1019 : {
1020 1 : pAnnotationContext->AddContentStyle( GetFamily(), GetName(), pDrawImp->GetSelection() );
1021 1 : nLastSheet = rXMLImport.GetTables().GetCurrentSheet();
1022 : }
1023 : }
1024 :
1025 : // if it's a different shape, BlockSheet is called from XMLTableShapeImportHelper::finishShape
1026 : // formatted text in page headers/footers can be ignored
1027 : }
1028 5 : }
1029 :
1030 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|