Skip to content
Commits on Source (5)
pdfsam (4.0.4-1) unstable; urgency=medium
* New upstream version 4.0.4.
-- Markus Koschany <apo@debian.org> Tue, 10 Sep 2019 13:50:17 +0200
pdfsam (4.0.3-1) unstable; urgency=medium
* New upstream version 4.0.3.
......
......@@ -10,3 +10,4 @@ org.loadui testFx * * * *
org.mockito mockito-all * * * *
kr.motd.maven os-maven-plugin * * * *
org.testfx * * * * *
org.mockito mockito-core * * * *
# Dependencies are linked into the lib directory, works as intended
classpath-contains-relative-path
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.pdfsam</groupId>
<artifactId>pdfsam-parent</artifactId>
<version>4.0.3</version>
<version>4.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -70,7 +70,7 @@ public class AlternateMixModule extends BaseTaskExecutionModule {
.inputTypes(ModuleInputOutputType.MULTIPLE_PDF).name(DefaultI18nContext.getInstance().i18n("Alternate Mix"))
.description(DefaultI18nContext.getInstance()
.i18n("Merge two or more PDF documents taking pages alternately in natural or reverse order."))
.priority(ModulePriority.DEFAULT.getPriority()).supportURL("http://www.pdfsam.org/mix-pdf/").build();
.priority(ModulePriority.DEFAULT.getPriority()).supportURL("https://pdfsam.org/mix-pdf/").build();
@Inject
public AlternateMixModule(@Named(MODULE_ID + "field") BrowsablePdfOutputField destinationFileField,
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>org.pdfsam</groupId>
<artifactId>pdfsam-parent</artifactId>
<version>4.0.3</version>
<version>4.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.pdfsam</groupId>
<artifactId>pdfsam-parent</artifactId>
<version>4.0.3</version>
<version>4.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
/*
* This file is part of the PDF Split And Merge source code
* Created on 30 ago 2019
* Copyright 2019 by Sober Lemur S.a.s di Vacondio Andrea (info@pdfsam.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.pdfsam.pdf;
import static java.util.Optional.ofNullable;
import static org.pdfsam.support.RequireUtils.requireNotBlank;
import java.io.File;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.pdfsam.module.ModuleOwned;
/**
* A {@link File}s drop event to signal the user has dropped a file onto the the files selection component
*
* @author Andrea Vacondio
*
*/
public abstract class BaseFilesDroppedEvent implements ModuleOwned {
public final List<File> files;
private String ownerModule = StringUtils.EMPTY;
public BaseFilesDroppedEvent(String ownerModule, List<File> files) {
requireNotBlank(ownerModule, "Owner module cannot be blank");
this.ownerModule = ownerModule;
this.files = ofNullable(files).orElse(Collections.emptyList());
}
@Override
public String getOwnerModule() {
return ownerModule;
}
}
/*
* This file is part of the PDF Split And Merge source code
* Created on 31 ago 2019
* Copyright 2019 by Sober Lemur S.a.s di Vacondio Andrea (info@pdfsam.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.pdfsam.pdf;
import java.io.File;
import java.util.List;
/**
* Event for the multiple files drag and drop
*
* @author Andrea Vacondio
*
*/
public class MultipleFilesDroppedEvent extends BaseFilesDroppedEvent {
public MultipleFilesDroppedEvent(String ownerModule, List<File> files) {
super(ownerModule, files);
}
}
/*
* This file is part of the PDF Split And Merge source code
* Created on 31 ago 2019
* Copyright 2019 by Sober Lemur S.a.s di Vacondio Andrea (info@pdfsam.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.pdfsam.pdf;
import java.io.File;
import java.util.List;
/**
* Event for a single file dropped
*
* @author Andrea Vacondio
*
*/
public class SingleFileDroppedEvent extends BaseFilesDroppedEvent {
/**
* @param ownerModule
* @param files
*/
public SingleFileDroppedEvent(String ownerModule, List<File> files) {
super(ownerModule, files);
}
}
/*
* This file is part of the PDF Split And Merge source code
* Created on 24 lug 2019
* Copyright 2017 by Sober Lemur S.a.s di Vacondio Andrea (info@pdfsam.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.pdfsam.support.io;
import static java.util.Objects.isNull;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
/**
* @author Andrea Vacondio
*
*/
public class NetUtils {
/**
* https://stackoverflow.com/questions/1884230/urlconnection-doesnt-follow-redirect
*
* @param url
* @return
* @throws IOException
*/
public static InputStream urlToStream(URL url) throws IOException {
Map<String, Integer> visited = new HashMap<>();
while (true) {
if (visited.compute(url.toExternalForm(), (key, count) -> isNull(count) ? 1 : count++) > 3) {
throw new IOException("Too many redirects");
}
URLConnection conn = url.openConnection();
if (conn instanceof HttpURLConnection) {
HttpURLConnection connection = (HttpURLConnection) conn;
connection.setConnectTimeout(15000);
connection.setReadTimeout(15000);
connection.setInstanceFollowRedirects(false); // Make the logic below easier to detect redirections
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (PDFsam Basic)");
switch (connection.getResponseCode()) {
case HttpURLConnection.HTTP_MOVED_PERM:
case HttpURLConnection.HTTP_MOVED_TEMP:
String location = connection.getHeaderField("Location");
location = URLDecoder.decode(location, "UTF-8");
url = new URL(url, location); // Deal with relative URLs
connection.disconnect();
continue;
}
}
break;
}
return url.openStream();
}
}
......@@ -22,13 +22,13 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.sejda.model.parameter.base.AbstractParameters;
/**
* @author Andrea Vacondio
*
*/
@RunWith(value = org.mockito.runners.MockitoJUnitRunner.class)
@RunWith(value = MockitoJUnitRunner.class)
public class TaskExecutionRequestEventTest {
@Mock
private AbstractParameters params;
......
/*
* This file is part of the PDF Split And Merge source code
* Created on 30 ago 2019
* Copyright 2019 by Sober Lemur S.a.s di Vacondio Andrea (info@pdfsam.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.pdfsam.pdf;
import java.util.Collections;
import org.junit.Test;
/**
* @author Andrea Vacondio
*
*/
public class SingleFileDroppedEventTest {
@Test(expected = IllegalArgumentException.class)
public void blankModule() {
new SingleFileDroppedEvent(" ", Collections.emptyList());
}
@Test
public void valid() {
new SingleFileDroppedEvent("module", Collections.emptyList());
}
}
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.pdfsam</groupId>
<artifactId>pdfsam-parent</artifactId>
<version>4.0.3</version>
<version>4.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>org.pdfsam</groupId>
<artifactId>pdfsam-parent</artifactId>
<version>4.0.3</version>
<version>4.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -78,7 +78,7 @@ public class ExtractModule extends BaseTaskExecutionModule {
.inputTypes(ModuleInputOutputType.MULTIPLE_PDF, ModuleInputOutputType.SINGLE_PDF)
.name(DefaultI18nContext.getInstance().i18n("Extract"))
.description(DefaultI18nContext.getInstance().i18n("Extract pages from PDF documents."))
.priority(ModulePriority.DEFAULT.getPriority()).supportURL("http://www.pdfsam.org/pdf-extract-pages")
.priority(ModulePriority.DEFAULT.getPriority()).supportURL("https://pdfsam.org/pdf-extract-pages/")
.build();
@Inject
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.pdfsam</groupId>
<artifactId>pdfsam-parent</artifactId>
<version>4.0.3</version>
<version>4.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -143,6 +143,7 @@ public class PdfDestinationPane extends DestinationPane implements ModuleOwned,
public void resetView() {
super.resetView();
version.resetView();
compress.setSelected(false);
compress.setSelected(true);
discardBookmarks.ifPresent(c -> c.setSelected(false));
}
......@@ -182,6 +183,14 @@ public class PdfDestinationPane extends DestinationPane implements ModuleOwned,
.ifPresent(v -> this.version.getSelectionModel().select(v));
}
PdfVersionCombo getVersion() {
return version;
}
PdfVersionConstrainedCheckBox getCompress() {
return compress;
}
public static enum DestinationPanelFields {
DISCARD_BOOKMARKS;
}
......
......@@ -18,9 +18,11 @@
*/
package org.pdfsam.ui.io;
import static java.util.Optional.ofNullable;
import static org.sejda.eventstudio.StaticStudio.eventStudio;
import java.io.File;
import java.nio.file.Files;
import javafx.stage.DirectoryChooser;
import javafx.stage.Window;
......@@ -48,6 +50,10 @@ class RememberingLatestDirectoryChooserWrapper extends BaseRememberingLatestChoo
}
public File showDialog(Window ownerWindow) {
if (ofNullable(wrapped.getInitialDirectory()).map(File::toPath).filter(f -> !Files.isDirectory(f))
.isPresent()) {
wrapped.setInitialDirectory(null);
}
File selected = wrapped.showDialog(ownerWindow);
if (selected != null && selected.isDirectory()) {
eventStudio().broadcast(new SetLatestDirectoryEvent(selected));
......
......@@ -18,9 +18,11 @@
*/
package org.pdfsam.ui.io;
import static java.util.Optional.ofNullable;
import static org.sejda.eventstudio.StaticStudio.eventStudio;
import java.io.File;
import java.nio.file.Files;
import java.util.List;
import javafx.collections.ObservableList;
......@@ -55,6 +57,7 @@ public class RememberingLatestFileChooserWrapper extends BaseRememberingLatestCh
}
public List<File> showOpenMultipleDialog(Window ownerWindow) {
sanitizeInitialDirectory();
List<File> selected = wrapped.showOpenMultipleDialog(ownerWindow);
if (selected != null && !selected.isEmpty()) {
notifyNewLatestDirectory(selected.get(0));
......@@ -62,6 +65,13 @@ public class RememberingLatestFileChooserWrapper extends BaseRememberingLatestCh
return selected;
}
private void sanitizeInitialDirectory() {
if (ofNullable(wrapped.getInitialDirectory()).map(File::toPath).filter(f -> !Files.isDirectory(f))
.isPresent()) {
wrapped.setInitialDirectory(null);
}
}
/**
* Shows the file chooser dialog of the given type
*
......@@ -84,9 +94,11 @@ public class RememberingLatestFileChooserWrapper extends BaseRememberingLatestCh
File selected = null;
switch (type) {
case SAVE:
sanitizeInitialDirectory();
selected = wrapped.showSaveDialog(ownerWindow);
break;
default:
sanitizeInitialDirectory();
selected = wrapped.showOpenDialog(ownerWindow);
}
notifyNewLatestDirectory(selected);
......