[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - 2 commits - sc/source

2017-12-13 Thread Tomaž Vajngerl
 sc/source/ui/inc/printfun.hxx  |   35 ---
 sc/source/ui/unoobj/docuno.cxx |4 +-
 sc/source/ui/view/printfun.cxx |   61 +
 3 files changed, 77 insertions(+), 23 deletions(-)

New commits:
commit c542db6e3b2d7b881b52565cdcb6fdf9d849
Author: Tomaž Vajngerl 
Date:   Tue Dec 12 22:24:45 2017 +0900

tdf#114384 reset the print state if the sheet changes

Reviewed-on: https://gerrit.libreoffice.org/46301
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit c7a2538129f16ef1253ae974737d5c9676aaf883)

Change-Id: Ia90a2bae0dab3d82cae1204a9205f386f71e5c49
Reviewed-on: https://gerrit.libreoffice.org/46375
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 286f9a407b54..8776c6490e49 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1561,7 +1561,7 @@ uno::Sequence SAL_CALL 
ScModelObj::getRenderer( sal_Int32
 }
 
 std::unique_ptr pPrintFunc;
-if (m_pPrintState)
+if (m_pPrintState && m_pPrintState->nPrintTab == nTab)
 pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), 
*m_pPrintState, ()));
 else
 pPrintFunc.reset(new ScPrintFunc(pDocShell, pDocShell->GetPrinter(), 
nTab,
@@ -1673,7 +1673,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, 
const uno::Any& aSelec
 //  pages of the same sheet
 
 std::unique_ptr pPrintFunc;
-if (m_pPrintState)
+if (m_pPrintState && m_pPrintState->nPrintTab == nTab)
 pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, *m_pPrintState, 
()));
 else
 pPrintFunc.reset(new ScPrintFunc(pDev, pDocShell, nTab, 
pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, 
()));
commit dab029a384474c613709c86fa1bab133d6a900dd
Author: Tomaž Vajngerl 
Date:   Tue Dec 12 22:22:32 2017 +0900

tdf#114256 add cache criterium when to recalculate page range size

Page range size can only be valid for the input parameters, which
includes the document size, which was not taken into account at all
before. Now we look at all this parameters to decide if we need to
recalculate or not.

Change-Id: Ic52ad7516189b395c66f59aabc374c3da85f6a89
Reviewed-on: https://gerrit.libreoffice.org/46300
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 5217a2a0bf27e496cc429ee45dff7c239b466ae6)
Reviewed-on: https://gerrit.libreoffice.org/46374
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index ef8b370adae7..958ab4f28352 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -96,6 +96,28 @@ public:
 namespace sc
 {
 
+struct PrintPageRangesInput
+{
+bool m_bSkipEmpty;
+bool m_bPrintArea;
+SCROW m_nStartRow;
+SCROW m_nEndRow;
+SCCOL m_nStartCol;
+SCCOL m_nEndCol;
+SCTAB m_nPrintTab;
+Size  m_aDocSize;
+
+PrintPageRangesInput()
+: m_bSkipEmpty(false)
+, m_bPrintArea(false)
+, m_nStartRow(0)
+, m_nEndRow(0)
+, m_nStartCol(0)
+, m_nEndCol(0)
+, m_nPrintTab(0)
+{}
+};
+
 class PrintPageRanges
 {
 public:
@@ -109,12 +131,16 @@ public:
 size_t m_nPagesY;
 size_t m_nTotalY;
 
-bool m_bCalculated;
+PrintPageRangesInput m_aInput;
+
+bool checkIfAlreadyCalculatedAndSet(bool bSkipEmpty, bool bPrintArea,
+SCROW nStartRow, SCROW nEndRow,
+SCCOL nStartCol, SCCOL nEndCol,
+SCTAB nPrintTab, Size const & 
aDocSize);
 
-void calculate(ScDocument* pDoc, ScPageTableParam const & rTableParam,
-   ScPageAreaParam const & rAreaParam,
+void calculate(ScDocument* pDoc, bool bSkipEmpty, bool bPrintArea,
SCROW nStartRow, SCROW nEndRow, SCCOL nStartCol, SCCOL 
nEndCol,
-   SCTAB nPrintTab);
+   SCTAB nPrintTab, Size const & aDocSize);
 };
 
 }
@@ -136,6 +162,7 @@ struct ScPrintState //  Save 
Variables from ScPrintFunc
 
 // Additional state of page ranges
 bool bSavedStateRanges;
+sc::PrintPageRangesInput aPrintPageRangesInput;
 size_t nTotalY;
 std::vector aPageEndX;
 std::vector aPageEndY;
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 2398f41ee45a..b15b0dd7ec2e 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -262,7 +262,7 @@ 

