sc/qa/unit/data/functions/date_time/fods/weeks.fods                            
    |  652 +++++++++-
 scaddins/source/datefunc/datefunc.cxx                                          
    |   71 -
 sw/inc/IDocumentSettingAccess.hxx                                              
    |    3 
 
sw/qa/extras/layout/data/tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_New.odt
 |binary
 
sw/qa/extras/layout/data/tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_Old.odt
 |binary
 sw/qa/extras/layout/layout.cxx                                                 
    |   24 
 sw/source/core/doc/DocumentSettingManager.cxx                                  
    |   15 
 sw/source/core/inc/DocumentSettingManager.hxx                                  
    |    1 
 sw/source/core/layout/findfrm.cxx                                              
    |    6 
 sw/source/filter/ww8/ww8par.cxx                                                
    |    2 
 sw/source/uibase/app/docshini.cxx                                              
    |    1 
 sw/source/uibase/uno/SwXDocumentSettings.cxx                                   
    |   18 
 writerfilter/source/dmapper/DomainMapper.cxx                                   
    |    1 
 13 files changed, 727 insertions(+), 67 deletions(-)

New commits:
commit 8a82c6f3f1e85c941ac05b48416450cec813a04e
Author:     Attila Szűcs <szucs.atti...@nisz.hu>
AuthorDate: Thu Nov 18 11:02:01 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Nov 30 10:08:34 2021 +0100

    tdf#54465 tdf#139336 sw: add compat. flag for footnote in column
    
    Add compatibility option FOOTNOTE_IN_COLUMN_TO_PAGEEND to keep layout
    of old ODT files, where multicolumn sections have footnotes in columns,
    growing sections to the full page.
    
    Note: Multicolumn page styles or not evenly distributed multicolumn
    sections, or footnotes not collected at the end of the sections still
    use footnotes in columns, so they don't need this compatibility option.
    
    Follow-up to commit 4c31b4ef2083087a822c3ae648fd09acc67d2f88
    "tdf#139336 sw: fix extra pages of multicolumn sections with footnotes".
    
    Co-authored-by: Tibor Nagy (NISZ)
    
    Change-Id: I7d6a1f804b555dc5372767014b8fb5e3fa57ba9b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125442
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 41cc1d2c0c0c3bfa5ba341311f68df05375859fb)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126001
    Reviewed-by: Attila Szűcs <szucs.atti...@nisz.hu>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Tested-by: Jenkins

diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 310f6a773c3d..d20130dbd3e5 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -114,6 +114,9 @@ enum class DocumentSettingId
     HEADER_SPACING_BELOW_LAST_PARA,
     FRAME_AUTOWIDTH_WITH_MORE_PARA,
     GUTTER_AT_TOP,
