Skip to content

Commit 5446eec

Browse files
committed
Fix issue with patterns in templates
If draw or fill patterns are used in templates they need to be registered with the template. Pattern references were missing from templates.
1 parent af8df8a commit 5446eec

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

include/wx/pdftemplate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class WXDLLIMPEXP_PDFDOC wxPdfTemplate
8181
wxPdfImageHashMap* m_images; ///< array of used images
8282
wxPdfTemplatesMap* m_templates; ///< array of templates
8383
wxPdfExtGStateMap* m_extGStates; ///< array of extended graphics states
84+
wxPdfPatternMap* m_patterns; ///< array of patterns
8485

8586
wxPdfParser* m_parser; ///< Associated parser
8687
wxPdfObject* m_resources; ///< Array of page resource objects

src/pdfdocument.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,6 +2557,10 @@ wxPdfDocument::SetDrawPattern(const wxString& name)
25572557
{
25582558
OutAscii(m_drawColour.GetColour(true));
25592559
}
2560+
if (m_inTemplate)
2561+
{
2562+
(*(m_currentTemplate->m_patterns))[pattern->first] = pattern->second;
2563+
}
25602564
}
25612565
else
25622566
{
@@ -2652,6 +2656,10 @@ wxPdfDocument::SetFillPattern(const wxString& name)
26522656
{
26532657
OutAscii(m_fillColour.GetColour(false));
26542658
}
2659+
if (m_inTemplate)
2660+
{
2661+
(*(m_currentTemplate->m_patterns))[pattern->first] = pattern->second;
2662+
}
26552663
}
26562664
else
26572665
{

src/pdfkernel.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,17 @@ wxPdfDocument::PutTemplates()
18431843
}
18441844
Out(">>");
18451845
}
1846+
// References to patterns
1847+
if (currentTemplate->m_patterns->size() > 0)
1848+
{
1849+
Out("/Pattern <<");
1850+
wxPdfPatternMap::iterator pattern;
1851+
for (pattern = currentTemplate->m_patterns->begin(); pattern != currentTemplate->m_patterns->end(); pattern++)
1852+
{
1853+
OutAscii(wxString::Format(wxS("/P%d %d 0 R"), pattern->second->GetIndex(), pattern->second->GetObjIndex()));
1854+
}
1855+
Out(">>");
1856+
}
18461857
Out(">>");
18471858
}
18481859

@@ -2424,10 +2435,10 @@ wxPdfDocument::PutResources()
24242435
PutShaders();
24252436
PutFonts();
24262437
PutImages();
2438+
PutPatterns();
24272439
PutTemplates();
24282440
PutImportedObjects();
24292441
PutSpotColours();
2430-
PutPatterns();
24312442
PutLayers();
24322443

24332444
// Resource dictionary

src/pdftemplate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ wxPdfTemplate::wxPdfTemplate(int templateId)
3535
m_images = new wxPdfImageHashMap();
3636
m_templates = new wxPdfTemplatesMap();
3737
m_extGStates = new wxPdfExtGStateMap();
38+
m_patterns = new wxPdfPatternMap();
3839

3940
m_parser = NULL;
4041
m_resources = NULL;
@@ -47,6 +48,7 @@ wxPdfTemplate::~wxPdfTemplate()
4748
delete m_images;
4849
delete m_templates;
4950
delete m_extGStates;
51+
delete m_patterns;
5052

5153
if (m_resources != NULL)
5254
{

0 commit comments

Comments
 (0)