[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - 2 commits - sc/source

2017-12-13 Thread Tomaž Vajngerl
 sc/source/ui/inc/printfun.hxx  |  106 +--
 sc/source/ui/unoobj/docuno.cxx |   28 +++-
 sc/source/ui/view/printfun.cxx |  285 +
 3 files changed, 239 insertions(+), 180 deletions(-)

New commits:
commit 0321fdb0f73dcf41c502878131e9c580bdd9c6de
Author: Tomaž Vajngerl 
Date:   Sat Dec 2 01:17:15 2017 +0900

Calculate print page ranges only when needed, cache in print state

When printing or exporting PDF, we need to calculate the page
print (cell) ranges for the current zoom level (document size).
This is quite a expensive thing to do as you need to inspect
the properties of individual cells.
The calculation ideally needs to be done only once per printing
request, but because of the rendering UNO API, this was done
everytime ScPrintFunc was instantiated, which is for every page
twice (once getRenderer is called and then when render is called).
To fix this performance issue, the print page ranges need to be
carried from one call to ScPrintFunc to the other. There already
is a print state (ScPrintState) which is used for exactly that,
but it didn't do this for print page ranges.
With this, PDF export time in a test case decreased from 17 sec to
around 3 sec.

Reviewed-on: https://gerrit.libreoffice.org/45689
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 5684e53b931eaaac658bc3246ae1c3249e252fdb)

Change-Id: I97ade0e397960c5c98379e4bb28e57c5411ff757
Reviewed-on: https://gerrit.libreoffice.org/46373
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index 9a9f7ef44743..ef8b370adae7 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -65,6 +65,60 @@ struct ScPrintHFParam
 const SvxShadowItem* pShadow;
 };
 
