tdf#171366: Calc: use the print dialog orientation on every page
- the printout lost rows when the user set Orientation to Landscape in
the File - Print dialog. Only the first page used the landscape paper.
The pages after it kept the portrait page breaks, so they took more rows
than fitted on the paper. The preview was correct, so only the paper and
the PDF showed the problem.
- ScModelObj::render() built a second ScPrintFunc after every page, so
that the document would hold the page style's page size again. That
object shared its page break vectors with m_pPrintState and recalculated
them for the portrait paper, so the next page read the wrong breaks.
render() now counts the pages once, after the last page.
- "tdf#166107: remove unnecessary resetPrintArea()" added the second
ScPrintFunc, https://gerrit.libreoffice.org/c/core/+/183948
(eccf4cd57a)
- sc::PrintPageRanges kept its results in a shared_ptr and its input by
value. One copy could recalculate the shared result while another copy
still read its own input as a match. PrintPageRanges shares the input
along with the results now.
- added testTdf171366 to check that the print dialog and the page style
split the sheet at the same rows.
Signed-off-by: Bayram Çiçek <bayram.cicek@collabora.com>
Change-Id: Ifa5998278ff899e713b439e33ed04d76f109fbc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210649
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
Tested-by: Jenkins
This commit is contained in:
committed by
Michael Stahl
parent
b2f721869d
commit
78cbe0b2fb
@@ -36,6 +36,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_uicalc2, \
|
||||
svx \
|
||||
svxcore \
|
||||
test \
|
||||
tk \
|
||||
tl \
|
||||
unotest \
|
||||
utl \
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.spreadsheet">
|
||||
<office:font-face-decls>
|
||||
<style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/>
|
||||
</office:font-face-decls>
|
||||
<office:styles>
|
||||
<style:default-style style:family="table-cell">
|
||||
<style:text-properties style:font-name="Liberation Sans" fo:font-size="10pt"/>
|
||||
</style:default-style>
|
||||
</office:styles>
|
||||
<office:automatic-styles>
|
||||
<style:style style:name="ta1" style:family="table" style:master-page-name="Default">
|
||||
<style:table-properties table:display="true" style:writing-mode="lr-tb"/>
|
||||
</style:style>
|
||||
<style:style style:name="co1" style:family="table-column">
|
||||
<style:table-column-properties style:column-width="2.258cm"/>
|
||||
</style:style>
|
||||
<style:style style:name="ro1" style:family="table-row">
|
||||
<style:table-row-properties style:row-height="4.52mm" style:use-optimal-row-height="false"/>
|
||||
</style:style>
|
||||
<style:page-layout style:name="pm1">
|
||||
<style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb"/>
|
||||
<style:header-style/>
|
||||
<style:footer-style/>
|
||||
</style:page-layout>
|
||||
</office:automatic-styles>
|
||||
<office:master-styles>
|
||||
<style:master-page style:name="Default" style:page-layout-name="pm1">
|
||||
<style:header display="false"/>
|
||||
<style:footer display="false"/>
|
||||
</style:master-page>
|
||||
</office:master-styles>
|
||||
<office:body>
|
||||
<office:spreadsheet>
|
||||
<table:table table:name="Sheet1" table:style-name="ta1">
|
||||
<table:table-column table:style-name="co1" table:default-cell-style-name="Default"/>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row1</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row2</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row3</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row4</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row5</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row6</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row7</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row8</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row9</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row10</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row11</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row12</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row13</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row14</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row15</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row16</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row17</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row18</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row19</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row20</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row21</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row22</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row23</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row24</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row25</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row26</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row27</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row28</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row29</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row30</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row31</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row32</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row33</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row34</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row35</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row36</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row37</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row38</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row39</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row40</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row41</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row42</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row43</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row44</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row45</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row46</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row47</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row48</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row49</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row50</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row51</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row52</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row53</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row54</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row55</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row56</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row57</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row58</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row59</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row60</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row61</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row62</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row63</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row64</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row65</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row66</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row67</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row68</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row69</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row70</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row71</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row72</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row73</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row74</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row75</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row76</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row77</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row78</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row79</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row80</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row81</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row82</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row83</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row84</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row85</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row86</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row87</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row88</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row89</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row90</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row91</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row92</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row93</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row94</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row95</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row96</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row97</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row98</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row99</text:p></table:table-cell></table:table-row>
|
||||
<table:table-row table:style-name="ro1"><table:table-cell office:value-type="string" calcext:value-type="string"><text:p>row100</text:p></table:table-cell></table:table-row>
|
||||
</table:table>
|
||||
</office:spreadsheet>
|
||||
</office:body>
|
||||
</office:document>
|
||||
@@ -14,23 +14,33 @@
|
||||
#include <editeng/editobj.hxx>
|
||||
#include <editeng/flditem.hxx>
|
||||
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
||||
#include <sfx2/printer.hxx>
|
||||
#include <sfx2/viewsh.hxx>
|
||||
#include <sot/exchange.hxx>
|
||||
#include <svx/svdpage.hxx>
|
||||
#include <toolkit/awt/vclxdevice.hxx>
|
||||
#include <tools/stream.hxx>
|
||||
#include <vcl/gdimtf.hxx>
|
||||
#include <vcl/keycodes.hxx>
|
||||
#include <vcl/metaact.hxx>
|
||||
#include <vcl/print.hxx>
|
||||
#include <vcl/scheduler.hxx>
|
||||
#include <stlsheet.hxx>
|
||||
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <comphelper/propertysequence.hxx>
|
||||
#include <comphelper/propertyvalue.hxx>
|
||||
#include <comphelper/sequence.hxx>
|
||||
#include <comphelper/servicehelper.hxx>
|
||||
#include <com/sun/star/awt/Key.hpp>
|
||||
#include <com/sun/star/awt/XDevice.hpp>
|
||||
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
|
||||
#include <com/sun/star/datatransfer/DataFlavor.hpp>
|
||||
#include <com/sun/star/datatransfer/XTransferable.hpp>
|
||||
#include <com/sun/star/sheet/GlobalSheetSettings.hpp>
|
||||
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
|
||||
#include <com/sun/star/text/XTextRange.hpp>
|
||||
#include <com/sun/star/view/XRenderable.hpp>
|
||||
#include <dbdata.hxx>
|
||||
#include <document.hxx>
|
||||
#include <docsh.hxx>
|
||||
@@ -2595,6 +2605,120 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testSetHyperlinkKeepSelection)
|
||||
CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, pURLField->GetRepresentation());
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// Prints the document once and collects the cell text of each page, in drawing order. The
|
||||
// printer records into a metafile, so this is the text that would have reached the paper.
|
||||
std::vector<std::vector<OUString>>
|
||||
lcl_getPrintedPages(const uno::Reference<lang::XComponent>& xComponent, Printer* pPrinter)
|
||||
{
|
||||
rtl::Reference<VCLXDevice> pVclDevice = new VCLXDevice();
|
||||
pVclDevice->SetOutputDevice(pPrinter);
|
||||
|
||||
uno::Reference<view::XRenderable> xRenderable(xComponent, uno::UNO_QUERY_THROW);
|
||||
css::uno::Any aSelection(xComponent);
|
||||
|
||||
std::vector<beans::PropertyValue> aOptions{
|
||||
comphelper::makePropertyValue(u"RenderDevice"_ustr,
|
||||
uno::Reference<awt::XDevice>(pVclDevice)),
|
||||
comphelper::makePropertyValue(u"IsPrinter"_ustr, true),
|
||||
comphelper::makePropertyValue(u"IsLastPage"_ustr, false),
|
||||
};
|
||||
|
||||
sal_Int32 nPages
|
||||
= xRenderable->getRendererCount(aSelection, comphelper::containerToSequence(aOptions));
|
||||
|
||||
std::vector<std::vector<OUString>> aPages;
|
||||
for (sal_Int32 nPage = 0; nPage < nPages; ++nPage)
|
||||
{
|
||||
aOptions.back().Value <<= (nPage + 1 == nPages);
|
||||
css::uno::Sequence<beans::PropertyValue> aSequence
|
||||
= comphelper::containerToSequence(aOptions);
|
||||
|
||||
GDIMetaFile aMetaFile;
|
||||
pPrinter->SetConnectMetaFile(&aMetaFile);
|
||||
xRenderable->getRenderer(nPage, aSelection, aSequence);
|
||||
xRenderable->render(nPage, aSelection, aSequence);
|
||||
pPrinter->SetConnectMetaFile(nullptr);
|
||||
|
||||
std::vector<OUString> aTexts;
|
||||
for (size_t nAction = 0; nAction < aMetaFile.GetActionSize(); ++nAction)
|
||||
{
|
||||
MetaAction* pAction = aMetaFile.GetAction(nAction);
|
||||
OUString aText;
|
||||
if (pAction->GetType() == MetaActionType::TEXTARRAY)
|
||||
aText = static_cast<MetaTextArrayAction*>(pAction)->GetText();
|
||||
else if (pAction->GetType() == MetaActionType::TEXT)
|
||||
aText = static_cast<MetaTextAction*>(pAction)->GetText();
|
||||
else if (pAction->GetType() == MetaActionType::STRETCHTEXT)
|
||||
aText = static_cast<MetaStretchTextAction*>(pAction)->GetText();
|
||||
if (aText.startsWith(u"row"))
|
||||
aTexts.push_back(aText);
|
||||
}
|
||||
aPages.push_back(std::move(aTexts));
|
||||
}
|
||||
return aPages;
|
||||
}
|
||||
|
||||
// Names the first and the last cell of every page on one line. A failure then shows which rows
|
||||
// each page carried.
|
||||
OUString lcl_describePages(const std::vector<std::vector<OUString>>& rPages)
|
||||
{
|
||||
OUStringBuffer aBuffer;
|
||||
for (const auto& rPage : rPages)
|
||||
{
|
||||
if (!aBuffer.isEmpty())
|
||||
aBuffer.append(" ");
|
||||
if (rPage.empty())
|
||||
aBuffer.append("empty");
|
||||
else
|
||||
aBuffer.append(rPage.front() + ".." + rPage.back());
|
||||
}
|
||||
return aBuffer.makeStringAndClear();
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(ScUiCalcTest2, testTdf171366)
|
||||
{
|
||||
// The sheet holds 100 rows on A4 portrait paper. That is few enough per landscape page that
|
||||
// the two orientations break the sheet at different rows.
|
||||
createScDoc("tdf171366.fods");
|
||||
|
||||
// The view shell hands back the document's own printer, which is the one a print job uses.
|
||||
SfxViewShell* pViewShell = getViewShell();
|
||||
SfxPrinter* pPrinter = pViewShell->GetPrinter(true);
|
||||
CPPUNIT_ASSERT(pPrinter);
|
||||
|
||||
// The Print Dialog turns the paper size itself and hands it on in 1/100 mm.
|
||||
const Size aTurnedPaper(29700, 21001);
|
||||
|
||||
// The user chooses Landscape in the Print Dialog. The dialog gives the printer the turned
|
||||
// size and marks the printer as carrying a setting of its own.
|
||||
pPrinter->SetPrintPageSize(aTurnedPaper);
|
||||
pPrinter->SetOrientation(Orientation::Landscape);
|
||||
pPrinter->SetUsePrintDialogSetting(true);
|
||||
const OUString aFromDialog = lcl_describePages(lcl_getPrintedPages(mxComponent, pPrinter));
|
||||
|
||||
// The user makes the same turn in Format - Page Style instead. That path always worked.
|
||||
pPrinter->SetUsePrintDialogSetting(false);
|
||||
uno::Reference<style::XStyleFamiliesSupplier> xSupplier(mxComponent, uno::UNO_QUERY_THROW);
|
||||
uno::Reference<container::XNameAccess> xPageStyles(
|
||||
xSupplier->getStyleFamilies()->getByName(u"PageStyles"_ustr), uno::UNO_QUERY_THROW);
|
||||
uno::Reference<beans::XPropertySet> xPageStyle(xPageStyles->getByName(u"Default"_ustr),
|
||||
uno::UNO_QUERY_THROW);
|
||||
xPageStyle->setPropertyValue(u"IsLandscape"_ustr, css::uno::Any(true));
|
||||
xPageStyle->setPropertyValue(
|
||||
u"Size"_ustr, css::uno::Any(awt::Size(aTurnedPaper.Width(), aTurnedPaper.Height())));
|
||||
const OUString aFromPageStyle = lcl_describePages(lcl_getPrintedPages(mxComponent, pPrinter));
|
||||
|
||||
// Turning the paper in the Print Dialog splits the sheet the same way as turning it in the
|
||||
// page style. Without the accompanying fix, only the first page was laid out for landscape
|
||||
// paper and the rest kept the portrait splits, so this test failed with:
|
||||
// - Expected: row1..row37 row38..row74 row75..row100
|
||||
// - Actual : row1..row37 row57..row100 empty
|
||||
CPPUNIT_ASSERT_EQUAL(aFromPageStyle, aFromDialog);
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -174,7 +174,9 @@ public:
|
||||
size_t m_nPagesY;
|
||||
size_t m_nTotalY;
|
||||
|
||||
PrintPageRangesInput m_aInput;
|
||||
// The ranges above were calculated for this input. Every copy shares both, so the input
|
||||
// always matches the result.
|
||||
std::shared_ptr<PrintPageRangesInput> m_pInput;
|
||||
|
||||
void calculate(ScDocument& rDoc, PrintPageRangesInput const& rInput);
|
||||
};
|
||||
|
||||
@@ -2928,19 +2928,6 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
|
||||
|
||||
(void)pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart, true, nullptr );
|
||||
|
||||
if (pPrinter)
|
||||
{
|
||||
// reset the print area created by the Print Dialog to the page style's print area
|
||||
if (pPrinter->IsUsePrintDialogSetting())
|
||||
{
|
||||
bUsePrintDialogSetting = false;
|
||||
if (m_pPrintState && m_pPrintState->nPrintTab == nTab && !pSelRange)
|
||||
pPrintFunc.reset(new ScPrintFunc(pDev, *pDocShell, *m_pPrintState,
|
||||
&aStatus.GetOptions(), aPrintPageSize,
|
||||
bPrintPageLandscape, bUsePrintDialogSetting));
|
||||
}
|
||||
}
|
||||
|
||||
vcl::PDFExtOutDevData* pPDFData = dynamic_cast<vcl::PDFExtOutDevData*>(pDev->GetExtOutDevData());
|
||||
const bool bFinishTagging(pPDFData && pPDFData->GetIsExportTaggedPDF() && bIsLastPage);
|
||||
if (bFinishTagging)
|
||||
@@ -2956,6 +2943,12 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
|
||||
|
||||
if (bFinishTagging)
|
||||
lcl_PDFExportFinishTagging(*pPDFData);
|
||||
|
||||
// The document carried the Print Dialog's paper size and orientation for the length of the
|
||||
// job. A last count after the final page puts back the page size and the page breaks that
|
||||
// the page style describes.
|
||||
if (pPrinter && pPrinter->IsUsePrintDialogSetting() && bIsLastPage)
|
||||
pPrintFuncCache.reset(new ScPrintFuncCache(*pDocShell, aMark, aStatus));
|
||||
}
|
||||
|
||||
// XLinkTargetSupplier
|
||||
|
||||
@@ -3072,17 +3072,18 @@ PrintPageRanges::PrintPageRanges()
|
||||
: m_nPagesX(0)
|
||||
, m_nPagesY(0)
|
||||
, m_nTotalY(0)
|
||||
, m_pInput(std::make_shared<PrintPageRangesInput>())
|
||||
{}
|
||||
|
||||
void PrintPageRanges::calculate(ScDocument& rDoc, PrintPageRangesInput const& rInput)
|
||||
{
|
||||
// Already calculated?
|
||||
if (m_aInput == rInput)
|
||||
if (*m_pInput == rInput)
|
||||
return;
|
||||
|
||||
m_aInput = rInput;
|
||||
*m_pInput = rInput;
|
||||
|
||||
rDoc.SetPageSize(m_aInput.getPrintTab(), m_aInput.m_aDocSize);
|
||||
rDoc.SetPageSize(m_pInput->getPrintTab(), m_pInput->m_aDocSize);
|
||||
|
||||
// Clear the map to prevent any outdated values to "survive" when
|
||||
// we have to recalculate the new values anyway
|
||||
@@ -3094,17 +3095,18 @@ void PrintPageRanges::calculate(ScDocument& rDoc, PrintPageRangesInput const& rI
|
||||
m_xPageEndX->resize(rDoc.MaxCol()+1, SCCOL());
|
||||
}
|
||||
|
||||
if (m_aInput.m_bPrintArea)
|
||||
if (m_pInput->m_bPrintArea)
|
||||
{
|
||||
ScRange aRange(m_aInput.getStartColumn(), m_aInput.getStartRow(), m_aInput.getPrintTab(), m_aInput.getEndColumn(), m_aInput.getEndRow(), m_aInput.getPrintTab());
|
||||
rDoc.UpdatePageBreaks(m_aInput.getPrintTab(), &aRange);
|
||||
ScRange aRange(m_pInput->getStartColumn(), m_pInput->getStartRow(), m_pInput->getPrintTab(),
|
||||
m_pInput->getEndColumn(), m_pInput->getEndRow(), m_pInput->getPrintTab());
|
||||
rDoc.UpdatePageBreaks(m_pInput->getPrintTab(), &aRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
rDoc.UpdatePageBreaks(m_aInput.getPrintTab()); // else, end is marked
|
||||
rDoc.UpdatePageBreaks(m_pInput->getPrintTab()); // else, end is marked
|
||||
}
|
||||
|
||||
const size_t nRealCnt = m_aInput.getEndRow() - m_aInput.getStartRow() + 1;
|
||||
const size_t nRealCnt = m_pInput->getEndRow() - m_pInput->getStartRow() + 1;
|
||||
|
||||
// #i123672# use dynamic mem to react on size changes
|
||||
if (m_xPageEndY->size() < nRealCnt+1)
|
||||
@@ -3120,11 +3122,11 @@ void PrintPageRanges::calculate(ScDocument& rDoc, PrintPageRangesInput const& rI
|
||||
m_nTotalY = 0;
|
||||
|
||||
bool bVisCol = false;
|
||||
for (SCCOL i = m_aInput.getStartColumn(); i <= m_aInput.getEndColumn(); i++)
|
||||
for (SCCOL i = m_pInput->getStartColumn(); i <= m_pInput->getEndColumn(); i++)
|
||||
{
|
||||
bool bHidden = rDoc.ColHidden(i, m_aInput.getPrintTab());
|
||||
bool bPageBreak(rDoc.HasColBreak(i, m_aInput.getPrintTab()) & ScBreakType::Page);
|
||||
if (i > m_aInput.getStartColumn() && bVisCol && bPageBreak)
|
||||
bool bHidden = rDoc.ColHidden(i, m_pInput->getPrintTab());
|
||||
bool bPageBreak(rDoc.HasColBreak(i, m_pInput->getPrintTab()) & ScBreakType::Page);
|
||||
if (i > m_pInput->getStartColumn() && bVisCol && bPageBreak)
|
||||
{
|
||||
OSL_ENSURE(m_nPagesX < m_xPageEndX->size(), "vector access error for aPageEndX");
|
||||
(*m_xPageEndX)[m_nPagesX] = i-1;
|
||||
@@ -3137,40 +3139,45 @@ void PrintPageRanges::calculate(ScDocument& rDoc, PrintPageRangesInput const& rI
|
||||
if (bVisCol) // also at the end, no empty pages
|
||||
{
|
||||
OSL_ENSURE(m_nPagesX < m_xPageEndX->size(), "vector access error for aPageEndX");
|
||||
(*m_xPageEndX)[m_nPagesX] = m_aInput.getEndColumn();
|
||||
(*m_xPageEndX)[m_nPagesX] = m_pInput->getEndColumn();
|
||||
++m_nPagesX;
|
||||
}
|
||||
|
||||
bool bVisRow = false;
|
||||
SCROW nPageStartRow = m_aInput.getStartRow();
|
||||
SCROW nPageStartRow = m_pInput->getStartRow();
|
||||
SCROW nLastVisibleRow = -1;
|
||||
|
||||
std::unique_ptr<ScRowBreakIterator> pRowBreakIter(rDoc.GetRowBreakIterator(m_aInput.getPrintTab()));
|
||||
std::unique_ptr<ScRowBreakIterator> pRowBreakIter(
|
||||
rDoc.GetRowBreakIterator(m_pInput->getPrintTab()));
|
||||
SCROW nNextPageBreak = pRowBreakIter->first();
|
||||
while (nNextPageBreak != ScRowBreakIterator::NOT_FOUND && nNextPageBreak < m_aInput.getStartRow())
|
||||
while (nNextPageBreak != ScRowBreakIterator::NOT_FOUND
|
||||
&& nNextPageBreak < m_pInput->getStartRow())
|
||||
// Skip until the page break position is at the start row or greater.
|
||||
nNextPageBreak = pRowBreakIter->next();
|
||||
|
||||
for (SCROW nRow = m_aInput.getStartRow(); nRow <= m_aInput.getEndRow(); ++nRow)
|
||||
for (SCROW nRow = m_pInput->getStartRow(); nRow <= m_pInput->getEndRow(); ++nRow)
|
||||
{
|
||||
bool bPageBreak = (nNextPageBreak == nRow);
|
||||
if (bPageBreak)
|
||||
nNextPageBreak = pRowBreakIter->next();
|
||||
|
||||
if (nRow > m_aInput.getStartRow() && bVisRow && bPageBreak)
|
||||
if (nRow > m_pInput->getStartRow() && bVisRow && bPageBreak)
|
||||
{
|
||||
OSL_ENSURE(m_nTotalY < m_xPageEndY->size(), "vector access error for rPageEndY");
|
||||
(*m_xPageEndY)[m_nTotalY] = nRow - 1;
|
||||
++m_nTotalY;
|
||||
|
||||
if (!m_aInput.m_bSkipEmpty || !rDoc.IsPrintEmpty(m_aInput.getStartColumn(), nPageStartRow, m_aInput.getEndColumn(), nRow-1, m_aInput.getPrintTab()))
|
||||
if (!m_pInput->m_bSkipEmpty
|
||||
|| !rDoc.IsPrintEmpty(m_pInput->getStartColumn(), nPageStartRow,
|
||||
m_pInput->getEndColumn(), nRow-1, m_pInput->getPrintTab()))
|
||||
{
|
||||
auto& rPageRow = (*m_xPageRows)[m_nPagesY];
|
||||
rPageRow.SetStartRow(nPageStartRow);
|
||||
rPageRow.SetEndRow(nRow - 1);
|
||||
rPageRow.SetPagesX(m_nPagesX);
|
||||
if (m_aInput.m_bSkipEmpty)
|
||||
lcl_SetHidden(rDoc, m_aInput.getPrintTab(), rPageRow, m_aInput.getStartColumn(), *m_xPageEndX);
|
||||
if (m_pInput->m_bSkipEmpty)
|
||||
lcl_SetHidden(rDoc, m_pInput->getPrintTab(), rPageRow,
|
||||
m_pInput->getStartColumn(), *m_xPageEndX);
|
||||
++m_nPagesY;
|
||||
}
|
||||
|
||||
@@ -3187,7 +3194,7 @@ void PrintPageRanges::calculate(ScDocument& rDoc, PrintPageRangesInput const& rI
|
||||
}
|
||||
|
||||
SCROW nLastRow = -1;
|
||||
if (!rDoc.RowHidden(nRow, m_aInput.getPrintTab(), nullptr, &nLastRow))
|
||||
if (!rDoc.RowHidden(nRow, m_pInput->getPrintTab(), nullptr, &nLastRow))
|
||||
{
|
||||
bVisRow = true;
|
||||
nLastVisibleRow = nLastRow;
|
||||
@@ -3204,17 +3211,20 @@ void PrintPageRanges::calculate(ScDocument& rDoc, PrintPageRangesInput const& rI
|
||||
return;
|
||||
|
||||
OSL_ENSURE(m_nTotalY < m_xPageEndY->size(), "vector access error for maPageEndY");
|
||||
(*m_xPageEndY)[m_nTotalY] = m_aInput.getEndRow();
|
||||
(*m_xPageEndY)[m_nTotalY] = m_pInput->getEndRow();
|
||||
++m_nTotalY;
|
||||
|
||||
if (!m_aInput.m_bSkipEmpty || !rDoc.IsPrintEmpty(m_aInput.getStartColumn(), nPageStartRow, m_aInput.getEndColumn(), m_aInput.getEndRow(), m_aInput.getPrintTab()))
|
||||
if (!m_pInput->m_bSkipEmpty
|
||||
|| !rDoc.IsPrintEmpty(m_pInput->getStartColumn(), nPageStartRow, m_pInput->getEndColumn(),
|
||||
m_pInput->getEndRow(), m_pInput->getPrintTab()))
|
||||
{
|
||||
auto& rPageRow = (*m_xPageRows)[m_nPagesY];
|
||||
rPageRow.SetStartRow(nPageStartRow);
|
||||
rPageRow.SetEndRow(m_aInput.getEndRow());
|
||||
rPageRow.SetEndRow(m_pInput->getEndRow());
|
||||
rPageRow.SetPagesX(m_nPagesX);
|
||||
if (m_aInput.m_bSkipEmpty)
|
||||
lcl_SetHidden(rDoc, m_aInput.getPrintTab(), rPageRow, m_aInput.getStartColumn(), *m_xPageEndX);
|
||||
if (m_pInput->m_bSkipEmpty)
|
||||
lcl_SetHidden(rDoc, m_pInput->getPrintTab(), rPageRow, m_pInput->getStartColumn(),
|
||||
*m_xPageEndX);
|
||||
++m_nPagesY;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user