poppler/OptionalContent.h            |    6 +++---
 qt5/src/poppler-optcontent-private.h |    4 +++-
 qt5/src/poppler-optcontent.cc        |   10 ++++++----
 qt5/tests/check_optcontent.cpp       |   10 ++++++++++
 4 files changed, 22 insertions(+), 8 deletions(-)

New commits:
commit 65adf225eca287f63361cf49bd47388bff81af79
Author: Albert Astals Cid <[email protected]>
Date:   Thu May 16 17:20:55 2019 +0200

    qt5: Fix optional content handling with exclusive layers
    
    We were setting the "ui" value correctly, but not the "backend" one
    because we were shortcuting on obeyRadioGroups for the off state
    
    Update test to check also for the backend value

diff --git a/qt5/src/poppler-optcontent-private.h 
b/qt5/src/poppler-optcontent-private.h
index a134cd53..611c2870 100644
--- a/qt5/src/poppler-optcontent-private.h
+++ b/qt5/src/poppler-optcontent-private.h
@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2007, Brad Hards <[email protected]>
  * Copyright (C) 2008, Pino Toscano <[email protected]>
- * Copyright (C) 2016, 2018, Albert Astals Cid <[email protected]>
+ * Copyright (C) 2016, 2018, 2019, Albert Astals Cid <[email protected]>
  * Copyright (C) 2017, Hubert Figuière <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -77,6 +77,8 @@ namespace Poppler
 
     QSet<OptContentItem*> recurseListChildren(bool includeMe = false) const;
 
+    OptionalContentGroup *group() const { return m_group; }
+
     private:
     OptionalContentGroup *m_group;
     QString m_name;
diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc
index ebae31f3..49acd4a4 100644
--- a/qt5/src/poppler-optcontent.cc
+++ b/qt5/src/poppler-optcontent.cc
@@ -131,14 +131,16 @@ namespace Poppler
       child->m_enabled = state == OptContentItem::On;
       child->m_stateBackup = oldState;
     }
-    if (!m_group || !obeyRadioGroups) {
+    if (!m_group) {
       return;
     }
     if ( state == OptContentItem::On ) {
       m_group->setState( OptionalContentGroup::On );
-      for (int i = 0; i < m_rbGroups.size(); ++i) {
-        RadioButtonGroup *rbgroup = m_rbGroups.at(i);
-        changedItems += rbgroup->setItemOn( this );
+      if (obeyRadioGroups) {
+       for (int i = 0; i < m_rbGroups.size(); ++i) {
+         RadioButtonGroup *rbgroup = m_rbGroups.at(i);
+         changedItems += rbgroup->setItemOn( this );
+       }
       }
     } else if ( state == OptContentItem::Off ) {
       m_group->setState( OptionalContentGroup::Off );
diff --git a/qt5/tests/check_optcontent.cpp b/qt5/tests/check_optcontent.cpp
index eb5282ee..d1372307 100644
--- a/qt5/tests/check_optcontent.cpp
+++ b/qt5/tests/check_optcontent.cpp
@@ -4,6 +4,7 @@
 #include "GlobalParams.h"
 
 #include <poppler-qt5.h>
+#include <poppler-optcontent-private.h>
 
 class TestOptionalContent: public QObject
 {
@@ -399,14 +400,17 @@ void TestOptionalContent::checkRadioButtons()
     subindex = optContent->index( 0, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "English" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off 
);
 
     subindex = optContent->index( 2, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "Japanese" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Checked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::On );
 
     subindex = optContent->index( 1, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "French" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off 
);
 
     // and turning on French should turn off Japanese
     QVERIFY( optContent->setData( subindex, QVariant( true ), 
Qt::CheckStateRole ) );
@@ -414,14 +418,17 @@ void TestOptionalContent::checkRadioButtons()
     subindex = optContent->index( 0, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "English" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off 
);
 
     subindex = optContent->index( 2, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "Japanese" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off 
);
 
     subindex = optContent->index( 1, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "French" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Checked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::On );
 
 
     // and turning off French should leave them all off
@@ -430,14 +437,17 @@ void TestOptionalContent::checkRadioButtons()
     subindex = optContent->index( 0, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "English" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off 
);
 
     subindex = optContent->index( 2, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "Japanese" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off 
);
 
     subindex = optContent->index( 1, 0, index );
     QCOMPARE( optContent->data( subindex, Qt::DisplayRole ).toString(), 
QLatin1String( "French" ) );
     QCOMPARE( static_cast<Qt::CheckState>( optContent->data( subindex, 
Qt::CheckStateRole ).toInt() ), Qt::Unchecked );
+    QCOMPARE( static_cast<Poppler::OptContentItem 
*>(subindex.internalPointer())->group()->getState(), OptionalContentGroup::Off 
);
 
     delete doc;
 }
commit 157c723c0465bfa509dc499be46f3d6b8e3c7048
Author: Albert Astals Cid <[email protected]>
Date:   Thu May 16 17:19:48 2019 +0200

    OptionalContent: add some simple const

diff --git a/poppler/OptionalContent.h b/poppler/OptionalContent.h
index 29f50ab6..02619533 100644
--- a/poppler/OptionalContent.h
+++ b/poppler/OptionalContent.h
@@ -99,11 +99,11 @@ public:
   Ref getRef() const;
   void setRef(const Ref ref);
 
-  State getState() { return m_state; };
+  State getState() const { return m_state; };
   void setState(State state) { m_state = state; };
 
-  UsageState getViewState() { return viewState; }
-  UsageState getPrintState() { return printState; }
+  UsageState getViewState() const { return viewState; }
+  UsageState getPrintState() const { return printState; }
 
 private:
   GooString *m_name;
_______________________________________________
poppler mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to