+class ScPageRowEntry
+{
+private:
+SCROWnStartRow;
+SCROWnEndRow;
+size_t   nPagesX;
+std::vectoraHidden;
+//! Cache Number of really visible?
+
+public:
+ScPageRowEntry(){ nStartRow = nEndRow = 0; nPagesX = 0; }
+
+ScPageRowEntry(const ScPageRowEntry& r);
+ScPageRowEntry& operator=(const ScPageRowEntry& r);
+
+SCROW   GetStartRow() const { return nStartRow; }
+SCROW   GetEndRow() const   { return nEndRow; }
+size_t  GetPagesX() const   { return nPagesX; }
+voidSetStartRow(SCROW n){ nStartRow = n; }
+voidSetEndRow(SCROW n)  { nEndRow = n; }
+
+voidSetPagesX(size_t nNew);
+voidSetHidden(size_t nX);
+boolIsHidden(size_t nX) const;
+
+size_t  CountVisible() const;
+};
+
+namespace sc
+{
+
+class PrintPageRanges
+{
+public:
+PrintPageRanges();
+
+std::vector m_aPageEndX;
+std::vector m_aPageEndY;
+std::vector m_aPageRows;
+
+size_t m_nPagesX;
+size_t m_nPagesY;
+size_t m_nTotalY;
+
+bool m_bCalculated;
+
+void calculate(ScDocument* pDoc, ScPageTableParam const & rTableParam,
+   ScPageAreaParam const & rAreaParam,
+   SCROW nStartRow, SCROW nEndRow, SCCOL nStartCol, SCCOL 
nEndCol,
+   SCTAB nPrintTab);
+};
+
+}
+
 struct ScPrintState //  Save Variables from ScPrintFunc
 {
 SCTAB   nPrintTab;
@@ -79,6 +133,14 @@ struct ScPrintState //  Save 
Variables from ScPrintFunc
 longnTotalPages;
 longnPageStart;
 longnDocPages;
+
+// Additional state of page ranges
+bool bSavedStateRanges;
+size_t nTotalY;
+std::vector aPageEndX;
+std::vector aPageEndY;
+std::vector aPageRows;
+
 ScPrintState()
 : nPrintTab(0)
 , nStartCol(0)
@@ -92,37 +154,9 @@ struct ScPrintState //  Save 
Variables from ScPrintFunc
 , nTotalPages(0)
 , nPageStart(0)
 , nDocPages(0)
-{
-}
-};
-
-class ScPageRowEntry
-{
-private:
-SCROW   nStartRow;
-SCROW   nEndRow;
-size_t  nPagesX;
-std::vector aHidden;
-//! Cache Number of really visible?
-
-public:
-ScPageRowEntry(){ nStartRow = nEndRow = 0; nPagesX = 0; }
-~ScPageRowEntry()   { }
-
-ScPageRowEntry(const ScPageRowEntry& r);
-ScPageRowEntry& operator=(const ScPageRowEntry& r);
-
-SCROW   GetStartRow() const { return nStartRow; }
-SCROW   GetEndRow() const   { return nEndRow; }
-size_t  GetPagesX() const   { return nPagesX; }
-voidSetStartRow(SCROW n){ nStartRow = n; }
-voidSetEndRow(SCROW n)  { nEndRow = n; }
-
-voidSetPagesX(size_t nNew);
-voidSetHidden(size_t nX);
-boolIsHidden(size_t nX) 

[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - 2 commits - sc/source sw/qa sw/source

2017-11-09 Thread Andreas Brandner
Rebased ref, commits from common ancestor:
commit 42327130ab4455eb4fc6f487873cbf83ce21223b
Author: Andreas Brandner 
Date:   Sun Nov 5 20:41:31 2017 +0100

tdf#66401 don't lose docx-combined-characters' font props on roundtrip

- font-size will now get halfed, if exported within a 
combined-characters-field in docx
- font-property will get exported for every run in a field, this redundancy 
is required by MS Word

Change-Id: Idbdb5bf3066e2ed86b494255d72d66eebf72f755
Reviewed-on: https://gerrit.libreoffice.org/44509
Reviewed-by: Thorsten Behrens 
Tested-by: Thorsten Behrens 

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 467177d013fa..e8cdfc86182c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1740,12 +1740,18 @@ void DocxAttributeOutput::DoWriteCmd( const OUString& 
rCmd )
 
 void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 
nPos, FieldInfos const & rInfos, bool bWriteRun )
 {
+bool bWriteCombChars(false);
+
 // Write the Field instruction
 {
 if ( bWriteRun )
 {
 m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
-DoWriteFieldRunProperties( pNode, nPos );
+
+if (rInfos.eType == ww::eEQ)
+bWriteCombChars = true;
+
+DoWriteFieldRunProperties( pNode, nPos, bWriteCombChars );
 }
 
 sal_Int32 nNbToken = comphelper::string::getTokenCount(rInfos.sCmd, 
'\t');
@@ -1829,7 +1835,7 @@ void DocxAttributeOutput::CmdField_Impl( const 
SwTextNode* pNode, sal_Int32 nPos
 /// 
 /// 
 /// See, tdf#38778
-void DocxAttributeOutput::DoWriteFieldRunProperties( const SwTextNode * pNode, 
sal_Int32 nPos )
+void DocxAttributeOutput::DoWriteFieldRunProperties( const SwTextNode * pNode, 
sal_Int32 nPos, bool bWriteCombChars)
 {
 if (! pNode)
 {
@@ -1859,7 +1865,17 @@ void DocxAttributeOutput::DoWriteFieldRunProperties( 
const SwTextNode * pNode, s
 
 // 3. output all other character properties
 SwWW8AttrIter aAttrIt( m_rExport, *pNode );
-aAttrIt.OutAttr( nPos, false );
+aAttrIt.OutAttr( nPos, false, bWriteCombChars );
+
+// 4. explicitly write the font-properties, to ensure all runs in the 
field have them
+// see tdf#66401
+if ( m_pFontsAttrList.is() )
+{
+XFastAttributeListRef xAttrList( m_pFontsAttrList.get() );
+m_pFontsAttrList.clear();
+
+m_pSerializer->singleElementNS( XML_w, XML_rFonts, xAttrList );
+}
 
 m_pSerializer->endElementNS( XML_w, XML_rPr );
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 4c41f83d2f30..64fa4238e617 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -729,7 +729,7 @@ private:
 void DoWriteCmd( const OUString& rCmd );
 void CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos 
const & rInfos, bool bWriteRun );
 void EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& 
rInfos );
-void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos );
+void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos, 
bool bWriteCombChars = false );
 virtual void GenerateBookmarksForSequenceField(const SwTextNode& rNode, 
SwWW8AttrIter& rAttrIter) override;
 
 static void AddToAttrList( 
css::uno::Reference& pAttrList, sal_Int32 
nAttrName, const sal_Char* sAttrValue );
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index e9ba18f40d6f..33b67ea5e627 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -382,7 +382,7 @@ static bool lcl_isFontsizeItem( const SfxPoolItem& rItem )
 rItem.Which( ) == RES_CHRATR_CTL_FONTSIZE );
 }
 
-void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby )
+void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby , bool 
bWriteCombChars)
 {
 m_rExport.AttrOutput().RTLAndCJKState( IsCharRTL(), GetScript() );
 
@@ -488,7 +488,7 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby )
 // tdf#38778 Fix output of the font in DOC run for fields
 const SvxFontItem * pFontToOutput = ( rParentFont != *pFont )? pFont : 
nullptr;
 
-m_rExport.ExportPoolItemsToCHP( aExportItems, GetScript(), 
pFontToOutput );
+m_rExport.ExportPoolItemsToCHP( aExportItems, GetScript(), 
pFontToOutput, bWriteCombChars );
 
 // HasTextItem only allowed in the above range
 m_rExport.m_aCurrentCharPropStarts.pop();
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index dafffeaafd44..ff25dedd1c3e 100644
---