+    // footnoteContainer default position is the page end instead of the 
column end
+    // only if "evenly distributed" is set, and "collected at the end" is not 
set
+    FOOTNOTE_IN_COLUMN_TO_PAGEEND,
 };
 
 /** Provides access to settings of a document
diff --git 
a/sw/qa/extras/layout/data/tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_New.odt
 
b/sw/qa/extras/layout/data/tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_New.odt
new file mode 100644
index 000000000000..28a19263053a
Binary files /dev/null and 
b/sw/qa/extras/layout/data/tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_New.odt
 differ
diff --git 
a/sw/qa/extras/layout/data/tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_Old.odt
 
b/sw/qa/extras/layout/data/tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_Old.odt
new file mode 100644
index 000000000000..426e684937b3
Binary files /dev/null and 
b/sw/qa/extras/layout/data/tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_Old.odt
 differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 9050a00a86cf..3ef61970f5ae 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3733,6 +3733,30 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testTdf139336_ColumnsWithFootnoteDoNotOccup
     assertXPath(pXmlDoc, "/root/page", 2);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, 
testTdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage)
+{
+    // Old odt files should keep their original layout, as it was before 
Tdf139336 fix.
+    // The new odt file is only 1 page long, while the old odt file (with the 
same content)
+    // was more then 1 page long.
+    // Note: Somewhy this test miscalculates the layout of the old odt file.
+    // It will be 4 pages long, while opened in Writer it is 5 pages long.
+    SwDoc* pDoc
+        = createSwDoc(DATA_DIRECTORY, 
"tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_Old.odt");
+    CPPUNIT_ASSERT(pDoc);
+    Scheduler::ProcessEventsToIdle();
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, "/root/page");
+    xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
+    CPPUNIT_ASSERT_GREATER(1, xmlXPathNodeSetGetLength(pXmlNodes));
+    xmlXPathFreeObject(pXmlObj);
+
+    discardDumpedLayout();
+    pDoc = createSwDoc(DATA_DIRECTORY, 
"tdf54465_ColumnsWithFootnoteDoNotOccupyEntirePage_New.odt");
+    CPPUNIT_ASSERT(pDoc);
+    pXmlDoc = parseLayoutDump();
+    assertXPath(pXmlDoc, "/root/page", 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 883ab4736e73..2776422caf8e 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -102,7 +102,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
&rDoc)
     mbProtectFields(false),
     mbHeaderSpacingBelowLastPara(false),
     mbFrameAutowidthWithMorePara(false),
-    mbGutterAtTop(false)
+    mbGutterAtTop(false),
+    mbFootnoteInColumnToPageEnd(false)
 
     // COMPATIBILITY FLAGS END
 {
@@ -238,6 +239,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
         case DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA: return 
mbFrameAutowidthWithMorePara;
         case DocumentSettingId::GUTTER_AT_TOP:
             return mbGutterAtTop;
+        case DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND: return 
mbFootnoteInColumnToPageEnd;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -503,6 +505,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
         case DocumentSettingId::GUTTER_AT_TOP:
             mbGutterAtTop = value;
             break;
+        case DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND:
+            mbFootnoteInColumnToPageEnd = value;
+            break;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -679,6 +684,7 @@ void 
sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
     // No mbProtectFields: this is false by default everywhere
     mbHeaderSpacingBelowLastPara = rSource.mbHeaderSpacingBelowLastPara;
     mbFrameAutowidthWithMorePara = rSource.mbFrameAutowidthWithMorePara;
+    mbFootnoteInColumnToPageEnd = rSource.mbFootnoteInColumnToPageEnd;
 }
 
 sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const
@@ -990,7 +996,7 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr 
pWriter) const
 
     (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("mbFrameAutowidthWithMorePara"));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
-        BAD_CAST(OString::boolean(mbFrameAutowidthWithMorePara).getStr()));
+                                
BAD_CAST(OString::boolean(mbFrameAutowidthWithMorePara).getStr()));
     (void)xmlTextWriterEndElement(pWriter);
 
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbGutterAtTop"));
@@ -998,6 +1004,11 @@ void 
sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
                                 
BAD_CAST(OString::boolean(mbGutterAtTop).getStr()));
     (void)xmlTextWriterEndElement(pWriter);
 
+    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("mbFootnoteInColumnToPageEnd"));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+                                
BAD_CAST(OString::boolean(mbFootnoteInColumnToPageEnd).getStr()));
+    (void)xmlTextWriterEndElement(pWriter);
+
     (void)xmlTextWriterEndElement(pWriter);
 }
 
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 
b/sw/source/core/inc/DocumentSettingManager.hxx
index 19e55d5ede47..d5604f25490c 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -171,6 +171,7 @@ class DocumentSettingManager final :
     bool mbFrameAutowidthWithMorePara; //tdf#124423
     /// Gutter position: false means left (not a compatibility setting).
     bool mbGutterAtTop;
+    bool mbFootnoteInColumnToPageEnd;
 
 public:
 
diff --git a/sw/source/core/layout/findfrm.cxx 
b/sw/source/core/layout/findfrm.cxx
index 52d7e9627a1e..445d3e29dcd6 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -39,6 +39,7 @@
 #include <ndtxt.hxx>
 #include <osl/diagnose.h>
 #include <sal/log.hxx>
+#include <IDocumentSettingAccess.hxx>
 
 
 /// Searches the first ContentFrame in BodyText below the page.
@@ -457,7 +458,10 @@ SwFootnoteBossFrame* SwFrame::FindFootnoteBossFrame( bool 
bFootnotes )
     //         similar case can be reached with a page break + FootnoteAtEnd 
setting
     SwSectionFrame* pSectframe = pRet->FindSctFrame();
     bool bMoveToPageFrame = false;
-    if (pSectframe)
+    // tdf54465: compatibility flag to make old odt files keep these full page 
sections.
+    if (pSectframe
+        && pSectframe->GetFormat()->getIDocumentSettingAccess().get(
+            DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND))
     {
         SwSection* pSect = pSectframe->GetSection();
         if (pSect) {
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 818e3b013549..be67ed1fa795 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1823,6 +1823,8 @@ void SwWW8ImplReader::ImportDop()
         DocumentSettingId::HEADER_SPACING_BELOW_LAST_PARA, true);
     m_rDoc.getIDocumentSettingAccess().set(
         DocumentSettingId::FRAME_AUTOWIDTH_WITH_MORE_PARA, true);
+    m_rDoc.getIDocumentSettingAccess().set(
+        DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND, true);
 
     // Import Default Tabs
     tools::Long nDefTabSiz = m_xWDop->dxaTab;
diff --git a/sw/source/uibase/app/docshini.cxx 
b/sw/source/uibase/app/docshini.cxx
index aabd3e8e4eb6..3694c51a0367 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -289,6 +289,7 @@ bool SwDocShell::InitNew( const uno::Reference < 
embed::XStorage >& xStor )
         // value 'false' in the SwDoc c-tor)
         m_xDoc->getIDocumentSettingAccess().set( 
DocumentSettingId::MATH_BASELINE_ALIGNMENT,
                 SW_MOD()->GetUsrPref( bWeb )->IsAlignMathObjectsToBaseline() );
+        m_xDoc->getIDocumentSettingAccess().set( 
DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND, true);
     }
 
     /* #106748# If the default frame direction of a document is RTL
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx 
b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 8a8caaaa605c..881ac1540239 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -149,6 +149,7 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_HEADER_SPACING_BELOW_LAST_PARA,
     HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA,
     HANDLE_GUTTER_AT_TOP,
+    HANDLE_FOOTNOTE_IN_COLUMN_TO_PAGEEND,
 };
 
 }
@@ -244,6 +245,7 @@ static rtl::Reference<MasterPropertySetInfo> 
lcl_createSettingsInfo()
         { OUString("HeaderSpacingBelowLastPara"), 
HANDLE_HEADER_SPACING_BELOW_LAST_PARA, cppu::UnoType<bool>::get(), 0 },
         { OUString("FrameAutowidthWithMorePara"), 
HANDLE_FRAME_AUTOWIDTH_WITH_MORE_PARA, cppu::UnoType<bool>::get(), 0 },
         { OUString("GutterAtTop"), HANDLE_GUTTER_AT_TOP, 
cppu::UnoType<bool>::get(), 0 },
+        { OUString("FootnoteInColumnToPageEnd"), 
HANDLE_FOOTNOTE_IN_COLUMN_TO_PAGEEND, cppu::UnoType<bool>::get(), 0 },
 
 /*
  * As OS said, we don't have a view when we need to set this, so I have to
@@ -1016,6 +1018,16 @@ void SwXDocumentSettings::_setSingleValue( const 
comphelper::PropertyInfo & rInf
             }
         }
         break;
+        case HANDLE_FOOTNOTE_IN_COLUMN_TO_PAGEEND:
+        {
+            bool bTmp;
+            if (rValue >>= bTmp)
+            {
+                mpDoc->getIDocumentSettingAccess().set(
+                    DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND, bTmp);
+            }
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
@@ -1522,6 +1534,12 @@ void SwXDocumentSettings::_getSingleValue( const 
comphelper::PropertyInfo & rInf
             rValue <<= 
mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::GUTTER_AT_TOP);
         }
         break;
+        case HANDLE_FOOTNOTE_IN_COLUMN_TO_PAGEEND:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get(
+                DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND);
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index a40099ef30c7..6001d49d2117 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -130,6 +130,7 @@ DomainMapper::DomainMapper( const uno::Reference< 
uno::XComponentContext >& xCon
     m_pImpl->SetDocumentSettingsProperty("HeaderSpacingBelowLastPara",
                                          uno::makeAny(true));
     m_pImpl->SetDocumentSettingsProperty("FrameAutowidthWithMorePara", 
uno::makeAny(true));
+    m_pImpl->SetDocumentSettingsProperty("FootnoteInColumnToPageEnd", 
uno::makeAny(true));
 
     m_pImpl->SetDocumentSettingsProperty("TabAtLeftIndentForParagraphsInList", 
uno::makeAny(true));
 
commit bd8e584db0c19a30164575d7fc8c583436db5b85
Author:     Winfried Donkers <winfrieddonk...@libreoffice.org>
AuthorDate: Tue Nov 16 16:55:52 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Nov 30 10:08:22 2021 +0100

    tdf#145578, tdf#145587 revise calculations for WEEKS Add-In function
    
    The calculations now follow the documentation for WEEKS in
    https://wiki.documentfoundation.org/Documentation/Calc_Functions/WEEKS.
    
    Change-Id: Ifede6e2ec2d9cfb7301fd5eb53bf7b6f187053bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125319
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 105196aa00bc0d3e426796f6729a8e7e51271e56)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125993
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/data/functions/date_time/fods/weeks.fods 
b/sc/qa/unit/data/functions/date_time/fods/weeks.fods
index a0d596086220..f05803ea6684 100644
--- a/sc/qa/unit/data/functions/date_time/fods/weeks.fods
+++ b/sc/qa/unit/data/functions/date_time/fods/weeks.fods
@@ -1056,25 +1056,657 @@
      <table:table-cell table:number-columns-repeated="3"/>
     </table:table-row>
     <table:table-row table:style-name="ro2">
-     <table:table-cell table:number-columns-repeated="2"/>
-     <table:table-cell table:style-name="ce19"/>
-     <table:table-cell table:number-columns-repeated="7"/>
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2022;1;2);DATE(2022;1;9);1)" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce31" 
table:formula="of:=[.A12]=[.B12]" office:value-type="boolean" 
office:boolean-value="false" calcext:value-type="boolean">
+      <text:p>ONWAAR</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A12])" office:value-type="string" 
office:string-value="=WEEKS(DATE(2022;1;2);DATE(2022;1;9);1)" 
calcext:value-type="string">
+      <text:p>=WEEKS(DATE(2022;1;2);DATE(2022;1;9);1)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145578</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="5"/>
      <table:table-cell office:value-type="float" office:value="17" 
calcext:value-type="float">
       <text:p>17</text:p>
      </table:table-cell>
      <table:table-cell table:number-columns-repeated="3"/>
     </table:table-row>
     <table:table-row table:style-name="ro2">
-     <table:table-cell table:number-columns-repeated="2"/>
-     <table:table-cell table:style-name="ce19"/>
-     <table:table-cell table:style-name="ce26"/>
-     <table:table-cell table:number-columns-repeated="5"/>
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2022;1;3);DATE(2022;1;10);1)" 
office:value-type="float" office:value="1" calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce31" 
table:formula="of:=[.A13]=[.B13]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>WAAR</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A13])" office:value-type="string" 
office:string-value="=WEEKS(DATE(2022;1;3);DATE(2022;1;10);1)" 
calcext:value-type="string">
+      <text:p>=WEEKS(DATE(2022;1;3);DATE(2022;1;10);1)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145578</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
      <table:table-cell table:style-name="ce27"/>
      <table:table-cell table:style-name="ce29" office:value-type="date" 
office:date-value="2001-12-01" calcext:value-type="date">
-      <text:p>12/01/2001</text:p>
+      <text:p>01-12-2001</text:p>
      </table:table-cell>
      <table:table-cell table:style-name="ce27" 
table:number-columns-repeated="3"/>
     </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2022;1;9);DATE(2022;1;2);1)" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="-1" 
calcext:value-type="float">
+      <text:p>-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce31" 
table:formula="of:=[.A14]=[.B14]" office:value-type="boolean" 
office:boolean-value="false" calcext:value-type="boolean">
+      <text:p>ONWAAR</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A14])" office:value-type="string" 
office:string-value="=WEEKS(DATE(2022;1;9);DATE(2022;1;2);1)" 
calcext:value-type="string">
+      <text:p>=WEEKS(DATE(2022;1;9);DATE(2022;1;2);1)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145578</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="9"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2021;11;14);DATE(2021;11;15);1)" 
office:value-type="float" office:value="1" calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce31" 
table:formula="of:=[.A15]=[.B15]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>WAAR</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A15])" office:value-type="string" 
office:string-value="=WEEKS(DATE(2021;11;14);DATE(2021;11;15);1)" 
calcext:value-type="string">
+      <text:p>=WEEKS(DATE(2021;11;14);DATE(2021;11;15);1)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="9"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2021;11;14);DATE(2021;11;15);0)" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce31" 
table:formula="of:=[.A16]=[.B16]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>WAAR</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A16])" office:value-type="string" 
office:string-value="=WEEKS(DATE(2021;11;14);DATE(2021;11;15);0)" 
calcext:value-type="string">
+      <text:p>=WEEKS(DATE(2021;11;14);DATE(2021;11;15);0)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce28"/>
+     <table:table-cell table:style-name="ce27" 
table:number-columns-repeated="4"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2010;01;01);DATE(2011;01;01);1)" 
office:value-type="float" office:value="52" calcext:value-type="float">
+      <text:p>52</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="52" 
calcext:value-type="float">
+      <text:p>52</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce31" 
table:formula="of:=[.A17]=[.B17]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>WAAR</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A17])" office:value-type="string" 
office:string-value="=WEEKS(DATE(2010;01;01);DATE(2011;01;01);1)" 
calcext:value-type="string">
+      <text:p>=WEEKS(DATE(2010;01;01);DATE(2011;01;01);1)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145578</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="9"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2011;01;01);DATE(2010;01;01);1)" 
office:value-type="float" office:value="-52" calcext:value-type="float">
+      <text:p>-52</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="-52" 
calcext:value-type="float">
+      <text:p>-52</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce31" 
table:formula="of:=[.A18]=[.B18]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>WAAR</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A18])" office:value-type="string" 
office:string-value="=WEEKS(DATE(2011;01;01);DATE(2010;01;01);1)" 
calcext:value-type="string">
+      <text:p>=WEEKS(DATE(2011;01;01);DATE(2010;01;01);1)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145578</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="9"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.$K$19];[.$K$20];0)" 
office:value-type="float" office:value="3" calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="3" 
calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A19]=[.B19]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A19])" office:value-type="string" 
office:string-value="=WEEKS($K$19,$K$20,0)" calcext:value-type="string">
+      <text:p>=WEEKS($K$19,$K$20,0)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145578</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="5"/>
+     <table:table-cell table:style-name="ce31" office:value-type="date" 
office:date-value="-0001-11-25" calcext:value-type="date">
+      <text:p>Sat -0001-11-27</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.$K$19];[.$K$20];1)" 
office:value-type="float" office:value="4" calcext:value-type="float">
+      <text:p>4</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="4" 
calcext:value-type="float">
+      <text:p>4</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A20]=[.B20]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A20])" office:value-type="string" 
office:string-value="=WEEKS($K$19,$K$20,1)" calcext:value-type="string">
+      <text:p>=WEEKS($K$19,$K$20,1)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145578</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce27"/>
+     <table:table-cell table:style-name="ce31" office:value-type="date" 
office:date-value="-0001-12-19" calcext:value-type="date">
+      <text:p>Tue -0001-12-21</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce27" 
table:number-columns-repeated="3"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J21];[.K21];[.M21])" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A21]=[.B21]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A21])" office:value-type="string" 
office:string-value="=WEEKS(J21,K21,M21)" calcext:value-type="string">
+      <text:p>=WEEKS(J21,K21,M21)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="0001-01-01" calcext:value-type="date">
+      <text:p>01/03/1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-29" calcext:value-type="date">
+      <text:p>12/31/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J22];[.K22];[.M22])" 
office:value-type="float" office:value="-1" calcext:value-type="float">
+      <text:p>-1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="-1" 
calcext:value-type="float">
+      <text:p>-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A22]=[.B22]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A22])" office:value-type="string" 
office:string-value="=WEEKS(J22,K22,M22)" calcext:value-type="string">
+      <text:p>=WEEKS(J22,K22,M22)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="0001-01-01" calcext:value-type="date">
+      <text:p>01/03/1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-29" calcext:value-type="date">
+      <text:p>12/31/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J23];[.K23];[.M23])" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A23]=[.B23]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A23])" office:value-type="string" 
office:string-value="=WEEKS(J23,K23,M23)" calcext:value-type="string">
+      <text:p>=WEEKS(J23,K23,M23)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-29" calcext:value-type="date">
+      <text:p>12/31/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="0001-01-01" calcext:value-type="date">
+      <text:p>01/03/1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J24];[.K24];[.M24])" 
office:value-type="float" office:value="1" calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A24]=[.B24]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A24])" office:value-type="string" 
office:string-value="=WEEKS(J24,K24,M24)" calcext:value-type="string">
+      <text:p>=WEEKS(J24,K24,M24)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-29" calcext:value-type="date">
+      <text:p>12/31/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="0001-01-01" calcext:value-type="date">
+      <text:p>01/03/1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J25];[.K25];[.M25])" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A25]=[.B25]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A25])" office:value-type="string" 
office:string-value="=WEEKS(J25,K25,M25)" calcext:value-type="string">
+      <text:p>=WEEKS(J25,K25,M25)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="0001-01-05" calcext:value-type="date">
+      <text:p>01/07/1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="0001-01-08" calcext:value-type="date">
+      <text:p>01/10/1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce27"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J26];[.K26];[.M26])" 
office:value-type="float" office:value="1" calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A26]=[.B26]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A26])" office:value-type="string" 
office:string-value="=WEEKS(J26,K26,M26)" calcext:value-type="string">
+      <text:p>=WEEKS(J26,K26,M26)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="0001-01-05" calcext:value-type="date">
+      <text:p>01/07/1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="0001-01-08" calcext:value-type="date">
+      <text:p>01/10/1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J27];[.K27];[.M27])" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A27]=[.B27]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A27])" office:value-type="string" 
office:string-value="=WEEKS(J27,K27,M27)" calcext:value-type="string">
+      <text:p>=WEEKS(J27,K27,M27)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-22" calcext:value-type="date">
+      <text:p>12/24/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-25" calcext:value-type="date">
+      <text:p>12/27/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J28];[.K28];[.M28])" 
office:value-type="float" office:value="1" calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A28]=[.B28]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A28])" office:value-type="string" 
office:string-value="=WEEKS(J28,K28,M28)" calcext:value-type="string">
+      <text:p>=WEEKS(J28,K28,M28)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-22" calcext:value-type="date">
+      <text:p>12/24/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-25" calcext:value-type="date">
+      <text:p>12/27/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J29];[.K29];[.M29])" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A29]=[.B29]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A29])" office:value-type="string" 
office:string-value="=WEEKS(J29,K29,M29)" calcext:value-type="string">
+      <text:p>=WEEKS(J29,K29,M29)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-15" calcext:value-type="date">
+      <text:p>12/17/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-18" calcext:value-type="date">
+      <text:p>12/20/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J30];[.K30];[.M30])" 
office:value-type="float" office:value="1" calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A30]=[.B30]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A30])" office:value-type="string" 
office:string-value="=WEEKS(J30,K30,M30)" calcext:value-type="string">
+      <text:p>=WEEKS(J30,K30,M30)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-15" calcext:value-type="date">
+      <text:p>12/17/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-18" calcext:value-type="date">
+      <text:p>12/20/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J31];[.K31];[.M31])" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A31]=[.B31]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A31])" office:value-type="string" 
office:string-value="=WEEKS(J31,K31,M31)" calcext:value-type="string">
+      <text:p>=WEEKS(J31,K31,M31)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-31" calcext:value-type="date">
+      <text:p>01/02/1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-29" calcext:value-type="date">
+      <text:p>12/31/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J32];[.K32];[.M32])" 
office:value-type="float" office:value="0" calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A32]=[.B32]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A32])" office:value-type="string" 
office:string-value="=WEEKS(J32,K32,M32)" calcext:value-type="string">
+      <text:p>=WEEKS(J32,K32,M32)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-31" calcext:value-type="date">
+      <text:p>01/02/1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-29" calcext:value-type="date">
+      <text:p>12/31/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J33];[.K33];[.M33])" 
office:value-type="float" office:value="2" calcext:value-type="float">
+      <text:p>2</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="2" 
calcext:value-type="float">
+      <text:p>2</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A33]=[.B33]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A33])" office:value-type="string" 
office:string-value="=WEEKS(J33,K33,M33)" calcext:value-type="string">
+      <text:p>=WEEKS(J33,K33,M33)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-03" calcext:value-type="date">
+      <text:p>12/05/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-22" calcext:value-type="date">
+      <text:p>12/24/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J34];[.K34];[.M34])" 
office:value-type="float" office:value="3" calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="3" 
calcext:value-type="float">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A34]=[.B34]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A34])" office:value-type="string" 
office:string-value="=WEEKS(J34,K34,M34)" calcext:value-type="string">
+      <text:p>=WEEKS(J34,K34,M34)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-03" calcext:value-type="date">
+      <text:p>12/05/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-22" calcext:value-type="date">
+      <text:p>12/24/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J35];[.K35];[.M35])" 
office:value-type="float" office:value="1" calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A35]=[.B35]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A35])" office:value-type="string" 
office:string-value="=WEEKS(J35,K35,M35)" calcext:value-type="string">
+      <text:p>=WEEKS(J35,K35,M35)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-03" calcext:value-type="date">
+      <text:p>12/05/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-15" calcext:value-type="date">
+      <text:p>12/17/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="0" 
calcext:value-type="float">
+      <text:p>0</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2">
+     <table:table-cell 
table:formula="of:=ORG.OPENOFFICE.WEEKS([.J36];[.K36];[.M36])" 
office:value-type="float" office:value="2" calcext:value-type="float">
+      <text:p>2</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="float" office:value="2" 
calcext:value-type="float">
+      <text:p>2</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce18" 
table:formula="of:=[.A36]=[.B36]" office:value-type="boolean" 
office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>TRUE</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce26" 
table:formula="of:=FORMULA([.A36])" office:value-type="string" 
office:string-value="=WEEKS(J36,K36,M36)" calcext:value-type="string">
+      <text:p>=WEEKS(J36,K36,M36)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>tdf#145587</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-03" calcext:value-type="date">
+      <text:p>12/05/-1</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce38" office:value-type="date" 
office:date-value="-0001-12-15" calcext:value-type="date">
+      <text:p>12/17/-1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+     <table:table-cell office:value-type="float" office:value="1" 
calcext:value-type="float">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2" table:number-rows-repeated="2">
+     <table:table-cell table:style-name="ce31" 
table:number-columns-repeated="2"/>
+     <table:table-cell table:style-name="Default"/>
+     <table:table-cell table:style-name="ce37"/>
+     <table:table-cell table:number-columns-repeated="10"/>
+    </table:table-row>
     <table:table-row table:style-name="ro2" table:number-rows-repeated="2">
      <table:table-cell table:number-columns-repeated="2"/>
      <table:table-cell table:style-name="ce20"/>
@@ -1150,7 +1782,7 @@
      <table:table-cell table:number-columns-repeated="14"/>
     </table:table-row>
     <calcext:conditional-formats>
-     <calcext:conditional-format 
calcext:target-range-address="Sheet2.C29:Sheet2.C100 Sheet2.C20:Sheet2.C27 
Sheet2.C2:Sheet2.C3 Sheet2.C14:Sheet2.C15 Sheet2.C18:Sheet2.C18">
+     <calcext:conditional-format 
calcext:target-range-address="Sheet2.C2:Sheet2.C100">
       <calcext:condition calcext:apply-style-name="Default" 
calcext:value="=&quot;&quot;" calcext:base-cell-address="Sheet2.C2"/>
       <calcext:condition calcext:apply-style-name="Untitled1" 
calcext:value="=0" calcext:base-cell-address="Sheet2.C2"/>
       <calcext:condition calcext:apply-style-name="Untitled2" 
calcext:value="=1" calcext:base-cell-address="Sheet2.C2"/>
@@ -1203,4 +1835,4 @@
    </table:named-expressions>
   </office:spreadsheet>
  </office:body>
-</office:document>
\ No newline at end of file
+</office:document>
diff --git a/scaddins/source/datefunc/datefunc.cxx 
b/scaddins/source/datefunc/datefunc.cxx
index dc015e5ef0bd..fc6ecff83791 100644
--- a/scaddins/source/datefunc/datefunc.cxx
+++ b/scaddins/source/datefunc/datefunc.cxx
@@ -28,6 +28,7 @@
 #include <unotools/resmgr.hxx>
 #include <i18nlangtag/languagetag.hxx>
 #include <algorithm>
+#include <cmath>
 #include "deffuncname.hxx"
 
 using namespace ::com::sun::star;
@@ -444,49 +445,19 @@ sal_Int32 GetNullDate( const uno::Reference< 
beans::XPropertySet >& xOptions )
  * new Weeks(date1,date2,mode) function for StarCalc
  *
  * Two modes of operation are provided.
- * The first is just a simple division by 7 calculation.
+ * mode 0 is just a simple division by 7 calculation.
  *
- * The second calculates the difference by week of year.
+ * mode 1 calculates the difference by week adhering to ISO8601.
  *
- * The International Standard IS-8601 has decreed that Monday
- * shall be the first day of the week.
- *
- * A week that lies partly in one year and partly in another
- * is assigned a number in the year in which most of its days lie.
- *
- * That means that week 1 of any year is the week that contains the 4. January
- *
- * The internal representation of a Date used in the Addin is the number of 
days based on 01/01/0001
- *
- * A WeekDay can be then calculated by subtracting 1 and calculating the rest 
of
- * a division by 7, which gives a 0 - 6 value for Monday - Sunday
- *
- * Using the 4. January rule explained above the formula
- *
- *  nWeek1= ( nDays1 - nJan4 + ( (nJan4-1) % 7 ) ) / 7 + 1;
- *
- * calculates a number between 0-53 for each day which is in the same year as 
nJan4
- * where 0 means that this week belonged to the year before.
- *
- * If a day in the same or another year is used in this formula this calculates
- * a calendar week offset from a given 4. January
- *
- *  nWeek2 = ( nDays2 - nJan4 + ( (nJan4-1) % 7 ) ) / 7 + 1;
- *
- * The 4.January of first Date Argument can thus be used to calculate
- * the week difference by calendar weeks which is then nWeek = nWeek2 - nWeek1
- *
- * which can be optimized to
+ * The International Standard IS-8601 states that Monday is the first
+ * day of the week. The Gregorian Calender is used for all dates,
+ * proleptic in case of dates before 1582-10-15.
  *
- * nWeek = ( (nDays2-nJan4+((nJan4-1)%7))/7 ) - ( 
(nDays1-nJan4+((nJan4-1)%7))/7 )
+ * The (consecutive) week number of a date is
+ * std::floor( (date + NullDate - 1), 7.0 ),
+ * with weeks starting on Monday.
  *
- * Note: All calculations are operating on the long integer data type
- * % is the modulo operator in C which calculates the rest of an Integer 
division
- *
- *
- * mode 0 is the interval between the dates in month, that is days / 7
- *
- * mode 1 is the difference by week of year
+ * Weeks(d2,d1,m) is defined as -Weeks(d1,d2,m).
  *
  */
 
