Commit 2c4c9b85 authored by Albert Astals Cid's avatar Albert Astals Cid

Merge link.cc changes from xpdf 3.00 -> 3.01

parent 4e9490c0
2005-09-20 Albert Astals Cid <aacid@kde.org>
* poppler/GlobalParams.[cc|h]: Merge from xpdf 3.01
* poppler/Link.cc: Merge from xpdf 3.01
2005-09-20 Marco Pesenti Gritti <mpg@redhat.com>
......
......@@ -119,14 +119,19 @@ GooString *LinkAction::getFileSpecName(Object *fileSpecObj) {
// dictionary
} else if (fileSpecObj->isDict()) {
#ifdef WIN32
if (!fileSpecObj->dictLookup("DOS", &obj1)->isString()) {
#else
if (!fileSpecObj->dictLookup("Unix", &obj1)->isString()) {
#endif
obj1.free();
fileSpecObj->dictLookup("F", &obj1);
}
if (obj1.isString())
if (obj1.isString()) {
name = obj1.getString()->copy();
else
} else {
error(-1, "Illegal file spec in link");
}
obj1.free();
// error
......@@ -134,6 +139,55 @@ GooString *LinkAction::getFileSpecName(Object *fileSpecObj) {
error(-1, "Illegal file spec in link");
}
// system-dependent path manipulation
if (name) {
#ifdef WIN32
int i, j;
// "//...." --> "\...."
// "/x/...." --> "x:\...."
// "/server/share/...." --> "\\server\share\...."
// convert escaped slashes to slashes and unescaped slashes to backslashes
i = 0;
if (name->getChar(0) == '/') {
if (name->getLength() >= 2 && name->getChar(1) == '/') {
name->del(0);
i = 0;
} else if (name->getLength() >= 2 &&
((name->getChar(1) >= 'a' && name->getChar(1) <= 'z') ||
(name->getChar(1) >= 'A' && name->getChar(1) <= 'Z')) &&
(name->getLength() == 2 || name->getChar(2) == '/')) {
name->setChar(0, name->getChar(1));
name->setChar(1, ':');
i = 2;
} else {
for (j = 2; j < name->getLength(); ++j) {
if (name->getChar(j-1) != '\\' &&
name->getChar(j) == '/') {
break;
}
}
if (j < name->getLength()) {
name->setChar(0, '\\');
name->insert(0, '\\');
i = 2;
}
}
}
for (; i < name->getLength(); ++i) {
if (name->getChar(i) == '/') {
name->setChar(i, '\\');
} else if (name->getChar(i) == '\\' &&
i+1 < name->getLength() &&
name->getChar(i+1) == '/') {
name->del(i);
}
}
#else
// no manipulation needed for Unix
#endif
}
return name;
}
......@@ -499,7 +553,7 @@ LinkURI::LinkURI(Object *uriObj, GooString *baseURI) {
uri = NULL;
if (uriObj->isString()) {
uri2 = uriObj->getString()->copy();
if (baseURI) {
if (baseURI && baseURI->getLength() > 0) {
n = strcspn(uri2->getCString(), "/:");
if (n == uri2->getLength() || uri2->getChar(n) == '/') {
uri = baseURI->copy();
......@@ -724,6 +778,10 @@ Link::Link(Dict *dict, GooString *baseURI) {
}
obj3.free();
}
} else {
// Adobe draws no border at all if the last element is of
// the wrong type.
borderWidth = 0;
}
obj2.free();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment