]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed a problem with unrecognised paper id conversions
authorJulian Smart <julian@anthemion.co.uk>
Wed, 20 May 2009 11:56:49 +0000 (11:56 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 20 May 2009 11:56:49 +0000 (11:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/paper.cpp

index 18587e9b53a78212c66b695477a927e09b91c879..368d3a51c8f39ce8cce44c6015ac63e2a44821ef 100644 (file)
@@ -246,12 +246,16 @@ wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const wxString& name)
 
 wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(wxPaperSize id)
 {
-    typedef wxStringToPrintPaperTypeHashMap::iterator iterator;
-
-    for (iterator it = m_map->begin(), en = m_map->end(); it != en; ++it)
+    // Take the item ordering into account so that the more common types
+    // are likely to be taken into account first. This fixes problems with,
+    // for example, Letter reverting to A4 in the page setup dialog because
+    // it was wrongly translated to Note.
+    size_t i;
+    for (i = 0; i < GetCount(); i++)
     {
-        wxPrintPaperType* paperType = it->second;
-        if (paperType->GetId() == id)
+        wxPrintPaperType* paperType = Item(i);
+        wxSize paperSize = paperType->GetSize() ;
+        if ( abs( paperSize.x - sz.x ) < 10 && abs( paperSize.y - sz.y ) < 10 )
             return paperType;
     }