@@ -498,26 +469,18 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDiffWeeks(
     if (nMode != 0 && nMode != 1)
         throw lang::IllegalArgumentException();
 
-    sal_Int32 nNullDate = GetNullDate( xOptions );
-
-    sal_Int32 nDays1 = nStartDate + nNullDate;
-    sal_Int32 nDays2 = nEndDate + nNullDate;
-
-    sal_Int32 nRet;
-
-    if ( nMode == 1 )
+    if ( nMode  == 0 )
     {
-        sal_uInt16 nDay,nMonth,nYear;
-        DaysToDate( nDays1, nDay, nMonth, nYear );
-        sal_Int32 nJan4 = DateToDays( 4, 1, nYear );
-
-        nRet = ( (nDays2-nJan4+((nJan4-1)%7))/7 ) - ( 
(nDays1-nJan4+((nJan4-1)%7))/7 );
+        return ( nEndDate - nStartDate ) / 7;
     }
     else
     {
-        nRet = (nDays2 - nDays1) / 7;
+        sal_Int32 nNullDate = GetNullDate( xOptions );
+        sal_Int32 nDays1 = nStartDate + nNullDate - 1;
+        sal_Int32 nDays2 = nEndDate + nNullDate - 1;
+
+        return ( std::floor( nDays2 / 7.0 ) - std::floor( nDays1 / 7.0 ) );
     }
-    return nRet;
 }
 
 /**

Reply via email to